From patchwork Tue Sep 3 14:22:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 172801 Delivered-To: patches@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp5641515ocp; Tue, 3 Sep 2019 07:22:44 -0700 (PDT) X-Received: by 2002:a2e:9958:: with SMTP id r24mr8375166ljj.139.1567520564386; Tue, 03 Sep 2019 07:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567520564; cv=none; d=google.com; s=arc-20160816; b=rkRiwZwR6ICv9l6U7l62aydga5ENH21V3zNA9m8RVUzvpWg8wl/00+hELrxlJaZaN3 oQQnhSGfumnRkKMxSerwe24acIlup2hrcQiq5dU9NmnTGep4s/Icrcj91R7zxuhSWCIt 0VcpKC7HGdK5Y/KeL/+iK4GIertkYOTi5Zjbnu4CnuglhXUlzXofhWmkFDyqm7m9uDAe o7ipRfiqq65OqmJvQQnXDdaaaVO23bewY6jSfAcKKRz2sWaA0X4UqEf1OkwTdLnM21uA gkE5mW8Lk6FT7uERTc/K2aPasNkcbAvthuZRanzt5qLSXGPRqKjmWeKhkC0HYUyctRqa 1hJw== 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; bh=Fqo5mVILkGtSq0rdVWivMfGJMV/aCWEQdU0YePivD14=; b=fs20qk0j4TY7FiArm3gU2qQAPqV1UPcrqDIRZsAWS+Ng5Yh1Og3VKaVTQK2S2swYDq NUAmz/Lle3fvJvcDAm2oHBFLAEimmFk4ZM4ZLtGmIX3JKeIfHSfeFrxCsy/1gOLJddOp 6ez+cAD5mUJhX7mxcF1Fj/+R3M1FaPhyzVaDFzs9mbqBauO+r1po0vcjzh3rLAWJu/7Q hFLMt1+xmpI907Zazw/GgZFidbtf50GbTS46Odoe1T6nlFq+ZXS0gN11njwu90MPgFZu x4krsonsH4Cj9VENQmTcobRHvG210E0JTl4o8bvXAQwqoNH7+PI/xhxUo/LQJX2z9UVO xVzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tRNkWdgI; 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 v67sor4923494lfa.14.2019.09.03.07.22.44 for (Google Transport Security); Tue, 03 Sep 2019 07:22:44 -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=tRNkWdgI; 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:in-reply-to:references; bh=Fqo5mVILkGtSq0rdVWivMfGJMV/aCWEQdU0YePivD14=; b=tRNkWdgIeGlIeHF31vEECt46I4epYMs40YdMzeIjjLXwGWZIOSybZkB58seaPdpX8t sK4/S6ZL8nQNC+J05IX8ZtuSmXyvtt4moyYsM6VWqgOFZ1xR35BzuIqvZ7vjDpWCs5xp PIAQST0jb5AsjNJQATqgg23HbTVCPPPvTseizJwniLgedXlUXZ7/GNmioOl27/gpuJiI RC9FHbBTq3rVTg6D0l9Dy5+FCNvqJcO/ak28h5+VWbDCHYUCbke2VEaZtBxPufmI7Xi8 49v5d80bi3w3XilNwMLbgLiM+D5CqG1T8vuyDsdzb8zxrZLyM6IeLXKFzsEYf7MOP3hL z2OA== 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=Fqo5mVILkGtSq0rdVWivMfGJMV/aCWEQdU0YePivD14=; b=VmiFqyFJES+Z6EVgEMkK95aBtrZJGLXNc6BsXeedeToWKe/7gA5oaJ1Ljso1aK7NdH QJEfuO03Cbt4fYwbNlM4ZbK1B/yUM+8c7UG3cjlU5WHDXLNbikRKyYKUTLvpWy3HIVTN QAma0hfXaUmLe9KxWJodHfqyIqMt0YIZxmtyK2Y7OYH/9taL+Qe29vYgc2afZLtHgE4Q mCelFtlDd9XA1DDHcLdZWvjxG7J/PZMRmLAxGiCr1C5MK5er1b4Y1mDb0h98e/7npFRe H++36Goi6z2ZJdnQ5WdoXsbKJ7kNFfGKDLPQn6R65Bc8nPJRRGlF2LRVEImBbD9zRuKd wCjQ== X-Gm-Message-State: APjAAAUTNGukL986NT/QylVCse42Lo2BU7XKCeOZEXMZloGh28hA8x7H xT51cSdHuI2MithkJwrGMoEA6HHl X-Google-Smtp-Source: APXvYqzhx0C8QVyDdtmnXTBzvrkQ/qix4A9PLncU3OxOKzlPKzY1ZMxbBJXHsY8c8skjXFT0ebn0Iw== X-Received: by 2002:a19:f204:: with SMTP id q4mr6969539lfh.29.1567520564028; Tue, 03 Sep 2019 07:22:44 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id v10sm2430862ljc.64.2019.09.03.07.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 07:22:43 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH 08/11] mmc: core: Fixup processing of SDIO IRQs during system suspend/resume Date: Tue, 3 Sep 2019 16:22:04 +0200 Message-Id: <20190903142207.5825-9-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903142207.5825-1-ulf.hansson@linaro.org> References: <20190903142207.5825-1-ulf.hansson@linaro.org> System suspend/resume of SDIO cards, with SDIO IRQs enabled and when using MMC_CAP2_SDIO_IRQ_NOTHREAD is unfortunate still suffering from a fragile behaviour. Some problems have been taken care of so far, but more issues remains. For example, calling the ->ack_sdio_irq() callback to let host drivers re-enable the SDIO IRQs is a bad idea, unless the IRQ have been consumed, which may not be the case during system suspend/resume. This may lead to that a host driver re-signals the same SDIO IRQ over and over again, causing a storm of IRQs and gives a ping-pong effect towards the sdio_irq_work(). Moreover, calling the ->enable_sdio_irq() callback at system resume to re-enable already enabled SDIO IRQs for the host, causes the runtime PM count for some host drivers to become in-balanced. This then leads to the host to remain runtime resumed, no matter if it's needed or not. To fix these problems, let's check if process_sdio_pending_irqs() actually consumed the SDIO IRQ, before we continue to ack the IRQ by invoking the ->ack_sdio_irq() callback. Additionally, there should be no need to re-enable SDIO IRQs as the host driver already knows if they were enabled at system suspend, thus also whether it needs to re-enable them at system resume. For this reason, drop the call to ->enable_sdio_irq() during system resume. In regards to these changes there is yet another issue, which is when there is an SDIO IRQ being signaled by the host driver, but after the SDIO card has been system suspended. Currently these IRQs are just thrown away, while we should at least make sure to try to consume them when the SDIO card has been system resumed. Fix this by calling sdio_signal_irq() after system resumed the SDIO card. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio.c | 2 +- drivers/mmc/core/sdio_irq.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Matthias Kaehlcke diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index c557f1519b77..3114d496495a 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -1015,7 +1015,7 @@ static int mmc_sdio_resume(struct mmc_host *host) if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD)) wake_up_process(host->sdio_irq_thread); else if (host->caps & MMC_CAP_SDIO_IRQ) - host->ops->enable_sdio_irq(host, 1); + sdio_signal_irq(host); } out: diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index d7965b53a6d2..900871073bd7 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -115,7 +115,8 @@ static void sdio_run_irqs(struct mmc_host *host) mmc_claim_host(host); if (host->sdio_irqs) { process_sdio_pending_irqs(host); - host->ops->ack_sdio_irq(host); + if (!host->sdio_irq_pending) + host->ops->ack_sdio_irq(host); } mmc_release_host(host); }