From owner-svn-src-head@FreeBSD.ORG Sun Aug 25 15:15:56 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F394866F; Sun, 25 Aug 2013 15:15:55 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C55A622DC; Sun, 25 Aug 2013 15:15:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7PFFtn1061232; Sun, 25 Aug 2013 15:15:55 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7PFFt7T061230; Sun, 25 Aug 2013 15:15:55 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201308251515.r7PFFt7T061230@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Sun, 25 Aug 2013 15:15:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254876 - head/sys/dev/drm2/ttm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2013 15:15:56 -0000 Author: dumbbell Date: Sun Aug 25 15:15:55 2013 New Revision: 254876 URL: http://svnweb.freebsd.org/changeset/base/254876 Log: drm/ttm: Fix unmap of buffer object Add a new ttm_bo_release_mmap() function to unmap pages in a vm_object_t. Pages are freed when the buffer object is later released. This function is called in ttm_bo_unmap_virtual_locked(), replacing Linux' unmap_mapping_range(). In particular this is called when a buffer object is about to be moved, so that its mapping is invalidated. However, we don't use this function in ttm_bo_vm_dtor(), because the vm_object_t is already marked as OBJ_DEAD and the pages will be unmapped. Approved by: kib@ Modified: head/sys/dev/drm2/ttm/ttm_bo.c head/sys/dev/drm2/ttm/ttm_bo_vm.c Modified: head/sys/dev/drm2/ttm/ttm_bo.c ============================================================================== --- head/sys/dev/drm2/ttm/ttm_bo.c Sun Aug 25 15:12:26 2013 (r254875) +++ head/sys/dev/drm2/ttm/ttm_bo.c Sun Aug 25 15:15:55 2013 (r254876) @@ -1634,13 +1634,8 @@ bool ttm_mem_reg_is_pci(struct ttm_bo_de void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo) { - struct ttm_bo_device *bdev = bo->bdev; - /* off_t offset = (off_t)bo->addr_space_offset;XXXKIB */ - /* off_t holelen = ((off_t)bo->mem.num_pages) << PAGE_SHIFT;XXXKIB */ - if (!bdev->dev_mapping) - return; - /* unmap_mapping_range(bdev->dev_mapping, offset, holelen, 1); XXXKIB */ + ttm_bo_release_mmap(bo); ttm_mem_io_free_vm(bo); } Modified: head/sys/dev/drm2/ttm/ttm_bo_vm.c ============================================================================== --- head/sys/dev/drm2/ttm/ttm_bo_vm.c Sun Aug 25 15:12:26 2013 (r254875) +++ head/sys/dev/drm2/ttm/ttm_bo_vm.c Sun Aug 25 15:15:55 2013 (r254876) @@ -361,6 +361,33 @@ out_unref: return ret; } +void +ttm_bo_release_mmap(struct ttm_buffer_object *bo) +{ + vm_object_t vm_obj; + vm_page_t m; + int i; + + vm_obj = cdev_pager_lookup(bo); + if (vm_obj == NULL) { + return; + } + + VM_OBJECT_WLOCK(vm_obj); +retry: + for (i = 0; i < bo->num_pages; i++) { + m = vm_page_lookup(vm_obj, i); + if (m == NULL) + continue; + if (vm_page_sleep_if_busy(m, "ttm_unm")) + goto retry; + cdev_pager_free_page(vm_obj, m); + } + VM_OBJECT_WUNLOCK(vm_obj); + + vm_object_deallocate(vm_obj); +} + #if 0 int ttm_fbdev_mmap(struct vm_area_struct *vma, struct ttm_buffer_object *bo) {