Commit 50ad1c21 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'driver-core-5.8-rc6' of...

Merge tag 'driver-core-5.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core into master

Pull driver core fixes from Greg KH:
 "Here are 3 driver core fixes for 5.8-rc6.

  They resolve some issues found with the deferred probe code for some
  types of devices on some embedded systems. They have been tested a
  bunch and have been in linux-next for a while with no reported issues"

* tag 'driver-core-5.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
  driver core: Avoid deferred probe due to fw_devlink_pause/resume()
  driver core: Rename dev_links_info.defer_sync to defer_hook
  driver core: Don't do deferred probe in parallel with kernel_init thread
parents 6a058f0b 2451e746
...@@ -153,7 +153,6 @@ extern char *make_class_name(const char *name, struct kobject *kobj); ...@@ -153,7 +153,6 @@ extern char *make_class_name(const char *name, struct kobject *kobj);
extern int devres_release_all(struct device *dev); extern int devres_release_all(struct device *dev);
extern void device_block_probing(void); extern void device_block_probing(void);
extern void device_unblock_probing(void); extern void device_unblock_probing(void);
extern void driver_deferred_probe_force_trigger(void);
/* /sys/devices directory */ /* /sys/devices directory */
extern struct kset *devices_kset; extern struct kset *devices_kset;
......
...@@ -50,6 +50,7 @@ static DEFINE_MUTEX(wfs_lock); ...@@ -50,6 +50,7 @@ static DEFINE_MUTEX(wfs_lock);
static LIST_HEAD(deferred_sync); static LIST_HEAD(deferred_sync);
static unsigned int defer_sync_state_count = 1; static unsigned int defer_sync_state_count = 1;
static unsigned int defer_fw_devlink_count; static unsigned int defer_fw_devlink_count;
static LIST_HEAD(deferred_fw_devlink);
static DEFINE_MUTEX(defer_fw_devlink_lock); static DEFINE_MUTEX(defer_fw_devlink_lock);
static bool fw_devlink_is_permissive(void); static bool fw_devlink_is_permissive(void);
...@@ -754,11 +755,11 @@ static void __device_links_queue_sync_state(struct device *dev, ...@@ -754,11 +755,11 @@ static void __device_links_queue_sync_state(struct device *dev,
*/ */
dev->state_synced = true; dev->state_synced = true;
if (WARN_ON(!list_empty(&dev->links.defer_sync))) if (WARN_ON(!list_empty(&dev->links.defer_hook)))
return; return;
get_device(dev); get_device(dev);
list_add_tail(&dev->links.defer_sync, list); list_add_tail(&dev->links.defer_hook, list);
} }
/** /**
...@@ -776,8 +777,8 @@ static void device_links_flush_sync_list(struct list_head *list, ...@@ -776,8 +777,8 @@ static void device_links_flush_sync_list(struct list_head *list,
{ {
struct device *dev, *tmp; struct device *dev, *tmp;
list_for_each_entry_safe(dev, tmp, list, links.defer_sync) { list_for_each_entry_safe(dev, tmp, list, links.defer_hook) {
list_del_init(&dev->links.defer_sync); list_del_init(&dev->links.defer_hook);
if (dev != dont_lock_dev) if (dev != dont_lock_dev)
device_lock(dev); device_lock(dev);
...@@ -815,12 +816,12 @@ void device_links_supplier_sync_state_resume(void) ...@@ -815,12 +816,12 @@ void device_links_supplier_sync_state_resume(void)
if (defer_sync_state_count) if (defer_sync_state_count)
goto out; goto out;
list_for_each_entry_safe(dev, tmp, &deferred_sync, links.defer_sync) { list_for_each_entry_safe(dev, tmp, &deferred_sync, links.defer_hook) {
/* /*
* Delete from deferred_sync list before queuing it to * Delete from deferred_sync list before queuing it to
* sync_list because defer_sync is used for both lists. * sync_list because defer_hook is used for both lists.
*/ */
list_del_init(&dev->links.defer_sync); list_del_init(&dev->links.defer_hook);
__device_links_queue_sync_state(dev, &sync_list); __device_links_queue_sync_state(dev, &sync_list);
} }
out: out:
...@@ -838,8 +839,8 @@ late_initcall(sync_state_resume_initcall); ...@@ -838,8 +839,8 @@ late_initcall(sync_state_resume_initcall);
static void __device_links_supplier_defer_sync(struct device *sup) static void __device_links_supplier_defer_sync(struct device *sup)
{ {
if (list_empty(&sup->links.defer_sync) && dev_has_sync_state(sup)) if (list_empty(&sup->links.defer_hook) && dev_has_sync_state(sup))
list_add_tail(&sup->links.defer_sync, &deferred_sync); list_add_tail(&sup->links.defer_hook, &deferred_sync);
} }
static void device_link_drop_managed(struct device_link *link) static void device_link_drop_managed(struct device_link *link)
...@@ -1052,7 +1053,7 @@ void device_links_driver_cleanup(struct device *dev) ...@@ -1052,7 +1053,7 @@ void device_links_driver_cleanup(struct device *dev)
WRITE_ONCE(link->status, DL_STATE_DORMANT); WRITE_ONCE(link->status, DL_STATE_DORMANT);
} }
list_del_init(&dev->links.defer_sync); list_del_init(&dev->links.defer_hook);
__device_links_no_driver(dev); __device_links_no_driver(dev);
device_links_write_unlock(); device_links_write_unlock();
...@@ -1244,6 +1245,12 @@ static void fw_devlink_link_device(struct device *dev) ...@@ -1244,6 +1245,12 @@ static void fw_devlink_link_device(struct device *dev)
fw_ret = -EAGAIN; fw_ret = -EAGAIN;
} else { } else {
fw_ret = -ENODEV; fw_ret = -ENODEV;
/*
* defer_hook is not used to add device to deferred_sync list
* until device is bound. Since deferred fw devlink also blocks
* probing, same list hook can be used for deferred_fw_devlink.
*/
list_add_tail(&dev->links.defer_hook, &deferred_fw_devlink);
} }
if (fw_ret == -ENODEV) if (fw_ret == -ENODEV)
...@@ -1312,6 +1319,9 @@ void fw_devlink_pause(void) ...@@ -1312,6 +1319,9 @@ void fw_devlink_pause(void)
*/ */
void fw_devlink_resume(void) void fw_devlink_resume(void)
{ {
struct device *dev, *tmp;
LIST_HEAD(probe_list);
mutex_lock(&defer_fw_devlink_lock); mutex_lock(&defer_fw_devlink_lock);
if (!defer_fw_devlink_count) { if (!defer_fw_devlink_count) {
WARN(true, "Unmatched fw_devlink pause/resume!"); WARN(true, "Unmatched fw_devlink pause/resume!");
...@@ -1323,9 +1333,19 @@ void fw_devlink_resume(void) ...@@ -1323,9 +1333,19 @@ void fw_devlink_resume(void)
goto out; goto out;
device_link_add_missing_supplier_links(); device_link_add_missing_supplier_links();
driver_deferred_probe_force_trigger(); list_splice_tail_init(&deferred_fw_devlink, &probe_list);
out: out:
mutex_unlock(&defer_fw_devlink_lock); mutex_unlock(&defer_fw_devlink_lock);
/*
* bus_probe_device() can cause new devices to get added and they'll
* try to grab defer_fw_devlink_lock. So, this needs to be done outside
* the defer_fw_devlink_lock.
*/
list_for_each_entry_safe(dev, tmp, &probe_list, links.defer_hook) {
list_del_init(&dev->links.defer_hook);
bus_probe_device(dev);
}
} }
/* Device links support end. */ /* Device links support end. */
...@@ -2172,7 +2192,7 @@ void device_initialize(struct device *dev) ...@@ -2172,7 +2192,7 @@ void device_initialize(struct device *dev)
INIT_LIST_HEAD(&dev->links.consumers); INIT_LIST_HEAD(&dev->links.consumers);
INIT_LIST_HEAD(&dev->links.suppliers); INIT_LIST_HEAD(&dev->links.suppliers);
INIT_LIST_HEAD(&dev->links.needs_suppliers); INIT_LIST_HEAD(&dev->links.needs_suppliers);
INIT_LIST_HEAD(&dev->links.defer_sync); INIT_LIST_HEAD(&dev->links.defer_hook);
dev->links.status = DL_DEV_NO_DRIVER; dev->links.status = DL_DEV_NO_DRIVER;
} }
EXPORT_SYMBOL_GPL(device_initialize); EXPORT_SYMBOL_GPL(device_initialize);
......
...@@ -164,11 +164,6 @@ static void driver_deferred_probe_trigger(void) ...@@ -164,11 +164,6 @@ static void driver_deferred_probe_trigger(void)
if (!driver_deferred_probe_enable) if (!driver_deferred_probe_enable)
return; return;
driver_deferred_probe_force_trigger();
}
void driver_deferred_probe_force_trigger(void)
{
/* /*
* A successful probe means that all the devices in the pending list * A successful probe means that all the devices in the pending list
* should be triggered to be reprobed. Move all the deferred devices * should be triggered to be reprobed. Move all the deferred devices
......
...@@ -433,7 +433,8 @@ enum dl_dev_state { ...@@ -433,7 +433,8 @@ enum dl_dev_state {
* @suppliers: List of links to supplier devices. * @suppliers: List of links to supplier devices.
* @consumers: List of links to consumer devices. * @consumers: List of links to consumer devices.
* @needs_suppliers: Hook to global list of devices waiting for suppliers. * @needs_suppliers: Hook to global list of devices waiting for suppliers.
* @defer_sync: Hook to global list of devices that have deferred sync_state. * @defer_hook: Hook to global list of devices that have deferred sync_state or
* deferred fw_devlink.
* @need_for_probe: If needs_suppliers is on a list, this indicates if the * @need_for_probe: If needs_suppliers is on a list, this indicates if the
* suppliers are needed for probe or not. * suppliers are needed for probe or not.
* @status: Driver status information. * @status: Driver status information.
...@@ -442,7 +443,7 @@ struct dev_links_info { ...@@ -442,7 +443,7 @@ struct dev_links_info {
struct list_head suppliers; struct list_head suppliers;
struct list_head consumers; struct list_head consumers;
struct list_head needs_suppliers; struct list_head needs_suppliers;
struct list_head defer_sync; struct list_head defer_hook;
bool need_for_probe; bool need_for_probe;
enum dl_dev_state status; enum dl_dev_state status;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment