From patchwork Fri Apr 3 07:05:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11471927 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 3F7C792A for ; Fri, 3 Apr 2020 07:05:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13CDB206A3 for ; Fri, 3 Apr 2020 07:05:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MufWgAWf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389087AbgDCHFq (ORCPT ); Fri, 3 Apr 2020 03:05:46 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:36280 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388472AbgDCHFq (ORCPT ); Fri, 3 Apr 2020 03:05:46 -0400 Received: by mail-pj1-f67.google.com with SMTP id nu11so2564110pjb.1; Fri, 03 Apr 2020 00:05:45 -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=CrZe3I4PBsnuaIeN4buPPytwyP1ByhSDiM4SeWiS8VM=; b=MufWgAWfvPyyz50E4MGAbCI4cA4XL24r3qP/DblFxOdU59p/85Lge88T3t66lyfi+F 7R5fKLXAZAGk4aFAUGhBn7tDLKpYGaxtUrw0I2Qe5SZLaK/jmRVGnwEvYdiie0fWppQR wd+k/eGSaD/pk638UPDO32UPEFfrilGKJsWDiBCN4R5PXPehOGuDnsaH9BO4wAKrflc+ pPixaPXAtJD+3FYFLnGpdw6PaheBWbzIzNDd+9/SjGUOALyu8jo7ra/rFdNG9LdlkE6y bXn+4aGMxa425vrfnvkTn6cSMJUOr7Zl6WCzjWphryJhCz5d9OvWyp9Nv5Oq6IVEC4sy 8bGg== 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=CrZe3I4PBsnuaIeN4buPPytwyP1ByhSDiM4SeWiS8VM=; b=eTk/bvtwWrg2La6SNd2uKJcXx4g8nq6lIH4HHIrvrka636NPYnG3DrMRbjQn5vrO89 g//tEnbi+doV2TzBQkZ2vLElfMRPLSizD0pkzVAvXUNcaB5IMh11PZsNZEJ7cmw1VP1W 9gHCGT4r39Zj49CLnp+YSIMD1dLI07JV+UFgSt0Dfky+WKpPflt9lfiFS+IlCE63CT5C FPgOW0GGV7yN8h3D8gitXVl8wEwuC1nbDEUKzQ5FZWmpOH8twToyDKFTfVSNssn89z1k jxWnUX09y6vFeqaPbCKbPFNWAkDjCmYg+Qq5xuyg/kHGff/5KA9UmRzUmKSaXzw+dWGO XwWQ== X-Gm-Message-State: AGi0PuYyP4xz36Jn0/HGP9WqkKefDowZaFkwYZO/8sjVRvEONf8P325h CkjHZJW3VImQ0KNCBMSDnlk= X-Google-Smtp-Source: APiQypJvf9N/GAQ/pZeL8u+QLoEXYsFUpcobXFllMB4c0bcfvpd7djx+HyVORGQY98kg28CSl8uQSw== X-Received: by 2002:a17:90a:9f09:: with SMTP id n9mr7921682pjp.157.1585897544918; Fri, 03 Apr 2020 00:05:44 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id u18sm5138701pfl.40.2020.04.03.00.05.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Apr 2020 00:05:44 -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 v4 1/3] mmc: host: Introduce the request_atomic() for the host Date: Fri, 3 Apr 2020 15:05:26 +0800 Message-Id: <04c25ff9f9b17d41d734c498e4be61dee745bb30.1585896945.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 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. Moreover there is an unusual case that the card is busy when trying to send a command, and we can not polling the card status in interrupt context by using request_atomic() to dispatch requests. Thus we should queue a work to try again in the non-atomic context in case the host releases the busy signal later. Suggested-by: Adrian Hunter Signed-off-by: Baolin Wang Acked-by: Adrian Hunter --- drivers/mmc/host/mmc_hsq.c | 29 ++++++++++++++++++++++++++++- drivers/mmc/host/mmc_hsq.h | 1 + include/linux/mmc/host.h | 3 +++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/mmc_hsq.c b/drivers/mmc/host/mmc_hsq.c index b90b2c9..a57f802 100644 --- a/drivers/mmc/host/mmc_hsq.c +++ b/drivers/mmc/host/mmc_hsq.c @@ -16,11 +16,20 @@ #define HSQ_NUM_SLOTS 64 #define HSQ_INVALID_TAG HSQ_NUM_SLOTS +static void mmc_hsq_retry_handler(struct work_struct *work) +{ + struct mmc_hsq *hsq = container_of(work, struct mmc_hsq, retry_work); + struct mmc_host *mmc = hsq->mmc; + + mmc->ops->request(mmc, hsq->mrq); +} + static void mmc_hsq_pump_requests(struct mmc_hsq *hsq) { struct mmc_host *mmc = hsq->mmc; struct hsq_slot *slot; unsigned long flags; + int ret = 0; spin_lock_irqsave(&hsq->lock, flags); @@ -42,7 +51,24 @@ 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) + ret = mmc->ops->request_atomic(mmc, hsq->mrq); + else + mmc->ops->request(mmc, hsq->mrq); + + /* + * If returning BUSY from request_atomic(), which means the card + * may be busy now, and we should change to non-atomic context to + * try again for this unusual case, to avoid time-consuming operations + * in the atomic context. + * + * Note: we just give a warning for other error cases, since the host + * driver will handle them. + */ + if (ret == -EBUSY) + schedule_work(&hsq->retry_work); + else + WARN_ON_ONCE(ret && ret != -EBUSY); } static void mmc_hsq_update_next_tag(struct mmc_hsq *hsq, int remains) @@ -325,6 +351,7 @@ int mmc_hsq_init(struct mmc_hsq *hsq, struct mmc_host *mmc) hsq->mmc->cqe_private = hsq; mmc->cqe_ops = &mmc_hsq_ops; + INIT_WORK(&hsq->retry_work, mmc_hsq_retry_handler); spin_lock_init(&hsq->lock); init_waitqueue_head(&hsq->wait_queue); diff --git a/drivers/mmc/host/mmc_hsq.h b/drivers/mmc/host/mmc_hsq.h index 18b9cf5..ffdd9cd 100644 --- a/drivers/mmc/host/mmc_hsq.h +++ b/drivers/mmc/host/mmc_hsq.h @@ -12,6 +12,7 @@ struct mmc_hsq { wait_queue_head_t wait_queue; struct hsq_slot *slot; spinlock_t lock; + struct work_struct retry_work; int next_tag; int num_slots; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index c318fb5..d4a50e5d 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. */ + int (*request_atomic)(struct mmc_host *host, + struct mmc_request *req); /* * Avoid calling the next three functions too often or in a "fast From patchwork Fri Apr 3 07:05:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11471931 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 E9D901667 for ; Fri, 3 Apr 2020 07:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7A09206A3 for ; Fri, 3 Apr 2020 07:05:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nIvjKv0t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389448AbgDCHFt (ORCPT ); Fri, 3 Apr 2020 03:05:49 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45033 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388472AbgDCHFs (ORCPT ); Fri, 3 Apr 2020 03:05:48 -0400 Received: by mail-pl1-f194.google.com with SMTP id h11so2347729plr.11; Fri, 03 Apr 2020 00:05:48 -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=Cn9rxoHRwqUFpqjcL+3xJuR6J5sQOGtMSKzJdI2DfTs=; b=nIvjKv0totLA9J1qANJGWwvGcdvejsYy8TEY43F1hiZbDOJpsH9HSPv1f9yK5fT1rx of0szrECg7PW6NWvwmM83BUecPDFvCN/02Z2h1YAN/xi2e6F2VopsoTlXH2HfOCNEBX+ sHoUSEqjrbeEG4KP9l1b0bsT3DOz1YP3lxzGW1cz/iUlTIMAyp3JzxkYQM9lWV8GztOv 7cha51bONpjNFeSyxcwsBvqPtFAC2cXjLmtS6/cFU5zTc/eCniUnPrQZhVYrskB+pqFO 6dgJQLDsCKTza0wyUIsmx6TlfbBAPjvJIURyN3aHOaHvQBUwsC/X72a+MXxe2QJi+r1/ qZcA== 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=Cn9rxoHRwqUFpqjcL+3xJuR6J5sQOGtMSKzJdI2DfTs=; b=A9/STAVSqBKT/nOgvXWpMEENMj1XkAuFPUnjSr+LfgRFksA1C7WyPFiROtlXumeDYe D8VU1LeH2AnKreBCg9qSutFFgDH5l482UmC+BfoEdpNOApNVYwwzfMPPDN0cXZ4Q/fSQ prqdkfwHvM4i4u2XaRCTlLFLYQ79YblMpD41KNuMboDVvVWSbtb2JZWdV91ZtjzrC+aP Vz7mawoXBuMNlJD+P0YVtIVo2UBzjBcS+J5/HHTES3cZkaga2lWmz9ntESGRGHZDn5Zg ndW+Jxus224VtZQYYvCkOTC5r+jjyNePIgiLOyjBXRIM+qcShJzLm0x+BplviaQYVRpV vP2w== X-Gm-Message-State: AGi0PuaB750SsgLXXIw+uFGcZDzw12Gz2Mmeje86z804wtS/PLT89QRq Dki4Ni0LnXCLRerjMK4yLyvA1JAW X-Google-Smtp-Source: APiQypIFFOuAoNTKN7ddIsEBetM5he1h/XwWLQuTeUGCcpFVd+XiMAruXCGJZRbWmZnGuuBLg+lBTQ== X-Received: by 2002:a17:90a:19dc:: with SMTP id 28mr5376736pjj.180.1585897547903; Fri, 03 Apr 2020 00:05:47 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id u18sm5138701pfl.40.2020.04.03.00.05.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Apr 2020 00:05:47 -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 v4 2/3] mmc: host: sdhci: Implement the request_atomic() API Date: Fri, 3 Apr 2020 15:05:27 +0800 Message-Id: <974ff8409cf7e7759df9eff09368bea3545474d7.1585896945.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. Moreover, add a boolean parameter for sdhci_send_command() function to indicate if need poll the inhibit bits, which can avoid time-consuming polling in interrupt context by returning BUSY if we met this unusual case through request_atomic() API. Signed-off-by: Baolin Wang --- drivers/mmc/host/sdhci.c | 65 +++++++++++++++++++++++++++++++++++------------- drivers/mmc/host/sdhci.h | 4 ++- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 3f71646..1e67b1a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1539,14 +1539,15 @@ static void sdhci_finish_data(struct sdhci_host *host) } else { /* Avoid triggering warning in sdhci_send_command() */ host->cmd = NULL; - sdhci_send_command(host, data->stop); + sdhci_send_command(host, data->stop, true); } } else { __sdhci_finish_mrq(host, data->mrq); } } -void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) +int sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd, + bool polling) { int flags; u32 mask; @@ -1574,13 +1575,26 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) mask &= ~SDHCI_DATA_INHIBIT; while (sdhci_readl(host, SDHCI_PRESENT_STATE) & mask) { - if (timeout == 0) { + if (!polling) { + pr_err("%s: Controller has not released inhibit bit(s), try again.\n", + mmc_hostname(host->mmc)); + + /* + * HSQ may send a command in interrupt context without + * polling the busy signaling, which means we should + * return BUSY if controller has not released inhibit + * bits to allow HSQ trying to send request again in + * non-atomic context. so we should not finish this + * request here. + */ + return -EBUSY; + } else if (timeout == 0) { pr_err("%s: Controller never released inhibit bit(s).\n", mmc_hostname(host->mmc)); sdhci_dumpregs(host); cmd->error = -EIO; sdhci_finish_mrq(host, cmd->mrq); - return; + return -EIO; } timeout--; mdelay(1); @@ -1610,7 +1624,7 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) mmc_hostname(host->mmc)); cmd->error = -EINVAL; sdhci_finish_mrq(host, cmd->mrq); - return; + return -EINVAL; } if (!(cmd->flags & MMC_RSP_PRESENT)) @@ -1645,6 +1659,8 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) sdhci_external_dma_pre_transfer(host, cmd); sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND); + + return 0; } EXPORT_SYMBOL_GPL(sdhci_send_command); @@ -1707,7 +1723,7 @@ static void sdhci_finish_command(struct sdhci_host *host) /* Finished CMD23, now send actual command. */ if (cmd == cmd->mrq->sbc) { - sdhci_send_command(host, cmd->mrq->cmd); + sdhci_send_command(host, cmd->mrq->cmd, true); } else { /* Processed actual command. */ @@ -2035,16 +2051,12 @@ void sdhci_set_power_and_bus_voltage(struct sdhci_host *host, * * \*****************************************************************************/ -void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) +static int sdhci_start_request(struct mmc_host *mmc, struct mmc_request *mrq, + int present, bool polling) { - 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); + int ret; spin_lock_irqsave(&host->lock, flags); @@ -2052,15 +2064,34 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) if (!present || host->flags & SDHCI_DEVICE_DEAD) { mrq->cmd->error = -ENOMEDIUM; + ret = -ENOMEDIUM; sdhci_finish_mrq(host, mrq); } else { if (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23)) - sdhci_send_command(host, mrq->sbc); + ret = sdhci_send_command(host, mrq->sbc, polling); else - sdhci_send_command(host, mrq->cmd); + ret = sdhci_send_command(host, mrq->cmd, polling); } spin_unlock_irqrestore(&host->lock, flags); + + return ret; +} + +int sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq) +{ + return sdhci_start_request(mmc, mrq, 1, false); +} +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, true); } EXPORT_SYMBOL_GPL(sdhci_request); @@ -2600,7 +2631,7 @@ void sdhci_send_tuning(struct sdhci_host *host, u32 opcode) */ sdhci_writew(host, SDHCI_TRNS_READ, SDHCI_TRANSFER_MODE); - sdhci_send_command(host, &cmd); + sdhci_send_command(host, &cmd, true); host->cmd = NULL; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 79dffbb..f2d255c 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -757,7 +757,8 @@ void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver, int __sdhci_add_host(struct sdhci_host *host); int sdhci_add_host(struct sdhci_host *host); void sdhci_remove_host(struct sdhci_host *host, int dead); -void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd); +int sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd, + bool polling); static inline void sdhci_read_caps(struct sdhci_host *host) { @@ -776,6 +777,7 @@ void sdhci_set_power_and_bus_voltage(struct sdhci_host *host, 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); +int 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 Fri Apr 3 07:05:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11471929 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 9D4BB15AB for ; Fri, 3 Apr 2020 07:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A6B1206A3 for ; Fri, 3 Apr 2020 07:05:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KdqsOxJj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389654AbgDCHFw (ORCPT ); Fri, 3 Apr 2020 03:05:52 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:53357 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388472AbgDCHFv (ORCPT ); Fri, 3 Apr 2020 03:05:51 -0400 Received: by mail-pj1-f67.google.com with SMTP id l36so2609823pjb.3; Fri, 03 Apr 2020 00:05:51 -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=X5441Jy2VbGV6dbzgZxForefu3q50NuP2ovt+obRsE4=; b=KdqsOxJj3jIJF8lvmWFsOWJuT3iH0IM4CfLsCNIkcwxFSzinWd8uE3DN7BpJq3d3dN IAq7WUozAuBW9Peboj/muqESeRUcFALD9rl6eT7/iR5M2VMbEQRHIIvvcBrw8tDXSTQI RcPpfTiS8YmXuFR9oYnxvINs1yiuGWa6z7YKilGNEWbYKqDf8rLcSQUK6O5d6z4fTrTn Bdjxo49wflcMvAfa2J2qGe24WHEWHLz8UL1+Wi4+ZdN5F16kS9rtIwoK+me/pjwOP6JH +w9jjhQ5NYAEvOXG573xY3NL/TP55I/mJ6CSnaT+PcrG6JmBbw+Y9ECCVTjxJ4ywjqNf pZ4w== 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=X5441Jy2VbGV6dbzgZxForefu3q50NuP2ovt+obRsE4=; b=O1fdNSxCMjJIHtvZkpVaeBFdODKj0xi5TdzOy7HNY02OnyskeGOrWnOh/0JvuM+NlO NN+xuueSBI//fEOmAYhvLvWcLNaSwPiE6nc4dqjnxRYDbCrZN6GyfKAhyEefIwGNkQ0g Azm8tjZm12B4NJ3PJaFAQhv4YGxTHh2mqkM0/nMV+DEUlLUut+32gDotdlBuOsZgxpWR AdDZ3CZFs8UpN7IlidlYLNZpGfVKC89RcS7UPpC4yuCs8zczhEtLB9slsOIN0CjUzhRf lAzLzAaEh6EoVjONony1g1JpTqxbeLpdsWbHSs4EhyPsXmYFtNfaJilfO93P3Kd2MBNn VkPw== X-Gm-Message-State: AGi0PuawP4WotobUgrfecBAHR9yIfLZe+d6iHv93mJSruzepwdUjB4LG XcJst8ZrDetgDA4bow8d9rI= X-Google-Smtp-Source: APiQypJ5yGpiCWr3p8E88R3xUTg325QYKYDKW2LW0yQyyp0Mt2M+kRtW90UDBzb8GtYaMUPDsShSTQ== X-Received: by 2002:a17:902:8e84:: with SMTP id bg4mr6390446plb.11.1585897551311; Fri, 03 Apr 2020 00:05:51 -0700 (PDT) Received: from sh03840pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id u18sm5138701pfl.40.2020.04.03.00.05.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Apr 2020 00:05:50 -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 v4 3/3] mmc: host: sdhci-sprd: Implement the request_atomic() API Date: Fri, 3 Apr 2020 15:05:28 +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 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..bc7a8cb 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 int sdhci_sprd_request_atomic(struct mmc_host *mmc, + struct mmc_request *mrq) +{ + sdhci_sprd_check_auto_cmd23(mmc, mrq); + + return 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;