Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3941501imb; Wed, 6 Mar 2019 01:06:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwktQvCbuSyO/rUJLXdnuOc+NPLmkym4zspkLbE34UJ+8uVwsLpb4Oi7eA8OOqibGlmHb0X X-Received: by 2002:a17:902:9a09:: with SMTP id v9mr5729436plp.225.1551863187512; Wed, 06 Mar 2019 01:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551863187; cv=none; d=google.com; s=arc-20160816; b=dPr9rptEQ1gAT46hQANIzYF9VDwTQLI/r5kdb/uF4H7YhHW22wo7HhmFr9i4y8R7uZ duDO/ZluS0OI2slUVv7vhqSftZ4vYAmlw5JNg0pVqsaKpm9Qatq68B4JqM6fBUfUg0NI m5mPfVuytpcnF9ANRyVLvlkDjJLsj/EJJpV7YFQYVXa118oqP0VTFjWLo8GtKrzY2I0g Zn83qHFm3z1snK4Fq2mdLU7OoyhTu3L0YyEn+p9utM3/AXv9d8jjiB9QtFIPMQcZ+Wub bD6A8jR2pccux9ozi3vZDzVrMKRLTNnMcJG1FOKtQWtIqTsUBZlIoK4rY3Svvhw9qSmg QqYw== 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:from:references:cc:to:subject; bh=Fv+jMtVQ3LP/K4HJ0wMHUW0v1seJIOOwRlsN7A2lXZ8=; b=ntqDIEzDebHyZXIiJ6GCceNLMAHTEx4iGFSnStGVS1Ktn1mPijtHEFosmCbSveVd9K QqcbUaECydnBEZ5GR2/TUSB0VdXvCBp9z2cLcxFi8QbF86SUeq4gu4q68m+zDAkm3+if bCN5qoO1JjMirO2xiT5wxjqjYJXXU0dPfYUd3fkji4wJWkwom4dOWO8sPwNn/SwbDbMR ttAqAaEC11+Zxo0C2u3M2dY8Wx4LPZaGOgZFSEwOoikKdWOPJPlx+7tBCEGHdkoquBKU BagU2T/MWwvse/yWEyZWKtkBPPUtHsLmAfADjifXbgGUtBLF7JI5PC6xE2zDVIFmYX7S sD4g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3si987763pll.417.2019.03.06.01.06.12; Wed, 06 Mar 2019 01:06:27 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729342AbfCFJEg (ORCPT + 99 others); Wed, 6 Mar 2019 04:04:36 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:57391 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726391AbfCFJEg (ORCPT ); Wed, 6 Mar 2019 04:04:36 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2693YoT032403; Wed, 6 Mar 2019 10:04:25 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2qyhkn6t96-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 06 Mar 2019 10:04:25 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8534841; Wed, 6 Mar 2019 09:04:23 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag6node1.st.com [10.75.127.16]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 53745244B; Wed, 6 Mar 2019 09:04:23 +0000 (GMT) Received: from [10.48.0.237] (10.75.127.47) by SFHDAG6NODE1.st.com (10.75.127.16) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 6 Mar 2019 10:04:22 +0100 Subject: Re: [PATCH 1/4] mmc: mmci: avoid fake busy polling To: Ulf Hansson CC: Rob Herring , Srinivas Kandagatla , Maxime Coquelin , Alexandre Torgue , Linux ARM , Linux Kernel Mailing List , DTML , "linux-mmc@vger.kernel.org" , References: <1551802205-32188-1-git-send-email-ludovic.Barre@st.com> <1551802205-32188-2-git-send-email-ludovic.Barre@st.com> From: Ludovic BARRE Message-ID: <5b531f55-b8a0-5a83-4a7c-727013a66820@st.com> Date: Wed, 6 Mar 2019 10:04:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG6NODE1.st.com (10.75.127.16) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-06_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ulf On 3/6/19 10:00 AM, Ulf Hansson wrote: > On Tue, 5 Mar 2019 at 17:10, Ludovic Barre wrote: >> >> From: Ludovic Barre >> >> The busy status bit could occurred even if no busy response is >> expected (example cmd11). On sdmmc variant, the busy_detect_flag >> reflects inverted value of d0 state, it's sampled at the end of a >> CMD response and a second time 2 clk cycles after the CMD response. >> To avoid a fake busy, the busy status could be checked and polled >> only if the command has RSP_BUSY flag. >> >> Signed-off-by: Ludovic Barre > > Before I review this, can you tell what HW you have tested this on? I tested on stm32mp157c (stm32_sdmmc variant) > > Kind regards > Uffe > >> --- >> drivers/mmc/host/mmci.c | 19 +++++++++++++------ >> 1 file changed, 13 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c >> index 387ff14..4901b73 100644 >> --- a/drivers/mmc/host/mmci.c >> +++ b/drivers/mmc/host/mmci.c >> @@ -1220,12 +1220,13 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, >> unsigned int status) >> { >> void __iomem *base = host->base; >> - bool sbc; >> + bool sbc, busy_resp; >> >> if (!cmd) >> return; >> >> sbc = (cmd == host->mrq->sbc); >> + busy_resp = !!(cmd->flags & MMC_RSP_BUSY); >> >> /* >> * We need to be one of these interrupts to be considered worth >> @@ -1239,8 +1240,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, >> /* >> * ST Micro variant: handle busy detection. >> */ >> - if (host->variant->busy_detect) { >> - bool busy_resp = !!(cmd->flags & MMC_RSP_BUSY); >> + if (busy_resp && host->variant->busy_detect) { >> >> /* We are busy with a command, return */ >> if (host->busy_status && >> @@ -1253,7 +1253,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, >> * that the special busy status bit is still set before >> * proceeding. >> */ >> - if (!host->busy_status && busy_resp && >> + if (!host->busy_status && >> !(status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT)) && >> (readl(base + MMCISTATUS) & host->variant->busy_detect_flag)) { >> >> @@ -1508,6 +1508,7 @@ static irqreturn_t mmci_irq(int irq, void *dev_id) >> { >> struct mmci_host *host = dev_id; >> u32 status; >> + bool busy_resp; >> int ret = 0; >> >> spin_lock(&host->lock); >> @@ -1550,9 +1551,15 @@ static irqreturn_t mmci_irq(int irq, void *dev_id) >> } >> >> /* >> - * Don't poll for busy completion in irq context. >> + * Don't poll for: >> + * -busy completion in irq context. >> + * -no busy response expected. >> */ >> - if (host->variant->busy_detect && host->busy_status) >> + busy_resp = host->cmd ? >> + !!(host->cmd->flags & MMC_RSP_BUSY) : false; >> + >> + if (host->variant->busy_detect && >> + (!busy_resp || host->busy_status)) >> status &= ~host->variant->busy_detect_flag; >> >> ret = 1; >> -- >> 2.7.4 >>