Support for mapping an object page by page
Subsystems (3)
cover Support for mapping an object page by page
From: Ankitprasad Sharma <[email protected]>
It is possible that when we want to map an object to the aperture, either we run out of aperture space or the size of the object is larger than the mappable aperture. In such cases we might not be able to map the whole object to the aperture. For cases as such, here we introduce insert_page() which allows us to map a single page in to the mappable aperture space (which has a higher probabilty of succeeding). This can be iterated over to access the whole object by using space as meagre as page size.
Here we try to use insert_page() for pwrite_fast in case a nonblocking pin for the whole object fails, which helps us to iterate over the whole object and perform the pwrite without mapping the whole object to the mappable aperture.
We also introduce i915_gem_object_get_dma_address() to perform fast sequential lookup of the dma address associated with any page within the object.
Ankitprasad Sharma (1):
drm/i915: Use insert_page for pwrite_fast
Chris Wilson (2):
drm/i915: Add support for mapping an object page by page drm/i915: Introduce i915_gem_object_get_dma_address()
drivers/char/agp/intel-gtt.c | 9 ++++ drivers/gpu/drm/i915/i915_drv.h | 17 +++++++ drivers/gpu/drm/i915/i915_gem.c | 92 +++++++++++++++++++++++++++---------- drivers/gpu/drm/i915/i915_gem_gtt.c | 49 ++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_gtt.h | 5 ++ include/drm/intel-gtt.h | 3 ++ 6 files changed, 152 insertions(+), 23 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/3 drm/i915: Add support for mapping an object page by page
From: Chris Wilson <[email protected]>
Introduced a new vm specfic callback insert_page() to program a single pte in ggtt or ppgtt. This allows us to map a single page in to the mappable aperture space. This can be iterated over to access the whole object by using space as meagre as page size.
--- drivers/char/agp/intel-gtt.c | 9 +++++++ drivers/gpu/drm/i915/i915_gem_gtt.c | 49 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_gtt.h | 5 ++++ include/drm/intel-gtt.h | 3 +++ 4 files changed, 66 insertions(+)
drivers/char/agp/intel-gtt.c +9 -0
@@ -838,6 +838,15 @@ static bool i830_check_flags(unsigned int flags)return false; } +void intel_gtt_insert_page (dma_addr_t addr, +unsigned int pg, +unsigned int flags) +{ + intel_private.driver->write_entry (addr, pg, flags); +wmb (); +} +EXPORT_SYMBOL (intel_gtt_insert_page); +void intel_gtt_insert_sg_entries (struct sg_table *st,unsigned int pg_start,unsigned int flags)
drivers/gpu/drm/i915/i915_gem_gtt.c +49 -0
85 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_gtt.h +5 -0
@@ -320,6 +320,11 @@ struct i915_address_space {uint64_t start, uint64_t length, bool use_scratch); +void (*insert_page)(struct i915_address_space *vm, +dma_addr_t addr, +uint64_t offset, +enum i915_cache_level cache_level, +u32 flags); void (*insert_entries)(struct i915_address_space *vm, struct sg_table *st, uint64_t start,
include/drm/intel-gtt.h +3 -0
@@ -13,6 +13,9 @@ void intel_gmch_remove(void);bool intel_enable_gtt (void );void intel_gtt_chipset_flush (void ); +void intel_gtt_insert_page (dma_addr_t addr, +unsigned int pg, +unsigned int flags);void intel_gtt_insert_sg_entries (struct sg_table *st,unsigned int pg_start,unsigned int flags);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/3 drm/i915: Introduce i915_gem_object_get_dma_address()
In reply to [email protected]From: Chris Wilson <[email protected]>
This utility function is a companion to i915_gem_object_get_page() that uses the same cached iterator for the scatterlist to perform fast sequential lookup of the dma address associated with any page within the object.
--- drivers/gpu/drm/i915/i915_drv.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +17 -0
@@ -2854,6 +2854,23 @@ static inline int __sg_page_count(struct scatterlist *sg)return sg->length >>PAGE_SHIFT ; } +static inline dma_addr_t +i915_gem_object_get_dma_address (struct drm_i915_gem_object *obj,int n) +{ +if (n < obj->get_page.last) { + obj->get_page.sg = obj->pages->sgl; + obj->get_page.last =0 ; + } + +while (obj->get_page.last +__sg_page_count (obj->get_page.sg) <= n) { + obj->get_page.last +=__sg_page_count (obj->get_page.sg++); +if (unlikely (sg_is_chain (obj->get_page.sg))) + obj->get_page.sg =sg_chain_ptr (obj->get_page.sg); + } + +return sg_dma_address (obj->get_page.sg) + ((n - obj->get_page.last) <<PAGE_SHIFT ); +} +static inline struct page *i915_gem_object_get_page (struct drm_i915_gem_object *obj,int n) {
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/3 drm/i915: Use insert_page for pwrite_fast
In reply to [email protected]From: Ankitprasad Sharma <[email protected]>
In pwrite_fast, map an object page by page if obj_ggtt_pin fails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).
--- drivers/gpu/drm/i915/i915_gem.c | 92 ++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +69 -23
@@ -766,14 +766,26 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, struct drm_file *file) {struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_mm_node node;ssize_t remain;loff_t offset, page_base;char __user *user_data; -int page_offset, page_length, ret; +int page_offset, page_length, ret, i; +bool pinned = true; ret =i915_gem_obj_ggtt_pin (obj,0 ,PIN_MAPPABLE |PIN_NONBLOCK ); -if (ret) - goto out; +if (ret) { + pinned = false; +memset (&node,0 ,sizeof (node)); + ret =drm_mm_insert_node_in_range_generic (&dev_priv->gtt.base.mm, + &node,4096 ,0 , +I915_CACHE_NONE ,0 , + dev_priv->gtt.mappable_end, +DRM_MM_SEARCH_DEFAULT , +DRM_MM_CREATE_DEFAULT ); +if (ret) + goto out; + } ret =i915_gem_object_set_to_gtt_domain (obj, true);if (ret)
@@ -786,42 +798,76 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, user_data =to_user_ptr (args->data_ptr); remain = args->size; - offset =i915_gem_obj_ggtt_offset (obj) + args->offset; -intel_fb_obj_invalidate (obj,ORIGIN_GTT ); -while (remain >0 ) { -/* Operation in this page +if (likely (pinned)) { + offset =i915_gem_obj_ggtt_offset (obj) + args->offset; +/* Operation in the page * * page_base = page offset within aperture * page_offset = offset within page -* page_length = bytes to copy for this page +* page_length = bytes to copy for the page */ page_base = offset &PAGE_MASK ; page_offset =offset_in_page (offset); - page_length = remain; -if ((page_offset + remain) >PAGE_SIZE ) - page_length =PAGE_SIZE - page_offset; +while (remain >0 ) { + page_length = remain; +if ((page_offset + remain) >PAGE_SIZE ) + page_length =PAGE_SIZE - page_offset; + +/* If we get a fault while copying data, then (presumably) our +* source page isn't available. Return the error and we'll +* retry in the slow path. +*/ +if (fast_user_write (dev_priv->gtt.mappable, page_base, + page_offset, user_data, page_length)) { + ret = -EFAULT ; + goto out_flush; + } -/* If we get a fault while copying data, then (presumably) our -* source page isn't available. Return the error and we'll -* retry in the slow path. -*/ -if (fast_user_write (dev_priv->gtt.mappable, page_base, - page_offset, user_data, page_length)) { - ret = -EFAULT ; - goto out_flush; + remain -= page_length; + user_data += page_length; + page_offset =0 ; } + }else { + i = args->offset /PAGE_SIZE ; + page_offset =offset_in_page (args->offset); +while (remain >0 ) { + page_length = remain; +if ((page_offset + remain) >PAGE_SIZE ) + page_length =PAGE_SIZE - page_offset; + +wmb (); + dev_priv->gtt.base.insert_page (&dev_priv->gtt.base, +i915_gem_object_get_dma_address (obj, i), + node.start, +I915_CACHE_NONE , +0 ); +wmb (); + +if (fast_user_write (dev_priv->gtt.mappable, node.start, + page_offset, user_data, page_length)) { + ret = -EFAULT ; + goto out_flush; + } - remain -= page_length; - user_data += page_length; - offset += page_length; + remain -= page_length; + user_data += page_length; + page_offset =0 ; + i++; + } +wmb (); + dev_priv->gtt.base.clear_range (&dev_priv->gtt.base, + node.start, node.size, + true); +drm_mm_remove_node (&node); } out_flush:intel_fb_obj_flush (obj, false,ORIGIN_GTT ); out_unpin: -i915_gem_object_ggtt_unpin (obj); +if (pinned) +i915_gem_object_ggtt_unpin (obj); out:return ret; }
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 34 lines · On Thu, Nov 05, 2015 at 05:15:59PM +0530, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).Signed-off-by Ankitprasad Sharma <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 92 ++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 23 deletions(-)drivers/gpu/drm/i915/i915_gem.c +4
-3@@ -766,14 +766,26 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, struct drm_file *file) {struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_mm_node node;ssize_t remain;loff_t offset, page_base;char __user *user_data; -int page_offset, page_length, ret; +int page_offset, page_length, ret, i; +bool pinned = true; ret =i915_gem_obj_ggtt_pin (obj,0 ,PIN_MAPPABLE |PIN_NONBLOCK ); -if (ret) - goto out; +if (ret) {
drivers/gpu/drm/i915/i915_gem.c i915_gem_gtt_pwrite_fast(struct drm_device *dev, · line 787
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +10
-0+ pinned = false; +memset (&node,0 ,sizeof (node)); + ret =drm_mm_insert_node_in_range_generic (&dev_priv->gtt.base.mm, + &node,4096 ,0 , +I915_CACHE_NONE ,0 , + dev_priv->gtt.mappable_end, +DRM_MM_SEARCH_DEFAULT , +DRM_MM_CREATE_DEFAULT ); +if (ret) + goto out;
Prefer to refer to my original patch as to why this wrong. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 31 lines · Chris Wilson
Quoted 30 lines · On Thu, Nov 05, 2015 at 05:15:59PM +0530, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).Signed-off-by Ankitprasad Sharma <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 92 ++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 23 deletions(-)drivers/gpu/drm/i915/i915_gem.c +3
-1@@ -766,14 +766,26 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, struct drm_file *file) {struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_mm_node node;ssize_t remain;loff_t offset, page_base;char __user *user_data; -int page_offset, page_length, ret; +int page_offset, page_length, ret, i; +bool pinned = true;
Quoted 16 lines
Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.c +1
-2ret =i915_gem_obj_ggtt_pin (obj,0 ,PIN_MAPPABLE |PIN_NONBLOCK ); -if (ret) - goto out; +if (ret) {drivers/gpu/drm/i915/i915_gem.c i915_gem_gtt_pwrite_fast(struct drm_device *dev, · line 787
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +10
-0+ pinned = false; +memset (&node,0 ,sizeof (node)); + ret =drm_mm_insert_node_in_range_generic (&dev_priv->gtt.base.mm, + &node,4096 ,0 , +I915_CACHE_NONE ,0 , + dev_priv->gtt.mappable_end, +DRM_MM_SEARCH_DEFAULT , +DRM_MM_CREATE_DEFAULT ); +if (ret) + goto out;Prefer to refer to my original patch as to why this wrong.
If you are concerned about pages for the object not getting allocated, then soon after node insertion we call i915_gem_object_set_to_gtt_domain() which takes care of page allocations for the object.
If there is any other concern, please let me know.
Thanks,
Ankit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
In reply to [email protected]Quoted 8 lines · On 05/11/15 11:45, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).
Aperture in aperture, reminds me of those "Yo dawg I've heard you like X so I've put X in your X so you can Y while you Y" jokes. :D
Would using the partial view code be interesting for this? Might be faster due to larger chunks possible, or slower due more expensive set up time, I don't know.
Interesting thing is it was added for virtualization use cases so there is overlap here.
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 11 lines · Tvrtko Ursulin
Quoted 8 lines · On 05/11/15 11:45, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).
Quoted 6 lines
Aperture in aperture, reminds me of those "Yo dawg I've heard you like X so I've put X in your X so you can Y while you Y" jokes. :D
Would using the partial view code be interesting for this? Might be faster due to larger chunks possible, or slower due more expensive set up time, I don't know.
It's the wrong abstraction.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 12 lines · Chris Wilson
Quoted 11 lines · Tvrtko Ursulin
Quoted 8 lines · On 05/11/15 11:45, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).
Quoted 8 lines
Quoted 6 lines
Aperture in aperture, reminds me of those "Yo dawg I've heard you like X so I've put X in your X so you can Y while you Y" jokes. :D
Would using the partial view code be interesting for this? Might be faster due to larger chunks possible, or slower due more expensive set up time, I don't know.
It's the wrong abstraction.
Looks the same to me, only difference is the size.
Why not just to the page aperture then for simplicity? If there is any performance gain from trying the full VMA first then why there wouldn't be some to try with the partial VMA?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 17 lines · Tvrtko Ursulin
Quoted 15 lines · Chris Wilson
Quoted 14 lines · Tvrtko Ursulin
Quoted 8 lines · On 05/11/15 11:45, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).Aperture in aperture, reminds me of those "Yo dawg I've heard you like X so I've put X in your X so you can Y while you Y" jokes. :D
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Would using the partial view code be interesting for this? Might be faster due to larger chunks possible, or slower due more expensive set up time, I don't know.
It's the wrong abstraction.
Looks the same to me, only difference is the size.
There are many places that insert-page is used where we cannot do a partial-pin.
Quoted 3 lines
Why not just to the page aperture then for simplicity? If there is any performance gain from trying the full VMA first then why there wouldn't be some to try with the partial VMA?
obj->base.size >> PAGE_SHIFT x partial pages is not even funny. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 26 lines · Chris Wilson
Quoted 17 lines · Tvrtko Ursulin
Quoted 15 lines · Chris Wilson
Quoted 14 lines · Tvrtko Ursulin
Quoted 8 lines · On 05/11/15 11:45, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).Aperture in aperture, reminds me of those "Yo dawg I've heard you like X so I've put X in your X so you can Y while you Y" jokes. :D
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Would using the partial view code be interesting for this? Might be faster due to larger chunks possible, or slower due more expensive set up time, I don't know.
It's the wrong abstraction.
Looks the same to me, only difference is the size.
Quoted 8 lines
There are many places that insert-page is used where we cannot do a partial-pin.
Quoted 3 lines
Why not just to the page aperture then for simplicity? If there is any performance gain from trying the full VMA first then why there wouldn't be some to try with the partial VMA?
obj->base.size>>PAGE_SHIFTx partial pages is not even funny.
Well I did not suggest that but larger chunks so I will repeat my question.
If going page by page is fine for performance then why have the two code paths at all? One which tries top pin the whole object first, and second which goes page by page if that fails. Why not just do it page by page and avoid having two copy loops etc?
On the other hand, if there is significant performance hit with the page by page path, then why not use partial views with 1Mb chunks or something?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 35 lines · Tvrtko Ursulin
Quoted 33 lines · Chris Wilson
Quoted 17 lines · Tvrtko Ursulin
Quoted 15 lines · Chris Wilson
Quoted 14 lines · Tvrtko Ursulin
Quoted 8 lines · On 05/11/15 11:45, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).Aperture in aperture, reminds me of those "Yo dawg I've heard you like X so I've put X in your X so you can Y while you Y" jokes. :D
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Would using the partial view code be interesting for this? Might be faster due to larger chunks possible, or slower due more expensive set up time, I don't know.
It's the wrong abstraction.
Looks the same to me, only difference is the size.
There are many places that insert-page is used where we cannot do a partial-pin.
Quoted 3 lines
Why not just to the page aperture then for simplicity? If there is any performance gain from trying the full VMA first then why there wouldn't be some to try with the partial VMA?
Quoted 8 lines
Quoted 1 line
obj->base.size>>PAGE_SHIFTx partial pages is not even funny.Well I did not suggest that but larger chunks so I will repeat my question.
If going page by page is fine for performance then why have the two code paths at all? One which tries top pin the whole object first, and second which goes page by page if that fails. Why not just do it page by page and avoid having two copy loops etc?
If we already have the vma or can allocate it with impacting upon the system, using it is best (since we expect to reuse it again). If we cannot allocate it, our natural iterator size is 4096 bytes and is also our best chance at allocating that in the aperture.
Partial vma are a high overhead and more importantly a massive impedance mismatch.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
In reply to [email protected]Quoted 8 lines · On Thu, Nov 05, 2015 at 05:15:59PM +0530, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).
We already have a fallback to the shmem pwrite. Why do we need this? -Daniel
Quoted 144 lines
Signed-off-by Ankitprasad Sharma <[email protected]>--- drivers/gpu/drm/i915/i915_gem.c | 92 ++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 23 deletions(-)drivers/gpu/drm/i915/i915_gem.c +69
-23@@ -766,14 +766,26 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, struct drm_file *file) {struct drm_i915_private *dev_priv = dev->dev_private; +struct drm_mm_node node;ssize_t remain;loff_t offset, page_base;char __user *user_data; -int page_offset, page_length, ret; +int page_offset, page_length, ret, i; +bool pinned = true; ret =i915_gem_obj_ggtt_pin (obj,0 ,PIN_MAPPABLE |PIN_NONBLOCK ); -if (ret) - goto out; +if (ret) { + pinned = false; +memset (&node,0 ,sizeof (node)); + ret =drm_mm_insert_node_in_range_generic (&dev_priv->gtt.base.mm, + &node,4096 ,0 , +I915_CACHE_NONE ,0 , + dev_priv->gtt.mappable_end, +DRM_MM_SEARCH_DEFAULT , +DRM_MM_CREATE_DEFAULT ); +if (ret) + goto out; + } ret =i915_gem_object_set_to_gtt_domain (obj, true);if (ret)@@ -786,42 +798,76 @@ i915_gem_gtt_pwrite_fast(struct drm_device *dev, user_data =to_user_ptr (args->data_ptr); remain = args->size; - offset =i915_gem_obj_ggtt_offset (obj) + args->offset; -intel_fb_obj_invalidate (obj,ORIGIN_GTT ); -while (remain >0 ) { -/* Operation in this page +if (likely (pinned)) { + offset =i915_gem_obj_ggtt_offset (obj) + args->offset; +/* Operation in the page * * page_base = page offset within aperture * page_offset = offset within page -* page_length = bytes to copy for this page +* page_length = bytes to copy for the page */ page_base = offset &PAGE_MASK ; page_offset =offset_in_page (offset); - page_length = remain; -if ((page_offset + remain) >PAGE_SIZE ) - page_length =PAGE_SIZE - page_offset; +while (remain >0 ) { + page_length = remain; +if ((page_offset + remain) >PAGE_SIZE ) + page_length =PAGE_SIZE - page_offset; + +/* If we get a fault while copying data, then (presumably) our +* source page isn't available. Return the error and we'll +* retry in the slow path. +*/ +if (fast_user_write (dev_priv->gtt.mappable, page_base, + page_offset, user_data, page_length)) { + ret = -EFAULT ; + goto out_flush; + } -/* If we get a fault while copying data, then (presumably) our -* source page isn't available. Return the error and we'll -* retry in the slow path. -*/ -if (fast_user_write (dev_priv->gtt.mappable, page_base, - page_offset, user_data, page_length)) { - ret = -EFAULT ; - goto out_flush; + remain -= page_length; + user_data += page_length; + page_offset =0 ; } + }else { + i = args->offset /PAGE_SIZE ; + page_offset =offset_in_page (args->offset); +while (remain >0 ) { + page_length = remain; +if ((page_offset + remain) >PAGE_SIZE ) + page_length =PAGE_SIZE - page_offset; + +wmb (); + dev_priv->gtt.base.insert_page (&dev_priv->gtt.base, +i915_gem_object_get_dma_address (obj, i), + node.start, +I915_CACHE_NONE , +0 ); +wmb (); + +if (fast_user_write (dev_priv->gtt.mappable, node.start, + page_offset, user_data, page_length)) { + ret = -EFAULT ; + goto out_flush; + } - remain -= page_length; - user_data += page_length; - offset += page_length; + remain -= page_length; + user_data += page_length; + page_offset =0 ; + i++; + } +wmb (); + dev_priv->gtt.base.clear_range (&dev_priv->gtt.base, + node.start, node.size, + true); +drm_mm_remove_node (&node); } out_flush:intel_fb_obj_flush (obj, false,ORIGIN_GTT ); out_unpin: -i915_gem_object_ggtt_unpin (obj); +if (pinned) +i915_gem_object_ggtt_unpin (obj); out:return ret; }Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Thu, Nov 05, 2015 at 05:15:59PM +0530, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).We already have a fallback to the shmem pwrite. Why do we need this?
This is mainly for the non-shmem backed objects, as we do not have fallback path for that. Agree for the shmem backed objects, as we already have a fallback.
Would like to request Chris, if he can clarify further.
Thanks,
Ankit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 11 lines · Ankitprasad Sharma
Quoted 10 lines · Daniel Vetter
Quoted 8 lines · On Thu, Nov 05, 2015 at 05:15:59PM +0530, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).
Quoted 6 lines
Quoted 1 line
We already have a fallback to the shmem pwrite. Why do we need this?
This is mainly for the non-shmem backed objects, as we do not have fallback path for that. Agree for the shmem backed objects, as we already have a fallback.
Would like to request Chris, if he can clarify further.
Exactly that, with stolen we cannot use the shmem path so there exists no fallback. In order to pwrite to stolen, the GTT path must be fully capable.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 17 lines · Chris Wilson
Quoted 16 lines · Ankitprasad Sharma
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Thu, Nov 05, 2015 at 05:15:59PM +0530, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).We already have a fallback to the shmem pwrite. Why do we need this?
This is mainly for the non-shmem backed objects, as we do not have fallback path for that. Agree for the shmem backed objects, as we already have a fallback.
Quoted 5 lines
Quoted 1 line
Would like to request Chris, if he can clarify further.
Exactly that, with stolen we cannot use the shmem path so there exists no fallback. In order to pwrite to stolen, the GTT path must be fully capable.
Ok, in that case this should probably be part of the stolen obj series, just for clarification.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/3] drm/i915: Use insert_page for pwrite_fast
Quoted 20 lines · Daniel Vetter
Quoted 19 lines · Chris Wilson
Quoted 17 lines · Ankitprasad Sharma
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · On Thu, Nov 05, 2015 at 05:15:59PM +0530, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
In
pwrite_fast, map an object page by page ifobj_ggtt_pinfails. First, we try a nonblocking pin for the whole object (since that is fastest if reused), then failing that we try to grab one page in the mappable aperture. It also allows us to handle objects larger than the mappable aperture (e.g. if we need to pwrite with vGPU restricting the aperture to a measely 8MiB or something like that).We already have a fallback to the shmem pwrite. Why do we need this?
This is mainly for the non-shmem backed objects, as we do not have fallback path for that. Agree for the shmem backed objects, as we already have a fallback.
Would like to request Chris, if he can clarify further.
Quoted 7 lines
Quoted 3 lines
Exactly that, with stolen we cannot use the shmem path so there exists no fallback. In order to pwrite to stolen, the GTT path must be fully capable.
Ok, in that case this should probably be part of the stolen obj series, just for clarification.
-Daniel
Daniel,
I have moved this patch to the stolen memory series with the latest version. Can we please move ahead for the review and merge of the first 2 patches?
Thanks,
Ankit
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx