From: ankitprasad.r.sharma@intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>,
akash.goel@intel.com, shashidhar.hiremath@intel.com
Subject: [PATCH 02/10] drm/i915: Introduce i915_gem_object_get_dma_address()
Date: Mon, 29 Feb 2016 13:09:31 +0530 [thread overview]
Message-ID: <1456731579-25584-3-git-send-email-ankitprasad.r.sharma@intel.com> (raw)
In-Reply-To: <1456731579-25584-1-git-send-email-ankitprasad.r.sharma@intel.com>
From: Chris Wilson <chris@chris-wilson.co.uk>
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.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
drivers/gpu/drm/i915/i915_drv.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a4dcb74..fc02ee6 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2952,6 +2952,23 @@ static inline int __sg_page_count(struct scatterlist *sg)
struct page *
i915_gem_object_get_dirty_page(struct drm_i915_gem_object *obj, int n);
+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)
{
--
1.9.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-02-29 8:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-29 7:39 [PATCH v1 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-02-29 7:39 ` [PATCH 01/10] drm/i915: Add support for mapping an object page by page ankitprasad.r.sharma
2016-02-29 7:39 ` ankitprasad.r.sharma [this message]
2016-02-29 7:39 ` [PATCH 03/10] drm/i915: Use insert_page for pwrite_fast ankitprasad.r.sharma
2016-02-29 7:39 ` [PATCH 04/10] drm/i915: Clearing buffer objects via CPU/GTT ankitprasad.r.sharma
2016-02-29 7:39 ` [PATCH 05/10] drm/i915: Support for creating Stolen memory backed objects ankitprasad.r.sharma
2016-02-29 7:39 ` [PATCH 06/10] drm/i915: Propagating correct error codes to the userspace ankitprasad.r.sharma
2016-02-29 7:39 ` [PATCH 07/10] drm/i915: Add support for stealing purgable stolen pages ankitprasad.r.sharma
2016-02-29 7:39 ` [PATCH 08/10] drm/i915: Support for pread/pwrite from/to non shmem backed objects ankitprasad.r.sharma
2016-02-29 7:39 ` [PATCH 09/10] drm/i915: Migrate stolen objects before hibernation ankitprasad.r.sharma
2016-02-29 7:39 ` [PATCH 10/10] drm/i915: Disable use of stolen area by User when Intel RST is present ankitprasad.r.sharma
2016-02-29 8:27 ` ✗ Fi.CI.BAT: failure for Support for creating/using Stolen memory backed objects (rev11) Patchwork
-- strict thread matches above, loose matches on Subject: below --
2016-03-18 6:22 [PATCH v19 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-03-18 6:22 ` [PATCH 02/10] drm/i915: Introduce i915_gem_object_get_dma_address() ankitprasad.r.sharma
2016-02-19 6:51 [PATCH v17 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-02-19 6:51 ` [PATCH 02/10] drm/i915: Introduce i915_gem_object_get_dma_address() ankitprasad.r.sharma
2016-02-04 9:30 [PATCH v16 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-02-04 9:30 ` [PATCH 02/10] drm/i915: Introduce i915_gem_object_get_dma_address() ankitprasad.r.sharma
2016-02-11 10:52 ` Tvrtko Ursulin
2016-01-25 19:43 [PATCH v15 0/10] Support for creating/using Stolen memory backed objects ankitprasad.r.sharma
2016-01-25 19:43 ` [PATCH 02/10] drm/i915: Introduce i915_gem_object_get_dma_address() ankitprasad.r.sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456731579-25584-3-git-send-email-ankitprasad.r.sharma@intel.com \
--to=ankitprasad.r.sharma@intel.com \
--cc=akash.goel@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=shashidhar.hiremath@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).