diff options
Diffstat (limited to 'linux-core')
-rw-r--r-- | linux-core/drmP.h | 9 | ||||
-rw-r--r-- | linux-core/drm_agpsupport.c | 3 | ||||
-rw-r--r-- | linux-core/drm_bo.c | 58 | ||||
-rw-r--r-- | linux-core/drm_compat.c | 24 | ||||
-rw-r--r-- | linux-core/drm_ttm.h | 2 | ||||
-rw-r--r-- | linux-core/drm_vm.c | 4 | ||||
-rw-r--r-- | linux-core/i915_buffer.c | 15 |
7 files changed, 58 insertions, 57 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h index a8f5e3e2..62efddd9 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -655,6 +655,7 @@ typedef struct drm_ref_object { #define _DRM_FLAG_MEMTYPE_CACHED 0x00000004 /* Supports cached binding */ #define _DRM_FLAG_NEEDS_IOREMAP 0x00000008 /* Fixed memory needs ioremap before kernel access. */ +#define _DRM_FLAG_MEMTYPE_CMA 0x00000010 /* Can't map aperture */ typedef struct drm_mem_type_manager { int has_type; @@ -1037,9 +1038,9 @@ typedef struct drm_buffer_object{ /* For vm */ + drm_ttm_t *ttm; drm_map_list_t map_list; uint32_t memory_type; - drm_ttm_t *ttm; unsigned long bus_offset; uint32_t vm_flags; void *iomap; @@ -1491,10 +1492,14 @@ extern int drm_bo_ioctl(DRM_IOCTL_ARGS); extern int drm_mm_init_ioctl(DRM_IOCTL_ARGS); extern int drm_bo_driver_finish(drm_device_t *dev); extern int drm_bo_driver_init(drm_device_t *dev); -extern int drm_bo_pci_offset(const drm_buffer_object_t *bo, +extern int drm_bo_pci_offset(drm_device_t *dev, + drm_bo_mem_reg_t *mem, unsigned long *bus_base, unsigned long *bus_offset, unsigned long *bus_size); +extern int drm_mem_reg_is_pci(drm_device_t *dev, drm_bo_mem_reg_t *mem); + + extern void drm_bo_usage_deref_locked(drm_buffer_object_t * bo); extern int drm_fence_buffer_objects(drm_file_t * priv, struct list_head *list, diff --git a/linux-core/drm_agpsupport.c b/linux-core/drm_agpsupport.c index 177180f9..e28ff0c1 100644 --- a/linux-core/drm_agpsupport.c +++ b/linux-core/drm_agpsupport.c @@ -710,7 +710,6 @@ drm_ttm_backend_t *drm_agp_init_ttm(struct drm_device *dev, agp_priv->uncached_type = AGP_USER_MEMORY; agp_priv->bridge = dev->agp->bridge; agp_priv->populated = FALSE; - agp_be->aperture_base = dev->agp->agp_info.aper_base; agp_be->private = (void *) agp_priv; agp_be->needs_ub_cache_adjust = drm_agp_needs_unbind_cache_adjust; agp_be->populate = drm_agp_populate; @@ -720,8 +719,6 @@ drm_ttm_backend_t *drm_agp_init_ttm(struct drm_device *dev, agp_be->destroy = drm_agp_destroy_ttm; DRM_MASK_VAL(agp_be->flags, DRM_BE_FLAG_NEEDS_FREE, (backend == NULL) ? DRM_BE_FLAG_NEEDS_FREE : 0); - DRM_MASK_VAL(agp_be->flags, DRM_BE_FLAG_CMA, - (dev->agp->cant_use_aperture) ? DRM_BE_FLAG_CMA : 0); agp_be->drm_map_type = _DRM_AGP; return agp_be; } diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 8a6b49dc..16c89f61 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -718,7 +718,7 @@ static int drm_move_local_to_tt(drm_buffer_object_t * bo, } if (!(bo->mem.flags & DRM_BO_FLAG_BIND_CACHED)) - bo->mem.flags &= DRM_BO_FLAG_CACHED; + bo->mem.flags &= ~DRM_BO_FLAG_CACHED; bo->mem.flags &= ~DRM_BO_MASK_MEM; bo->mem.flags |= DRM_BO_FLAG_MEM_TT; bo->mem.mem_type = DRM_BO_MEM_TT; @@ -2163,6 +2163,26 @@ int drm_mm_init_ioctl(DRM_IOCTL_ARGS) * buffer object vm functions. */ +int drm_mem_reg_is_pci(drm_device_t *dev, drm_bo_mem_reg_t *mem) +{ + drm_buffer_manager_t *bm = &dev->bm; + drm_mem_type_manager_t *man = &bm->man[mem->mem_type]; + + if (!(man->flags & _DRM_FLAG_MEMTYPE_FIXED)) { + if (mem->mem_type == DRM_BO_MEM_LOCAL) + return 0; + + if (man->flags & _DRM_FLAG_MEMTYPE_CMA) + return 0; + + if ((mem->mask & DRM_BO_FLAG_BIND_CACHED) && + (man->flags & _DRM_FLAG_MEMTYPE_CACHED)) + return 0; + } + return 1; +} +EXPORT_SYMBOL(drm_mem_reg_is_pci); + /** * \c Get the PCI offset for the buffer object memory. * @@ -2174,48 +2194,32 @@ int drm_mm_init_ioctl(DRM_IOCTL_ARGS) * \return Failure indication. * * Returns -EINVAL if the buffer object is currently not mappable. - * Otherwise returns zero. Call bo->mutex locked. + * Otherwise returns zero. */ -int drm_bo_pci_offset(const drm_buffer_object_t *bo, +int drm_bo_pci_offset(drm_device_t *dev, + drm_bo_mem_reg_t *mem, unsigned long *bus_base, unsigned long *bus_offset, unsigned long *bus_size) { - drm_device_t *dev = bo->dev; drm_buffer_manager_t *bm = &dev->bm; - drm_mem_type_manager_t *man = &bm->man[bo->mem.mem_type]; + drm_mem_type_manager_t *man = &bm->man[mem->mem_type]; *bus_size = 0; - if (bo->type != drm_bo_type_dc) - return -EINVAL; - if (!(man->flags & _DRM_FLAG_MEMTYPE_MAPPABLE)) return -EINVAL; - - if (!(man->flags & _DRM_FLAG_MEMTYPE_FIXED)) { - drm_ttm_t *ttm = bo->ttm; - if (!bo->ttm) { - return -EINVAL; - } - - drm_ttm_fixup_caching(ttm); - - if (!(ttm->page_flags & DRM_TTM_PAGE_UNCACHED)) - return 0; - if (ttm->be->flags & DRM_BE_FLAG_CMA) - return 0; - *bus_base = ttm->be->aperture_base; - } else { + if (drm_mem_reg_is_pci(dev, mem)) { + *bus_offset = mem->mm_node->start << PAGE_SHIFT; + *bus_size = mem->num_pages << PAGE_SHIFT; *bus_base = man->io_offset; } - *bus_offset = bo->mem.mm_node->start << PAGE_SHIFT; - *bus_size = bo->mem.num_pages << PAGE_SHIFT; return 0; } + /** * \c Return a kernel virtual address to the buffer object PCI memory. * @@ -2231,7 +2235,8 @@ int drm_bo_pci_offset(const drm_buffer_object_t *bo, * Call bo->mutex locked. */ -int drm_bo_ioremap(drm_buffer_object_t *bo) +#if 0 +int drm_mem_reg_ioremap(drm_bo_mem_reg_t *mem) { drm_device_t *dev = bo->dev; drm_buffer_manager_t *bm = &dev->bm; @@ -2281,6 +2286,7 @@ void drm_bo_iounmap(drm_buffer_object_t *bo) bo->iomap = NULL; } +#endif /** * \c Kill all user-space virtual mappings of this buffer object. diff --git a/linux-core/drm_compat.c b/linux-core/drm_compat.c index 48d598e8..044cf4a4 100644 --- a/linux-core/drm_compat.c +++ b/linux-core/drm_compat.c @@ -222,10 +222,6 @@ struct page *drm_bo_vm_nopage(struct vm_area_struct *vma, drm_ttm_t *ttm; drm_buffer_manager_t *bm; drm_device_t *dev; - unsigned long bus_base; - unsigned long bus_offset; - unsigned long bus_size; - int err; mutex_lock(&bo->mutex); @@ -238,14 +234,8 @@ struct page *drm_bo_vm_nopage(struct vm_area_struct *vma, } dev = bo->dev; - err = drm_bo_pci_offset(bo, &bus_base, &bus_offset, &bus_size); - - if (err) { - page = NOPAGE_SIGBUS; - goto out_unlock; - } - if (bus_size != 0) { + if (drm_mem_reg_is_pci(dev, &bo->mem)) { DRM_ERROR("Invalid compat nopage.\n"); page = NOPAGE_SIGBUS; goto out_unlock; @@ -253,6 +243,7 @@ struct page *drm_bo_vm_nopage(struct vm_area_struct *vma, bm = &dev->bm; ttm = bo->ttm; + drm_ttm_fixup_caching(ttm); page_offset = (address - vma->vm_start) >> PAGE_SHIFT; page = ttm->pages[page_offset]; @@ -284,7 +275,8 @@ int drm_bo_map_bound(struct vm_area_struct *vma) unsigned long bus_offset; unsigned long bus_size; - ret = drm_bo_pci_offset(bo, &bus_base, &bus_offset, &bus_size); + ret = drm_bo_pci_offset(bo->dev, &bo->mem, &bus_base, + &bus_offset, &bus_size); BUG_ON(ret); if (bus_size) { @@ -415,14 +407,8 @@ int drm_bo_remap_bound(drm_buffer_object_t *bo) { vma_entry_t *v_entry; int ret = 0; - unsigned long bus_base; - unsigned long bus_offset; - unsigned long bus_size; - - ret = drm_bo_pci_offset(bo, &bus_base, &bus_offset, &bus_size); - BUG_ON(ret); - if (bus_size) { + if (drm_mem_reg_is_pci(bo->dev, &bo->mem)) { list_for_each_entry(v_entry, &bo->vma_list, head) { ret = drm_bo_map_bound(v_entry->vma); if (ret) diff --git a/linux-core/drm_ttm.h b/linux-core/drm_ttm.h index 6aa1c5ad..3f649281 100644 --- a/linux-core/drm_ttm.h +++ b/linux-core/drm_ttm.h @@ -46,10 +46,8 @@ #define DRM_BE_FLAG_NEEDS_FREE 0x00000001 #define DRM_BE_FLAG_BOUND_CACHED 0x00000002 -#define DRM_BE_FLAG_CMA 0x00000004 /* Don't map through aperture */ typedef struct drm_ttm_backend { - unsigned long aperture_base; void *private; uint32_t flags; uint32_t drm_map_type; diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index a4a9b09d..843fc362 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -754,7 +754,8 @@ struct page *drm_bo_vm_fault(struct vm_area_struct *vma, } dev = bo->dev; - err = drm_bo_pci_offset(bo, &bus_base, &bus_offset, &bus_size); + err = drm_bo_pci_offset(dev, &bo->mem, &bus_base, &bus_offset, + &bus_size); if (err) { data->type = VM_FAULT_SIGBUS; @@ -770,6 +771,7 @@ struct page *drm_bo_vm_fault(struct vm_area_struct *vma, bm = &dev->bm; ttm = bo->ttm; + drm_ttm_fixup_caching(ttm); page = ttm->pages[page_offset]; if (!page) { page = drm_ttm_alloc_page(); diff --git a/linux-core/i915_buffer.c b/linux-core/i915_buffer.c index 13a3e9bb..c1cdd112 100644 --- a/linux-core/i915_buffer.c +++ b/linux-core/i915_buffer.c @@ -71,8 +71,17 @@ int i915_init_mem_type(drm_device_t *dev, uint32_t type, switch(type) { case DRM_BO_MEM_LOCAL: case DRM_BO_MEM_TT: + if (!(drm_core_has_AGP(dev) && dev->agp)) { + DRM_ERROR("AGP is not enabled for memory type %u\n", + (unsigned) type); + return -EINVAL; + } + man->io_offset = dev->agp->agp_info.aper_base; + man->io_size = dev->agp->agp_info.aper_size * 1024 * 1024; + man->io_addr = NULL; man->flags = _DRM_FLAG_MEMTYPE_MAPPABLE | - _DRM_FLAG_MEMTYPE_CACHED; + _DRM_FLAG_MEMTYPE_CACHED | + _DRM_FLAG_NEEDS_IOREMAP; break; case DRM_BO_MEM_PRIV0: if (!(drm_core_has_AGP(dev) && dev->agp)) { @@ -82,13 +91,11 @@ int i915_init_mem_type(drm_device_t *dev, uint32_t type, } man->io_offset = dev->agp->agp_info.aper_base; man->io_size = dev->agp->agp_info.aper_size * 1024 * 1024; - + man->io_addr = NULL; man->flags = _DRM_FLAG_MEMTYPE_MAPPABLE | - _DRM_FLAG_MEMTYPE_CACHED | _DRM_FLAG_MEMTYPE_FIXED | _DRM_FLAG_NEEDS_IOREMAP; - man->io_addr = NULL; break; default: DRM_ERROR("Unsupported memory type %u\n", (unsigned) type); |