diff mbox series

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

Message ID 20191120012859.23300-25-oohall@gmail.com (mailing list archive)
State RFC
Headers show
Series [Very,RFC,01/46] powerpc/eeh: Don't attempt to restore VF config space after reset | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (784eee1cc44801366d4f197e0ade7739ee8e1e83)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (0695f8bca93ea0c57f0e8e21b4b4db70183b3d1c)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (c74386d50fbaf4a54fd3fe560f1abc709c0cff4b)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (7d6475051fb3d9339c5c760ed9883bc0a9048b21)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (5d1131b4d61e52e5702e0fa4bcbec81ac7d6ef52)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Oliver O'Halloran Nov. 20, 2019, 1:28 a.m. UTC
Squash another usage in preperation for making the config accessors pci_dn.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
We might want to move this into eeh-powernv.c
---
 arch/powerpc/platforms/powernv/pci.c | 37 +++++++++++++---------------
 1 file changed, 17 insertions(+), 20 deletions(-)

Comments

Alexey Kardashevskiy Nov. 27, 2019, 12:21 a.m. UTC | #1
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@gmail.com>



Reviewed-by: Alexey Kardashevskiy <aik@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);
>
diff mbox series

Patch

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);