<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<div>The plan is for the vbios version to be available through the ROCM-SMI utility. We have the GPU power usage listed in the debugfs currently. If they are both to be used for a userspace utility, should we be moving both of those to sysfs instead?<br>
<br>
Kent<br>
<br>
KENT RUSSELL<br>
Software Engineer | Vertical Workstation/Compute<br>
1 Commerce Valley Drive East<br>
Markham, ON L3T 7X6<br>
Canada<br>
O +(1) 289-695-2122 | Ext x72122<br>
<br>
<br>
<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> Christian König <deathsimple@vodafone.de><br>
<b>Sent:</b> Thursday, August 24, 2017 2:10:35 PM<br>
<b>To:</b> Russell, Kent; Alex Deucher; Kuehling, Felix<br>
<b>Cc:</b> amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Actually the main difference is not root vs. user, but rather unstable
<br>
vs stable interface.<br>
<br>
If you want a stable interface for an userspace tool you should use <br>
sysfs, if you don't care about that you should use debugfs.<br>
<br>
Christian.<br>
<br>
Am 24.08.2017 um 18:37 schrieb Russell, Kent:<br>
> We already access the GPU Power usage via debugfs, which is why I didn't think it was a huge deal to switch it over, since we already need root access for the SMI due to that.<br>
><br>
> Kent<br>
><br>
> -----Original Message-----<br>
> From: Alex Deucher [<a href="mailto:alexdeucher@gmail.com">mailto:alexdeucher@gmail.com</a>]<br>
> Sent: Thursday, August 24, 2017 11:39 AM<br>
> To: Kuehling, Felix<br>
> Cc: Russell, Kent; Christian König; amd-gfx@lists.freedesktop.org<br>
> Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS<br>
><br>
> On Thu, Aug 24, 2017 at 11:35 AM, Kuehling, Felix <Felix.Kuehling@amd.com> wrote:<br>
>> Debugfs is only accessible by Root. The BIOS version is already reported in the kernel log, which is visible to everyone. So why hide this away in debugfs?<br>
>><br>
>> I think Kent's intention is to add VBIOS version reporting to the rocm-smi tool. I'd prefer using a stable interface like sysfs, and one that doesn't require root access in a tool like rocm-smi.<br>
>><br>
> Ah, ok, sysfs is fine in that case. I thought this was just general debugging stuff.<br>
><br>
> Alex<br>
><br>
>> Regards,<br>
>> Felix<br>
>> ________________________________________<br>
>> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of<br>
>> Russell, Kent <Kent.Russell@amd.com><br>
>> Sent: Thursday, August 24, 2017 9:06:22 AM<br>
>> To: Alex Deucher<br>
>> Cc: Christian König; amd-gfx@lists.freedesktop.org<br>
>> Subject: RE: [PATCH] drm/amdgpu: Add sysfs file for VBIOS<br>
>><br>
>> I can definitely add that as well.<br>
>><br>
>> Kent<br>
>><br>
>> -----Original Message-----<br>
>> From: Alex Deucher [<a href="mailto:alexdeucher@gmail.com">mailto:alexdeucher@gmail.com</a>]<br>
>> Sent: Thursday, August 24, 2017 8:56 AM<br>
>> To: Russell, Kent<br>
>> Cc: Christian König; amd-gfx@lists.freedesktop.org<br>
>> Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS<br>
>><br>
>> On Thu, Aug 24, 2017 at 5:58 AM, Russell, Kent <Kent.Russell@amd.com> wrote:<br>
>>> No real reason for sysfs instead of debugfs, I just picked the one that was more familiar with. I can definitely move it to debugfs instead. I will also clean up the commit message per Michel's comments. Thank you!<br>
>>><br>
>> While you are at it, can you expose the vbios binary itself via debugfs? That's been on by todo list for a while.<br>
>><br>
>> Alex<br>
>><br>
>>> Kent<br>
>>><br>
>>> -----Original Message-----<br>
>>> From: Christian König [<a href="mailto:deathsimple@vodafone.de">mailto:deathsimple@vodafone.de</a>]<br>
>>> Sent: Thursday, August 24, 2017 2:22 AM<br>
>>> To: Russell, Kent; amd-gfx@lists.freedesktop.org<br>
>>> Subject: Re: [PATCH] drm/amdgpu: Add sysfs file for VBIOS<br>
>>><br>
>>> Am 23.08.2017 um 20:12 schrieb Kent Russell:<br>
>>>> This won't change after initialization, so we can add the<br>
>>>> information when we parse the atombios information. This ensures<br>
>>>> that we can find out the VBIOS, even when the dmesg buffer fills up,<br>
>>>> and makes it easier to associate which VBIOS is for which GPU on<br>
>>>> mGPU configurations. Set the size to 20 characters in case of some<br>
>>>> weird VBIOS suffix that exceeds the expected 17 character format<br>
>>>> (3-8-3\0)<br>
>>> Is there any reason that needs to be sysfs? Sounds more like an use case for debugfs.<br>
>>><br>
>>> Christian.<br>
>>><br>
>>>> Signed-off-by: Kent Russell <kent.russell@amd.com><br>
>>>> ---<br>
>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++++++++++++++++<br>
>>>> drivers/gpu/drm/amd/amdgpu/atom.c | 5 ++++-<br>
>>>> drivers/gpu/drm/amd/amdgpu/atom.h | 1 +<br>
>>>> 3 files changed, 28 insertions(+), 1 deletion(-)<br>
>>>><br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
>>>> index a1f9424..f40be71 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
>>>> @@ -888,6 +888,20 @@ static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg)<br>
>>>> return r;<br>
>>>> }<br>
>>>><br>
>>>> +static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,<br>
>>>> + struct device_attribute *attr,<br>
>>>> + char *buf) {<br>
>>>> + struct drm_device *ddev = dev_get_drvdata(dev);<br>
>>>> + struct amdgpu_device *adev = ddev->dev_private;<br>
>>>> + struct atom_context *ctx = adev->mode_info.atom_context;<br>
>>>> +<br>
>>>> + return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); }<br>
>>>> +<br>
>>>> +static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,<br>
>>>> + NULL);<br>
>>>> +<br>
>>>> /**<br>
>>>> * amdgpu_atombios_fini - free the driver info and callbacks for atombios<br>
>>>> *<br>
>>>> @@ -907,6 +921,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)<br>
>>>> adev->mode_info.atom_context = NULL;<br>
>>>> kfree(adev->mode_info.atom_card_info);<br>
>>>> adev->mode_info.atom_card_info = NULL;<br>
>>>> + device_remove_file(adev->dev, &dev_attr_vbios_version);<br>
>>>> }<br>
>>>><br>
>>>> /**<br>
>>>> @@ -923,6 +938,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)<br>
>>>> {<br>
>>>> struct card_info *atom_card_info =<br>
>>>> kzalloc(sizeof(struct card_info), GFP_KERNEL);<br>
>>>> + int ret;<br>
>>>><br>
>>>> if (!atom_card_info)<br>
>>>> return -ENOMEM;<br>
>>>> @@ -959,6 +975,13 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev)<br>
>>>> amdgpu_atombios_scratch_regs_init(adev);<br>
>>>> amdgpu_atombios_allocate_fb_scratch(adev);<br>
>>>> }<br>
>>>> +<br>
>>>> + ret = device_create_file(adev->dev, &dev_attr_vbios_version);<br>
>>>> + if (ret) {<br>
>>>> + DRM_ERROR("Failed to create device file for VBIOS version\n");<br>
>>>> + return ret;<br>
>>>> + }<br>
>>>> +<br>
>>>> return 0;<br>
>>>> }<br>
>>>><br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/atom.c<br>
>>>> index d69aa2e..69500a8 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/atom.c<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c<br>
>>>> @@ -1343,8 +1343,11 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)<br>
>>>> idx = 0x80;<br>
>>>><br>
>>>> str = CSTR(idx);<br>
>>>> - if (*str != '\0')<br>
>>>> + if (*str != '\0') {<br>
>>>> pr_info("ATOM BIOS: %s\n", str);<br>
>>>> + strlcpy(ctx->vbios_version, str, sizeof(ctx->vbios_version));<br>
>>>> + }<br>
>>>> +<br>
>>>><br>
>>>> return ctx;<br>
>>>> }<br>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.h<br>
>>>> b/drivers/gpu/drm/amd/amdgpu/atom.h<br>
>>>> index ddd8045..a391709 100644<br>
>>>> --- a/drivers/gpu/drm/amd/amdgpu/atom.h<br>
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/atom.h<br>
>>>> @@ -140,6 +140,7 @@ struct atom_context {<br>
>>>> int io_mode;<br>
>>>> uint32_t *scratch;<br>
>>>> int scratch_size_bytes;<br>
>>>> + char vbios_version[20];<br>
>>>> };<br>
>>>><br>
>>>> extern int amdgpu_atom_debug;<br>
>>><br>
>>> _______________________________________________<br>
>>> amd-gfx mailing list<br>
>>> amd-gfx@lists.freedesktop.org<br>
>>> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
>> _______________________________________________<br>
>> amd-gfx mailing list<br>
>> amd-gfx@lists.freedesktop.org<br>
>> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
> _______________________________________________<br>
> amd-gfx mailing list<br>
> amd-gfx@lists.freedesktop.org<br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
<br>
<br>
</div>
</span></font>
</body>
</html>