Message ID | 511912F5.9070605@canonical.com |
---|---|
State | New |
Headers | show |
On 02/11/2013 08:49 AM, Alberto Milone wrote: > Hi all, > > The attached patches come from NVIDIA's Aaron Plattner's branch: > > git://github.com/aaronp24/linux > > The first patch adds some helpers for the dma_buf functionality (which > we need for hybrid graphics) whereas the other two patches make both the > nouveau driver and the radeon driver use these helpers. > > The patches apply cleanly to Raring's kernel sources and would be a > first step towards having hybrid graphics working even with NVIDIA's > binary blob. > > Please have a look at the patches and (if possible) integrate them in > Raring's kernel. > > Thanks in advance for your time. > > Regards, > I'd like to see this cook upstream first. There is enough code movement in these patches that it is difficult to ascertain regression potential. Will they make the 3.9 merge window ? I might consider pulling them back to Raring at that point. rtg
On 12/02/13 17:15, Tim Gardner wrote: > I'd like to see this cook upstream first. There is enough code movement > in these patches that it is difficult to ascertain regression potential. > > Will they make the 3.9 merge window ? I might consider pulling them back > to Raring at that point. Yes, I think so. I'll ping you again when this happens. Thanks,
On 12/02/13 17:19, Alberto Milone wrote: > On 12/02/13 17:15, Tim Gardner wrote: >> I'd like to see this cook upstream first. There is enough code movement >> in these patches that it is difficult to ascertain regression potential. >> >> Will they make the 3.9 merge window ? I might consider pulling them back >> to Raring at that point. > > Yes, I think so. > > I'll ping you again when this happens. > > Thanks, > It looks like the patches were merged 7 days ago: http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=89177644a7b6306e6084a89eab7e290f4bfef397 http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=ab9ccb96a6e6f95bcde6b8b2a524370efdbfdcd6 http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=1e6d17a5df848cf8e483b689c6295776e9d6d997 You can cherrypick them directly from that branch. Thanks,
On 02/15/2013 05:40 AM, Alberto Milone wrote: > On 12/02/13 17:19, Alberto Milone wrote: >> On 12/02/13 17:15, Tim Gardner wrote: >>> I'd like to see this cook upstream first. There is enough code movement >>> in these patches that it is difficult to ascertain regression potential. >>> >>> Will they make the 3.9 merge window ? I might consider pulling them back >>> to Raring at that point. >> >> Yes, I think so. >> >> I'll ping you again when this happens. >> >> Thanks, >> > > It looks like the patches were merged 7 days ago: > > http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=89177644a7b6306e6084a89eab7e290f4bfef397 > > http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=ab9ccb96a6e6f95bcde6b8b2a524370efdbfdcd6 > > http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=1e6d17a5df848cf8e483b689c6295776e9d6d997 > > You can cherrypick them directly from that branch. > > Thanks, > Perhaps once these patches make it into the merge window.
On 15/02/13 13:40, Alberto Milone wrote: > On 12/02/13 17:19, Alberto Milone wrote: >> On 12/02/13 17:15, Tim Gardner wrote: >>> I'd like to see this cook upstream first. There is enough code movement >>> in these patches that it is difficult to ascertain regression potential. >>> >>> Will they make the 3.9 merge window ? I might consider pulling them back >>> to Raring at that point. >> >> Yes, I think so. >> >> I'll ping you again when this happens. >> >> Thanks, >> > > It looks like the patches were merged 7 days ago: > > http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=89177644a7b6306e6084a89eab7e290f4bfef397 > > http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=ab9ccb96a6e6f95bcde6b8b2a524370efdbfdcd6 > > http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=1e6d17a5df848cf8e483b689c6295776e9d6d997 > > You can cherrypick them directly from that branch. > > Thanks, > The patches have been merged: https://github.com/torvalds/linux/commit/8917764 Please consider including them. Thanks,
On 03/01/2013 09:35 AM, Alberto Milone wrote: > On 15/02/13 13:40, Alberto Milone wrote: >> On 12/02/13 17:19, Alberto Milone wrote: >>> On 12/02/13 17:15, Tim Gardner wrote: >>>> I'd like to see this cook upstream first. There is enough code movement >>>> in these patches that it is difficult to ascertain regression potential. >>>> >>>> Will they make the 3.9 merge window ? I might consider pulling them back >>>> to Raring at that point. >>> >>> Yes, I think so. >>> >>> I'll ping you again when this happens. >>> >>> Thanks, >>> >> >> It looks like the patches were merged 7 days ago: >> >> http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=89177644a7b6306e6084a89eab7e290f4bfef397 >> >> http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=ab9ccb96a6e6f95bcde6b8b2a524370efdbfdcd6 >> >> http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=1e6d17a5df848cf8e483b689c6295776e9d6d997 >> >> You can cherrypick them directly from that branch. >> >> Thanks, >> > > The patches have been merged: > https://github.com/torvalds/linux/commit/8917764 > > Please consider including them. > > Thanks, > How about the list of commits that you want ? I find the git hub web page to be confusing. Plus I'd like the email list to be a one stop shopping place for information regarding what was requested and what was actually committed without having to grovel around in other places.
On 01/03/13 17:45, Tim Gardner wrote: > On 03/01/2013 09:35 AM, Alberto Milone wrote: >> On 15/02/13 13:40, Alberto Milone wrote: >>> On 12/02/13 17:19, Alberto Milone wrote: >>>> On 12/02/13 17:15, Tim Gardner wrote: >>>>> I'd like to see this cook upstream first. There is enough code movement >>>>> in these patches that it is difficult to ascertain regression potential. >>>>> >>>>> Will they make the 3.9 merge window ? I might consider pulling them back >>>>> to Raring at that point. >>>> >>>> Yes, I think so. >>>> >>>> I'll ping you again when this happens. >>>> >>>> Thanks, >>>> >>> >>> It looks like the patches were merged 7 days ago: >>> >>> http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=89177644a7b6306e6084a89eab7e290f4bfef397 >>> >>> http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=ab9ccb96a6e6f95bcde6b8b2a524370efdbfdcd6 >>> >>> http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=1e6d17a5df848cf8e483b689c6295776e9d6d997 >>> >>> You can cherrypick them directly from that branch. >>> >>> Thanks, >>> >> >> The patches have been merged: >> https://github.com/torvalds/linux/commit/8917764 >> >> Please consider including them. >> >> Thanks, >> > > How about the list of commits that you want ? I find the git hub web > page to be confusing. Plus I'd like the email list to be a one stop > shopping place for information regarding what was requested and what was > actually committed without having to grovel around in other places. > Here are the commit ids from Linus' tree: drm: add prime helpers: 89177644a7b6306e6084a89eab7e290f4bfef397 drm/nouveau: use prime helpers: ab9ccb96a6e6f95bcde6b8b2a524370efdbfdcd6 drm/radeon: use prime helpers: 1e6d17a5df848cf8e483b689c6295776e9d6d997 Thanks,
On 03/01/2013 01:34 PM, Alberto Milone wrote: > On 01/03/13 17:45, Tim Gardner wrote: >>> >> >> > >> > How about the list of commits that you want ? I find the git hub web >> > page to be confusing. Plus I'd like the email list to be a one stop >> > shopping place for information regarding what was requested and what was >> > actually committed without having to grovel around in other places. >> > > Here are the commit ids from Linus' tree: > > drm: add prime helpers: > 89177644a7b6306e6084a89eab7e290f4bfef397 > > drm/nouveau: use prime helpers: > ab9ccb96a6e6f95bcde6b8b2a524370efdbfdcd6 > > drm/radeon: use prime helpers: > 1e6d17a5df848cf8e483b689c6295776e9d6d997 I've opened bug 1138440 to track this https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1138440
From 1db1e95cf1f475a42c05d217ec59da83cefe311a Mon Sep 17 00:00:00 2001 From: Aaron Plattner <aplattner@nvidia.com> Date: Thu, 6 Dec 2012 09:26:25 -0800 Subject: [PATCH 3/3] drm/radeon: use prime helpers Simplify the Radeon prime implementation by using the default behavior provided by drm_gem_prime_import and drm_gem_prime_export. v2: - Rename functions to radeon_gem_prime_get_sg_table and radeon_gem_prime_import_sg_table. - Delete the now-unused vmapping_count variable. Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: David Airlie <airlied@linux.ie> --- drivers/gpu/drm/radeon/radeon.h | 1 - drivers/gpu/drm/radeon/radeon_drv.c | 21 ++-- drivers/gpu/drm/radeon/radeon_prime.c | 170 ++++----------------------------- 3 files changed, 35 insertions(+), 157 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 34e5230..48bb80e 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -342,7 +342,6 @@ struct radeon_bo { struct drm_gem_object gem_base; struct ttm_bo_kmap_obj dma_buf_vmap; - int vmapping_count; }; #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base) diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index dff6cf7..7a63817 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -117,11 +117,13 @@ int radeon_mode_dumb_create(struct drm_file *file_priv, int radeon_mode_dumb_destroy(struct drm_file *file_priv, struct drm_device *dev, uint32_t handle); -struct dma_buf *radeon_gem_prime_export(struct drm_device *dev, - struct drm_gem_object *obj, - int flags); -struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev, - struct dma_buf *dma_buf); +struct sg_table *radeon_gem_prime_get_sg_table(struct drm_gem_object *obj); +struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev, + size_t size, + struct sg_table *sg); +int radeon_gem_prime_pin(struct drm_gem_object *obj); +void *radeon_gem_prime_vmap(struct drm_gem_object *obj); +void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); #if defined(CONFIG_DEBUG_FS) int radeon_debugfs_init(struct drm_minor *minor); @@ -396,8 +398,13 @@ static struct drm_driver kms_driver = { .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_export = radeon_gem_prime_export, - .gem_prime_import = radeon_gem_prime_import, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_pin = radeon_gem_prime_pin, + .gem_prime_get_sg_table = radeon_gem_prime_get_sg_table, + .gem_prime_import_sg_table = radeon_gem_prime_import_sg_table, + .gem_prime_vmap = radeon_gem_prime_vmap, + .gem_prime_vunmap = radeon_gem_prime_vunmap, .name = DRIVER_NAME, .desc = DRIVER_DESC, diff --git a/drivers/gpu/drm/radeon/radeon_prime.c b/drivers/gpu/drm/radeon/radeon_prime.c index 26c23bb..4940af7 100644 --- a/drivers/gpu/drm/radeon/radeon_prime.c +++ b/drivers/gpu/drm/radeon/radeon_prime.c @@ -28,199 +28,71 @@ #include "radeon.h" #include <drm/radeon_drm.h> -#include <linux/dma-buf.h> - -static struct sg_table *radeon_gem_map_dma_buf(struct dma_buf_attachment *attachment, - enum dma_data_direction dir) +struct sg_table *radeon_gem_prime_get_sg_table(struct drm_gem_object *obj) { - struct radeon_bo *bo = attachment->dmabuf->priv; - struct drm_device *dev = bo->rdev->ddev; + struct radeon_bo *bo = gem_to_radeon_bo(obj); int npages = bo->tbo.num_pages; - struct sg_table *sg; - int nents; - - mutex_lock(&dev->struct_mutex); - sg = drm_prime_pages_to_sg(bo->tbo.ttm->pages, npages); - nents = dma_map_sg(attachment->dev, sg->sgl, sg->nents, dir); - mutex_unlock(&dev->struct_mutex); - return sg; -} - -static void radeon_gem_unmap_dma_buf(struct dma_buf_attachment *attachment, - struct sg_table *sg, enum dma_data_direction dir) -{ - dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir); - sg_free_table(sg); - kfree(sg); -} - -static void radeon_gem_dmabuf_release(struct dma_buf *dma_buf) -{ - struct radeon_bo *bo = dma_buf->priv; - - if (bo->gem_base.export_dma_buf == dma_buf) { - DRM_ERROR("unreference dmabuf %p\n", &bo->gem_base); - bo->gem_base.export_dma_buf = NULL; - drm_gem_object_unreference_unlocked(&bo->gem_base); - } -} - -static void *radeon_gem_kmap_atomic(struct dma_buf *dma_buf, unsigned long page_num) -{ - return NULL; -} - -static void radeon_gem_kunmap_atomic(struct dma_buf *dma_buf, unsigned long page_num, void *addr) -{ - -} -static void *radeon_gem_kmap(struct dma_buf *dma_buf, unsigned long page_num) -{ - return NULL; -} - -static void radeon_gem_kunmap(struct dma_buf *dma_buf, unsigned long page_num, void *addr) -{ + return drm_prime_pages_to_sg(bo->tbo.ttm->pages, npages); } -static int radeon_gem_prime_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma) +void *radeon_gem_prime_vmap(struct drm_gem_object *obj) { - return -EINVAL; -} - -static void *radeon_gem_prime_vmap(struct dma_buf *dma_buf) -{ - struct radeon_bo *bo = dma_buf->priv; - struct drm_device *dev = bo->rdev->ddev; + struct radeon_bo *bo = gem_to_radeon_bo(obj); int ret; - mutex_lock(&dev->struct_mutex); - if (bo->vmapping_count) { - bo->vmapping_count++; - goto out_unlock; - } - ret = ttm_bo_kmap(&bo->tbo, 0, bo->tbo.num_pages, &bo->dma_buf_vmap); - if (ret) { - mutex_unlock(&dev->struct_mutex); + if (ret) return ERR_PTR(ret); - } - bo->vmapping_count = 1; -out_unlock: - mutex_unlock(&dev->struct_mutex); + return bo->dma_buf_vmap.virtual; } -static void radeon_gem_prime_vunmap(struct dma_buf *dma_buf, void *vaddr) +void radeon_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr) { - struct radeon_bo *bo = dma_buf->priv; - struct drm_device *dev = bo->rdev->ddev; + struct radeon_bo *bo = gem_to_radeon_bo(obj); - mutex_lock(&dev->struct_mutex); - bo->vmapping_count--; - if (bo->vmapping_count == 0) { - ttm_bo_kunmap(&bo->dma_buf_vmap); - } - mutex_unlock(&dev->struct_mutex); + ttm_bo_kunmap(&bo->dma_buf_vmap); } -const static struct dma_buf_ops radeon_dmabuf_ops = { - .map_dma_buf = radeon_gem_map_dma_buf, - .unmap_dma_buf = radeon_gem_unmap_dma_buf, - .release = radeon_gem_dmabuf_release, - .kmap = radeon_gem_kmap, - .kmap_atomic = radeon_gem_kmap_atomic, - .kunmap = radeon_gem_kunmap, - .kunmap_atomic = radeon_gem_kunmap_atomic, - .mmap = radeon_gem_prime_mmap, - .vmap = radeon_gem_prime_vmap, - .vunmap = radeon_gem_prime_vunmap, -}; - -static int radeon_prime_create(struct drm_device *dev, - size_t size, - struct sg_table *sg, - struct radeon_bo **pbo) + +struct drm_gem_object *radeon_gem_prime_import_sg_table(struct drm_device *dev, + size_t size, + struct sg_table *sg) { struct radeon_device *rdev = dev->dev_private; struct radeon_bo *bo; int ret; ret = radeon_bo_create(rdev, size, PAGE_SIZE, false, - RADEON_GEM_DOMAIN_GTT, sg, pbo); + RADEON_GEM_DOMAIN_GTT, sg, &bo); if (ret) - return ret; - bo = *pbo; + return ERR_PTR(ret); bo->gem_base.driver_private = bo; mutex_lock(&rdev->gem.mutex); list_add_tail(&bo->list, &rdev->gem.objects); mutex_unlock(&rdev->gem.mutex); - return 0; + return &bo->gem_base; } -struct dma_buf *radeon_gem_prime_export(struct drm_device *dev, - struct drm_gem_object *obj, - int flags) +int radeon_gem_prime_pin(struct drm_gem_object *obj) { struct radeon_bo *bo = gem_to_radeon_bo(obj); int ret = 0; ret = radeon_bo_reserve(bo, false); if (unlikely(ret != 0)) - return ERR_PTR(ret); + return ret; /* pin buffer into GTT */ ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL); if (ret) { radeon_bo_unreserve(bo); - return ERR_PTR(ret); + return ret; } radeon_bo_unreserve(bo); - return dma_buf_export(bo, &radeon_dmabuf_ops, obj->size, flags); -} -struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev, - struct dma_buf *dma_buf) -{ - struct dma_buf_attachment *attach; - struct sg_table *sg; - struct radeon_bo *bo; - int ret; - - if (dma_buf->ops == &radeon_dmabuf_ops) { - bo = dma_buf->priv; - if (bo->gem_base.dev == dev) { - drm_gem_object_reference(&bo->gem_base); - dma_buf_put(dma_buf); - return &bo->gem_base; - } - } - - /* need to attach */ - attach = dma_buf_attach(dma_buf, dev->dev); - if (IS_ERR(attach)) - return ERR_CAST(attach); - - sg = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL); - if (IS_ERR(sg)) { - ret = PTR_ERR(sg); - goto fail_detach; - } - - ret = radeon_prime_create(dev, dma_buf->size, sg, &bo); - if (ret) - goto fail_unmap; - - bo->gem_base.import_attach = attach; - - return &bo->gem_base; - -fail_unmap: - dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL); -fail_detach: - dma_buf_detach(dma_buf, attach); - return ERR_PTR(ret); + return 0; } -- 1.7.9.5