From patchwork Fri Feb 24 15:22:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Povi=C5=A1er?= X-Patchwork-Id: 13151399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07CF8C61DA4 for ; Fri, 24 Feb 2023 15:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Kjdeq72Ucxpnb8YMzYrvAaDeRC+LVKt8yet9jy9xEAw=; b=rg0b3G2VQesi5d XvL4aT6QRpfccnuADQCugyleiMh4g7NVGztsNMy08Ie6w9OfTtses2t0z0212j1K23mPok0ubu9HO VDse1si/GReaaAWnFTutHKz3dOSQV7/8n7YPKwf8PxNPg2EAru0au494sQ810vA/Iu5kvR6ETnxvu B0/OHWcCXBofu1RieO+y067BKtUHTnKy/865Rk6wTGxbVJJdiNGIUfm1iueIiUhYMf6DX1NtTREDV FcXqNLpwD0V41hnJho3RiNIW21dg45HDCxB5JuOWsq66rFmybmlxYbzwhlLXxENbMSCsjhpYexONf pepsRNLl/eqAdSISZdsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVZv3-002wqG-A9; Fri, 24 Feb 2023 15:23:33 +0000 Received: from [2a03:3b40:fe:f0::1] (helo=hutie.ust.cz) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVZu4-002wUN-TG for linux-arm-kernel@lists.infradead.org; Fri, 24 Feb 2023 15:22:37 +0000 From: =?utf-8?q?Martin_Povi=C5=A1er?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1677252145; bh=8I53wAm0Lhx1Y1CRpTsp/SrqowkIL26beK+I0BreeKg=; h=From:To:Cc:Subject:Date; b=KzjvnnBtPMLzkpne5ixV1R5vuvAuRq/riSQMn9JedY18pihL2mEdyY4AVhiv2dpX4 2jOIvqTVWjw8jMAAe4igDy0ErG5dXi8IdYScZWKLs1WURJu6IVVQGM4gAmerF6KtlL uzDbQyJTxoBgbh/cekLbEdEGeCEnorFmhJLgHseg= To: Hector Martin , Sven Peter , Vinod Koul Cc: Alyssa Rosenzweig , =?utf-8?q?Martin_Povi=C5=A1er?= , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags Date: Fri, 24 Feb 2023 16:22:20 +0100 Message-Id: <20230224152222.26732-1-povik+lin@cutebit.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230224_072234_006501_06CDC757 X-CRM114-Status: GOOD ( 10.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In addition to TX channel and RX channel interrupt flags there's another class of 'global' interrupt flags with unknown semantics. Those weren't being handled up to now, and they are the suspected cause of stuck IRQ states that have been sporadically occurring. Check the global flags and clear them if raised. Fixes: b127315d9a78 ("dmaengine: apple-admac: Add Apple ADMAC driver") Signed-off-by: Martin Povišer --- drivers/dma/apple-admac.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c index 90f28bda29c8..00cbfafe0ed9 100644 --- a/drivers/dma/apple-admac.c +++ b/drivers/dma/apple-admac.c @@ -75,6 +75,7 @@ #define REG_TX_INTSTATE(idx) (0x0030 + (idx) * 4) #define REG_RX_INTSTATE(idx) (0x0040 + (idx) * 4) +#define REG_GLOBAL_INTSTATE(idx) (0x0050 + (idx) * 4) #define REG_CHAN_INTSTATUS(ch, idx) (0x8010 + (ch) * 0x200 + (idx) * 4) #define REG_CHAN_INTMASK(ch, idx) (0x8020 + (ch) * 0x200 + (idx) * 4) @@ -672,13 +673,14 @@ static void admac_handle_chan_int(struct admac_data *ad, int no) static irqreturn_t admac_interrupt(int irq, void *devid) { struct admac_data *ad = devid; - u32 rx_intstate, tx_intstate; + u32 rx_intstate, tx_intstate, global_intstate; int i; rx_intstate = readl_relaxed(ad->base + REG_RX_INTSTATE(ad->irq_index)); tx_intstate = readl_relaxed(ad->base + REG_TX_INTSTATE(ad->irq_index)); + global_intstate = readl_relaxed(ad->base + REG_GLOBAL_INTSTATE(ad->irq_index)); - if (!tx_intstate && !rx_intstate) + if (!tx_intstate && !rx_intstate && !global_intstate) return IRQ_NONE; for (i = 0; i < ad->nchannels; i += 2) { @@ -693,6 +695,12 @@ static irqreturn_t admac_interrupt(int irq, void *devid) rx_intstate >>= 1; } + if (global_intstate) { + dev_warn(ad->dev, "clearing unknown global interrupt flag: %x\n", + global_intstate); + writel_relaxed(~(u32) 0, ad->base + REG_GLOBAL_INTSTATE(ad->irq_index)); + } + return IRQ_HANDLED; } From patchwork Fri Feb 24 15:22:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Povi=C5=A1er?= X-Patchwork-Id: 13151398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13569C61DA3 for ; Fri, 24 Feb 2023 15:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W3l1Bb4SpVvkbQ8+zUFRKzluYo8FtdzH05k91Qi6GHs=; b=E/97Fq1ffHRVnI WnkuQDWCPE36+pImQ7/oXtKdgMMUcY5u/ukPEmN8SUYITlZF0BwS5BmPd//baPdxaCuZgkWqvQvxE SwqQCifqvIESwhesjKo4v9bTmz7ZodPc8trsnyWibJq2i9UB+Ei1Kx1M8F0xgj19YxpW0BXDz/hW6 1N5oJu5RFqNtj1fUMIUk2hFWiyhU4Cw5ffVt8MPwQz5s7gFynVaH2tnk+r1LTOS2cgeZpOAE965Tc 8ur3HnDDMbMIalk3O6c2p1vZqZ3HTZzd0C0dlKgtX85wPsX2cm9dCy2RmwsOrTo6fDpjJDDyB50we EVrHGmWo1rZrrzI97C7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVZuh-002wk3-7x; Fri, 24 Feb 2023 15:23:11 +0000 Received: from hutie.ust.cz ([185.8.165.127]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVZu5-002wUM-O2 for linux-arm-kernel@lists.infradead.org; Fri, 24 Feb 2023 15:22:35 +0000 From: =?utf-8?q?Martin_Povi=C5=A1er?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1677252145; bh=StaFikSjZpFQ+BUcIlQfwrxM+sCnU+rvBEoVvGQ2nmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fOvbi5u7TfZbdRb/5lxtFwcD+ebCgEW+egwfuLYdhfzxpB2grc3CsYFX5m3JosTZ3 5CP7I59IxQyKuSrYvD7i+g0nm3Z7Anzbz6LcVbPDatTuX7bCwQrAa765yoNtapNLkx VYNi76Ina7OQb60oYtDZ5wzW7ec+E3dPHKVJiV+4= To: Hector Martin , Sven Peter , Vinod Koul Cc: Alyssa Rosenzweig , =?utf-8?q?Martin_Povi=C5=A1er?= , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed Date: Fri, 24 Feb 2023 16:22:21 +0100 Message-Id: <20230224152222.26732-2-povik+lin@cutebit.org> In-Reply-To: <20230224152222.26732-1-povik+lin@cutebit.org> References: <20230224152222.26732-1-povik+lin@cutebit.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230224_072233_981536_BAD6D5A7 X-CRM114-Status: GOOD ( 10.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In terminate_all we should queue up all submitted descriptors to be freed. We do that for the content of the 'issued' and 'submitted' lists, but the 'current_tx' descriptor falls through the cracks as it's removed from the 'issued' list once it gets assigned to be the current descriptor. Explicitly queue up freeing of the 'current_tx' descriptor to address a memory leak that is otherwise present. Fixes: b127315d9a78 ("dmaengine: apple-admac: Add Apple ADMAC driver") Signed-off-by: Martin Povišer --- drivers/dma/apple-admac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c index 00cbfafe0ed9..497bb65b7d6d 100644 --- a/drivers/dma/apple-admac.c +++ b/drivers/dma/apple-admac.c @@ -512,7 +512,10 @@ static int admac_terminate_all(struct dma_chan *chan) admac_stop_chan(adchan); admac_reset_rings(adchan); - adchan->current_tx = NULL; + if (adchan->current_tx) { + list_add_tail(&adchan->current_tx->node, &adchan->to_free); + adchan->current_tx = NULL; + } /* * Descriptors can only be freed after the tasklet * has been killed (in admac_synchronize). From patchwork Fri Feb 24 15:22:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Povi=C5=A1er?= X-Patchwork-Id: 13151397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37B82C678DB for ; Fri, 24 Feb 2023 15:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CWQmMmqjK2n9SC8jQhdEdtcyOZ7Zk84NhY4RBvS2HVQ=; b=LJcJ2bUaQWWQpk TXqXcsLE625Iu0doXuhk0+zoByaYSllaIV7pBV4hfAuWerG0ZOBG+5911Nk/HO3Ay1MjLOTvuaiQl MRJ9pKUDfrTnRLSN4N3dzd3dJMqmrSPp7shgxNhhwBBUL5exHxCuOxnETR7n5c0KJ1Q00hEunm7pK 3DcErXvdkwymdVCKxuq4VFYuKXGs8pcZqvTijxX3kw+efB+W3u2ofkI1uAIH2oJ9/nXutxpuk9y3o VtctxSBe4YIl3kHrkSAt/7O34PBgxpMAWY2LGCT8M/PAeNQq7MvpkBPNF3QPD6QCFRLEE3sjJdr2Z 9PhOfES1QwFMJdnkMu2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVZuB-002waT-Fz; Fri, 24 Feb 2023 15:22:39 +0000 Received: from [2a03:3b40:fe:f0::1] (helo=hutie.ust.cz) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pVZu4-002wUQ-S5 for linux-arm-kernel@lists.infradead.org; Fri, 24 Feb 2023 15:22:35 +0000 From: =?utf-8?q?Martin_Povi=C5=A1er?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1677252146; bh=qcgclGCFYD+77b0HLKFa7/pKBARXaiNkZFUlsvgiV7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rPQdylosAxrYCCO5c8/2Rz1rgF2eMzEo2nN+XzDHHHY4+Y/P8SWrZZ3ZkW96z5Hcb 7hYQRfRVs/LzFiwrE5hV2PlmdcgVImUYYTcN6kqBi+W5L2KFPLvVQuwqPe1AOsk3bW qLWLeQ+rLGrT5pbA3RNrIgOsxOwUY1GatwjsNLj8= To: Hector Martin , Sven Peter , Vinod Koul Cc: Alyssa Rosenzweig , =?utf-8?q?Martin_Povi=C5=A1er?= , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] dmaengine: apple-admac: Set src_addr_widths capability Date: Fri, 24 Feb 2023 16:22:22 +0100 Message-Id: <20230224152222.26732-3-povik+lin@cutebit.org> In-Reply-To: <20230224152222.26732-1-povik+lin@cutebit.org> References: <20230224152222.26732-1-povik+lin@cutebit.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230224_072234_011800_8C23351F X-CRM114-Status: UNSURE ( 8.56 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add missing setting of 'src_addr_widths', which is the same as for the other direction. Fixes: b127315d9a78 ("dmaengine: apple-admac: Add Apple ADMAC driver") Signed-off-by: Martin Povišer --- drivers/dma/apple-admac.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c index 497bb65b7d6d..4cf8da77bdd9 100644 --- a/drivers/dma/apple-admac.c +++ b/drivers/dma/apple-admac.c @@ -861,6 +861,9 @@ static int admac_probe(struct platform_device *pdev) dma->directions = BIT(DMA_MEM_TO_DEV) | BIT(DMA_DEV_TO_MEM); dma->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; + dma->src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | + BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | + BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); dma->dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);