RE: [PATCH v9 06/10] PCI: dwc: ep: Call dw_pcie_ep_init_registers() API directly from all glue drivers

2024-03-08 Thread Yoshihiro Shimoda
> From: Manivannan Sadhasivam, Sent: Monday, March 4, 2024 6:22 PM
> 
> Currently, dw_pcie_ep_init_registers() API is directly called by the glue
> drivers requiring active refclk from host. But for the other drivers, it is
> getting called implicitly by dw_pcie_ep_init(). This is due to the fact
> that this API initializes DWC EP specific registers and that requires an
> active refclk (either from host or generated locally by endpoint itsef).
> 
> But, this causes a discrepancy among the glue drivers. So to avoid this
> confusion, let's call this API directly from all glue drivers irrespective
> of refclk dependency. Only difference here is that the drivers requiring
> refclk from host will call this API only after the refclk is received and
> other drivers without refclk dependency will call this API right after
> dw_pcie_ep_init().
> 
> With this change, the check for 'core_init_notifier' flag can now be
> dropped from dw_pcie_ep_init() API. This will also allow us to remove the
> 'core_init_notifier' flag completely in the later commits.
> 
> Signed-off-by: Manivannan Sadhasivam 
> ---
>  drivers/pci/controller/dwc/pci-dra7xx.c   |  7 +++
>  drivers/pci/controller/dwc/pci-imx6.c |  8 
>  drivers/pci/controller/dwc/pci-keystone.c |  9 +
>  drivers/pci/controller/dwc/pci-layerscape-ep.c|  7 +++
>  drivers/pci/controller/dwc/pcie-artpec6.c | 13 -
>  drivers/pci/controller/dwc/pcie-designware-ep.c   | 22 --
>  drivers/pci/controller/dwc/pcie-designware-plat.c |  9 +
>  drivers/pci/controller/dwc/pcie-keembay.c | 16 +++-
>  drivers/pci/controller/dwc/pcie-rcar-gen4.c   | 12 +++-

Thank you for the patch! About pcie-rcar-gen4.c,

Reviewed-by: Yoshihiro Shimoda 

Best regards,
Yoshihiro Shimoda

>  drivers/pci/controller/dwc/pcie-uniphier-ep.c | 13 -
>  10 files changed, 90 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c 
> b/drivers/pci/controller/dwc/pci-dra7xx.c
> index 0e406677060d..395042b29ffc 100644
> --- a/drivers/pci/controller/dwc/pci-dra7xx.c
> +++ b/drivers/pci/controller/dwc/pci-dra7xx.c
> @@ -467,6 +467,13 @@ static int dra7xx_add_pcie_ep(struct dra7xx_pcie *dra7xx,
>   return ret;
>   }
> 
> + ret = dw_pcie_ep_init_registers(ep);
> + if (ret) {
> + dev_err(dev, "Failed to initialize DWC endpoint registers\n");
> + dw_pcie_ep_deinit(ep);
> + return ret;
> + }
> +
>   return 0;
>  }
> 
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c 
> b/drivers/pci/controller/dwc/pci-imx6.c
> index dc2c036ab28c..bfcafa440ddb 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -1136,6 +1136,14 @@ static int imx6_add_pcie_ep(struct imx6_pcie 
> *imx6_pcie,
>   dev_err(dev, "failed to initialize endpoint\n");
>   return ret;
>   }
> +
> + ret = dw_pcie_ep_init_registers(ep);
> + if (ret) {
> + dev_err(dev, "Failed to initialize DWC endpoint registers\n");
> + dw_pcie_ep_deinit(ep);
> + return ret;
> + }
> +
>   /* Start LTSSM. */
>   imx6_pcie_ltssm_enable(dev);
> 
> diff --git a/drivers/pci/controller/dwc/pci-keystone.c 
> b/drivers/pci/controller/dwc/pci-keystone.c
> index c0c62533a3f1..8392894ed286 100644
> --- a/drivers/pci/controller/dwc/pci-keystone.c
> +++ b/drivers/pci/controller/dwc/pci-keystone.c
> @@ -1286,6 +1286,13 @@ static int ks_pcie_probe(struct platform_device *pdev)
>   ret = dw_pcie_ep_init(>ep);
>   if (ret < 0)
>   goto err_get_sync;
> +
> + ret = dw_pcie_ep_init_registers(>ep);
> + if (ret < 0) {
> + dev_err(dev, "Failed to initialize DWC endpoint 
> registers\n");
> + goto err_ep_init;
> + }
> +
>   break;
>   default:
>   dev_err(dev, "INVALID device type %d\n", mode);
> @@ -1295,6 +1302,8 @@ static int ks_pcie_probe(struct platform_device *pdev)
> 
>   return 0;
> 
> +err_ep_init:
> + dw_pcie_ep_deinit(>ep);
>  err_get_sync:
>   pm_runtime_put(dev);
>   pm_runtime_disable(dev);
> diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c 
> b/drivers/pci/controller/dwc/pci-layerscape-ep.c
> index 2e398494e7c0..b712fdd06549 100644
> --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c
> +++ b/drivers/pci/controller/dwc/pci-layerscap

RE: [PATCH v9 02/10] PCI: dwc: ep: Rename dw_pcie_ep_exit() to dw_pcie_ep_deinit()

2024-03-08 Thread Yoshihiro Shimoda
> From: Manivannan Sadhasivam, Sent: Monday, March 4, 2024 6:22 PM
> 
> dw_pcie_ep_exit() API is undoing what the dw_pcie_ep_init() API has done
> already (at least partly). But the API name dw_pcie_ep_exit() is not quite
> reflecting that. So let's rename it to dw_pcie_ep_deinit() to make the
> purpose of this API clear. This also aligns with the DWC host driver.
> 
> Reviewed-by: Frank Li 
> Signed-off-by: Manivannan Sadhasivam 

Thank you for the patch!

Reviewed-by: Yoshihiro Shimoda 

Best regards,
Yoshihiro Shimoda

> ---
>  drivers/pci/controller/dwc/pcie-designware-ep.c | 4 ++--
>  drivers/pci/controller/dwc/pcie-designware.h| 4 ++--
>  drivers/pci/controller/dwc/pcie-rcar-gen4.c | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c 
> b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index d305f9b4cdfe..2b11290aab4c 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -564,7 +564,7 @@ int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 
> func_no,
>   return 0;
>  }
> 
> -void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
> +void dw_pcie_ep_deinit(struct dw_pcie_ep *ep)
>  {
>   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
>   struct pci_epc *epc = ep->epc;
> @@ -576,7 +576,7 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
> 
>   pci_epc_mem_exit(epc);
>  }
> -EXPORT_SYMBOL_GPL(dw_pcie_ep_exit);
> +EXPORT_SYMBOL_GPL(dw_pcie_ep_deinit);
> 
>  static unsigned int dw_pcie_ep_find_ext_capability(struct dw_pcie *pci, int 
> cap)
>  {
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h 
> b/drivers/pci/controller/dwc/pcie-designware.h
> index ab7431a37209..61465203bb60 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -671,7 +671,7 @@ void dw_pcie_ep_linkup(struct dw_pcie_ep *ep);
>  int dw_pcie_ep_init(struct dw_pcie_ep *ep);
>  int dw_pcie_ep_init_complete(struct dw_pcie_ep *ep);
>  void dw_pcie_ep_init_notify(struct dw_pcie_ep *ep);
> -void dw_pcie_ep_exit(struct dw_pcie_ep *ep);
> +void dw_pcie_ep_deinit(struct dw_pcie_ep *ep);
>  int dw_pcie_ep_raise_intx_irq(struct dw_pcie_ep *ep, u8 func_no);
>  int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,
>u8 interrupt_num);
> @@ -701,7 +701,7 @@ static inline void dw_pcie_ep_init_notify(struct 
> dw_pcie_ep *ep)
>  {
>  }
> 
> -static inline void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
> +static inline void dw_pcie_ep_deinit(struct dw_pcie_ep *ep)
>  {
>  }
> 
> diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c 
> b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> index ac97d594ea47..9d9d22e367bb 100644
> --- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> @@ -430,7 +430,7 @@ static int rcar_gen4_add_dw_pcie_ep(struct rcar_gen4_pcie 
> *rcar)
> 
>  static void rcar_gen4_remove_dw_pcie_ep(struct rcar_gen4_pcie *rcar)
>  {
> - dw_pcie_ep_exit(>dw.ep);
> + dw_pcie_ep_deinit(>dw.ep);
>   rcar_gen4_pcie_ep_deinit(rcar);
>  }
> 
> 
> --
> 2.25.1



RE: [PATCH v9 01/10] PCI: dwc: ep: Remove deinit() callback from struct dw_pcie_ep_ops

2024-03-08 Thread Yoshihiro Shimoda
Hello Manivannan,

> From: Manivannan Sadhasivam, Sent: Monday, March 4, 2024 6:22 PM
> 
> deinit() callback was solely introduced for the pcie-rcar-gen4 driver where
> it is used to do platform specific resource deallocation. And this callback
> is called right at the end of the dw_pcie_ep_exit() API. So it doesn't
> matter whether it is called within or outside of dw_pcie_ep_exit() API.
> 
> So let's remove this callback and directly call rcar_gen4_pcie_ep_deinit()
> in pcie-rcar-gen4 driver to do resource deallocation after the completion
> of dw_pcie_ep_exit() API in rcar_gen4_remove_dw_pcie_ep().
> 
> This simplifies the DWC layer.
> 
> Reviewed-by: Frank Li 
> Signed-off-by: Manivannan Sadhasivam 

Thank you for the patch!

Reviewed-by: Yoshihiro Shimoda 

Best regards,
Yoshihiro Shimoda

> ---
>  drivers/pci/controller/dwc/pcie-designware-ep.c |  9 +
>  drivers/pci/controller/dwc/pcie-designware.h|  1 -
>  drivers/pci/controller/dwc/pcie-rcar-gen4.c | 14 --
>  3 files changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c 
> b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index 5befed2dc02b..d305f9b4cdfe 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> @@ -575,9 +575,6 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)
> epc->mem->window.page_size);
> 
>   pci_epc_mem_exit(epc);
> -
> - if (ep->ops->deinit)
> - ep->ops->deinit(ep);
>  }
>  EXPORT_SYMBOL_GPL(dw_pcie_ep_exit);
> 
> @@ -738,7 +735,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
>  ep->page_size);
>   if (ret < 0) {
>   dev_err(dev, "Failed to initialize address space\n");
> - goto err_ep_deinit;
> + return ret;
>   }
> 
>   ep->msi_mem = pci_epc_mem_alloc_addr(epc, >msi_mem_phys,
> @@ -775,10 +772,6 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
>  err_exit_epc_mem:
>   pci_epc_mem_exit(epc);
> 
> -err_ep_deinit:
> - if (ep->ops->deinit)
> - ep->ops->deinit(ep);
> -
>   return ret;
>  }
>  EXPORT_SYMBOL_GPL(dw_pcie_ep_init);
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h 
> b/drivers/pci/controller/dwc/pcie-designware.h
> index 26dae4837462..ab7431a37209 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -333,7 +333,6 @@ struct dw_pcie_rp {
>  struct dw_pcie_ep_ops {
>   void(*pre_init)(struct dw_pcie_ep *ep);
>   void(*init)(struct dw_pcie_ep *ep);
> - void(*deinit)(struct dw_pcie_ep *ep);
>   int (*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
>unsigned int type, u16 interrupt_num);
>   const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);
> diff --git a/drivers/pci/controller/dwc/pcie-rcar-gen4.c 
> b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> index e9166619b1f9..ac97d594ea47 100644
> --- a/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> +++ b/drivers/pci/controller/dwc/pcie-rcar-gen4.c
> @@ -352,11 +352,8 @@ static void rcar_gen4_pcie_ep_init(struct dw_pcie_ep *ep)
>   dw_pcie_ep_reset_bar(pci, bar);
>  }
> 
> -static void rcar_gen4_pcie_ep_deinit(struct dw_pcie_ep *ep)
> +static void rcar_gen4_pcie_ep_deinit(struct rcar_gen4_pcie *rcar)
>  {
> - struct dw_pcie *dw = to_dw_pcie_from_ep(ep);
> - struct rcar_gen4_pcie *rcar = to_rcar_gen4_pcie(dw);
> -
>   writel(0, rcar->base + PCIEDMAINTSTSEN);
>   rcar_gen4_pcie_common_deinit(rcar);
>  }
> @@ -408,7 +405,6 @@ static unsigned int 
> rcar_gen4_pcie_ep_get_dbi2_offset(struct dw_pcie_ep *ep,
>  static const struct dw_pcie_ep_ops pcie_ep_ops = {
>   .pre_init = rcar_gen4_pcie_ep_pre_init,
>   .init = rcar_gen4_pcie_ep_init,
> - .deinit = rcar_gen4_pcie_ep_deinit,
>   .raise_irq = rcar_gen4_pcie_ep_raise_irq,
>   .get_features = rcar_gen4_pcie_ep_get_features,
>   .get_dbi_offset = rcar_gen4_pcie_ep_get_dbi_offset,
> @@ -418,18 +414,24 @@ static const struct dw_pcie_ep_ops pcie_ep_ops = {
>  static int rcar_gen4_add_dw_pcie_ep(struct rcar_gen4_pcie *rcar)
>  {
>   struct dw_pcie_ep *ep = >dw.ep;
> + int ret;
> 
>   if (!IS_ENABLED(CONFIG_PCIE_RCAR_GEN4_EP))
>   return -ENODEV;
> 
>   ep->ops = _ep_ops;
> 
> - return dw_pcie_ep_init(ep);
> + ret = dw_pcie_ep_init(ep);
> + if (ret)
> + rcar_gen4_pcie_ep_deinit(rcar);
> +
> + return ret;
>  }
> 
>  static void rcar_gen4_remove_dw_pcie_ep(struct rcar_gen4_pcie *rcar)
>  {
>   dw_pcie_ep_exit(>dw.ep);
> + rcar_gen4_pcie_ep_deinit(rcar);
>  }
> 
>  /* Common */
> 
> --
> 2.25.1



RE: [PATCH 3/3] PCI: dwc: Add dw_pcie_ep_{read,write}_dbi[2] helpers

2023-11-13 Thread Yoshihiro Shimoda
Hello Serge,

> From: Serge Semin, Sent: Monday, November 13, 2023 9:41 PM
> 
> On Mon, Nov 13, 2023 at 10:33:00AM +0900, Yoshihiro Shimoda wrote:
> > The current code calculated some dbi[2] registers' offset by calling
> > dw_pcie_ep_get_dbi[2]_offset() in each function. To improve code
> > readability, add dw_pcie_ep_{read,write}_dbi[2} and some data-width
> > related helpers.
> 
> Thanks for submitting this cleanup patch. That's exactly what I meant
> here

> and Mani later here

> 
> Please note a few nitpicks below.

Thank you for your review!

> >
> > Signed-off-by: Yoshihiro Shimoda 
> > ---
> >  .../pci/controller/dwc/pcie-designware-ep.c   | 230 ++
> >  1 file changed, 129 insertions(+), 101 deletions(-)
> >
> > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c 
> > b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > index 1100671db887..dcbed49c9613 100644
> > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
> > @@ -65,24 +65,89 @@ static unsigned int dw_pcie_ep_get_dbi2_offset(struct 
> > dw_pcie_ep *ep, u8 func_no
> > return dbi2_offset;
> >  }
> >
> > +static u32 dw_pcie_ep_read_dbi(struct dw_pcie_ep *ep, u8 func_no, u32 reg,
> > +  size_t size)
> > +{
> > +   unsigned int offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
> > +   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > +
> > +   return dw_pcie_read_dbi(pci, offset + reg, size);
> > +}
> > +
> > +static void dw_pcie_ep_write_dbi(struct dw_pcie_ep *ep, u8 func_no, u32 
> > reg,
> > +size_t size, u32 val)
> > +{
> > +   unsigned int offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
> > +   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > +
> > +   dw_pcie_write_dbi(pci, offset + reg, size, val);
> > +}
> > +
> > +static void dw_pcie_ep_write_dbi2(struct dw_pcie_ep *ep, u8 func_no, u32 
> > reg,
> > + size_t size, u32 val)
> > +{
> > +   unsigned int offset = dw_pcie_ep_get_dbi2_offset(ep, func_no);
> > +   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
> > +
> > +   dw_pcie_write_dbi2(pci, offset + reg, size, val);
> > +}
> > +
> > +static inline void dw_pcie_ep_writel_dbi(struct dw_pcie_ep *ep, u8 func_no,
> > +u32 reg, u32 val)
> > +{
> > +   dw_pcie_ep_write_dbi(ep, func_no, reg, 0x4, val);
> > +}
> > +
> > +static inline u32 dw_pcie_ep_readl_dbi(struct dw_pcie_ep *ep, u8 func_no,
> > +  u32 reg)
> > +{
> > +   return dw_pcie_ep_read_dbi(ep, func_no, reg, 0x4);
> > +}
> > +
> > +static inline void dw_pcie_ep_writew_dbi(struct dw_pcie_ep *ep, u8 func_no,
> > +u32 reg, u16 val)
> > +{
> > +   dw_pcie_ep_write_dbi(ep, func_no, reg, 0x2, val);
> > +}
> > +
> > +static inline u16 dw_pcie_ep_readw_dbi(struct dw_pcie_ep *ep, u8 func_no,
> > +  u32 reg)
> > +{
> > +   return dw_pcie_ep_read_dbi(ep, func_no, reg, 0x2);
> > +}
> > +
> > +static inline void dw_pcie_ep_writeb_dbi(struct dw_pcie_ep *ep, u8 func_no,
> > +u32 reg, u8 val)
> > +{
> > +   dw_pcie_ep_write_dbi(ep, func_no, reg, 0x1, val);
> > +}
> > +
> > +static inline u8 dw_pcie_ep_readb_dbi(struct dw_pcie_ep *ep, u8 func_no,
> > + u32 reg)
> > +{
> > +   return dw_pcie_ep_read_dbi(ep, func_no, reg, 0x1);
> > +}
> > +
> > +static inline void dw_pcie_ep_writel_dbi2(struct dw_pcie_ep *ep, u8 
> > func_no,
> > + u32 reg, u32 val)
> > +{
> > +   dw_pcie_ep_write_dbi2(ep, func_no, reg, 0x4, val);
> > +}
> > +
> 
> I am not sure whether the methods above are supposed to be defined
> here instead of being moved to the "pcie-designware.h" header file
> together with dw_pcie_ep_get_dbi2_offset() and
> dw_pcie_ep_get_dbi_offset(). The later place seems more suitable
> seeing the accessors are generic, look similar to the
> dw_pcie_{write,read}_dbi{,2}() functions and might be useful in the
> platform drivers. On the other hand no LLDDs would have used it
> currently. So I'll leave this as a food for thoughts for the driver
> and subsystem maintainers.

Perhaps, when a device driver needs to use these functions actually,
we can move these functions to pcie-designware.h, I 

RE: [PATCH 0/3] PCI: dwc: Improve code readability

2023-11-13 Thread Yoshihiro Shimoda
Hello,

> From: Krzysztof Wilczyński, Sent: Monday, November 13, 2023 9:22 PM
> 
> [...]
> > > > Now, while you are looking at things, can you also take care about the 
> > > > following:
> > > >
> > > >   drivers/pci/controller/dwc/pcie-rcar-gen4.c:439:15: warning: cast to 
> > > > smaller integer type 'enum
> dw_pcie_device_mode'
> > > from 'const void *' [-Wvoid-pointer-to-enum-cast]
> >
> > Thank you for the report!
> >
> > > > This requires adding structs for each data member of the of_device_id 
> > > > type.
> > >
> > > That sounds like overkill to me.
> > > An intermediate cast to uintptr_t should fix the issue as well.
> >
> > I confirmed that the uintptr_t fixed the issue.
> 
> We declined a similar fix in the past[1] ...
> 
> > I also think that adding a new struct with the mode is overkill.
> 
> ... with the hopes that a driver could drop the switch statements in place
> of using the other pattern.  Also, to be consistent with other drivers that
> do this already.
> 
> > So, I would like to fix the issue by using the cast of uintptr_t.
> 
> Sure.  I appreciate that this would be more work.  When you send your
> patch, can you include an update to the iproc driver (and credit the
> original author from [1])?  I would appreciate it.
> 
> 1. https://lore.kernel.org/linux-pci/20230814230008.GA196797@bhelgaas/

I got it. I'll include the following patch on v2.

https://lore.kernel.org/linux-pci/20230814-void-drivers-pci-controller-pcie-iproc-platform-v1-1-81a121607...@google.com/

Best regards,
Yoshihiro Shimoda

> 
>   Krzysztof


RE: [PATCH 1/3] PCI: dwc: Rename to .init in struct dw_pcie_ep_ops

2023-11-13 Thread Yoshihiro Shimoda
Hi Serge,

> From: Serge Semin, Sent: Monday, November 13, 2023 7:15 PM
> 
> Hi Yoshihiro.
> 
> On Mon, Nov 13, 2023 at 10:32:58AM +0900, Yoshihiro Shimoda wrote:
> > Since the name of dw_pcie_ep_ops indicates that it's for ep obviously,
> > rename a member .ep_init to .init.
> 
> Thanks for the series. This change particularly looks good. But since
> you are fixing the redundant prefixes anyway, could you also fix the
> dw_pcie_host_ops structure too (drop host_ prefixes from the
> .host_init() and .host_deinit() fields)? The change was discussed a
> while ago here
> https://lore.kernel.org/linux-pci/20230802104049.GB57374@thinkpad/
> 
> It's better to be done in the framework of a separate patch released
> within this series.

Thank you for reminding me about the discussion. I'll add such a patch in v2.

Best regards,
Yoshihiro Shimoda

> -Serge(y)
> 
> >
> > Signed-off-by: Yoshihiro Shimoda 
> > ---
> >  drivers/pci/controller/dwc/pci-dra7xx.c   | 2 +-
> >  drivers/pci/controller/dwc/pci-imx6.c | 2 +-
> >  drivers/pci/controller/dwc/pci-keystone.c | 2 +-
> >  drivers/pci/controller/dwc/pci-layerscape-ep.c| 2 +-
> >  drivers/pci/controller/dwc/pcie-artpec6.c | 2 +-
> >  drivers/pci/controller/dwc/pcie-designware-ep.c   | 4 ++--
> >  drivers/pci/controller/dwc/pcie-designware-plat.c | 2 +-
> >  drivers/pci/controller/dwc/pcie-designware.h  | 2 +-
> >  drivers/pci/controller/dwc/pcie-keembay.c | 2 +-
> >  drivers/pci/controller/dwc/pcie-qcom-ep.c | 2 +-
> >  drivers/pci/controller/dwc/pcie-rcar-gen4.c   | 2 +-
> >  drivers/pci/controller/dwc/pcie-uniphier-ep.c | 2 +-
> >  12 files changed, 13 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c 
> > b/drivers/pci/controller/dwc/pci-dra7xx.c
> > index b445ffe95e3f..f9182cd6fe67 100644
> > --- a/drivers/pci/controller/dwc/pci-dra7xx.c
> > +++ b/drivers/pci/controller/dwc/pci-dra7xx.c
> > @@ -436,7 +436,7 @@ dra7xx_pcie_get_features(struct dw_pcie_ep *ep)
> >  }
> >
> >  static const struct dw_pcie_ep_ops pcie_ep_ops = {
> > -   .ep_init = dra7xx_pcie_ep_init,
> > +   .init = dra7xx_pcie_ep_init,
> > .raise_irq = dra7xx_pcie_raise_irq,
> > .get_features = dra7xx_pcie_get_features,
> >  };
> > diff --git a/drivers/pci/controller/dwc/pci-imx6.c 
> > b/drivers/pci/controller/dwc/pci-imx6.c
> > index 74703362aeec..737d4d90fef2 100644
> > --- a/drivers/pci/controller/dwc/pci-imx6.c
> > +++ b/drivers/pci/controller/dwc/pci-imx6.c
> > @@ -1093,7 +1093,7 @@ imx6_pcie_ep_get_features(struct dw_pcie_ep *ep)
> >  }
> >
> >  static const struct dw_pcie_ep_ops pcie_ep_ops = {
> > -   .ep_init = imx6_pcie_ep_init,
> > +   .init = imx6_pcie_ep_init,
> > .raise_irq = imx6_pcie_ep_raise_irq,
> > .get_features = imx6_pcie_ep_get_features,
> >  };
> > diff --git a/drivers/pci/controller/dwc/pci-keystone.c 
> > b/drivers/pci/controller/dwc/pci-keystone.c
> > index 0def919f89fa..655c7307eb88 100644
> > --- a/drivers/pci/controller/dwc/pci-keystone.c
> > +++ b/drivers/pci/controller/dwc/pci-keystone.c
> > @@ -944,7 +944,7 @@ ks_pcie_am654_get_features(struct dw_pcie_ep *ep)
> >  }
> >
> >  static const struct dw_pcie_ep_ops ks_pcie_am654_ep_ops = {
> > -   .ep_init = ks_pcie_am654_ep_init,
> > +   .init = ks_pcie_am654_ep_init,
> > .raise_irq = ks_pcie_am654_raise_irq,
> > .get_features = _pcie_am654_get_features,
> >  };
> > diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c 
> > b/drivers/pci/controller/dwc/pci-layerscape-ep.c
> > index 3d3c50ef4b6f..4e4b687ef508 100644
> > --- a/drivers/pci/controller/dwc/pci-layerscape-ep.c
> > +++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c
> > @@ -195,7 +195,7 @@ static unsigned int ls_pcie_ep_func_conf_select(struct 
> > dw_pcie_ep *ep,
> >  }
> >
> >  static const struct dw_pcie_ep_ops ls_pcie_ep_ops = {
> > -   .ep_init = ls_pcie_ep_init,
> > +   .init = ls_pcie_ep_init,
> > .raise_irq = ls_pcie_ep_raise_irq,
> > .get_features = ls_pcie_ep_get_features,
> > .func_conf_select = ls_pcie_ep_func_conf_select,
> > diff --git a/drivers/pci/controller/dwc/pcie-artpec6.c 
> > b/drivers/pci/controller/dwc/pcie-artpec6.c
> > index 9b572a2b2c9a..27ff425c0698 100644
> > --- a/drivers/pci/controller/dwc/pcie-artpec6.c
> > +++ b/drivers/pci/controller/dwc/pcie-artpec6.c
> > @@ -370,7 +370,7 @@ static int artpec6_pcie_raise_irq(struct dw_pcie_ep 
> > *

RE: [PATCH 0/3] PCI: dwc: Improve code readability

2023-11-13 Thread Yoshihiro Shimoda
Hi Krzysztof-san, Geert-san,

> From: Geert Uytterhoeven, Sent: Monday, November 13, 2023 8:07 PM
> 
> Hi Krzysztof,
> 
> On Mon, Nov 13, 2023 at 11:09 AM Krzysztof Wilczyński  wrote:
> > > This patch series is based on the latest pci.git / next branch.
> > [...]
> >
> > Thank you for following up to tidy things up!  Much appreciated.
> >
> > Now, while you are looking at things, can you also take care about the 
> > following:
> >
> >   drivers/pci/controller/dwc/pcie-rcar-gen4.c:439:15: warning: cast to 
> > smaller integer type 'enum dw_pcie_device_mode'
> from 'const void *' [-Wvoid-pointer-to-enum-cast]

Thank you for the report!

> > This requires adding structs for each data member of the of_device_id type.
> 
> That sounds like overkill to me.
> An intermediate cast to uintptr_t should fix the issue as well.

I confirmed that the uintptr_t fixed the issue.
I also think that adding a new struct with the mode is overkill.
So, I would like to fix the issue by using the cast of uintptr_t.

Best regards,
Yoshihiro Shimoda

> Gr{oetje,eeting}s,
> 
> Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds


[PATCH 3/3] PCI: dwc: Add dw_pcie_ep_{read,write}_dbi[2] helpers

2023-11-12 Thread Yoshihiro Shimoda
The current code calculated some dbi[2] registers' offset by calling
dw_pcie_ep_get_dbi[2]_offset() in each function. To improve code
readability, add dw_pcie_ep_{read,write}_dbi[2} and some data-width
related helpers.

Signed-off-by: Yoshihiro Shimoda 
---
 .../pci/controller/dwc/pcie-designware-ep.c   | 230 ++
 1 file changed, 129 insertions(+), 101 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c 
b/drivers/pci/controller/dwc/pcie-designware-ep.c
index 1100671db887..dcbed49c9613 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -65,24 +65,89 @@ static unsigned int dw_pcie_ep_get_dbi2_offset(struct 
dw_pcie_ep *ep, u8 func_no
return dbi2_offset;
 }
 
+static u32 dw_pcie_ep_read_dbi(struct dw_pcie_ep *ep, u8 func_no, u32 reg,
+  size_t size)
+{
+   unsigned int offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
+   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
+
+   return dw_pcie_read_dbi(pci, offset + reg, size);
+}
+
+static void dw_pcie_ep_write_dbi(struct dw_pcie_ep *ep, u8 func_no, u32 reg,
+size_t size, u32 val)
+{
+   unsigned int offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
+   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
+
+   dw_pcie_write_dbi(pci, offset + reg, size, val);
+}
+
+static void dw_pcie_ep_write_dbi2(struct dw_pcie_ep *ep, u8 func_no, u32 reg,
+ size_t size, u32 val)
+{
+   unsigned int offset = dw_pcie_ep_get_dbi2_offset(ep, func_no);
+   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
+
+   dw_pcie_write_dbi2(pci, offset + reg, size, val);
+}
+
+static inline void dw_pcie_ep_writel_dbi(struct dw_pcie_ep *ep, u8 func_no,
+u32 reg, u32 val)
+{
+   dw_pcie_ep_write_dbi(ep, func_no, reg, 0x4, val);
+}
+
+static inline u32 dw_pcie_ep_readl_dbi(struct dw_pcie_ep *ep, u8 func_no,
+  u32 reg)
+{
+   return dw_pcie_ep_read_dbi(ep, func_no, reg, 0x4);
+}
+
+static inline void dw_pcie_ep_writew_dbi(struct dw_pcie_ep *ep, u8 func_no,
+u32 reg, u16 val)
+{
+   dw_pcie_ep_write_dbi(ep, func_no, reg, 0x2, val);
+}
+
+static inline u16 dw_pcie_ep_readw_dbi(struct dw_pcie_ep *ep, u8 func_no,
+  u32 reg)
+{
+   return dw_pcie_ep_read_dbi(ep, func_no, reg, 0x2);
+}
+
+static inline void dw_pcie_ep_writeb_dbi(struct dw_pcie_ep *ep, u8 func_no,
+u32 reg, u8 val)
+{
+   dw_pcie_ep_write_dbi(ep, func_no, reg, 0x1, val);
+}
+
+static inline u8 dw_pcie_ep_readb_dbi(struct dw_pcie_ep *ep, u8 func_no,
+ u32 reg)
+{
+   return dw_pcie_ep_read_dbi(ep, func_no, reg, 0x1);
+}
+
+static inline void dw_pcie_ep_writel_dbi2(struct dw_pcie_ep *ep, u8 func_no,
+ u32 reg, u32 val)
+{
+   dw_pcie_ep_write_dbi2(ep, func_no, reg, 0x4, val);
+}
+
 static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no,
   enum pci_barno bar, int flags)
 {
-   unsigned int dbi_offset, dbi2_offset;
struct dw_pcie_ep *ep = >ep;
u32 reg, reg_dbi2;
 
-   dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
-   dbi2_offset = dw_pcie_ep_get_dbi2_offset(ep, func_no);
-
-   reg = dbi_offset + PCI_BASE_ADDRESS_0 + (4 * bar);
-   reg_dbi2 = dbi2_offset + PCI_BASE_ADDRESS_0 + (4 * bar);
+   reg = PCI_BASE_ADDRESS_0 + (4 * bar);
+   reg_dbi2 = PCI_BASE_ADDRESS_0 + (4 * bar);
dw_pcie_dbi_ro_wr_en(pci);
-   dw_pcie_writel_dbi2(pci, reg_dbi2, 0x0);
-   dw_pcie_writel_dbi(pci, reg, 0x0);
+   dw_pcie_ep_writel_dbi2(ep, func_no, reg_dbi2, 0x0);
+   dw_pcie_ep_writel_dbi(ep, func_no, reg, 0x0);
if (flags & PCI_BASE_ADDRESS_MEM_TYPE_64) {
-   dw_pcie_writel_dbi2(pci, reg_dbi2 + 4, 0x0);
-   dw_pcie_writel_dbi(pci, reg + 4, 0x0);
+   dw_pcie_ep_writel_dbi2(ep, func_no, reg_dbi2 + 4, 0x0);
+   dw_pcie_ep_writel_dbi(ep, func_no, reg + 4, 0x0);
}
dw_pcie_dbi_ro_wr_dis(pci);
 }
@@ -99,19 +164,15 @@ void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum 
pci_barno bar)
 EXPORT_SYMBOL_GPL(dw_pcie_ep_reset_bar);
 
 static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep *ep, u8 func_no,
-   u8 cap_ptr, u8 cap)
+u8 cap_ptr, u8 cap)
 {
-   struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
-   unsigned int dbi_offset = 0;
u8 cap_id, next_cap_ptr;
u16 reg;
 
if (!cap_ptr)
return 0;
 
-   dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
-
-   reg = dw_pcie_readw_dbi(pci, dbi_offset + cap_ptr);
+   reg = dw_pcie_ep_readw_dbi(ep, func_no, 

[PATCH 1/3] PCI: dwc: Rename to .init in struct dw_pcie_ep_ops

2023-11-12 Thread Yoshihiro Shimoda
Since the name of dw_pcie_ep_ops indicates that it's for ep obviously,
rename a member .ep_init to .init.

Signed-off-by: Yoshihiro Shimoda 
---
 drivers/pci/controller/dwc/pci-dra7xx.c   | 2 +-
 drivers/pci/controller/dwc/pci-imx6.c | 2 +-
 drivers/pci/controller/dwc/pci-keystone.c | 2 +-
 drivers/pci/controller/dwc/pci-layerscape-ep.c| 2 +-
 drivers/pci/controller/dwc/pcie-artpec6.c | 2 +-
 drivers/pci/controller/dwc/pcie-designware-ep.c   | 4 ++--
 drivers/pci/controller/dwc/pcie-designware-plat.c | 2 +-
 drivers/pci/controller/dwc/pcie-designware.h  | 2 +-
 drivers/pci/controller/dwc/pcie-keembay.c | 2 +-
 drivers/pci/controller/dwc/pcie-qcom-ep.c | 2 +-
 drivers/pci/controller/dwc/pcie-rcar-gen4.c   | 2 +-
 drivers/pci/controller/dwc/pcie-uniphier-ep.c | 2 +-
 12 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c 
b/drivers/pci/controller/dwc/pci-dra7xx.c
index b445ffe95e3f..f9182cd6fe67 100644
--- a/drivers/pci/controller/dwc/pci-dra7xx.c
+++ b/drivers/pci/controller/dwc/pci-dra7xx.c
@@ -436,7 +436,7 @@ dra7xx_pcie_get_features(struct dw_pcie_ep *ep)
 }
 
 static const struct dw_pcie_ep_ops pcie_ep_ops = {
-   .ep_init = dra7xx_pcie_ep_init,
+   .init = dra7xx_pcie_ep_init,
.raise_irq = dra7xx_pcie_raise_irq,
.get_features = dra7xx_pcie_get_features,
 };
diff --git a/drivers/pci/controller/dwc/pci-imx6.c 
b/drivers/pci/controller/dwc/pci-imx6.c
index 74703362aeec..737d4d90fef2 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -1093,7 +1093,7 @@ imx6_pcie_ep_get_features(struct dw_pcie_ep *ep)
 }
 
 static const struct dw_pcie_ep_ops pcie_ep_ops = {
-   .ep_init = imx6_pcie_ep_init,
+   .init = imx6_pcie_ep_init,
.raise_irq = imx6_pcie_ep_raise_irq,
.get_features = imx6_pcie_ep_get_features,
 };
diff --git a/drivers/pci/controller/dwc/pci-keystone.c 
b/drivers/pci/controller/dwc/pci-keystone.c
index 0def919f89fa..655c7307eb88 100644
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -944,7 +944,7 @@ ks_pcie_am654_get_features(struct dw_pcie_ep *ep)
 }
 
 static const struct dw_pcie_ep_ops ks_pcie_am654_ep_ops = {
-   .ep_init = ks_pcie_am654_ep_init,
+   .init = ks_pcie_am654_ep_init,
.raise_irq = ks_pcie_am654_raise_irq,
.get_features = _pcie_am654_get_features,
 };
diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c 
b/drivers/pci/controller/dwc/pci-layerscape-ep.c
index 3d3c50ef4b6f..4e4b687ef508 100644
--- a/drivers/pci/controller/dwc/pci-layerscape-ep.c
+++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c
@@ -195,7 +195,7 @@ static unsigned int ls_pcie_ep_func_conf_select(struct 
dw_pcie_ep *ep,
 }
 
 static const struct dw_pcie_ep_ops ls_pcie_ep_ops = {
-   .ep_init = ls_pcie_ep_init,
+   .init = ls_pcie_ep_init,
.raise_irq = ls_pcie_ep_raise_irq,
.get_features = ls_pcie_ep_get_features,
.func_conf_select = ls_pcie_ep_func_conf_select,
diff --git a/drivers/pci/controller/dwc/pcie-artpec6.c 
b/drivers/pci/controller/dwc/pcie-artpec6.c
index 9b572a2b2c9a..27ff425c0698 100644
--- a/drivers/pci/controller/dwc/pcie-artpec6.c
+++ b/drivers/pci/controller/dwc/pcie-artpec6.c
@@ -370,7 +370,7 @@ static int artpec6_pcie_raise_irq(struct dw_pcie_ep *ep, u8 
func_no,
 }
 
 static const struct dw_pcie_ep_ops pcie_ep_ops = {
-   .ep_init = artpec6_pcie_ep_init,
+   .init = artpec6_pcie_ep_init,
.raise_irq = artpec6_pcie_raise_irq,
 };
 
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c 
b/drivers/pci/controller/dwc/pcie-designware-ep.c
index f6207989fc6a..ea99a97ce504 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -794,8 +794,8 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
list_add_tail(_func->list, >func_list);
}
 
-   if (ep->ops->ep_init)
-   ep->ops->ep_init(ep);
+   if (ep->ops->init)
+   ep->ops->init(ep);
 
ret = pci_epc_mem_init(epc, ep->phys_base, ep->addr_size,
   ep->page_size);
diff --git a/drivers/pci/controller/dwc/pcie-designware-plat.c 
b/drivers/pci/controller/dwc/pcie-designware-plat.c
index b625841e98aa..97088b7663e0 100644
--- a/drivers/pci/controller/dwc/pcie-designware-plat.c
+++ b/drivers/pci/controller/dwc/pcie-designware-plat.c
@@ -74,7 +74,7 @@ dw_plat_pcie_get_features(struct dw_pcie_ep *ep)
 }
 
 static const struct dw_pcie_ep_ops pcie_ep_ops = {
-   .ep_init = dw_plat_pcie_ep_init,
+   .init = dw_plat_pcie_ep_init,
.raise_irq = dw_plat_pcie_ep_raise_irq,
.get_features = dw_plat_pcie_get_features,
 };
diff --git a/drivers/pci/controller/dwc/pcie-designware.h 
b/drivers/pci/controller/dwc/pcie-designware.h

[PATCH 2/3] PCI: dwc: Rename to .get_dbi_offset in struct dw_pcie_ep_ops

2023-11-12 Thread Yoshihiro Shimoda
Since meaning of .func_conf_select is difficult to understand,
rename it to .get_dbi_offset.

Signed-off-by: Yoshihiro Shimoda 
---
 .../pci/controller/dwc/pci-layerscape-ep.c|   5 +-
 .../pci/controller/dwc/pcie-designware-ep.c   | 108 +-
 drivers/pci/controller/dwc/pcie-designware.h  |   2 +-
 drivers/pci/controller/dwc/pcie-rcar-gen4.c   |   4 +-
 4 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c 
b/drivers/pci/controller/dwc/pci-layerscape-ep.c
index 4e4b687ef508..961ff1b719a1 100644
--- a/drivers/pci/controller/dwc/pci-layerscape-ep.c
+++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c
@@ -184,8 +184,7 @@ static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 
func_no,
}
 }
 
-static unsigned int ls_pcie_ep_func_conf_select(struct dw_pcie_ep *ep,
-   u8 func_no)
+static unsigned int ls_pcie_ep_get_dbi_offset(struct dw_pcie_ep *ep, u8 
func_no)
 {
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci);
@@ -198,7 +197,7 @@ static const struct dw_pcie_ep_ops ls_pcie_ep_ops = {
.init = ls_pcie_ep_init,
.raise_irq = ls_pcie_ep_raise_irq,
.get_features = ls_pcie_ep_get_features,
-   .func_conf_select = ls_pcie_ep_func_conf_select,
+   .get_dbi_offset = ls_pcie_ep_get_dbi_offset,
 };
 
 static const struct ls_pcie_ep_drvdata ls1_ep_drvdata = {
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c 
b/drivers/pci/controller/dwc/pcie-designware-ep.c
index ea99a97ce504..1100671db887 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -43,14 +43,14 @@ dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 
func_no)
return NULL;
 }
 
-static unsigned int dw_pcie_ep_func_select(struct dw_pcie_ep *ep, u8 func_no)
+static unsigned int dw_pcie_ep_get_dbi_offset(struct dw_pcie_ep *ep, u8 
func_no)
 {
-   unsigned int func_offset = 0;
+   unsigned int dbi_offset = 0;
 
-   if (ep->ops->func_conf_select)
-   func_offset = ep->ops->func_conf_select(ep, func_no);
+   if (ep->ops->get_dbi_offset)
+   dbi_offset = ep->ops->get_dbi_offset(ep, func_no);
 
-   return func_offset;
+   return dbi_offset;
 }
 
 static unsigned int dw_pcie_ep_get_dbi2_offset(struct dw_pcie_ep *ep, u8 
func_no)
@@ -59,8 +59,8 @@ static unsigned int dw_pcie_ep_get_dbi2_offset(struct 
dw_pcie_ep *ep, u8 func_no
 
if (ep->ops->get_dbi2_offset)
dbi2_offset = ep->ops->get_dbi2_offset(ep, func_no);
-   else if (ep->ops->func_conf_select) /* for backward compatibility */
-   dbi2_offset = ep->ops->func_conf_select(ep, func_no);
+   else if (ep->ops->get_dbi_offset) /* for backward compatibility */
+   dbi2_offset = ep->ops->get_dbi_offset(ep, func_no);
 
return dbi2_offset;
 }
@@ -68,14 +68,14 @@ static unsigned int dw_pcie_ep_get_dbi2_offset(struct 
dw_pcie_ep *ep, u8 func_no
 static void __dw_pcie_ep_reset_bar(struct dw_pcie *pci, u8 func_no,
   enum pci_barno bar, int flags)
 {
-   unsigned int func_offset, dbi2_offset;
+   unsigned int dbi_offset, dbi2_offset;
struct dw_pcie_ep *ep = >ep;
u32 reg, reg_dbi2;
 
-   func_offset = dw_pcie_ep_func_select(ep, func_no);
+   dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
dbi2_offset = dw_pcie_ep_get_dbi2_offset(ep, func_no);
 
-   reg = func_offset + PCI_BASE_ADDRESS_0 + (4 * bar);
+   reg = dbi_offset + PCI_BASE_ADDRESS_0 + (4 * bar);
reg_dbi2 = dbi2_offset + PCI_BASE_ADDRESS_0 + (4 * bar);
dw_pcie_dbi_ro_wr_en(pci);
dw_pcie_writel_dbi2(pci, reg_dbi2, 0x0);
@@ -102,16 +102,16 @@ static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep 
*ep, u8 func_no,
u8 cap_ptr, u8 cap)
 {
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
-   unsigned int func_offset = 0;
+   unsigned int dbi_offset = 0;
u8 cap_id, next_cap_ptr;
u16 reg;
 
if (!cap_ptr)
return 0;
 
-   func_offset = dw_pcie_ep_func_select(ep, func_no);
+   dbi_offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
 
-   reg = dw_pcie_readw_dbi(pci, func_offset + cap_ptr);
+   reg = dw_pcie_readw_dbi(pci, dbi_offset + cap_ptr);
cap_id = (reg & 0x00ff);
 
if (cap_id > PCI_CAP_ID_MAX)
@@ -127,13 +127,13 @@ static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie_ep 
*ep, u8 func_no,
 static u8 dw_pcie_ep_find_capability(struct dw_pcie_ep *ep, u8 func_no, u8 cap)
 {
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
-   unsigned int func_offset = 0;
+   unsigned int dbi_offset = 0;
u8 next_cap_ptr;
u16 reg;
 
-   func_offset = dw_pcie_ep_func_select(ep

[PATCH 0/3] PCI: dwc: Improve code readability

2023-11-12 Thread Yoshihiro Shimoda
This patch series is based on the latest pci.git / next branch.
The patch 1/3 is related to the "note" in the commit [1]
The patches [23]/3 are related to the "Note" which in the commit [2].

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9baa8a18e31b7167885c11c38841ce92bbe20f4f

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7873b49b41b92edb3395bff9a528eaf89da5e41c

Yoshihiro Shimoda (3):
  PCI: dwc: Rename to .init in struct dw_pcie_ep_ops
  PCI: dwc: Rename to .get_dbi_offset in struct dw_pcie_ep_ops
  PCI: dwc: Add dw_pcie_ep_{read,write}_dbi[2] helpers

 drivers/pci/controller/dwc/pci-dra7xx.c   |   2 +-
 drivers/pci/controller/dwc/pci-imx6.c |   2 +-
 drivers/pci/controller/dwc/pci-keystone.c |   2 +-
 .../pci/controller/dwc/pci-layerscape-ep.c|   7 +-
 drivers/pci/controller/dwc/pcie-artpec6.c |   2 +-
 .../pci/controller/dwc/pcie-designware-ep.c   | 248 ++
 .../pci/controller/dwc/pcie-designware-plat.c |   2 +-
 drivers/pci/controller/dwc/pcie-designware.h  |   4 +-
 drivers/pci/controller/dwc/pcie-keembay.c |   2 +-
 drivers/pci/controller/dwc/pcie-qcom-ep.c |   2 +-
 drivers/pci/controller/dwc/pcie-rcar-gen4.c   |   6 +-
 drivers/pci/controller/dwc/pcie-uniphier-ep.c |   2 +-
 12 files changed, 154 insertions(+), 127 deletions(-)

-- 
2.34.1



RE: [PATCH 08/20] dt-bindings: usb: renesas-xhci: Refer to the usb-xhci.yaml file

2020-10-20 Thread Yoshihiro Shimoda
Hi,

> From: Serge Semin, Sent: Wednesday, October 14, 2020 7:14 PM
> 
> With minor peculiarities (like uploading some vendor-specific firmware)
> these are just Generic xHCI controllers fully compatible with its
> properties. Make sure the Renesas USB xHCI DT nodes are also validated
> against the Generic xHCI DT schema.
> 
> Signed-off-by: Serge Semin 
> ---

Thank you for the patch!

Reviewed-by: Yoshihiro Shimoda 

Best regards,
Yoshihiro Shimoda