<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Bike shedding accepted. <img alt="😊" class="EmojiInsert" style="vertical-align: bottom;" src="cid:2164fc72-30fb-46f1-8408-487a551a49cd"> Of course now I have to circle back and fix the debug tool...</p>
<p><br>
</p>
<p>Tom</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Nicolai Hähnle <nhaehnle@gmail.com><br>
<b>Sent:</b> Wednesday, June 29, 2016 09:50<br>
<b>To:</b> Tom St Denis; amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> StDenis, Tom<br>
<b>Subject:</b> Re: [PATCH 3/3] drm/amd/amdgpu: Add bank selection for MMIO debugfs</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">On 29.06.2016 12:15, Tom St Denis wrote:<br>
> (v2) Added INSTANCE selector<br>
><br>
> Signed-off-by: Tom St Denis <tom.stdenis@amd.com><br>
> ---<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 35 +++++++++++++++++++++++++++---<br>
> 1 file changed, 32 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> index 7f08ac02f9de..bea5f90f479e 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
> @@ -2244,20 +2244,43 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,<br>
> struct amdgpu_device *adev = f->f_inode->i_private;<br>
> ssize_t result = 0;<br>
> int r;<br>
> + bool use_bank;<br>
> + unsigned instance_bank, sh_bank, se_bank;<br>
><br>
> if (size & 0x3 || *pos & 0x3)<br>
> return -EINVAL;<br>
><br>
> + if (*pos & (1ULL << 62)) {<br>
> + sh_bank = (*pos >> 24) & 0x3FF;<br>
> + se_bank = (*pos >> 34) & 0x3FF;<br>
> + instance_bank = (*pos >> 44) & 0x3FF;<br>
<br>
It's a bit of an bike-shedding quibble, but the bit shift should be <br>
ordered SE -> SH -> INSTANCE, since the SE is the highest-level concept <br>
and the instance number is the lowest level.<br>
<br>
Apart from that and the comment on #1, patch 1 and 3 look good to me. <br>
(Can't really say much about patch 2.)<br>
<br>
Cheers,<br>
Nicolai<br>
<br>
> + use_bank = 1;<br>
> + *pos &= 0xFFFFFF;<br>
> + } else {<br>
> + use_bank = 0;<br>
> + }<br>
> +<br>
> + if (use_bank) {<br>
> + if (sh_bank >= adev->gfx.config.max_sh_per_se ||<br>
> + se_bank >= adev->gfx.config.max_shader_engines)<br>
> + return -EINVAL;<br>
> + mutex_lock(&adev->grbm_idx_mutex);<br>
> + amdgpu_gfx_select_se_sh(adev, se_bank,<br>
> + sh_bank, instance_bank);<br>
> + }<br>
> +<br>
> while (size) {<br>
> uint32_t value;<br>
><br>
> if (*pos > adev->rmmio_size)<br>
> - return result;<br>
> + goto end;<br>
><br>
> value = RREG32(*pos >> 2);<br>
> r = put_user(value, (uint32_t *)buf);<br>
> - if (r)<br>
> - return r;<br>
> + if (r) {<br>
> + result = r;<br>
> + goto end;<br>
> + }<br>
><br>
> result += 4;<br>
> buf += 4;<br>
> @@ -2265,6 +2288,12 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,<br>
> size -= 4;<br>
> }<br>
><br>
> +end:<br>
> + if (use_bank) {<br>
> + amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);<br>
> + mutex_unlock(&adev->grbm_idx_mutex);<br>
> + }<br>
> +<br>
> return result;<br>
> }<br>
><br>
><br>
</div>
</span></font></div>
</div>
</body>
</html>