From patchwork Tue Oct 9 05:47:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 10631953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5254933 for ; Tue, 9 Oct 2018 05:52:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B51D12875C for ; Tue, 9 Oct 2018 05:52:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A346C28A4A; Tue, 9 Oct 2018 05:52:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 15D742875C for ; Tue, 9 Oct 2018 05:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eOZqQQ4PCLzHeY1LC+cw12egxUmpgXQ7UcNuqFJIy+4=; b=nFDlWxuEpAOS9B Tw2QCBugmsEOxO5S+vZQv+vu1+U2K8dcScDtgP1RElpT8qZ52Gma9UVtaSKD+0OHvpUti9uL9eAVv uSW+mM6hM4VHGU1iBag1L03sHpCJlCvDeEwmHZ8GSohRmEjhlpcy9X9n3kSTWyrrKsy5pdm9gwGOm RJiF7TN0Dv6K88YoX+u3AkxYEDPWj7r7kG39U8hzAHEQ9e2gg6UuaFESb87BUUwIJKT5BrpHBmIbY cH4DmQim6jZ10u2JIZ+CdKpKHjHjMnKdhfXKyaDgtTNoUBv+AbBe6i3X4IuJFodEJJhgas7c8FNmA liGcPeyiUzxQvpBpxAug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9kw4-0008V2-Ez; Tue, 09 Oct 2018 05:52:00 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9ksa-0005mq-KF for linux-arm-kernel@lists.infradead.org; Tue, 09 Oct 2018 05:48:47 +0000 Received: by mail-pl1-x642.google.com with SMTP id v5-v6so229515plz.13 for ; Mon, 08 Oct 2018 22:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z23Tjh1yqMbwhE8WbL7Mv5Y/M073KHw3jtyb5qocoBQ=; b=PbZ1lIJyVyyh3yI53kRy/FLEntyL9v3ClQWBuhzRBKXg78LnoAVfyWFgPJzoIA6L/w w3MOu5KXNdANYv8/7appfJ6EQUa/pkPyPQM50A8cZ1HiwJB6zKHRuhdXLtIkkQmOqYDh LLrEUvZiKGrnGhEON+CkLddhpseaIKTjZOK9Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z23Tjh1yqMbwhE8WbL7Mv5Y/M073KHw3jtyb5qocoBQ=; b=gfPYkaSO9HeY8rbJ7EIDf6L/XdstrNpW32KkRGK4okR7K55IeJZLkPTKboPTLYBL/V RKpDa7r/gYW32UlBYwSRuwBVOGeN3sSVfjQMK54s2lUS3BD7jQayy5dwEC6l7syf/jfF xRfUVyBWYO+UxhzeLO+RzdV2nlYqXZszqrxNqai95e197ppnCLUGDRxcza6dMCOsFOex CL9k6o94ES0SqXvV8omGsSOHmixYd0Tp9wtDrXayjgmdNF2BV5yAOVKic3tVyBOFMVfJ GKRrX+wppNL5qgs5Jfr2jaRcaGI/GUxXf+eGjRw8G99AGArVtGmlkQzckBexeeoHlkIl Olkw== X-Gm-Message-State: ABuFfoj56m3gVZel0q9DombJCsyIjYsGHXbrFOMsi8WMIBvqzBvMpmnI QM6xkx1bUecPiM2DKeCZ7H/LFg== X-Google-Smtp-Source: ACcGV615++WW5p6TKsjmAHxp8EVY43qGKMs9RmF8EHqlvjVJXxxB2ee08QLTfYReCUz3k/aBRJ0SOw== X-Received: by 2002:a17:902:50e3:: with SMTP id c32-v6mr26734108plj.194.1539064097457; Mon, 08 Oct 2018 22:48:17 -0700 (PDT) Received: from joelaf.mtv.corp.google.com ([2620:0:1000:1601:3aef:314f:b9ea:889f]) by smtp.gmail.com with ESMTPSA id a15-v6sm16886234pff.8.2018.10.08.22.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 22:48:16 -0700 (PDT) From: "Joel Fernandes (Google)" To: stable@vger.kernel.org Subject: [PATCH 7/7] dmaengine: stm32-dma: properly mask irq bits Date: Mon, 8 Oct 2018 22:47:52 -0700 Message-Id: <20181009054752.145978-8-joel@joelfernandes.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181009054752.145978-1-joel@joelfernandes.org> References: <20181009054752.145978-1-joel@joelfernandes.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181008_224824_778631_82286A64 X-CRM114-Status: GOOD ( 13.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Torgue , Vinod Koul , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, Pierre Yves MORDRET , Antonio Borneo , "Joel Fernandes \(Google\)" , Maxime Coquelin , dmaengine@vger.kernel.org, Dan Williams , "moderated list:ARM/STM32 ARCHITECTURE" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Pierre Yves MORDRET A single register of the controller holds the information for four dma channels. The functions stm32_dma_irq_status() don't mask the relevant bits after the shift, thus adjacent channel's status is also reported in the returned value. Fixed by masking the value before returning it. Similarly, the function stm32_dma_irq_clear() don't mask the input value before shifting it, thus an incorrect input value could disable the interrupts of adjacent channels. Fixed by masking the input value before using it. Signed-off-by: Pierre-Yves MORDRET Signed-off-by: Antonio Borneo Signed-off-by: Vinod Koul --- drivers/dma/stm32-dma.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c index 05a2974cd2c0..8c5807362a25 100644 --- a/drivers/dma/stm32-dma.c +++ b/drivers/dma/stm32-dma.c @@ -38,6 +38,10 @@ #define STM32_DMA_TEI BIT(3) /* Transfer Error Interrupt */ #define STM32_DMA_DMEI BIT(2) /* Direct Mode Error Interrupt */ #define STM32_DMA_FEI BIT(0) /* FIFO Error Interrupt */ +#define STM32_DMA_MASKI (STM32_DMA_TCI \ + | STM32_DMA_TEI \ + | STM32_DMA_DMEI \ + | STM32_DMA_FEI) /* DMA Stream x Configuration Register */ #define STM32_DMA_SCR(x) (0x0010 + 0x18 * (x)) /* x = 0..7 */ @@ -405,7 +409,7 @@ static u32 stm32_dma_irq_status(struct stm32_dma_chan *chan) flags = dma_isr >> (((chan->id & 2) << 3) | ((chan->id & 1) * 6)); - return flags; + return flags & STM32_DMA_MASKI; } static void stm32_dma_irq_clear(struct stm32_dma_chan *chan, u32 flags) @@ -420,6 +424,7 @@ static void stm32_dma_irq_clear(struct stm32_dma_chan *chan, u32 flags) * If (ch % 4) is 2 or 3, left shift the mask by 16 bits. * If (ch % 4) is 1 or 3, additionally left shift the mask by 6 bits. */ + flags &= STM32_DMA_MASKI; dma_ifcr = flags << (((chan->id & 2) << 3) | ((chan->id & 1) * 6)); if (chan->id & 4)