From patchwork Tue Mar 17 10:14:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11442421 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64D75913 for ; Tue, 17 Mar 2020 10:14:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 451332071C for ; Tue, 17 Mar 2020 10:14:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B2a8uuHA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726250AbgCQKO0 (ORCPT ); Tue, 17 Mar 2020 06:14:26 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33688 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbgCQKOZ (ORCPT ); Tue, 17 Mar 2020 06:14:25 -0400 Received: by mail-pf1-f196.google.com with SMTP id n7so11699012pfn.0; Tue, 17 Mar 2020 03:14:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=CJ+wcXrk2AEgHUVo4xt56W56ueRIUgPFWZGnDDDncXc=; b=B2a8uuHAXzQ6/5JN+HOZJYJ/4vaiesxeohSbKzfzIaIiwYgIN3zNkNyvHLdRGTAPtG nhwaLNwx+iz4GGkvh00uI8tRnv8Mc4mvTUcbk+3xMUaJ6axlYtnODQH6lbz/aQV0bvy8 EyIe1hx6BNEmANsOGmvXogbrEvv5PXkkimfXBBzi+cbVX4ssKMEIapTi4maDTWfe3+iy K5KeQcC5x0/o7QLP3ixpaG5t//MF1jOTd7Wg+d38W0TkOXAB4ZPHm6XgMNlI+aokmxvz acdiT55pjHNF6U0UZAuU0LLXCiUmQy9z5AjB0Z0vQipmIX5SKPu7oBo9Pd8t+5BObgdP 4/yA== 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=CJ+wcXrk2AEgHUVo4xt56W56ueRIUgPFWZGnDDDncXc=; b=NcGngEY18hLlN/817yPiYVDRfnj7bZVsDUaGa5SztOH3F9zqQIFVitVHVQU0C8Xrnv 1nMBX4MJpoCJwc/wyMqVIb3Po+Y8sqay4XDZNo0BRGmDD2/YYD/UZ9FrDIvRC1x+MPdT RnZKwJ0+2hQ5u8qj9bOcy9zqc4A7XGwhwB6dy2a8Hq4tP6B8i8wsHecFvASRMXi6phDl GXpkVKq40fOisr14LJWFggSz4zIzAcOLSNmIweISdKp5cXFbHcmW4pGAfz/UJH/jfsjJ FYVgEG20dQprA30bGubLQK/rqtGgoKMKM7ehrkom6Shdwa9KTRJKm83KGzmy9cwYjOKg 8Rhg== X-Gm-Message-State: ANhLgQ3aBpGwhTa1Igs4X+8RRn6+YJjAPvLcYhDVHocGTECYg+/oDNQU CFpAPZN1a7OC3v0G+tZ54NYhO5YRwec= X-Google-Smtp-Source: ADFU+vsk7ad1YGpnHh9fr67sum48t3QZAHGEe+H8j+CZNAo1fiKXToOmnyNKLR/yAx1nPaK43FvVVg== X-Received: by 2002:a63:ed10:: with SMTP id d16mr4265924pgi.107.1584440063976; Tue, 17 Mar 2020 03:14:23 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id s25sm2195487pgv.70.2020.03.17.03.14.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Mar 2020 03:14:23 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, baolin.wang7@gmail.com, arnd@arndb.de, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] mmc: host: Introduce the request_atomic() for the host Date: Tue, 17 Mar 2020 18:14:09 +0800 Message-Id: X-Mailer: git-send-email 1.9.1 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 The SD host controller can process one request in the atomic context if the card is nonremovable, which means we can submit next request in the irq hard handler when using the MMC host software queue to reduce the latency. Thus this patch adds a new API request_atomic() for the host controller, as well as adding support for host software queue to submit a request by the new request_atomic() API. Suggested-by: Adrian Hunter Signed-off-by: Baolin Wang --- drivers/mmc/host/mmc_hsq.c | 5 ++++- include/linux/mmc/host.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/mmc_hsq.c b/drivers/mmc/host/mmc_hsq.c index 59d2776..fdbaa98 100644 --- a/drivers/mmc/host/mmc_hsq.c +++ b/drivers/mmc/host/mmc_hsq.c @@ -41,7 +41,10 @@ static void mmc_hsq_pump_requests(struct mmc_hsq *hsq) spin_unlock_irqrestore(&hsq->lock, flags); - mmc->ops->request(mmc, hsq->mrq); + if (mmc->ops->request_atomic) + mmc->ops->request_atomic(mmc, hsq->mrq); + else + mmc->ops->request(mmc, hsq->mrq); } static void mmc_hsq_update_next_tag(struct mmc_hsq *hsq, int remains) diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 562ed06..db5e59c 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -92,6 +92,9 @@ struct mmc_host_ops { int err); void (*pre_req)(struct mmc_host *host, struct mmc_request *req); void (*request)(struct mmc_host *host, struct mmc_request *req); + /* Submit one request to host in atomic context. */ + void (*request_atomic)(struct mmc_host *host, + struct mmc_request *req); /* * Avoid calling the next three functions too often or in a "fast From patchwork Tue Mar 17 10:14:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11442423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C3CC913 for ; Tue, 17 Mar 2020 10:14:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D54E20736 for ; Tue, 17 Mar 2020 10:14:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mwxZK12o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725995AbgCQKO2 (ORCPT ); Tue, 17 Mar 2020 06:14:28 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:35551 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbgCQKO1 (ORCPT ); Tue, 17 Mar 2020 06:14:27 -0400 Received: by mail-pf1-f194.google.com with SMTP id u68so11693405pfb.2; Tue, 17 Mar 2020 03:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Fjm25eN67Hl8nyOyYLv4A1iv8wxFfMXZZCpQcIx04n4=; b=mwxZK12o2yFozq5LmtW0340Kj6e5cy3+iINHt9d9FhoP8FJlNCV8FF6meN5ck887xS GRZv1Qp0O3sU7pgv/l/oUShq7oHzVeEnm4Vbm3/m6wYJ4qEN1p29cXL+14V+ZlNmaX/c 7W5/qT6+5mNtAbtdZXZEaNeck7+gxwvquI8h8hGJS2J9azOozAhXJzAALPyjsJ5ehYTT vBh9GwLyaQcRlJAVwO3JHoCT2V90gkT6UP6iSK7ZXnvviLPiFULFaB25xJ5tMmZF4Bb+ 2A/u0oK5nYGBHoTaNZ7jZJnmIRjRefvsoe7i2nJqXyYt0ibVdkn5o4OpWyBQxb2l7pf9 kgGA== 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=Fjm25eN67Hl8nyOyYLv4A1iv8wxFfMXZZCpQcIx04n4=; b=VCBOcJ9UA7k4yub+CcGxONelzLaFotoUv5NfnrfqbmOI/wHNr7X9/JaPO9jug8Z58y Elxmj5EO4L2cUuIfwlSAWg8Vfb41yzUzwz6OI2T3HdbMAxFWcTuYS4p1WNiq1qVeHLUt igarpQRma339uy/zxqDOdSB0I58yq/Nx528Cd/Wq8ZG1Lal3PojDfUiqRyl789nTS0ZE WbjwuzBsJWFe4Bx5oQ44IWXGchtGZdECHwtp2r72SEdFQF/9m3gCE1igOzE/2GNspK65 5W3Ln3MEmpAVT0ASVRsLF2545a2ZtYsfboPFWnrBxvke1esUioXAXskaS+VOIeGGSblT CJvQ== X-Gm-Message-State: ANhLgQ2LYx5CfGa/cLHzcWnuVXu5+/B5zhefq/HlW9qxjDtnvv5kXsw6 AxqkgW9DIuzSk0vyZ7cbDQs= X-Google-Smtp-Source: ADFU+vt0gPIsnKNi8QcQSYy1f9nkaTot8YwWssQrEJGM+YdgqdtFrAlpfD6o2Cfwk8GkTzGbj9Jveg== X-Received: by 2002:a65:5688:: with SMTP id v8mr4021453pgs.403.1584440066838; Tue, 17 Mar 2020 03:14:26 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id s25sm2195487pgv.70.2020.03.17.03.14.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Mar 2020 03:14:26 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, baolin.wang7@gmail.com, arnd@arndb.de, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] mmc: host: sdhci: Implement the request_atomic() API Date: Tue, 17 Mar 2020 18:14:10 +0800 Message-Id: <3e1b588cd5579b63f4efcc5dd0d3a155f8de5a07.1584428736.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 1.9.1 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 Implement the request_atomic() ops for the sdhci driver to process one request in the atomic context if the card is nonremovable. Signed-off-by: Baolin Wang --- drivers/mmc/host/sdhci.c | 27 +++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9c37451..4febbcb 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2016,17 +2016,12 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode, * * \*****************************************************************************/ -void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) +static void sdhci_start_request(struct mmc_host *mmc, struct mmc_request *mrq, + int present) { - struct sdhci_host *host; - int present; + struct sdhci_host *host = mmc_priv(mmc); unsigned long flags; - host = mmc_priv(mmc); - - /* Firstly check card presence */ - present = mmc->ops->get_cd(mmc); - spin_lock_irqsave(&host->lock, flags); sdhci_led_activate(host); @@ -2043,6 +2038,22 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) spin_unlock_irqrestore(&host->lock, flags); } + +void sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq) +{ + sdhci_start_request(mmc, mrq, 1); +} +EXPORT_SYMBOL_GPL(sdhci_request_atomic); + +void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) +{ + int present; + + /* Firstly check card presence */ + present = mmc->ops->get_cd(mmc); + + sdhci_start_request(mmc, mrq, present); +} EXPORT_SYMBOL_GPL(sdhci_request); void sdhci_set_bus_width(struct sdhci_host *host, int width) diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index cac2d97..5507a73 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -775,6 +775,7 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode, void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode, unsigned short vdd); void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq); +void sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq); void sdhci_set_bus_width(struct sdhci_host *host, int width); void sdhci_reset(struct sdhci_host *host, u8 mask); void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing); From patchwork Tue Mar 17 10:14:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11442425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC005913 for ; Tue, 17 Mar 2020 10:14:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC757206EC for ; Tue, 17 Mar 2020 10:14:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VW6deAEG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726438AbgCQKOb (ORCPT ); Tue, 17 Mar 2020 06:14:31 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43674 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726428AbgCQKOb (ORCPT ); Tue, 17 Mar 2020 06:14:31 -0400 Received: by mail-pg1-f193.google.com with SMTP id u12so11459164pgb.10; Tue, 17 Mar 2020 03:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=unr3k2tfwI2GqRohsFvvT8LxV6+FWELnFqCEg/uISRU=; b=VW6deAEGfLYbY7pS6MtMsUncuzhTbxcO4qKni6upZKof/ofZXI+1u0W3aK9al4MPug F5E05y6PMNqPlPk3l2Dw7Qy9mPI4eGPghQ7eBfaqmH7o7EXTY944XoipebnA9jSgLdtr jRRC1vsQS3lwxbV98io69ZRCUTk8bxOV+gJH3HInXmMLk9x5Wpy4s2/QTY4mzdub/f/O KEqTo0MOHyDMU8s4TOh3Ikr7+02Y8YtGQ2+nJ4QL5wWsTH6G3F+vKrB79pJgI4pTu4Nq WSrY107HREU7h2nWywPMPo8hUddKJ5ylEQfh06CcmAJwUFLW1NM1+W5QoGkKNcX3X+8T Uvog== 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=unr3k2tfwI2GqRohsFvvT8LxV6+FWELnFqCEg/uISRU=; b=FMyO8Mj4VF0CDDJBulZrRS8GScbfc2H9pmTdAs0MkS+4y6mBkKhL/bqbv2QPW6xqHh ZNafCRBM2yrk1eVQz4NWDUwUG58+JopTNZ4QwyBT9bzbbqDst34jSWDzSWxDOT9o3AQ0 Fdo9r0SKcgl6LUoGTOT8scPmMNgngJkE/7KJrvA09Qlp3rWmwCFM2MdFfaH4L6vXkJuc /61ktgvcEjwPMQspzLWiZsQfzBSV77s1els/qaM1AMPUfu9JtWgMlf0sAaQL+bFs54Xx BVAY+5dmeZoeoGaeLYJS/Ni79oTRlM4ijmVIu7S8oBDlj/bQzOEKHyu5o9YIauQxLiyy 58OQ== X-Gm-Message-State: ANhLgQ3XRbAYTPsERzdxErDH6yMfLbWpg4W1NNUgsICJFas5fICe18lZ EjKo/XBOkbzhrnXF6eEB87Bx3IWNLvo= X-Google-Smtp-Source: ADFU+vuVmuOuaOQmHeXtRiW9FzeySr1ANKAzEBgX0qkeji0WpiinCnOTkUqYSe6sDFp7M5g2mIWb0Q== X-Received: by 2002:aa7:87c1:: with SMTP id i1mr4521301pfo.297.1584440069616; Tue, 17 Mar 2020 03:14:29 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id s25sm2195487pgv.70.2020.03.17.03.14.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Mar 2020 03:14:29 -0700 (PDT) From: Baolin Wang To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, baolin.wang7@gmail.com, arnd@arndb.de, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] mmc: host: sdhci-sprd: Implement the request_atomic() API Date: Tue, 17 Mar 2020 18:14:11 +0800 Message-Id: <8cc959db07c9f9dbcad5dfdbffd78760c06f1c7b.1584428736.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 1.9.1 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 Implement the request_atomic() API for nonremovable cards, that means we can submit next request in the irq hard handler context to reduce latency. Moreover factor out the AUTO CMD23 checking into a separate function to reduce duplicate code. Signed-off-by: Baolin Wang --- drivers/mmc/host/sdhci-sprd.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c index 2ab42c5..9a08f70 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -406,7 +406,8 @@ static void sdhci_sprd_request_done(struct sdhci_host *host, .request_done = sdhci_sprd_request_done, }; -static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) +static void sdhci_sprd_check_auto_cmd23(struct mmc_host *mmc, + struct mmc_request *mrq) { struct sdhci_host *host = mmc_priv(mmc); struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); @@ -422,10 +423,23 @@ static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) mrq->sbc && (mrq->sbc->arg & SDHCI_SPRD_ARG2_STUFF) && (host->flags & SDHCI_AUTO_CMD23)) host->flags &= ~SDHCI_AUTO_CMD23; +} + +static void sdhci_sprd_request(struct mmc_host *mmc, struct mmc_request *mrq) +{ + sdhci_sprd_check_auto_cmd23(mmc, mrq); sdhci_request(mmc, mrq); } +static void sdhci_sprd_request_atomic(struct mmc_host *mmc, + struct mmc_request *mrq) +{ + sdhci_sprd_check_auto_cmd23(mmc, mrq); + + sdhci_request_atomic(mmc, mrq); +} + static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios) { struct sdhci_host *host = mmc_priv(mmc); @@ -561,6 +575,11 @@ static int sdhci_sprd_probe(struct platform_device *pdev) if (ret) goto pltfm_free; + if (!mmc_card_is_removable(host->mmc)) + host->mmc_host_ops.request_atomic = sdhci_sprd_request_atomic; + else + host->always_defer_done = true; + sprd_host = TO_SPRD_HOST(host); sdhci_sprd_phy_param_parse(sprd_host, pdev->dev.of_node); @@ -654,8 +673,6 @@ static int sdhci_sprd_probe(struct platform_device *pdev) if (ret) goto err_cleanup_host; - host->always_defer_done = true; - ret = __sdhci_add_host(host); if (ret) goto err_cleanup_host;