Re: [Patch] dma_sync_to_device

From: Deepak Saxena
Date: Wed Feb 11 2004 - 01:19:47 EST


On Feb 10 2004, at 18:31, Martin Diehl was caught saying:
[snip]
> --- linux-2.6.0-test8/Documentation/DMA-mapping.txt Wed Oct 8 21:24:06 2003
> +++ v2.6.0-test8-md/Documentation/DMA-mapping.txt Tue Oct 21 11:27:17 2003
> @@ -543,8 +543,11 @@
> all bus addresses.
>
> If you need to use the same streaming DMA region multiple times and touch
> -the data in between the DMA transfers, just map it with
> -pci_map_{single,sg}, and after each DMA transfer call either:
> +the data in between the DMA transfers, the buffer needs to be synced
> +depending on the transfer direction.
> +
> +When reading from the device, just map it with pci_map_{single,sg},
> +and after each DMA transfer call either:
>
> pci_dma_sync_single(dev, dma_handle, size, direction);
>
> @@ -553,6 +556,20 @@
> pci_dma_sync_sg(dev, sglist, nents, direction);
>
> as appropriate.
> +
> +When writing to the mapped the buffer, prepare the data and
> +then before giving the buffer to the hardware call either:
> +
> + pci_dma_sync_to_device_single(dev, dma_handle, size, direction);
> +
> +or:
> +
> + pci_dma_sync_to_device_sg(dev, sglist, nents, direction);

Maybe I am missunderstanding something, but how is this
any different than simply doing:

pci_dma_sync_single(dev, dma_handle, size, DMA_TO_DEVICE);

My understanding of the API is that I can map a buffer
as DMA_BIDIRECTIONAL and then specify the direction. An
existing working example is in the eepro100 driver
in speedo_init_rx_ring():

sp->rx_ring_dma[i] = pci_map_single(sp->pdev, rxf,
PKT_BUF_SZ + sizeof(struct RxFD), PCI_DMA_BIDIRECTIONAL);

later in the same function:

pci_dma_sync_single(sp->pdev, sp->rx_ring_dma[i],
sizeof(struct RxFD), PCI_DMA_TODEVICE);

If this is not allowed, then the docs and this driver
(along with any others using it) need to be updated.
If this acceptable, why add an existing function to
achieve the same goal?

~Deepak

--
Deepak Saxena - dsaxena at plexity dot net - http://www.plexity.net/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/