From patchwork Wed Jan 15 16:02:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= X-Patchwork-Id: 13940586 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 50503C02180 for ; Wed, 15 Jan 2025 16:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type: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=1cpdHJxpiKdoCJBJhkUL0M4SqzQhG4ymd2U7r+mGgSU=; b=OyDQqYx2BAeHwD /P0QAfypIm/p0dAaxEKHBNrJcJ8BC3WZkDMkWiUjeqpFUQx8kmYgoi/P0K99dUkv2Q9Gylsrwxky4 Sn/hhOMSAhJT7rEdW0MloY0Zqlg17ExeEZ5NNZ8qlkYawo7C/ieHkL1KWrkVaQbzXRfVgUQ2agy7O bDHfWhcQ5s2VT4X8QwFk+nUqpWdYdOGGa+7cjCpnjdErXTIVoNFDhfZu/D6DSLKGI1OLeQ1Utkia3 sTa/4T6tIF2zX+N6R6/cle4bcGCiqd2Rb2+b07cpMNaLadPdYnYxHsEBMnos2H/ekaR5EDS3PGVss F9EZ3GH86f0G0hfKQmvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tY5sU-0000000CMdy-3KGE; Wed, 15 Jan 2025 16:04:22 +0000 Received: from fw2.prolan.hu ([193.68.50.107]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tY5rB-0000000CMQH-32Jl for linux-arm-kernel@lists.infradead.org; Wed, 15 Jan 2025 16:03:03 +0000 Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 26D09A0955; Wed, 15 Jan 2025 17:02:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=1cpdHJxpiKdoCJBJhkUL 0M4SqzQhG4ymd2U7r+mGgSU=; b=edZQ9IAhPDOS3UkLhGpv/S4GZ65IsKanX2Fh U/l+weMXuV4dRCoiyL5GaM9y/a7ZZl8/DOEkVT/sld+4O13tVzLqppepWx+MiDDV 5dJV+JPRDDEL9BKCRSLYVtl7c2+kVzw49ti2c3k7kUN3cG57XcduKclUFeJ7SJi3 KabjLMQ8xDgaGP/9tj9x5SY8dRUrhZltrrIGpBGtrOVmq+32N4MqxXoMZei8AIn6 DjDse6qGvGTKirMQVnpPGklZ9ESUj7jk1u3iKETVb8KJu+95IhheDG4XBX2zn2Nj EbgNBUU7doWlPMD9x85S2BfQCPnY/uf9ZefYMkKbZNDm3Y1lc84ugR29/b0pw/B4 pJZiGMtz6YIgHjtWLa8wawkEQNxvxhiv2j/9c2IFqVEicbdnzysv0TG/WAQwUK2y H3Mo16uIFjo8yZ1dCYowfG4Ff1B+WnoNsARLWIqWHVtK3dPQ4zF6uY09hYfZRI7+ OeJM2rA/nNqM4VhQ3c2r4CBzWWbeLFzz6lejrra1wOEWeAb71lO7SbV8WQ2ZDBm3 xc3SVaEXf7vKMwwfIt3uu7sp/6lI83zqwZaNKtNwh3D6M8w2ore3V7Eea14U2au+ FYAX33X+wLVQw0BHrE6wdZxarCgzseWl/8y8n8uTQOSDZgU/8jQw3A85djffh3Gx P7JXb5Y= From: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= To: , , Subject: [PATCH 3/4] spi: atmel-quadspi: Use `devm_dma_request_chan()` Date: Wed, 15 Jan 2025 17:02:40 +0100 Message-ID: <20250115160244.1102881-3-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250115160244.1102881-1-csokas.bence@prolan.hu> References: <20250115160244.1102881-1-csokas.bence@prolan.hu> MIME-Version: 1.0 X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1736956968;VERSION=7983;MC=1121942183;ID=287149;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A29ACD94852647067 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250115_080302_205442_6A6FD844 X-CRM114-Status: GOOD ( 14.79 ) 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: , Cc: Alexandre Belloni , Mark Brown , =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Leave releasing of DMA channels up to the devm facilities. This way we can eliminate the rest of the "goto ladder". Signed-off-by: Bence Csókás --- drivers/spi/atmel-quadspi.c | 44 ++++++++++--------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c index abdc49d9d940..b1fb4426c78d 100644 --- a/drivers/spi/atmel-quadspi.c +++ b/drivers/spi/atmel-quadspi.c @@ -1288,18 +1288,20 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl) struct atmel_qspi *aq = spi_controller_get_devdata(ctrl); int ret; - aq->rx_chan = dma_request_chan(&aq->pdev->dev, "rx"); + aq->rx_chan = devm_dma_request_chan(&aq->pdev->dev, "rx"); if (IS_ERR(aq->rx_chan)) { aq->rx_chan = NULL; return dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->rx_chan), "RX DMA channel is not available\n"); } - aq->tx_chan = dma_request_chan(&aq->pdev->dev, "tx"); + aq->tx_chan = devm_dma_request_chan(&aq->pdev->dev, "tx"); if (IS_ERR(aq->tx_chan)) { ret = dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->tx_chan), "TX DMA channel is not available\n"); - goto release_rx_chan; + aq->rx_chan = NULL; + aq->tx_chan = NULL; + return ret; } ctrl->dma_rx = aq->rx_chan; @@ -1310,20 +1312,6 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl) dma_chan_name(aq->tx_chan), dma_chan_name(aq->rx_chan)); return 0; - -release_rx_chan: - dma_release_channel(aq->rx_chan); - aq->rx_chan = NULL; - aq->tx_chan = NULL; - return ret; -} - -static void atmel_qspi_dma_release(struct atmel_qspi *aq) -{ - if (aq->rx_chan) - dma_release_channel(aq->rx_chan); - if (aq->tx_chan) - dma_release_channel(aq->tx_chan); } static const struct atmel_qspi_ops atmel_qspi_ops = { @@ -1428,14 +1416,13 @@ static int atmel_qspi_probe(struct platform_device *pdev) /* Request the IRQ */ irq = platform_get_irq(pdev, 0); - if (irq < 0) { - err = irq; - goto dma_release; - } + if (irq < 0) + return irq; + err = devm_request_irq(&pdev->dev, irq, atmel_qspi_interrupt, 0, dev_name(&pdev->dev), aq); if (err) - goto dma_release; + return err; pm_runtime_set_autosuspend_delay(&pdev->dev, 500); pm_runtime_use_autosuspend(&pdev->dev); @@ -1445,7 +1432,7 @@ static int atmel_qspi_probe(struct platform_device *pdev) err = atmel_qspi_init(aq); if (err) - goto dma_release; + return err; err = spi_register_controller(ctrl); if (err) { @@ -1453,18 +1440,12 @@ static int atmel_qspi_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); pm_runtime_dont_use_autosuspend(&pdev->dev); - goto dma_release; + return err; } pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev); return 0; - -dma_release: - if (aq->caps->has_dma) - atmel_qspi_dma_release(aq); - - return err; } static int atmel_qspi_sama7g5_suspend(struct atmel_qspi *aq) @@ -1514,9 +1495,6 @@ static void atmel_qspi_remove(struct platform_device *pdev) ret = pm_runtime_get_sync(&pdev->dev); if (ret >= 0) { - if (aq->caps->has_dma) - atmel_qspi_dma_release(aq); - if (aq->caps->has_gclk) { ret = atmel_qspi_sama7g5_suspend(aq); if (ret) From patchwork Wed Jan 15 16:02:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= X-Patchwork-Id: 13940587 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 18745C02180 for ; Wed, 15 Jan 2025 16:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type: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=VtKelQz/78A8bo8Vg0JkYpThHcAAeYRmgdNPVPZFl4g=; b=K5y3Iwbh0KdL4A k8RmshQMdgT6GlbxNvwOnlEz7VD78rOkVCUIERXzozRlpROjE1yb6vWOzEFuCxVL5ZzQNQ9ylaCWH yC0kAuVlEjbcAWDQRaddvM5IKQNtzOmM0vSdAQhH92cJZT1QACQRQJ87Nt8sdUnP2TsStu//jcHZa IN1k2aAvGTtMnH19bkANYgY5stJV9f3tU3MroHzlIpstuFUqSbddvDJbBlrZvMU6sh0XGfy+O7U/6 bmsfGBe+FABRFao0lyKc/FqitEPdRw0cG3328z/EaCGHhITSFiyDkKWEuL0aQq0NaIrKEnaT9f2Pi TlYEzyRxzKNZFfVEEe5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tY5tk-0000000CMxy-2aHb; Wed, 15 Jan 2025 16:05:40 +0000 Received: from fw2.prolan.hu ([193.68.50.107]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tY5rB-0000000CMQJ-2xHl for linux-arm-kernel@lists.infradead.org; Wed, 15 Jan 2025 16:03:03 +0000 Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id D7E9FA099A; Wed, 15 Jan 2025 17:02:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=VtKelQz/78A8bo8Vg0Jk YpThHcAAeYRmgdNPVPZFl4g=; b=iJxIkM7HY0Tv8C0GXViAA/y5NpP4ovq3qhom YPdXfZbhsQIaIBngULnL2S0ZtmTVWl9ETazZhmOKbSNlV74ZvhcfK+liDNBh0V58 KbXJZndvj8wv1NaW6pZpdgQBQEmoY6UWxANrpMFMk+u9/wn/UHnsiyboEmuL2Rhr 1/nvTbRd1YUT7id87nerGAhui88rJVOhnTJ1IqmfddgotpfJtnom8ZjDOriq5R09 RDL4Dc1ezQg2yQYPoOyWZ1rPJ6IPA7KLy9Slv1wjeDxvQPdIwuVNZ8+Ak+X6lYFE RDdlpMKnHI0VFgXE2AAaghcARwfp/XVKejf/l5rv+l6M3XLkrDUiMt93pxSHzHuG fmBS874EBAaw/CnMcE1fiN7i8a7/kUSlhtg4cbb33ftITg3khLQidf+0KMlzD85I V5j9eABen5hdXpliVtcrVqgain3exWnvXgLjoNjUj7ry4cNompGmYoZfjiKPQtYr EZiYNrjhHP56T8Ma/ceIB4y7B4U6UJLgMnlPp68SZUzF8mvz/Yr5FQUo3dS9Id6h N3jXCFiN0HMc4SgXCPXsPxUBPy/i0fZ+bk0Q3HUwDEtYzteYxeDuVMEpiUWvZ4uU nC6ocTv+ETgYiaWoOxn3Qn4Kms3eLDsMgrMgT3IdiSYB3eC2/VNPzdIQi/jClzxY 5oCVR04= From: =?utf-8?b?QmVuY2UgQ3PDs2vDoXM=?= To: Tudor Ambarus , Mark Brown , Varshini Rajendran , =?utf-8?b?Q3PDs2s=?= =?utf-8?b?w6FzLCBCZW5jZQ==?= , , , Subject: [PATCH 4/4] spi: atmel-quadspi: Fix unbalanced pm_runtime by using devm_ API Date: Wed, 15 Jan 2025 17:02:41 +0100 Message-ID: <20250115160244.1102881-4-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.48.0 In-Reply-To: <20250115160244.1102881-1-csokas.bence@prolan.hu> References: <20250115160244.1102881-1-csokas.bence@prolan.hu> MIME-Version: 1.0 X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1736956969;VERSION=7983;MC=3460317179;ID=287150;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A29ACD94852647067 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250115_080302_204875_7AB437A6 X-CRM114-Status: GOOD ( 10.39 ) 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: , Cc: Alexander Dahl , Alexandre Belloni , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Fix unbalanced PM in error path of `atmel_qspi_probe()` by using `devm_pm_runtime_*()` functions. Reported-by: Alexander Dahl Closes: https://lore.kernel.org/linux-spi/20250110-paycheck-irregular-bcddab1276c7@thorsis.com/ Fixes: 5af42209a4d2 ("spi: atmel-quadspi: Add support for sama7g5 QSPI") Signed-off-by: Bence Csókás --- drivers/spi/atmel-quadspi.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c index b1fb4426c78d..f2164685d3d5 100644 --- a/drivers/spi/atmel-quadspi.c +++ b/drivers/spi/atmel-quadspi.c @@ -1426,22 +1426,18 @@ static int atmel_qspi_probe(struct platform_device *pdev) pm_runtime_set_autosuspend_delay(&pdev->dev, 500); pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - pm_runtime_get_noresume(&pdev->dev); + devm_pm_runtime_set_active(&pdev->dev); + devm_pm_runtime_enable(&pdev->dev); + devm_pm_runtime_get_noresume(&pdev->dev); err = atmel_qspi_init(aq); if (err) return err; err = spi_register_controller(ctrl); - if (err) { - pm_runtime_put_noidle(&pdev->dev); - pm_runtime_disable(&pdev->dev); - pm_runtime_set_suspended(&pdev->dev); - pm_runtime_dont_use_autosuspend(&pdev->dev); + if (err) return err; - } + pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev); @@ -1511,10 +1507,6 @@ static void atmel_qspi_remove(struct platform_device *pdev) */ dev_warn(&pdev->dev, "Failed to resume device on remove\n"); } - - pm_runtime_disable(&pdev->dev); - pm_runtime_dont_use_autosuspend(&pdev->dev); - pm_runtime_put_noidle(&pdev->dev); } static int __maybe_unused atmel_qspi_suspend(struct device *dev)