Re: [PATCH v4 7/9] powerpc/eeh: Add bdfn field to eeh_dev

2019-08-08 Thread Oliver O'Halloran
On Thu, Aug 8, 2019 at 5:05 PM Jordan Niethe  wrote:
>
> On Wed, 2019-08-07 at 13:44 +1000, Sam Bobroff wrote:
> > From: Oliver O'Halloran 
> >
> > Preparation for removing pci_dn from the powernv EEH code. The only
> > thing we really use pci_dn for is to get the bdfn of the device for
> > config space accesses, so adding that information to eeh_dev reduces
> > the need to carry around the pci_dn.
> >
> > Signed-off-by: Oliver O'Halloran 
> > [SB: Re-wrapped commit message, fixed whitespace damage.]
> > Signed-off-by: Sam Bobroff 
> > ---
> >  arch/powerpc/include/asm/eeh.h | 2 ++
> >  arch/powerpc/include/asm/ppc-pci.h | 2 ++
> >  arch/powerpc/kernel/eeh_dev.c  | 2 ++
> >  3 files changed, 6 insertions(+)
> >
> > diff --git a/arch/powerpc/include/asm/eeh.h
> > b/arch/powerpc/include/asm/eeh.h
> > index 7f9404a0c3bb..bbe0798f6624 100644
> > --- a/arch/powerpc/include/asm/eeh.h
> > +++ b/arch/powerpc/include/asm/eeh.h
> > @@ -121,6 +121,8 @@ static inline bool eeh_pe_passed(struct eeh_pe
> > *pe)
> >  struct eeh_dev {
> >   int mode;   /* EEH mode */
> >   int class_code; /* Class code of the device
> > */
> > + int bdfn;   /* bdfn of device (for cfg ops) */
> > + struct pci_controller *controller;
>
> The other members of the structure get a comment, maybe it would be
> more consistant if this one did too?

At some point we need to go through all the EEH documentation /
comments and get rid of everything that is not useful or just straight
up wrong. The comments here are in-offensive, but they mostly just
repeat the information in the variable name so it's hard to see the
value.


Re: [PATCH v4 7/9] powerpc/eeh: Add bdfn field to eeh_dev

2019-08-08 Thread Jordan Niethe
On Wed, 2019-08-07 at 13:44 +1000, Sam Bobroff wrote:
> From: Oliver O'Halloran 
> 
> Preparation for removing pci_dn from the powernv EEH code. The only
> thing we really use pci_dn for is to get the bdfn of the device for
> config space accesses, so adding that information to eeh_dev reduces
> the need to carry around the pci_dn.
> 
> Signed-off-by: Oliver O'Halloran 
> [SB: Re-wrapped commit message, fixed whitespace damage.]
> Signed-off-by: Sam Bobroff 
> ---
>  arch/powerpc/include/asm/eeh.h | 2 ++
>  arch/powerpc/include/asm/ppc-pci.h | 2 ++
>  arch/powerpc/kernel/eeh_dev.c  | 2 ++
>  3 files changed, 6 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/eeh.h
> b/arch/powerpc/include/asm/eeh.h
> index 7f9404a0c3bb..bbe0798f6624 100644
> --- a/arch/powerpc/include/asm/eeh.h
> +++ b/arch/powerpc/include/asm/eeh.h
> @@ -121,6 +121,8 @@ static inline bool eeh_pe_passed(struct eeh_pe
> *pe)
>  struct eeh_dev {
>   int mode;   /* EEH mode */
>   int class_code; /* Class code of the device 
> */
> + int bdfn;   /* bdfn of device (for cfg ops) */
> + struct pci_controller *controller;

The other members of the structure get a comment, maybe it would be
more consistant if this one did too?

>   int pe_config_addr; /* PE config address
> */
>   u32 config_space[16];   /* Saved PCI config space   
> */
>   int pcix_cap;   /* Saved PCIx capability
> */
> diff --git a/arch/powerpc/include/asm/ppc-pci.h
> b/arch/powerpc/include/asm/ppc-pci.h
> index cec2d6409515..72860de205a0 100644
> --- a/arch/powerpc/include/asm/ppc-pci.h
> +++ b/arch/powerpc/include/asm/ppc-pci.h
> @@ -74,6 +74,8 @@ static inline const char *eeh_driver_name(struct
> pci_dev *pdev)
>  
>  #endif /* CONFIG_EEH */
>  
> +#define PCI_BUSNO(bdfn) ((bdfn >> 8) & 0xff)
> +
>  #else /* CONFIG_PCI */
>  static inline void init_pci_config_tokens(void) { }
>  #endif /* !CONFIG_PCI */
> diff --git a/arch/powerpc/kernel/eeh_dev.c
> b/arch/powerpc/kernel/eeh_dev.c
> index c4317c452d98..7370185c7a05 100644
> --- a/arch/powerpc/kernel/eeh_dev.c
> +++ b/arch/powerpc/kernel/eeh_dev.c
> @@ -47,6 +47,8 @@ struct eeh_dev *eeh_dev_init(struct pci_dn *pdn)
>   /* Associate EEH device with OF node */
>   pdn->edev = edev;
>   edev->pdn = pdn;
> + edev->bdfn = (pdn->busno << 8) | pdn->devfn;
> + edev->controller = pdn->phb;
>  
>   return edev;
>  }



[PATCH v4 7/9] powerpc/eeh: Add bdfn field to eeh_dev

2019-08-06 Thread Sam Bobroff
From: Oliver O'Halloran 

Preparation for removing pci_dn from the powernv EEH code. The only
thing we really use pci_dn for is to get the bdfn of the device for
config space accesses, so adding that information to eeh_dev reduces
the need to carry around the pci_dn.

Signed-off-by: Oliver O'Halloran 
[SB: Re-wrapped commit message, fixed whitespace damage.]
Signed-off-by: Sam Bobroff 
---
 arch/powerpc/include/asm/eeh.h | 2 ++
 arch/powerpc/include/asm/ppc-pci.h | 2 ++
 arch/powerpc/kernel/eeh_dev.c  | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 7f9404a0c3bb..bbe0798f6624 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -121,6 +121,8 @@ static inline bool eeh_pe_passed(struct eeh_pe *pe)
 struct eeh_dev {
int mode;   /* EEH mode */
int class_code; /* Class code of the device */
+   int bdfn;   /* bdfn of device (for cfg ops) */
+   struct pci_controller *controller;
int pe_config_addr; /* PE config address*/
u32 config_space[16];   /* Saved PCI config space   */
int pcix_cap;   /* Saved PCIx capability*/
diff --git a/arch/powerpc/include/asm/ppc-pci.h 
b/arch/powerpc/include/asm/ppc-pci.h
index cec2d6409515..72860de205a0 100644
--- a/arch/powerpc/include/asm/ppc-pci.h
+++ b/arch/powerpc/include/asm/ppc-pci.h
@@ -74,6 +74,8 @@ static inline const char *eeh_driver_name(struct pci_dev 
*pdev)
 
 #endif /* CONFIG_EEH */
 
+#define PCI_BUSNO(bdfn) ((bdfn >> 8) & 0xff)
+
 #else /* CONFIG_PCI */
 static inline void init_pci_config_tokens(void) { }
 #endif /* !CONFIG_PCI */
diff --git a/arch/powerpc/kernel/eeh_dev.c b/arch/powerpc/kernel/eeh_dev.c
index c4317c452d98..7370185c7a05 100644
--- a/arch/powerpc/kernel/eeh_dev.c
+++ b/arch/powerpc/kernel/eeh_dev.c
@@ -47,6 +47,8 @@ struct eeh_dev *eeh_dev_init(struct pci_dn *pdn)
/* Associate EEH device with OF node */
pdn->edev = edev;
edev->pdn = pdn;
+   edev->bdfn = (pdn->busno << 8) | pdn->devfn;
+   edev->controller = pdn->phb;
 
return edev;
 }
-- 
2.22.0.216.g00a2a96fc9