From patchwork Mon Apr 13 02:46:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11484963 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 B7A7717D4 for ; Mon, 13 Apr 2020 02:46:42 +0000 (UTC) Received: from vger.kernel.org (unknown [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86311206C3 for ; Mon, 13 Apr 2020 02:46:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jXHNHbBI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86311206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728357AbgDMCq0 (ORCPT ); Sun, 12 Apr 2020 22:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.18]:43348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728248AbgDMCqZ (ORCPT ); Sun, 12 Apr 2020 22:46:25 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5CEBC0086D3; Sun, 12 Apr 2020 19:46:25 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id a32so3287836pje.5; Sun, 12 Apr 2020 19:46:25 -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=22ImBzfhRquGecQMtA17MsJ6QqnzRdATqzouc8zKUW4=; b=jXHNHbBIKZQyh+pn1gZzQLnsgZPd6mgh17jpUu0Qapwzc6YkgGHOlUB7mkJ7yH3LFu zHaTD4+h2eSC4CtU9YY+ADDd6eGl6n9DGDDQ3DymOV0qJ1Il3wYtDvj31OQaB4VPEJ4l WYif2QzxCbbafKgVwaGoPV8Dy4BRxcBLQCawOry8NMdZK02xTLIMR9JVCn/S8llXCutK j1qMMdQxuqjIohQQczAY9pqW4/I9XQC47IcySa0Z+rW2Sq0ojlNZfYstGPlg1l7Cs9VA jFusr6tUxvp2178OPNLxZC07PQnm077K1jFt00MdY5k2YOSMYi2/lOh7wOhiHww9XGq/ LV0A== 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=22ImBzfhRquGecQMtA17MsJ6QqnzRdATqzouc8zKUW4=; b=dVDqSUH1udpfwS9VBJ8u7eRVU3QEBa7HaY/6Dvr6FXTE6heyEUcPFCVC/i/6k57t8u GktNy1aQkMSkBLJzGilnLerf2du1GUR1E6rhtIzX0RZEjskqrfcE/LrL6I94iT3HMa5Y 9ykplZIdsC765Asqs26o6zl1vVZjbuS7i6lQ0If6IBjvf0Dc4ppZM5wqMfM7os7LEMjC rxX4JP/a9mJr7K7waNeQuv/HTNSkcMnz45InqNAQ7ADm8Al9/j922sH41LjjjLWGu7lM sIGh2AHa8rr4dsIwFTK3cwzN6RHazP2eZ5qE6RzbSFsYqxat0swH5+Da6Rx62ssjR4ys OMpg== X-Gm-Message-State: AGi0PuaXx5p4HgCK4ypdmMknxR3sMFz8cVpL2iALGnedYP/0Q17MZx44 d3tqntpSx7/s2gmhXDCf3R6tFNYhtow= X-Google-Smtp-Source: APiQypLMblVK7N+LEhbw3OkzGosNBCoLYuJm+bVEn6K/4G2fIB+BLitb7vthcQ6CFyYijvbT6N2Idg== X-Received: by 2002:a17:90a:1955:: with SMTP id 21mr2513673pjh.25.1586745985303; Sun, 12 Apr 2020 19:46:25 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.19]) by smtp.gmail.com with ESMTPSA id i15sm2327882pfe.197.2020.04.12.19.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 19:46:24 -0700 (PDT) From: Baolin Wang To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: arnd@arndb.de, baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/3] mmc: host: Introduce the request_atomic() for the host Date: Mon, 13 Apr 2020 10:46:03 +0800 Message-Id: X-Mailer: git-send-email 2.17.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 Acked-by: Adrian Hunter Signed-off-by: Baolin Wang --- 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 b90b2c97b6cf..a5e05ed0fda3 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); } 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 18b9cf55925f..ffdd9cd172c3 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 c318fb5b6a94..d4a50e5dc111 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 Mon Apr 13 02:46:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11484965 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 E74C0186E for ; Mon, 13 Apr 2020 02:46:42 +0000 (UTC) Received: from vger.kernel.org (unknown [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF0F9206C3 for ; Mon, 13 Apr 2020 02:46:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rpg9/nlM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF0F9206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728413AbgDMCqa (ORCPT ); Sun, 12 Apr 2020 22:46:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.18]:43366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728248AbgDMCqa (ORCPT ); Sun, 12 Apr 2020 22:46:30 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9304BC0086D3; Sun, 12 Apr 2020 19:46:30 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id w3so2917376plz.5; Sun, 12 Apr 2020 19:46: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=YHBOhO4LyqyjDx63OQCrCgMDcpXOM1V+lH7ff49OMtU=; b=rpg9/nlMwTlyEJRJJPlYEBSDp/Z9HeRshrYva2w7lnYuF+gpYqSKj935QpmBLwpe6g cqkuatIMM2kfDKdrxtPul9bOOz7WOcfxyNBqyPZUIb7rJrYhHwGaJWWWzIGK9luKeL5W LKSS6dx3R6PKwt5EwTMy19NeDGeBxIx2LfbqJEOO9t9XzwA3CPJkCV3njVNZwo2UzLDi ff7D2dufkBNXhFgrXqHDFuK0juKbIow4m8o9g5lUpVr72CjIKBqQF8hpRzHKg/0j+TXV +ao5HNGl+opLh2+rF6LA/Oj3VJ2oOwln98a+Wwa7hwrREDObBoq9utmLXXrG1qt7NyfF ItrA== 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=YHBOhO4LyqyjDx63OQCrCgMDcpXOM1V+lH7ff49OMtU=; b=Sjkl+OEeLLNNlzrHirI8JL0KaO2KZ3SwwOCw6vEV7xQxbVH79Fc/dCHjd7nR12nyKD +W/yMd5alZLE8mfZEyzEtzjffc4al5Mt2DTvgwAS0GpCiK10lp12DCIUAuYVOWCp83Tf uAme3PIBswy5H8zi+mmBFfYNSkVgvwyUkCehLNC+8vWtddOWYEBRnIyQBhtvLqeBEEuE 56rbaY98H21gkgi0Nle8T+nmnxZoDeD8rwgtHVL2uC1OCaeCjAr25D8SDd5JYwk/yCuJ SupTyy5T8IR9b1NMNV/XR8mj/btV/jh1+ulYvHRDBGJvbG+2GwaZvFhlF5kZCpzLCfld B6YQ== X-Gm-Message-State: AGi0PuYyZsXf0bX/NS24kzJkIOKdgNrUTgMijcw3upBoancBMlEtW4IJ /JX2RtSxjMJMD/AOEeyPjegP6K7jYv0= X-Google-Smtp-Source: APiQypJTd9TiVaxLLVzNoyXtGYQYZ8rJP07wc26cWc97WPOhF2d4SZRmELRkul+6+o13HIR6ctmrjw== X-Received: by 2002:a17:902:8542:: with SMTP id d2mr9943031plo.273.1586745990075; Sun, 12 Apr 2020 19:46:30 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.19]) by smtp.gmail.com with ESMTPSA id i15sm2327882pfe.197.2020.04.12.19.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 19:46:29 -0700 (PDT) From: Baolin Wang To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: arnd@arndb.de, baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/3] mmc: host: sdhci: Implement the request_atomic() API Date: Mon, 13 Apr 2020 10:46:04 +0800 Message-Id: <9ed34afa9fb42e0c234065cac5401d7826942b55.1586744073.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 2.17.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, we should return BUSY flag if controller has not released the inhibit bits to allow HSQ trying to send request again in non-atomic context. Suggested-by: Adrian Hunter Signed-off-by: Baolin Wang Reported-by: kbuild test robot Reported-by: kbuild test robot Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 34 ++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci.h | 1 + 2 files changed, 35 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 10b9570f48aa..0baef595de26 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2144,6 +2144,40 @@ void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) } EXPORT_SYMBOL_GPL(sdhci_request); +int sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq) +{ + struct sdhci_host *host = mmc_priv(mmc); + struct mmc_command *cmd; + unsigned long flags; + int ret = 0; + + spin_lock_irqsave(&host->lock, flags); + + if (sdhci_present_error(host, mrq->cmd, true)) { + sdhci_finish_mrq(host, mrq); + goto out_finish; + } + + cmd = sdhci_manual_cmd23(host, mrq) ? mrq->sbc : mrq->cmd; + + /* + * The 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. + */ + if (!sdhci_send_command(host, cmd)) + ret = -EBUSY; + else + sdhci_led_activate(host); + +out_finish: + spin_unlock_irqrestore(&host->lock, flags); + return ret; +} +EXPORT_SYMBOL_GPL(sdhci_request_atomic); + void sdhci_set_bus_width(struct sdhci_host *host, int width) { u8 ctrl; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index a7e469c00617..4bd70da7aa00 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -776,6 +776,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 Mon Apr 13 02:46:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 11484967 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 2D3B41392 for ; Mon, 13 Apr 2020 02:46:43 +0000 (UTC) Received: from vger.kernel.org (unknown [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF2B9206C3 for ; Mon, 13 Apr 2020 02:46:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JKC4RlA0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF2B9206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728426AbgDMCqf (ORCPT ); Sun, 12 Apr 2020 22:46:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.18]:43380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728248AbgDMCqf (ORCPT ); Sun, 12 Apr 2020 22:46:35 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8C99C0086D3; Sun, 12 Apr 2020 19:46:35 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id p8so3882803pgi.5; Sun, 12 Apr 2020 19:46:35 -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=tnqE8PEqqE1BRJn6nGWZTUwVBt6LXnaUqshkgnwb5Ss=; b=JKC4RlA0I5ioGbFK2YWXszKo1eYASbnBVQaV0jyDXUyKbuaX1QfL9EgmlJk0b9/Z74 +5hPsr9+mtRim7QXQlNmdKajwcVYjLEvdwEi8dGzmE7pUe18VgJpih9NbPus1zBg2b+O Of9mo/jzuH7mtMyyVLNnX7EgFaixx2gfuPDB6TA+7l++1Y6G3D3fo029tmx/3JR3zWmD SEbI1S9YNmZbeWTmm0XaG/bFCovQN/yACoW2Z3Lzx4a0jQS73flM+PPfKa+2hFVX7Q7T xz6q9tjbe+5+/598101LBuHj/e4g0CegOkONy+qqYJJsACRkSiA09wlxCd7vdQFwpr6s sBmQ== 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=tnqE8PEqqE1BRJn6nGWZTUwVBt6LXnaUqshkgnwb5Ss=; b=mZLQiYkWensLWzFWhr+dyfxlJV+V+7mxrT7n2uPTxyOA5HZGlyuTpJZOGxbA2a4L9p iYAGZeFKwqssG5xc+PohbEFYzAj19+aShccsU7Rl1d5+Q/8iPyCOAtpm6XEc5ibhFhOF u3n1bvs9Nt1/YPEUF3+kzBoxtPujUJRWrvd9P/3msuA/GSmOAOdXfHBQ2Wxh/lrBw9lg 8CbsPYRYIr7gUQPCJnQ7G66LdJiJMpBYKi7pXcbE88b3Fh0VzQaFvJaF2LnAAfjxpR/u 3gGzo0TTv3KpRnLxKjsFxFalnbKiRxPdMw3Z96YzYmHp0c4QP7il5v2BzeJmQ64TFIJ4 WLdA== X-Gm-Message-State: AGi0PuY8pobK+4DA7RCgWDG9JNl+yLGZgG5KpUr2eivuNQ36q1xtAbYW 3wdA0zFAaTP3ZiJrfcBc/zU= X-Google-Smtp-Source: APiQypJH5BgTFOWeJiaGKc45nm2kik87Ll6tco0vNzX1CBGvtUntoOdUHyWd/s+SmvtpDhdOFiO3Wg== X-Received: by 2002:a63:fa0b:: with SMTP id y11mr5060865pgh.334.1586745995228; Sun, 12 Apr 2020 19:46:35 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.19]) by smtp.gmail.com with ESMTPSA id i15sm2327882pfe.197.2020.04.12.19.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 19:46:34 -0700 (PDT) From: Baolin Wang To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: arnd@arndb.de, baolin.wang7@gmail.com, orsonzhai@gmail.com, zhang.lyra@gmail.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] mmc: host: sdhci-sprd: Implement the request_atomic() API Date: Mon, 13 Apr 2020 10:46:05 +0800 Message-Id: <60142fe6c6c1dbba2696e775564ae2166786f0bc.1586744073.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 2.17.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 Acked-by: Adrian Hunter --- 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 2ab42c59e4f8..bc7a8cb84862 100644 --- a/drivers/mmc/host/sdhci-sprd.c +++ b/drivers/mmc/host/sdhci-sprd.c @@ -406,7 +406,8 @@ static struct sdhci_ops sdhci_sprd_ops = { .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;