Skip to content

Commit b8ed216

Browse files
floatiousvijay-suman
authored andcommitted
ata: libata-eh: Do not use ATAPI DMA for a device limited to PIO mode
[ Upstream commit 91ec84f8eaddbc93d7c62e363d68aeb7b89879c7 ] 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]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 714036b176babbc3cf94e6c9d6ebe55d1b02747f) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 1bf16d9 commit b8ed216

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
@@ -1479,8 +1479,15 @@ unsigned int atapi_eh_request_sense(struct ata_device *dev,
14791479
tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
14801480
tf.command = ATA_CMD_PACKET;
14811481

1482-
/* is it pointless to prefer PIO for "safety reasons"? */
1483-
if (ap->flags & ATA_FLAG_PIO_DMA) {
1482+
/*
1483+
* Do not use DMA if the connected device only supports PIO, even if the
1484+
* port prefers PIO commands via DMA.
1485+
*
1486+
* Ideally, we should call atapi_check_dma() to check if it is safe for
1487+
* the LLD to use DMA for REQUEST_SENSE, but we don't have a qc.
1488+
* Since we can't check the command, perhaps we should only use pio?
1489+
*/
1490+
if ((ap->flags & ATA_FLAG_PIO_DMA) && !(dev->flags & ATA_DFLAG_PIO)) {
14841491
tf.protocol = ATAPI_PROT_DMA;
14851492
tf.feature |= ATAPI_PKT_DMA;
14861493
} else {

0 commit comments

Comments
 (0)