Skip to content

Commit b52fb25

Browse files
author
Ulf Hansson
committed
mmc: core: Always allow the card detect uevent to be consumed
The approach to allow userspace ~5s to consume the uevent, which is triggered when a new card is inserted/initialized, currently requires the mmc host to support system wakeup. This is unnecessary limiting, especially for an mmc host that relies on a GPIO IRQ for card detect. More precisely, the mmc host may not support system wakeup for its corresponding struct device, while the GPIO IRQ still could be configured as a wakeup IRQ via enable_irq_wake(). To support all various cases, let's simply drop the need for the wakeup support. Instead let's always register a wakeup source and activate it for all card detect IRQs by calling __pm_wakeup_event(). Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://lore.kernel.org/r/20200529102341.12529-1-ulf.hansson@linaro.org
1 parent 11ba468 commit b52fb25

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎drivers/mmc/core/core.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,12 +1455,12 @@ void mmc_detach_bus(struct mmc_host *host)
14551455
void _mmc_detect_change(struct mmc_host *host, unsigned long delay, bool cd_irq)
14561456
{
14571457
/*
1458-
* If the device is configured as wakeup, we prevent a new sleep for
1459-
* 5 s to give provision for user space to consume the event.
1458+
* Prevent system sleep for 5s to allow user space to consume the
1459+
* corresponding uevent. This is especially useful, when CD irq is used
1460+
* as a system wakeup, but doesn't hurt in other cases.
14601461
*/
1461-
if (cd_irq && !(host->caps & MMC_CAP_NEEDS_POLL) &&
1462-
device_can_wakeup(mmc_dev(host)))
1463-
pm_wakeup_event(mmc_dev(host), 5000);
1462+
if (cd_irq && !(host->caps & MMC_CAP_NEEDS_POLL))
1463+
__pm_wakeup_event(host->ws, 5000);
14641464

14651465
host->detect_change = 1;
14661466
mmc_schedule_delayed_work(&host->detect, delay);

‎drivers/mmc/core/host.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/of.h>
1616
#include <linux/of_gpio.h>
1717
#include <linux/pagemap.h>
18+
#include <linux/pm_wakeup.h>
1819
#include <linux/export.h>
1920
#include <linux/leds.h>
2021
#include <linux/slab.h>
@@ -36,6 +37,7 @@ static DEFINE_IDA(mmc_host_ida);
3637
static void mmc_host_classdev_release(struct device *dev)
3738
{
3839
struct mmc_host *host = cls_dev_to_mmc_host(dev);
40+
wakeup_source_unregister(host->ws);
3941
ida_simple_remove(&mmc_host_ida, host->index);
4042
kfree(host);
4143
}
@@ -400,6 +402,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
400402
host->index = err;
401403

402404
dev_set_name(&host->class_dev, "mmc%d", host->index);
405+
host->ws = wakeup_source_register(NULL, dev_name(&host->class_dev));
403406

404407
host->parent = dev;
405408
host->class_dev.parent = dev;

‎include/linux/mmc/host.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ struct mmc_host {
287287
#ifdef CONFIG_PM_SLEEP
288288
struct notifier_block pm_notify;
289289
#endif
290+
struct wakeup_source *ws; /* Enable consume of uevents */
290291
u32 max_current_330;
291292
u32 max_current_300;
292293
u32 max_current_180;

0 commit comments

Comments
 (0)