commit ea187e71aba8a1195eb0abb6e151e943aebdf906
Author: Hans de Goede <hdegoede(a)redhat.com>
Date: Thu Feb 6 14:34:53 2025 +0100
Fix bug causing udev to not properly enumerate the /dev/ipu-psys0 device
Fix bug causing udev to not properly enumerate the /dev/ipu-psys0 device
Fix bug causing udev to not properly enumerate the /dev/ipu-psys0 device
...-skipping-registering-ipu_psys_bus-for-ke.patch | 202 +++++++++++++++++++++
...sys-Use-cdev_device_add-for-dev-ipu-psys0.patch | 130 +++++++++++++
intel-ipu6-kmod.spec | 22 ++-
3 files changed, 347 insertions(+), 7 deletions(-)
---
diff --git a/0010-psys-Do-not-skipping-registering-ipu_psys_bus-for-ke.patch
b/0010-psys-Do-not-skipping-registering-ipu_psys_bus-for-ke.patch
new file mode 100644
index 0000000..6ba5e4a
--- /dev/null
+++ b/0010-psys-Do-not-skipping-registering-ipu_psys_bus-for-ke.patch
@@ -0,0 +1,202 @@
+From c1cb2a62cd9d949fda60f5993a72ec0c44f52719 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede(a)redhat.com>
+Date: Wed, 5 Feb 2025 13:20:21 +0100
+Subject: [PATCH 10/11] psys: Do not skipping registering ipu_psys_bus for
+ kernels >= 6.10
+
+The new auxbus code-paths were not registering the ipu_psys_bus used for
+psys->dev.bus = &ipu_psys_bus, this was causing udev to not be able to
+properly enumerate the device. For example running:
+
+udevadm test -a add /dev/ipu-psys0
+
+would fail with the following error:
+
+"Failed to clone sd_device object: No such file or directory"
+
+This udev issue in turn was causing issues with udev rules to set
+permissions on /dev/ipu-psys0 not working
+
+Fix this by:
+
+1. Rename ipu6_psys_bus to ipu_psys_bus, there is no need for separate
+names for this struct with different kernels and having the same name
+allows code sharing.
+
+2. Switching back from using module_auxiliary_driver() to using
+module_init() / module_exit() codes for registering the drivers.
+
+3. Move the now always used ipu_psys_init() and ipu_psys_exit()
+out of any ifdefs blocks, so that these functions now always
+(un)register the chrdev region and the ipu_psys_bus.
+
+4. Remove the now duplicate chrdev region handling from the auxbus
+ipu6_psys_probe() and ipu6_psys_remove() functions (now handled
+by ipu_psys_init() and ipu_psys_exit()).
+
+Signed-off-by: Hans de Goede
+---
+ drivers/media/pci/intel/ipu6/psys/ipu-psys.c | 94 +++++++++-----------
+ 1 file changed, 40 insertions(+), 54 deletions(-)
+
+diff --git a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+index 7c512e5ae..c06cd515a 100644
+--- a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
++++ b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+@@ -92,7 +92,7 @@ static struct bus_type ipu_psys_bus = {
+ .name = IPU_PSYS_NAME,
+ };
+ #else
+-static const struct bus_type ipu6_psys_bus = {
++static const struct bus_type ipu_psys_bus = {
+ .name = "intel-ipu6-psys",
+ };
+ #endif
+@@ -2331,17 +2331,9 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
+
+ ipu_ver = adev->isp->hw_ver;
+
+- rval = alloc_chrdev_region(&ipu_psys_dev_t, 0,
+- IPU_PSYS_NUM_DEVICES, IPU6_PSYS_NAME);
+- if (rval) {
+- dev_err(dev, "can't alloc psys chrdev region (%d)\n",
+- rval);
+- return rval;
+- }
+-
+ rval = ipu6_mmu_hw_init(adev->mmu);
+ if (rval)
+- goto out_unregister_chr_region;
++ return rval;
+
+ mutex_lock(&ipu_psys_mutex);
+
+@@ -2453,7 +2445,7 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
+ goto out_free_pgs;
+ }
+
+- psys->dev.bus = &ipu6_psys_bus;
++ psys->dev.bus = &ipu_psys_bus;
+ psys->dev.parent = dev;
+ psys->dev.devt = MKDEV(MAJOR(ipu_psys_dev_t), minor);
+ psys->dev.release = ipu_psys_dev_release;
+@@ -2500,10 +2492,6 @@ out_unlock:
+ /* Safe to call even if the init is not called */
+ mutex_unlock(&ipu_psys_mutex);
+ ipu6_mmu_hw_cleanup(adev->mmu);
+-
+-out_unregister_chr_region:
+- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
+-
+ return rval;
+ }
+ #endif
+@@ -2521,9 +2509,6 @@ static void ipu6_psys_remove(struct auxiliary_device *auxdev)
+ #endif
+ struct ipu_psys_pg *kpg, *kpg0;
+
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0)
+- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
+-#endif
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
+ #ifdef CONFIG_DEBUG_FS
+ if (isp->ipu_dir)
+@@ -2658,38 +2643,6 @@ static struct ipu_bus_driver ipu_psys_driver = {
+ },
+ };
+
+-static int __init ipu_psys_init(void)
+-{
+- int rval = alloc_chrdev_region(&ipu_psys_dev_t, 0,
+- IPU_PSYS_NUM_DEVICES, IPU_PSYS_NAME);
+- if (rval) {
+- pr_err("can't alloc psys chrdev region (%d)\n", rval);
+- return rval;
+- }
+-
+- rval = bus_register(&ipu_psys_bus);
+- if (rval) {
+- pr_warn("can't register psys bus (%d)\n", rval);
+- goto out_bus_register;
+- }
+-
+- ipu_bus_register_driver(&ipu_psys_driver);
+-
+- return rval;
+-
+-out_bus_register:
+- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
+-
+- return rval;
+-}
+-
+-static void __exit ipu_psys_exit(void)
+-{
+- ipu_bus_unregister_driver(&ipu_psys_driver);
+- bus_unregister(&ipu_psys_bus);
+- unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
+-}
+-
+ static const struct pci_device_id ipu_pci_tbl[] = {
+ {PCI_DEVICE(PCI_VENDOR_ID_INTEL, IPU6_PCI_ID)},
+ {PCI_DEVICE(PCI_VENDOR_ID_INTEL, IPU6SE_PCI_ID)},
+@@ -2700,9 +2653,6 @@ static const struct pci_device_id ipu_pci_tbl[] = {
+ {0,}
+ };
+ MODULE_DEVICE_TABLE(pci, ipu_pci_tbl);
+-
+-module_init(ipu_psys_init);
+-module_exit(ipu_psys_exit);
+ #else
+ static const struct ipu6_auxdrv_data ipu6_psys_auxdrv_data = {
+ .isr_threaded = psys_isr_threaded,
+@@ -2727,9 +2677,45 @@ static struct auxiliary_driver ipu6_psys_aux_driver = {
+ .pm = &psys_pm_ops,
+ },
+ };
+-module_auxiliary_driver(ipu6_psys_aux_driver);
+ #endif
+
++static int __init ipu_psys_init(void)
++{
++ int rval = alloc_chrdev_region(&ipu_psys_dev_t, 0,
++ IPU_PSYS_NUM_DEVICES, ipu_psys_bus.name);
++ if (rval) {
++ pr_err("can't alloc psys chrdev region (%d)\n", rval);
++ return rval;
++ }
++
++ rval = bus_register(&ipu_psys_bus);
++ if (rval) {
++ pr_err("can't register psys bus (%d)\n", rval);
++ unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
++ return rval;
++ }
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
++ ipu_bus_register_driver(&ipu_psys_driver);
++#else
++ auxiliary_driver_register(&ipu6_psys_aux_driver);
++#endif
++ return 0;
++}
++module_init(ipu_psys_init);
++
++static void __exit ipu_psys_exit(void)
++{
++#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
++ ipu_bus_unregister_driver(&ipu_psys_driver);
++#else
++ auxiliary_driver_unregister(&ipu6_psys_aux_driver);
++#endif
++ bus_unregister(&ipu_psys_bus);
++ unregister_chrdev_region(ipu_psys_dev_t, IPU_PSYS_NUM_DEVICES);
++}
++module_exit(ipu_psys_exit);
++
+ MODULE_AUTHOR("Antti Laakso <antti.laakso(a)intel.com>");
+ MODULE_AUTHOR("Bin Han <bin.b.han(a)intel.com>");
+ MODULE_AUTHOR("Renwei Wu <renwei.wu(a)intel.com>");
+--
+2.48.1
+
diff --git a/0011-psys-Use-cdev_device_add-for-dev-ipu-psys0.patch
b/0011-psys-Use-cdev_device_add-for-dev-ipu-psys0.patch
new file mode 100644
index 0000000..e1c7d44
--- /dev/null
+++ b/0011-psys-Use-cdev_device_add-for-dev-ipu-psys0.patch
@@ -0,0 +1,130 @@
+From ce28836eb5ce74ae26a66a97949778bdb2cebc3c Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede(a)redhat.com>
+Date: Tue, 4 Feb 2025 17:34:54 +0100
+Subject: [PATCH 11/11] psys: Use cdev_device_add() for /dev/ipu-psys0
+
+Use cdev_device_add() for /dev/ipu-psys0 so that its kobj parents gets
+set properly by calling cdev_set_parent().
+
+"cdev_set_parent() sets a parent kobject which will be referenced
+ appropriately so the parent is not freed before the cdev. This
+ should be called before cdev_add."
+
+Signed-off-by: Hans de Goede <hdegoede(a)redhat.com>
+---
+ drivers/media/pci/intel/ipu6/psys/ipu-psys.c | 45 ++++++++------------
+ 1 file changed, 17 insertions(+), 28 deletions(-)
+
+diff --git a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+index c06cd515a..62fcf0215 100644
+--- a/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
++++ b/drivers/media/pci/intel/ipu6/psys/ipu-psys.c
+@@ -2170,17 +2170,6 @@ static int ipu_psys_probe(struct ipu_bus_device *adev)
+ ipu_trace_init(adev->isp, psys->pdata->base, &adev->dev,
+ psys_trace_blocks);
+
+- cdev_init(&psys->cdev, &ipu_psys_fops);
+- psys->cdev.owner = ipu_psys_fops.owner;
+-
+- rval = cdev_add(&psys->cdev, MKDEV(MAJOR(ipu_psys_dev_t), minor), 1);
+- if (rval) {
+- dev_err(&adev->dev, "cdev_add failed (%d)\n", rval);
+- goto out_unlock;
+- }
+-
+- set_bit(minor, ipu_psys_devices);
+-
+ spin_lock_init(&psys->ready_lock);
+ spin_lock_init(&psys->pgs_lock);
+ psys->ready = 0;
+@@ -2261,12 +2250,19 @@ static int ipu_psys_probe(struct ipu_bus_device *adev)
+ psys->dev.devt = MKDEV(MAJOR(ipu_psys_dev_t), minor);
+ psys->dev.release = ipu_psys_dev_release;
+ dev_set_name(&psys->dev, "ipu-psys%d", minor);
+- rval = device_register(&psys->dev);
++ device_initialize(&psys->dev);
++
++ cdev_init(&psys->cdev, &ipu_psys_fops);
++ psys->cdev.owner = ipu_psys_fops.owner;
++
++ rval = cdev_device_add(&psys->cdev, &psys->dev);
+ if (rval < 0) {
+ dev_err(&psys->dev, "psys device_register failed\n");
+ goto out_release_fw_com;
+ }
+
++ set_bit(minor, ipu_psys_devices);
++
+ /* Add the hw stepping information to caps */
+ strscpy(psys->caps.dev_model, IPU_MEDIA_DEV_MODEL_NAME,
+ sizeof(psys->caps.dev_model));
+@@ -2298,7 +2294,6 @@ out_free_pgs:
+ ipu_psys_resource_pool_cleanup(&psys->resource_pool_running);
+ out_mutex_destroy:
+ mutex_destroy(&psys->mutex);
+- cdev_del(&psys->cdev);
+ if (psys->sched_cmd_thread) {
+ kthread_stop(psys->sched_cmd_thread);
+ psys->sched_cmd_thread = NULL;
+@@ -2359,17 +2354,6 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
+
+ psys->power_gating = 0;
+
+- cdev_init(&psys->cdev, &ipu_psys_fops);
+- psys->cdev.owner = ipu_psys_fops.owner;
+-
+- rval = cdev_add(&psys->cdev, MKDEV(MAJOR(ipu_psys_dev_t), minor), 1);
+- if (rval) {
+- dev_err(dev, "cdev_add failed (%d)\n", rval);
+- goto out_unlock;
+- }
+-
+- set_bit(minor, ipu_psys_devices);
+-
+ spin_lock_init(&psys->ready_lock);
+ spin_lock_init(&psys->pgs_lock);
+ psys->ready = 0;
+@@ -2450,12 +2434,19 @@ static int ipu6_psys_probe(struct auxiliary_device *auxdev,
+ psys->dev.devt = MKDEV(MAJOR(ipu_psys_dev_t), minor);
+ psys->dev.release = ipu_psys_dev_release;
+ dev_set_name(&psys->dev, "ipu-psys%d", minor);
+- rval = device_register(&psys->dev);
++ device_initialize(&psys->dev);
++
++ cdev_init(&psys->cdev, &ipu_psys_fops);
++ psys->cdev.owner = ipu_psys_fops.owner;
++
++ rval = cdev_device_add(&psys->cdev, &psys->dev);
+ if (rval < 0) {
+ dev_err(dev, "psys device_register failed\n");
+ goto out_release_fw_com;
+ }
+
++ set_bit(minor, ipu_psys_devices);
++
+ /* Add the hw stepping information to caps */
+ strscpy(psys->caps.dev_model, IPU6_MEDIA_DEV_MODEL_NAME,
+ sizeof(psys->caps.dev_model));
+@@ -2483,7 +2474,6 @@ out_free_pgs:
+ ipu_psys_resource_pool_cleanup(&psys->resource_pool_running);
+ out_mutex_destroy:
+ mutex_destroy(&psys->mutex);
+- cdev_del(&psys->cdev);
+ if (psys->sched_cmd_thread) {
+ kthread_stop(psys->sched_cmd_thread);
+ psys->sched_cmd_thread = NULL;
+@@ -2552,10 +2542,9 @@ static void ipu6_psys_remove(struct auxiliary_device *auxdev)
+
+ ipu_psys_resource_pool_cleanup(&psys->resource_pool_running);
+
+- device_unregister(&psys->dev);
++ cdev_device_del(&psys->cdev, &psys->dev);
+
+ clear_bit(MINOR(psys->cdev.dev), ipu_psys_devices);
+- cdev_del(&psys->cdev);
+
+ mutex_unlock(&ipu_psys_mutex);
+
+--
+2.48.1
+
diff --git a/intel-ipu6-kmod.spec b/intel-ipu6-kmod.spec
index 048cf90..d6c7893 100644
--- a/intel-ipu6-kmod.spec
+++ b/intel-ipu6-kmod.spec
@@ -16,7 +16,7 @@
Name: %{prjname}-kmod
Summary: Kernel module (kmod) for %{prjname}
Version: 0.0
-Release: 19.%{ipu6_commitdate}git%{ipu6_shortcommit}%{?dist}
+Release: 20.%{ipu6_commitdate}git%{ipu6_shortcommit}%{?dist}
License: GPL-2.0-or-later
URL:
https://github.com/intel/ipu6-drivers
@@ -36,12 +36,15 @@ Patch7:
0007-Modify-0001-v6.10-IPU6-headers-used-by-PSYS.patch-fo.patch
#
https://github.com/intel/ipu6-drivers/pull/324
Patch8: 0008-ipu6-psys-Adjust-DMA-code-for-ipu6-bus-DMA-changes-i.patch
Patch9: 0009-Add-ipu6-dma.h-to-0001-v6.10-IPU6-headers-used-by-PS.patch
+#
https://github.com/intel/ipu6-drivers/pull/327
+Patch10: 0010-psys-Do-not-skipping-registering-ipu_psys_bus-for-ke.patch
+Patch11: 0011-psys-Use-cdev_device_add-for-dev-ipu-psys0.patch
#
https://github.com/intel/usbio-drivers/pull/33
-Patch10: 0010-usbio-Fix-GPIO-and-I2C-driver-modaliases.patch
+Patch20: 0010-usbio-Fix-GPIO-and-I2C-driver-modaliases.patch
#
https://github.com/intel/usbio-drivers/pull/34
-Patch11: 0011-usbio-Fix-I2C-max-transfer-size.patch
-Patch12: 0012-usbio-Use-MAX_PAYLOAD_BSIZE-in-usbio_bulk_write.patch
+Patch21: 0011-usbio-Fix-I2C-max-transfer-size.patch
+Patch22: 0012-usbio-Use-MAX_PAYLOAD_BSIZE-in-usbio_bulk_write.patch
# Downstream / Fedora specific patches
Patch101: 0101-Fedora-local-mod-integrate-usbio-drivers-within-ipu6.patch
@@ -77,13 +80,15 @@ kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname
%{prjname} %{?buil
%patch 7 -p1
%patch 8 -p1
%patch 9 -p1
+%patch 10 -p1
+%patch 11 -p1
%patch 101 -p1
patch -p1 < patches/0001-v6.10-IPU6-headers-used-by-PSYS.patch
)
(cd usbio-drivers-%{usbio_commit}
-%patch 10 -p1
-%patch 11 -p1
-%patch 12 -p1
+%patch 20 -p1
+%patch 21 -p1
+%patch 22 -p1
)
cp -Rp usbio-drivers-%{usbio_commit}/drivers ipu6-drivers-%{ipu6_commit}/
@@ -111,6 +116,9 @@ done
%changelog
+* Wed Feb 5 2025 Hans de Goede <hdegoede(a)redhat.com> - 0.0-20.20250115git13c466e
+- Fix bug causing udev to not properly enumerate the /dev/ipu-psys0 device
+
* Thu Jan 30 2025 Hans de Goede <hdegoede(a)redhat.com> - 0.0-19.20250115git13c466e
- Update to latest upstream
- Drop iVSC drivers, these are part of the mainline kernel now