Skip to contentSkip to conversation

PCI: more trivial demodularization of builtin code

PATCH Applied Paul Gortmaker 3 participants 11 messages Aug 22, 2016 – Aug 24, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover PCI: more trivial demodularization of builtin code

This is another group of commits that was chosen since they really don't change anything even at a binary object file level ; they just replace module_init with device_initcall (which are identical), and remove some MODULE_<blah> tags that are no-ops in code. So the run time regression risk is zero here.

More specifically, we are doing the following to these PCI files that currently can only be built-in:

-- remove the include of module.h ; replace it with init.h as req'd

-- drop instances of MODULE_DEVICE_TABLE which is a no-op built-in.

-- replace module_init (if present) with device_initcall, which is
functionally identical once CPP has processed the source.

-- drop instances of MODULE_LICENSE, MODULE_AUTHOR, MODULE_DESCRIPTION
while ensuring the contained info is present in the file comments.

Build tested for allmodconfig on several arch, including ARM and ARM-64 on a recent linux-next baseline.

Some non-modular PCI files still remain with unused __exit and/or .remove functions. Those will be dealt with in a separate series after this.

Also note that we looked into modularizing some of the PCI_DW stuff at an earlier time[1] but that ran into problems such as trying to create unwind for hook_fault_code etc. that wasn't easily solved. So we just go with keeping the code runtime functionally equivalent to what it was.

Paul.

[1] https://lkml.kernel.org/r/[email protected]

---

Cc Bjorn Helgaas <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Lucas Stach <[email protected]>
Cc Pratyush Anand <[email protected]>
Cc Richard Zhu <[email protected]>
Cc Tom Long Nguyen <[email protected]>
Cc Will Deacon <[email protected]>

Paul Gortmaker (8):
PCI: altera: make msi explicitly non-modular
PCI: altera: make it explicitly non-modular
PCI: imx6: make it explicitly non-modular
PCI: portdrv: make it explicitly non-modular
PCI: spear13xx: make it explicitly non-modular
PCI: designware: make host support explicitly non-modular
PCI: exynos: make host support explicitly non-modular
PCI: generic: make host-common explicitly non-modular

 drivers/pci/host/pci-exynos.c      |  7 +------
 drivers/pci/host/pci-host-common.c |  7 ++-----
 drivers/pci/host/pci-imx6.c        |  9 +--------
 drivers/pci/host/pcie-altera-msi.c | 10 +++++-----
 drivers/pci/host/pcie-altera.c     | 12 +++++-------
 drivers/pci/host/pcie-designware.c |  5 -----
 drivers/pci/host/pcie-spear13xx.c  | 11 ++---------
 drivers/pci/pcie/portdrv_pci.c     |  8 +-------
 8 files changed, 17 insertions(+), 52 deletions(-)
Signature · 1 line
2.8.4
#7 lore raw

PATCH 7/8 PCI: exynos: make host support explicitly non-modular

The Kconfig currently controlling compilation of this code is:

drivers/pci/host/Kconfig:config PCI_EXYNOS
drivers/pci/host/Kconfig: bool "Samsung Exynos PCIe controller"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.

Note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

Cc Jingoo Han <[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
---
 drivers/pci/host/pci-exynos.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/pci/host/pci-exynos.c +1 -6
index 219976103efc..c3ae9c7a6e33 100644
@@ -16,7 +16,7 @@
 #include <linux/gpio.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/of_gpio.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
@@ -624,7 +624,6 @@ static const struct of_device_id exynos_pcie_of_match[] = {
 	{ .compatible = "samsung,exynos5440-pcie", },
 	{},
 };
-MODULE_DEVICE_TABLE(of, exynos_pcie_of_match);
 
 static struct platform_driver exynos_pcie_driver = {
 	.remove		= __exit_p(exynos_pcie_remove),
@@ -641,7 +640,3 @@ static int __init exynos_pcie_init(void)
 	return platform_driver_probe(&exynos_pcie_driver, exynos_pcie_probe);
 }
 subsys_initcall(exynos_pcie_init);
-
-MODULE_AUTHOR("Jingoo Han <[email protected]>");
-MODULE_DESCRIPTION("Samsung PCIe host controller driver");
-MODULE_LICENSE("GPL v2");
Signature · 1 line
2.8.4
#1 lore raw

PATCH 1/8 PCI: altera: make msi explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/pci/host/Kconfig:config PCIE_ALTERA_MSI
drivers/pci/host/Kconfig: bool "Altera PCIe MSI feature"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.

We also delete the MODULE_LICENSE tag etc. since all that information was (or is now) contained at the top of the file in the comments.

---
 drivers/pci/host/pcie-altera-msi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pci/host/pcie-altera-msi.c +5 -5
index 99177f4ccde2..369e033449c6 100644
@@ -1,4 +1,8 @@
 /*
+ * Altera PCIe MSI support
+ *
+ * Author: Ley Foon Tan <[email protected]>
+ *
  * Copyright Altera Corporation (C) 2013-2015. All rights reserved
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -16,7 +20,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/irqchip/chained_irq.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/msi.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
@@ -308,7 +312,3 @@ static int __init altera_msi_init(void)
 	return platform_driver_register(&altera_msi_driver);
 }
 subsys_initcall(altera_msi_init);
-
-MODULE_AUTHOR("Ley Foon Tan <[email protected]>");
-MODULE_DESCRIPTION("Altera PCIe MSI support");
-MODULE_LICENSE("GPL v2");
Signature · 1 line
2.8.4
#2 lore raw

PATCH 2/8 PCI: altera: make it explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/pci/host/Kconfig:config PCIE_ALTERA
drivers/pci/host/Kconfig: bool "Altera PCIe controller"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information was (or is now) contained at the top of the file in the comments.

---
 drivers/pci/host/pcie-altera.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/pci/host/pcie-altera.c +5 -7
index 2b7837650db8..48f2736a10cd 100644
@@ -1,6 +1,9 @@
 /*
  * Copyright Altera Corporation (C) 2013-2015. All rights reserved
  *
+ * Author: Ley Foon Tan <[email protected]>
+ * Description: Altera PCIe host controller driver
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
  * version 2, as published by the Free Software Foundation.
@@ -17,7 +20,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/irqchip/chained_irq.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/of_pci.h>
@@ -568,7 +571,6 @@ static const struct of_device_id altera_pcie_of_match[] = {
 	{ .compatible = "altr,pcie-root-port-1.0", },
 	{},
 };
-MODULE_DEVICE_TABLE(of, altera_pcie_of_match);
 
 static struct platform_driver altera_pcie_driver = {
 	.probe		= altera_pcie_probe,
@@ -583,8 +585,4 @@ static int altera_pcie_init(void)
 {
 	return platform_driver_register(&altera_pcie_driver);
 }
-module_init(altera_pcie_init);
-
-MODULE_AUTHOR("Ley Foon Tan <[email protected]>");
-MODULE_DESCRIPTION("Altera PCIe host controller driver");
-MODULE_LICENSE("GPL v2");
+device_initcall(altera_pcie_init);
Signature · 1 line
2.8.4
#4 lore raw

PATCH 4/8 PCI: portdrv: make it explicitly non-modular

In reply to Paul Gortmaker

The Makefile/Kconfig currently controlling compilation of this code is:

pcieportdrv-y := portdrv_core.o portdrv_pci.o portdrv_bus.o
obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o

drivers/pci/pcie/Kconfig:config PCIEPORTBUS
drivers/pci/pcie/Kconfig: bool "PCI Express Port Bus support"

...meaning that it currently is not being built as a module by anyone.

Lets remove the modular code that is essentially orphaned, so that when reading the driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.

We don't replace module.h with init.h since the file already has that.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained earlier up in the file.

---
 drivers/pci/pcie/portdrv_pci.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/pci/pcie/portdrv_pci.c +1 -7
index 70d7ad8c6d17..85f7afcd6227 100644
@@ -6,7 +6,6 @@
  * Copyright (C) Tom Long Nguyen ([email protected])
  */
 
-#include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -27,9 +26,6 @@
 #define DRIVER_VERSION "v1.0"
 #define DRIVER_AUTHOR "[email protected]"
 #define DRIVER_DESC "PCIe Port Bus Driver"
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
 
 /* If this switch is set, PCIe port native services should not be enabled. */
 bool pcie_ports_disabled;
@@ -341,7 +337,6 @@ static const struct pci_device_id port_pci_ids[] = { {
 	PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0),
 	}, { /* end: all zeroes */ }
 };
-MODULE_DEVICE_TABLE(pci, port_pci_ids);
 
 static const struct pci_error_handlers pcie_portdrv_err_handler = {
 	.error_detected = pcie_portdrv_error_detected,
@@ -406,5 +401,4 @@ static int __init pcie_portdrv_init(void)
  out:
 	return retval;
 }
-
-module_init(pcie_portdrv_init);
+device_initcall(pcie_portdrv_init);
Signature · 1 line
2.8.4
#5 lore raw

PATCH 5/8 PCI: spear13xx: make it explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/pci/host/Kconfig:config PCIE_SPEAR13XX
drivers/pci/host/Kconfig: bool "STMicroelectronics SPEAr PCIe controller"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple instances of modular code usage, so that when reading the driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

---
 drivers/pci/host/pcie-spear13xx.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/pci/host/pcie-spear13xx.c +2 -9
index a4060b85ab23..09aed85f275a 100644
@@ -15,7 +15,7 @@
 #include <linux/clk.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
 #include <linux/of.h>
 #include <linux/pci.h>
 #include <linux/phy/phy.h>
@@ -355,7 +355,6 @@ static const struct of_device_id spear13xx_pcie_of_match[] = {
 	{ .compatible = "st,spear1340-pcie", },
 	{},
 };
-MODULE_DEVICE_TABLE(of, spear13xx_pcie_of_match);
 
 static struct platform_driver spear13xx_pcie_driver = {
 	.probe		= spear13xx_pcie_probe,
@@ -365,14 +364,8 @@ static struct platform_driver spear13xx_pcie_driver = {
 	},
 };
 
-/* SPEAr13xx PCIe driver does not allow module unload */
-
 static int __init spear13xx_pcie_init(void)
 {
 	return platform_driver_register(&spear13xx_pcie_driver);
 }
-module_init(spear13xx_pcie_init);
-
-MODULE_DESCRIPTION("ST Microelectronics SPEAr13xx PCIe host controller driver");
-MODULE_AUTHOR("Pratyush Anand <[email protected]>");
-MODULE_LICENSE("GPL v2");
+device_initcall(spear13xx_pcie_init);
Signature · 1 line
2.8.4
#6 lore raw

PATCH 6/8 PCI: designware: make host support explicitly non-modular

In reply to Paul Gortmaker

The Kconfig entry controlling compilation of this code is:

drivers/pci/host/Kconfig:config PCIE_DW
drivers/pci/host/Kconfig: bool

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.

We delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

We don't end up adding init.h to this file, since it isn't actually using __init or any initcalls directly.

Cc Jingoo Han <[email protected]>
Cc Pratyush Anand <[email protected]>
Cc Bjorn Helgaas <[email protected]>
---
 drivers/pci/host/pcie-designware.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/pci/host/pcie-designware.c +0 -5
index 12afce19890b..16374202cb8b 100644
@@ -14,7 +14,6 @@
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/msi.h>
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
@@ -802,7 +801,3 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
 	val |= PORT_LOGIC_SPEED_CHANGE;
 	dw_pcie_wr_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, val);
 }
-
-MODULE_AUTHOR("Jingoo Han <[email protected]>");
-MODULE_DESCRIPTION("Designware PCIe host controller driver");
-MODULE_LICENSE("GPL v2");
Signature · 1 line
2.8.4
#3 lore raw

PATCH 3/8 PCI: imx6: make it explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/pci/host/Kconfig:config PCI_IMX6
drivers/pci/host/Kconfig: bool "Freescale i.MX6 PCIe controller"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple instances of modular code usage, so that when reading the driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular case, the init ordering remains unchanged with this commit.

Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We don't delete module.h since the file never even had that.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

---
 drivers/pci/host/pci-imx6.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/pci/host/pci-imx6.c +1 -8
index b741a36a67f3..ead4a5c3480b 100644
@@ -739,7 +739,6 @@ static const struct of_device_id imx6_pcie_of_match[] = {
 	{ .compatible = "fsl,imx6qp-pcie", .data = (void *)IMX6QP, },
 	{},
 };
-MODULE_DEVICE_TABLE(of, imx6_pcie_of_match);
 
 static struct platform_driver imx6_pcie_driver = {
 	.driver = {
@@ -749,14 +748,8 @@ static struct platform_driver imx6_pcie_driver = {
 	.shutdown = imx6_pcie_shutdown,
 };
 
-/* Freescale PCIe driver does not allow module unload */
-
 static int __init imx6_pcie_init(void)
 {
 	return platform_driver_probe(&imx6_pcie_driver, imx6_pcie_probe);
 }
-module_init(imx6_pcie_init);
-
-MODULE_AUTHOR("Sean Cross <[email protected]>");
-MODULE_DESCRIPTION("Freescale i.MX6 PCIe host controller driver");
-MODULE_LICENSE("GPL v2");
+device_initcall(imx6_pcie_init);
Signature · 1 line
2.8.4
#9 lore raw

PATCH 8/8 PCI: generic: make host-common explicitly non-modular

In reply to Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/pci/host/Kconfig:config PCI_HOST_COMMON
drivers/pci/host/Kconfig: bool

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple trivial modular references, so that when reading the code there is no doubt it is builtin-only.

There are no modular init calls in this code, so no init ordering issues to be concerned with here.

We don't replace module.h with init.h since the file does not have any functions marked with the __init prefix.

We delete the MODULE_LICENSE tag etc. since all that information was (or is now) contained at the top of the file in the comments.

---
 drivers/pci/host/pci-host-common.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/pci/host/pci-host-common.c +2 -5
index 9d9d34e959b6..946382fd4ea1 100644
@@ -1,4 +1,6 @@
 /*
+ * Generic PCI host driver common code
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
@@ -17,7 +19,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
 #include <linux/pci-ecam.h>
@@ -162,7 +163,3 @@ int pci_host_common_probe(struct platform_device *pdev,
 	pci_bus_add_devices(bus);
 	return 0;
 }
-
-MODULE_DESCRIPTION("Generic PCI host driver common code");
-MODULE_AUTHOR("Will Deacon <[email protected]>");
-MODULE_LICENSE("GPL v2");
Signature · 1 line
2.8.4
#10 lore raw
In reply to Paul Gortmaker
Quoted 60 lines · Paul Gortmaker

This is another group of commits that was chosen since they really don't change anything even at a binary object file level ; they just replace module_init with device_initcall (which are identical), and remove some MODULE_<blah> tags that are no-ops in code. So the run time regression risk is zero here.

More specifically, we are doing the following to these PCI files that currently can only be built-in:

-- remove the include of module.h ; replace it with init.h as req'd

-- drop instances of MODULE_DEVICE_TABLE which is a no-op built-in.

-- replace module_init (if present) with device_initcall, which is
functionally identical once CPP has processed the source.

-- drop instances of MODULE_LICENSE, MODULE_AUTHOR, MODULE_DESCRIPTION
while ensuring the contained info is present in the file comments.

Build tested for allmodconfig on several arch, including ARM and ARM-64 on a recent linux-next baseline.

Some non-modular PCI files still remain with unused __exit and/or .remove functions. Those will be dealt with in a separate series after this.

Also note that we looked into modularizing some of the PCI_DW stuff at an earlier time[1] but that ran into problems such as trying to create unwind for hook_fault_code etc. that wasn't easily solved. So we just go with keeping the code runtime functionally equivalent to what it was.

Paul.

[1] https://lkml.kernel.org/r/[email protected]

---

Cc Bjorn Helgaas <[email protected]>
Cc Jingoo Han <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Ley Foon Tan <[email protected]>
Cc Lucas Stach <[email protected]>
Cc Pratyush Anand <[email protected]>
Cc Richard Zhu <[email protected]>
Cc Tom Long Nguyen <[email protected]>
Cc Will Deacon <[email protected]>

Paul Gortmaker (8):
PCI: altera: make msi explicitly non-modular
PCI: altera: make it explicitly non-modular
PCI: imx6: make it explicitly non-modular
PCI: portdrv: make it explicitly non-modular
PCI: spear13xx: make it explicitly non-modular
PCI: designware: make host support explicitly non-modular
PCI: exynos: make host support explicitly non-modular
PCI: generic: make host-common explicitly non-modular

Quoted 9 lines
 drivers/pci/host/pci-exynos.c      |  7 +------
 drivers/pci/host/pci-host-common.c |  7 ++-----
 drivers/pci/host/pci-imx6.c        |  9 +--------
 drivers/pci/host/pcie-altera-msi.c | 10 +++++-----
 drivers/pci/host/pcie-altera.c     | 12 +++++-------
 drivers/pci/host/pcie-designware.c |  5 -----
 drivers/pci/host/pcie-spear13xx.c  | 11 ++---------
 drivers/pci/pcie/portdrv_pci.c     |  8 +-------
 8 files changed, 17 insertions(+), 52 deletions(-)

I applied all these to pci/demodularize for v4.9, thanks, Paul!

maintainer Acked-by on v1 7/8
#8 lore raw

Re: [PATCH 7/8] PCI: exynos: make host support explicitly non-modular

In reply to Paul Gortmaker
Quoted 22 lines · Paul Gortmaker

The Kconfig currently controlling compilation of this code is:

drivers/pci/host/Kconfig:config PCI_EXYNOS
drivers/pci/host/Kconfig: bool "Samsung Exynos PCIe controller"

...meaning that it currently is not being built as a module by anyone.

Lets remove the couple traces of modular infrastructure use, so that when reading the driver there is no doubt it is builtin-only.

Note that MODULE_DEVICE_TABLE is a no-op for non-modular code.

We also delete the MODULE_LICENSE tag etc. since all that information is already contained at the top of the file in the comments.

Cc Jingoo Han <[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Quoted 4 lines
---
 drivers/pci/host/pci-exynos.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Best regards,
Krzysztof