Skip to contentSkip to conversation

ata: ahci allow 64-bit DMA for SATA

PATCH Superseded Roman Kapl 1 participant 1 message Aug 28, 2019 libata

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Roman Kapl

author
#0 lore raw

PATCH 1/1 ata: ahci allow 64-bit DMA for SATA

Allow 64-bit DMA on AHCI. If not supported by the host controller, at least print a message and fail.

---
 drivers/ata/ahci.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/ata/ahci.c +9 -3
index 9a08575053..02007ad4bd 100644
@@ -503,9 +503,15 @@ static int ahci_fill_sg(struct ahci_uc_priv *uc_priv, u8 port,
 	}
 
 	for (i = 0; i < sg_count; i++) {
-		ahci_sg->addr =
-		    cpu_to_le32((unsigned long) buf + i * MAX_DATA_BYTE_COUNT);
-		ahci_sg->addr_hi = 0;
+		/* We assume virt=phys */
+		phys_addr_t pa = (unsigned long)buf + i * MAX_DATA_BYTE_COUNT;
+
+		ahci_sg->addr = cpu_to_le32(pa & U32_MAX);
+		ahci_sg->addr_hi = cpu_to_le32((pa >> 32) & U32_MAX);
+		if (ahci_sg->addr_hi && !(uc_priv->cap & AHCI_CAP_S64A)) {
+			printf("Error: DMA address too high\n");
+			return -1;
+		}
 		ahci_sg->flags_size = cpu_to_le32(0x3fffff &
 					  (buf_len < MAX_DATA_BYTE_COUNT
 					   ? (buf_len - 1)
Signature · 1 line
2.22.0