From patchwork Mon Nov 11 07:33:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 179057 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6294176ilf; Sun, 10 Nov 2019 23:35:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxiBa3VUCdUTOaS7SLSqFTZM3dyraiWE//jgvjFA+xgV0/vHc68wKUVCQxaYlNbFplW52f9 X-Received: by 2002:aa7:d4d8:: with SMTP id t24mr24869915edr.40.1573457726355; Sun, 10 Nov 2019 23:35:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573457726; cv=none; d=google.com; s=arc-20160816; b=bxgozZE5hJ0Lj/zAm3t8iFYYzwJNLysLBgm/lKSolCAu1cW+M7xjjjyq5VnN9JFISV /4RlarwXhc9pkl9m2yk+uCQYdjkS1pCy+8bfknW2a0NqRZEyv1YYEXz72nfH2migbpW5 nXxC8YHqbFsfP9EGzgT02Gg7DcC0usyAgvlGi00LfjNtYtNkbX1KcVasGmUp/ERDILrY KM7PPjedk+45byLDqR0Epc+HBDM+xXXGsHvcsucBZvRvP50XzzXCgecxTGG+Rmn8JqXV mB6YHhB3A1kwe84OTOq4bmNdykW6ILg6xmOAzA6qjeYTt/103dTxTAlHxiyDzwG/8csV qqcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=shSJXxHkqiOnwVznDt/3eHxUBXqubG/+hrNMGFN/+WI=; b=k4RmE9BLbZFz99mP1JdCv3JUZNAq3o1lNgS9R0wlW82o7VclcaYo1VniVG66WnJi7J O2dY65BpHKOz005G3aORKvIaXIk+6R6mVyn5yqJ+dRE4NJa3Tw9F0itPzmNXf4pEMqeX 80BJc2YGBau0EqIEn4jM4NgmpLK9Ki2Crpxer5zJKRQid3kpTMCY4qt3n4nMYYhAlHLB n0caXSJBziECmEidGDAWr2gRASEo0yPLbjafMH2E0/kmVHM824/QeZYizeB+ap1fifMD FoOwx6CQtlkbO0Wd2+VXDhiOc5CtTO+uC03PY90yOsHEi7iHKQ8b29cgbdXB+v4LV6M/ FHSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s0ExBf69; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si9369704ejt.61.2019.11.10.23.35.26; Sun, 10 Nov 2019 23:35:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-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=@linaro.org header.s=google header.b=s0ExBf69; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727028AbfKKHfZ (ORCPT + 5 others); Mon, 11 Nov 2019 02:35:25 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43714 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727023AbfKKHfZ (ORCPT ); Mon, 11 Nov 2019 02:35:25 -0500 Received: by mail-pg1-f193.google.com with SMTP id l24so8906044pgh.10 for ; Sun, 10 Nov 2019 23:35:23 -0800 (PST) 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 :in-reply-to:references; bh=shSJXxHkqiOnwVznDt/3eHxUBXqubG/+hrNMGFN/+WI=; b=s0ExBf69BmmTL8g8enNiPwaRmpBMFWW+q7MngojPegddgeqfh2kgXDFE2hDQ8T2JyG ggi+0b0rIR/nNwAiYSw6V/WvnJpfITQzXqiNJtBp/wqHduWt3VLLhzVBSTM7p3KZGs/N ex5F/9AKeJcvhao21rlQ8yVLzgJ39s90ruG/NY28kqG1I7UI6aH93dX1eOX1ccF2Q4Vn o5XOb0liCGl/CZxAlUiwyHaXC8NQIbKk6gejnCc99hzVFILoZbA5kX/i4b7wkD1KtBlX ZLogjfb2lQyl5XmpZDRB2UH0VrmWkiV57kI1rh/oVYq1IEScxehvEKBlH4vAu3VE9hGk BWAA== 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:in-reply-to:references; bh=shSJXxHkqiOnwVznDt/3eHxUBXqubG/+hrNMGFN/+WI=; b=ZU2WS+lM14hvSUWVKXRvcvmf35rL16wEL355U/w1rwjvtSmB+B4OKafcZJf1tZyFcG 6zhKAKzqVq7LkXOuLdjzCAogY+stBN5xIGm7GPWq7E148BIoS2ROdwZIBMnYd+3qIzL+ JSKOqSd4YDK/mE2q2bnfPhPHxufF/2k/PHsyXgq+hiJhEY0C3SR6zpN9Y8mQRgMKxGCt KMInzwlDFNfUfyPYq6ZA+aJ+1mj/CbYQ3TR2Lu0bnU4TiH1iBPdEqWFWwp6esnJdWoj8 qZWKy7TDRLyjFk2hkaCin23XKUvfjXVY1BFyN92C6CYlgJqwBgpFsOV0haN+uwSDp2TN 9lUw== X-Gm-Message-State: APjAAAUv509tZbD0ZfF8ojOT3UdrjfaaiSJ+aww6d9piPK6lq/6jdZEP l9hmsgSv+7H505ixRCPXe4iLKA== X-Received: by 2002:a62:ea1a:: with SMTP id t26mr5386170pfh.14.1573457722961; Sun, 10 Nov 2019 23:35:22 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id c184sm17345285pfc.159.2019.11.10.23.35.18 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 Nov 2019 23:35:22 -0800 (PST) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, asutoshd@codeaurora.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, arnd@arndb.de, linus.walleij@linaro.org, vincent.guittot@linaro.org, baolin.wang@linaro.org, baolin.wang7@gmail.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 3/4] mmc: host: sdhci-sprd: Add software queue support Date: Mon, 11 Nov 2019 15:33:59 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Add software queue support to improve the performance. Signed-off-by: Baolin Wang --- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-sprd.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) -- 1.7.9.5 diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index efa4019..54b86f6 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -632,6 +632,7 @@ config MMC_SDHCI_SPRD depends on ARCH_SPRD depends on MMC_SDHCI_PLTFM select MMC_SDHCI_IO_ACCESSORS + select MMC_HSQ help This selects the SDIO Host Controller in Spreadtrum SoCs, this driver supports R11(IP version: R11P0). diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index d07b979..3cc1277 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -19,6 +19,7 @@ #include #include "sdhci-pltfm.h" +#include "mmc_hsq.h" /* SDHCI_ARGUMENT2 register high 16bit */ #define SDHCI_SPRD_ARG2_STUFF GENMASK(31, 16) @@ -379,6 +380,16 @@ static unsigned int sdhci_sprd_get_ro(struct sdhci_host *host) return 0; } +static void sdhci_sprd_request_done(struct sdhci_host *host, + struct mmc_request *mrq) +{ + /* Validate if the request was from software queue firstly. */ + if (mmc_hsq_finalize_request(host->mmc, mrq)) + return; + + mmc_request_done(host->mmc, mrq); +} + static struct sdhci_ops sdhci_sprd_ops = { .read_l = sdhci_sprd_readl, .write_l = sdhci_sprd_writel, @@ -392,6 +403,7 @@ static unsigned int sdhci_sprd_get_ro(struct sdhci_host *host) .hw_reset = sdhci_sprd_hw_reset, .get_max_timeout_count = sdhci_sprd_get_max_timeout_count, .get_ro = sdhci_sprd_get_ro, + .request_done = sdhci_sprd_request_done, }; static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) @@ -521,6 +533,7 @@ static int sdhci_sprd_probe(struct platform_device *pdev) { struct sdhci_host *host; struct sdhci_sprd_host *sprd_host; + struct mmc_hsq *hsq; struct clk *clk; int ret = 0; @@ -631,6 +644,16 @@ static int sdhci_sprd_probe(struct platform_device *pdev) sprd_host->flags = host->flags; + hsq = devm_kzalloc(&pdev->dev, sizeof(*hsq), GFP_KERNEL); + if (!hsq) { + ret = -ENOMEM; + goto err_cleanup_host; + } + + ret = mmc_hsq_init(hsq, host->mmc); + if (ret) + goto err_cleanup_host; + ret = __sdhci_add_host(host); if (ret) goto err_cleanup_host; @@ -689,6 +712,7 @@ static int sdhci_sprd_runtime_suspend(struct device *dev) struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); + mmc_hsq_suspend(host->mmc); sdhci_runtime_suspend_host(host); clk_disable_unprepare(sprd_host->clk_sdio); @@ -717,6 +741,8 @@ static int sdhci_sprd_runtime_resume(struct device *dev) goto clk_disable; sdhci_runtime_resume_host(host, 1); + mmc_hsq_resume(host->mmc); + return 0; clk_disable: From patchwork Mon Nov 11 07:34:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 179058 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp6294227ilf; Sun, 10 Nov 2019 23:35:29 -0800 (PST) X-Google-Smtp-Source: APXvYqym4gjuwFqK6qIo5iwrueiAPlYyI6/waFRJIL2XXxFuQjStISbVpfijrJRYTSX0W/cbI+z8 X-Received: by 2002:a50:9850:: with SMTP id h16mr25388432edb.193.1573457729011; Sun, 10 Nov 2019 23:35:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573457729; cv=none; d=google.com; s=arc-20160816; b=DU9gBHeQ4aWo7jkn8VlgSLwUvZONJ/nzImbumC+WMq1HTW8Wv4SoT65R7P7Imvx1FS sLq18AW1rISOXrOv9cv2jfiujqFUH5WfQv3DFXjx4eO+xaUvkf0FyXCLtLalUe7FfLTl nxv9KFTJlLs4CY9p7LijXoSsC8R7RL4xGmhlFW9hd40RBgSEksmepSMPRXnhIQbQGsd8 Uw0IrsPqXuJ50ZCfzGTiiqUsxcg2BRoUVu+ygWWe9BJfIDX+UIiCZrXIRYAWlSEDv7t/ c6H5XNv1O6YyS1oC90ZvCvgQpRPVKFKA3fo1Rzhrnaopga1rqSIXqUKcoWIIoq2Ju6J3 WOrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=i6cJtP2GLYXrWSbffAAlWqbiBaFJmvg9QhFIx0JCR4w=; b=r8zlgARfBtOqnXsp7rI25rRo4MNYwpKP+hnOuHHX1xoMGio+LKzRGPmPOEPN/R24E8 kv2VBuJkDldax/cEeyjxJ3m/dBbRnh3fasgq5nwhKGXH3XM68Q0QdxNJMBZ6URklMrIJ 4VN0fNRqlcH6lewNfEIT3YtLBU/tiTEOYPAi9ExQ3vL7ZgSq7pC5tH+5jkk673srtEWO VzCOItukxXCF11xNK9EVXHT9Jjmn4JgTgxR3R3euVsSatu11iPQHcIAQjmVA84KQgEZP N4QpGJ+32vzyXnw1g6Jh442QcAfygFl2V1+iO1HOcqoTY/84u2/F7tzhzsDGQ4MsJT7v hgUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fDhq0K+/"; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si9369704ejt.61.2019.11.10.23.35.28; Sun, 10 Nov 2019 23:35:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-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=@linaro.org header.s=google header.b="fDhq0K+/"; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727023AbfKKHf2 (ORCPT + 5 others); Mon, 11 Nov 2019 02:35:28 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44035 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbfKKHf1 (ORCPT ); Mon, 11 Nov 2019 02:35:27 -0500 Received: by mail-pf1-f193.google.com with SMTP id q26so10073748pfn.11 for ; Sun, 10 Nov 2019 23:35:27 -0800 (PST) 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 :in-reply-to:references; bh=i6cJtP2GLYXrWSbffAAlWqbiBaFJmvg9QhFIx0JCR4w=; b=fDhq0K+/Rn0iuKKs10LO1snJBg6va0XLJdJa4Bz/h7Q5iuKxXTGigB77w3v0ezUGv7 wN9k5uqyPodAtGkyVOPY1YOlstq2rqxsBmFs+7tsqE/tF95NyFrwW0NiWsFmcMGxuSN6 7Xb7zSaRRZhZylx+27eHpbgWmeIuJJnbcxODRj7yqS8s6p6QeUUvcHiAsWaB9fQQviHo Hr4Xjv7NOWumj6n+AstBAJWIR3KJv8kWTHv8S9I8HlkSk1pAQnxR46/Cf6MoevHFfc+F 3B1CnqUYgyBVz60ZWMH/yaITJlVlDcDZ0zSZYP4AMXYEp4bRi42ls1WEsp+JLbcS/OFP PgeA== 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:in-reply-to:references; bh=i6cJtP2GLYXrWSbffAAlWqbiBaFJmvg9QhFIx0JCR4w=; b=uGHa/RWuiZJYI1R1Nh79n3KYU48vIbk3j41X5Ogn7S5lA2PfHGdKSmrFaTzKugx0P8 +b7YKiUxdQNKIJh32HbwqvfJqGj9xJjVpmRRJEtY5oHtvMdijzg1QNuppMDNIyDxabdF kYkpEuyNXEfS0XzpK79YUPvG1WNnerL8TOjZIzVoBC87EvINTC1gWm+xaSFIFvA3djlz RwHoszG4T7USpeI0O4GtXRf+sQQ07jVBWvdoogF9nOlNJ/KGPtN4eVmzuo+SdT9i5xBi eburvr4hQGlJO4qfSNMe8Dxo4wEP04GX1YzwquK4/yUVVA0M4A1DSYlOHKF506wTv0hL AelA== X-Gm-Message-State: APjAAAVQ+2Wx+OwHyGUSdqhI/R7u73elpcyoTUHZe9jkretwBxiCRJL9 N8dZ+2hMp7ccxx4ogdUIP2lAng== X-Received: by 2002:a63:9a12:: with SMTP id o18mr26772073pge.379.1573457727181; Sun, 10 Nov 2019 23:35:27 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id c184sm17345285pfc.159.2019.11.10.23.35.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 Nov 2019 23:35:26 -0800 (PST) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org, asutoshd@codeaurora.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, arnd@arndb.de, linus.walleij@linaro.org, vincent.guittot@linaro.org, baolin.wang@linaro.org, baolin.wang7@gmail.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/4] mmc: host: sdhci: Add a variable to defer to complete requests if needed Date: Mon, 11 Nov 2019 15:34:00 +0800 Message-Id: <119d3285ab610967b43f7c822dfdc0ebb8d521cb.1573456284.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org When using the host software queue, it will trigger the next request in irq handler without a context switch. But the sdhci_request() can not be called in interrupt context when using host software queue for some host drivers, due to the get_cd() ops can be sleepable. But for some host drivers, such as Spreadtrum host driver, the card is nonremovable, so the get_cd() ops is not sleepable, which means we can complete the data request and trigger the next request in irq handler to remove the context switch for the Spreadtrum host driver. Thus we still need introduce a variable in struct sdhci_host to indicate that we will always to defer to complete requests if the sdhci_request() can not be called in interrupt context for some host drivers, when using the host software queue. Suggested-by: Adrian Hunter Signed-off-by: Baolin Wang --- drivers/mmc/host/sdhci.c | 2 +- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 850241f..4bef066 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3035,7 +3035,7 @@ static inline bool sdhci_defer_done(struct sdhci_host *host, { struct mmc_data *data = mrq->data; - return host->pending_reset || + return host->pending_reset || host->always_defer_done || ((host->flags & SDHCI_REQ_USE_DMA) && data && data->host_cookie == COOKIE_MAPPED); } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index d89cdb9..a73ce89 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -533,6 +533,7 @@ struct sdhci_host { bool pending_reset; /* Cmd/data reset is pending */ bool irq_wake_enabled; /* IRQ wakeup is enabled */ bool v4_mode; /* Host Version 4 Enable */ + bool always_defer_done; /* Always defer to complete requests */ struct mmc_request *mrqs_done[SDHCI_MAX_MRQS]; /* Requests done */ struct mmc_command *cmd; /* Current command */