Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1310076pxb; Fri, 20 Nov 2020 06:36:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJybvOc5otwp+HJ7pBdxE/RCtEkqotf+UoV171blzPNu156lC4dxjCM7aq+P3vXMGK+x9iPp X-Received: by 2002:a17:907:40c7:: with SMTP id nv7mr10311403ejb.325.1605882985099; Fri, 20 Nov 2020 06:36:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605882985; cv=none; d=google.com; s=arc-20160816; b=JAE6/u1jlVzCnTuf7GHh/BkE2U+LDDxFkehuDEe7KIOf5PxJfSq27csL+M+45PJaF5 oWr9HnJ+nhd0yBiL4Wn/VNfuPNEl92FXL4w86JBUXd5IT64D/DACy5vi9Ce4X1qUgH1X 9wU4f2e3csgQiA3+c70ykrWKfjuF3YCzltU13KTBbOy4/6s1MSRI7lovP93jc5afkId9 4FEvI/2lctyMj8tSadqeb2DBg0l7A7WQ6Pkzmdryfrmj5aLTfRnIJ3rHTHMNEQE6yjJH HKf3JnDoAAF3m9O4fpeuR0NWhEdWUN5geOs/1PW3dDJVqhbSYbhvsNA3cvjS8KHrlEBx L57Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=E9kJGNt1mLYDS6pj2G2ES1qpvtEVVewRXb6bBj3rbxA=; b=Tc8jGeACStnNI9NihBom3dGymUToUDAGvSqYjTPPwKrk25bRMR7QVa91nBKSmc9VIU RgW8xtG/5iW7NAlfPyfI3j/Uu9YBFzvi4caNQeRccD+yB3FjpZjKIIMHhDxNJ7mkg3pQ rsjk4+5pnPhhs+eZWKmiTAwoFXrYLE90hX65932TPZhenWNs9d+5SBvgcZ/1VZNMTKJT k0VTyfnkThPVX2QBo6ZqRfC9m/+FPaAxACRMB39Wb5/YyXqQtq0oVK/sAT3SzIo/1USD 1Cfwu+CeZH/naaYmxrq4kMIqo3nVkwYJJlRHpvK4/A6zDQsKQjVfeSYaYB12AbCUzvuU qaew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=syq32dy8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n22si1767628ejo.705.2020.11.20.06.36.00; Fri, 20 Nov 2020 06:36:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=syq32dy8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728017AbgKTOdt (ORCPT + 99 others); Fri, 20 Nov 2020 09:33:49 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:23978 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727682AbgKTOdo (ORCPT ); Fri, 20 Nov 2020 09:33:44 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AKEXHHZ018448; Fri, 20 Nov 2020 15:33:31 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=E9kJGNt1mLYDS6pj2G2ES1qpvtEVVewRXb6bBj3rbxA=; b=syq32dy8KOR8+W6S9XbTrUN8OtoTFu9XbAt95eZKm3nxu/LOC7xqleI7LiEsnxZZJoOD E74I2UcMKSEUNe43XwKH+5eOb6K/AJ/mZsMoZt/7FJcvkxRV4OXoG4OIa22pnQ6WsEbt WCuiZjFeIip7oFAsDBVgCYvvPeqQpJKZC5PLc+xpUCXK9o4dtM5tpRM7/RCkbZzEjP2u /5/ec6CeI6bACw5ZihM5rOvoEauDAvshtks78TCC/oMQMa3i14ueNHWTi9bdni7IcKjn O40bhlxxX3d4H5UGbuUBkGJ5mUcORIogyvm9N5HPMeoRo6xy5cFDlft4yD/GKfUyBZjH WQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 34t58d7ufa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Nov 2020 15:33:31 +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 EEDB910002A; Fri, 20 Nov 2020 15:33:30 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E31FE2777DE; Fri, 20 Nov 2020 15:33:30 +0100 (CET) Received: from localhost (10.75.127.45) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 20 Nov 2020 15:33:30 +0100 From: Amelie Delaunay To: Vinod Koul , Dan Williams , Maxime Coquelin , Alexandre Torgue CC: , , , , Amelie Delaunay , Pierre-Yves MORDRET Subject: [PATCH 4/4] dmaengine: stm32-mdma: rework interrupt handler Date: Fri, 20 Nov 2020 15:33:20 +0100 Message-ID: <20201120143320.30367-5-amelie.delaunay@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201120143320.30367-1-amelie.delaunay@st.com> References: <20201120143320.30367-1-amelie.delaunay@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG3NODE2.st.com (10.75.127.8) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-20_07:2020-11-20,2020-11-20 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To avoid multiple entries in MDMA interrupt handler for each flag&interrupt enable, manage all flags set at once. Signed-off-by: Amelie Delaunay --- drivers/dma/stm32-mdma.c | 64 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c index 29e5e30524bb..e4637ec786d3 100644 --- a/drivers/dma/stm32-mdma.c +++ b/drivers/dma/stm32-mdma.c @@ -1346,7 +1346,7 @@ static irqreturn_t stm32_mdma_irq_handler(int irq, void *devid) { struct stm32_mdma_device *dmadev = devid; struct stm32_mdma_chan *chan = devid; - u32 reg, id, ien, status, flag; + u32 reg, id, ccr, ien, status; /* Find out which channel generates the interrupt */ status = readl_relaxed(dmadev->base + STM32_MDMA_GISR0); @@ -1368,67 +1368,71 @@ static irqreturn_t stm32_mdma_irq_handler(int irq, void *devid) chan = &dmadev->chan[id]; if (!chan) { - dev_dbg(mdma2dev(dmadev), "MDMA channel not initialized\n"); - goto exit; + dev_warn(mdma2dev(dmadev), "MDMA channel not initialized\n"); + return IRQ_NONE; } /* Handle interrupt for the channel */ spin_lock(&chan->vchan.lock); - status = stm32_mdma_read(dmadev, STM32_MDMA_CISR(chan->id)); - ien = stm32_mdma_read(dmadev, STM32_MDMA_CCR(chan->id)); - ien &= STM32_MDMA_CCR_IRQ_MASK; - ien >>= 1; + status = stm32_mdma_read(dmadev, STM32_MDMA_CISR(id)); + /* Mask Channel ReQuest Active bit which can be set in case of MEM2MEM */ + status &= ~STM32_MDMA_CISR_CRQA; + ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(id)); + ien = (ccr & STM32_MDMA_CCR_IRQ_MASK) >> 1; if (!(status & ien)) { spin_unlock(&chan->vchan.lock); - dev_dbg(chan2dev(chan), - "spurious it (status=0x%04x, ien=0x%04x)\n", - status, ien); + dev_warn(chan2dev(chan), + "spurious it (status=0x%04x, ien=0x%04x)\n", + status, ien); return IRQ_NONE; } - flag = __ffs(status & ien); - reg = STM32_MDMA_CIFCR(chan->id); + reg = STM32_MDMA_CIFCR(id); - switch (1 << flag) { - case STM32_MDMA_CISR_TEIF: - id = chan->id; - status = readl_relaxed(dmadev->base + STM32_MDMA_CESR(id)); - dev_err(chan2dev(chan), "Transfer Err: stat=0x%08x\n", status); + if (status & STM32_MDMA_CISR_TEIF) { + dev_err(chan2dev(chan), "Transfer Err: stat=0x%08x\n", + readl_relaxed(dmadev->base + STM32_MDMA_CESR(id))); stm32_mdma_set_bits(dmadev, reg, STM32_MDMA_CIFCR_CTEIF); - break; + status &= ~STM32_MDMA_CISR_TEIF; + } - case STM32_MDMA_CISR_CTCIF: + if (status & STM32_MDMA_CISR_CTCIF) { stm32_mdma_set_bits(dmadev, reg, STM32_MDMA_CIFCR_CCTCIF); + status &= ~STM32_MDMA_CISR_CTCIF; stm32_mdma_xfer_end(chan); - break; + } - case STM32_MDMA_CISR_BRTIF: + if (status & STM32_MDMA_CISR_BRTIF) { stm32_mdma_set_bits(dmadev, reg, STM32_MDMA_CIFCR_CBRTIF); - break; + status &= ~STM32_MDMA_CISR_BRTIF; + } - case STM32_MDMA_CISR_BTIF: + if (status & STM32_MDMA_CISR_BTIF) { stm32_mdma_set_bits(dmadev, reg, STM32_MDMA_CIFCR_CBTIF); + status &= ~STM32_MDMA_CISR_BTIF; chan->curr_hwdesc++; if (chan->desc && chan->desc->cyclic) { if (chan->curr_hwdesc == chan->desc->count) chan->curr_hwdesc = 0; vchan_cyclic_callback(&chan->desc->vdesc); } - break; + } - case STM32_MDMA_CISR_TCIF: + if (status & STM32_MDMA_CISR_TCIF) { stm32_mdma_set_bits(dmadev, reg, STM32_MDMA_CIFCR_CLTCIF); - break; + status &= ~STM32_MDMA_CISR_TCIF; + } - default: - dev_err(chan2dev(chan), "it %d unhandled (status=0x%04x)\n", - 1 << flag, status); + if (status) { + stm32_mdma_set_bits(dmadev, reg, status); + dev_err(chan2dev(chan), "DMA error: status=0x%08x\n", status); + if (!(ccr & STM32_MDMA_CCR_EN)) + dev_err(chan2dev(chan), "chan disabled by HW\n"); } spin_unlock(&chan->vchan.lock); -exit: return IRQ_HANDLED; } -- 2.17.1