On Friday, March 4, 2005 10:05 am, Stephane Marchesin wrote:
> >It also looks like drm_addbufs_pci uses virt_to_bus, which won't work on
> > many non-x86 platforms. Hmm... the version in latest 2.6 kernel tree
> > doesn't seem to have these problems, which one is the master copy?
>
> It's drm cvs, which gets merged into 2.6 from time to time.
Well, we'd better fix it before it gets merged then! :)
In particular, this snippet from linux-core/drm_bufs.c:drm_addbufs_pci:
buf->order = order;
buf->used = 0;
buf->offset = (dma->byte_count + byte_count + offset);
buf->address = (void *)(page + offset);
buf->bus_address = virt_to_bus(buf->address);
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
It looks like the bus_address field usage here is new? At least I don't see
it in the same routine in the latest 2.6 kernel tree. The problem with
virt_to_bus is that it doesn't specify *which* bus, so it's only suitable on
machines with very simple bus layouts (and I/O cache coherent ones at that).
Seems like we need something like this instead?
Index: linux-core/drm_dma.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_dma.c,v
retrieving revision 1.39
diff -u -r1.39 drm_dma.c
--- linux-core/drm_dma.c 31 Oct 2004 15:16:44 -0000 1.39
+++ linux-core/drm_dma.c 4 Mar 2005 18:29:03 -0000
@@ -141,6 +141,9 @@
buf->filp = NULL;
buf->used = 0;
+ pci_unmap_page(dev->pdev, buf->bus_address, buf->total,
+ PCI_DMA_FROMDEVICE);
+
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)
&& waitqueue_active(&buf->dma_wait)) {
wake_up_interruptible(&buf->dma_wait);
Index: linux-core/drm_bufs.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_bufs.c,v
retrieving revision 1.54
diff -u -r1.54 drm_bufs.c
--- linux-core/drm_bufs.c 5 Feb 2005 08:00:14 -0000 1.54
+++ linux-core/drm_bufs.c 4 Mar 2005 18:29:04 -0000
@@ -752,7 +752,9 @@
buf->used = 0;
buf->offset = (dma->byte_count + byte_count + offset);
buf->address = (void *)(page + offset);
- buf->bus_address = virt_to_bus(buf->address);
+ buf->bus_address = pci_map_page(dev->pdev, page, offset,
+ buf->total,
+ PCI_DMA_TODEVICE);
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel