Skip to content

Commit e33aafa

Browse files
committed
Merge tag 'driver-core-7.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core
Pull driver core fix from Danilo Krummrich: - Revert "driver core: enforce device_lock for driver_match_device()": When a device is already present in the system and a driver is registered on the same bus, we iterate over all devices registered on this bus to see if one of them matches. If we come across an already bound one where the corresponding driver crashed while holding the device lock (e.g. in probe()) we can't make any progress anymore. Thus, revert and clarify that an implementer of struct bus_type must not expect match() to be called with the device lock held. * tag 'driver-core-7.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core: Revert "driver core: enforce device_lock for driver_match_device()"
2 parents 0f912c8 + 9de6839 commit e33aafa

3 files changed

Lines changed: 4 additions & 11 deletions

File tree

drivers/base/base.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,10 @@ void device_release_driver_internal(struct device *dev, const struct device_driv
179179
void driver_detach(const struct device_driver *drv);
180180
void driver_deferred_probe_del(struct device *dev);
181181
void device_set_deferred_probe_reason(const struct device *dev, struct va_format *vaf);
182-
static inline int driver_match_device_locked(const struct device_driver *drv,
183-
struct device *dev)
184-
{
185-
device_lock_assert(dev);
186-
187-
return drv->bus->match ? drv->bus->match(dev, drv) : 1;
188-
}
189-
190182
static inline int driver_match_device(const struct device_driver *drv,
191183
struct device *dev)
192184
{
193-
guard(device)(dev);
194-
return driver_match_device_locked(drv, dev);
185+
return drv->bus->match ? drv->bus->match(dev, drv) : 1;
195186
}
196187

197188
static inline void dev_sync_state(struct device *dev)

drivers/base/dd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
928928
bool async_allowed;
929929
int ret;
930930

931-
ret = driver_match_device_locked(drv, dev);
931+
ret = driver_match_device(drv, dev);
932932
if (ret == 0) {
933933
/* no match */
934934
return 0;

include/linux/device/bus.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ struct fwnode_handle;
3535
* otherwise. It may also return error code if determining that
3636
* the driver supports the device is not possible. In case of
3737
* -EPROBE_DEFER it will queue the device for deferred probing.
38+
* Note: This callback may be invoked with or without the device
39+
* lock held.
3840
* @uevent: Called when a device is added, removed, or a few other things
3941
* that generate uevents to add the environment variables.
4042
* @probe: Called when a new device or driver add to this bus, and callback

0 commit comments

Comments
 (0)