[Very RFC 24/46] powernv/pci: Make the pre-cfg EEH freeze check use eeh_dev rather than pci_dn

Alexey Kardashevskiy aik at ozlabs.ru
Wed Nov 27 11:21:25 AEDT 2019



On 20/11/2019 12:28, Oliver O'Halloran wrote:
> Squash another usage in preperation for making the config accessors pci_dn.
> 
> Signed-off-by: Oliver O'Halloran <oohall at gmail.com>



Reviewed-by: Alexey Kardashevskiy <aik at ozlabs.ru>


> ---
> We might want to move this into eeh-powernv.c
> ---
>  arch/powerpc/platforms/powernv/pci.c | 37 +++++++++++++---------------
>  1 file changed, 17 insertions(+), 20 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
> index d36dde9777aa..6170677bfdc7 100644
> --- a/arch/powerpc/platforms/powernv/pci.c
> +++ b/arch/powerpc/platforms/powernv/pci.c
> @@ -708,30 +708,23 @@ int pnv_pci_cfg_write(struct pci_dn *pdn,
>  }
>  
>  #if CONFIG_EEH
> -static bool pnv_pci_cfg_check(struct pci_dn *pdn)
> +bool pnv_eeh_pre_cfg_check(struct eeh_dev *edev)
>  {
> -	struct eeh_dev *edev = NULL;
> -	struct pnv_phb *phb = pdn->phb->private_data;
> -
> -	/* EEH not enabled ? */
> -	if (!(phb->flags & PNV_PHB_FLAG_EEH))
> +	if (!edev || !edev->pe)
>  		return true;
>  
> -	/* PE reset or device removed ? */
> -	edev = pdn->edev;
> -	if (edev) {
> -		if (edev->pe &&
> -		    (edev->pe->state & EEH_PE_CFG_BLOCKED))
> -			return false;
> +	/* PE in reset? */
> +	if (edev->pe->state & EEH_PE_CFG_BLOCKED)
> +		return false;
>  
> -		if (edev->mode & EEH_DEV_REMOVED)
> -			return false;
> -	}
> +	/* Device removed? */
> +	if (edev->mode & EEH_DEV_REMOVED)
> +		return false;
>  
>  	return true;
>  }
>  #else
> -static inline pnv_pci_cfg_check(struct pci_dn *pdn)
> +static inline pnv_pci_cfg_check(struct eeh_dev *edev)
>  {
>  	return true;
>  }
> @@ -743,6 +736,7 @@ static int pnv_pci_read_config(struct pci_bus *bus,
>  {
>  	struct pci_dn *pdn;
>  	struct pnv_phb *phb;
> +	struct eeh_dev *edev;
>  	int ret;
>  
>  	*val = 0xFFFFFFFF;
> @@ -750,14 +744,15 @@ static int pnv_pci_read_config(struct pci_bus *bus,
>  	if (!pdn)
>  		return PCIBIOS_DEVICE_NOT_FOUND;
>  
> -	if (!pnv_pci_cfg_check(pdn))
> +	edev = pdn_to_eeh_dev(pdn);
> +	if (!pnv_eeh_pre_cfg_check(edev))
>  		return PCIBIOS_DEVICE_NOT_FOUND;
>  
>  	ret = pnv_pci_cfg_read(pdn, where, size, val);
>  	phb = pdn->phb->private_data;
> -	if (phb->flags & PNV_PHB_FLAG_EEH && pdn->edev) {
> +	if (phb->flags & PNV_PHB_FLAG_EEH && edev) {
>  		if (*val == EEH_IO_ERROR_VALUE(size) &&
> -		    eeh_dev_check_failure(pdn->edev))
> +		    eeh_dev_check_failure(edev))
>                          return PCIBIOS_DEVICE_NOT_FOUND;
>  	} else {
>  		pnv_pci_config_check_eeh(pdn);
> @@ -772,13 +767,15 @@ static int pnv_pci_write_config(struct pci_bus *bus,
>  {
>  	struct pci_dn *pdn;
>  	struct pnv_phb *phb;
> +	struct eeh_dev *edev;
>  	int ret;
>  
>  	pdn = pci_get_pdn_by_devfn(bus, devfn);
>  	if (!pdn)
>  		return PCIBIOS_DEVICE_NOT_FOUND;
>  
> -	if (!pnv_pci_cfg_check(pdn))
> +	edev = pdn_to_eeh_dev(pdn);
> +	if (!pnv_eeh_pre_cfg_check(edev))
>  		return PCIBIOS_DEVICE_NOT_FOUND;
>  
>  	ret = pnv_pci_cfg_write(pdn, where, size, val);
> 

-- 
Alexey


More information about the Linuxppc-dev mailing list