From patchwork Thu Oct 3 15:53:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 175186 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp629750ill; Thu, 3 Oct 2019 10:28:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqylILGoIXR/QNM6kWuwaAbxApSXtetztXfvIS3Vv8I52zIQviUgdqRofEc6qjA+VykDbT0B X-Received: by 2002:a17:906:fc20:: with SMTP id ov32mr8802201ejb.22.1570123717356; Thu, 03 Oct 2019 10:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570123717; cv=none; d=google.com; s=arc-20160816; b=aGlzPQ7GFOkdLNZ5lmIpLtAYKn35tIyb63DF1FOCWpRPROHQ2nZBLu6X4lKoPJAGuA 94ebXQQtzvJOdGBpsBizeIgfXx9mPCKwfJzA+MJC3nduCY1y37XS5Q/GWUeRm7NQ6AP4 GQ9XAHsG7jIv9EnBSNuMGJYor6dwGI6Xt4k6VIvQO/4tLEN831H56zRiuiGitBaCTwcZ VE9AgZ49ZlbPcgj5A7iVj0NvH2wjxjX2WNpY5k4PAkXOv2TClnem+uftNFtSs0A26cE9 bJPwdL8SUVS+13IVEIGCFez91W2JQeSsMrfGTk3dCS8E0fHRXzTKl/I0VEC9bA4GnKIe SGkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fQkp+GufTqoL68pzMZR1rVC6RW/pkFpOkKEmWUpgoGQ=; b=K1Om0CE9YVTOjF+Dn4t3bquLnGIIEPcuOFOaXfAOcXxpJWRb6+vnUJwqKplWamSw9w r/0isawikxCyFWI+eXzWZ/2LD6TW5hr2zgv7K3Fj0KmqGnWv/63RppVfz+4T66jn+TGD jC43vlG9++3ulOSjAEPnp+rTOHjSqxBqITUu5jABpqga9EekQEn2Wdi3yKm+5O4PkSAH Lz/tBOb/sVOJVz+XpePiX5yZHXZa4y9+wzIKaTo5mr0hqLnBGIjLT2AKr691BfebknTO VlfoExs5oDlowE2gV7dbnf03H0h9umco295OnG07ue+YmMq+w+6EqwZS0jtS4V6JVycn A2EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0d+JYRCX; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f35si1943365eda.415.2019.10.03.10.28.37; Thu, 03 Oct 2019 10:28:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0d+JYRCX; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729278AbfJCR2g (ORCPT + 14 others); Thu, 3 Oct 2019 13:28:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:36298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388354AbfJCQNd (ORCPT ); Thu, 3 Oct 2019 12:13:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 772282054F; Thu, 3 Oct 2019 16:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119212; bh=6b5jTT1uSMagUS3nV3QpOU2+HHivB8utPxBdWmXGx7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0d+JYRCXYZ4iy8loQGGfwM+x6Xu+Oqi+gY6rB1lzyrD7ERw0oQvfpgnaWupNo6r98 Lv8+MlWjgt9ME2FI8K7L8cnnYK/Q8aUESCz5aee/qsPtskmqFwJ4lfV6Trikx+sLOi s8AChB52Hl6B7loqgZGV5Jec8S3YYDqenrc0A5h0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthias Kaehlcke , Ulf Hansson , Douglas Anderson , Sasha Levin Subject: [PATCH 4.14 128/185] mmc: core: Clarify sdio_irq_pending flag for MMC_CAP2_SDIO_IRQ_NOTHREAD Date: Thu, 3 Oct 2019 17:53:26 +0200 Message-Id: <20191003154506.607376909@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154437.541662648@linuxfoundation.org> References: <20191003154437.541662648@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Ulf Hansson [ Upstream commit 36d57efb4af534dd6b442ea0b9a04aa6dfa37abe ] The sdio_irq_pending flag is used to let host drivers indicate that it has signaled an IRQ. If that is the case and we only have a single SDIO func that have claimed an SDIO IRQ, our assumption is that we can avoid reading the SDIO_CCCR_INTx register and just call the SDIO func irq handler immediately. This makes sense, but the flag is set/cleared in a somewhat messy order, let's fix that up according to below. First, the flag is currently set in sdio_run_irqs(), which is executed as a work that was scheduled from sdio_signal_irq(). To make it more implicit that the host have signaled an IRQ, let's instead immediately set the flag in sdio_signal_irq(). This also makes the behavior consistent with host drivers that uses the legacy, mmc_signal_sdio_irq() API. This have no functional impact, because we don't expect host drivers to call sdio_signal_irq() until after the work (sdio_run_irqs()) have been executed anyways. Second, currently we never clears the flag when using the sdio_run_irqs() work, but only when using the sdio_irq_thread(). Let make the behavior consistent, by moving the flag to be cleared inside the common process_sdio_pending_irqs() function. Additionally, tweak the behavior of the flag slightly, by avoiding to clear it unless we processed the SDIO IRQ. The purpose with this at this point, is to keep the information about whether there have been an SDIO IRQ signaled by the host, so at system resume we can decide to process it without reading the SDIO_CCCR_INTx register. Tested-by: Matthias Kaehlcke Reviewed-by: Matthias Kaehlcke Signed-off-by: Ulf Hansson Reviewed-by: Douglas Anderson Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/core/sdio_irq.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index 2fdd84c67f191..0656d740b0dd2 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -35,6 +35,7 @@ static int process_sdio_pending_irqs(struct mmc_host *host) { struct mmc_card *card = host->card; int i, ret, count; + bool sdio_irq_pending = host->sdio_irq_pending; unsigned char pending; struct sdio_func *func; @@ -42,13 +43,16 @@ static int process_sdio_pending_irqs(struct mmc_host *host) if (mmc_card_suspended(card)) return 0; + /* Clear the flag to indicate that we have processed the IRQ. */ + host->sdio_irq_pending = false; + /* * Optimization, if there is only 1 function interrupt registered * and we know an IRQ was signaled then call irq handler directly. * Otherwise do the full probe. */ func = card->sdio_single_irq; - if (func && host->sdio_irq_pending) { + if (func && sdio_irq_pending) { func->irq_handler(func); return 1; } @@ -100,7 +104,6 @@ void sdio_run_irqs(struct mmc_host *host) { mmc_claim_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); @@ -119,6 +122,7 @@ void sdio_irq_work(struct work_struct *work) void sdio_signal_irq(struct mmc_host *host) { + host->sdio_irq_pending = true; queue_delayed_work(system_wq, &host->sdio_irq_work, 0); } EXPORT_SYMBOL_GPL(sdio_signal_irq); @@ -163,7 +167,6 @@ static int sdio_irq_thread(void *_host) if (ret) break; ret = process_sdio_pending_irqs(host); - host->sdio_irq_pending = false; mmc_release_host(host); /*