linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: altera: Allow building as module
@ 2019-04-24  4:57 Ley Foon Tan
  2019-04-24  4:57 ` [PATCH] PCI: altera-msi: " Ley Foon Tan
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Ley Foon Tan @ 2019-04-24  4:57 UTC (permalink / raw)
  To: Bjorn Helgaas, Lorenzo Pieralisi
  Cc: linux-kernel, linux-pci, devicetree, lftan.linux, Ley Foon Tan

Altera PCIe Rootport IP is a soft IP and is only available after
FPGA image is programmed.

Make driver modulable to support use case FPGA image is programmed
after kernel is booted. User proram FPGA image in kernel then only load
PCIe driver module.

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
---
 drivers/pci/controller/Kconfig       |  2 +-
 drivers/pci/controller/pcie-altera.c | 28 ++++++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 6012f3059acd..4b550f9cdd56 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -174,7 +174,7 @@ config PCIE_IPROC_MSI
 	  PCIe controller
 
 config PCIE_ALTERA
-	bool "Altera PCIe controller"
+	tristate "Altera PCIe controller"
 	depends on ARM || NIOS2 || ARM64 || COMPILE_TEST
 	help
 	  Say Y here if you want to enable PCIe controller support on Altera
diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c
index 27edcebd1726..6c86bc69ace8 100644
--- a/drivers/pci/controller/pcie-altera.c
+++ b/drivers/pci/controller/pcie-altera.c
@@ -10,6 +10,7 @@
 #include <linux/interrupt.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/init.h>
+#include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
@@ -705,6 +706,13 @@ static int altera_pcie_init_irq_domain(struct altera_pcie *pcie)
 	return 0;
 }
 
+static int altera_pcie_irq_teardown(struct altera_pcie *pcie)
+{
+	irq_set_chained_handler_and_data(pcie->irq, NULL, NULL);
+	irq_domain_remove(pcie->irq_domain);
+	irq_dispose_mapping(pcie->irq);
+}
+
 static int altera_pcie_parse_dt(struct altera_pcie *pcie)
 {
 	struct device *dev = &pcie->pdev->dev;
@@ -798,6 +806,7 @@ static int altera_pcie_probe(struct platform_device *pdev)
 
 	pcie = pci_host_bridge_priv(bridge);
 	pcie->pdev = pdev;
+	platform_set_drvdata(pdev, pcie);
 
 	match = of_match_device(altera_pcie_of_match, &pdev->dev);
 	if (!match)
@@ -855,13 +864,28 @@ static int altera_pcie_probe(struct platform_device *pdev)
 	return ret;
 }
 
+static int altera_pcie_remove(struct platform_device *pdev)
+{
+	struct altera_pcie *pcie = platform_get_drvdata(pdev);
+	struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
+
+	pci_stop_root_bus(bridge->bus);
+	pci_remove_root_bus(bridge->bus);
+	pci_free_resource_list(&pcie->resources);
+	altera_pcie_irq_teardown(pcie);
+
+	return 0;
+}
+
 static struct platform_driver altera_pcie_driver = {
 	.probe		= altera_pcie_probe,
+	.remove		= altera_pcie_remove,
 	.driver = {
 		.name	= "altera-pcie",
 		.of_match_table = altera_pcie_of_match,
-		.suppress_bind_attrs = true,
 	},
 };
 
-builtin_platform_driver(altera_pcie_driver);
+MODULE_DEVICE_TABLE(of, altera_pcie_of_match);
+module_platform_driver(altera_pcie_driver);
+MODULE_LICENSE("GPL v2");
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] PCI: altera-msi: Allow building as module
  2019-04-24  4:57 [PATCH] PCI: altera: Allow building as module Ley Foon Tan
@ 2019-04-24  4:57 ` Ley Foon Tan
  2019-05-14  5:35   ` Ley Foon Tan
  2019-05-30 15:08   ` Lorenzo Pieralisi
  2019-05-14  5:35 ` [PATCH] PCI: altera: " Ley Foon Tan
  2019-06-04 13:18 ` Bjorn Helgaas
  2 siblings, 2 replies; 10+ messages in thread
From: Ley Foon Tan @ 2019-04-24  4:57 UTC (permalink / raw)
  To: Bjorn Helgaas, Lorenzo Pieralisi
  Cc: linux-kernel, linux-pci, devicetree, lftan.linux, Ley Foon Tan

Altera MSI IP is a soft IP and is only available after
FPGA image is programmed.

Make driver modulable to support use case FPGA image is programmed
after kernel is booted. User proram FPGA image in kernel then only load
MSI driver module.

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
---
 drivers/pci/controller/Kconfig           |  2 +-
 drivers/pci/controller/pcie-altera-msi.c | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 4b550f9cdd56..920546cb84e2 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -181,7 +181,7 @@ config PCIE_ALTERA
 	  FPGA.
 
 config PCIE_ALTERA_MSI
-	bool "Altera PCIe MSI feature"
+	tristate "Altera PCIe MSI feature"
 	depends on PCIE_ALTERA
 	depends on PCI_MSI_IRQ_DOMAIN
 	help
diff --git a/drivers/pci/controller/pcie-altera-msi.c b/drivers/pci/controller/pcie-altera-msi.c
index 025ef7d9a046..16d938920ca5 100644
--- a/drivers/pci/controller/pcie-altera-msi.c
+++ b/drivers/pci/controller/pcie-altera-msi.c
@@ -10,6 +10,7 @@
 #include <linux/interrupt.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/init.h>
+#include <linux/module.h>
 #include <linux/msi.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
@@ -288,4 +289,13 @@ static int __init altera_msi_init(void)
 {
 	return platform_driver_register(&altera_msi_driver);
 }
+
+static void __exit altera_msi_exit(void)
+{
+	platform_driver_unregister(&altera_msi_driver);
+}
+
 subsys_initcall(altera_msi_init);
+MODULE_DEVICE_TABLE(of, altera_msi_of_match);
+module_exit(altera_msi_exit);
+MODULE_LICENSE("GPL v2");
-- 
2.19.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] PCI: altera: Allow building as module
  2019-04-24  4:57 [PATCH] PCI: altera: Allow building as module Ley Foon Tan
  2019-04-24  4:57 ` [PATCH] PCI: altera-msi: " Ley Foon Tan
@ 2019-05-14  5:35 ` Ley Foon Tan
  2019-05-30 15:07   ` Lorenzo Pieralisi
  2019-06-04 13:18 ` Bjorn Helgaas
  2 siblings, 1 reply; 10+ messages in thread
From: Ley Foon Tan @ 2019-05-14  5:35 UTC (permalink / raw)
  To: Ley Foon Tan
  Cc: Bjorn Helgaas, Lorenzo Pieralisi, linux-kernel, linux-pci, devicetree

On Wed, Apr 24, 2019 at 12:57 PM Ley Foon Tan <ley.foon.tan@intel.com> wrote:
>
> Altera PCIe Rootport IP is a soft IP and is only available after
> FPGA image is programmed.
>
> Make driver modulable to support use case FPGA image is programmed
> after kernel is booted. User proram FPGA image in kernel then only load
> PCIe driver module.
>
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
>  drivers/pci/controller/Kconfig       |  2 +-
>  drivers/pci/controller/pcie-altera.c | 28 ++++++++++++++++++++++++++--
>  2 files changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> index 6012f3059acd..4b550f9cdd56 100644
> --- a/drivers/pci/controller/Kconfig
> +++ b/drivers/pci/controller/Kconfig
> @@ -174,7 +174,7 @@ config PCIE_IPROC_MSI
>           PCIe controller
>
>  config PCIE_ALTERA
> -       bool "Altera PCIe controller"
> +       tristate "Altera PCIe controller"
>         depends on ARM || NIOS2 || ARM64 || COMPILE_TEST
>         help
>           Say Y here if you want to enable PCIe controller support on Altera
> diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c
> index 27edcebd1726..6c86bc69ace8 100644
> --- a/drivers/pci/controller/pcie-altera.c
> +++ b/drivers/pci/controller/pcie-altera.c
> @@ -10,6 +10,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/irqchip/chained_irq.h>
>  #include <linux/init.h>
> +#include <linux/module.h>
>  #include <linux/of_address.h>
>  #include <linux/of_device.h>
>  #include <linux/of_irq.h>
> @@ -705,6 +706,13 @@ static int altera_pcie_init_irq_domain(struct altera_pcie *pcie)
>         return 0;
>  }
>
> +static int altera_pcie_irq_teardown(struct altera_pcie *pcie)
> +{
> +       irq_set_chained_handler_and_data(pcie->irq, NULL, NULL);
> +       irq_domain_remove(pcie->irq_domain);
> +       irq_dispose_mapping(pcie->irq);
> +}
> +
>  static int altera_pcie_parse_dt(struct altera_pcie *pcie)
>  {
>         struct device *dev = &pcie->pdev->dev;
> @@ -798,6 +806,7 @@ static int altera_pcie_probe(struct platform_device *pdev)
>
>         pcie = pci_host_bridge_priv(bridge);
>         pcie->pdev = pdev;
> +       platform_set_drvdata(pdev, pcie);
>
>         match = of_match_device(altera_pcie_of_match, &pdev->dev);
>         if (!match)
> @@ -855,13 +864,28 @@ static int altera_pcie_probe(struct platform_device *pdev)
>         return ret;
>  }
>
> +static int altera_pcie_remove(struct platform_device *pdev)
> +{
> +       struct altera_pcie *pcie = platform_get_drvdata(pdev);
> +       struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
> +
> +       pci_stop_root_bus(bridge->bus);
> +       pci_remove_root_bus(bridge->bus);
> +       pci_free_resource_list(&pcie->resources);
> +       altera_pcie_irq_teardown(pcie);
> +
> +       return 0;
> +}
> +
>  static struct platform_driver altera_pcie_driver = {
>         .probe          = altera_pcie_probe,
> +       .remove         = altera_pcie_remove,
>         .driver = {
>                 .name   = "altera-pcie",
>                 .of_match_table = altera_pcie_of_match,
> -               .suppress_bind_attrs = true,
>         },
>  };
>
> -builtin_platform_driver(altera_pcie_driver);
> +MODULE_DEVICE_TABLE(of, altera_pcie_of_match);
> +module_platform_driver(altera_pcie_driver);
> +MODULE_LICENSE("GPL v2");
> --
> 2.19.0
>
Hi

Any comment for this patch?

Regards
Ley Foon

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] PCI: altera-msi: Allow building as module
  2019-04-24  4:57 ` [PATCH] PCI: altera-msi: " Ley Foon Tan
@ 2019-05-14  5:35   ` Ley Foon Tan
  2019-05-15 13:59     ` Lorenzo Pieralisi
  2019-05-30 15:08   ` Lorenzo Pieralisi
  1 sibling, 1 reply; 10+ messages in thread
From: Ley Foon Tan @ 2019-05-14  5:35 UTC (permalink / raw)
  To: Ley Foon Tan
  Cc: Bjorn Helgaas, Lorenzo Pieralisi, linux-kernel, linux-pci, devicetree

On Wed, Apr 24, 2019 at 12:57 PM Ley Foon Tan <ley.foon.tan@intel.com> wrote:
>
> Altera MSI IP is a soft IP and is only available after
> FPGA image is programmed.
>
> Make driver modulable to support use case FPGA image is programmed
> after kernel is booted. User proram FPGA image in kernel then only load
> MSI driver module.
>
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
>  drivers/pci/controller/Kconfig           |  2 +-
>  drivers/pci/controller/pcie-altera-msi.c | 10 ++++++++++
>  2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> index 4b550f9cdd56..920546cb84e2 100644
> --- a/drivers/pci/controller/Kconfig
> +++ b/drivers/pci/controller/Kconfig
> @@ -181,7 +181,7 @@ config PCIE_ALTERA
>           FPGA.
>
>  config PCIE_ALTERA_MSI
> -       bool "Altera PCIe MSI feature"
> +       tristate "Altera PCIe MSI feature"
>         depends on PCIE_ALTERA
>         depends on PCI_MSI_IRQ_DOMAIN
>         help
> diff --git a/drivers/pci/controller/pcie-altera-msi.c b/drivers/pci/controller/pcie-altera-msi.c
> index 025ef7d9a046..16d938920ca5 100644
> --- a/drivers/pci/controller/pcie-altera-msi.c
> +++ b/drivers/pci/controller/pcie-altera-msi.c
> @@ -10,6 +10,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/irqchip/chained_irq.h>
>  #include <linux/init.h>
> +#include <linux/module.h>
>  #include <linux/msi.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> @@ -288,4 +289,13 @@ static int __init altera_msi_init(void)
>  {
>         return platform_driver_register(&altera_msi_driver);
>  }
> +
> +static void __exit altera_msi_exit(void)
> +{
> +       platform_driver_unregister(&altera_msi_driver);
> +}
> +
>  subsys_initcall(altera_msi_init);
> +MODULE_DEVICE_TABLE(of, altera_msi_of_match);
> +module_exit(altera_msi_exit);
> +MODULE_LICENSE("GPL v2");
> --
> 2.19.0
>
Hi

Any comment for this patch?

Regards
Ley Foon

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] PCI: altera-msi: Allow building as module
  2019-05-14  5:35   ` Ley Foon Tan
@ 2019-05-15 13:59     ` Lorenzo Pieralisi
  2019-05-16  2:12       ` Ley Foon Tan
  0 siblings, 1 reply; 10+ messages in thread
From: Lorenzo Pieralisi @ 2019-05-15 13:59 UTC (permalink / raw)
  To: Ley Foon Tan
  Cc: Ley Foon Tan, Bjorn Helgaas, linux-kernel, linux-pci, devicetree

On Tue, May 14, 2019 at 01:35:20PM +0800, Ley Foon Tan wrote:
> On Wed, Apr 24, 2019 at 12:57 PM Ley Foon Tan <ley.foon.tan@intel.com> wrote:
> >
> > Altera MSI IP is a soft IP and is only available after
> > FPGA image is programmed.
> >
> > Make driver modulable to support use case FPGA image is programmed
> > after kernel is booted. User proram FPGA image in kernel then only load
> > MSI driver module.
> >
> > Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> > ---
> >  drivers/pci/controller/Kconfig           |  2 +-
> >  drivers/pci/controller/pcie-altera-msi.c | 10 ++++++++++
> >  2 files changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> > index 4b550f9cdd56..920546cb84e2 100644
> > --- a/drivers/pci/controller/Kconfig
> > +++ b/drivers/pci/controller/Kconfig
> > @@ -181,7 +181,7 @@ config PCIE_ALTERA
> >           FPGA.
> >
> >  config PCIE_ALTERA_MSI
> > -       bool "Altera PCIe MSI feature"
> > +       tristate "Altera PCIe MSI feature"
> >         depends on PCIE_ALTERA
> >         depends on PCI_MSI_IRQ_DOMAIN
> >         help
> > diff --git a/drivers/pci/controller/pcie-altera-msi.c b/drivers/pci/controller/pcie-altera-msi.c
> > index 025ef7d9a046..16d938920ca5 100644
> > --- a/drivers/pci/controller/pcie-altera-msi.c
> > +++ b/drivers/pci/controller/pcie-altera-msi.c
> > @@ -10,6 +10,7 @@
> >  #include <linux/interrupt.h>
> >  #include <linux/irqchip/chained_irq.h>
> >  #include <linux/init.h>
> > +#include <linux/module.h>
> >  #include <linux/msi.h>
> >  #include <linux/of_address.h>
> >  #include <linux/of_irq.h>
> > @@ -288,4 +289,13 @@ static int __init altera_msi_init(void)
> >  {
> >         return platform_driver_register(&altera_msi_driver);
> >  }
> > +
> > +static void __exit altera_msi_exit(void)
> > +{
> > +       platform_driver_unregister(&altera_msi_driver);
> > +}
> > +
> >  subsys_initcall(altera_msi_init);
> > +MODULE_DEVICE_TABLE(of, altera_msi_of_match);
> > +module_exit(altera_msi_exit);
> > +MODULE_LICENSE("GPL v2");
> > --
> > 2.19.0
> >
> Hi
> 
> Any comment for this patch?

I will get to these patches for the next merge window, thanks.

Lorenzo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] PCI: altera-msi: Allow building as module
  2019-05-15 13:59     ` Lorenzo Pieralisi
@ 2019-05-16  2:12       ` Ley Foon Tan
  0 siblings, 0 replies; 10+ messages in thread
From: Ley Foon Tan @ 2019-05-16  2:12 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Ley Foon Tan, Bjorn Helgaas, linux-kernel, linux-pci, devicetree

On Wed, May 15, 2019 at 9:59 PM Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
>
> On Tue, May 14, 2019 at 01:35:20PM +0800, Ley Foon Tan wrote:
> > On Wed, Apr 24, 2019 at 12:57 PM Ley Foon Tan <ley.foon.tan@intel.com> wrote:
> > >
> > > Altera MSI IP is a soft IP and is only available after
> > > FPGA image is programmed.
> > >
> > > Make driver modulable to support use case FPGA image is programmed
> > > after kernel is booted. User proram FPGA image in kernel then only load
> > > MSI driver module.
> > >
> > > Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> > > ---
> > >  drivers/pci/controller/Kconfig           |  2 +-
> > >  drivers/pci/controller/pcie-altera-msi.c | 10 ++++++++++
> > >  2 files changed, 11 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> > > index 4b550f9cdd56..920546cb84e2 100644
> > > --- a/drivers/pci/controller/Kconfig
> > > +++ b/drivers/pci/controller/Kconfig
> > > @@ -181,7 +181,7 @@ config PCIE_ALTERA
> > >           FPGA.
> > >
> > >  config PCIE_ALTERA_MSI
> > > -       bool "Altera PCIe MSI feature"
> > > +       tristate "Altera PCIe MSI feature"
> > >         depends on PCIE_ALTERA
> > >         depends on PCI_MSI_IRQ_DOMAIN
> > >         help
> > > diff --git a/drivers/pci/controller/pcie-altera-msi.c b/drivers/pci/controller/pcie-altera-msi.c
> > > index 025ef7d9a046..16d938920ca5 100644
> > > --- a/drivers/pci/controller/pcie-altera-msi.c
> > > +++ b/drivers/pci/controller/pcie-altera-msi.c
> > > @@ -10,6 +10,7 @@
> > >  #include <linux/interrupt.h>
> > >  #include <linux/irqchip/chained_irq.h>
> > >  #include <linux/init.h>
> > > +#include <linux/module.h>
> > >  #include <linux/msi.h>
> > >  #include <linux/of_address.h>
> > >  #include <linux/of_irq.h>
> > > @@ -288,4 +289,13 @@ static int __init altera_msi_init(void)
> > >  {
> > >         return platform_driver_register(&altera_msi_driver);
> > >  }
> > > +
> > > +static void __exit altera_msi_exit(void)
> > > +{
> > > +       platform_driver_unregister(&altera_msi_driver);
> > > +}
> > > +
> > >  subsys_initcall(altera_msi_init);
> > > +MODULE_DEVICE_TABLE(of, altera_msi_of_match);
> > > +module_exit(altera_msi_exit);
> > > +MODULE_LICENSE("GPL v2");
> > > --
> > > 2.19.0
> > >
> > Hi
> >
> > Any comment for this patch?
>
> I will get to these patches for the next merge window, thanks.

Thanks.

Regards
Ley Foon

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] PCI: altera: Allow building as module
  2019-05-14  5:35 ` [PATCH] PCI: altera: " Ley Foon Tan
@ 2019-05-30 15:07   ` Lorenzo Pieralisi
  0 siblings, 0 replies; 10+ messages in thread
From: Lorenzo Pieralisi @ 2019-05-30 15:07 UTC (permalink / raw)
  To: Ley Foon Tan
  Cc: Ley Foon Tan, Bjorn Helgaas, linux-kernel, linux-pci, devicetree

On Tue, May 14, 2019 at 01:35:05PM +0800, Ley Foon Tan wrote:
> On Wed, Apr 24, 2019 at 12:57 PM Ley Foon Tan <ley.foon.tan@intel.com> wrote:
> >
> > Altera PCIe Rootport IP is a soft IP and is only available after
> > FPGA image is programmed.
> >
> > Make driver modulable to support use case FPGA image is programmed
> > after kernel is booted. User proram FPGA image in kernel then only load
> > PCIe driver module.
> >
> > Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> > ---
> >  drivers/pci/controller/Kconfig       |  2 +-
> >  drivers/pci/controller/pcie-altera.c | 28 ++++++++++++++++++++++++++--
> >  2 files changed, 27 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> > index 6012f3059acd..4b550f9cdd56 100644
> > --- a/drivers/pci/controller/Kconfig
> > +++ b/drivers/pci/controller/Kconfig
> > @@ -174,7 +174,7 @@ config PCIE_IPROC_MSI
> >           PCIe controller
> >
> >  config PCIE_ALTERA
> > -       bool "Altera PCIe controller"
> > +       tristate "Altera PCIe controller"
> >         depends on ARM || NIOS2 || ARM64 || COMPILE_TEST
> >         help
> >           Say Y here if you want to enable PCIe controller support on Altera
> > diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c
> > index 27edcebd1726..6c86bc69ace8 100644
> > --- a/drivers/pci/controller/pcie-altera.c
> > +++ b/drivers/pci/controller/pcie-altera.c
> > @@ -10,6 +10,7 @@
> >  #include <linux/interrupt.h>
> >  #include <linux/irqchip/chained_irq.h>
> >  #include <linux/init.h>
> > +#include <linux/module.h>
> >  #include <linux/of_address.h>
> >  #include <linux/of_device.h>
> >  #include <linux/of_irq.h>
> > @@ -705,6 +706,13 @@ static int altera_pcie_init_irq_domain(struct altera_pcie *pcie)
> >         return 0;
> >  }
> >
> > +static int altera_pcie_irq_teardown(struct altera_pcie *pcie)
> > +{
> > +       irq_set_chained_handler_and_data(pcie->irq, NULL, NULL);
> > +       irq_domain_remove(pcie->irq_domain);
> > +       irq_dispose_mapping(pcie->irq);
> > +}
> > +
> >  static int altera_pcie_parse_dt(struct altera_pcie *pcie)
> >  {
> >         struct device *dev = &pcie->pdev->dev;
> > @@ -798,6 +806,7 @@ static int altera_pcie_probe(struct platform_device *pdev)
> >
> >         pcie = pci_host_bridge_priv(bridge);
> >         pcie->pdev = pdev;
> > +       platform_set_drvdata(pdev, pcie);
> >
> >         match = of_match_device(altera_pcie_of_match, &pdev->dev);
> >         if (!match)
> > @@ -855,13 +864,28 @@ static int altera_pcie_probe(struct platform_device *pdev)
> >         return ret;
> >  }
> >
> > +static int altera_pcie_remove(struct platform_device *pdev)
> > +{
> > +       struct altera_pcie *pcie = platform_get_drvdata(pdev);
> > +       struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
> > +
> > +       pci_stop_root_bus(bridge->bus);
> > +       pci_remove_root_bus(bridge->bus);
> > +       pci_free_resource_list(&pcie->resources);
> > +       altera_pcie_irq_teardown(pcie);
> > +
> > +       return 0;
> > +}
> > +
> >  static struct platform_driver altera_pcie_driver = {
> >         .probe          = altera_pcie_probe,
> > +       .remove         = altera_pcie_remove,
> >         .driver = {
> >                 .name   = "altera-pcie",
> >                 .of_match_table = altera_pcie_of_match,
> > -               .suppress_bind_attrs = true,
> >         },
> >  };
> >
> > -builtin_platform_driver(altera_pcie_driver);
> > +MODULE_DEVICE_TABLE(of, altera_pcie_of_match);
> > +module_platform_driver(altera_pcie_driver);
> > +MODULE_LICENSE("GPL v2");
> > --
> > 2.19.0
> >
> Hi
> 
> Any comment for this patch?

Applied to pci/altera for v5.3, thanks.

Lorenzo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] PCI: altera-msi: Allow building as module
  2019-04-24  4:57 ` [PATCH] PCI: altera-msi: " Ley Foon Tan
  2019-05-14  5:35   ` Ley Foon Tan
@ 2019-05-30 15:08   ` Lorenzo Pieralisi
  1 sibling, 0 replies; 10+ messages in thread
From: Lorenzo Pieralisi @ 2019-05-30 15:08 UTC (permalink / raw)
  To: Ley Foon Tan
  Cc: Bjorn Helgaas, linux-kernel, linux-pci, devicetree, lftan.linux

On Wed, Apr 24, 2019 at 12:57:15PM +0800, Ley Foon Tan wrote:
> Altera MSI IP is a soft IP and is only available after
> FPGA image is programmed.
> 
> Make driver modulable to support use case FPGA image is programmed
> after kernel is booted. User proram FPGA image in kernel then only load
> MSI driver module.
> 
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
>  drivers/pci/controller/Kconfig           |  2 +-
>  drivers/pci/controller/pcie-altera-msi.c | 10 ++++++++++
>  2 files changed, 11 insertions(+), 1 deletion(-)

Applied to pci/altera for v5.3, thanks.

Lorenzo

> diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> index 4b550f9cdd56..920546cb84e2 100644
> --- a/drivers/pci/controller/Kconfig
> +++ b/drivers/pci/controller/Kconfig
> @@ -181,7 +181,7 @@ config PCIE_ALTERA
>  	  FPGA.
>  
>  config PCIE_ALTERA_MSI
> -	bool "Altera PCIe MSI feature"
> +	tristate "Altera PCIe MSI feature"
>  	depends on PCIE_ALTERA
>  	depends on PCI_MSI_IRQ_DOMAIN
>  	help
> diff --git a/drivers/pci/controller/pcie-altera-msi.c b/drivers/pci/controller/pcie-altera-msi.c
> index 025ef7d9a046..16d938920ca5 100644
> --- a/drivers/pci/controller/pcie-altera-msi.c
> +++ b/drivers/pci/controller/pcie-altera-msi.c
> @@ -10,6 +10,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/irqchip/chained_irq.h>
>  #include <linux/init.h>
> +#include <linux/module.h>
>  #include <linux/msi.h>
>  #include <linux/of_address.h>
>  #include <linux/of_irq.h>
> @@ -288,4 +289,13 @@ static int __init altera_msi_init(void)
>  {
>  	return platform_driver_register(&altera_msi_driver);
>  }
> +
> +static void __exit altera_msi_exit(void)
> +{
> +	platform_driver_unregister(&altera_msi_driver);
> +}
> +
>  subsys_initcall(altera_msi_init);
> +MODULE_DEVICE_TABLE(of, altera_msi_of_match);
> +module_exit(altera_msi_exit);
> +MODULE_LICENSE("GPL v2");
> -- 
> 2.19.0
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] PCI: altera: Allow building as module
  2019-04-24  4:57 [PATCH] PCI: altera: Allow building as module Ley Foon Tan
  2019-04-24  4:57 ` [PATCH] PCI: altera-msi: " Ley Foon Tan
  2019-05-14  5:35 ` [PATCH] PCI: altera: " Ley Foon Tan
@ 2019-06-04 13:18 ` Bjorn Helgaas
  2019-06-11  7:22   ` Ley Foon Tan
  2 siblings, 1 reply; 10+ messages in thread
From: Bjorn Helgaas @ 2019-06-04 13:18 UTC (permalink / raw)
  To: Ley Foon Tan
  Cc: Lorenzo Pieralisi, linux-kernel, linux-pci, devicetree, lftan.linux

On Wed, Apr 24, 2019 at 12:57:14PM +0800, Ley Foon Tan wrote:
> Altera PCIe Rootport IP is a soft IP and is only available after
> FPGA image is programmed.
> 
> Make driver modulable to support use case FPGA image is programmed
> after kernel is booted. User proram FPGA image in kernel then only load
> PCIe driver module.

I'm not objecting to these patches, but help me understand how this
works.  The "usual" scenario is that if a driver is loaded before a
matching device is available, i.e., either the driver is built
statically or it is loaded before a device is hot-added, the event of
the device being available causes the driver's probe method to be
called.

This seems to be a more manual process of programming the FPGA which
results in a new "altera-pcie" platform device.  And then apparently
you need to load the appropriate module by hand?  Is there no
"hot-add" type of event for this platform device that automatically
looks for the driver?

Bjorn

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] PCI: altera: Allow building as module
  2019-06-04 13:18 ` Bjorn Helgaas
@ 2019-06-11  7:22   ` Ley Foon Tan
  0 siblings, 0 replies; 10+ messages in thread
From: Ley Foon Tan @ 2019-06-11  7:22 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Ley Foon Tan, Lorenzo Pieralisi, linux-kernel, linux-pci, devicetree

On Tue, Jun 4, 2019 at 9:18 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> On Wed, Apr 24, 2019 at 12:57:14PM +0800, Ley Foon Tan wrote:
> > Altera PCIe Rootport IP is a soft IP and is only available after
> > FPGA image is programmed.
> >
> > Make driver modulable to support use case FPGA image is programmed
> > after kernel is booted. User proram FPGA image in kernel then only load
> > PCIe driver module.
>
> I'm not objecting to these patches, but help me understand how this
> works.  The "usual" scenario is that if a driver is loaded before a
> matching device is available, i.e., either the driver is built
> statically or it is loaded before a device is hot-added, the event of
> the device being available causes the driver's probe method to be
> called.
>
> This seems to be a more manual process of programming the FPGA which
> results in a new "altera-pcie" platform device.  And then apparently
> you need to load the appropriate module by hand?  Is there no
> "hot-add" type of event for this platform device that automatically
> looks for the driver?
Yes, we need load module manually now.

Regards
Ley Foon

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-06-11  7:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24  4:57 [PATCH] PCI: altera: Allow building as module Ley Foon Tan
2019-04-24  4:57 ` [PATCH] PCI: altera-msi: " Ley Foon Tan
2019-05-14  5:35   ` Ley Foon Tan
2019-05-15 13:59     ` Lorenzo Pieralisi
2019-05-16  2:12       ` Ley Foon Tan
2019-05-30 15:08   ` Lorenzo Pieralisi
2019-05-14  5:35 ` [PATCH] PCI: altera: " Ley Foon Tan
2019-05-30 15:07   ` Lorenzo Pieralisi
2019-06-04 13:18 ` Bjorn Helgaas
2019-06-11  7:22   ` Ley Foon Tan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).