Skip to content

Commit 91ec84f

Browse files
committed
ata: libata-eh: Do not use ATAPI DMA for a device limited to PIO mode
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 <[email protected]> Closes: https://lore.kernel.org/linux-ide/[email protected]/ Tested-by: Philip Pemberton <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Niklas Cassel <[email protected]>
1 parent 08a04e2 commit 91ec84f

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)