While working on bring-up SATA on ARM SoC I had issues with DMA memory
coherency. After tracing, I have found problem in generic ATA code behaviour.
The ATA generic driver allocates 64k DMA workspace memory which can be
optionally used by ATA chipset drivers. Currently only ata-ahci, ata-marvell,
ata-promise and ata-siliconimage relies on this feature. In general, the
drivers use preallocated DMA workspace to hold small request descriptors,
consumed by hardware.
All of these drivers do not synchronize workspace with bus_dmamap_sync(). They
assumes that DMA workspace is coherent. However ATA driver neither enforces
coherency by using BUS_DMA_COHERENT flag nor synchronizes the workspace with
bus_dmamap_sync().
I have fixed my problem by adding BUS_DMA_COHERENT flag to workspace
allocation code:
diff --git a/sys/dev/ata/ata-dma.c b/sys/dev/ata/ata-dma.c
index ab4c3c8..71ee41b 100644
--- a/sys/dev/ata/ata-dma.c
+++ b/sys/dev/ata/ata-dma.c
@@ -95,8 +95,8 @@ ata_dmainit(device_t dev)
0, NULL, NULL, &ch->dma.work_tag))
goto error;
- if (bus_dmamem_alloc(ch->dma.work_tag, (void **)&ch->dma.work, 0,
- &ch->dma.work_map))
+ if (bus_dmamem_alloc(ch->dma.work_tag, (void **)&ch->dma.work,
+ BUS_DMA_COHERENT, &ch->dma.work_map))
goto error;
if (bus_dmamap_load(ch->dma.work_tag, ch->dma.work_map, ch->dma.work,
The question is about multiplatform impact of this change. Especially I am
curious how everything works without any problems on i386.
--
Best Regards.
Piotr Ziecik.
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"| Linus Torvalds | Linux 2.6.21 |
| debian developer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Jan Engelhardt | intel iommu (Re: -mm merge plans for 2.6.23) |
| Greg Kroah-Hartman | [PATCH 002/196] Chinese: rephrase English introduction in HOWTO |
git: | |
| Andrew Morton | Re: [Bugme-new] [Bug 12877] New: tg3: eth0 transit timed out, resetting -> dead NIC |
| Krzysztof Oledzki | Error: an inet prefix is expected rather than "0/0". |
| David Miller | Re: iptables very slow after commit784544739a25c30637397ace5489eeb6e15d7d49 |
| Johann Baudy | Packet mmap: TX RING and zero copy |
