From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Liao Yuanhong <liaoyuanhong@vivo.com>
Cc: <vkoul@kernel.org>, <linux-arm-kernel@lists.infradead.org>,
<dmaengine@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/6] dma:imx-sdma:Use devm_clk_get_enabled() helpers
Date: Fri, 23 Aug 2024 13:08:35 +0100 [thread overview]
Message-ID: <20240823130835.00003495@Huawei.com> (raw)
In-Reply-To: <20240823101933.9517-5-liaoyuanhong@vivo.com>
On Fri, 23 Aug 2024 18:19:31 +0800
Liao Yuanhong <liaoyuanhong@vivo.com> wrote:
> Use devm_clk_get_enabled() instead of clk functions in imx-sdma.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
No.
Consider why the clocks are adjusted where they are in existing code
before 'cleaning' it up.
> ---
> drivers/dma/imx-sdma.c | 57 ++++--------------------------------------
> 1 file changed, 5 insertions(+), 52 deletions(-)
>
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> index 72299a08af44..af972a4b6ce1 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -1493,24 +1493,11 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan)
> sdmac->event_id0 = data->dma_request;
> sdmac->event_id1 = data->dma_request2;
>
> - ret = clk_enable(sdmac->sdma->clk_ipg);
> - if (ret)
> - return ret;
> - ret = clk_enable(sdmac->sdma->clk_ahb);
> - if (ret)
> - goto disable_clk_ipg;
> -
> ret = sdma_set_channel_priority(sdmac, prio);
> if (ret)
> - goto disable_clk_ahb;
> + return ret;
>
> return 0;
> -
> -disable_clk_ahb:
> - clk_disable(sdmac->sdma->clk_ahb);
> -disable_clk_ipg:
> - clk_disable(sdmac->sdma->clk_ipg);
> - return ret;
> }
>
> static void sdma_free_chan_resources(struct dma_chan *chan)
> @@ -1530,9 +1517,6 @@ static void sdma_free_chan_resources(struct dma_chan *chan)
> sdmac->event_id1 = 0;
>
> sdma_set_channel_priority(sdmac, 0);
> -
> - clk_disable(sdma->clk_ipg);
> - clk_disable(sdma->clk_ahb);
> }
>
> static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac,
> @@ -2015,14 +1999,10 @@ static void sdma_load_firmware(const struct firmware *fw, void *context)
> addr = (void *)header + header->script_addrs_start;
> ram_code = (void *)header + header->ram_code_start;
>
> - clk_enable(sdma->clk_ipg);
> - clk_enable(sdma->clk_ahb);
> /* download the RAM image for SDMA */
> sdma_load_script(sdma, ram_code,
> header->ram_code_size,
> addr->ram_code_start_addr);
> - clk_disable(sdma->clk_ipg);
> - clk_disable(sdma->clk_ahb);
Why do you think it is suddenly fine to leave the locks on here and it
wasn't before?
Check all the paths.
>
> sdma_add_scripts(sdma, addr);
>
> @@ -2119,13 +2099,6 @@ static int sdma_init(struct sdma_engine *sdma)
> dma_addr_t ccb_phys;
> int ccbsize;
>
> - ret = clk_enable(sdma->clk_ipg);
> - if (ret)
> - return ret;
> - ret = clk_enable(sdma->clk_ahb);
> - if (ret)
> - goto disable_clk_ipg;
> -
> if (sdma->drvdata->check_ratio &&
> (clk_get_rate(sdma->clk_ahb) == clk_get_rate(sdma->clk_ipg)))
> sdma->clk_ratio = 1;
> @@ -2180,15 +2153,9 @@ static int sdma_init(struct sdma_engine *sdma)
> /* Initializes channel's priorities */
> sdma_set_channel_priority(&sdma->channel[0], 7);
>
> - clk_disable(sdma->clk_ipg);
> - clk_disable(sdma->clk_ahb);
> -
> return 0;
>
> err_dma_alloc:
> - clk_disable(sdma->clk_ahb);
> -disable_clk_ipg:
> - clk_disable(sdma->clk_ipg);
> dev_err(sdma->dev, "initialisation failed with %d\n", ret);
> return ret;
> }
> @@ -2266,33 +2233,25 @@ static int sdma_probe(struct platform_device *pdev)
> if (IS_ERR(sdma->regs))
> return PTR_ERR(sdma->regs);
>
> - sdma->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
> + sdma->clk_ipg = devm_clk_get_enabled(&pdev->dev, "ipg");
> if (IS_ERR(sdma->clk_ipg))
> return PTR_ERR(sdma->clk_ipg);
>
> - sdma->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
> + sdma->clk_ahb = devm_clk_get_enabled(&pdev->dev, "ahb");
> if (IS_ERR(sdma->clk_ahb))
> return PTR_ERR(sdma->clk_ahb);
>
> - ret = clk_prepare(sdma->clk_ipg);
> - if (ret)
> - return ret;
> -
> - ret = clk_prepare(sdma->clk_ahb);
> - if (ret)
> - goto err_clk;
> -
> ret = devm_request_irq(&pdev->dev, irq, sdma_int_handler, 0,
> dev_name(&pdev->dev), sdma);
> if (ret)
> - goto err_irq;
> + return ret;
>
> sdma->irq = irq;
>
> sdma->script_addrs = kzalloc(sizeof(*sdma->script_addrs), GFP_KERNEL);
> if (!sdma->script_addrs) {
> ret = -ENOMEM;
> - goto err_irq;
> + return ret;
> }
>
> /* initially no scripts available */
> @@ -2407,10 +2366,6 @@ static int sdma_probe(struct platform_device *pdev)
> dma_async_device_unregister(&sdma->dma_device);
> err_init:
> kfree(sdma->script_addrs);
> -err_irq:
> - clk_unprepare(sdma->clk_ahb);
> -err_clk:
> - clk_unprepare(sdma->clk_ipg);
> return ret;
> }
>
> @@ -2422,8 +2377,6 @@ static void sdma_remove(struct platform_device *pdev)
> devm_free_irq(&pdev->dev, sdma->irq, sdma);
> dma_async_device_unregister(&sdma->dma_device);
> kfree(sdma->script_addrs);
> - clk_unprepare(sdma->clk_ahb);
> - clk_unprepare(sdma->clk_ipg);
> /* Kill the tasklet */
> for (i = 0; i < MAX_DMA_CHANNELS; i++) {
> struct sdma_channel *sdmac = &sdma->channel[i];
next prev parent reply other threads:[~2024-08-23 12:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 10:19 [PATCH 0/6] dma:Use devm_clk_get_enabled() helpers Liao Yuanhong
2024-08-23 10:19 ` [PATCH 1/6] dma:at_hdmac:Use " Liao Yuanhong
2024-08-23 11:58 ` Jonathan Cameron
2024-08-23 12:01 ` Nicolas Ferre
2024-08-23 10:19 ` [PATCH 2/6] dma:dma-jz4780:Use " Liao Yuanhong
2024-08-23 12:01 ` Jonathan Cameron
2024-08-23 10:19 ` [PATCH 3/6] dma:imx-dma:Use " Liao Yuanhong
2024-08-23 12:07 ` Jonathan Cameron
2024-08-26 12:21 ` [PATCH v2 " Liao Yuanhong
2024-08-28 13:00 ` Vinod Koul
2024-08-23 10:19 ` [PATCH 4/6] dma:imx-sdma:Use " Liao Yuanhong
2024-08-23 12:08 ` Jonathan Cameron [this message]
2024-08-26 19:27 ` Frank Li
2024-08-28 8:52 ` [PATCH v2 " Liao Yuanhong
2024-08-23 10:19 ` [PATCH 5/6] dma:milbeaut-hdmac:Use " Liao Yuanhong
2024-08-23 12:09 ` Jonathan Cameron
2024-08-23 10:19 ` [PATCH 6/6] dma:uniphier-mdmac:Use " Liao Yuanhong
2024-08-23 12:10 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240823130835.00003495@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=dmaengine@vger.kernel.org \
--cc=liaoyuanhong@vivo.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).