public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3] ata: ahci allow 64-bit DMA for SATA
@ 2019-10-14  9:21 Roman Kapl
  2019-11-01 13:30 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Roman Kapl @ 2019-10-14  9:21 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Roman Kapl <rka@sysgo.com>
---
v1 -> v2: v1 was a mistake
v2 -> v3: suppress warning on 32-bit phys addr platforms by using the
           upper/lower 32 bits macros

 drivers/ata/ahci.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 21a89eba5a..d10f9f0bf8 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -50,6 +50,8 @@ struct ahci_uc_priv *probe_ent = NULL;
 #define WAIT_MS_FLUSH	5000
 #define WAIT_MS_LINKUP	200
 
+#define AHCI_CAP_S64A BIT(31)
+
 __weak void __iomem *ahci_port_base(void __iomem *base, u32 port)
 {
 	return base + 0x100 + (port * 0x80);
@@ -503,9 +505,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(lower_32_bits(pa));
+		ahci_sg->addr_hi = cpu_to_le32(upper_32_bits(pa));
+		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)
-- 
2.22.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH v3] ata: ahci allow 64-bit DMA for SATA
  2019-10-14  9:21 [U-Boot] [PATCH v3] ata: ahci allow 64-bit DMA for SATA Roman Kapl
@ 2019-11-01 13:30 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2019-11-01 13:30 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 14, 2019 at 11:21:09AM +0200, Roman Kapl wrote:

> Allow 64-bit DMA on AHCI. If not supported by the host controller, at
> least print a message and fail.
> 
> Signed-off-by: Roman Kapl <rka@sysgo.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191101/3d596807/attachment.sig>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-01 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-14  9:21 [U-Boot] [PATCH v3] ata: ahci allow 64-bit DMA for SATA Roman Kapl
2019-11-01 13:30 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox