Skip to content

Commit 04c0c55

Browse files
floatiousgregkh
authored andcommitted
ata: libata-eh: Do not use ATAPI DMA for a device limited to PIO mode
[ Upstream commit 91ec84f ] atapi_eh_request_sense() currently uses ATAPI DMA if the SATA controller has ATA_FLAG_PIO_DMA (PIO cmds via DMA) set. However, ATA_FLAG_PIO_DMA is a flag that can be set by a low-level driver on a port at initialization time, before any devices are scanned. If a controller detects a connected device that only supports PIO, we set the flag ATA_DFLAG_PIO. Modify atapi_eh_request_sense() to not use ATAPI DMA if the connected device only supports PIO. Reported-by: Philip Pemberton <lists@philpem.me.uk> Closes: https://lore.kernel.org/linux-ide/c6722ee8-5e21-4169-af59-cbbae9edc02f@philpem.me.uk/ Tested-by: Philip Pemberton <lists@philpem.me.uk> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/r/20250221015422.20687-2-cassel@kernel.org Signed-off-by: Niklas Cassel <cassel@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ccd97c8 commit 04c0c55

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/ata/libata-eh.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,8 +1542,15 @@ unsigned int atapi_eh_request_sense(struct ata_device *dev,
15421542
tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
15431543
tf.command = ATA_CMD_PACKET;
15441544

1545-
/* is it pointless to prefer PIO for "safety reasons"? */
1546-
if (ap->flags & ATA_FLAG_PIO_DMA) {
1545+
/*
1546+
* Do not use DMA if the connected device only supports PIO, even if the
1547+
* port prefers PIO commands via DMA.
1548+
*
1549+
* Ideally, we should call atapi_check_dma() to check if it is safe for
1550+
* the LLD to use DMA for REQUEST_SENSE, but we don't have a qc.
1551+
* Since we can't check the command, perhaps we should only use pio?
1552+
*/
1553+
if ((ap->flags & ATA_FLAG_PIO_DMA) && !(dev->flags & ATA_DFLAG_PIO)) {
15471554
tf.protocol = ATAPI_PROT_DMA;
15481555
tf.feature |= ATAPI_PKT_DMA;
15491556
} else {

0 commit comments

Comments
 (0)