Skip to contentSkip to conversation

firmware: coreboot: store owner from modules with coreboot_driver_register()

PATCH Applied Krzysztof Kozlowski 3 participants 7 messages Mar 30, 2024 – May 27, 2024 ChromeOS EC subdrivers

lore
Share & tools
lore
#0 lore raw

cover firmware: coreboot: store owner from modules with coreboot_driver_register()

Moving the .owner setting code to the core this effectively fixes missing .owner in framebuffer-coreboot, memconsole-coreboot and vpd drivers.

Best regards,
Krzysztof

---
Krzysztof Kozlowski (2):
firmware: coreboot: store owner from modules with coreboot_driver_register()
firmware: google: cbmem: drop driver owner initialization

 drivers/firmware/google/cbmem.c          | 1 -
 drivers/firmware/google/coreboot_table.c | 6 ++++--
 drivers/firmware/google/coreboot_table.h | 6 +++++-
 3 files changed, 9 insertions(+), 4 deletions(-)

---
base-commit: 7fdcff3312e16ba8d1419f8a18f465c5cc235ecf
change-id: 20240330-module-owner-coreboot-114292b6d11b

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>
#1 lore raw

PATCH 1/2 firmware: coreboot: store owner from modules with coreboot_driver_register()

Modules registering driver with coreboot_driver_register() might forget to set .owner field. The field is used by some of other kernel parts for reference counting (try_module_get()), so it is expected that drivers will set it.

Solve the problem by moving this task away from the drivers to the core code, just like we did for platform_driver in
commit 9447057eaff8 ("platform_device: use a macro instead of platform_driver_register").

Moving the .owner setting code to the core this effectively fixes missing .owner in framebuffer-coreboot, memconsole-coreboot and vpd drivers.

---
 drivers/firmware/google/coreboot_table.c | 6 ++++--
 drivers/firmware/google/coreboot_table.h | 6 +++++-
 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/firmware/google/coreboot_table.c +4 -2
index d4b6e581a6c6..fa7752f6e89b 100644
@@ -85,13 +85,15 @@ static void coreboot_device_release(struct device *dev)
 	kfree(device);
 }
 
-int coreboot_driver_register(struct coreboot_driver *driver)
+int __coreboot_driver_register(struct coreboot_driver *driver,
+			       struct module *owner)
 {
 	driver->drv.bus = &coreboot_bus_type;
+	driver->drv.owner = owner;
 
 	return driver_register(&driver->drv);
 }
-EXPORT_SYMBOL(coreboot_driver_register);
+EXPORT_SYMBOL(__coreboot_driver_register);
 
 void coreboot_driver_unregister(struct coreboot_driver *driver)
 {
drivers/firmware/google/coreboot_table.h +5 -1
index 86427989c57f..bb6f0f7299b4 100644
@@ -97,8 +97,12 @@ struct coreboot_driver {
 	const struct coreboot_device_id *id_table;
 };
 
+/* use a macro to avoid include chaining to get THIS_MODULE */
+#define coreboot_driver_register(driver) \
+	__coreboot_driver_register(driver, THIS_MODULE)
 /* Register a driver that uses the data from a coreboot table. */
-int coreboot_driver_register(struct coreboot_driver *driver);
+int __coreboot_driver_register(struct coreboot_driver *driver,
+			       struct module *owner);
 
 /* Unregister a driver that uses the data from a coreboot table. */
 void coreboot_driver_unregister(struct coreboot_driver *driver);
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 firmware: google: cbmem: drop driver owner initialization

In reply to Krzysztof Kozlowski

Core in coreboot_driver_register() already sets the .owner, so driver does not need to.

---
 drivers/firmware/google/cbmem.c | 1 -
 1 file changed, 1 deletion(-)
drivers/firmware/google/cbmem.c +0 -1
index c2bffdc352a3..6f810d720f4d 100644
@@ -124,7 +124,6 @@ static struct coreboot_driver cbmem_entry_driver = {
 	.probe = cbmem_entry_probe,
 	.drv = {
 		.name = "cbmem",
-		.owner = THIS_MODULE,
 		.dev_groups = dev_groups,
 	},
 	.id_table = cbmem_ids,
Signature · 1 line
2.34.1
#3 lore raw
In reply to Krzysztof Kozlowski
Quoted 4 lines · Krzysztof Kozlowski

Moving the .owner setting code to the core this effectively fixes missing .owner in framebuffer-coreboot, memconsole-coreboot and vpd drivers.

It has been almost a month. Any comments on this patchset?

Best regards,
Krzysztof

#4 lore raw
Quoted 7 lines · Krzysztof Kozlowski
Quoted 4 lines · Krzysztof Kozlowski

Moving the .owner setting code to the core this effectively fixes missing .owner in framebuffer-coreboot, memconsole-coreboot and vpd drivers.

It has been almost a month. Any comments on this patchset?

They have been applied for a while, thanks! Just realized this email was forgotten.

[1/2] firmware: coreboot: store owner from modules with coreboot_driver_register()

      commit: 46c6685e7e886b7fa098465f8bfd139a253365e4
[2/2] firmware: google: cbmem: drop driver owner initialization
      commit: 7f20f21c22aa22e488530f66bf4fc168e427f5bd
#5 lore raw
In reply to Krzysztof Kozlowski
This series was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Hello:

This series was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Quoted 8 lines · On Sat, 30 Mar 2024 20:49:46 +0100 you wrote:

Moving the .owner setting code to the core this effectively fixes missing .owner in framebuffer-coreboot, memconsole-coreboot and vpd drivers.

Best regards,
Krzysztof

[...]

Here is the summary with links:
- [1/2] firmware: coreboot: store owner from modules with coreboot_driver_register()

    https://git.kernel.org/chrome-platform/c/46c6685e7e88
  - [2/2] firmware: google: cbmem: drop driver owner initialization
    https://git.kernel.org/chrome-platform/c/7f20f21c22aa

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#6 lore raw
In reply to Krzysztof Kozlowski
This series was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Hello:

This series was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Quoted 8 lines · On Sat, 30 Mar 2024 20:49:46 +0100 you wrote:

Moving the .owner setting code to the core this effectively fixes missing .owner in framebuffer-coreboot, memconsole-coreboot and vpd drivers.

Best regards,
Krzysztof

[...]

Here is the summary with links:
- [1/2] firmware: coreboot: store owner from modules with coreboot_driver_register()

    https://git.kernel.org/chrome-platform/c/46c6685e7e88
  - [2/2] firmware: google: cbmem: drop driver owner initialization
    https://git.kernel.org/chrome-platform/c/7f20f21c22aa

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html