Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4585247ybc; Fri, 15 Nov 2019 07:01:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyzDVjcs9jbLQ4/LqoopR3mWbSkd08o+9KEkxvwLq+taSLqCTM0mDna8IXAkDAC7cSnC/SR X-Received: by 2002:a5d:526f:: with SMTP id l15mr15412696wrc.169.1573830103087; Fri, 15 Nov 2019 07:01:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573830103; cv=none; d=google.com; s=arc-20160816; b=HVeZHjaw6ssjVKiaxdNH9+SOFOpEfHc174HSjU/zQkPibnJjn4kYCLdJ2zw3HqCrab cASwTdhSohuwomcz1tIIldm/ZYLki4jVr2OV+edGv3MmJe3KQs/YRNwt1ozFiPLqBaOe h3UvSG+WXYgfsLRG7mtCgg4Jwj0MA+xDDlgwYGWcBqw73TUXi/mL33/jRSWiJLiAPdpS vV/tUevX71mHkqdQERtusGC1NmMLVXYPCABfoFvjlbC7Rp4uyFvqW/n0AK8gJS4U3hV/ ZF7Bcxa0llleymr3bL9y/wDOngsEp53hcJ5sBq9zf5JqsglCSHHd1+BaHRrafVb09UGG HQ1w== 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:dkim-signature; bh=FTENcbU0iOl2dVpbEg+JvzJowB9OWl4cNDXi2mw6WWo=; b=w9ixjV5J4LMvDgeT3Sus/Gh/PUzBwgitJd1o9bEBnEe+Ksjv9wmLNpWoOVounHopSe wFdpPqiBBVQ5PFHPPyiiEfTVuX5Yv0e+AzEcTJVVNkfBqc6BrMxxd2flC9aYsDabUuAd sdPW83IQq+S+u8WZEyENvfyl3q47jtxx7f7vCziQFBfS3qS9ri2Mo4kuvNms3ZGoP+H1 EmQRVNhiMPkO0L/fSXlEGy2dc5pul9z5IU5w2rc6g6M5aRNANAmqysjspgq2fblw9NKx afB88t2EQsSRYP6XLPaehrvHCxrqieUpAuzxpe2e3dgY6DDocnCJTNN+8EztTHttdNBE PWaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=nAUkjJLX; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si6284599eds.63.2019.11.15.07.01.16; Fri, 15 Nov 2019 07:01:43 -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=@st.com header.s=STMicroelectronics header.b=nAUkjJLX; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727632AbfKOPAD (ORCPT + 99 others); Fri, 15 Nov 2019 10:00:03 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:3870 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727472AbfKOPAC (ORCPT ); Fri, 15 Nov 2019 10:00:02 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAFEv8bs026219; Fri, 15 Nov 2019 15:59:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=FTENcbU0iOl2dVpbEg+JvzJowB9OWl4cNDXi2mw6WWo=; b=nAUkjJLXKxbDA8uIfdGOiOIF0d7KgGGJTa6azZxY44JITDPC2BQk54SL8iCLFlUgjmuH Sg9YA18N55HrzFzkdmVpp6sw2PeRqTCeGIepmzx8FSMHTvdx3TdDRh4S7Sby0TOTYfu0 wX2POVYXPb6yF8rETrfBcyvQ7C83Pmv+T9oTqr4P8Vvo4F6t8O9VKWXQyucpGqGosSSM YlKttm9HmdBRTcFfysHIJpD5RtvL8eJXXcBUUDA6x0sNHHV2biXPBkOLttViOVfvPxC8 2wvpgmRY6J+GvXNPrdC2zpqzl4kAT4zzxCu0MH848WqO/qFN/o2AjpajdO4RKDg2Vql5 2w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2w7psfmxbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Nov 2019 15:59:49 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 22C56100034; Fri, 15 Nov 2019 15:59:49 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag6node1.st.com [10.75.127.16]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0F6C82C01FD; Fri, 15 Nov 2019 15:59:49 +0100 (CET) Received: from lmecxl0923.lme.st.com (10.75.127.50) by SFHDAG6NODE1.st.com (10.75.127.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 15 Nov 2019 15:59:47 +0100 Subject: Re: [PATCH 1/1] mmc: mmci: add threaded irq to abort DPSM of non-functional state 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: <20191113172514.19052-1-ludovic.Barre@st.com> From: Ludovic BARRE Message-ID: Date: Fri, 15 Nov 2019 15:59:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG3NODE2.st.com (10.75.127.8) To SFHDAG6NODE1.st.com (10.75.127.16) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-15_04:2019-11-15,2019-11-15 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi Ulf Le 11/14/19 à 4:09 PM, Ulf Hansson a écrit : > On Wed, 13 Nov 2019 at 18:25, Ludovic Barre wrote: >> >> From: Ludovic Barre >> >> If datatimeout occurs on R1B request, the Data Path State Machine stays >> in busy and is non-functional. Only a reset aborts the DPSM. > > Please clarify/extend this information to tell that this is for the > variant, that keeps DPSM enabled and uses the data timer while sending > a CMD12. Or something along those lines. > yes, of course. >> >> Like a reset must be outside of critical section, this patch adds > > /s/critical section/atomic context OK, thanks > >> threaded irq function to release state machine. In this case, >> the mmc_request_done is called at the end of threaded irq and >> skipped into irq handler. >> >> Signed-off-by: Ludovic Barre >> --- >> drivers/mmc/host/mmci.c | 44 ++++++++++++++++++++++++++++++++++++----- >> drivers/mmc/host/mmci.h | 1 + >> 2 files changed, 40 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c >> index 40e72c30ea84..ec6e249c87ca 100644 >> --- a/drivers/mmc/host/mmci.c >> +++ b/drivers/mmc/host/mmci.c >> @@ -556,6 +556,9 @@ static void mmci_dma_error(struct mmci_host *host) >> static void >> mmci_request_end(struct mmci_host *host, struct mmc_request *mrq) >> { >> + if (host->irq_action == IRQ_WAKE_THREAD) >> + return; >> + >> writel(0, host->base + MMCICOMMAND); >> >> BUG_ON(host->data); >> @@ -1321,6 +1324,7 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, >> } else if (host->variant->busy_timeout && busy_resp && >> status & MCI_DATATIMEOUT) { >> cmd->error = -ETIMEDOUT; >> + host->irq_action = IRQ_WAKE_THREAD; >> } else { >> cmd->resp[0] = readl(base + MMCIRESPONSE0); >> cmd->resp[1] = readl(base + MMCIRESPONSE1); >> @@ -1532,9 +1536,9 @@ static irqreturn_t mmci_irq(int irq, void *dev_id) >> { >> struct mmci_host *host = dev_id; >> u32 status; >> - int ret = 0; >> >> spin_lock(&host->lock); >> + host->irq_action = IRQ_HANDLED; >> >> do { >> status = readl(host->base + MMCISTATUS); >> @@ -1574,12 +1578,41 @@ static irqreturn_t mmci_irq(int irq, void *dev_id) >> if (host->variant->busy_detect_flag) >> status &= ~host->variant->busy_detect_flag; >> >> - ret = 1; >> } while (status); >> >> spin_unlock(&host->lock); >> >> - return IRQ_RETVAL(ret); >> + return host->irq_action; >> +} >> + >> +/* >> + * mmci_irq_threaded is call if the mmci host need to release state machines >> + * before to terminate the request. >> + * If datatimeout occurs on R1B request, the Data Path State Machine stays >> + * in busy and is non-functional. Only a reset can to abort the DPSM. >> + */ >> +static irqreturn_t mmci_irq_threaded(int irq, void *dev_id) >> +{ >> + struct mmci_host *host = dev_id; >> + unsigned long flags; >> + >> + if (host->rst) { >> + reset_control_assert(host->rst); >> + udelay(2); >> + reset_control_deassert(host->rst); >> + } >> + >> + spin_lock_irqsave(&host->lock, flags); >> + writel(host->clk_reg, host->base + MMCICLOCK); >> + writel(host->pwr_reg, host->base + MMCIPOWER); >> + writel(MCI_IRQENABLE | host->variant->start_err, >> + host->base + MMCIMASK0); >> + >> + host->irq_action = IRQ_HANDLED; >> + mmci_request_end(host, host->mrq); >> + spin_unlock_irqrestore(&host->lock, flags); >> + >> + return host->irq_action; >> } >> >> static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq) >> @@ -2071,8 +2104,9 @@ static int mmci_probe(struct amba_device *dev, >> goto clk_disable; >> } >> >> - ret = devm_request_irq(&dev->dev, dev->irq[0], mmci_irq, IRQF_SHARED, >> - DRIVER_NAME " (cmd)", host); >> + ret = devm_request_threaded_irq(&dev->dev, dev->irq[0], mmci_irq, >> + mmci_irq_threaded, IRQF_SHARED, >> + DRIVER_NAME " (cmd)", host); > > In general it's a good idea to move drivers into using a threaded IRQ handler. > > However, the reason this hasn't been done for mmci before, is because > there are some legacy variants, that doesn't support HW flow control. With this patch, the mmci_irq_threaded is called only when a datatimeout occurs on R1B request else the mmci_irq return IRQ_HANDLED and the threaded irq is not called. So normally, there is no impact for legacy variants. > > Unless I am mistaken, that means when the fifo gets full during data > transfers - it's too late to act. In other words, running the handler > in hard IRQ context, should increase the probability of not missing > the deadline. > > If a threaded IRQ handler also is sufficient for these legacy > variants, only tests can tell. > > An option, would be to use a threaded handler for those variants that > supports HW flow control. Not sure how messy the code would be with > this option, perhaps you can give this a try? For all these reasons you mentioned above, I'm not sure it's safe to extend the thread manager to anything other than "aborting the DPSM" on R1B datatiemout ? what do you think about that? I prefer just used the irq threaded for specific errors case which need be outside of atomic context. > > >> if (ret) >> goto clk_disable; >> >> diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h >> index 158e1231aa23..5e63c0596364 100644 >> --- a/drivers/mmc/host/mmci.h >> +++ b/drivers/mmc/host/mmci.h >> @@ -412,6 +412,7 @@ struct mmci_host { >> >> struct timer_list timer; >> unsigned int oldstat; >> + u32 irq_action; >> >> /* pio stuff */ >> struct sg_mapping_iter sg_miter; >> -- >> 2.17.1 >> > > Kind regards > Uffe >