From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: dlemoal@kernel.org, cassel@kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCHv2 6/8] ata: sata_dwc_460ex: disable SATA interrupts on device removal
Date: Thu, 02 Jul 2026 00:18:12 +0000 [thread overview]
Message-ID: <20260702001813.0F45D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702000350.68331-7-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Masking hardware interrupts before calling ata_host_detach() breaks the SCSI teardown sequence, leading to command timeouts, shutdown hangs, and potentially unwritten disk caches.
- [Medium] Missing read-back to flush posted writes when disabling hardware interrupts in sata_dwc_disable_interrupts().
Pre-existing issues:
- [High] sata_dwc_probe() incorrectly returns 0 (success) even if ata_host_activate() fails, leading to unhandled error paths and crashes on remove.
- [High] Masking interrupts without calling synchronize_irq() allows an in-flight interrupt handler to execute concurrently with hardware teardown.
--
commit df81e2008992f864aa17e308c42b08931c2b48f5
Author: Rosen Penev <rosenp@gmail.com>
ata: sata_dwc_460ex: disable SATA interrupts on device removal
This commit adds sata_dwc_disable_interrupts() and calls it at the beginning
of sata_dwc_remove(). It masks the controller's INTMR and ERRMR registers to
prevent unhandled interrupt storms during teardown.
> diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
> index 4fc22ce4bd9aa..62580a58ad76e 100644
> --- a/drivers/ata/sata_dwc_460ex.c
> +++ b/drivers/ata/sata_dwc_460ex.c
> @@ -762,6 +762,12 @@ static int sata_dwc_qc_complete(struct ata_port *ap, struct ata_queued_cmd *qc)
> return 0;
> }
>
> +static void sata_dwc_disable_interrupts(struct sata_dwc_device *hsdev)
> +{
> + sata_dwc_writel(&hsdev->sata_dwc_regs->intmr, 0);
> + sata_dwc_writel(&hsdev->sata_dwc_regs->errmr, 0);
[Severity: Medium]
Will these posted writes reach the hardware predictably before the CPU moves
on to tear down the device?
Since sata_dwc_writel() wraps writel_relaxed(), writes to the memory-mapped
registers over the system bus can be posted. Without a subsequent dummy read
to a controller register to flush them, the interrupt mask configuration might
be delayed in write buffers. This could allow an interrupt to fire during
teardown, which is exactly what this change is intended to prevent.
> +}
> +
[ ... ]
> @@ -1217,6 +1223,8 @@ static void sata_dwc_remove(struct platform_device *ofdev)
> struct ata_host *host = dev_get_drvdata(dev);
> struct sata_dwc_device *hsdev = host->private_data;
>
> + sata_dwc_disable_interrupts(hsdev);
> +
[Severity: High]
Does masking interrupts here break the SCSI teardown sequence?
When ata_host_detach() is called, it instructs the SCSI layer to issue cache
flush and spindown commands. If hardware interrupts are already masked, won't
these commands fail to complete and eventually time out? This could lead to a
system hang during device removal and potential data loss if caches are not
successfully flushed.
[Severity: High]
This isn't a bug introduced by this patch, but does the teardown sequence
leave a race window with the still-registered ISR?
The interrupt handler is registered using devm_request_irq() and is only
freed by devres after sata_dwc_remove() returns. While the new masking stops
new interrupts, it does not wait for an already-running ISR on another CPU to
finish. Since synchronize_irq() isn't called, could the ISR execute
concurrently with ata_host_detach(), phy_exit(), and sata_dwc_dma_exit_old(),
accessing freed memory or hardware in an invalid state?
[Severity: High]
This is a pre-existing issue, but can sata_dwc_remove() crash if the initial
device probe failed?
Looking at sata_dwc_probe():
err = ata_host_activate(host, irq, sata_dwc_isr, 0, &sata_dwc_sht);
if (err)
dev_err(dev, "failed to activate host");
return 0;
If ata_host_activate() fails, probe still returns 0 (success). When the
driver is later unbound, sata_dwc_remove() will unconditionally call
ata_host_detach() and attempt to tear down host structures that were never
successfully initialized, potentially causing a NULL pointer dereference or
list corruption.
> ata_host_detach(host);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260702000350.68331-7-rosenp@gmail.com?part=1
next prev parent reply other threads:[~2026-07-02 0:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 0:03 [PATCHv2 0/8] ata: sata_dwc_460ex: cleanups and interrupt ordering fix Rosen Penev
2026-07-02 0:03 ` [PATCHv2 1/8] ata: sata_dwc_460ex: use device_property_present() Rosen Penev
2026-07-02 0:03 ` [PATCHv2 2/8] ata: sata_dwc_460ex: use platform_get_irq() Rosen Penev
2026-07-02 0:03 ` [PATCHv2 3/8] ata: sata_dwc_460ex: enable SATA interrupts only after IRQ handler is registered Rosen Penev
2026-07-02 0:03 ` [PATCHv2 4/8] ata: sata_dwc_460ex: drop redundant struct copy of port_info Rosen Penev
2026-07-02 0:13 ` sashiko-bot
2026-07-02 0:27 ` Rosen Penev
2026-07-02 0:03 ` [PATCHv2 5/8] ata: sata_dwc_460ex: fix data race on hsdev->sactive_issued in interrupt handler Rosen Penev
2026-07-02 0:16 ` sashiko-bot
2026-07-02 0:03 ` [PATCHv2 6/8] ata: sata_dwc_460ex: disable SATA interrupts on device removal Rosen Penev
2026-07-02 0:18 ` sashiko-bot [this message]
2026-07-02 0:03 ` [PATCHv2 7/8] ata: sata_dwc_460ex: fix PHY lifecycle ordering " Rosen Penev
2026-07-02 0:03 ` [PATCHv2 8/8] ata: sata_dwc_460ex: use devm for old DMA resource lifetime management Rosen Penev
2026-07-02 2:02 ` [PATCHv2 0/8] ata: sata_dwc_460ex: cleanups and interrupt ordering fix Damien Le Moal
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=20260702001813.0F45D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=rosenp@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