diff --git a/linux-core/i915_gem.c b/linux-core/i915_gem.c index 64ffa35..8b55879 100644 --- a/linux-core/i915_gem.c +++ b/linux-core/i915_gem.c @@ -31,6 +31,7 @@ #include "i915_drm.h" #include "i915_drv.h" #include +#include static int i915_gem_object_set_domain(struct drm_gem_object *obj, @@ -477,7 +478,61 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data, return 0; } +#if 0 +/** + * Maps the contents of an object into the GTT range, returning the address + * it is mapped into. + * + * While the mapping holds a reference on the contents of the object, it doesn't + * imply a ref on the object itself. + */ +int +i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) +{ + struct drm_i915_gem_mmap_gtt *args = data; + struct drm_gem_object *obj; + struct drm_i915_gem_object *obj_priv; + loff_t offset; + unsigned long addr; + struct mm_struct *mm = current->mm; + struct vm_area_struct *vma; + + if (!(dev->driver->driver_features & DRIVER_GEM)) + return -ENODEV; + obj = drm_gem_object_lookup(dev, file_priv, args->handle); + if (obj == NULL) + return -EBADF; + + obj_priv = obj->driver_private; + offset = args->offset; + + if (args->flags) + return -EINVAL; + + /* Create a new mapping to be backed by a GTT range */ + addr = mm->get_unmapped_area(file_priv->filp, 0, args->size, 0, + args->flags); + vma = find_vma(mm, addr); + if (!vma) + return -EFAULT; + + vma->vm_pgoff += obj_priv->gtt_space->start >> PAGE_SHIFT; + /* Assuming the object is pinned, map it in the GTT range w/WC */ + pci_mmap_page_range(dev->pdev, vma, pci_mmap_mem, 1); + + mutex_lock(&dev->struct_mutex); + drm_gem_object_unreference(obj); + mutex_unlock(&dev->struct_mutex); + if (IS_ERR((void *)addr)) + return addr; + + args->addr_ptr = (uint64_t) addr; + + return 0; +} +#endif static void i915_gem_object_free_page_list(struct drm_gem_object *obj) { @@ -579,8 +634,6 @@ i915_add_request(struct drm_device *dev, uint32_t flush_domains) OUT_RING(MI_USER_INTERRUPT); ADVANCE_LP_RING(); - DRM_DEBUG("%d\n", seqno); - request->seqno = seqno; request->emitted_jiffies = jiffies; request->flush_domains = flush_domains; @@ -2302,9 +2355,11 @@ i915_gem_init_hws(struct drm_device *dev) int ret; /* If we need a physical address for the status page, it's already - * initialized at driver load time. + * initialized at driver load time, unless kernel modesetting is + * active. */ - if (!I915_NEED_GFX_HWS(dev)) + if (!I915_NEED_GFX_HWS(dev) && + !drm_core_check_feature(dev, DRIVER_MODESET)) return 0; obj = drm_gem_object_alloc(dev, 4096); diff --git a/shared-core/i915_drm.h b/shared-core/i915_drm.h index 53087b5..6cfd1a8 100644 --- a/shared-core/i915_drm.h +++ b/shared-core/i915_drm.h @@ -501,6 +501,23 @@ struct drm_i915_gem_mmap { uint64_t addr_ptr; /* void *, but pointers are not 32/64 compatible */ }; +struct drm_i915_gem_mmap_gtt { + /** Handle for the object being mapped. */ + uint32_t handle; + uint32_t pad; + /** Offset in the object to map. */ + uint64_t offset; + /** + * Length of data to map. + * + * The value will be page-aligned. + */ + uint64_t size; + /** Returned pointer the data was mapped at */ + uint64_t addr_ptr; /* void *, but pointers are not 32/64 compatible */ + uint32_t flags; +}; + struct drm_i915_gem_set_domain { /** Handle for the object */ uint32_t handle;