Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp516452ybx; Wed, 6 Nov 2019 04:21:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwN8rMlHKBTgbzDblQI4HOObUeADr/yHvTW2vcxp559HLkXmEV3KQQxqN9VCZqMmk1NqNZV X-Received: by 2002:a50:ff12:: with SMTP id a18mr2256766edu.200.1573042886503; Wed, 06 Nov 2019 04:21:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573042886; cv=none; d=google.com; s=arc-20160816; b=YdnTJQnsTTaSSVzAJswTrt54cfNU9cAUaSMV315oRjEqMWgGBllZALn4+3SEYCWDsH QyLzrgDPShDKBCL5imF9SVKn29zENIIk8Wh0UanDyCL4S2A3XKWtgNMzUDNsRKpheKjK jbSSaMwq4hctn8IXMGLPEA8GIGXJ3VqtX+mdb3SfIzejvnQ1eT9u3geG9Q1y02w5yeAE k0naFXyFE+HF2KiB/cNcMsFW6PvHexgHrcZK9Gfw2svIBJrnVu+tpJhswLvPrJyAvmsw NzY0TmapbW/5O58YosOEz6XoRq5z4QACwR/HJpFrgG8Fc5lcclOhYBGBFq4uSe2fqTXb jKJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pyaNKtEJ2dhdRbX0XGG2IskdfPoKWgFFcpf2S2Y9JTA=; b=D+nM2yKqBpRa+6HsMSZlbi+azYOvGKdONe1OPTI3yvBMS20fbmUMSV6bJe5KJheCaS VZXCHACjv8t5SqmImPTjiWnIrIf0LH0xo/NDtQiecUHoMBilBT48F3cZbibCY01TTe8s 5uthuSdyQwgCVNMoewXRwb3GkNOQm95bjC8LXEUJtYq+2oFp1ZF5YmOsV+1rHQJKNPlM VIEV8svJfalBdV4zkWkKBpg2VaARhiwKOFHLT+Gj4mhyozNZRg59ZCz5zg3E4xvzPmqr wwnhxpTcUGOaIZN86094NmAk7JF7dxUVFECrZn9xSh97IYA/Qgg1GKM6jOy6EDJDZKv2 /0AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QpM1stPs; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b27si12482333ede.204.2019.11.06.04.21.02; Wed, 06 Nov 2019 04:21:26 -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=@linaro.org header.s=google header.b=QpM1stPs; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731302AbfKFMRr (ORCPT + 99 others); Wed, 6 Nov 2019 07:17:47 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:34365 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730501AbfKFMRr (ORCPT ); Wed, 6 Nov 2019 07:17:47 -0500 Received: by mail-lf1-f67.google.com with SMTP id f5so17892023lfp.1 for ; Wed, 06 Nov 2019 04:17:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pyaNKtEJ2dhdRbX0XGG2IskdfPoKWgFFcpf2S2Y9JTA=; b=QpM1stPsxibreOYhSOYUvFH3b58z/8EkMAfLRJIfpyMKCIlh9GtTXfpiruDZlg8eht r2JBScHEAOT2u0L9HZ+5bAYM9jptDj61F9/f6V+0yodOwA58RwzbAbAwKKBkZeB8FyYu Agf48Vn+n4ExxJBgcjkDJjwCA94IHRIGaT549OBxaDMCxvilIbJHMJuUPqsEaI+RjiWT IeRQp0/t5wvonASnw0GmcIyzxvHahqQRYLNqbNgmErk89iUHiA7j1+BsDWN1HY+/qcTj isnsKQqi2JOPJX1VmctAkMgJLB3Cqudx0+Jsq1dQwKR6QqaUSlyDCnMjsi+27R8riVkZ E0UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pyaNKtEJ2dhdRbX0XGG2IskdfPoKWgFFcpf2S2Y9JTA=; b=mYnrbH41enXftdT5LHBQn/1LEYtw5Q/CdX8Kq/KgPY3m0HlmzzdtixJAaBKUgIC+D3 BBmOsm1Xj+nMk4yS+3S4gvrT+hgUevpgOJxxktsLprPg2qPkhREESp3cqxDYRXh9U/dc jANYT6Sow4bazXOR5y2RKx8vh88OS/9LYF1Tad/m3WiyA+LhJXMYXx0Nj2mL6RgYxT0W izR3kp8dx/S1eOvXhhPmbQeH9I5UChXy1I7GXmEVmknPsSI9QZaoKVpZ4q536+MoQoGz qj9OepYzGQdbSRSDssF6o5vKDfaBnk1B/hFmZEWiai8yoryBfYWFo0KQsXV/SpMSNtQS zmFw== X-Gm-Message-State: APjAAAXIsO6LU8EM6H0r976a6rSZFJ6jgBWhkXUrCYCuQaDxTuMOvcys yXQaKSXkg7NEYU++kXH6jq2hFGY3YQVeWhqJDLpZQw== X-Received: by 2002:a19:a40c:: with SMTP id q12mr11951247lfc.65.1573042664331; Wed, 06 Nov 2019 04:17:44 -0800 (PST) MIME-Version: 1.0 References: <19910a2f34b9be81f64637a5a5fc8d07bd5f4885.1572326519.git.baolin.wang@linaro.org> <2ed0bcd1-fa74-d095-97ee-7d0c46a4fdbb@intel.com> In-Reply-To: <2ed0bcd1-fa74-d095-97ee-7d0c46a4fdbb@intel.com> From: Baolin Wang Date: Wed, 6 Nov 2019 20:17:33 +0800 Message-ID: Subject: Re: [PATCH v5 4/4] mmc: host: sdhci: Add a variable to defer to complete data requests if needed To: Adrian Hunter Cc: Ulf Hansson , asutoshd@codeaurora.org, Orson Zhai , Chunyan Zhang , Arnd Bergmann , Linus Walleij , Vincent Guittot , baolin.wang7@gmail.com, linux-mmc , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 6 Nov 2019 at 20:02, Adrian Hunter wrote: > > On 6/11/19 12:48 PM, Baolin Wang wrote: > > On Wed, 6 Nov 2019 at 18:10, Adrian Hunter wrote: > >> > >> On 29/10/19 7:43 AM, Baolin Wang wrote: > >>> 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. > >>> > >>> Thus we still need introduce a variable in struct sdhci_host to indicate > >>> that we will always to defer to complete data requests if the sdhci_request() > >>> can not be called in interrupt context for some host drivers, when using > >>> the host software queue. > >>> > >>> Suggested-by: Adrian Hunter > >>> 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 850241f..9cf2130 100644 > >>> --- a/drivers/mmc/host/sdhci.c > >>> +++ b/drivers/mmc/host/sdhci.c > >>> @@ -3035,7 +3035,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 && data) || > > To move ahead in the meantime without a new host API, just defer always i.e. OK. And I'll wait for a while to see if Ulf will post some comments for this patch set before new version. Thanks. > > + return host->pending_reset || host->always_defer_done || > > >> > >> I didn't realize you still wanted to call the request function in interrupt > >> context. In my view that needs a new host API > >> i.e. int (*request_atomic)(struct mmc_host *mmc, struct mmc_request *mrq) > > > > Actually there are no documentation said that the > > mmc_host_ops->request() is a sleepable API, so I introduce a > > host->always_defer_done flag to decide if the request can be called in > > interrupt context or not, since for some host drivers, the request() > > implementation can be called in interrupt context. > > > > Yes, I agree a new host API is more reasonable, if you do not like the > > current approach, I can add new patches to introduce the new > > request_atomic() API. But can I create another separate patch set to > > do this? since in this patch set, the Spreadtrum host driver's > > request() implementation can be called in interrupt context. Or you > > still want these changes introducing new request_atomic() can be done > > in this patch set? Thanks. > > > >> > >>> ((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 d89cdb9..38fbd18 100644 > >>> --- a/drivers/mmc/host/sdhci.h > >>> +++ b/drivers/mmc/host/sdhci.h > >>> @@ -533,6 +533,7 @@ struct sdhci_host { > >>> bool pending_reset; /* Cmd/data reset is pending */ > >>> bool irq_wake_enabled; /* IRQ wakeup is enabled */ > >>> bool v4_mode; /* Host Version 4 Enable */ > >>> + bool always_defer_done; /* Always defer to complete data requests */ > >>> > >>> struct mmc_request *mrqs_done[SDHCI_MAX_MRQS]; /* Requests done */ > >>> struct mmc_command *cmd; /* Current command */ > >>> > >> > > > > > -- Baolin Wang Best Regards