linux-stable/drivers/ata
Damien Le Moal acadffcc16 ata: libata-scsi: Avoid deadlock on rescan after device resume
[ Upstream commit 6aa0365a3c ]

When an ATA port is resumed from sleep, the port is reset and a power
management request issued to libata EH to reset the port and rescanning
the device(s) attached to the port. Device rescanning is done by
scheduling an ata_scsi_dev_rescan() work, which will execute
scsi_rescan_device().

However, scsi_rescan_device() takes the generic device lock, which is
also taken by dpm_resume() when the SCSI device is resumed as well. If
a device rescan execution starts before the completion of the SCSI
device resume, the rcu locking used to refresh the cached VPD pages of
the device, combined with the generic device locking from
scsi_rescan_device() and from dpm_resume() can cause a deadlock.

Avoid this situation by changing struct ata_port scsi_rescan_task to be
a delayed work instead of a simple work_struct. ata_scsi_dev_rescan() is
modified to check if the SCSI device associated with the ATA device that
must be rescanned is not suspended. If the SCSI device is still
suspended, ata_scsi_dev_rescan() returns early and reschedule itself for
execution after an arbitrary delay of 5ms.

Reported-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Reported-by: Joe Breuer <linux-kernel@jmbreuer.net>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217530
Fixes: a19a93e4c6 ("scsi: core: pm: Rely on the device driver core for async power management")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Tested-by: Joe Breuer <linux-kernel@jmbreuer.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-06-28 11:13:57 +02:00
..
pata_parport ata: pata_parport: fix memory leaks 2023-03-16 16:54:38 +09:00
Kconfig ATA changes for 6.3-rc1 2023-02-22 13:35:51 -08:00
Makefile ATA changes for 6.3-rc1 2023-02-22 13:35:51 -08:00
acard-ahci.c ata: libata: simplify qc_fill_rtf port operation interface 2023-01-04 13:37:45 +09:00
ahci.c ata: ahci: Revert "ata: ahci: Add Tiger Lake UP{3,4} AHCI controller" 2023-03-03 18:43:02 +09:00
ahci.h ata changes for 6.2 2022-12-13 10:54:19 -08:00
ahci_brcm.c ata: ahci_brcm: Fix compilation warning 2022-10-18 08:01:57 +09:00
ahci_ceva.c
ahci_da850.c ata: libahci_platform: Convert to using devm bulk clocks API 2022-09-17 01:39:22 +09:00
ahci_dm816.c ata: libahci_platform: Convert to using devm bulk clocks API 2022-09-17 01:39:22 +09:00
ahci_dwc.c ata: ahci-dwc: Add Baikal-T1 AHCI SATA interface support 2022-09-17 01:40:31 +09:00
ahci_imx.c ata: ahci_imx: Fix compilation warning 2022-10-18 08:02:14 +09:00
ahci_mtk.c ata: libahci_platform: Parse ports-implemented property in resources getter 2022-09-17 01:39:30 +09:00
ahci_mvebu.c
ahci_octeon.c ata: octeon: Drop empty platform remove function 2023-01-03 08:39:41 +09:00
ahci_platform.c ata: ahci: Add DWC AHCI SATA controller support 2022-09-17 01:40:15 +09:00
ahci_qoriq.c ata: ahci_qoriq: Fix compilation warning 2022-10-18 08:02:14 +09:00
ahci_seattle.c
ahci_st.c ata: ahci_st: Fix compilation warning 2022-10-17 22:01:57 +09:00
ahci_sunxi.c
ahci_tegra.c
ahci_xgene.c ata: ahci_xgene: Fix compilation warning 2022-10-18 08:02:14 +09:00
ata_generic.c
ata_piix.c
libahci.c ata: libata: respect successfully completed commands during errors 2023-01-04 13:39:19 +09:00
libahci_platform.c ata: libahci_platform: ahci_platform_find_clk: oops, NULL pointer 2022-12-07 08:36:37 +09:00
libata-acpi.c ata: make use of ata_port_is_frozen() helper 2022-10-18 13:53:27 +09:00
libata-core.c ata: libata-scsi: Avoid deadlock on rescan after device resume 2023-06-28 11:13:57 +02:00
libata-eh.c ata: libata-scsi: Avoid deadlock on rescan after device resume 2023-06-28 11:13:57 +02:00
libata-pata-timings.c
libata-pmp.c
libata-sata.c ata: libata: read the shared status for successful NCQ commands once 2023-01-04 13:38:14 +09:00
libata-scsi.c ata: libata-scsi: Avoid deadlock on rescan after device resume 2023-06-28 11:13:57 +02:00
libata-sff.c ata: libata: simplify qc_fill_rtf port operation interface 2023-01-04 13:37:45 +09:00
libata-trace.c ata: scsi: rename flag ATA_QCFLAG_FAILED to ATA_QCFLAG_EH 2023-01-04 13:36:26 +09:00
libata-transport.c ata: libata-transport: fix error handling in ata_tdev_add() 2022-11-11 17:26:05 +09:00
libata-transport.h
libata-zpodd.c
libata.h ata: libata: only set sense valid flag if sense data is valid 2022-10-17 11:31:52 +09:00
pata_acpi.c
pata_ali.c
pata_amd.c
pata_arasan_cf.c
pata_artop.c
pata_atiixp.c
pata_atp867x.c
pata_buddha.c
pata_cmd64x.c
pata_cmd640.c
pata_cs5520.c
pata_cs5530.c
pata_cs5535.c
pata_cs5536.c
pata_cypress.c
pata_efar.c
pata_ep93xx.c ata: pata_ep93xx: use devm_platform_get_and_ioremap_resource() 2022-11-12 10:58:56 +09:00
pata_falcon.c
pata_ftide010.c ata: pata_ftide010: Remove build dependency on OF 2022-10-18 08:05:10 +09:00
pata_gayle.c
pata_hpt3x2n.c
pata_hpt3x3.c
pata_hpt37x.c
pata_hpt366.c
pata_icside.c
pata_imx.c
pata_isapnp.c
pata_it821x.c
pata_it8213.c
pata_ixp4xx_cf.c
pata_jmicron.c
pata_legacy.c ata: pata_legacy: fix pdc20230_set_piomode() 2022-10-31 20:27:27 +09:00
pata_macio.c ata: pata_macio: Remove unneeded word in comments 2022-09-16 23:24:06 +09:00
pata_marvell.c
pata_mpc52xx.c ata: pata_mpc52xx: Replace NO_IRQ with 0 2022-10-17 11:38:15 +09:00
pata_mpiix.c
pata_netcell.c
pata_ninja32.c
pata_ns87410.c
pata_ns87415.c
pata_octeon_cf.c ata: pata_octeon_cf: drop kernel-doc notation 2023-02-14 12:23:37 +09:00
pata_of_platform.c
pata_oldpiix.c
pata_opti.c
pata_optidma.c
pata_pcmcia.c
pata_pdc202xx_old.c
pata_pdc2027x.c
pata_piccolo.c
pata_platform.c
pata_pxa.c
pata_radisys.c
pata_rb532_cf.c
pata_rdc.c
pata_rz1000.c
pata_sc1200.c
pata_sch.c
pata_serverworks.c
pata_sil680.c
pata_sis.c
pata_sl82c105.c
pata_triflex.c
pata_via.c
pdc_adma.c
sata_dwc_460ex.c ata: sata_dwc_460ex: Check !irq instead of irq == NO_IRQ 2022-11-12 11:00:04 +09:00
sata_fsl.c ata: libata: simplify qc_fill_rtf port operation interface 2023-01-04 13:37:45 +09:00
sata_gemini.c ata: sata_gemini: Remove dependency on OF for compile tests 2022-10-18 08:04:46 +09:00
sata_gemini.h
sata_highbank.c
sata_inic162x.c ata: libata: simplify qc_fill_rtf port operation interface 2023-01-04 13:37:45 +09:00
sata_mv.c ata: sata_mv: Fixes expected number of resources now IRQs are gone 2022-08-03 07:59:12 +09:00
sata_nv.c ata: make use of ata_port_is_frozen() helper 2022-10-18 13:53:27 +09:00
sata_promise.c ata: scsi: rename flag ATA_QCFLAG_FAILED to ATA_QCFLAG_EH 2023-01-04 13:36:26 +09:00
sata_promise.h
sata_qstor.c
sata_rcar.c ata: sata_rcar: Fix compilation warning 2022-10-18 08:01:45 +09:00
sata_sil.c
sata_sil24.c ata: libata: simplify qc_fill_rtf port operation interface 2023-01-04 13:37:45 +09:00
sata_sis.c
sata_svw.c
sata_sx4.c ata: scsi: rename flag ATA_QCFLAG_FAILED to ATA_QCFLAG_EH 2023-01-04 13:36:26 +09:00
sata_uli.c
sata_via.c
sata_vsc.c
sis.h