From patchwork Fri Feb 19 23:45:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 80863 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1JNl8IA001849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 19 Feb 2010 23:47:46 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NicY3-0002l4-Ch; Fri, 19 Feb 2010 23:46:15 +0000 Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.122] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NicY1-0002kc-NW for dri-devel@lists.sourceforge.net; Fri, 19 Feb 2010 23:46:13 +0000 Received-SPF: fail (sfi-mx-2.v28.ch3.sourceforge.com: domain of redhat.com does not designate 88.191.38.29 as permitted sender) client-ip=88.191.38.29; envelope-from=jglisse@redhat.com; helo=nox.protox.org; Received: from nox.protox.org ([88.191.38.29]) by sfi-mx-2.v28.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1NicY0-0004wc-Gn for dri-devel@lists.sourceforge.net; Fri, 19 Feb 2010 23:46:13 +0000 Received: from localhost.localdomain (lag77-1-82-238-106-69.fbx.proxad.net [82.238.106.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by nox.protox.org (Postfix) with ESMTPSA id 4F766169E3E; Sat, 20 Feb 2010 00:46:05 +0100 (CET) From: Jerome Glisse To: airlied@gmail.com Subject: [PATCH 2/9] drm/radeon/kms: add support for new fault callback Date: Sat, 20 Feb 2010 00:45:51 +0100 Message-Id: <1266623158-2404-3-git-send-email-jglisse@redhat.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1266623158-2404-2-git-send-email-jglisse@redhat.com> References: <1266623158-2404-1-git-send-email-jglisse@redhat.com> <1266623158-2404-2-git-send-email-jglisse@redhat.com> X-Spam-Score: 4.7 (++++) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 4.0 SPF_CHECK_FAIL SPF reports sender host as NOT permitted to send mails from 1.0 SPF_FAIL SPF: sender does not match SPF record (fail) -0.3 AWL AWL: From: address is in the auto white-list X-Headers-End: 1NicY0-0004wc-Gn Cc: thellstrom@vmware.com, skeggsb@gmail.com, Jerome Glisse , dri-devel@lists.sf.net X-BeenThere: dri-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 19 Feb 2010 23:47:46 +0000 (UTC) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 1157e0f..b8c6567 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -434,10 +434,104 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, memcpy: r = ttm_bo_move_memcpy(bo, evict, no_wait, new_mem); } - return r; } +static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem, struct ttm_bus_placement *pl) +{ + struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; + struct radeon_device *rdev = radeon_get_rdev(bdev); + + pl->offset = mem->mm_node->start << PAGE_SHIFT; + pl->size = mem->num_pages << PAGE_SHIFT; + pl->base = 0; + pl->is_iomem = false; + if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE)) + return -EINVAL; + switch (mem->mem_type) { + case TTM_PL_SYSTEM: + /* system memory */ + return 0; + case TTM_PL_TT: +#if __OS_HAS_AGP + if (rdev->flags & RADEON_IS_AGP) { + /* RADEON_IS_AGP is set only if AGP is active */ + pl->base = rdev->mc.agp_base; + pl->is_iomem = true; + } +#endif + return 0; + case TTM_PL_VRAM: + /* check if it's visible */ + if ((pl->offset + pl->size) > rdev->mc.visible_vram_size) + return -EINVAL; + pl->base = rdev->mc.aper_base; + pl->is_iomem = true; + break; + default: + return -EINVAL; + } + return 0; +} + +static void radeon_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) +{ + /* hopefully will be usefull soon */ +} + +static int radeon_ttm_fault_callback(struct ttm_buffer_object *bo, struct ttm_bus_placement *pl) +{ + struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type]; + struct radeon_bo *rbo; + struct radeon_device *rdev; + int r; + + pl->offset = bo->mem.mm_node->start << PAGE_SHIFT; + pl->size = bo->mem.num_pages << PAGE_SHIFT; + pl->base = 0; + pl->is_iomem = false; + if (!radeon_ttm_bo_is_radeon_bo(bo)) + /* FIXME should we return 0 ? we don't know about this BO */ + return -EINVAL; + if (!(man->flags & TTM_MEMTYPE_FLAG_MAPPABLE)) + return -EINVAL; + rbo = container_of(bo, struct radeon_bo, tbo); + rdev = rbo->rdev; + switch (bo->mem.mem_type) { + case TTM_PL_SYSTEM: + /* System memory */ + return 0; + case TTM_PL_TT: +#if __OS_HAS_AGP + if (rdev->flags & RADEON_IS_AGP) { + /* RADEON_IS_AGP is set only if AGP is active */ + pl->base = rdev->mc.agp_base; + pl->is_iomem = true; + } +#endif + return 0; + case TTM_PL_VRAM: + if ((pl->offset + pl->size) > rdev->mc.visible_vram_size) { + /* hurrah the memory is not visible ! */ + radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_VRAM); + rbo->placement.lpfn = rdev->mc.visible_vram_size >> PAGE_SHIFT; + r = ttm_bo_validate(bo, &rbo->placement, false, false); + if (unlikely(r != 0)) + return r; + pl->offset = bo->mem.mm_node->start << PAGE_SHIFT; + /* this should not happen */ + if ((pl->offset + pl->size) > rdev->mc.visible_vram_size) + return -EINVAL; + } + pl->base = rdev->mc.aper_base; + pl->is_iomem = true; + break; + default: + return -EINVAL; + } + return 0; +} + static int radeon_sync_obj_wait(void *sync_obj, void *sync_arg, bool lazy, bool interruptible) { @@ -478,6 +572,9 @@ static struct ttm_bo_driver radeon_bo_driver = { .sync_obj_ref = &radeon_sync_obj_ref, .move_notify = &radeon_bo_move_notify, .fault_reserve_notify = &radeon_bo_fault_reserve_notify, + .fault_reserve = &radeon_ttm_fault_callback, + .io_mem_reserve = &radeon_ttm_io_mem_reserve, + .io_mem_free = &radeon_ttm_io_mem_free, }; int radeon_ttm_init(struct radeon_device *rdev)