Thread (27 messages) 27 messages, 5 authors, 2021-10-12
STALE1697d

[PATCH] libata: fix setting and checking of DMA state.

From: Reimar Döffinger <hidden>
Date: 2021-08-17 19:03:19
Subsystem: libata subsystem (serial and parallel ata drivers), the rest · Maintainers: Damien Le Moal, Niklas Cassel, Linus Torvalds

Checking if DMA is enabled should be done via the
ata_dma_enabled helper function.
Update dma_mode initialization so that SATA devices
are reported as DMA enabled.
---
 drivers/ata/libata-core.c | 4 ++--
 include/linux/ata.h       | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 9934f6c465f4..a5fe20bb22d6 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2004,7 +2004,7 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
 
 retry:
 	ata_tf_init(dev, &tf);
-	if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id) &&
+	if (ata_dma_enabled(dev) && ata_id_has_read_log_dma_ext(dev->id) &&
 	    !(dev->horkage & ATA_HORKAGE_NO_DMA_LOG)) {
 		tf.command = ATA_CMD_READ_LOG_DMA_EXT;
 		tf.protocol = ATA_PROT_DMA;
@@ -2824,7 +2824,7 @@ int ata_bus_probe(struct ata_port *ap)
 		 * bus as we may be talking too fast.
 		 */
 		dev->pio_mode = XFER_PIO_0;
-		dev->dma_mode = 0xff;
+		dev->dma_mode = ap->flags & ATA_FLAG_SATA ? XFER_SATA : 0xff;
 
 		/* If the controller has a pio mode setup function
 		 * then use it to set the chipset to rights. Don't
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 1b44f40c7700..7bb2c2acbc42 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -374,6 +374,7 @@ enum {
 
 	/* SETFEATURES stuff */
 	SETFEATURES_XFER	= 0x03,
+	XFER_SATA               = 0x48,
 	XFER_UDMA_7		= 0x47,
 	XFER_UDMA_6		= 0x46,
 	XFER_UDMA_5		= 0x45,
-- 
2.32.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help