diff mbox

[Vivid,SRU] powerpc/eeh: Fix PE#0 check in eeh_add_to_parent_pe()

Message ID 1444935055-16438-1-git-send-email-tim.gardner@canonical.com
State New
Headers show

Commit Message

Tim Gardner Oct. 15, 2015, 6:50 p.m. UTC
From: Gavin Shan <gwshan@linux.vnet.ibm.com>

BugLink: http://bugs.launchpad.net/bugs/1502982

The function eeh_add_parent_pe() is used to create a PE or add one
edev to its parent PE. Current code checks if PE#0 is valid for the
later case. Actually, we should validate PE#0 for both cases when
EEH core regards PE#0 as invalid one (without flag EEH_VALID_PE_ZERO).
Otherwise, not all EEH devices can be added to its parent PE#0 for
EEH on P7IOC.

The patch fixes the issue by validating PE#0 for the two cases. So far,
we don't have PE#0 for EEH on P7IOC, but it will show up when we enable
M64 for P7IOC. The patch also makes the error message more meaningful.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
(cherry picked from commit 433185d2b4e9c25f2a444424c05af72fbadd4275)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 arch/powerpc/kernel/eeh_pe.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Seth Forshee Oct. 15, 2015, 7:42 p.m. UTC | #1

Stefan Bader Oct. 16, 2015, 8:30 a.m. UTC | #2
On 15.10.2015 20:50, tim.gardner@canonical.com wrote:
> From: Gavin Shan <gwshan@linux.vnet.ibm.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1502982
> 
> The function eeh_add_parent_pe() is used to create a PE or add one
> edev to its parent PE. Current code checks if PE#0 is valid for the
> later case. Actually, we should validate PE#0 for both cases when
> EEH core regards PE#0 as invalid one (without flag EEH_VALID_PE_ZERO).
> Otherwise, not all EEH devices can be added to its parent PE#0 for
> EEH on P7IOC.

Is there any difference to the patch submitted a on Monday?

> 
> The patch fixes the issue by validating PE#0 for the two cases. So far,
> we don't have PE#0 for EEH on P7IOC, but it will show up when we enable
> M64 for P7IOC. The patch also makes the error message more meaningful.
> 
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> (cherry picked from commit 433185d2b4e9c25f2a444424c05af72fbadd4275)
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  arch/powerpc/kernel/eeh_pe.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
> index 1e4946c..edf503c 100644
> --- a/arch/powerpc/kernel/eeh_pe.c
> +++ b/arch/powerpc/kernel/eeh_pe.c
> @@ -330,6 +330,13 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
>  {
>  	struct eeh_pe *pe, *parent;
>  
> +	/* Check if the PE number is valid */
> +	if (!eeh_has_flag(EEH_VALID_PE_ZERO) && !edev->pe_config_addr) {
> +		pr_err("%s: Invalid PE#0 for edev 0x%x on PHB#%d\n",
> +		       __func__, edev->config_addr, edev->phb->global_number);
> +		return -EINVAL;
> +	}
> +
>  	/*
>  	 * Search the PE has been existing or not according
>  	 * to the PE address. If that has been existing, the
> @@ -338,12 +345,6 @@ int eeh_add_to_parent_pe(struct eeh_dev *edev)
>  	 */
>  	pe = eeh_pe_get(edev);
>  	if (pe && !(pe->type & EEH_PE_INVALID)) {
> -		if (!edev->pe_config_addr) {
> -			pr_err("%s: PE with addr 0x%x already exists\n",
> -				__func__, edev->config_addr);
> -			return -EEXIST;
> -		}
> -
>  		/* Mark the PE as type of PCI bus */
>  		pe->type = EEH_PE_BUS;
>  		edev->pe = pe;
>
diff mbox

Patch

diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
index 1e4946c..edf503c 100644
--- a/arch/powerpc/kernel/eeh_pe.c
+++ b/arch/powerpc/kernel/eeh_pe.c
@@ -330,6 +330,13 @@  int eeh_add_to_parent_pe(struct eeh_dev *edev)
 {
 	struct eeh_pe *pe, *parent;
 
+	/* Check if the PE number is valid */
+	if (!eeh_has_flag(EEH_VALID_PE_ZERO) && !edev->pe_config_addr) {
+		pr_err("%s: Invalid PE#0 for edev 0x%x on PHB#%d\n",
+		       __func__, edev->config_addr, edev->phb->global_number);
+		return -EINVAL;
+	}
+
 	/*
 	 * Search the PE has been existing or not according
 	 * to the PE address. If that has been existing, the
@@ -338,12 +345,6 @@  int eeh_add_to_parent_pe(struct eeh_dev *edev)
 	 */
 	pe = eeh_pe_get(edev);
 	if (pe && !(pe->type & EEH_PE_INVALID)) {
-		if (!edev->pe_config_addr) {
-			pr_err("%s: PE with addr 0x%x already exists\n",
-				__func__, edev->config_addr);
-			return -EEXIST;
-		}
-
 		/* Mark the PE as type of PCI bus */
 		pe->type = EEH_PE_BUS;
 		edev->pe = pe;