From patchwork Sun Sep 8 10:12:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 173340 Delivered-To: patches@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp3003051ilq; Sun, 8 Sep 2019 03:12:48 -0700 (PDT) X-Received: by 2002:ac2:5971:: with SMTP id h17mr9675318lfp.16.1567937568721; Sun, 08 Sep 2019 03:12:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567937568; cv=none; d=google.com; s=arc-20160816; b=RaC+RsUHCihOEv38G9AGzinrojYiQCDlCO2U94mFBXCYksWHHYKRmZKwBD/9CAnViu siQ48i3zN/LjEdsvQpa4wx5Z3OA+8cc5ptTgtkH8CcE0yEfKORmj3guQhKteYHjxhY8B 03uGr05X7hGdl7Ff+X3GWaNDiwehoSiQ9OpK1eLhllDq5PhcYX8teVv0hjf2uQK0fds2 Dfgvz+mD8z7AnlzrgnkildkAqsHlyR8+QbUi/5sfg4R3PUpDdtKjLwpP18z/3kmI39Yq 9ZcWpfI48gw0ATj/jLzpvdbPYenvjPRImuglonaFBhSmQaoMLAOEZhX6lOnTzBvwHn0K Tp9w== 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=pKTLA8BPyKLX9YHHuPwtPhpXH4h+0Jxv8uz/z0H2wn8=; b=pFtVg2vfiNxK4OVMlLpzm+T+RhVup0+UwkDj0ialG1l1Bxfn+hN82Un6SIqNSsViQR 6LNKh0y/tculbphpobPcWSb1/s6D+7KLH0JdEss+LbXpUf4Mn6TpWPkSk/48xmu2hfaa joIw+/ZkR9Hq4jO2YWpiLYoV1bNuTPrb3zNC6CJkSR6uMKq30wIIB63dp/hETBJSyj6w f0g2Ug4YZkQruvhJ+tX2xrr4avmebsRCQgtOha6Z4Rgm52D6KrYWG8GZu46sI1J8x9hH CfWgoWd8ac81eO5cqJEOVHnFFkqAStr1WgpeP2ceY+sxAocP9kDLHsBGKh39Yc+3ZXFK 8J2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IQz6usR0; 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 w21sor5604438ljg.10.2019.09.08.03.12.48 for (Google Transport Security); Sun, 08 Sep 2019 03:12:48 -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=IQz6usR0; 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=pKTLA8BPyKLX9YHHuPwtPhpXH4h+0Jxv8uz/z0H2wn8=; b=IQz6usR0dVKguJznE5uwgQrDgBPq+1KDURHrwgj3B68bVWnvG2HpejbwXV9o6x03hg pyD2rFKEQDWaN6d7CyUM3W+CVs5ggKUaha1XE9GRYfAOzqxXfMBEVIZm8lk/DrYuUQnn K7l1WXgCWy6jJdGeZBSzs/1QfBLwMWj2atFZx/+W7lS9Xvdzrn5uMXDX9WHecRub2lvS ELZw9+sZ4PTrhnXh7MyZKGtpHyHieSHzeOS0SepU5vOln6djN8SVpBgfE7uFQUFvv2TD fr88VUn+pZjfn552rf6/wS00NR7kdexqpXWiL3uAZQcwUfAW5HmaY+1p0i6F2nBnxLPS RQeA== 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=pKTLA8BPyKLX9YHHuPwtPhpXH4h+0Jxv8uz/z0H2wn8=; b=cD/t1Nag28QhOZvSqwG/1V87ttWMSR4utDvYlH0mP4DGDQqF/ynnbs2R26vptXeZPi mnp2ar+Z6d73FK+xpsIWBtJZS+B9THb+7znK+k4Lf8s6JFdIqYVvE/JMMEyrrpSYgBZF huGEbAGXVjQ7TDWrHZjZtYA4VbimK7HMPRsMZag+c62aWESve/SGz+oBnSRFX2C/7Zew NXARwPq2Ht4dbZbCO/qjPuZhnBzjlFOBWZHUJYDuBn6YaoWyc8TtATvg4h6VNmcrDult ze9725djZ6SBaTE3LXsKTQSVFzKdaAwnq2JZ7HbNpx3STu7npGrHQfu9ASq5RENxdH6E Ar8g== X-Gm-Message-State: APjAAAXNFfCD2hf7+RPEWToCYPu9NE6tQvGDZC30+mos+TeeZSUWCDOX FSOsVf4T3Uhk0tbsSagSCiMnwzkH X-Google-Smtp-Source: APXvYqzIBrVCzTFMAkkD8zaEddXTkXDJL2QuHMc/BkCaUp14332Xlp3p1Xir6bNKkkBPWLadqtU6RA== X-Received: by 2002:a2e:958c:: with SMTP id w12mr11761091ljh.98.1567937568383; Sun, 08 Sep 2019 03:12:48 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([185.122.190.73]) by smtp.gmail.com with ESMTPSA id h25sm2444849lfj.81.2019.09.08.03.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2019 03:12:47 -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 v2 05/11] mmc: core: Clarify sdio_irq_pending flag for MMC_CAP2_SDIO_IRQ_NOTHREAD Date: Sun, 8 Sep 2019 12:12:30 +0200 Message-Id: <20190908101236.2802-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190908101236.2802-1-ulf.hansson@linaro.org> References: <20190908101236.2802-1-ulf.hansson@linaro.org> 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 --- Changes in v2: - Re-wrote changelog. --- drivers/mmc/core/sdio_irq.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index f75043266984..0962a4357d54 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -59,6 +59,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; @@ -66,13 +67,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; } @@ -110,7 +114,6 @@ static 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); @@ -128,6 +131,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); @@ -173,7 +177,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); /*