From patchwork Tue May 9 08:27:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 98883 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1708392qge; Tue, 9 May 2017 01:27:37 -0700 (PDT) X-Received: by 10.28.203.143 with SMTP id b137mr4623171wmg.115.1494318457359; Tue, 09 May 2017 01:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494318457; cv=none; d=google.com; s=arc-20160816; b=pjyw4LHkgtjcqD5v6UU6LoRdIM4I/OTZurWpyCiwBJB5IffNdJRAj1du1vCfGPp9JN w+HC12fUo1GUui1FajF2VNxq5paZ0lvNToyyoLD9H3Pza7mOxEwO3VRTfyMYEHci8Evv NU8tM3VuZNmVZW7Sc8WSBrKrnRziK7HiDoJMM3NRF8dgm6TJRme1AF6z90XmYERU32ux 32IHuz60Hg3ipsQFiFWJ7N6ZptRkp6uEoyNSrHwAsEtUPyayc1/QwcZ3jFFMvcqfbKsm pcQAROJtp+mTIF2WMb3OcSZjtNwcgm9UwGOIUYF2V4B/JwP8RnRVrunyiNai2i+PzQYd WPug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=30BbE8mQAd3tnjfHE9wXYlYo6qerrlS4WG++0HNhYOQ=; b=T2as/uWQCS9MfGdSAYvpvOahjJCrBxLUvYRjckhYDIhrUaDr2KMLstrEJGUc+9YLVc OYTiWGhBqgOxpj0dfxl7q8NBUzqxnUPCs/fxwqe30Vwf/OQw/nmdS6MNlYSeU+i+hCic k73SWAYEsR+H7EsRvqwRSWC1QB/FW6TaqJGkl7JG5d803vlh+aW85C2AdYGlHME86GPv jYuSBrc7cOuSRdheQ6vdZnImRJkj4Ims9Xf6Z8u53ilo7rBoz1o53rJzcjHfxrpNmOFR 7CAl4SOfMqzfuASJWUO+VyskFHAjKloPnqHtsgGO+v/A8rjkegxN2qLyZ0m3QycQ8iu9 RKIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::234 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-wr0-x234.google.com (mail-wr0-x234.google.com. [2a00:1450:400c:c0c::234]) by mx.google.com with ESMTPS id 93si16406873wrq.153.2017.05.09.01.27.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 01:27:37 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::234 as permitted sender) client-ip=2a00:1450:400c:c0c::234; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::234 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wr0-x234.google.com with SMTP id l9so63239075wre.1 for ; Tue, 09 May 2017 01:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=30BbE8mQAd3tnjfHE9wXYlYo6qerrlS4WG++0HNhYOQ=; b=ACxLSsQbT7R3iFK6QRtdRVDdnUWN4cLtYq9q/9KK+Wk3jvkSi4RUTAQ+49b6A7TKJw vFL3hRA2kWmxSxSLvNKk23D1Lf2ufzA9EOy27gBfBbRg6rD7BW7AWoVWoni/qB7xj9zX cKX7PSZv/dcpi1Tr7DMW6go6++n322pR4nOIw= 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:in-reply-to :references; bh=30BbE8mQAd3tnjfHE9wXYlYo6qerrlS4WG++0HNhYOQ=; b=SfUZtBU/uxJv8o/If+kJpwUdceKoISQGLvKlW/D7r0EkhdOHDLJQ8Wxtox2gdlaxzs c98Dh5q9ewTrq+Udib1kGufoyseeEUPyRIMpRTT07pSCVFUvISIc7cAcvNXLb+6R4mNp Rja3htnjFWRe3TmMUMWbY/8ldzE3Ska1eOqibxFOIoRQqGcTq+jP+AJmOPIdC326s1jx OUsDbWeHklbN0RYbG/YM4yUzgcbCmyJkocyny0nYd5PP/nhcXBDR7UDC0NtFcb1sdPFD jZmMKO4jHHVJn+eyHHQLOs43D6s2Eqjcs1bXKZgnzhQMVfSC8W/7khMljOzn0YWWo3jN qVtQ== X-Gm-Message-State: AODbwcAm1esMmoF5JjT4L/q6HE+0vkvjoNPoHHAgKSlW9XWnEma+zklR kEPFxdqIqIYUq4NQnOQ= X-Received: by 10.46.32.230 with SMTP id g99mr2979042lji.38.1494318457034; Tue, 09 May 2017 01:27:37 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id o21sm3151108lfo.34.2017.05.09.01.27.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 01:27:36 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson Subject: [PATCH v3 1/5] mmc: core: Prevent processing SDIO IRQs when none is claimed Date: Tue, 9 May 2017 10:27:25 +0200 Message-Id: <1494318449-2591-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> References: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> In cases when MMC_CAP2_SDIO_IRQ_NOTHREAD is set, there is a minor window for when the mmc host could call sdio_run_irqs(), while in fact an SDIO func driver could have decided to released the SDIO IRQ via a call to sdio_release_irq(). In this scenario, processing of the SDIO IRQs are done even if there is none IRQ claimed, which is not what we want. To prevent this from happen, close the window by validating that at least one SDIO IRQs is claimed, before deciding to process them. Signed-off-by: Ulf Hansson Tested-by: Douglas Anderson Reviewed-by: Douglas Anderson --- drivers/mmc/core/sdio_irq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index 6d4b720..44d9c86 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -95,8 +95,10 @@ static int process_sdio_pending_irqs(struct mmc_host *host) void sdio_run_irqs(struct mmc_host *host) { mmc_claim_host(host); - host->sdio_irq_pending = true; - process_sdio_pending_irqs(host); + if (host->sdio_irqs) { + host->sdio_irq_pending = true; + process_sdio_pending_irqs(host); + } mmc_release_host(host); } EXPORT_SYMBOL_GPL(sdio_run_irqs); From patchwork Tue May 9 08:27:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 98884 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1708398qge; Tue, 9 May 2017 01:27:38 -0700 (PDT) X-Received: by 10.223.153.181 with SMTP id y50mr41687560wrb.41.1494318458459; Tue, 09 May 2017 01:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494318458; cv=none; d=google.com; s=arc-20160816; b=xcWYi2am/OSnqjHtsiDIVEbIga5m9ty3uXKqftB+p2subPD3v6eD2sAV9KQ7kNQXSo wykdAnzj4RttnaESK9Y68mUGtg0OBn4Y1L1/BjKwjHllLQ+AQSKM2ayY5rvCUUgNIJ+L dyLIzKwa9BgNv2HnLCp0yNcWwIEzfZRCSJihpuxTiVjDL/5pCWbtt1h+HmIwmGYbflnK o9xxpN/tf95Oll3CQlGMONiQnku9H/VXnYeAdELebCoKi/JbS2iJ8rg10LbuezoO6KBO fHJ9Y4Ua+Ny/5zuCfeNkuzq+zY+oLiCQoKF9wTLQDDcZqxfv875a/QCAZQa8bvwuS9G/ gEIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Y2wVdM/0OSvHBpF88xlr+DwnSL9iobLDisyXyd8fAqo=; b=wXykJekQ4u7QcnBzNj8u/KEDnZbKeYmyLM1bkiEa6FkC7quQ30sJpayu1XiZWljHhb U4aF9EruRxym5sMunS85cJLciDa+nDu3P9k7Uyx5+afOC8ov9T9C96JPJzXWMIN0c9Kq OrhlMJnZ52ioBdLFVbQ3JOAsnauADhZxCKBOAcxidAmdNClSVkPycwAfxvV+A+Nqtrx4 uTKq+Fd7nof2qUpon7UIhPvAUaeJAzODfogzd40h4B+0VD9KczI/3wE+zSd8hjwmJ4A9 aEmWCUykrrn+euZ0iA2iGfbqwQCTzIueIXMo2WARGr0QCn2VKKLPqa6hE3NBJh8LOPZQ ALsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::235 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-wr0-x235.google.com (mail-wr0-x235.google.com. [2a00:1450:400c:c0c::235]) by mx.google.com with ESMTPS id u31si17426590wrc.200.2017.05.09.01.27.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 01:27:38 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::235 as permitted sender) client-ip=2a00:1450:400c:c0c::235; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::235 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wr0-x235.google.com with SMTP id l50so63260792wrc.3 for ; Tue, 09 May 2017 01:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y2wVdM/0OSvHBpF88xlr+DwnSL9iobLDisyXyd8fAqo=; b=GeHfn/MXs/U1DbMVucN9GUUFSFxHkQnoTCs/T4x82iYbhYVjK0dX5pvOzi3wYSuUSH Yi0MykZtTOD+Ncln+b+neQ/atO1NnzAXiOWFtvsiQCDoSm9/BDxFAorsNIYFzlcjez/r UOQIDLF3bOvLiGAeTL552FYbmx+gTUURgsZIE= 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:in-reply-to :references; bh=Y2wVdM/0OSvHBpF88xlr+DwnSL9iobLDisyXyd8fAqo=; b=k65c1/rihEUOOSu2rLl0BHAAECDM68GS+ScfkSLzm2v1vAhwJ6IBWXPlKScEDuG3Lg CLmoy3vBscPWQL5gIjzZnRlesr9YfZqAFlXtepbPloDOEGmBqOP3dC1s4ILImiKTsdTJ SKjd9R5kfuh7RZNRjp0EwaO5nViKxYhGJyDZXg4d/AmQ6EANI8d0XXMtp+rVs/thyaPk xGKdLtGBximDwYtiW+UBuvJqzPL4OBwPeru3ueD4mgC77IcJo/Iv2E3nQoKF4g5wJpXU 3+UIDIgqIhlyoAatBt940mkoG8JHfiPjsXpZZOCzNkGH07amVV8GLTM2fhnTTjN/5kc1 3eZQ== X-Gm-Message-State: AODbwcAduR6EsOaDmIFdqw+EeBAE+9hIk28dyKWqX/BtAQoc38Xzlhc3 KL+HBLqDmuoiXSmrmko= X-Received: by 10.46.83.82 with SMTP id t18mr6046890ljd.70.1494318458014; Tue, 09 May 2017 01:27:38 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id o21sm3151108lfo.34.2017.05.09.01.27.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 01:27:37 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson Subject: [PATCH v3 2/5] mmc: sdio: Add API to manage SDIO IRQs from a workqueue Date: Tue, 9 May 2017 10:27:26 +0200 Message-Id: <1494318449-2591-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> References: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> For hosts not supporting MMC_CAP2_SDIO_IRQ_NOTHREAD but MMC_CAP_SDIO_IRQ, the SDIO IRQs are processed from a dedicated kernel thread. For these cases, the host calls mmc_signal_sdio_irq() from its ISR to signal a new SDIO IRQ. Signaling an SDIO IRQ makes the host's ->enable_sdio_irq() callback to be invoked to temporary disable the IRQs, before the kernel thread is woken up to process it. When processing of the IRQs are completed, they are re-enabled by the kernel thread, again via invoking the host's ->enable_sdio_irq(). The observation from this, is that the execution path is being unnecessary complex, as the host driver already knows that it needs to temporary disable the IRQs before signaling a new one. Moreover, replacing the kernel thread with a work/workqueue would not only greatly simplify the code, but also make it more robust. To address the above problems, let's continue to build upon the support for MMC_CAP2_SDIO_IRQ_NOTHREAD, as it already implements SDIO IRQs to be processed without using the clumsy kernel thread and without the ping-pong calls of the host's ->enable_sdio_irq() callback for each processed IRQ. Therefore, let's add new API sdio_signal_irq(), which enables hosts to signal/process SDIO IRQs by using a work/workqueue, rather than using the kernel thread. Add also a new host callback ->ack_sdio_irq(), which the work invokes when the SDIO IRQs have been processed. This informs the host about when it shall re-enable the SDIO IRQs. Potentially, we could re-use the existing ->enable_sdio_irq() callback instead of adding a new one, however it has turned out that it's more convenient for hosts to get this information via a separate callback. Hosts that wants to use this new method to signal/process SDIO IRQs, must enable MMC_CAP2_SDIO_IRQ_NOTHREAD and implement the ->ack_sdio_irq() callback. Signed-off-by: Ulf Hansson Tested-by: Douglas Anderson Reviewed-by: Douglas Anderson --- Changes in v3: - Switched to use system_wq, as system_freezable_wq doesn't work. - Use a delayed_work instead of a regular work. It's needed in next step when implementing SDIO IRQ polling. --- drivers/mmc/core/host.c | 2 ++ drivers/mmc/core/sdio_irq.c | 16 ++++++++++++++++ drivers/mmc/core/sdio_ops.h | 2 ++ include/linux/mmc/host.h | 3 +++ 4 files changed, 23 insertions(+) -- 2.7.4 diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 3f8c85d..8823c97 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -30,6 +30,7 @@ #include "host.h" #include "slot-gpio.h" #include "pwrseq.h" +#include "sdio_ops.h" #define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev) @@ -379,6 +380,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) spin_lock_init(&host->lock); init_waitqueue_head(&host->wq); INIT_DELAYED_WORK(&host->detect, mmc_rescan); + INIT_DELAYED_WORK(&host->sdio_irq_work, sdio_irq_work); setup_timer(&host->retune_timer, mmc_retune_timer, (unsigned long)host); /* diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index 44d9c86..c771843 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -98,11 +98,27 @@ void sdio_run_irqs(struct mmc_host *host) if (host->sdio_irqs) { host->sdio_irq_pending = true; process_sdio_pending_irqs(host); + if (host->ops->ack_sdio_irq) + host->ops->ack_sdio_irq(host); } mmc_release_host(host); } EXPORT_SYMBOL_GPL(sdio_run_irqs); +void sdio_irq_work(struct work_struct *work) +{ + struct mmc_host *host = + container_of(work, struct mmc_host, sdio_irq_work.work); + + sdio_run_irqs(host); +} + +void sdio_signal_irq(struct mmc_host *host) +{ + queue_delayed_work(system_wq, &host->sdio_irq_work, 0); +} +EXPORT_SYMBOL_GPL(sdio_signal_irq); + static int sdio_irq_thread(void *_host) { struct mmc_host *host = _host; diff --git a/drivers/mmc/core/sdio_ops.h b/drivers/mmc/core/sdio_ops.h index ee35cb4..96945ca 100644 --- a/drivers/mmc/core/sdio_ops.h +++ b/drivers/mmc/core/sdio_ops.h @@ -17,6 +17,7 @@ struct mmc_host; struct mmc_card; +struct work_struct; int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, @@ -25,6 +26,7 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz); int sdio_reset(struct mmc_host *host); unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz); +void sdio_irq_work(struct work_struct *work); static inline bool sdio_is_io_busy(u32 opcode, u32 arg) { diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 21385ac..f186b26 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -130,6 +130,7 @@ struct mmc_host_ops { int (*get_cd)(struct mmc_host *host); void (*enable_sdio_irq)(struct mmc_host *host, int enable); + void (*ack_sdio_irq)(struct mmc_host *host); /* optional callback for HC quirks */ void (*init_card)(struct mmc_host *host, struct mmc_card *card); @@ -358,6 +359,7 @@ struct mmc_host { unsigned int sdio_irqs; struct task_struct *sdio_irq_thread; + struct delayed_work sdio_irq_work; bool sdio_irq_pending; atomic_t sdio_irq_thread_abort; @@ -428,6 +430,7 @@ static inline void mmc_signal_sdio_irq(struct mmc_host *host) } void sdio_run_irqs(struct mmc_host *host); +void sdio_signal_irq(struct mmc_host *host); #ifdef CONFIG_REGULATOR int mmc_regulator_get_ocrmask(struct regulator *supply); From patchwork Tue May 9 08:27:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 98885 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1708406qge; Tue, 9 May 2017 01:27:39 -0700 (PDT) X-Received: by 10.223.162.158 with SMTP id s30mr40254873wra.34.1494318459795; Tue, 09 May 2017 01:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494318459; cv=none; d=google.com; s=arc-20160816; b=cWD320CGe6L+Mkt4p+xE2A+rIirAdPcLSF+Ddta4LToUJuKXUeNMHTYtpdnWFFJk36 RcTfuFBybIrnH2kQRcMKG4aD3/8kft9zbw839gDc+ht4qje+Tg9ozXzHNmOlv7ieEi19 w8jk3Zj0Q1tO/PgOu51LD2Rm1crAEyNKApa0KIRuVBRO4igCQ3VBd7fdJwyXN3C9wgkN 9WFapuvtaSpnLiEcU/WgoZ4Ax6iJsto3fOe7gFqyPdWU2GkJ7puBkYbNgR7wjz+VE+Tx O3QsrWz966vlJJcdiPYIYg37LXJWdyIX/d0xk5sSKNgJbi6z5MkMpOsrPEtx4ar7Yw89 CDog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=6w9WYksrBqpFRB8uJcO+DrIOPlpmn2f6WoNr7JF6Uuk=; b=O8w6WK+MWUNdoTWQIcQ07LFDXKNojH/kalDQCCfR3NhLs5Uvc144n7G+MzRoo0h4Yn xNpbMpCw8goJKYVxUkPx8dovHfmuESIRdDws1j85rTQ4zpTH0MhDCTAedR3Esk2m9gUT hvJVS5hyil1aMvr4M1uznQ1WEI5Io05jB8D06UJndAJ397xzFvVzxN/lO/7rNmbaoUW6 dZtaI+4WKUrP+kVE1CErFSsWtNwGU1wacJT+5ecFXVwn+Qy9ErDmJD5UkyjKfAMwo+n3 plQwh44khZSchUER/wzPDOdwDmEVbuLi6wrSSN/0rb2rpvZEDjQE877kGS17f7OzZIGA Np0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::235 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-wr0-x235.google.com (mail-wr0-x235.google.com. [2a00:1450:400c:c0c::235]) by mx.google.com with ESMTPS id z23si17599697wrz.204.2017.05.09.01.27.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 01:27:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::235 as permitted sender) client-ip=2a00:1450:400c:c0c::235; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::235 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wr0-x235.google.com with SMTP id z52so63314150wrc.2 for ; Tue, 09 May 2017 01:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6w9WYksrBqpFRB8uJcO+DrIOPlpmn2f6WoNr7JF6Uuk=; b=JlU3mrd+/AFCiSlve4mMW8v3u2vSiFdplmQw8PcZ1fr2w8SdAn22S43rTJMKjLj8U4 B+gzWwBNbkp46UtLI17PygS1TtOao8hfWEDmawzEF3S7sPgj62vxjErM+dmhlBQXYj/u QDXYCtKHyU4f/AmrvW3f09r2LUufemB4ce4Ng= 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:in-reply-to :references; bh=6w9WYksrBqpFRB8uJcO+DrIOPlpmn2f6WoNr7JF6Uuk=; b=oIJQ2d9DLWFT5FTiFbG5SA1vzJSwltzCOBX3d7fJhJRCImv2EgLdyPZIKoiG/DP7/G tc0Je4t2H+o2nAdbt8I3A1HwV7g59pynwq0Tv2eJnHUZoVDLgpl7a/fWZeN2DmAhZddr 75EoLHpG2zNntk8f7BDGZV/y7dzgjSZQvb5bJcfJcgr1eq1DuBVZC7itNEeFh4sDKEaX 2x58Hc1IhBFru7VLfIZVFMF07BnxcJDYJ/SCumagznhrmnWB4kjwzwL3ZfuahmJmVyxc 6QX4NZM34Wou3e7lxX1atRZAQSqJAKiGrZCDPwxMNcgWm+wdLVl8Pw4yuja+8ngrfuAH TUgg== X-Gm-Message-State: AODbwcC1HJ9ds5gCr6ZkWqf3k22Zi+3mW8+8Co8SjNVR7Hde3aQf4LOq 0sI4FUCVtiTaq5gROOs= X-Received: by 10.46.71.193 with SMTP id u184mr8272450lja.16.1494318459455; Tue, 09 May 2017 01:27:39 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id o21sm3151108lfo.34.2017.05.09.01.27.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 01:27:38 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson Subject: [PATCH v3 3/5] mmc: dw_mmc: Convert to use MMC_CAP2_SDIO_IRQ_NOTHREAD for SDIO IRQs Date: Tue, 9 May 2017 10:27:27 +0200 Message-Id: <1494318449-2591-4-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> References: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> Convert to use the more lightweight method for processing SDIO IRQs, which involves the following changes: - Enable MMC_CAP2_SDIO_IRQ_NOTHREAD when SDIO IRQ is supported and use sdio_signal_irq() instead of mmc_signal_sdio_irq(). - Mask the SDIO IRQ before signaling a new one to be processed. - Implement the ->ack_sdio_irq() callback to unmask the SDIO IRQ. Signed-off-by: Ulf Hansson Tested-by: Douglas Anderson Reviewed-by: Douglas Anderson --- drivers/mmc/host/dw_mmc.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index e45129f..635d76c 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1642,9 +1642,8 @@ static void dw_mci_init_card(struct mmc_host *mmc, struct mmc_card *card) } } -static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb) +static void __dw_mci_enable_sdio_irq(struct dw_mci_slot *slot, int enb) { - struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci *host = slot->host; unsigned long irqflags; u32 int_mask; @@ -1662,6 +1661,20 @@ static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb) spin_unlock_irqrestore(&host->irq_lock, irqflags); } +static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb) +{ + struct dw_mci_slot *slot = mmc_priv(mmc); + + __dw_mci_enable_sdio_irq(slot, enb); +} + +static void dw_mci_ack_sdio_irq(struct mmc_host *mmc) +{ + struct dw_mci_slot *slot = mmc_priv(mmc); + + __dw_mci_enable_sdio_irq(slot, 1); +} + static int dw_mci_execute_tuning(struct mmc_host *mmc, u32 opcode) { struct dw_mci_slot *slot = mmc_priv(mmc); @@ -1763,6 +1776,7 @@ static const struct mmc_host_ops dw_mci_ops = { .get_cd = dw_mci_get_cd, .hw_reset = dw_mci_hw_reset, .enable_sdio_irq = dw_mci_enable_sdio_irq, + .ack_sdio_irq = dw_mci_ack_sdio_irq, .execute_tuning = dw_mci_execute_tuning, .card_busy = dw_mci_card_busy, .start_signal_voltage_switch = dw_mci_switch_voltage, @@ -2654,7 +2668,8 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) if (pending & SDMMC_INT_SDIO(slot->sdio_id)) { mci_writel(host, RINTSTS, SDMMC_INT_SDIO(slot->sdio_id)); - mmc_signal_sdio_irq(slot->mmc); + __dw_mci_enable_sdio_irq(slot, 0); + sdio_signal_irq(slot->mmc); } } @@ -2755,6 +2770,10 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) if (ret) goto err_host_allocated; + /* Process SDIO IRQs through the sdio_irq_work. */ + if (mmc->caps & MMC_CAP_SDIO_IRQ) + mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD; + /* Useful defaults if platform data is unset. */ if (host->use_dma == TRANS_MODE_IDMAC) { mmc->max_segs = host->ring_size; From patchwork Tue May 9 08:27:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 98886 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1708412qge; Tue, 9 May 2017 01:27:41 -0700 (PDT) X-Received: by 10.223.146.225 with SMTP id 88mr42132875wrn.51.1494318461057; Tue, 09 May 2017 01:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494318461; cv=none; d=google.com; s=arc-20160816; b=p4rxihsx4Zk4/wD6wsqilvAtSpoH52RPYV03cEiHGGTDBIp995AGWsW4lhcV05msp/ HyU6MGJJP8B52Hl/xipHhe2XpqzUHOviCtilkgjqoTfsVAz2+NGMLsccKO6m+DE4BoO/ ywqsgxaBSGv0pjMhuJosn2fwHACLp2YYKuTYEaLDdo1Z60X0zI0lRIO0KhdKDNCDAFTW CzMb8xGxoZz8cu02g85BuU9y9m275+FzZbyTrLP1uVk7f4Vr4Vvjhp2Ls7VPHydUxjNe qhxA+pLc1VafLX8gSCZRkttTMS6GWVdr0jWRzqcKfM02oTxaIAsUAWzql7w0eslbr2ac Fqeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=430++NgDsfRLE2/2rRn0RsJBv5NaHP2iADbDyENosGQ=; b=tn8QvvYh+whGP0yLRh0DoxGcVFZP146UqPG0SpIjTH97p8l3qME/h3PpgD7bkmdyFP 5PiMr+/0t9Meqr1aeAVj0dGpGV6E0+MwP97eisN+tLWwADGsz/zmWhmxMOYomT1nxElj F0yL0DlPpZZdGRb98cLVhpo+2SvQrMeGCyDp1o2ywfdD8H3TlmOrzDNVBf+DjuKWWBRc ACeMHFpw9hJ2GzmptiojctSOjnYpRZImC/eF5Hey8CU/ndUCH85qS4he7Y2Uy+E/Nlbe gP0XMuMtgpwpbhcY2bc6Brliq9F/P6jmeb27T6cFtbd97vm6bUddXi4e1hZ+c6ryIUXY LoUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::230 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-wr0-x230.google.com (mail-wr0-x230.google.com. [2a00:1450:400c:c0c::230]) by mx.google.com with ESMTPS id j30si16919424wrb.275.2017.05.09.01.27.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 01:27:41 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::230 as permitted sender) client-ip=2a00:1450:400c:c0c::230; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::230 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wr0-x230.google.com with SMTP id l50so63261702wrc.3 for ; Tue, 09 May 2017 01:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=430++NgDsfRLE2/2rRn0RsJBv5NaHP2iADbDyENosGQ=; b=KwiUJ/Fr4udKHe1ugvmXJXoLvyZUNYXUZoRjyq7bGbsJxufTSif+yZERUgWr0ZrXT5 3Zpm5ViqNAJOhFenxbwDKlO1D+37Uepfm4ZOUSrSFuAufSY/+OgDhIVoxiB2l1Pd2yJV j2G4hf0Vl9DrTk1fbha05xKcTT4Ud9QX9i0ag= 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:in-reply-to :references; bh=430++NgDsfRLE2/2rRn0RsJBv5NaHP2iADbDyENosGQ=; b=GlzW4MLEkOJz2PREo06lNajTG+UbbD5WfG9wQIS54tzrcIo0kVMKn6IWOFYmy2h94u 6fAWmNqdT6BzEOu09bL/8SUwiA0594OZ3Ey88+u6XHKkydXxWr6KQtt6mSYMNDpOKno2 eClZfUjLxTAj5eOAa80e/T8KBXYjaCb0L50e3FnvvsDZG9IIzqdUc8Fp0tATg//TA3jp BVKn3Iqpc8WbRh5UIcTg1DijFewbKHL3KdqQWAAVDAKTgFEeJUZzAc6bCrtdqSa9FNvZ HhC4DeNJ1kR/MfhrNYvLz6lGyAe1t7kHSVcQv7xIGLFqpIwD7LXr5GXs802uBrLMiiDb x1+Q== X-Gm-Message-State: AODbwcD9vjU7SEr4nsj47XG+N8psIqVxkV6eWtCB1l2AbqB9trtcQo0w gO6OSyr7fL8nfpbbp24= X-Received: by 10.46.87.79 with SMTP id r15mr5762473ljd.4.1494318460682; Tue, 09 May 2017 01:27:40 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id o21sm3151108lfo.34.2017.05.09.01.27.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 01:27:40 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson Subject: [PATCH v3 4/5] mmc: dw_mmc: Prevent runtime PM suspend when SDIO IRQs are enabled Date: Tue, 9 May 2017 10:27:28 +0200 Message-Id: <1494318449-2591-5-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> References: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> To be able to handle SDIO IRQs the dw_mmc device needs to be powered and providing clock to the SDIO card. Therefore, we must not allow the device to be runtime PM suspended while SDIO IRQs are enabled. To fix this, let's increase the runtime PM usage count while the mmc core enables SDIO IRQs. Later when the mmc core tells dw_mmc to disable SDIO IRQs, we drop the usage count to again allow runtime PM suspend. This now becomes the default behaviour for dw_mmc. In cases where SDIO IRQs can be re-routed as GPIO wake-ups during runtime PM suspend, one could potentially allow runtime PM suspend. However, that will have to be addressed as a separate change on top of this one. Signed-off-by: Ulf Hansson Tested-by: Douglas Anderson Reviewed-by: Douglas Anderson --- Changes in v3: - Don't add include of pm_runtime.h as it's already there. --- drivers/mmc/host/dw_mmc.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.7.4 diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 635d76c..454b847 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1664,8 +1664,15 @@ static void __dw_mci_enable_sdio_irq(struct dw_mci_slot *slot, int enb) static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb) { struct dw_mci_slot *slot = mmc_priv(mmc); + struct dw_mci *host = slot->host; __dw_mci_enable_sdio_irq(slot, enb); + + /* Avoid runtime suspending the device when SDIO IRQ is enabled */ + if (enb) + pm_runtime_get_noresume(host->dev); + else + pm_runtime_put_noidle(host->dev); } static void dw_mci_ack_sdio_irq(struct mmc_host *mmc) From patchwork Tue May 9 08:27:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 98887 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1708418qge; Tue, 9 May 2017 01:27:42 -0700 (PDT) X-Received: by 10.28.234.221 with SMTP id g90mr208615wmi.103.1494318462178; Tue, 09 May 2017 01:27:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494318462; cv=none; d=google.com; s=arc-20160816; b=ypuwunYMoSIn9XMIX9IZvsdeyH6J4H6TrEIHB9JVF+vSSEmQbg0y0DNor8H/zM+foQ V5AGlySV1vF15IJA8XGS8aEni8/015Xoh1B1mDlmjxidQoBOvLMEInau8wyPPse8FZXY Q7WokoVX98QdEXjQ2px84K7bW0BYOcS1KXj7OR/Jah3IW+ujATqjX8hLPp/O0MvC1Ak4 +FGVF7/ZzOoaOx3rqDi73dH8WZAfoI/NQ8ju/rvkLdlXFid3eSQ4OGcyb9MgQZxuvk2k l3qxFj8aki5/BLp5YPDWNuB914uWVg/bGAGFs0DzVN4dkv8MHGKDCd7T+MEs5BzSScaM KGZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=/DWWEocq2Gobi94tFYveTkvcWrxTiLFEApPWvJAP64g=; b=Ndp7vKCU50LZU40Q2yMCqF058xmnDaBfQV+vZK+WEZfAwMw2dyZyWIs99CBLochq2q vG+/oZyhybs/qCE2F95fHLwXpVj6cj+rYRRVOGkg8TLTeHBLWrjm7oVgNupuRSqEjfIL /lENXs2hpd8fkk4tx61lIJgbXko54SJVW3cHHdMHg+n5Ce5r5Gyr80jp7HVTPKIvbW+n j9U6JkqzYEgVKxsroYhUQ5ANZ5ZPRgqVxY7j3ImhhtY90OWEtqsJUNmITdsMUGZ7kvBw qLOpIvhsicItHttlzquIUbz5kdmMcSyoE8P9beJyY85nO/BkXZEshudkPWEI28Q1GhQc Jb2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::236 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-wr0-x236.google.com (mail-wr0-x236.google.com. [2a00:1450:400c:c0c::236]) by mx.google.com with ESMTPS id v8si195817wmg.95.2017.05.09.01.27.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 01:27:42 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::236 as permitted sender) client-ip=2a00:1450:400c:c0c::236; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:400c:c0c::236 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-wr0-x236.google.com with SMTP id w50so63347048wrc.0 for ; Tue, 09 May 2017 01:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/DWWEocq2Gobi94tFYveTkvcWrxTiLFEApPWvJAP64g=; b=Hka0cJ5vbGhF2sQXmZT9Xd1kYQKiYS148+4lKIPTTwjYsneUyqkfvw+cjmB2obW+0y GYN6w29BSiZ6SOYOk3aKFLdZb9xxM3aE5MisbjEZzSLUX+MhpZ9kFmxXl00wPF0awR8k TXgQ1zY3B74a20HSvS2jQ0ou7p/Iu1tgWgWps= 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:in-reply-to :references; bh=/DWWEocq2Gobi94tFYveTkvcWrxTiLFEApPWvJAP64g=; b=KADhA19b9gixNVgRYbcwRboxwIbRjvdAXkMTNcTIQYbpR0QjcSImy1KA59EbzoF91a Is2mLDO4Wm8Ok7ZZe1sI0BYNCYqrOvQOjg8H8o1uUPantWAtjaz+0YQwS43vjqb7Drc3 Ilc5KWfu73cTJpKnhPpYoA+QdIFtOsUCTnpjRY14luSxKvz/2fMuKiVu5SlYVc+0lexu E+NctbhNqYe2LbmHrqJrmELWSf8uTaW7eAKSCJ03o6lqORSNb7QUn6A/KhHVmM51L3Zt 00Gi3d0vJ2gwrNgLmMoy0Oo1IBJHS/fiHwQwqggFmnI05JBJG9FoAPzZUSKtB7Kah3Qh blHw== X-Gm-Message-State: AODbwcCQnJyZcs7OGcgeLJL0a2Y+RQvL5tGbrVnZFvcqN7kVIXhIqDVT VNBsvDEZeQfgg5WX2oo= X-Received: by 10.46.14.9 with SMTP id 9mr8547201ljo.27.1494318461763; Tue, 09 May 2017 01:27:41 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id o21sm3151108lfo.34.2017.05.09.01.27.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 May 2017 01:27:41 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson Subject: [PATCH v3 5/5] Revert "mmc: dw_mmc: Don't allow Runtime PM for SDIO cards" Date: Tue, 9 May 2017 10:27:29 +0200 Message-Id: <1494318449-2591-6-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> References: <1494318449-2591-1-git-send-email-ulf.hansson@linaro.org> This reverts commit a6db2c86033b ("mmc: dw_mmc: Don't allow Runtime PM for SDIO cards")' As dw_mmc now is capable of preventing runtime PM suspend while SDIO IRQs are enabled, let's drop the less fine-grained method, which is preventing runtime PM suspend for all SDIO cards - no matter of whether SDIO IRQs are being enabled or not. In this way we don't keep the host runtime PM resumed, unless it's really needed, thus avoiding to waste power. Especially when SDIO IRQs is supported via a separate out-of-band IRQ line, which isn't defined by the SDIO standard, typically the SDIO func driver doesn't enable SDIO IRQs via sdio_claim_irq(). So, for these cases we can now allow the dwmmc device to be runtime PM suspended in-between requests. Signed-off-by: Ulf Hansson Tested-by: Douglas Anderson Reviewed-by: Douglas Anderson --- Changes in v3: - Don't remove include of pm_runtime.h as it's needed. --- drivers/mmc/host/dw_mmc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 454b847..0e2d6f7 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -1621,16 +1621,10 @@ static void dw_mci_init_card(struct mmc_host *mmc, struct mmc_card *card) if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) { - if (!test_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags)) { - pm_runtime_get_noresume(mmc->parent); - set_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); - } + set_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); clk_en_a = clk_en_a_old & ~clken_low_pwr; } else { - if (test_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags)) { - pm_runtime_put_noidle(mmc->parent); - clear_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); - } + clear_bit(DW_MMC_CARD_NO_LOW_PWR, &slot->flags); clk_en_a = clk_en_a_old | clken_low_pwr; }