Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp664242ybl; Wed, 11 Dec 2019 05:41:10 -0800 (PST) X-Google-Smtp-Source: APXvYqwLezMGgst1IA8Cb4oyKrUZKibF6NQhkc0i7mxF7/xDxXSreVyGr56ibKMkVL8iKkiUc2Mv X-Received: by 2002:a54:400a:: with SMTP id x10mr2892873oie.67.1576071670461; Wed, 11 Dec 2019 05:41:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576071670; cv=none; d=google.com; s=arc-20160816; b=qGT09pt9Niwa9zPWcKhAhpe83F5Iv4dBFJKZeJcGFk8ArUThADyS/Tta0sJVxIXJb8 Xfn6j/cVSCVf/Lx/YFZ8FhhZBjiCyf29Uymgmta9vfmL/yCJ0EpnM51i+VlNdhhiYgVb y0CY8n3ErD4sEOD9K10C/VwL23ZAVyMXpuHTaNVks2dFH0OFmvZFzLPXbBMkmSd0tfg0 UxJoFhq5ln4LzjueZylv2zJhMDcCD0mO16GaxJO518J+4QmrLGtNuF5QH6fJ0NiJm4X4 MN7SSc8zgF5t3J573hikycJO2gqmE4VNHzPooj0TWbyYNkIShqbiM2xl2RRlt3Ct5JYh OXHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=yAqm9sZp35cLmzHCOHCPDTCRBjuP7SiwSxl28sXlrQg=; b=DVvW3tSUz9hkpUK8I6gaS6kVYGzARX2TCgDlYbO4JMLtpMZt6gKdQyGbCFMiSf+6Ei of62BTjkkhsTZKv12N32PgVd2xfHo++3gogwj0+FXzJv1M6p8TyuG+2wYL8Kd3m+n70l Io5vkG9oniPU8UmABOvWBYJaJWFYyhpReXCGM4ZpYAQ1fFSG9fS8uLaDpLCCNgqwQBah Q6dM2EMigb2Vaoro+TB4Hv6i0RoKcx5FLVB3CgTSDNG4L13M6qHH03mzOcslhQNEEg50 gJttP7eldjKLZPYJa7TIH5rXbQA6PWn855rL4PoDeWr62ck0KeRk6qzjJGt7tD+wDUjG 0Y7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=UMp7LFUI; 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 s206si1221921oib.73.2019.12.11.05.40.58; Wed, 11 Dec 2019 05:41:10 -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=UMp7LFUI; 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 S1729674AbfLKNkW (ORCPT + 99 others); Wed, 11 Dec 2019 08:40:22 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:31774 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729438AbfLKNkV (ORCPT ); Wed, 11 Dec 2019 08:40:21 -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 xBBDb2YD005490; Wed, 11 Dec 2019 14:40:10 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=yAqm9sZp35cLmzHCOHCPDTCRBjuP7SiwSxl28sXlrQg=; b=UMp7LFUIJcMpL/ztTzkeuNKPIoW5d2MdO7D/MLpo+4fZDT9Cmc1SpOSuw/HEaQMgQKJo EK+l8gh7NZ4ruBUdTHv11v+53EQwTcTh10rqgrckblxKuuNoQh8P0BaRMyVjb9drkOUj 6OAx/XUm9yn8OQkniTn9nqFn7A3ljOC04dz5GZtlxxG9nJvTtgb8u1JcYS0xgm+sm7HN 9q6AN822uTyn3MkRPFVHWWINqeq4T9JmDeZeuYeZ7sbng+4n50HqbhZlmi5Q2MvAD/LV W7VhrIXpwcVGfzIxguHIrjZpiiFyZOAkMEVxJJYn+O800N1tH5NgZn0DX8wcUljM+H0a pQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2wrbrfjcgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Dec 2019 14:40:10 +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 3F3E5100038; Wed, 11 Dec 2019 14:40:08 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag6node1.st.com [10.75.127.16]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 2C32A2B5440; Wed, 11 Dec 2019 14:40:08 +0100 (CET) Received: from lmecxl0923.lme.st.com (10.75.127.47) by SFHDAG6NODE1.st.com (10.75.127.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 11 Dec 2019 14:40:07 +0100 From: Ludovic Barre To: Ulf Hansson , Rob Herring CC: , Maxime Coquelin , Alexandre Torgue , , , , , , Ludovic Barre Subject: [PATCH V2] mmc: mmci: add threaded irq to abort DPSM of non-functional state Date: Wed, 11 Dec 2019 14:39:34 +0100 Message-ID: <20191211133934.16932-1-ludovic.Barre@st.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) 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-12-11_03:2019-12-11,2019-12-11 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Like a reset must be outside of critical section, this patch adds 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 --- change V2: -check IRQ_WAKE_THREAD only in mmci_cmd_irq error part, to avoid this test in mmci_request_end. --- drivers/mmc/host/mmci.c | 46 +++++++++++++++++++++++++++++++++++------ drivers/mmc/host/mmci.h | 1 + 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 40e72c30ea84..2b91757e3e84 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1321,6 +1321,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); @@ -1339,7 +1340,10 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, return; } } - mmci_request_end(host, host->mrq); + + if (host->irq_action != IRQ_WAKE_THREAD) + mmci_request_end(host, host->mrq); + } else if (sbc) { mmci_start_command(host, host->mrq->cmd, 0); } else if (!host->variant->datactrl_first && @@ -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); 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