Correct a LOR related to the PCI resource allocations by simply moving the
authorEric Anholt <anholt@freebsd.org>
Tue, 8 Nov 2005 06:11:55 +0000 (06:11 +0000)
committerEric Anholt <anholt@freebsd.org>
Tue, 8 Nov 2005 06:11:55 +0000 (06:11 +0000)
    uninit to unload time rather than lastclose.

bsd-core/drm_bufs.c
bsd-core/drm_drv.c

index f088703..93bcc81 100644 (file)
@@ -53,7 +53,7 @@ int drm_order(unsigned long size)
 
 /* Allocation of PCI memory resources (framebuffer, registers, etc.) for
  * drm_get_resource_*.  Note that they are not RF_ACTIVE, so there's no virtual
- * address for accessing them.  Cleaned up at lastclose.
+ * address for accessing them.  Cleaned up at unload.
  */
 static int drm_alloc_resource(drm_device_t *dev, int resource)
 {
index 648fbf3..6766195 100644 (file)
@@ -474,13 +474,7 @@ static int drm_lastclose(drm_device_t *dev)
        TAILQ_FOREACH_SAFE(map, &dev->maplist, link, mapsave) {
                drm_rmmap(dev, map);
        }
-       for (i = 0; i < DRM_MAX_PCI_RESOURCE; i++) {
-               if (dev->pcir[i] == NULL)
-                       continue;
-               bus_release_resource(dev->device, SYS_RES_MEMORY,
-                   dev->pcirid[i], dev->pcir[i]);
-               dev->pcir[i] = NULL;
-       }
+
 
        drm_dma_takedown(dev);
        if ( dev->lock.hw_lock ) {
@@ -568,6 +562,8 @@ error:
 
 static void drm_unload(drm_device_t *dev)
 {
+       int i;
+
        DRM_DEBUG( "\n" );
 
 #ifdef __FreeBSD__
@@ -589,6 +585,19 @@ static void drm_unload(drm_device_t *dev)
        drm_lastclose(dev);
        DRM_UNLOCK();
 
+       /* Clean up PCI resources allocated by drm_bufs.c.  We're not really
+        * worried about resource consumption while the DRM is inactive (between
+        * lastclose and firstopen or unload) because these aren't actually
+        * taking up KVA, just keeping the PCI resource allocated.
+        */
+       for (i = 0; i < DRM_MAX_PCI_RESOURCE; i++) {
+               if (dev->pcir[i] == NULL)
+                       continue;
+               bus_release_resource(dev->device, SYS_RES_MEMORY,
+                   dev->pcirid[i], dev->pcir[i]);
+               dev->pcir[i] = NULL;
+       }
+
        if ( dev->agp ) {
                free(dev->agp, M_DRM);
                dev->agp = NULL;