Subject: Re: [PATCH V3 6/9] powerpc/powernv: create/release eeh_dev for VF

From: Gavin Shan <[email-masked]>
Date: Wed, 13 May 2015 09:09:04 +1000

On Tue, May 12, 2015 at 04:06:43PM +0800, Wei Yang wrote:
>On Mon, May 11, 2015 at 12:48:56PM +1000, Gavin Shan wrote:
>>On Mon, May 04, 2015 at 03:07:35PM +0800, Wei Yang wrote:
>>
>>Please order this patch and PATCH[5] because EEH device is expected to
>>be created before EEH PE.
>>
>>>EEH on powerpc platform needs eeh_dev structure to track the pci device
>>                                                              ^^^
>>							      PCI
>>
>>>status. Since VFs are created/released dynamically, VF's eeh_dev is also
>>>dynamically created/released in system.
>>>
>>>This patch creates/removes eeh_dev when pci_dn is created/removed for VFs,
>>>and marks it with EEH_DEV_VF type.
>>>
>>>Signed-off-by: Wei Yang <[email-masked]>
>>>---
>>> arch/powerpc/include/asm/eeh.h |    7 +++++++
>>> arch/powerpc/kernel/eeh.c      |    4 ++++
>>> arch/powerpc/kernel/eeh_dev.c  |   20 ++++++++++++++++++++
>>> arch/powerpc/kernel/pci_dn.c   |    7 +++++++
>>> 4 files changed, 38 insertions(+)
>>>
>>>diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
>>>index 56e8cd9..2067de4 100644
>>>--- a/arch/powerpc/include/asm/eeh.h
>>>+++ b/arch/powerpc/include/asm/eeh.h
>>>@@ -124,6 +124,7 @@ static inline bool eeh_pe_passed(struct eeh_pe *pe)
>>> #define EEH_DEV_NO_HANDLER	(1 << 8)	/* No error handler	*/
>>> #define EEH_DEV_SYSFS		(1 << 9)	/* Sysfs created	*/
>>> #define EEH_DEV_REMOVED		(1 << 10)	/* Removed permanently	*/
>>>+#define EEH_DEV_VF		(1 << 11)	/* VF port		*/
>>>
>>
>>Why you need this flag? I guess "edev->physfn" can be used to distinguish
>>it's a normal or VF eeh_dev.
>>
>
>Just like we have EEH_DEV_BRIDGE and EEH_DEV_DS_PORT, I use the flag
>EEH_DEV_VF to mark it a VF eeh_dev.
>
>

They're not equal from my point of review. When the VF edev is created
from VF's pdn, edev->physfn is determined. Furthermore, edev->physfn
is only meaningful to VF's edev. It's why I think you needn't introduce
another one flag (EEH_DEV_VF), which is just duplicated to (edev->physfn).
So I think you can use following condition to check if one edev is created
from VF's pdn or others:

	if (edev->physfn)
		/* VF's edev */
	else
		/* All other cases */

In order to use the above condition, edev->phyfn is initialized to dereference
the VF's physical function when it's created from VF's pdn in arch/powerpc/kernel/pdn.c.

Thanks,
Gavin