From patchwork Wed Feb 12 04:12:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 211195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C318C3B187 for ; Wed, 12 Feb 2020 04:14:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40E7020842 for ; Wed, 12 Feb 2020 04:14:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e/MKSaug" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727984AbgBLEOK (ORCPT ); Tue, 11 Feb 2020 23:14:10 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40510 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727602AbgBLEOK (ORCPT ); Tue, 11 Feb 2020 23:14:10 -0500 Received: by mail-pg1-f194.google.com with SMTP id z7so498064pgk.7; Tue, 11 Feb 2020 20:14:09 -0800 (PST) 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=341fIr27AyNPBcsww4i3en3R4df0bv31VLkS1AGBqK0=; b=e/MKSaugs0NVZ5zlKgcrjRIFDkFKH1MjbOdhMjZXao0ijbBhSU+TRLzKOGcqJEH4kw bOW9HADRj7zS069n4EL9GFEQ7Cju5gLZQU9ItS1jjQ0bPxAGby6FxjRtndkja5rrDqVN y8+hJF8YcOtIpcT04MtsJb+FEBv3Nyn8iFcc2GouBWuy68Bjl+c7wvWJDr9p3kaxP+I+ p+pJnXJp5K+zPw6GVo/jbkFapBQYUWLXZHnC+SFtE/JEnOWEYxT9UP1IoTxXQ1pohvDP 1Oc3J3oklEnn4BraoA5kRVMN1l1xqO/gb+xqppmBVzru2HjTkPWiiHcd3RPQSp0wrNag P41Q== 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=341fIr27AyNPBcsww4i3en3R4df0bv31VLkS1AGBqK0=; b=nzku3OQtDwLde36SfYmHczubkj6S/d7Hjj5k1E6xlBoixE+pB/PRVs4hylbfG+8xJJ drODWG8VDYmFn9CJEcVfijK9R7ldOXwtROEPV2rFAFu7IAiKeVEMzz12TtfPe04ubmr5 +Ir0g8OefuHOqs7y9xQHbNWDABGlFaGKJnBfEdRHyq87mZa/MKoQFvk/5KgkhVzSnli1 H5lH+L27zMslLhRpMa3tKOvgKKBrW1ybcp3Q6sdXziUX26HTZXE7oJzGPF56lHQTfOM6 iuCR6qpQijaAd8nXx6/NKiiycpzIoA0tcnL9fPlT1SYr94iNp8XQFrDG0B3BC6++ZaKV N1bQ== X-Gm-Message-State: APjAAAXtDBOQTKgumiF5Z/4Ny6dp8SYoUhTfeNS/bOuHJskri/98kVKW JDVFCYxV58ujKTuOow511rY= X-Google-Smtp-Source: APXvYqzTeweseuqdQBHIGo33w8FKX03J53/5SGk3JtJ3+YlIHYRE7zP9U1X2AgjnVPGPrwB3mqNqog== X-Received: by 2002:aa7:8755:: with SMTP id g21mr9774050pfo.36.1581480849589; Tue, 11 Feb 2020 20:14:09 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id q66sm6424762pfq.27.2020.02.11.20.14.06 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Feb 2020 20:14:09 -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, baolin.wang@linaro.org, baolin.wang7@gmail.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 2/5] mmc: core: Enable the MMC host software queue for the SD card Date: Wed, 12 Feb 2020 12:12:57 +0800 Message-Id: <0065b4631fef2d61c3b89d14a4ea4f2b7499ea56.1581478568.git.baolin.wang7@gmail.com> 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 From: Baolin Wang Enable the MMC host software queue for the SD card if the host controller supports the MMC host software queue. On my Spreadtrum platform, I did not see any obvious performance changes in 4K block size when changing to use hsq for the SD cards, I think the reason is the SD card works at a low speed on my platform, and most of time is spent in the hardware. But we can see some obvious improvements when enabling the packed request based on hsq, that's why we still add hsq support for the SD cards. Signed-off-by: Baolin Wang Signed-off-by: Baolin Wang --- drivers/mmc/core/sd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index fe914ff..76c7add 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1082,6 +1082,16 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, } } + if (host->cqe_ops && !host->cqe_enabled) { + err = host->cqe_ops->cqe_enable(host, card); + if (!err) { + host->cqe_enabled = true; + host->hsq_enabled = true; + pr_info("%s: Host Software Queue enabled\n", + mmc_hostname(host)); + } + } + if (host->caps2 & MMC_CAP2_AVOID_3_3V && host->ios.signal_voltage == MMC_SIGNAL_VOLTAGE_330) { pr_err("%s: Host failed to negotiate down from 3.3V\n", From patchwork Wed Feb 12 04:12:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 211194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37605C2BA83 for ; Wed, 12 Feb 2020 04:14:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0AC8A20842 for ; Wed, 12 Feb 2020 04:14:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hGdyka6/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728053AbgBLEOR (ORCPT ); Tue, 11 Feb 2020 23:14:17 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:32921 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727602AbgBLEOQ (ORCPT ); Tue, 11 Feb 2020 23:14:16 -0500 Received: by mail-pj1-f68.google.com with SMTP id m7so1428314pjs.0; Tue, 11 Feb 2020 20:14:16 -0800 (PST) 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=qXFSOdJFY54Rwc/1S4vXiFbbifW3bH93ZRFzyBvbEM0=; b=hGdyka6/RmAXFjU841hEJJ21UrRKnW8Hoe1NIwqk5ipPXxuIf/fHKOJmpz7WjEuHeN KEd11+a0oVSA02bOfHJ6tSz27iF2eT0inqjKAIW5O4OiAWiK8yn3B2JM9dmXB4+I904o YEuCIL/co326mIIX0ijWC6UsSEcEULBNx/wX3LZz/HeLukOWWTJWX7CiR0SRlaBdkIBn tsR/Ht/7Oup0k6ERXyeliBVtG/1YnfxTFTL/cHSE+ugv8q5Iv/929nfCy1M2KhWSzu5L UoA/zzda6iE0ZyqyI9pMsvPcp8O8mh23l1LvourNMyMvIFuao+QFPWJCcJrl+MEcl9kl FILg== 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=qXFSOdJFY54Rwc/1S4vXiFbbifW3bH93ZRFzyBvbEM0=; b=XZfc22MlmEf9dalHvmyaDqQqguKHAvmNqdIsoxSz6jLgXvVl1hjgRydAF2IO91GxxB gNAZBoD8rVpQZB4K1PnaGWT3qK/EV4iyC5+LMG3eh/xvnAAoRoN+BzGv51zAfk6rBt4J LeE8GX/W5eLcFQGT93nMQCkTIX9s6uVp6+WU4r1QHX0dJ9q++Ll0zSpX43Zi4jFICmHb /xohhdYKEc9aXxIhxi9SJHEMeKvPVkQMIiyDm9IO27qWYnm5CdgyO87iVI5GU+WbypMB LJK43E320yJg4bkK1iB6zlnLevsucDbIHpWNFbE2t8MAqMrL4Ctypm3hvONpnCUHLTsF wlaw== X-Gm-Message-State: APjAAAWmPhQC5ge3RffqlS8pw9cRKZZ0d5I0Gd9otzCFXhlhqImjHK5H UnBTAcRwY50IyCpzmtF5LYg= X-Google-Smtp-Source: APXvYqxQVb2chEkGjnmYtilp53q3aLcRcGNzxL6C1uOMNe1G9W3h8QKkKvjRYhQy0HFmgd/lQZbfEQ== X-Received: by 2002:a17:902:ba8b:: with SMTP id k11mr6337872pls.208.1581480855883; Tue, 11 Feb 2020 20:14:15 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id q66sm6424762pfq.27.2020.02.11.20.14.13 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Feb 2020 20:14:15 -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, baolin.wang@linaro.org, baolin.wang7@gmail.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 4/5] mmc: host: sdhci: Add a variable to defer to complete requests if needed Date: Wed, 12 Feb 2020 12:12: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 From: Baolin Wang 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. As suggested by Adrian, we should introduce a request_atomic() API to indicate that a request can be called in interrupt context to remove the context switch when using mmc host software queue. But this should be done in another thread to convert the users of mmc host software queue. Thus we can introduce a variable in struct sdhci_host to indicate that we will always to defer to complete requests when using the host software queue. Suggested-by: Adrian Hunter Signed-off-by: Baolin Wang Signed-off-by: Baolin Wang --- drivers/mmc/host/sdhci.c | 2 +- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 9761981..9c37451 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3250,7 +3250,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 3e95f74..cac2d97 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -537,6 +537,7 @@ struct sdhci_host { bool irq_wake_enabled; /* IRQ wakeup is enabled */ bool v4_mode; /* Host Version 4 Enable */ bool use_external_dma; /* Host selects to use external DMA */ + 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 */