2024-03-30 19:50:04

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 0/2] 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,
--
Krzysztof Kozlowski <[email protected]>



2024-03-30 19:50:11

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/firmware/google/coreboot_table.c | 6 ++++--
drivers/firmware/google/coreboot_table.h | 6 +++++-
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c
index d4b6e581a6c6..fa7752f6e89b 100644
--- a/drivers/firmware/google/coreboot_table.c
+++ b/drivers/firmware/google/coreboot_table.c
@@ -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)
{
diff --git a/drivers/firmware/google/coreboot_table.h b/drivers/firmware/google/coreboot_table.h
index 86427989c57f..bb6f0f7299b4 100644
--- a/drivers/firmware/google/coreboot_table.h
+++ b/drivers/firmware/google/coreboot_table.h
@@ -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);

--
2.34.1


2024-03-30 19:50:22

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 2/2] firmware: google: cbmem: drop driver owner initialization

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

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/firmware/google/cbmem.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/firmware/google/cbmem.c b/drivers/firmware/google/cbmem.c
index c2bffdc352a3..6f810d720f4d 100644
--- a/drivers/firmware/google/cbmem.c
+++ b/drivers/firmware/google/cbmem.c
@@ -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,

--
2.34.1


2024-04-24 06:43:06

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 0/2] firmware: coreboot: store owner from modules with coreboot_driver_register()

On 30/03/2024 20:49, Krzysztof Kozlowski wrote:
> 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


2024-04-24 08:52:26

by Tzung-Bi Shih

[permalink] [raw]
Subject: Re: [PATCH 0/2] firmware: coreboot: store owner from modules with coreboot_driver_register()

On Wed, Apr 24, 2024 at 08:40:34AM +0200, Krzysztof Kozlowski wrote:
> On 30/03/2024 20:49, Krzysztof Kozlowski wrote:
> > 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

Subject: Re: [PATCH 0/2] firmware: coreboot: store owner from modules with coreboot_driver_register()

Hello:

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

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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



Subject: Re: [PATCH 0/2] firmware: coreboot: store owner from modules with coreboot_driver_register()

Hello:

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

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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html