<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Am 05.03.20 um 15:35 schrieb Nirmoy:<br>
</div>
<blockquote type="cite"
cite="mid:3f6148c1-8357-0f18-3bda-bd989ac26393@amd.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<p><br>
</p>
<div class="moz-cite-prefix">On 3/5/20 3:07 PM, Gerd Hoffmann
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20200305140749.5oggp4gh6hozsh7j@sirius.home.kraxel.org">
<pre class="moz-quote-pre" wrap="">On Thu, Mar 05, 2020 at 02:29:08PM +0100, Nirmoy Das wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Calculate GEM VRAM bo's offset within vram-helper without depending on
bo->offset.
Signed-off-by: Nirmoy Das <a class="moz-txt-link-rfc2396E" href="mailto:nirmoy.das@amd.com" moz-do-not-send="true"><nirmoy.das@amd.com></a>
Reviewed-by: Daniel Vetter <a class="moz-txt-link-rfc2396E" href="mailto:daniel.vetter@ffwll.ch" moz-do-not-send="true"><daniel.vetter@ffwll.ch></a>
---
drivers/gpu/drm/drm_gem_vram_helper.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index 92a11bb42365..2749c2d25ac4 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -198,6 +198,13 @@ u64 drm_gem_vram_mmap_offset(struct drm_gem_vram_object *gbo)
}
EXPORT_SYMBOL(drm_gem_vram_mmap_offset);
+static s64 drm_gem_vram_pg_offset(struct drm_gem_vram_object *gbo)
+{
+ if (WARN_ON_ONCE(!gbo->bo.mem.mm_node))
+ return 0;
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">returns 0 on error.</pre>
</blockquote>
<p>I am not sure if we should call this an error. This patch
series removes below offset calculation from ttm_bo.c. <br>
</p>
<pre class="moz-quote-pre" wrap="">- if (bo->mem.mm_node)
- bo->offset = (bo->mem.start << PAGE_SHIFT) +
- bdev->man[bo->mem.mem_type].gpu_offset;
- else
- bo->offset = 0;
-
</pre>
<p><font size="+1">Most of the driver sets "bo->mem.mm_node".
Thomas suggested to use this "return 0" in case some driver
depends on bo->offset = 0.</font></p>
</blockquote>
<br>
We should probably add a code comment here to explain why we do
this.<br>
<br>
Something like "Keep TTM behavior for now, remove when drivers are
audited".<br>
<br>
Regards,<br>
Christian.<br>
<br>
<blockquote type="cite"
cite="mid:3f6148c1-8357-0f18-3bda-bd989ac26393@amd.com">
<blockquote type="cite"
cite="mid:20200305140749.5oggp4gh6hozsh7j@sirius.home.kraxel.org">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">+ return gbo->bo.mem.start;
+}
+
/**
* drm_gem_vram_offset() - \
Returns a GEM VRAM object's offset in video memory
@@ -214,7 +221,7 @@ s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo)
{
if (WARN_ON_ONCE(!gbo->pin_count))
return (s64)-ENODEV;
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">returns -errno on error.
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">- return gbo->bo.offset;
+ return drm_gem_vram_pg_offset(gbo) << PAGE_SHIFT;
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">And given that one calls the other behavior on error should better be
consistent ...
cheers,
Gerd
</pre>
</blockquote>
<p><br>
</p>
<p>Regards,</p>
<p>Nirmoy<br>
</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
amd-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
</pre>
</blockquote>
<br>
</body>
</html>