Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psys: Do not skip registering ipu_psys_bus for kernels >= 6.10 #327

Merged
merged 3 commits into from
Feb 24, 2025

Conversation

jwrdegoede
Copy link
Contributor

@jwrdegoede jwrdegoede commented Feb 5, 2025

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()).

The new auxbus code-paths where 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
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 <[email protected]>
@jwrdegoede jwrdegoede changed the title psys: Do not skipping registering ipu_psys_bus for kernels >= 6.10 psys: Do not skip registering ipu_psys_bus for kernels >= 6.10 Feb 5, 2025
@hao-yao
Copy link
Contributor

hao-yao commented Feb 17, 2025

Hi Hans @jwrdegoede , I'm looking into this PR and rebased internally. Will update it later.

@jwrdegoede
Copy link
Contributor Author

Hi Hans @jwrdegoede , I'm looking into this PR and rebased internally. Will update it later.

Note you can reproduce the issue (with a new enough kernel using the in kernel isys) by doing:

udevadm info -e > udevdb.txt

and then look for /dev/ipu-psys0 in udevdb.txt without this pull-request there will be no udevdb entry for that.

@bingbucao
Copy link

Here is the udev rule to change the owner on Chrome:
KERNELS=="ipu-psys[0-9]", OWNER="arc-camera", GROUP="arc-camera", MODE="0600"
psys->dev.bus = &ipu6_psys_bus can help to allow udev to apply the rule.
Is there some specific reason we need to bus_register()?

@hao-yao
Copy link
Contributor

hao-yao commented Feb 19, 2025

Hi Hans @jwrdegoede , I resolved a conflict and rebased your PR to my fork here which have synced with intel/ipu6-drivers/master, could you help to update to this PR? Thank you.

@hao-yao
Copy link
Contributor

hao-yao commented Feb 21, 2025

Hi Bingbu @bingbucao , seems the PSYS driver called bus_register() before kernel v6.10 but not after v6.10. As we are using the struct bus_type ipu_isys_bus, I think it's better to call bus_register() on it although we can change udev rule condition to let it work.

@jwrdegoede Hans, is there any other issues could we met if we don't call bus_register()?

@jwrdegoede
Copy link
Contributor Author

jwrdegoede commented Feb 21, 2025

@jwrdegoede Hans, is there any other issues could we met if we don't call bus_register()?

ATM the device's bus member is set to the ipu6-bus, setting a device's bus-member to a non registered bus is not supported and will result in undefined behavior. I'm surprised things work as well as they do without this patch.

You could try setting the device's bus member to NULL, I think that will just result in the device being attached to the virtual bus.

@bingbucao
Copy link

@jwrdegoede Hans, is there any other issues could we met if we don't call bus_register()?

ATM the device's bus member is set to the ipu6-bus, setting a device's bus-member to a non registered bus is not supported and will result in undefined behavior. I'm surprised things work as well as they do without this patch.

You could try setting the device's bus member to NULL, I think that will just result in the device being attached to the virtual bus.

ACK. We will land this PR.

@hao-yao hao-yao merged commit 8ed9323 into intel:master Feb 24, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants