From: William Jhun <wjhun@ayrnetworks.com>
To: "David S. Miller" <davem@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Functions to complement pci_dma_sync_{single,sg}(). (was: Re: Possible discrepancy regarding streaming DMA mappings in DMA-mapping.txt?)
Date: Fri, 24 May 2002 20:41:30 -0700 [thread overview]
Message-ID: <20020524204130.A17401@ayrnetworks.com> (raw)
In-Reply-To: <20020523162425.G7205@ayrnetworks.com> <20020523.225927.132611174.davem@redhat.com> <20020524104345.J7205@ayrnetworks.com> <20020524.104209.31440798.davem@redhat.com>
On Fri, May 24, 2002 at 10:42:09AM -0700, David S. Miller wrote:
> I see what your problem is, the interfaces were designed such
> that the CPU could read the data. It did not consider writes.
>
> It was designed to handle a case like a networking driver where
> a receive packet is inspected before we decide whether we accept the
> packet or just give it back to the card.
>
> Feel free to design the "cpu writes, back to device ownership"
> interfaces and submit a patch :-)
Here is a patch to demonstrate which calls I'd like added. I'll send a
similar one to linux-mips if this interface looks ok...
This patch adds two functions, pci_dma_prep_single() and
pci_dma_prep_sg(), for a driver to relinquish a buffer to a PCI device
after having gained "ownership" via pci_dma_sync_*(). Essentially,
they should do whatever pci_map_*() does to prepare the buffer for
being accessed by the device, except for the mapping itself (e.g.
flush cache lines, copy to a bounce buffer if direction is
PCIDMA_TO_DEVICE, etc).
This is useful if one wants to use a buffer for making repeated DMA
transfers into a device without having to unmap the buffer. In such a
case, a typical usage would be:
1) Take a buffer that is "owned" by the PCI device
2) pci_dma_sync_single(...., PCIDMA_TO_DEVICE); buffer is
now owned by the driver
3) Write into the buffer
4) pci_dma_prep_single(...., PCIDMA_TO_DEVICE);
5) Perform DMA transfer
6) goto 1)
Thanks,
William
--
Index: include/asm-i386/pci.h
===================================================================
RCS file: /vger/linux/include/asm-i386/pci.h,v
retrieving revision 1.16.2.2
diff -c -r1.16.2.2 pci.h
*** include/asm-i386/pci.h 24 Jan 2002 13:38:58 -0000 1.16.2.2
--- include/asm-i386/pci.h 25 May 2002 03:24:56 -0000
***************
*** 209,214 ****
--- 209,247 ----
flush_write_buffers();
}
+ /*
+ * Prepare buffer for a DMA transfer after driver temporarily
+ * re-claimed it with pci_dma_sync_*().
+ *
+ * In essence, this "returns" the buffer to the PCI device.
+ */
+ static inline void pci_dma_prep_single(struct pci_dev *hwdev,
+ dma_addr_t dma_handle,
+ size_t size, int direction)
+ {
+ if (direction == PCI_DMA_NONE)
+ BUG();
+
+ flush_write_buffers();
+ }
+
+ /*
+ * Prepare buffer for a DMA transfer after driver temporarily
+ * re-claimed it with pci_dma_sync_*().
+ *
+ * The same as pci_dma_prep_single but for a scatter-gather list,
+ * same rules and usage.
+ */
+ static inline void pci_dma_prep_sg(struct pci_dev *hwdev,
+ struct scatterlist *sg,
+ int nelems, int direction)
+ {
+ if (direction == PCI_DMA_NONE)
+ BUG();
+
+ flush_write_buffers();
+ }
+
/* Return whether the given PCI device DMA address mask can
* be supported properly. For example, if your device can
* only drive the low 24-bits during PCI bus mastering, then
next prev parent reply other threads:[~2002-05-25 3:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-23 23:24 Possible discrepancy regarding streaming DMA mappings in DMA-mapping.txt? William Jhun
2002-05-24 5:59 ` David S. Miller
2002-05-24 17:43 ` William Jhun
2002-05-24 17:42 ` David S. Miller
2002-05-24 20:37 ` William Jhun
2002-05-24 20:26 ` David S. Miller
2002-05-24 20:58 ` William Jhun
2002-05-24 20:53 ` David S. Miller
2002-05-24 21:18 ` William Jhun
2002-05-25 3:41 ` William Jhun [this message]
2002-05-25 23:04 ` [PATCH] Functions to complement pci_dma_sync_{single,sg}() David S. Miller
2002-05-26 7:09 ` [PATCH] DMA-mapping.txt (was Re: [PATCH] Functions to complement pci_dma_sync_{single,sg}().) William Jhun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020524204130.A17401@ayrnetworks.com \
--to=wjhun@ayrnetworks.com \
--cc=davem@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.