Am Do, den 30.12.2004 schrieb Felix K�hling um 15:06:
> Am Do, den 30.12.2004 schrieb Dave Airlie um 13:19:
> > >
> > > drm_pci_alloc allows limiting the maximum address. Would it be too
> > > hackish to pass this via map->offset to the drm_addmap ioctl?
> >
> > Probably no need for the Xserver maps to care about a max address I'd hate
> > to overload anything in the addmap ioctl...
>
> Ok. Anyway, it doesn't work. I tried to use drm_pci_alloc for allocating
> _DRM_CONSISTENT maps. But after successful DRI initialization the
> Xserver is just killed by the VM, probably when it accesses the status
> page for the first time:
>
> Dec 30 14:53:14 viking kernel: VM: killing process Xorg
It seems this was related to limiting the max_address. Anythingh other
than 0xffffffffUL makes pci_alloc_consistent allocate pages with GFP_DMA
which is intended for ISA DMA < 16MB. I don't think we're ever going to
need this in a DRM driver. I attached an updated patch that uses
drm_pci_alloc now. Just say "GO!" and I'll commit it. ;-)
--
| Felix K�hling <[EMAIL PROTECTED]> http://fxk.de.vu |
| PGP Fingerprint: 6A3C 9566 5B30 DDED 73C3 B152 151C 5CC1 D888 E595 |
Index: linux-core/drm_bufs.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_bufs.c,v
retrieving revision 1.51
diff -u -r1.51 drm_bufs.c
--- linux-core/drm_bufs.c 18 Oct 2004 14:16:41 -0000 1.51
+++ linux-core/drm_bufs.c 30 Dec 2004 14:59:33 -0000
@@ -244,7 +244,21 @@
}
map->offset += dev->sg->handle;
break;
-
+ case _DRM_CONSISTENT: {
+ /* dma_addr_t is 64bit on i386 with CONFIG_HIGHMEM64G.
+ * As we're limiting the address to 2^32-1 (or less),
+ * casting it down to 32 bits is no problem, but we
+ * need to point to a 64bit variable first. */
+ dma_addr_t bus_addr;
+ map->handle = drm_pci_alloc(dev, map->size, map->size,
+ 0xffffffffUL, &bus_addr);
+ map->offset = (unsigned long)bus_addr;
+ if (!map->handle) {
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ return -ENOMEM;
+ }
+ break;
+ }
default:
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return -EINVAL;
@@ -348,6 +362,9 @@
case _DRM_AGP:
case _DRM_SCATTER_GATHER:
break;
+ case _DRM_CONSISTENT:
+ drm_pci_free(dev, map->size, map->handle, map->offset);
+ break;
}
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
Index: linux-core/drm_drv.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_drv.c,v
retrieving revision 1.106
diff -u -r1.106 drm_drv.c
--- linux-core/drm_drv.c 7 Dec 2004 12:18:47 -0000 1.106
+++ linux-core/drm_drv.c 30 Dec 2004 14:59:36 -0000
@@ -227,6 +227,10 @@
dev->sg = NULL;
}
break;
+ case _DRM_CONSISTENT:
+ drm_pci_free(dev, map->size,
+ map->handle, map->offset);
+ break;
}
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
@@ -396,6 +400,7 @@
case _DRM_SHM:
case _DRM_AGP:
case _DRM_SCATTER_GATHER:
+ case _DRM_CONSISTENT:
DRM_DEBUG("Extra maplist item\n");
break;
}
Index: linux-core/drm_proc.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_proc.c,v
retrieving revision 1.23
diff -u -r1.23 drm_proc.c
--- linux-core/drm_proc.c 20 Oct 2004 05:11:49 -0000 1.23
+++ linux-core/drm_proc.c 30 Dec 2004 14:59:39 -0000
@@ -211,9 +211,9 @@
struct list_head *list;
/* Hardcoded from _DRM_FRAME_BUFFER,
- _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
- _DRM_SCATTER_GATHER. */
- const char *types[] = { "FB", "REG", "SHM", "AGP", "SG" };
+ _DRM_REGISTERS, _DRM_SHM, _DRM_AGP,
+ _DRM_SCATTER_GATHER, and _DRM_CONSISTENT. */
+ const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
const char *type;
int i;
@@ -234,7 +234,7 @@
map = r_list->map;
if (!map)
continue;
- if (map->type < 0 || map->type > 4)
+ if (map->type < 0 || map->type > 5)
type = "??";
else
type = types[map->type];
Index: linux-core/drm_vm.c
===================================================================
RCS file: /cvs/dri/drm/linux-core/drm_vm.c,v
retrieving revision 1.47
diff -u -r1.47 drm_vm.c
--- linux-core/drm_vm.c 23 Oct 2004 06:59:15 -0000 1.47
+++ linux-core/drm_vm.c 30 Dec 2004 14:59:40 -0000
@@ -232,6 +232,10 @@
case _DRM_AGP:
case _DRM_SCATTER_GATHER:
break;
+ case _DRM_CONSISTENT:
+ drm_pci_free(dev, map->size, map->handle,
+ map->offset);
+ break;
}
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
@@ -658,6 +662,9 @@
vma->vm_ops = &drm_vm_ops;
break;
case _DRM_SHM:
+ case _DRM_CONSISTENT:
+ /* Consistent memory is really like shared memory. It's only
+ * allocated in a different way. */
vma->vm_ops = &drm_vm_shm_ops;
vma->vm_private_data = (void *)map;
/* Don't let this area swap. Change when
Index: shared-core/drm.h
===================================================================
RCS file: /cvs/dri/drm/shared-core/drm.h,v
retrieving revision 1.59
diff -u -r1.59 drm.h
--- shared-core/drm.h 30 Sep 2004 21:12:09 -0000 1.59
+++ shared-core/drm.h 30 Dec 2004 14:59:42 -0000
@@ -246,7 +246,8 @@
_DRM_REGISTERS = 1, /**< no caching, no core dump */
_DRM_SHM = 2, /**< shared, cached */
_DRM_AGP = 3, /**< AGP/GART */
- _DRM_SCATTER_GATHER = 4 /**< Scatter/gather memory for PCI DMA */
+ _DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */
+ _DRM_CONSISTENT = 5 /**< Consistent memory for PCI DMA */
} drm_map_type_t;
/**
Index: libdrm/xf86drm.h
===================================================================
RCS file: /cvs/dri/drm/libdrm/xf86drm.h,v
retrieving revision 1.2
diff -u -r1.2 xf86drm.h
--- libdrm/xf86drm.h 31 Jul 2004 08:12:39 -0000 1.2
+++ libdrm/xf86drm.h 30 Dec 2004 14:59:43 -0000
@@ -104,7 +104,8 @@
DRM_REGISTERS = 1, /**< no caching, no core dump */
DRM_SHM = 2, /**< shared, cached */
DRM_AGP = 3, /**< AGP/GART */
- DRM_SCATTER_GATHER = 4 /**< PCI scatter/gather */
+ DRM_SCATTER_GATHER = 4, /**< PCI scatter/gather */
+ DRM_CONSISTENT = 5 /**< PCI consistent */
} drmMapType;
typedef enum {