mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
ata: ahci_st: Assert the power down reset in the probe() error path
st_ahci_probe_resets() deasserts the "pwr-dwn" reset, but the probe()
error path of st_ahci_probe() only releases the host resources, so the
SATA IP is left powered up when probe() fails after
st_ahci_probe_resets() has succeeded, e.g. when
ahci_platform_enable_resources() fails.
The reset is asserted by st_ahci_host_stop(), however ->host_stop() is
only called through the ata_host_stop() devres action registered by
ata_host_start(), so it does not cover any failure happening before the
host has been started.
Factor the assert out into st_ahci_assert_pwrdwn() and call it when
either ahci_platform_enable_resources() or ahci_platform_init_host()
fails. The "pwr-dwn" reset control is an exclusive one, so asserting it
once more from st_ahci_host_stop() is harmless.
No functional change intended for ->host_stop() and st_ahci_suspend().
Fixes: 76884cb2f7 ("ahci: st: Add support for ST's SATA IP")
Cc: stable@vger.kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20260915084127.692494-10-cassel@kernel.org
Signed-off-by: Niklas Cassel <cassel@kernel.org>
This commit is contained in:
parent
c74ee9230a
commit
91e0a7452d
|
|
@ -83,18 +83,27 @@ static int st_ahci_deassert_resets(struct ahci_host_priv *hpriv,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int st_ahci_assert_pwrdwn(struct ahci_host_priv *hpriv,
|
||||
struct device *dev)
|
||||
{
|
||||
struct st_ahci_drv_data *drv_data = hpriv->plat_data;
|
||||
int err;
|
||||
|
||||
if (!drv_data->pwr)
|
||||
return 0;
|
||||
|
||||
err = reset_control_assert(drv_data->pwr);
|
||||
if (err)
|
||||
dev_err(dev, "unable to pwrdwn\n");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void st_ahci_host_stop(struct ata_host *host)
|
||||
{
|
||||
struct ahci_host_priv *hpriv = host->private_data;
|
||||
struct st_ahci_drv_data *drv_data = hpriv->plat_data;
|
||||
struct device *dev = host->dev;
|
||||
int err;
|
||||
|
||||
if (drv_data->pwr) {
|
||||
err = reset_control_assert(drv_data->pwr);
|
||||
if (err)
|
||||
dev_err(dev, "unable to pwrdwn\n");
|
||||
}
|
||||
st_ahci_assert_pwrdwn(hpriv, host->dev);
|
||||
|
||||
ahci_platform_disable_resources(hpriv);
|
||||
}
|
||||
|
|
@ -159,38 +168,38 @@ static int st_ahci_probe(struct platform_device *pdev)
|
|||
|
||||
err = ahci_platform_enable_resources(hpriv);
|
||||
if (err)
|
||||
return err;
|
||||
goto assert_pwrdwn;
|
||||
|
||||
st_ahci_configure_oob(hpriv->mmio);
|
||||
|
||||
err = ahci_platform_init_host(pdev, hpriv, &st_ahci_port_info,
|
||||
&ahci_platform_sht);
|
||||
if (err) {
|
||||
ahci_platform_disable_resources(hpriv);
|
||||
return err;
|
||||
}
|
||||
if (err)
|
||||
goto disable_resources;
|
||||
|
||||
return 0;
|
||||
|
||||
disable_resources:
|
||||
ahci_platform_disable_resources(hpriv);
|
||||
assert_pwrdwn:
|
||||
st_ahci_assert_pwrdwn(hpriv, &pdev->dev);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int st_ahci_suspend(struct device *dev)
|
||||
{
|
||||
struct ata_host *host = dev_get_drvdata(dev);
|
||||
struct ahci_host_priv *hpriv = host->private_data;
|
||||
struct st_ahci_drv_data *drv_data = hpriv->plat_data;
|
||||
int err;
|
||||
|
||||
err = ahci_platform_suspend_host(dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (drv_data->pwr) {
|
||||
err = reset_control_assert(drv_data->pwr);
|
||||
if (err) {
|
||||
dev_err(dev, "unable to pwrdwn");
|
||||
return err;
|
||||
}
|
||||
}
|
||||
err = st_ahci_assert_pwrdwn(hpriv, dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
ahci_platform_disable_resources(hpriv);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user