Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4222527ybb; Tue, 7 Apr 2020 03:16:04 -0700 (PDT) X-Google-Smtp-Source: APiQypLWPDWNaYS71D3C7Gry4qgh3iGrsO/9XoRBKjYccQR+r9LEWUvrrToToEEcPh7A2ZNQQj+Y X-Received: by 2002:aca:b383:: with SMTP id c125mr1018057oif.160.1586254564684; Tue, 07 Apr 2020 03:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586254564; cv=none; d=google.com; s=arc-20160816; b=j+Wtdt4X9pv3uSv/ekCQ5l4CX+rvgZBf4bZLAQ3nxLOBV8t7i6esKqF6+zmQs6zIOP B6AdMIn1ggEdzIN4YwB5Cy7f976KsTNb4UWc7+3LldkNXpBTuTmw5BeVKQvg6aHzjGOV vvnNXBK7SnMvoTn5UyeV89GzfKQoVSquXyI04mk2DoloQ88mclvyGM4y4bGRbfn9tuO0 MUQrBu2I/7DaACTBsOOFu2E9Kh70E749z19V8gB4SIB5/6isBqHXWkav9R9WnZ2T6knv G+Tz+seN8hirOh+z9ToQ4rsBfq8o6hY+oTLa28OerOkp7BH+juLveJryItbQGvuUA3dv JY9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject:ironport-sdr :ironport-sdr; bh=Wfki2Fe4cmO0/2gc8Ei/BDikPMuOvt+gyga0ReizINM=; b=MUFG/y61Cs+NFju8kfP5Jq3irhib1eohQKXZJLXfMtw+feeXYTa1jLTiL1f2u5RBA5 uX75CO9yTbEvMShnHJskJg7G5S1opsECeZMZVLK1PELTpQJ4uxEtfYawWZesI8lTsQ+7 I+dDW0guD7K8XATadzr1TT+F9E7//t3ZBCpdP744FW1oeEAFMFG1ksfJywWtGWy/ONIf owthOGpCTgK0heaq94IYFwxx1Uk69tfb4cbEBCEBkwDRPeu2CCXQ039rNceQZKR+B3U1 +7VDRLOok+tF9X56C8nXTlwP3bBuhJAXCKX1kLpjuekAszRmBjbIToNLLdh8VT3sZBam R29g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2si1038520otk.220.2020.04.07.03.15.52; Tue, 07 Apr 2020 03:16:04 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728167AbgDGKPI (ORCPT + 99 others); Tue, 7 Apr 2020 06:15:08 -0400 Received: from mga17.intel.com ([192.55.52.151]:39649 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbgDGKPH (ORCPT ); Tue, 7 Apr 2020 06:15:07 -0400 IronPort-SDR: x3U3uClDZd93FhwryB6KDY7jMud9//Hmk9LqydcA/4XTGWwSXlhkPU4TgtiA8/JpJp95dG3MHi LY8Df6UHJxhQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2020 03:15:07 -0700 IronPort-SDR: CjaCR8V+9ymL4ndQ8pNhtruwZmYMTt8pnFR7kZksUs4VylPAdNCQ1luRcDIUlm+WxD5T6W/hQ8 +XPgDau0QbMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,353,1580803200"; d="scan'208";a="330148961" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.87]) ([10.237.72.87]) by orsmga001.jf.intel.com with ESMTP; 07 Apr 2020 03:15:04 -0700 Subject: Re: [PATCH v4 1/3] mmc: host: Introduce the request_atomic() for the host To: Baolin Wang Cc: Ulf Hansson , Orson Zhai , Chunyan Zhang , Arnd Bergmann , linux-mmc , LKML References: <04c25ff9f9b17d41d734c498e4be61dee745bb30.1585896945.git.baolin.wang7@gmail.com> <5a55947b-e920-4515-49cf-163f6d539421@intel.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <5cc006fe-e5f5-b9bf-bb01-c425d943783c@intel.com> Date: Tue, 7 Apr 2020 13:14:17 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/04/20 10:21 am, Baolin Wang wrote: > On Tue, Apr 7, 2020 at 2:38 PM Adrian Hunter wrote: >> >> On 3/04/20 10:05 am, Baolin Wang wrote: >>> 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 >> >> >> One minor point below, otherwise: >> >> 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); >> >> 'ret != -EBUSY' is redundant because it is always true in the 'else' clause. > > Ah, Yes, thanks for pointing this out and I will fix it ine next version. > > By the way, could you help to review patch 2 and 3 in this patch set? Thanks. > I'd like to handle the inhibit wait differently. I will make some patches for that and send them out.