Skip to content

Commit

Permalink
drm/omap: add GEM support for tiled/dmm buffers
Browse files Browse the repository at this point in the history
TILER/DMM provides two features for omapdrm GEM objects:
1) providing a physically contiguous view to discontiguous memory
   for hw initiators that cannot otherwise support discontiguous
   buffers (DSS scanout, IVAHD video decode/encode, etc)
2) providing untiling for 2d tiled buffers, which are used in some
   cases to provide rotation and reduce memory bandwidth for hw
   initiators that tend to access data in 2d block patterns.

For 2d tiled buffers, there are some additional complications when
it comes to userspace mmap'ings.  For non-tiled buffers, the original
(potentially physically discontiguous) pages are used to back the
mmap.  For tiled buffers, we need to mmap via the tiler/dmm region to
provide an unswizzled view of the buffer.  But (a) the buffer is not
necessarily pinned in TILER all the time (it can be unmapped when
there is no DMA access to the buffer), and (b) when they are they
are pinned, they not necessarily page aligned from the perspective of
the CPU.  And non-page aligned userspace buffer mapping is evil.

To solve this, we reserve one or more small regions in each of the 2d
containers when the driver is loaded to use as a "user-GART" where we
can create a second page-aligned mapping of parts of the buffer being
accessed from userspace.  Page faulting is used to evict and remap
different regions of whichever buffers are being accessed from user-
space.

Signed-off-by: Rob Clark <rob@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Rob Clark authored and Greg Kroah-Hartman committed Dec 8, 2011
1 parent 71e8831 commit f7f9f45
Show file tree
Hide file tree
Showing 6 changed files with 466 additions and 37 deletions.
5 changes: 5 additions & 0 deletions drivers/staging/omapdrm/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ TODO
. Review DSS vs KMS mismatches. The omap_dss_device is sort of part encoder,
part connector. Which results in a bit of duct tape to fwd calls from
encoder to connector. Possibly this could be done a bit better.
. Solve PM sequencing on resume. DMM/TILER must be reloaded before any
access is made from any component in the system. Which means on suspend
CRTC's should be disabled, and on resume the LUT should be reprogrammed
before CRTC's are re-enabled, to prevent DSS from trying to DMA from a
buffer mapped in DMM/TILER before LUT is reloaded.
. Add debugfs information for DMM/TILER

Userspace:
Expand Down
6 changes: 4 additions & 2 deletions drivers/staging/omapdrm/omap_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ static int ioctl_gem_info(struct drm_device *dev, void *data,
return -ENOENT;
}

args->size = obj->size; /* for now */
args->size = omap_gem_mmap_size(obj);
args->offset = omap_gem_mmap_offset(obj);

drm_gem_object_unreference_unlocked(obj);
Expand Down Expand Up @@ -557,6 +557,8 @@ static int dev_load(struct drm_device *dev, unsigned long flags)

dev->dev_private = priv;

omap_gem_init(dev);

ret = omap_modeset_init(dev);
if (ret) {
dev_err(dev->dev, "omap_modeset_init failed: ret=%d\n", ret);
Expand Down Expand Up @@ -589,8 +591,8 @@ static int dev_unload(struct drm_device *dev)
drm_kms_helper_poll_fini(dev);

omap_fbdev_free(dev);

omap_modeset_free(dev);
omap_gem_deinit(dev);

kfree(dev->dev_private);
dev->dev_private = NULL;
Expand Down
3 changes: 3 additions & 0 deletions drivers/staging/omapdrm/omap_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ struct drm_connector *omap_framebuffer_get_next_connector(
void omap_framebuffer_flush(struct drm_framebuffer *fb,
int x, int y, int w, int h);

void omap_gem_init(struct drm_device *dev);
void omap_gem_deinit(struct drm_device *dev);

struct drm_gem_object *omap_gem_new(struct drm_device *dev,
union omap_gem_size gsize, uint32_t flags);
Expand All @@ -109,6 +111,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
dma_addr_t *paddr, bool remap);
int omap_gem_put_paddr(struct drm_gem_object *obj);
uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
size_t omap_gem_mmap_size(struct drm_gem_object *obj);

static inline int align_pitch(int pitch, int width, int bpp)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/omapdrm/omap_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int omap_framebuffer_get_buffer(struct drm_framebuffer *fb, int x, int y,
* dma_alloc_coherent()). But this should be ok because it
* is only used by legacy fbdev
*/
BUG_ON(!bo_vaddr);
BUG_ON(IS_ERR_OR_NULL(bo_vaddr));
*vaddr = bo_vaddr + offset;
}

Expand Down
Loading

0 comments on commit f7f9f45

Please sign in to comment.