Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp242704ybv; Wed, 5 Feb 2020 04:53:07 -0800 (PST) X-Google-Smtp-Source: APXvYqyUXdhb3ni94TAS8/dLqetP+5/THEJjLCCHtLgoKW+eLCQx8C7c+ZNYGzSyIe4gIk7jEJlf X-Received: by 2002:a54:4418:: with SMTP id k24mr2791064oiw.46.1580907187139; Wed, 05 Feb 2020 04:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580907187; cv=none; d=google.com; s=arc-20160816; b=xjlPtrVtHSd42+6L3CqWXukAFpgmA7c6NpUMbF/lX5K5gY7LCzUW3cAvBJCYdH1+EM xz0FTIt4G2JK1chvEw7PJFa0jeflOZJ01W3ak9SI/bWZY1RkpC993rdoGzOX/H6fFI5E VDQcrekl8xN2/9E6euEG2UprQa/DEj5BzQmIYGQ6CVIGk8ckrS/CjJVtHeFXlio/LvZs pMp6I0wkEAwlWKKIhA5arILItDWG1vF7/Q5G/l5RjDVm126fqcQdQvn5fwRn5d7+3wfx 33B49gQen0vMRRxw16fsce8Mwcosj2gouyG06PxjVWdicmt0TqS3x72RZhxjCu10el2H +VWA== 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=qXFSOdJFY54Rwc/1S4vXiFbbifW3bH93ZRFzyBvbEM0=; b=m+6Q+PTe/+JcBkpGUVdKxGzxgWUhODCSne8TNMOzK5b7T8OgRW2/9QQwoxQlDvfTDL PAt68o5bz8k9sQ7WuwdIVFr8SKIXe7cxbVc49XgO9V5jAl0kO76lz08H0FKqvSwzBkEi oTbL84RiGBIM5uX/L3fn/uQ2Dc61OaXAPecFEc6tB2OTAjmlep3FaZUJJ8PhNHAvr+nY i7PRAPjto4IuH+6gjXkUwfHeLvCYmiQmfgXE5OWYI2heMnFKCvMxXWL96t83HFeJ51ql 33JukTV2Corh8RoZNQVzLfYYjQ++Jp5BOmP9b2ADeiyuaNweZFgbSePTreSDWRWclyNK pm9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PqK8prlj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a25si8110803otr.39.2020.02.05.04.52.54; Wed, 05 Feb 2020 04:53:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@gmail.com header.s=20161025 header.b=PqK8prlj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728109AbgBEMvc (ORCPT + 99 others); Wed, 5 Feb 2020 07:51:32 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:55723 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728094AbgBEMvb (ORCPT ); Wed, 5 Feb 2020 07:51:31 -0500 Received: by mail-pj1-f68.google.com with SMTP id d5so941423pjz.5; Wed, 05 Feb 2020 04:51:30 -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=PqK8prljZrh8Nl09N/AoAVTK4xaSUk222FtX0iOIv5d7HaHwIloY88/YO3i1r7jFcQ IRsyA1hnh8T364CkFBfs8D95p2pgdi/QjgzUepSOWpc/C1NqmzRcpsYGbyuRRYKzrpN2 F4hNclJnsWtTYSesPMcbOAPWdHGHIWBiMTdHWaxVlDsUsLSt8SDKbGkNyhSvvvcPwdh8 99gDupRFG7Tgnd6olFlUrnRQXKaCXT2UMS8S0mTG6UFHahmeQpIbj7s3dS9V30BE3gpO /nBwM0msmy3ceE6XEDvmzdLEHPUgbj0HLjD9s8I8zqyiwxiTN1JOD375+dJxtPJ1KbUn oppg== 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=QAElIwRXnJGytcVpZygqYXuAR2I6FnRxT70W/neuoizY+MRnfp0+n+MSGkj+z2+AjN 5wBZKPcEnAP1oNc1RUTeCOvYhuhUSrLeZaUttrn70ya9DGsIqAiWF2vPMT7Pd+qSeKaJ 37h2kPQRqZUhB6qUxFRaD2JN/xWtWb9ykbD9IZSWZWpTzSgubXz7MiMRyBOQfy3KEPo3 HOzuUMOoGq5Lr/txW8pArIuRM9Ex1RWnlX+Ffvw79db11yoHMfPhRXIYWip63Etl5rsb Qzh1bTk68YJBW0UMeGAHnrseGb/3Qt7aXIPHjzEymSGs7vjoLEge5X378i5Q9XaMRF2H BczQ== X-Gm-Message-State: APjAAAUnQYh19zTYowHl48Ywoq4eMYghChUaeZMsxCD4kmQyVMauLGbl ZTZtqPFB9OPpMLWOALmbWl4= X-Received: by 2002:a17:902:463:: with SMTP id 90mr36624355ple.213.1580907090390; Wed, 05 Feb 2020 04:51:30 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id y127sm22864784pfg.22.2020.02.05.04.51.27 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Feb 2020 04:51:30 -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 v8 4/5] mmc: host: sdhci: Add a variable to defer to complete requests if needed Date: Wed, 5 Feb 2020 20:50:31 +0800 Message-Id: <99f715b4b442d196bd7127cb6264b804219036ad.1580894083.git.baolin.wang7@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 */ -- 1.7.9.5