Linux-Amlogic Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: phucduc.bui@gmail.com
Cc: neil.armstrong@linaro.org, linux-amlogic@lists.infradead.org
Subject: Re: [PATCH 3/3] mmc: davinci: Handle optional IRQ return value correctly
Date: Wed, 12 Aug 2026 11:56:05 +0000	[thread overview]
Message-ID: <20260812115606.6AA5D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812112023.42254-4-phucduc.bui@gmail.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

New issues:
- [Medium] Direct return on `platform_get_irq_optional` error bypasses clock cleanup, leaking the clock enable reference.

Pre-existing issues:
- [High] The driver manually disables the hardware clock in the remove and probe error paths while devm-managed IRQs are still active, risking unclocked register accesses.
- [High] If DMA descriptor allocation fails, the driver attempts PIO fallback but leaves `host->do_dma` set and leaks the mapped scatterlist.
- [High] The system suspend routine disables the MMC controller clock without masking the SDIO interrupt, risking unclocked register access.
--

--- Patch [3]: [PATCH 3/3] mmc: davinci: Handle optional IRQ return value correctly ---
commit 6f8e3291a8bba48fcd7880ece2584b86bc2ca506
Author: bui duc phuc <phucduc.bui@gmail.com>

mmc: davinci: Handle optional IRQ return value correctly
    
The commit checks for a positive IRQ number before requesting the SDIO
IRQ, fixing an issue where 0 was treated as a valid IRQ.

> diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
> index 4765d2dee5993..dddd152d2ec45 100644
> --- a/drivers/mmc/host/davinci_mmc.c
> +++ b/drivers/mmc/host/davinci_mmc.c
> @@ -1303,7 +1303,7 @@ static int davinci_mmcsd_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto mmc_add_host_fail;
>  
> -	if (host->sdio_irq >= 0) {
> +	if (host->sdio_irq > 0) {

[Severity: Medium]
In davinci_mmcsd_probe(), if platform_get_irq_optional() returns an error:

    ret = platform_get_irq_optional(pdev, 1);
    if (ret < 0 && ret != -ENXIO)
        return ret;

Does this direct return bypass the error handling sequence (e.g., goto
parse_fail) and leak the clock enable reference?


[Severity: High]
This isn't a bug introduced by this patch, but I noticed the driver
manually disables the hardware clock in the remove and probe error paths
while devm-managed IRQs are still active.

In the davinci_mmcsd_probe() error paths and davinci_mmcsd_remove(),
clk_disable_unprepare(host->clk) is called before devres frees the IRQs.

If a spurious or SDIO interrupt fires in this window,
mmc_davinci_sdio_irq() will execute:

    status = readl(host->base + DAVINCI_SDIOIST);

Could this cause a fatal bus fault by reading from memory-mapped
registers while the clock is disabled?


[Severity: High]
This is a pre-existing issue, but I found a potential problem in the DMA
fallback path.

In mmc_davinci_start_dma_transfer():

    host->do_dma = 1;
    ret = mmc_davinci_send_dma_request(host, data);

If dmaengine_prep_slave_sg() fails inside mmc_davinci_send_dma_request(),
it returns an error but leaves host->do_dma set to 1, and does not unmap
the scatterlist mapped via dma_map_sg().

Does this break the PIO fallback since mmc_davinci_start_command() will
still configure the hardware for DMA?


[Severity: High]
This is a pre-existing issue, but the system suspend routine might have a
clock management problem.

In davinci_mmcsd_suspend():

    writel(0, host->base + DAVINCI_MMCIM);
    mmc_davinci_reset_ctrl(host, 1);
    clk_disable(host->clk);

The MMC controller clock is disabled without masking the SDIO interrupt
via DAVINCI_SDIOIEN.

If an SDIO interrupt fires between the device suspend callback and the IRQ
core's suspend_device_irqs() phase, won't mmc_davinci_sdio_irq() attempt
to read DAVINCI_SDIOIST while the clock domain is off?

>  		ret = devm_request_irq(&pdev->dev, host->sdio_irq,
>  				       mmc_davinci_sdio_irq, 0,
>  				       mmc_hostname(mmc), host);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812112023.42254-1-phucduc.bui@gmail.com?part=3

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

      reply	other threads:[~2026-08-12 11:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 11:20 [PATCH 0/3] mmc: Handle errors from optional IRQ lookup phucduc.bui
2026-08-12 11:20 ` [PATCH 1/3] mmc: meson-gx: " phucduc.bui
2026-08-12 11:40   ` sashiko-bot
2026-08-12 11:20 ` [PATCH 2/3] mmc: davinci: " phucduc.bui
2026-08-12 11:47   ` sashiko-bot
2026-08-12 11:20 ` [PATCH 3/3] mmc: davinci: Handle optional IRQ return value correctly phucduc.bui
2026-08-12 11:56   ` sashiko-bot [this message]

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=20260812115606.6AA5D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=phucduc.bui@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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