FreeBSD/sys/dev/drm2/drm_bufs.c
/**
 * Remove a map private from list and deallocate resources if the mapping
 * isn't in use.
 *
 * Searches the map on drm_device::maplist, removes it from the list, see if
 * its being used, and free any associate resource (such as MTRR's) if it's not
 * being on use.
 *
 * \sa drm_addmap
 */
Remove a map private from list and deallocate resources if the mapping
isn't in use.

Searches the map on drm_device::maplist, removes it from the list, see if
its being used, and free any associate resource (such as MTRR's) if it's not
being on use.


Remove a map private from list and deallocate resources if the mapping isn ' t in use . Searches the map on drm_device :: maplist removes it from the list see if its being used and free any associate resource ( such as MTRR ' s ) if it ' s not being on use .
int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
{
	struct drm_map_list *r_list = NULL, *list_t;
	int found = 0;
	struct drm_master *master;
	list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
		if (r_list->map == map) {
			master = r_list->master;
			list_del(&r_list->head);
			drm_ht_remove_key(&dev->map_hash,
					  r_list->user_token >> PAGE_SHIFT);
			free(r_list, DRM_MEM_MAPS);
			found = 1;
			break;
		}
	}
	if (!found)
		return -EINVAL;
	switch (map->type) {
	case _DRM_REGISTERS:
		drm_core_ioremapfree(map, dev);
	case _DRM_FRAME_BUFFER:
		if (drm_core_has_MTRR(dev) && map->mtrr >= 0) {
			int retcode;
			retcode = drm_mtrr_del(map->mtrr, map->offset,
			    map->size, DRM_MTRR_WC);
			DRM_DEBUG("mtrr_del=%d\n", retcode);
		}
		break;
	case _DRM_SHM:
		free(map->handle, DRM_MEM_MAPS);
		if (master) {
			if (dev->sigdata.lock == master->lock.hw_lock)
				dev->sigdata.lock = NULL;
			master->lock.hw_lock = NULL;   
			master->lock.file_priv = NULL;
			DRM_WAKEUP_INT((void *)&master->lock.lock_queue);
		}
		break;
	case _DRM_AGP:
	case _DRM_SCATTER_GATHER:
		break;
	case _DRM_CONSISTENT:
		drm_pci_free(dev, map->dmah);
		break;
	case _DRM_GEM:
		DRM_ERROR("tried to rmmap GEM object\n");
		break;
	}
	free(map, DRM_MEM_MAPS);
	return 0;
}
int drm_rmmap_locked ( struct drm_device * dev , struct drm_local_map * map ) { struct drm_map_list * r_list = NULL , * list_t ; int found = 0 ; struct drm_master * master ; list_for_each_entry_safe ( r_list , list_t , & dev -> maplist , head ) { if ( r_list -> map == map ) { master = r_list -> master ; list_del ( & r_list -> head ) ; drm_ht_remove_key ( & dev -> map_hash , r_list -> user_token >> PAGE_SHIFT ) ; free ( r_list , DRM_MEM_MAPS ) ; found = 1 ; break ; } } if ( ! found ) return - EINVAL ; switch ( map -> type ) { case _DRM_REGISTERS : drm_core_ioremapfree ( map , dev ) ; case _DRM_FRAME_BUFFER : if ( drm_core_has_MTRR ( dev ) && map -> mtrr >= 0 ) { int retcode ; retcode = drm_mtrr_del ( map -> mtrr , map -> offset , map -> size , DRM_MTRR_WC ) ; DRM_DEBUG ( " \n " , retcode ) ; } break ; case _DRM_SHM : free ( map -> handle , DRM_MEM_MAPS ) ; if ( master ) { if ( dev -> sigdata . lock == master -> lock . hw_lock ) dev -> sigdata . lock = NULL ; master -> lock . hw_lock = NULL ; master -> lock . file_priv = NULL ; DRM_WAKEUP_INT ( ( void * ) & master -> lock . lock_queue ) ; } break ; case _DRM_AGP : case _DRM_SCATTER_GATHER : break ; case _DRM_CONSISTENT : drm_pci_free ( dev , map -> dmah ) ; break ; case _DRM_GEM : DRM_ERROR ( " \n " ) ; break ; } free ( map , DRM_MEM_MAPS ) ; return 0 ; }
Remove a map private from list and deallocate resources if the mapping
 isn't in use.
Remove a map private from list and deallocate resources if the mapping isn ' t in use .
/* Find the list entry for the map and remove it */ /* FALLTHROUGH */ /* SHM removed */