Skip to content

Commit 6ac380a

Browse files
jhovoldgregkh
authored andcommitted
spi: cadence: fix unclocked access on unbind
commit 5b1689a upstream. Make sure that the controller is runtime resumed before disabling it during driver unbind to avoid unclocked register access and unbalanced clock disable. Also restore the autosuspend setting. This issue was flagged by Sashiko when reviewing a controller deregistration fix. Fixes: d36ccd9 ("spi: cadence: Runtime pm adaptation") Cc: stable@vger.kernel.org # 4.7 Cc: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com> Link: https://sashiko.dev/#/patchset/20260414134319.978196-1-johan%40kernel.org?part=1 Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260421123615.1533617-2-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 59701f0 commit 6ac380a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/spi/spi-cadence.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,16 +697,23 @@ static void cdns_spi_remove(struct platform_device *pdev)
697697
{
698698
struct spi_controller *ctlr = platform_get_drvdata(pdev);
699699
struct cdns_spi *xspi = spi_controller_get_devdata(ctlr);
700+
int ret = 0;
701+
702+
if (!spi_controller_is_target(ctlr))
703+
ret = pm_runtime_get_sync(&pdev->dev);
700704

701705
spi_controller_get(ctlr);
702706

703707
spi_unregister_controller(ctlr);
704708

705-
cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
709+
if (ret >= 0)
710+
cdns_spi_write(xspi, CDNS_SPI_ER, CDNS_SPI_ER_DISABLE);
706711

707712
if (!spi_controller_is_target(ctlr)) {
708713
pm_runtime_disable(&pdev->dev);
709714
pm_runtime_set_suspended(&pdev->dev);
715+
pm_runtime_put_noidle(&pdev->dev);
716+
pm_runtime_dont_use_autosuspend(&pdev->dev);
710717
}
711718

712719
spi_controller_put(ctlr);

0 commit comments

Comments
 (0)