[PATCH v2 00/25] virtio: store owner from modules with register_virtio_driver()
Changes in v2: - Three new patches: virtio mem+input+balloon - Minor commit msg adjustments - Add tags - Link to v1: https://lore.kernel.org/r/20240327-module-owner-virtio-v1-0-0feffab77d99@lin...
Merging ======= All further patches depend on the first virtio patch, therefore please ack and this should go via one tree: maybe virtio?
Description =========== Modules registering driver with register_virtio_driver() often forget to set .owner field.
Solve the problem by moving this task away from the drivers to the core virtio code, just like we did for platform_driver in commit 9447057eaff8 ("platform_device: use a macro instead of platform_driver_register").
Best regards, Krzysztof
--- Krzysztof Kozlowski (25): virtio: store owner from modules with register_virtio_driver() virtio: balloon: drop owner assignment virtio: input: drop owner assignment virtio: mem: drop owner assignment um: virt-pci: drop owner assignment virtio_blk: drop owner assignment bluetooth: virtio: drop owner assignment hwrng: virtio: drop owner assignment virtio_console: drop owner assignment crypto: virtio - drop owner assignment firmware: arm_scmi: virtio: drop owner assignment gpio: virtio: drop owner assignment drm/virtio: drop owner assignment iommu: virtio: drop owner assignment misc: nsm: drop owner assignment net: caif: virtio: drop owner assignment net: virtio: drop owner assignment net: 9p: virtio: drop owner assignment vsock/virtio: drop owner assignment wifi: mac80211_hwsim: drop owner assignment nvdimm: virtio_pmem: drop owner assignment rpmsg: virtio: drop owner assignment scsi: virtio: drop owner assignment fuse: virtio: drop owner assignment sound: virtio: drop owner assignment
Documentation/driver-api/virtio/writing_virtio_drivers.rst | 1 - arch/um/drivers/virt-pci.c | 1 - drivers/block/virtio_blk.c | 1 - drivers/bluetooth/virtio_bt.c | 1 - drivers/char/hw_random/virtio-rng.c | 1 - drivers/char/virtio_console.c | 2 -- drivers/crypto/virtio/virtio_crypto_core.c | 1 - drivers/firmware/arm_scmi/virtio.c | 1 - drivers/gpio/gpio-virtio.c | 1 - drivers/gpu/drm/virtio/virtgpu_drv.c | 1 - drivers/iommu/virtio-iommu.c | 1 - drivers/misc/nsm.c | 1 - drivers/net/caif/caif_virtio.c | 1 - drivers/net/virtio_net.c | 1 - drivers/net/wireless/virtual/mac80211_hwsim.c | 1 - drivers/nvdimm/virtio_pmem.c | 1 - drivers/rpmsg/virtio_rpmsg_bus.c | 1 - drivers/scsi/virtio_scsi.c | 1 - drivers/virtio/virtio.c | 6 ++++-- drivers/virtio/virtio_balloon.c | 1 - drivers/virtio/virtio_input.c | 1 - drivers/virtio/virtio_mem.c | 1 - fs/fuse/virtio_fs.c | 1 - include/linux/virtio.h | 7 +++++-- net/9p/trans_virtio.c | 1 - net/vmw_vsock/virtio_transport.c | 1 - sound/virtio/virtio_card.c | 1 - 27 files changed, 9 insertions(+), 30 deletions(-) --- base-commit: 7fdcff3312e16ba8d1419f8a18f465c5cc235ecf change-id: 20240327-module-owner-virtio-546763b3ca22
Best regards,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Changes in v2: 1. New patch --- drivers/virtio/virtio_balloon.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 1f5b3dd31fcf..85d28a0a404d 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -1155,7 +1155,6 @@ static struct virtio_driver virtio_balloon_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .validate = virtballoon_validate, .probe = virtballoon_probe,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Changes in v2: 1. New patch --- drivers/virtio/virtio_input.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c index 3aa46703872d..1a730d6c0b55 100644 --- a/drivers/virtio/virtio_input.c +++ b/drivers/virtio/virtio_input.c @@ -394,7 +394,6 @@ static const struct virtio_device_id id_table[] = {
static struct virtio_driver virtio_input_driver = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .id_table = id_table,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Changes in v2: 1. New patch --- drivers/virtio/virtio_mem.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index e8355f55a8f7..e605d906639f 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -2991,7 +2991,6 @@ static struct virtio_driver virtio_mem_driver = { .feature_table = virtio_mem_features, .feature_table_size = ARRAY_SIZE(virtio_mem_features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = virtio_mem_id_table, .probe = virtio_mem_probe, .remove = virtio_mem_remove,
virtio core already sets the .owner, so driver does not need to.
Acked-by: Johannes Berg johannes@sipsolutions.net Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org ---
Depends on the first patch. --- arch/um/drivers/virt-pci.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c index 97a37c062997..7cb503469bbd 100644 --- a/arch/um/drivers/virt-pci.c +++ b/arch/um/drivers/virt-pci.c @@ -752,7 +752,6 @@ MODULE_DEVICE_TABLE(virtio, id_table);
static struct virtio_driver um_pci_virtio_driver = { .driver.name = "virtio-pci", - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = um_pci_virtio_probe, .remove = um_pci_virtio_remove,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/block/virtio_blk.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 42dea7601d87..46bdbad1ab48 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -1658,7 +1658,6 @@ static struct virtio_driver virtio_blk = { .feature_table_legacy = features_legacy, .feature_table_size_legacy = ARRAY_SIZE(features_legacy), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = virtblk_probe, .remove = virtblk_remove,
On Sun, Mar 31, 2024 at 10:43:53AM +0200, Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Depends on the first patch.
drivers/block/virtio_blk.c | 1 - 1 file changed, 1 deletion(-)
Reviewed-by: Stefan Hajnoczi stefanha@redhat.com
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/bluetooth/virtio_bt.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/bluetooth/virtio_bt.c b/drivers/bluetooth/virtio_bt.c index 2ac70b560c46..463b49ca2492 100644 --- a/drivers/bluetooth/virtio_bt.c +++ b/drivers/bluetooth/virtio_bt.c @@ -417,7 +417,6 @@ static const unsigned int virtbt_features[] = {
static struct virtio_driver virtbt_driver = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .feature_table = virtbt_features, .feature_table_size = ARRAY_SIZE(virtbt_features), .id_table = virtbt_table,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/char/hw_random/virtio-rng.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index 7a4b45393acb..dd998f4fe4f2 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c @@ -245,7 +245,6 @@ static const struct virtio_device_id id_table[] = {
static struct virtio_driver virtio_rng_driver = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = virtrng_probe, .remove = virtrng_remove,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/char/virtio_console.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 035f89f1a251..d9ee2dbc7eab 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -2173,7 +2173,6 @@ static struct virtio_driver virtio_console = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = virtcons_probe, .remove = virtcons_remove, @@ -2188,7 +2187,6 @@ static struct virtio_driver virtio_rproc_serial = { .feature_table = rproc_serial_features, .feature_table_size = ARRAY_SIZE(rproc_serial_features), .driver.name = "virtio_rproc_serial", - .driver.owner = THIS_MODULE, .id_table = rproc_serial_id_table, .probe = virtcons_probe, .remove = virtcons_remove,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/crypto/virtio/virtio_crypto_core.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/crypto/virtio/virtio_crypto_core.c b/drivers/crypto/virtio/virtio_crypto_core.c index 6a67d70e7f1c..30cd040aa03b 100644 --- a/drivers/crypto/virtio/virtio_crypto_core.c +++ b/drivers/crypto/virtio/virtio_crypto_core.c @@ -581,7 +581,6 @@ static const struct virtio_device_id id_table[] = {
static struct virtio_driver virtio_crypto_driver = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .id_table = id_table,
On Sun, Mar 31, 2024 at 10:43:57AM +0200, Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Depends on the first patch.
drivers/crypto/virtio/virtio_crypto_core.c | 1 - 1 file changed, 1 deletion(-)
Acked-by: Herbert Xu herbert@gondor.apana.org.au
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/firmware/arm_scmi/virtio.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/virtio.c b/drivers/firmware/arm_scmi/virtio.c index d68c01cb7aa0..4892058445ce 100644 --- a/drivers/firmware/arm_scmi/virtio.c +++ b/drivers/firmware/arm_scmi/virtio.c @@ -908,7 +908,6 @@ static const struct virtio_device_id id_table[] = {
static struct virtio_driver virtio_scmi_driver = { .driver.name = "scmi-virtio", - .driver.owner = THIS_MODULE, .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .id_table = id_table,
On Sun, Mar 31, 2024 at 10:43:58AM +0200, Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Acked-by: Sudeep Holla sudeep.holla@arm.com
virtio core already sets the .owner, so driver does not need to.
Acked-by: Bartosz Golaszewski bartosz.golaszewski@linaro.org Acked-by: Viresh Kumar viresh.kumar@linaro.org Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org ---
Depends on the first patch. --- drivers/gpio/gpio-virtio.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c index fcc5e8c08973..9fae8e396c58 100644 --- a/drivers/gpio/gpio-virtio.c +++ b/drivers/gpio/gpio-virtio.c @@ -653,7 +653,6 @@ static struct virtio_driver virtio_gpio_driver = { .remove = virtio_gpio_remove, .driver = { .name = KBUILD_MODNAME, - .owner = THIS_MODULE, }, }; module_virtio_driver(virtio_gpio_driver);
On Sun, Mar 31, 2024 at 10:45 AM Krzysztof Kozlowski krzysztof.kozlowski@linaro.org wrote:
virtio core already sets the .owner, so driver does not need to.
Acked-by: Bartosz Golaszewski bartosz.golaszewski@linaro.org Acked-by: Viresh Kumar viresh.kumar@linaro.org Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Acked-by: Linus Walleij linus.walleij@linaro.org
Yours, Linus Walleij
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/gpu/drm/virtio/virtgpu_drv.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c index 9539aa28937f..188e126383c2 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.c +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c @@ -154,7 +154,6 @@ static struct virtio_driver virtio_gpu_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = virtio_gpu_probe, .remove = virtio_gpu_remove,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/iommu/virtio-iommu.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 04048f64a2c0..9ed8958a42bf 100644 --- a/drivers/iommu/virtio-iommu.c +++ b/drivers/iommu/virtio-iommu.c @@ -1261,7 +1261,6 @@ MODULE_DEVICE_TABLE(virtio, id_table);
static struct virtio_driver virtio_iommu_drv = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .feature_table = features, .feature_table_size = ARRAY_SIZE(features),
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/misc/nsm.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/misc/nsm.c b/drivers/misc/nsm.c index 0eaa3b4484bd..ef7b32742340 100644 --- a/drivers/misc/nsm.c +++ b/drivers/misc/nsm.c @@ -494,7 +494,6 @@ static struct virtio_driver virtio_nsm_driver = { .feature_table_legacy = 0, .feature_table_size_legacy = 0, .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = nsm_device_probe, .remove = nsm_device_remove,
On 31.03.24 10:44, Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Reviewed-by: Alexander Graf graf@amazon.com
Alex
Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/net/caif/caif_virtio.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c index 0b0f234b0b50..99d984851fef 100644 --- a/drivers/net/caif/caif_virtio.c +++ b/drivers/net/caif/caif_virtio.c @@ -782,7 +782,6 @@ static struct virtio_driver caif_virtio_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = cfv_probe, .remove = cfv_remove,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/net/virtio_net.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index c22d1118a133..61f680699648 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -5021,7 +5021,6 @@ static struct virtio_driver virtio_net_driver = { .feature_table_legacy = features_legacy, .feature_table_size_legacy = ARRAY_SIZE(features_legacy), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .validate = virtnet_validate, .probe = virtnet_probe,
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- net/9p/trans_virtio.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index e305071eb7b8..0b8086f58ad5 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -781,7 +781,6 @@ static struct virtio_driver p9_virtio_drv = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = p9_virtio_probe, .remove = p9_virtio_remove,
virtio core already sets the .owner, so driver does not need to.
Acked-by: Stefano Garzarella sgarzare@redhat.com Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org ---
Depends on the first patch. --- net/vmw_vsock/virtio_transport.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c index 1748268e0694..13f42a62b034 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -858,7 +858,6 @@ static struct virtio_driver virtio_vsock_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = virtio_vsock_probe, .remove = virtio_vsock_remove,
On Sun, Mar 31, 2024 at 10:44:06AM +0200, Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Acked-by: Stefano Garzarella sgarzare@redhat.com Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Depends on the first patch.
net/vmw_vsock/virtio_transport.c | 1 - 1 file changed, 1 deletion(-)
Reviewed-by: Stefan Hajnoczi stefanha@redhat.com
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/net/wireless/virtual/mac80211_hwsim.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c index b55fe320633c..ef38b7cc9fdf 100644 --- a/drivers/net/wireless/virtual/mac80211_hwsim.c +++ b/drivers/net/wireless/virtual/mac80211_hwsim.c @@ -6662,7 +6662,6 @@ MODULE_DEVICE_TABLE(virtio, id_table);
static struct virtio_driver virtio_hwsim = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = hwsim_virtio_probe, .remove = hwsim_virtio_remove,
Modules registering driver with register_virtio_driver() might forget to set .owner field. i2c-virtio.c for example has it missing. 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 virtio code, just like we did for platform_driver in commit 9447057eaff8 ("platform_device: use a macro instead of platform_driver_register").
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org --- Documentation/driver-api/virtio/writing_virtio_drivers.rst | 1 - drivers/virtio/virtio.c | 6 ++++-- include/linux/virtio.h | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/Documentation/driver-api/virtio/writing_virtio_drivers.rst b/Documentation/driver-api/virtio/writing_virtio_drivers.rst index e14c58796d25..e5de6f5d061a 100644 --- a/Documentation/driver-api/virtio/writing_virtio_drivers.rst +++ b/Documentation/driver-api/virtio/writing_virtio_drivers.rst @@ -97,7 +97,6 @@ like this::
static struct virtio_driver virtio_dummy_driver = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = virtio_dummy_probe, .remove = virtio_dummy_remove, diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index f173587893cb..9510c551dce8 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -362,14 +362,16 @@ static const struct bus_type virtio_bus = { .remove = virtio_dev_remove, };
-int register_virtio_driver(struct virtio_driver *driver) +int __register_virtio_driver(struct virtio_driver *driver, struct module *owner) { /* Catch this early. */ BUG_ON(driver->feature_table_size && !driver->feature_table); driver->driver.bus = &virtio_bus; + driver->driver.owner = owner; + return driver_register(&driver->driver); } -EXPORT_SYMBOL_GPL(register_virtio_driver); +EXPORT_SYMBOL_GPL(__register_virtio_driver);
void unregister_virtio_driver(struct virtio_driver *driver) { diff --git a/include/linux/virtio.h b/include/linux/virtio.h index b0201747a263..26c4325aa373 100644 --- a/include/linux/virtio.h +++ b/include/linux/virtio.h @@ -170,7 +170,7 @@ size_t virtio_max_dma_size(const struct virtio_device *vdev);
/** * struct virtio_driver - operations for a virtio I/O driver - * @driver: underlying device driver (populate name and owner). + * @driver: underlying device driver (populate name). * @id_table: the ids serviced by this driver. * @feature_table: an array of feature numbers supported by this driver. * @feature_table_size: number of entries in the feature table array. @@ -208,7 +208,10 @@ static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv) return container_of(drv, struct virtio_driver, driver); }
-int register_virtio_driver(struct virtio_driver *drv); +/* use a macro to avoid include chaining to get THIS_MODULE */ +#define register_virtio_driver(drv) \ + __register_virtio_driver(drv, THIS_MODULE) +int __register_virtio_driver(struct virtio_driver *drv, struct module *owner); void unregister_virtio_driver(struct virtio_driver *drv);
/* module_virtio_driver() - Helper macro for drivers that don't do
virtio core already sets the .owner, so driver does not need to.
Acked-by: Dave Jiang dave.jiang@intel.com Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org ---
Depends on the first patch. --- drivers/nvdimm/virtio_pmem.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/nvdimm/virtio_pmem.c b/drivers/nvdimm/virtio_pmem.c index 4ceced5cefcf..c9b97aeabf85 100644 --- a/drivers/nvdimm/virtio_pmem.c +++ b/drivers/nvdimm/virtio_pmem.c @@ -151,7 +151,6 @@ static struct virtio_driver virtio_pmem_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .validate = virtio_pmem_validate, .probe = virtio_pmem_probe,
virtio core already sets the .owner, so driver does not need to.
Acked-by: Dave Jiang dave.jiang@intel.com Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Reviewed-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com
---
Depends on the first patch.
drivers/nvdimm/virtio_pmem.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/nvdimm/virtio_pmem.c b/drivers/nvdimm/virtio_pmem.c index 4ceced5cefcf..c9b97aeabf85 100644 --- a/drivers/nvdimm/virtio_pmem.c +++ b/drivers/nvdimm/virtio_pmem.c @@ -151,7 +151,6 @@ static struct virtio_driver virtio_pmem_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME,
.driver.owner = THIS_MODULE, .id_table = id_table, .validate = virtio_pmem_validate, .probe = virtio_pmem_probe,
-- 2.34.1
On 3/31/2024 10:44 AM, Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Acked-by: Dave Jiang dave.jiang@intel.com Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Depends on the first patch.
drivers/nvdimm/virtio_pmem.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/nvdimm/virtio_pmem.c b/drivers/nvdimm/virtio_pmem.c index 4ceced5cefcf..c9b97aeabf85 100644 --- a/drivers/nvdimm/virtio_pmem.c +++ b/drivers/nvdimm/virtio_pmem.c @@ -151,7 +151,6 @@ static struct virtio_driver virtio_pmem_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME,
- .driver.owner = THIS_MODULE, .id_table = id_table, .validate = virtio_pmem_validate, .probe = virtio_pmem_probe,
Reviewed-by: Pankaj Gupta pankaj.gupta@amd.com
Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Acked-by: Dave Jiang dave.jiang@intel.com
Acked-by: Ira Weiny ira.weiny@intel.com
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Depends on the first patch.
drivers/nvdimm/virtio_pmem.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/nvdimm/virtio_pmem.c b/drivers/nvdimm/virtio_pmem.c index 4ceced5cefcf..c9b97aeabf85 100644 --- a/drivers/nvdimm/virtio_pmem.c +++ b/drivers/nvdimm/virtio_pmem.c @@ -151,7 +151,6 @@ static struct virtio_driver virtio_pmem_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME,
- .driver.owner = THIS_MODULE, .id_table = id_table, .validate = virtio_pmem_validate, .probe = virtio_pmem_probe,
-- 2.34.1
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- drivers/scsi/virtio_scsi.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 617eb892f4ad..89ca26945721 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -1052,7 +1052,6 @@ static struct virtio_driver virtio_scsi_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = virtscsi_probe, #ifdef CONFIG_PM_SLEEP
On Sun, Mar 31, 2024 at 10:44:10AM +0200, Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Depends on the first patch.
drivers/scsi/virtio_scsi.c | 1 - 1 file changed, 1 deletion(-)
Reviewed-by: Stefan Hajnoczi stefanha@redhat.com
Krzysztof,
virtio core already sets the .owner, so driver does not need to.
virtio_scsi looks OK to me.
Acked-by: Martin K. Petersen martin.petersen@oracle.com
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- fs/fuse/virtio_fs.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 322af827a232..ca7b64f9c3c7 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -1023,7 +1023,6 @@ static const unsigned int feature_table[] = {};
static struct virtio_driver virtio_fs_driver = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .feature_table = feature_table, .feature_table_size = ARRAY_SIZE(feature_table),
On Sun, Mar 31, 2024 at 10:44:11AM +0200, Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Depends on the first patch.
fs/fuse/virtio_fs.c | 1 - 1 file changed, 1 deletion(-)
Reviewed-by: Stefan Hajnoczi stefanha@redhat.com
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
---
Depends on the first patch. --- sound/virtio/virtio_card.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c index 2da20c625247..7805daea0102 100644 --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c @@ -438,7 +438,6 @@ static unsigned int features[] = {
static struct virtio_driver virtsnd_driver = { .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .feature_table = features, .feature_table_size = ARRAY_SIZE(features),
Hi Krzysztof,
On 31.03.2024 10:44, Krzysztof Kozlowski wrote:
virtio core already sets the .owner, so driver does not need to.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
Acked-by: Anton Yakovlev anton.yakovlev@opensynergy.com
Depends on the first patch.
sound/virtio/virtio_card.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c index 2da20c625247..7805daea0102 100644 --- a/sound/virtio/virtio_card.c +++ b/sound/virtio/virtio_card.c @@ -438,7 +438,6 @@ static unsigned int features[] = {
static struct virtio_driver virtsnd_driver = { .driver.name = KBUILD_MODNAME,
- .driver.owner = THIS_MODULE, .id_table = id_table, .feature_table = features, .feature_table_size = ARRAY_SIZE(features),
virtio core already sets the .owner, so driver does not need to.
Reviewed-by: Mathieu Poirier mathieu.poirier@linaro.org Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org ---
Depends on the first patch. --- drivers/rpmsg/virtio_rpmsg_bus.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 1062939c3264..e9e8c1f7829f 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -1053,7 +1053,6 @@ static struct virtio_driver virtio_ipc_driver = { .feature_table = features, .feature_table_size = ARRAY_SIZE(features), .driver.name = KBUILD_MODNAME, - .driver.owner = THIS_MODULE, .id_table = id_table, .probe = rpmsg_probe, .remove = rpmsg_remove,
On 31/03/2024 10:43, Krzysztof Kozlowski wrote:
Changes in v2:
- Three new patches: virtio mem+input+balloon
- Minor commit msg adjustments
- Add tags
- Link to v1: https://lore.kernel.org/r/20240327-module-owner-virtio-v1-0-0feffab77d99@lin...
Merging
All further patches depend on the first virtio patch, therefore please ack and this should go via one tree: maybe virtio?
Michael, Jason, Xuan,
Will you be able to take the entire patchset through virtio?
Best regards, Krzysztof
On Wed, Apr 10, 2024 at 09:41:57AM +0200, Krzysztof Kozlowski wrote:
On 31/03/2024 10:43, Krzysztof Kozlowski wrote:
Changes in v2:
- Three new patches: virtio mem+input+balloon
- Minor commit msg adjustments
- Add tags
- Link to v1: https://lore.kernel.org/r/20240327-module-owner-virtio-v1-0-0feffab77d99@lin...
Merging
All further patches depend on the first virtio patch, therefore please ack and this should go via one tree: maybe virtio?
Michael, Jason, Xuan,
Will you be able to take the entire patchset through virtio?
Best regards, Krzysztof
Hello! Yes I intend to take it for the next merge window. I am also merging the 1st patch for this release (it's a bugfix).
participants (12)
-
Alexander Graf
-
Anton Yakovlev
-
Gupta, Pankaj
-
Herbert Xu
-
Ira Weiny
-
Krzysztof Kozlowski
-
Linus Walleij
-
Martin K. Petersen
-
Michael S. Tsirkin
-
Pankaj Gupta
-
Stefan Hajnoczi
-
Sudeep Holla