From patchwork Fri May 29 10:23:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 187298 Delivered-To: patches@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp445077ilb; Fri, 29 May 2020 03:23:50 -0700 (PDT) X-Received: by 2002:a19:c8e:: with SMTP id 136mr3976874lfm.72.1590747829940; Fri, 29 May 2020 03:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590747829; cv=none; d=google.com; s=arc-20160816; b=uyrs1M5zFv7noSR9nxwQSNEecQhuN3vmAuHc46Zq/XU1YBGiOMVA7F/9mrr0HxkZE0 x48V56NnLzQLQhnQlwO0kAibSZx1JDt4LBic9HK+SXbmUdL1aUh9bTPW3LdMOm+M+MDN JwPjtu5S2L5y2lqWwrJ9QzUe+604OgSAc0r7MP1F7sw0qLSKq6Gq/pk4XudjnEzCzYLM C0Lge82KddDZdgDlHp8irB17kvXBaqib+mCsirr5bj0kMsPuuPk5mEkIzJlRdFOgecwM BpGO9AAQ6+vzWdvjxCGijHXQiMZvKQrsf6xFsqX4V3l3uyKkJg6UadjHV+YMQSvsL9/d r4Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=RtiHAujl9lf2oMvwRBMnVGbOD90IBdFARsRXPPpNsWY=; b=QW4kXBorTHmAwQh7CxfdbjBVm+BH74IJIxEUYYBeDxCsOhmWv8Jg5jA+Tem0S6BaBd TATfhiOIoWtHZQOl3r3q+pTrmUEUojaCC3a59QE77OWAlIFk3+3w2RNDz1roLBTN1T04 UkfIBwF/GKbzHxCyaCZCAuEVtl3GjFOI8Mau5BqOkiRk10FKcxBgZY/Nv26ICb5OvgKn liRslHi+Y7xc6WMJd1uNNx6NJb0p6D1TUrDXYlzMEjVpNmUa5oq+jt72EZEdZrwvLIic yeVEgXX6dyQzOooseISHlkGVvxG8ADW9MR3dGuJuWlcSfB1USYe5+nbximstW/zBh2SF n+dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=poIRSp28; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w12sor5476637ljh.49.2020.05.29.03.23.49 for (Google Transport Security); Fri, 29 May 2020 03:23:49 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=poIRSp28; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RtiHAujl9lf2oMvwRBMnVGbOD90IBdFARsRXPPpNsWY=; b=poIRSp28YZwRA/l7u/DkP2Hcl603SWYzvPDSwddXAqTudJYmQuYGH2QobiSOQjiMWD tYlGXNTFFdq9mJS01vTirdtF8gpUxBdiBnNnRO0nOOMmuar7cHod5Xuno9HPM/9VKrZR N1Iya4RgYNf18bhwdD8BiKNnjzMN1CsW6RSQUNRGjiMgl8vfxuY0UUVKQMnSx3RRKjSZ U3bWKwWDKABc7hix4vDyqhOHlbmkdALRq7pOVAqByi286lDEW71KixibqBWdPe4KSKz+ rd9NYrNSKFlyqgY0cHaYdN4c4+ypEuFLGI/9BYKhne0AjaWYRiujURjfTJUkjOI3Pb4x UwUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RtiHAujl9lf2oMvwRBMnVGbOD90IBdFARsRXPPpNsWY=; b=JmHMXBISb8wVvee4CgP2axoF7rSiEWSnLNRtzxTTsTY2jHJcvQIqv/UmJjmdFdyH6u svlLeuVZ/PPxmwy6WxMP0RftsgvsoBEPrnPJq1p+I5IpjfLJfie/L0d0QrC9TLLlS6aQ qNjV6tHmbo4o3ZH4sAxP99iH6pDUV0nKOBvOmLICedbHx4fa7MwJzpEWPGmlVe1/zAB7 qa7WXsQEQuVj9BpKQS0t8MznsVCdcJwoqGi3M6oix7cDTQS1QZpUzXzZZXY1lA82x3r5 UPzKWyBJue2eYQR6OOkViTLn8DLXp52kN75cCWL5g/weTEZzlhmjP/kXIsptAHwtVD5/ 7/Uw== X-Gm-Message-State: AOAM532ewyLu4jOI60lBpxk4ugG/0IAWKLhn6KpqFjgvTiFl0GZQt3CQ 1M5Yj7oJgat/EVoBTMtX4Nm9xNMT X-Google-Smtp-Source: ABdhPJycAtZPotAPlmj89l9sOK9ZfCEE9Y2BHD3lMtTp3cDn3DaGEz7sVaVlq2KCtV8mrq07crqmxQ== X-Received: by 2002:a2e:980d:: with SMTP id a13mr4017188ljj.277.1590747829267; Fri, 29 May 2020 03:23:49 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id g142sm2175067lfd.59.2020.05.29.03.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 03:23:47 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Adrian Hunter , "Rafael J . Wysocki" Cc: Haibo Chen , Ulf Hansson , linux-pm@vger.kernel.org Subject: [PATCH] mmc: core: Always allow the card detect uevent to be consumed Date: Fri, 29 May 2020 12:23:41 +0200 Message-Id: <20200529102341.12529-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 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 --- drivers/mmc/core/core.c | 10 +++++----- drivers/mmc/core/host.c | 3 +++ include/linux/mmc/host.h | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 8d2b808e9b58..aff3fa937674 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1455,12 +1455,12 @@ void mmc_detach_bus(struct mmc_host *host) void _mmc_detect_change(struct mmc_host *host, unsigned long delay, bool cd_irq) { /* - * If the device is configured as wakeup, we prevent a new sleep for - * 5 s to give provision for user space to consume the event. + * Prevent system sleep for 5s to allow user space to consume the + * corresponding uevent. This is especially useful, when CD irq is used + * as a system wakeup, but doesn't hurt in other cases. */ - if (cd_irq && !(host->caps & MMC_CAP_NEEDS_POLL) && - device_can_wakeup(mmc_dev(host))) - pm_wakeup_event(mmc_dev(host), 5000); + if (cd_irq && !(host->caps & MMC_CAP_NEEDS_POLL)) + __pm_wakeup_event(host->ws, 5000); host->detect_change = 1; mmc_schedule_delayed_work(&host->detect, delay); diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index c8768726d925..6141a85749ca 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ static DEFINE_IDA(mmc_host_ida); static void mmc_host_classdev_release(struct device *dev) { struct mmc_host *host = cls_dev_to_mmc_host(dev); + wakeup_source_unregister(host->ws); ida_simple_remove(&mmc_host_ida, host->index); kfree(host); } @@ -400,6 +402,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) host->index = err; dev_set_name(&host->class_dev, "mmc%d", host->index); + host->ws = wakeup_source_register(NULL, dev_name(&host->class_dev)); host->parent = dev; host->class_dev.parent = dev; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 7149bab555d7..1fa4fa1caef5 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -287,6 +287,7 @@ struct mmc_host { #ifdef CONFIG_PM_SLEEP struct notifier_block pm_notify; #endif + struct wakeup_source *ws; /* Enable consume of uevents */ u32 max_current_330; u32 max_current_300; u32 max_current_180;