<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 2/21/20 2:19 AM, Luben Tuikov wrote:<br>
</div>
<blockquote type="cite" cite="mid:9e26a27b-eeaa-39b3-dacc-9f3777f3cf92@amd.com">
<pre class="moz-quote-pre" wrap="">On 2020-02-19 08:53, Nirmoy Das wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">Calculate GPU offset in radeon_bo_gpu_offset without depending on
bo->offset
Signed-off-by: Nirmoy Das <a class="moz-txt-link-rfc2396E" href="mailto:nirmoy.das@amd.com"><nirmoy.das@amd.com></a>
Reviewed-and-tested-by: Christian König <a class="moz-txt-link-rfc2396E" href="mailto:christian.koenig@amd.com"><christian.koenig@amd.com></a>
---
drivers/gpu/drm/radeon/radeon.h | 1 +
drivers/gpu/drm/radeon/radeon_object.h | 16 +++++++++++++++-
drivers/gpu/drm/radeon/radeon_ttm.c | 4 +---
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 30e32adc1fc6..b7c3fb2bfb54 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2828,6 +2828,7 @@ extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size
extern void radeon_program_register_sequence(struct radeon_device *rdev,
const u32 *registers,
const u32 array_size);
+struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev);
/*
* vm
diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
index d23f2ed4126e..4d37571c7ff5 100644
--- a/drivers/gpu/drm/radeon/radeon_object.h
+++ b/drivers/gpu/drm/radeon/radeon_object.h
@@ -90,7 +90,21 @@ static inline void radeon_bo_unreserve(struct radeon_bo *bo)
*/
static inline u64 radeon_bo_gpu_offset(struct radeon_bo *bo)
{
- return bo->tbo.offset;
+ struct radeon_device *rdev;
+ u64 start = 0;
+
+ rdev = radeon_get_rdev(bo->tbo.bdev);
+
+ switch(bo->tbo.mem.mem_type) {
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
LKCS wants a space after a keyword, "switch (" .</pre>
</blockquote>
Thanks Luben, will fix that for both radeon and amdgpu.<br>
<blockquote type="cite" cite="mid:9e26a27b-eeaa-39b3-dacc-9f3777f3cf92@amd.com">
<pre class="moz-quote-pre" wrap="">
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">+ case TTM_PL_TT:
+ start = rdev->mc.gtt_start;
+ break;
+ case TTM_PL_VRAM:
+ start = rdev->mc.vram_start;
+ break;
+ }
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
Could this lookup have been parameterized by "mem_type"
to be looked up by an index (possibly "mem_type") to result
in something new like (pseudo-code):
start = rdev->mc.mem_start_table[bo->tbo.mem.mem_type];
Where "mem_start_table" is a new table holding memory starts
of particular memories.
Then you don't need the switch-case.
</pre>
</blockquote>
<p>That would look good but I am afraid, amdgpu_ttm_domain_start()
and radeon_bo_gpu_offset() will be the only consumer of <i>mem_start_table.</i></p>
<p>I think it is not worth to do a intrusive change for this patch
series.<br>
</p>
<p>Regards,</p>
<p>Nirmoy<br>
</p>
<p>
</p>
<br>
</body>
</html>