RE: [EXT] Re: [PATCHv5 1/6] PCI: mobiveil: Refactor Mobiveil PCIe Host Bridge IP driver

2019-04-29 Thread Z.q. Hou
Hi Subbu,

> -Original Message-
> From: Subrahmanya Lingappa [mailto:l.subrahma...@mobiveil.co.in]
> Sent: 2019年4月24日 13:36
> To: Z.q. Hou 
> Cc: linux-...@vger.kernel.org; linux-arm-ker...@lists.infradead.org;
> devicet...@vger.kernel.org; linux-kernel@vger.kernel.org;
> bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com;
> shawn...@kernel.org; Leo Li ;
> lorenzo.pieral...@arm.com; catalin.mari...@arm.com;
> will.dea...@arm.com; Mingkai Hu ; M.h. Lian
> ; Xiaowei Bao 
> Subject: [EXT] Re: [PATCHv5 1/6] PCI: mobiveil: Refactor Mobiveil PCIe Host
> Bridge IP driver
> 
> WARNING: This email was created outside of NXP. DO NOT CLICK links or
> attachments unless you recognize the sender and know the content is safe.
> 
> 
> 
> ZQ,
> 
> On Fri, Apr 12, 2019 at 3:22 PM Z.q. Hou  wrote:
> >
> > From: Hou Zhiqiang 
> >
> > Refactor the Mobiveil PCIe Host Bridge IP driver to make
> > it easier to add support for both RC and EP mode driver.
> > This patch moved the Mobiveil driver to an new directory
> > 'drivers/pci/controller/mobiveil' and refactor it according
> > to the RC and EP abstraction.
> >
> > Signed-off-by: Hou Zhiqiang 
> > Reviewed-by: Minghuan Lian 
> > Reviewed-by: Subrahmanya Lingappa 
> > ---
> > V5:
> >  - Regenerated this patch on the new base.
> >  - Retouched the changelog.
> >  - Updated the Copyright.
> >
> >  MAINTAINERS   |   2 +-
> >  drivers/pci/controller/Kconfig|  11 +-
> >  drivers/pci/controller/Makefile   |   2 +-
> >  drivers/pci/controller/mobiveil/Kconfig   |  24 +
> >  drivers/pci/controller/mobiveil/Makefile  |   4 +
> >  .../pcie-mobiveil-host.c} | 570 +++---
> >  .../controller/mobiveil/pcie-mobiveil-plat.c  |  56 ++
> >  .../pci/controller/mobiveil/pcie-mobiveil.c   | 248 
> >  .../pci/controller/mobiveil/pcie-mobiveil.h   | 211 +++
> >  9 files changed, 636 insertions(+), 492 deletions(-)
> >  create mode 100644 drivers/pci/controller/mobiveil/Kconfig
> >  create mode 100644 drivers/pci/controller/mobiveil/Makefile
> >  rename drivers/pci/controller/{pcie-mobiveil.c =>
> mobiveil/pcie-mobiveil-host.c} (53%)
> >  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c
> >  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil.c
> >  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil.h
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 1e64279f338a..1013e74b14f2 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -11877,7 +11877,7 @@ M:  Subrahmanya Lingappa
> 
> >  L: linux-...@vger.kernel.org
> >  S: Supported
> >  F: Documentation/devicetree/bindings/pci/mobiveil-pcie.txt
> > -F: drivers/pci/controller/pcie-mobiveil.c
> > +F: drivers/pci/controller/mobiveil/pcie-mobiveil*
> >
> 
> Please add yourself as co-maintainer of the mobiveil driver.

Thanks for your invite, will add in v6.

Regards,
Zhiqiang


RE: [EXT] Re: [PATCHv5 1/6] PCI: mobiveil: Refactor Mobiveil PCIe Host Bridge IP driver

2019-04-29 Thread Z.q. Hou
Hi Arnd,

Thanks a lot for your comments!

> -Original Message-
> From: Arnd Bergmann [mailto:a...@arndb.de]
> Sent: 2019年4月12日 22:39
> To: Z.q. Hou 
> Cc: linux-...@vger.kernel.org; linux-arm-ker...@lists.infradead.org;
> devicet...@vger.kernel.org; linux-kernel@vger.kernel.org;
> bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com;
> l.subrahma...@mobiveil.co.in; shawn...@kernel.org; Leo Li
> ; lorenzo.pieral...@arm.com;
> catalin.mari...@arm.com; will.dea...@arm.com; M.h. Lian
> ; Xiaowei Bao ; Mingkai
> Hu 
> Subject: [EXT] Re: [PATCHv5 1/6] PCI: mobiveil: Refactor Mobiveil PCIe Host
> Bridge IP driver
> 
> WARNING: This email was created outside of NXP. DO NOT CLICK links or
> attachments unless you recognize the sender and know the content is safe.
> 
> 
> 
> On Fri, Apr 12, 2019 at 11:53 AM Z.q. Hou  wrote:
> 
> > +int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie)
> >  {
> > -   struct mobiveil_pcie *pcie;
> > struct pci_bus *bus;
> > struct pci_bus *child;
> > struct pci_host_bridge *bridge;
> > -   struct device *dev = >dev;
> > +   struct device *dev = >pdev->dev;
> > resource_size_t iobase;
> > int ret;
> >
> > -   /* allocate the PCIe port */
> > -   bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
> > -   if (!bridge)
> > -   return -ENOMEM;
> > -
> > -   pcie = pci_host_bridge_priv(bridge);
> > -
> > -   pcie->pdev = pdev;
> > +   INIT_LIST_HEAD(>resources);
> >
> > ret = mobiveil_pcie_parse_dt(pcie);
> > if (ret) {
> > @@ -928,7 +560,10 @@ static int mobiveil_pcie_probe(struct
> platform_device *pdev)
> > return ret;
> > }
> >
> > -   INIT_LIST_HEAD(>resources);
> > +   /* allocate the PCIe port */
> > +   bridge = devm_pci_alloc_host_bridge(dev, 0);
> > +   if (!bridge)
> > +   return -ENOMEM;
> >
> 
> > +static int mobiveil_pcie_probe(struct platform_device *pdev) {
> > +   struct mobiveil_pcie *pcie;
> > +   struct device *dev = >dev;
> > +
> > +   pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
> > +   if (!pcie)
> > +   return -ENOMEM;
> > +
> > +   pcie->pdev = pdev;
> > +
> > +   return mobiveil_pcie_host_probe(pcie); }
> 
> I think you need to pull the allocation of the host structure out into the 
> main
> driver here, to keep both allocations together, otherwise the release function
> will free the mobiveil_pcie structure before freeing the pci_host_bridge if 
> that
> is still in use.

Yes, that will be arranged in v6.

> 
> > +
> > +struct mobiveil_pcie {
> > +   struct platform_device *pdev;
> > +   struct list_head resources;
> 
> These two should not be needed here, as they are already part of the
> pci_host_bridge structure.

The resources list structure has been changed to a pointer to the 
bridge->windows.
It is better to keep these 2 pointers in the private structure to make it easy 
to use them
in the PCIe controller driver.

> 
>  Arnd

Regards,
Zhiqiang


Re: [PATCHv5 1/6] PCI: mobiveil: Refactor Mobiveil PCIe Host Bridge IP driver

2019-04-23 Thread Subrahmanya Lingappa
ZQ,

On Fri, Apr 12, 2019 at 3:22 PM Z.q. Hou  wrote:
>
> From: Hou Zhiqiang 
>
> Refactor the Mobiveil PCIe Host Bridge IP driver to make
> it easier to add support for both RC and EP mode driver.
> This patch moved the Mobiveil driver to an new directory
> 'drivers/pci/controller/mobiveil' and refactor it according
> to the RC and EP abstraction.
>
> Signed-off-by: Hou Zhiqiang 
> Reviewed-by: Minghuan Lian 
> Reviewed-by: Subrahmanya Lingappa 
> ---
> V5:
>  - Regenerated this patch on the new base.
>  - Retouched the changelog.
>  - Updated the Copyright.
>
>  MAINTAINERS   |   2 +-
>  drivers/pci/controller/Kconfig|  11 +-
>  drivers/pci/controller/Makefile   |   2 +-
>  drivers/pci/controller/mobiveil/Kconfig   |  24 +
>  drivers/pci/controller/mobiveil/Makefile  |   4 +
>  .../pcie-mobiveil-host.c} | 570 +++---
>  .../controller/mobiveil/pcie-mobiveil-plat.c  |  56 ++
>  .../pci/controller/mobiveil/pcie-mobiveil.c   | 248 
>  .../pci/controller/mobiveil/pcie-mobiveil.h   | 211 +++
>  9 files changed, 636 insertions(+), 492 deletions(-)
>  create mode 100644 drivers/pci/controller/mobiveil/Kconfig
>  create mode 100644 drivers/pci/controller/mobiveil/Makefile
>  rename drivers/pci/controller/{pcie-mobiveil.c => 
> mobiveil/pcie-mobiveil-host.c} (53%)
>  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c
>  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil.c
>  create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 1e64279f338a..1013e74b14f2 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -11877,7 +11877,7 @@ M:  Subrahmanya Lingappa 
> 
>  L: linux-...@vger.kernel.org
>  S: Supported
>  F: Documentation/devicetree/bindings/pci/mobiveil-pcie.txt
> -F: drivers/pci/controller/pcie-mobiveil.c
> +F: drivers/pci/controller/mobiveil/pcie-mobiveil*
>

Please add yourself as co-maintainer of the mobiveil driver.

>
>  PCI DRIVER FOR MVEBU (Marvell Armada 370 and Armada XP SOC support)
>  M: Thomas Petazzoni 
> diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> index 6671946dbf66..0e981ed00a75 100644
> --- a/drivers/pci/controller/Kconfig
> +++ b/drivers/pci/controller/Kconfig
> @@ -241,16 +241,6 @@ config PCIE_MEDIATEK
>   Say Y here if you want to enable PCIe controller support on
>   MediaTek SoCs.
>
> -config PCIE_MOBIVEIL
> -   bool "Mobiveil AXI PCIe controller"
> -   depends on ARCH_ZYNQMP || COMPILE_TEST
> -   depends on OF
> -   depends on PCI_MSI_IRQ_DOMAIN
> -   help
> - Say Y here if you want to enable support for the Mobiveil AXI PCIe
> - Soft IP. It has up to 8 outbound and inbound windows
> - for address translation and it is a PCIe Gen4 IP.
> -
>  config PCIE_TANGO_SMP8759
> bool "Tango SMP8759 PCIe controller (DANGEROUS)"
> depends on ARCH_TANGO && PCI_MSI && OF
> @@ -281,4 +271,5 @@ config VMD
>   module will be called vmd.
>
>  source "drivers/pci/controller/dwc/Kconfig"
> +source "drivers/pci/controller/mobiveil/Kconfig"
>  endmenu
> diff --git a/drivers/pci/controller/Makefile b/drivers/pci/controller/Makefile
> index d56a507495c5..b79a615041a0 100644
> --- a/drivers/pci/controller/Makefile
> +++ b/drivers/pci/controller/Makefile
> @@ -26,11 +26,11 @@ obj-$(CONFIG_PCIE_ROCKCHIP) += pcie-rockchip.o
>  obj-$(CONFIG_PCIE_ROCKCHIP_EP) += pcie-rockchip-ep.o
>  obj-$(CONFIG_PCIE_ROCKCHIP_HOST) += pcie-rockchip-host.o
>  obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o
> -obj-$(CONFIG_PCIE_MOBIVEIL) += pcie-mobiveil.o
>  obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o
>  obj-$(CONFIG_VMD) += vmd.o
>  # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
>  obj-y  += dwc/
> +obj-y  += mobiveil/
>
>
>  # The following drivers are for devices that use the generic ACPI
> diff --git a/drivers/pci/controller/mobiveil/Kconfig 
> b/drivers/pci/controller/mobiveil/Kconfig
> new file mode 100644
> index ..64343c07bfed
> --- /dev/null
> +++ b/drivers/pci/controller/mobiveil/Kconfig
> @@ -0,0 +1,24 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +menu "Mobiveil PCIe Core Support"
> +   depends on PCI
> +
> +config PCIE_MOBIVEIL
> +   bool
> +
> +config PCIE_MOBIVEIL_HOST
> +bool
> +   depends on PCI_MSI_IRQ_DOMAIN
> +select PCIE_MOBIVEIL
> +
> +config PCIE_MOBIVEIL_PLAT
> +   bool "Mobiveil AXI PCIe controller"
> +   depends on ARCH_ZYNQMP || COMPILE_TEST
> +   depends on OF
> +   select PCIE_MOBIVEIL_HOST
> +   help
> + Say Y here if you want to enable support for the Mobiveil AXI PCIe
> + Soft IP. It has up to 8 outbound and inbound windows
> + for address translation and it is a PCIe Gen4 IP.
> +
> +endmenu
> diff --git 

Re: [PATCHv5 1/6] PCI: mobiveil: Refactor Mobiveil PCIe Host Bridge IP driver

2019-04-12 Thread Arnd Bergmann
On Fri, Apr 12, 2019 at 11:53 AM Z.q. Hou  wrote:

> +int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie)
>  {
> -   struct mobiveil_pcie *pcie;
> struct pci_bus *bus;
> struct pci_bus *child;
> struct pci_host_bridge *bridge;
> -   struct device *dev = >dev;
> +   struct device *dev = >pdev->dev;
> resource_size_t iobase;
> int ret;
>
> -   /* allocate the PCIe port */
> -   bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
> -   if (!bridge)
> -   return -ENOMEM;
> -
> -   pcie = pci_host_bridge_priv(bridge);
> -
> -   pcie->pdev = pdev;
> +   INIT_LIST_HEAD(>resources);
>
> ret = mobiveil_pcie_parse_dt(pcie);
> if (ret) {
> @@ -928,7 +560,10 @@ static int mobiveil_pcie_probe(struct platform_device 
> *pdev)
> return ret;
> }
>
> -   INIT_LIST_HEAD(>resources);
> +   /* allocate the PCIe port */
> +   bridge = devm_pci_alloc_host_bridge(dev, 0);
> +   if (!bridge)
> +   return -ENOMEM;
>

> +static int mobiveil_pcie_probe(struct platform_device *pdev)
> +{
> +   struct mobiveil_pcie *pcie;
> +   struct device *dev = >dev;
> +
> +   pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
> +   if (!pcie)
> +   return -ENOMEM;
> +
> +   pcie->pdev = pdev;
> +
> +   return mobiveil_pcie_host_probe(pcie);
> +}

I think you need to pull the allocation of the host structure out into the
main driver here, to keep both allocations together, otherwise the
release function will free the mobiveil_pcie structure before freeing
the pci_host_bridge if that is still in use.

> +
> +struct mobiveil_pcie {
> +   struct platform_device *pdev;
> +   struct list_head resources;

These two should not be needed here, as they are already part
of the pci_host_bridge structure.

 Arnd


[PATCHv5 1/6] PCI: mobiveil: Refactor Mobiveil PCIe Host Bridge IP driver

2019-04-12 Thread Z.q. Hou
From: Hou Zhiqiang 

Refactor the Mobiveil PCIe Host Bridge IP driver to make
it easier to add support for both RC and EP mode driver.
This patch moved the Mobiveil driver to an new directory
'drivers/pci/controller/mobiveil' and refactor it according
to the RC and EP abstraction.

Signed-off-by: Hou Zhiqiang 
Reviewed-by: Minghuan Lian 
Reviewed-by: Subrahmanya Lingappa 
---
V5:
 - Regenerated this patch on the new base.
 - Retouched the changelog.
 - Updated the Copyright.

 MAINTAINERS   |   2 +-
 drivers/pci/controller/Kconfig|  11 +-
 drivers/pci/controller/Makefile   |   2 +-
 drivers/pci/controller/mobiveil/Kconfig   |  24 +
 drivers/pci/controller/mobiveil/Makefile  |   4 +
 .../pcie-mobiveil-host.c} | 570 +++---
 .../controller/mobiveil/pcie-mobiveil-plat.c  |  56 ++
 .../pci/controller/mobiveil/pcie-mobiveil.c   | 248 
 .../pci/controller/mobiveil/pcie-mobiveil.h   | 211 +++
 9 files changed, 636 insertions(+), 492 deletions(-)
 create mode 100644 drivers/pci/controller/mobiveil/Kconfig
 create mode 100644 drivers/pci/controller/mobiveil/Makefile
 rename drivers/pci/controller/{pcie-mobiveil.c => 
mobiveil/pcie-mobiveil-host.c} (53%)
 create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil-plat.c
 create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil.c
 create mode 100644 drivers/pci/controller/mobiveil/pcie-mobiveil.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 1e64279f338a..1013e74b14f2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11877,7 +11877,7 @@ M:  Subrahmanya Lingappa 

 L: linux-...@vger.kernel.org
 S: Supported
 F: Documentation/devicetree/bindings/pci/mobiveil-pcie.txt
-F: drivers/pci/controller/pcie-mobiveil.c
+F: drivers/pci/controller/mobiveil/pcie-mobiveil*
 
 PCI DRIVER FOR MVEBU (Marvell Armada 370 and Armada XP SOC support)
 M: Thomas Petazzoni 
diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 6671946dbf66..0e981ed00a75 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -241,16 +241,6 @@ config PCIE_MEDIATEK
  Say Y here if you want to enable PCIe controller support on
  MediaTek SoCs.
 
-config PCIE_MOBIVEIL
-   bool "Mobiveil AXI PCIe controller"
-   depends on ARCH_ZYNQMP || COMPILE_TEST
-   depends on OF
-   depends on PCI_MSI_IRQ_DOMAIN
-   help
- Say Y here if you want to enable support for the Mobiveil AXI PCIe
- Soft IP. It has up to 8 outbound and inbound windows
- for address translation and it is a PCIe Gen4 IP.
-
 config PCIE_TANGO_SMP8759
bool "Tango SMP8759 PCIe controller (DANGEROUS)"
depends on ARCH_TANGO && PCI_MSI && OF
@@ -281,4 +271,5 @@ config VMD
  module will be called vmd.
 
 source "drivers/pci/controller/dwc/Kconfig"
+source "drivers/pci/controller/mobiveil/Kconfig"
 endmenu
diff --git a/drivers/pci/controller/Makefile b/drivers/pci/controller/Makefile
index d56a507495c5..b79a615041a0 100644
--- a/drivers/pci/controller/Makefile
+++ b/drivers/pci/controller/Makefile
@@ -26,11 +26,11 @@ obj-$(CONFIG_PCIE_ROCKCHIP) += pcie-rockchip.o
 obj-$(CONFIG_PCIE_ROCKCHIP_EP) += pcie-rockchip-ep.o
 obj-$(CONFIG_PCIE_ROCKCHIP_HOST) += pcie-rockchip-host.o
 obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o
-obj-$(CONFIG_PCIE_MOBIVEIL) += pcie-mobiveil.o
 obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o
 obj-$(CONFIG_VMD) += vmd.o
 # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
 obj-y  += dwc/
+obj-y  += mobiveil/
 
 
 # The following drivers are for devices that use the generic ACPI
diff --git a/drivers/pci/controller/mobiveil/Kconfig 
b/drivers/pci/controller/mobiveil/Kconfig
new file mode 100644
index ..64343c07bfed
--- /dev/null
+++ b/drivers/pci/controller/mobiveil/Kconfig
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0
+
+menu "Mobiveil PCIe Core Support"
+   depends on PCI
+
+config PCIE_MOBIVEIL
+   bool
+
+config PCIE_MOBIVEIL_HOST
+bool
+   depends on PCI_MSI_IRQ_DOMAIN
+select PCIE_MOBIVEIL
+
+config PCIE_MOBIVEIL_PLAT
+   bool "Mobiveil AXI PCIe controller"
+   depends on ARCH_ZYNQMP || COMPILE_TEST
+   depends on OF
+   select PCIE_MOBIVEIL_HOST
+   help
+ Say Y here if you want to enable support for the Mobiveil AXI PCIe
+ Soft IP. It has up to 8 outbound and inbound windows
+ for address translation and it is a PCIe Gen4 IP.
+
+endmenu
diff --git a/drivers/pci/controller/mobiveil/Makefile 
b/drivers/pci/controller/mobiveil/Makefile
new file mode 100644
index ..9fb6d1c6504d
--- /dev/null
+++ b/drivers/pci/controller/mobiveil/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_PCIE_MOBIVEIL) += pcie-mobiveil.o
+obj-$(CONFIG_PCIE_MOBIVEIL_HOST) += pcie-mobiveil-host.o