| Message ID | 20261105-device-trust-core-v1-8-1e536825b4eb@nvidia.com |
|---|---|
| State | New |
| Headers | show |
| Series | driver core: Authorize device trust before driver binding | expand |
> From: Leon Romanovsky <leonro@nvidia.com> > > commit b8c5cec23d5c ("Driver core: udev triggered device-<>driver > binding") introduced the concept of "Systems who want to control the > driver binding with udev" can use the drivers_probe sysfs to trigger a > driver bind based on the kernel's match list. > > If attaching the driver is deferred before its probe callback runs, > userspace sees EINVAL and cannot tell it should try again, maybe after > loading other drivers. > > Map that deferral to EAGAIN and add missed documentation for the > drivers_probe sysfs. A deferral requested by the probe callback itself > is still not reported. > > Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Sashiko has reviewed this patch and found no issues.
diff --git a/Documentation/ABI/testing/sysfs-bus-drivers-probe b/Documentation/ABI/testing/sysfs-bus-drivers-probe new file mode 100644 index 0000000000000..851c65b9331ae --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-drivers-probe @@ -0,0 +1,13 @@ +What: /sys/bus/.../drivers_probe +Date: February 2007 +Contact: driver-core@lists.linux.dev +Description: + (WO) Writing a device name requests driver attachment on this + bus, even when drivers_autoprobe is disabled. A successful + write does not guarantee that a driver bound. The device's + driver link reports the result. + + EAGAIN means attachment was deferred before the driver's probe + callback, for example while a supplier or the device itself + is not ready. ENODEV means the device was not found. Other + attachment errors return EINVAL. diff --git a/MAINTAINERS b/MAINTAINERS index 93abbb315065d..b726344362b41 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8149,6 +8149,7 @@ M: Johan Hovold <johan@kernel.org> L: driver-core@lists.linux.dev S: Supported T: git git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git +F: Documentation/ABI/testing/sysfs-bus-drivers-probe F: Documentation/core-api/kobject.rst F: Documentation/driver-api/driver-model/ F: drivers/base/ diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 396097fdb3162..ecff32c3704b5 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -310,13 +310,18 @@ static ssize_t drivers_probe_store(const struct bus_type *bus, const char *buf, size_t count) { struct device *dev; - int err = -EINVAL; + int err; dev = bus_find_device_by_name(bus, NULL, buf); if (!dev) return -ENODEV; - if (bus_rescan_devices_helper(dev, NULL) == 0) + err = bus_rescan_devices_helper(dev, NULL); + if (!err) err = count; + else if (err == -EPROBE_DEFER) + err = -EAGAIN; + else + err = -EINVAL; put_device(dev); return err; }