mirror of
https://github.com/opnsense/src.git
synced 2026-02-18 18:20:26 -05:00
sdhci: Use bus_topo_lock and taskqueue_bus for hotplug events
Drop SDHCI_LOCK and instead acquire bus_topo_lock when adding and removing new-bus devices. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D49271 (cherry picked from commit aaf0a7302d10912e62dcd8e047798b4a2aefa039)
This commit is contained in:
parent
ee08e84551
commit
207e58ce8a
1 changed files with 10 additions and 6 deletions
|
|
@ -701,12 +701,14 @@ sdhci_card_task(void *arg, int pending __unused)
|
|||
mmccam_start_discovery(slot->sim);
|
||||
SDHCI_UNLOCK(slot);
|
||||
#else
|
||||
d = slot->dev = device_add_child(slot->bus, "mmc", -1);
|
||||
SDHCI_UNLOCK(slot);
|
||||
bus_topo_lock();
|
||||
d = slot->dev = device_add_child(slot->bus, "mmc", -1);
|
||||
if (d) {
|
||||
device_set_ivars(d, slot);
|
||||
(void)device_probe_and_attach(d);
|
||||
}
|
||||
bus_topo_unlock();
|
||||
#endif
|
||||
} else
|
||||
SDHCI_UNLOCK(slot);
|
||||
|
|
@ -732,7 +734,9 @@ sdhci_card_task(void *arg, int pending __unused)
|
|||
slot->opt &= ~SDHCI_TUNING_ENABLED;
|
||||
SDHCI_UNLOCK(slot);
|
||||
callout_drain(&slot->retune_callout);
|
||||
bus_topo_lock();
|
||||
device_delete_child(slot->bus, d);
|
||||
bus_topo_unlock();
|
||||
#endif
|
||||
} else
|
||||
SDHCI_UNLOCK(slot);
|
||||
|
|
@ -761,10 +765,10 @@ sdhci_handle_card_present_locked(struct sdhci_slot *slot, bool is_present)
|
|||
was_present = slot->dev != NULL;
|
||||
#endif
|
||||
if (!was_present && is_present) {
|
||||
taskqueue_enqueue_timeout(taskqueue_swi_giant,
|
||||
taskqueue_enqueue_timeout(taskqueue_bus,
|
||||
&slot->card_delayed_task, -SDHCI_INSERT_DELAY_TICKS);
|
||||
} else if (was_present && !is_present) {
|
||||
taskqueue_enqueue(taskqueue_swi_giant, &slot->card_task);
|
||||
taskqueue_enqueue(taskqueue_bus, &slot->card_task);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1130,7 +1134,7 @@ no_tuning:
|
|||
"timeout", CTLFLAG_RWTUN, &slot->timeout, 0,
|
||||
"Maximum timeout for SDHCI transfers (in secs)");
|
||||
TASK_INIT(&slot->card_task, 0, sdhci_card_task, slot);
|
||||
TIMEOUT_TASK_INIT(taskqueue_swi_giant, &slot->card_delayed_task, 0,
|
||||
TIMEOUT_TASK_INIT(taskqueue_bus, &slot->card_delayed_task, 0,
|
||||
sdhci_card_task, slot);
|
||||
callout_init(&slot->card_poll_callout, 1);
|
||||
callout_init_mtx(&slot->timeout_callout, &slot->mtx, 0);
|
||||
|
|
@ -1184,8 +1188,8 @@ sdhci_cleanup_slot(struct sdhci_slot *slot)
|
|||
callout_drain(&slot->timeout_callout);
|
||||
callout_drain(&slot->card_poll_callout);
|
||||
callout_drain(&slot->retune_callout);
|
||||
taskqueue_drain(taskqueue_swi_giant, &slot->card_task);
|
||||
taskqueue_drain_timeout(taskqueue_swi_giant, &slot->card_delayed_task);
|
||||
taskqueue_drain(taskqueue_bus, &slot->card_task);
|
||||
taskqueue_drain_timeout(taskqueue_bus, &slot->card_delayed_task);
|
||||
|
||||
SDHCI_LOCK(slot);
|
||||
d = slot->dev;
|
||||
|
|
|
|||
Loading…
Reference in a new issue