From 0f6e823d077fae8ba9f792499ebcd236df608e57 Mon Sep 17 00:00:00 2001 From: jmcneill Date: Wed, 21 Mar 2007 22:15:59 +0000 Subject: [PATCH] In drm_ioremap, provide extra slots for mapping AGP memory space; it's not reasonable to assume that these regions will show up in a VGA BAR. --- sys/dev/drm/drmP.h | 1 + sys/dev/drm/drm_memory.c | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/sys/dev/drm/drmP.h b/sys/dev/drm/drmP.h index 7ab2fc114377..b94d41ccaea7 100644 --- a/sys/dev/drm/drmP.h +++ b/sys/dev/drm/drmP.h @@ -848,6 +848,7 @@ struct drm_device { #elif defined(__NetBSD__) || defined(__OpenBSD__) struct pci_attach_args pa; pci_map_data_t pci_map_data[DRM_MAX_PCI_RESOURCE]; + pci_map_data_t agp_map_data[DRM_MAX_PCI_RESOURCE]; int unit; /* drm unit number */ #endif void *irqh; /* Handle from bus_setup_intr */ diff --git a/sys/dev/drm/drm_memory.c b/sys/dev/drm/drm_memory.c index 5d2d6ba7f899..800507603adc 100644 --- a/sys/dev/drm/drm_memory.c +++ b/sys/dev/drm/drm_memory.c @@ -120,6 +120,47 @@ void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map) return dev->pci_map_data[i].vaddr; } } + /* failed to find a valid mapping; all hope isn't lost though */ + for(i = 0; iagp_map_data[i].mapped > 0 && + dev->agp_map_data[i].base == map->offset && + dev->agp_map_data[i].size >= map->size) { + map->bst = dev->pa.pa_memt; + map->cnt = &(dev->agp_map_data[i].mapped); + map->mapsize = dev->agp_map_data[i].size; + dev->agp_map_data[i].mapped++; + map->bsh = dev->agp_map_data[i].bsh; + return dev->agp_map_data[i].vaddr; + } + if (dev->agp_map_data[i].mapped == 0) { + int rv; + + map->bst = dev->pa.pa_memt; + dev->agp_map_data[i].mapped++; + dev->agp_map_data[i].size = map->size; + dev->agp_map_data[i].flags = BUS_SPACE_MAP_LINEAR; + dev->agp_map_data[i].maptype = PCI_MAPREG_TYPE_MEM; + map->cnt = &(dev->agp_map_data[i].mapped); + map->mapsize = dev->agp_map_data[i].size; + + rv = bus_space_map(map->bst, map->offset, + dev->agp_map_data[i].size, + dev->agp_map_data[i].flags, &map->bsh); + if (rv) { + dev->agp_map_data[i].mapped--; + DRM_DEBUG("ioremap: failed to map (%d)\n", rv); + return NULL; + } + dev->agp_map_data[i].bsh = map->bsh; + dev->agp_map_data[i].vaddr = + bus_space_vaddr(map->bst, map->bsh); + DRM_DEBUG("ioremap agp mem found: %p\n", + dev->agp_map_data[i].vaddr); + return dev->agp_map_data[i].vaddr; + } + } + + /* now we can give up... */ DRM_DEBUG("drm_ioremap failed: offset=%lx size=%lu\n", map->offset, map->size); return NULL;