Skip to contentSkip to conversation

PCI: mvebu: Add support for unbinding and unloading driver

PATCH Applied Pali Rohár 2 participants 4 messages Nov 26, 2021 – Jan 6, 2022

Subsystems (4)
lore
Share & tools
lore

Pali Rohár

author maintainer
#0 lore raw

cover PCI: mvebu: Add support for unbinding and unloading driver

This patch series add support for unbinding device from pci-mvebu driver, allow to compile pci-mvebu.c as kernel module pci-mvebu.ko and allow to rmmod this module.

This patch series depends on another patch series which converts pci-mvebu.c driver to use devm_pci_remap_iospace() function:

"arm: ioremap: Remove pci_ioremap_io() and mvebu_pci_host_probe()":
https://lore.kernel.org/linux-pci/[email protected]/

Without usage of devm_pci_remap_iospace() it is not possible to bind device to pci-mvebu driver again after unbinding it.

Tested on Turris Omnia - Armada 385 board.

Pali Rohár (2):
bus: mvebu-mbus: Export symbols for public API window functions
PCI: mvebu: Add support for compiling driver as module

 drivers/bus/mvebu-mbus.c           |  5 ++
 drivers/pci/controller/Kconfig     |  2 +-
 drivers/pci/controller/pci-mvebu.c | 91 +++++++++++++++++++++++++-----
 3 files changed, 82 insertions(+), 16 deletions(-)
Signature · 7 lines
2.20.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author maintainer
#1 lore raw

PATCH 1/2 bus: mvebu-mbus: Export symbols for public API window functions

This would allow to compile pci-mvebu.c driver as module.

---
 drivers/bus/mvebu-mbus.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/bus/mvebu-mbus.c +5 -0
index ea0424922de7..db612045616f 100644
@@ -914,6 +914,7 @@ int mvebu_mbus_add_window_remap_by_id(unsigned int target,
 
 	return mvebu_mbus_alloc_window(s, base, size, remap, target, attribute);
 }
+EXPORT_SYMBOL_GPL(mvebu_mbus_add_window_remap_by_id);
 
 int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
 				phys_addr_t base, size_t size)
@@ -921,6 +922,7 @@ int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
 	return mvebu_mbus_add_window_remap_by_id(target, attribute, base,
 						 size, MVEBU_MBUS_NO_REMAP);
 }
+EXPORT_SYMBOL_GPL(mvebu_mbus_add_window_by_id);
 
 int mvebu_mbus_del_window(phys_addr_t base, size_t size)
 {
@@ -933,6 +935,7 @@ int mvebu_mbus_del_window(phys_addr_t base, size_t size)
 	mvebu_mbus_disable_window(&mbus_state, win);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(mvebu_mbus_del_window);
 
 void mvebu_mbus_get_pcie_mem_aperture(struct resource *res)
 {
@@ -940,6 +943,7 @@ void mvebu_mbus_get_pcie_mem_aperture(struct resource *res)
 		return;
 	*res = mbus_state.pcie_mem_aperture;
 }
+EXPORT_SYMBOL_GPL(mvebu_mbus_get_pcie_mem_aperture);
 
 void mvebu_mbus_get_pcie_io_aperture(struct resource *res)
 {
@@ -947,6 +951,7 @@ void mvebu_mbus_get_pcie_io_aperture(struct resource *res)
 		return;
 	*res = mbus_state.pcie_io_aperture;
 }
+EXPORT_SYMBOL_GPL(mvebu_mbus_get_pcie_io_aperture);
 
 int mvebu_mbus_get_dram_win_info(phys_addr_t phyaddr, u8 *target, u8 *attr)
 {
Signature · 7 lines
2.20.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author maintainer
#2 lore raw

PATCH 2/2 PCI: mvebu: Add support for compiling driver as module

In reply to Pali Rohár

Now when driver uses devm_pci_remap_iospace() function, it is possible implement ->remove() callback for unbinding device from driver.

Implement mvebu_pcie_remove() callback with proper cleanup phase, drop driver's suppress_bind_attrs flag and switch type of CONFIG_PCI_MVEBU option from bool to tristate.

This allows to compile pci-mvebu.c driver as loadable module pci-mvebu.ko with ability to unload it.

---
 drivers/pci/controller/Kconfig     |  2 +-
 drivers/pci/controller/pci-mvebu.c | 91 +++++++++++++++++++++++++-----
 2 files changed, 77 insertions(+), 16 deletions(-)
drivers/pci/controller/Kconfig +1 -1
index 93b141110537..67189bcd5d89 100644
@@ -4,7 +4,7 @@ menu "PCI controller drivers"
 	depends on PCI
 
 config PCI_MVEBU
-	bool "Marvell EBU PCIe controller"
+	tristate "Marvell EBU PCIe controller"
 	depends on ARCH_MVEBU || ARCH_DOVE || COMPILE_TEST
 	depends on MVEBU_MBUS
 	depends on ARM
drivers/pci/controller/pci-mvebu.c +76 -15

126 lines not on this page · raw message

Signature · 7 lines
2.20.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#3 lore raw
In reply to Pali Rohár
Quoted 8 lines · Pali Rohár

This patch series add support for unbinding device from pci-mvebu driver, allow to compile pci-mvebu.c as kernel module pci-mvebu.ko and allow to rmmod this module.

This patch series depends on another patch series which converts pci-mvebu.c driver to use devm_pci_remap_iospace() function:

[...]

Applied to pci/mvebu, thanks!

[1/2] bus: mvebu-mbus: Export symbols for public API window functions

      https://git.kernel.org/lpieralisi/pci/c/859186e238
[2/2] PCI: mvebu: Add support for compiling driver as module
      https://git.kernel.org/lpieralisi/pci/c/0746ae1be1

Thanks,
Lorenzo