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

Introduce USB device probe helper #42

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nfraprado
Copy link

Current bootrr helpers, assert_device_present and assert_driver_present,
use driver and device names, both of which are not part of the kernel's
stable ABI and end up requiring extra maintenance whenever those names
are changed, in order to check for the expected name on each kernel
version.

Introduce a new helper, assert_usb_probed, that verifies a USB device
has been probed, taking as parameters the device's hardware identifying
properties, which are documented kernel ABI: idVendor, idProduct,
bcdDevice, bDeviceClass, bDeviceSubClass, bDeviceProtocol,
bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol,
bInterfaceNumber.

A 'count' parameter is also required, to inform the number of devices
matching these criteria that should have been probed. This allows the
test to verify the probe of multiple identical devices.

A '*' can be used as wildcard for any of the matching fields as
necessary.

As part of this PR, the USB devices on Spherion are converted to use this new helper. Other platforms should also be converted over time.

Note: I have a series on the kernel mailing list that adds a kselftest to check for probed devices based on the Devicetree: https://lore.kernel.org/all/[email protected] . That should make most of the assert_device_present and assert_driver_present tests in bootrr unnecessary. The exception being devices from discoverable busses, like USB and PCI. Hence this PR improves the stability of the checks for USB devices, and I intend to create a similar PR for a check for PCI devices.

Current bootrr helpers, assert_device_present and assert_driver_present,
use driver and device names, both of which are not part of the kernel's
stable ABI and end up requiring extra maintenance whenever those names
are changed, in order to check for the expected name on each kernel
version.

Introduce a new helper, assert_usb_probed, that verifies a USB device
has been probed, taking as parameters the device's hardware identifying
properties, which are documented kernel ABI: idVendor, idProduct,
bcdDevice, bDeviceClass, bDeviceSubClass, bDeviceProtocol,
bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol,
bInterfaceNumber.

A 'count' parameter is also required, to inform the number of devices
matching these criteria that should have been probed. This allows the
test to verify the probe of multiple identical devices.

A '*' can be used as wildcard for any of the matching fields as
necessary.

Signed-off-by: Nícolas F. R. A. Prado <[email protected]>
Make use of the newly added assert_usb_probed helper for USB devices on
Spherion, as it relies on documented kernel ABI and will therefore
require less maintenance.

Signed-off-by: Nícolas F. R. A. Prado <[email protected]>
@gctucker
Copy link

gctucker commented Sep 7, 2023

It might be a good idea to submit this upstream first, or maybe at the same time?

@nfraprado
Copy link
Author

I hadn't because there wasn't any platform that I could test this on upstream (my own fault since I had not added the Spherion tests upstream). But I've submitted this same PR upstream now: linux-msm#60.

@gctucker
Copy link

gctucker commented Sep 8, 2023

Maybe platforms or even everything in this fork should be considered for upstreaming. The only reason why we're using the fork is because the upstream was a bit unmaintained a few years ago, but maybe that has changed now.

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.

2 participants