linux-stable/drivers/ata
Niklas Cassel e20e81a24a ata: libata-core: do not issue non-internal commands once EH is pending
While the ATA specification states that a device should return command
aborted for all commands queued after the device has entered error state,
since ATA only keeps the sense data for the latest command (in non-NCQ
case), we really don't want to send block layer commands to the device
after it has entered error state. (Only ATA EH commands should be sent,
to read the sense data etc.)

Currently, scsi_queue_rq() will check if scsi_host_in_recovery()
(state is SHOST_RECOVERY), and if so, it will _not_ issue a command via:
scsi_dispatch_cmd() -> host->hostt->queuecommand() (ata_scsi_queuecmd())
-> __ata_scsi_queuecmd() -> ata_scsi_translate() -> ata_qc_issue()

Before commit e494f6a728 ("[SCSI] improved eh timeout handler"),
when receiving a TFES error IRQ, the call chain looked like this:
ahci_error_intr() -> ata_port_abort() -> ata_do_link_abort() ->
ata_qc_complete() -> ata_qc_schedule_eh() -> blk_abort_request() ->
blk_rq_timed_out() -> q->rq_timed_out_fn() (scsi_times_out()) ->
scsi_eh_scmd_add() -> scsi_host_set_state(shost, SHOST_RECOVERY)

Which meant that as soon as an error IRQ was serviced, SHOST_RECOVERY
would be set.

However, after commit e494f6a728 ("[SCSI] improved eh timeout handler"),
scsi_times_out() will instead call scsi_abort_command() which will queue
delayed work, and the worker function scmd_eh_abort_handler() will call
scsi_eh_scmd_add(), which calls scsi_host_set_state(shost, SHOST_RECOVERY).

So now, after the TFES error IRQ has been serviced, we need to wait for
the SCSI workqueue to run its work before SHOST_RECOVERY gets set.

It is worth noting that, even before commit e494f6a728 ("[SCSI] improved
eh timeout handler"), we could receive an error IRQ from the time when
scsi_queue_rq() checks scsi_host_in_recovery(), to the time when
ata_scsi_queuecmd() is actually called.

In order to handle both the delayed setting of SHOST_RECOVERY and the
window where we can receive an error IRQ, add a check against
ATA_PFLAG_EH_PENDING (which gets set when servicing the error IRQ),
inside ata_scsi_queuecmd() itself, while holding the ap->lock.
(Since the ap->lock is held while servicing IRQs.)

Fixes: e494f6a728 ("[SCSI] improved eh timeout handler")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Tested-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
2022-11-12 07:51:06 +09:00
..
acard-ahci.c ata: add/use ata_taskfile::{error|status} fields 2022-02-20 09:06:05 +09:00
ahci.c ata: ahci: Convert __ahci_port_base to accepting hpriv as arguments 2022-09-17 01:39:54 +09:00
ahci.h ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS 2022-10-17 12:02:59 +09:00
ahci_brcm.c ata: ahci_brcm: Fix compilation warning 2022-10-18 08:01:57 +09:00
ahci_ceva.c ata: Drop commas after OF match table sentinels 2022-03-07 11:49:10 +09:00
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 Char/Misc and other driver updates for 5.18-rc1 2022-03-28 12:27:35 -07:00
ahci_octeon.c ata: Drop commas after OF match table sentinels 2022-03-07 11:49:10 +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 ata: Drop commas after OF match table sentinels 2022-03-07 11:49:10 +09:00
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
Kconfig ata: ahci_st: Enable compile test 2022-09-20 08:52:02 +09:00
libahci.c ata: ahci: Introduce firmware-specific caps initialization 2022-09-17 01:40:02 +09:00
libahci_platform.c ata: libahci_platform: Add function returning a clock-handle by id 2022-09-17 01:40:11 +09:00
libata-acpi.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
libata-core.c ata changes for 6.1-rc1 2022-10-07 10:48:49 -07:00
libata-eh.c ata changes for 6.1-rc1 2022-10-07 10:48:49 -07:00
libata-pata-timings.c
libata-pmp.c
libata-sata.c ata changes for 6.1-rc1 2022-10-07 10:48:49 -07:00
libata-scsi.c ata: libata-core: do not issue non-internal commands once EH is pending 2022-11-12 07:51:06 +09:00
libata-sff.c ata: libata-sff: Fix double word in comments 2022-09-16 23:24:06 +09:00
libata-trace.c
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-core: Simplify ata_build_rw_tf() 2022-08-26 07:46:08 +09:00
Makefile ata: ahci: Add DWC AHCI SATA controller support 2022-09-17 01:40:15 +09:00
pata_acpi.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pata_ali.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pata_amd.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pata_arasan_cf.c
pata_artop.c
pata_atiixp.c
pata_atp867x.c
pata_bk3710.c
pata_buddha.c
pata_cmd64x.c
pata_cmd640.c
pata_cs5520.c
pata_cs5530.c
pata_cs5535.c ata: pata_cs5535: Fix W=1 warnings 2022-06-30 08:21:43 +09:00
pata_cs5536.c
pata_cypress.c
pata_efar.c
pata_ep93xx.c ata: add/use ata_taskfile::{error|status} fields 2022-02-20 09:06:05 +09:00
pata_falcon.c
pata_ftide010.c ata: pata_ftide010: Remove unneeded ERROR check before clk_disable_unprepare 2022-05-16 20:22:37 +09:00
pata_gayle.c
pata_hpt3x2n.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pata_hpt3x3.c
pata_hpt37x.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pata_hpt366.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pata_icside.c
pata_imx.c
pata_isapnp.c
pata_it821x.c
pata_it8213.c
pata_ixp4xx_cf.c ata: Drop commas after OF match table sentinels 2022-03-07 11:49:10 +09:00
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 ata: pata_marvell: Check the 'bmdma_addr' beforing reading 2022-04-22 08:45:06 +09:00
pata_mpc52xx.c powerpc/mpc5xxx: Switch mpc5xxx_get_bus_frequency() to use fwnode 2022-06-22 12:51:49 +10:00
pata_mpiix.c
pata_netcell.c
pata_ninja32.c
pata_ns87410.c
pata_ns87415.c ata: add/use ata_taskfile::{error|status} fields 2022-02-20 09:06:05 +09:00
pata_octeon_cf.c ata: pata_octeon_cf: Fix refcount leak in octeon_cf_probe 2022-06-06 09:52:17 +09:00
pata_of_platform.c ata: Drop commas after OF match table sentinels 2022-03-07 11:49:10 +09:00
pata_oldpiix.c
pata_opti.c
pata_optidma.c
pata_palmld.c ata: palmld: fix return value check in palmld_pata_probe() 2022-10-31 20:28:05 +09:00
pata_pcmcia.c
pata_pdc202xx_old.c
pata_pdc2027x.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pata_piccolo.c
pata_platform.c
pata_pxa.c ata: pata_pxa: Use platform_get_irq() to get the interrupt 2022-03-10 11:17:59 +09:00
pata_radisys.c
pata_rb532_cf.c
pata_rdc.c
pata_rz1000.c
pata_samsung_cf.c ata: add/use ata_taskfile::{error|status} fields 2022-02-20 09:06:05 +09:00
pata_sc1200.c
pata_sch.c
pata_serverworks.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pata_sil680.c ata: pata_sil680: fix result type of sil680_sel{dev|reg}() 2022-04-13 12:42:51 +09:00
pata_sis.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pata_sl82c105.c
pata_triflex.c
pata_via.c ata: make transfer mode masks *unsigned int* 2022-06-17 16:35:02 +09:00
pdc_adma.c
sata_dwc_460ex.c ata: sata_dwc_460ex: Fix crash due to OOB write 2022-04-04 09:56:34 +09:00
sata_fsl.c ata changes for 5.18-rc1 2022-03-23 14:35:59 -07:00
sata_gemini.c ata: Make use of the helper function devm_platform_ioremap_resource() 2022-04-22 08:38:18 +09:00
sata_gemini.h
sata_highbank.c ata: Drop commas after OF match table sentinels 2022-03-07 11:49:10 +09:00
sata_inic162x.c ata: add/use ata_taskfile::{error|status} fields 2022-02-20 09:06:05 +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
sata_promise.c
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
sata_sis.c
sata_svw.c ata: add/use ata_taskfile::{error|status} fields 2022-02-20 09:06:05 +09:00
sata_sx4.c
sata_uli.c
sata_via.c
sata_vsc.c ata: add/use ata_taskfile::{error|status} fields 2022-02-20 09:06:05 +09:00
sis.h