From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.4 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MIME_HTML_MOSTLY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B460C433ED for ; Wed, 19 May 2021 03:10:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E0980610CD for ; Wed, 19 May 2021 03:10:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0980610CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=amd-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D3FF6E17A; Wed, 19 May 2021 03:10:55 +0000 (UTC) Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B4EF6E17A for ; Wed, 19 May 2021 03:10:54 +0000 (UTC) Received: by mail-pj1-x102e.google.com with SMTP id o17-20020a17090a9f91b029015cef5b3c50so2700077pjp.4 for ; Tue, 18 May 2021 20:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w4NVfXw7JqZYO1CgbsLhHCmsnyFGdgHAJoBu7AfqlBE=; b=fy/5T/D7vL5XoSLTd5GXlmpydV2QeAVCP/VlvTpILFHaNilnaoE5eFLbxNcPvky7RG lQacXkbmE4OIoPi4bhuHEb/cCE1XGvJFHbw+Lh7ik647pEV377TmU67J9LkD6SqlGW+k smHscdB7LKKjJwUUrfyGFXHfOgUJZ2QLsUWpz/dx4pAaFinQukdOlhg8QmaXI2z40NIJ V+1i59SbWbIziWlNYb/vJ5pFWpcSjZZAsY4Z4WYNY62GxMZc1KDDBSE1hVn8AEHh8xNC AMflmywgfrJoSQu6oNH8FFmZL628pxTfLUCAwh418coLd1a0LvLbyl1yrs5xF0d0iM5e zZuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w4NVfXw7JqZYO1CgbsLhHCmsnyFGdgHAJoBu7AfqlBE=; b=bsANGAa55wWplILt2zxh51Sde4YmhHlbI9jNyqB+/oiXJzrrRYQRiRgDK3FHUouacY 0QJ+pKjqTaX6Qx/5uU067aWNGy3L8uUSle6bx/Ga5Ol+F4p4MgjAL1o43ycToN1R/Owo Kwmh/nlvT43U1vm8oNodijD02mBef807XhQG3kDMkwtw3sfdFJ6km/el1VJSVKwu4fRL vK+VdvG9sC7x9b97Gq3iOE05kq3is1pdQeHZENDyJ60y/gxcnJAakGXiZS7Cerv4Tu0K Qe0lfBEMY+LOY3EuLo/CQLsdahNwanBY3oy74Mdow3OrI1hVPMyelrTTxQa+jO+GC/Fm o3ig== X-Gm-Message-State: AOAM531KdlvtY/ZJbopbL/p5cOSI+ZSAAP/DLFU8uwbYpeX8gsUMuKTs 3HRw8ZDVqXufce9o+A/R7/Y0/AHk3TPcD6x+/Fg= X-Google-Smtp-Source: ABdhPJyvDCbURh6xi0mej3thS9+W1+NwpIbH8wT5ZwvegZDkhEk9+lTIEk9LPa2W1QTw4nRbPGR4IvYVmKjLtZe5lhE= X-Received: by 2002:a17:90a:67c6:: with SMTP id g6mr8720352pjm.198.1621393853629; Tue, 18 May 2021 20:10:53 -0700 (PDT) MIME-Version: 1.0 References: <20210518121628.9811-1-Jiawei.Gu@amd.com> <1ec97d1f-aaa3-46c1-b702-378879e67cc5@amd.com> In-Reply-To: From: =?UTF-8?B?TWFyZWsgT2zFocOhaw==?= Date: Tue, 18 May 2021 23:10:41 -0400 Message-ID: Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface To: "Gu, JiaWei (Will)" X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "StDenis, Tom" , amd-gfx mailing list , "Deng, Emily" , "Deucher, Alexander" , "Koenig, Christian" , "Nieto, David M" Content-Type: multipart/mixed; boundary="===============1723184269==" Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" --===============1723184269== Content-Type: multipart/alternative; boundary="000000000000afc74505c2a62c6b" --000000000000afc74505c2a62c6b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Mesa doesn't have any use for this. It should be ok to expose just the ioctl without userspace because it's just vbios info. Marek On Tue., May 18, 2021, 22:41 Gu, JiaWei (Will), wrote: > [AMD Official Use Only - Internal Distribution Only] > > Thanks Tom's suggestion. > I'm fine to replace ioctl with sysfs. > > Hi all, how about this sysfs alternative? > > And if it's a must to insist on ioctl, is there any Mesa expert to help > provide the patch? > > Best regards, > Jiawei > > > -----Original Message----- > From: StDenis, Tom > Sent: Tuesday, May 18, 2021 9:26 PM > To: Koenig, Christian ; Gu, JiaWei (Will) < > JiaWei.Gu@amd.com>; amd-gfx@lists.freedesktop.org; Nieto, David M < > David.Nieto@amd.com>; maraeo@gmail.com; Deucher, Alexander < > Alexander.Deucher@amd.com> > Cc: Deng, Emily > Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface > > [AMD Official Use Only - Internal Distribution Only] > > If changing the ioctl is an issue why not just use sysfs? umr already > makes uses of all three for it's purposes so it's fine by me for either. > > Tom > > ________________________________________ > From: amd-gfx on behalf of > Christian K=C3=B6nig > Sent: Tuesday, May 18, 2021 09:17 > To: Gu, JiaWei (Will); amd-gfx@lists.freedesktop.org; Nieto, David M; > maraeo@gmail.com; Deucher, Alexander > Cc: Deng, Emily > Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface > > Well not an expert on that stuff, but looks like that should work for me. > > Question is can you provide a patch to use that information in Mesa as > well? Umr might be sufficient as well as justification for upstreaming, b= ut > I want to be better save than sorry. > > Unless Marek has a better idea maybe add the vbios version to the string > returned by GLX_MESA_query_renderer or something like that. > > Thanks, > Christian. > > Am 18.05.21 um 14:19 schrieb Gu, JiaWei (Will): > > [AMD Official Use Only - Internal Distribution Only] > > > > Hi all, > > > > Please help confirm that we're all fine with this new struct in uapi in > this V3 patch: > > > > +struct drm_amdgpu_info_vbios { > > + __u8 name[64]; > > + __u8 vbios_pn[64]; > > + __u32 version; > > + __u8 vbios_ver_str[32]; > > + __u8 date[32]; > > +}; > > > > Best regards, > > Jiawei > > > > -----Original Message----- > > From: Jiawei Gu > > Sent: Tuesday, May 18, 2021 8:16 PM > > To: amd-gfx@lists.freedesktop.org; Koenig, Christian > > ; Nieto, David M ; > > maraeo@gmail.com; Deucher, Alexander > > Cc: Deng, Emily ; Gu, JiaWei (Will) > > > > Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface > > > > Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info. > > > > Provides a way for the user application to get the VBIOS information > without having to parse the binary. > > It is useful for the user to be able to display in a simple way the > VBIOS version in their system if they happen to encounter an issue. > > > > V2: > > Use numeric serial. > > Parse and expose vbios version string. > > > > V3: > > Remove redundant data in drm_amdgpu_info_vbios struct. > > > > Signed-off-by: Jiawei Gu > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 15 ++ > > drivers/gpu/drm/amd/amdgpu/atom.c | 172 ++++++++++++++++++++= + > > drivers/gpu/drm/amd/amdgpu/atom.h | 10 ++ > > drivers/gpu/drm/amd/include/atomfirmware.h | 5 + > > include/uapi/drm/amdgpu_drm.h | 10 ++ > > 5 files changed, 212 insertions(+) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > index 8d12e474745a..524e4fe5efe8 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > @@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void > *data, struct drm_file *filp) > > min((size_t)size, > (size_t)(bios_size - bios_offset))) > > ? -EFAULT : 0; > > } > > + case AMDGPU_INFO_VBIOS_INFO: { > > + struct drm_amdgpu_info_vbios vbios_info =3D {}; > > + struct atom_context *atom_context; > > + > > + atom_context =3D adev->mode_info.atom_context; > > + memcpy(vbios_info.name, atom_context->name, > sizeof(atom_context->name)); > > + memcpy(vbios_info.vbios_pn, > atom_context->vbios_pn, sizeof(atom_context->vbios_pn)); > > + vbios_info.version =3D atom_context->version; > > + memcpy(vbios_info.vbios_ver_str, > atom_context->vbios_ver_str, > > + > sizeof(atom_context->vbios_ver_str)); > > + memcpy(vbios_info.date, atom_context->date, > > +sizeof(atom_context->date)); > > + > > + return copy_to_user(out, &vbios_info, > > + min((size_t)size, > sizeof(vbios_info))) ? -EFAULT : 0; > > + } > > default: > > DRM_DEBUG_KMS("Invalid request %d\n", > > info->vbios_info.type); diff > > --git a/drivers/gpu/drm/amd/amdgpu/atom.c > > b/drivers/gpu/drm/amd/amdgpu/atom.c > > index 3dcb8b32f48b..6fa2229b7229 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/atom.c > > +++ b/drivers/gpu/drm/amd/amdgpu/atom.c > > @@ -31,6 +31,7 @@ > > > > #define ATOM_DEBUG > > > > +#include "atomfirmware.h" > > #include "atom.h" > > #include "atom-names.h" > > #include "atom-bits.h" > > @@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_context > *ctx, int base) > > } > > } > > > > +static void atom_get_vbios_name(struct atom_context *ctx) { > > + unsigned char *p_rom; > > + unsigned char str_num; > > + unsigned short off_to_vbios_str; > > + unsigned char *c_ptr; > > + int name_size; > > + int i; > > + > > + const char *na =3D "--N/A--"; > > + char *back; > > + > > + p_rom =3D ctx->bios; > > + > > + str_num =3D *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS); > > + if (str_num !=3D 0) { > > + off_to_vbios_str =3D > > + *(unsigned short *)(p_rom + > > + OFFSET_TO_GET_ATOMBIOS_STRING_START); > > + > > + c_ptr =3D (unsigned char *)(p_rom + off_to_vbios_str); > > + } else { > > + /* do not know where to find name */ > > + memcpy(ctx->name, na, 7); > > + ctx->name[7] =3D 0; > > + return; > > + } > > + > > + /* > > + * skip the atombios strings, usually 4 > > + * 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th is Memory type > > + */ > > + for (i =3D 0; i < str_num; i++) { > > + while (*c_ptr !=3D 0) > > + c_ptr++; > > + c_ptr++; > > + } > > + > > + /* skip the following 2 chars: 0x0D 0x0A */ > > + c_ptr +=3D 2; > > + > > + name_size =3D strnlen(c_ptr, STRLEN_LONG - 1); > > + memcpy(ctx->name, c_ptr, name_size); > > + back =3D ctx->name + name_size; > > + while ((*--back) =3D=3D ' ') > > + ; > > + *(back + 1) =3D '\0'; > > +} > > + > > +static void atom_get_vbios_date(struct atom_context *ctx) { > > + unsigned char *p_rom; > > + unsigned char *date_in_rom; > > + > > + p_rom =3D ctx->bios; > > + > > + date_in_rom =3D p_rom + OFFSET_TO_VBIOS_DATE; > > + > > + ctx->date[0] =3D '2'; > > + ctx->date[1] =3D '0'; > > + ctx->date[2] =3D date_in_rom[6]; > > + ctx->date[3] =3D date_in_rom[7]; > > + ctx->date[4] =3D '/'; > > + ctx->date[5] =3D date_in_rom[0]; > > + ctx->date[6] =3D date_in_rom[1]; > > + ctx->date[7] =3D '/'; > > + ctx->date[8] =3D date_in_rom[3]; > > + ctx->date[9] =3D date_in_rom[4]; > > + ctx->date[10] =3D ' '; > > + ctx->date[11] =3D date_in_rom[9]; > > + ctx->date[12] =3D date_in_rom[10]; > > + ctx->date[13] =3D date_in_rom[11]; > > + ctx->date[14] =3D date_in_rom[12]; > > + ctx->date[15] =3D date_in_rom[13]; > > + ctx->date[16] =3D '\0'; > > +} > > + > > +static unsigned char *atom_find_str_in_rom(struct atom_context *ctx, > char *str, int start, > > + int end, int maxlen) { > > + unsigned long str_off; > > + unsigned char *p_rom; > > + unsigned short str_len; > > + > > + str_off =3D 0; > > + str_len =3D strnlen(str, maxlen); > > + p_rom =3D ctx->bios; > > + > > + for (; start <=3D end; ++start) { > > + for (str_off =3D 0; str_off < str_len; ++str_off) { > > + if (str[str_off] !=3D *(p_rom + start + str_off)) > > + break; > > + } > > + > > + if (str_off =3D=3D str_len || str[str_off] =3D=3D 0) > > + return p_rom + start; > > + } > > + return NULL; > > +} > > + > > +static void atom_get_vbios_pn(struct atom_context *ctx) { > > + unsigned char *p_rom; > > + unsigned short off_to_vbios_str; > > + unsigned char *vbios_str; > > + int count; > > + > > + off_to_vbios_str =3D 0; > > + p_rom =3D ctx->bios; > > + > > + if (*(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS) !=3D 0) { > > + off_to_vbios_str =3D > > + *(unsigned short *)(p_rom + > > + OFFSET_TO_GET_ATOMBIOS_STRING_START); > > + > > + vbios_str =3D (unsigned char *)(p_rom + off_to_vbios_str)= ; > > + } else { > > + vbios_str =3D p_rom + OFFSET_TO_VBIOS_PART_NUMBER; > > + } > > + > > + if (*vbios_str =3D=3D 0) { > > + vbios_str =3D atom_find_str_in_rom(ctx, BIOS_ATOM_PREFIX,= 3, > 1024, 64); > > + if (vbios_str =3D=3D NULL) > > + vbios_str +=3D sizeof(BIOS_ATOM_PREFIX) - 1; > > + } > > + if (vbios_str !=3D NULL && *vbios_str =3D=3D 0) > > + vbios_str++; > > + > > + if (vbios_str !=3D NULL) { > > + count =3D 0; > > + while ((count < BIOS_STRING_LENGTH) && vbios_str[count] >= =3D > ' ' && > > + vbios_str[count] <=3D 'z') { > > + ctx->vbios_pn[count] =3D vbios_str[count]; > > + count++; > > + } > > + > > + ctx->vbios_pn[count] =3D 0; > > + } > > +} > > + > > +static void atom_get_vbios_version(struct atom_context *ctx) { > > + unsigned char *vbios_ver; > > + > > + /* find anchor ATOMBIOSBK-AMD */ > > + vbios_ver =3D atom_find_str_in_rom(ctx, BIOS_VERSION_PREFIX, 3, > 1024, 64); > > + if (vbios_ver !=3D NULL) { > > + /* skip ATOMBIOSBK-AMD VER */ > > + vbios_ver +=3D 18; > > + memcpy(ctx->vbios_ver_str, vbios_ver, STRLEN_NORMAL); > > + } else { > > + ctx->vbios_ver_str[0] =3D '\0'; > > + } > > +} > > + > > struct atom_context *amdgpu_atom_parse(struct card_info *card, void > *bios) { > > int base; > > struct atom_context *ctx =3D > > kzalloc(sizeof(struct atom_context), GFP_KERNEL); > > char *str; > > + struct _ATOM_ROM_HEADER *atom_rom_header; > > + struct _ATOM_MASTER_DATA_TABLE *master_table; > > + struct _ATOM_FIRMWARE_INFO *atom_fw_info; > > u16 idx; > > > > if (!ctx) > > @@ -1353,6 +1510,21 @@ struct atom_context *amdgpu_atom_parse(struct > card_info *card, void *bios) > > strlcpy(ctx->vbios_version, str, > sizeof(ctx->vbios_version)); > > } > > > > + atom_rom_header =3D (struct _ATOM_ROM_HEADER *)CSTR(base); > > + if (atom_rom_header->usMasterDataTableOffset !=3D 0) { > > + master_table =3D (struct _ATOM_MASTER_DATA_TABLE *) > > + > CSTR(atom_rom_header->usMasterDataTableOffset); > > + if (master_table->ListOfDataTables.FirmwareInfo !=3D 0) { > > + atom_fw_info =3D (struct _ATOM_FIRMWARE_INFO *) > > + > CSTR(master_table->ListOfDataTables.FirmwareInfo); > > + ctx->version =3D atom_fw_info->ulFirmwareRevision= ; > > + } > > + } > > + > > + atom_get_vbios_name(ctx); > > + atom_get_vbios_pn(ctx); > > + atom_get_vbios_date(ctx); > > + atom_get_vbios_version(ctx); > > > > return ctx; > > } > > diff --git a/drivers/gpu/drm/amd/amdgpu/atom.h > > b/drivers/gpu/drm/amd/amdgpu/atom.h > > index d279759cab47..0c1839824520 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/atom.h > > +++ b/drivers/gpu/drm/amd/amdgpu/atom.h > > @@ -112,6 +112,10 @@ struct drm_device; > > #define ATOM_IO_SYSIO 2 > > #define ATOM_IO_IIO 0x80 > > > > +#define STRLEN_NORMAL 32 > > +#define STRLEN_LONG 64 > > +#define STRLEN_VERYLONG 254 > > + > > struct card_info { > > struct drm_device *dev; > > void (* reg_write)(struct card_info *, uint32_t, uint32_t); /* > filled by driver */ > > @@ -140,6 +144,12 @@ struct atom_context { > > uint32_t *scratch; > > int scratch_size_bytes; > > char vbios_version[20]; > > + > > + uint8_t name[STRLEN_LONG]; > > + uint8_t vbios_pn[STRLEN_LONG]; > > + uint32_t version; > > + uint8_t vbios_ver_str[STRLEN_NORMAL]; > > + uint8_t date[STRLEN_NORMAL]; > > }; > > > > extern int amdgpu_atom_debug; > > diff --git a/drivers/gpu/drm/amd/include/atomfirmware.h > > b/drivers/gpu/drm/amd/include/atomfirmware.h > > index 275468e4be60..28deecc2f990 100644 > > --- a/drivers/gpu/drm/amd/include/atomfirmware.h > > +++ b/drivers/gpu/drm/amd/include/atomfirmware.h > > @@ -197,6 +197,9 @@ enum atom_dp_vs_preemph_def{ > > DP_VS_LEVEL0_PREEMPH_LEVEL3 =3D 0x18, > > }; > > > > +#define BIOS_ATOM_PREFIX "ATOMBIOS" > > +#define BIOS_VERSION_PREFIX "ATOMBIOSBK-AMD" > > +#define BIOS_STRING_LENGTH 43 > > > > /* > > enum atom_string_def{ > > @@ -215,6 +218,8 @@ enum atombios_image_offset{ > > MAXSIZE_OF_ATOMBIOS_ASIC_BUS_MEM_TYPE =3D 20, /*including the > terminator 0x0!*/ > > OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS =3D 0x2f, > > OFFSET_TO_GET_ATOMBIOS_STRING_START =3D 0x6e, > > + OFFSET_TO_VBIOS_PART_NUMBER =3D 0x80, > > + OFFSET_TO_VBIOS_DATE =3D 0x50, > > }; > > > > > > /********************************************************************* > > ******* diff --git a/include/uapi/drm/amdgpu_drm.h > > b/include/uapi/drm/amdgpu_drm.h index 9169df7fadee..155fd9918b4d > > 100644 > > --- a/include/uapi/drm/amdgpu_drm.h > > +++ b/include/uapi/drm/amdgpu_drm.h > > @@ -756,6 +756,8 @@ struct drm_amdgpu_cs_chunk_data { > > #define AMDGPU_INFO_VBIOS_SIZE 0x1 > > /* Subquery id: Query vbios image */ > > #define AMDGPU_INFO_VBIOS_IMAGE 0x2 > > + /* Subquery id: Query vbios info */ > > + #define AMDGPU_INFO_VBIOS_INFO 0x3 > > /* Query UVD handles */ > > #define AMDGPU_INFO_NUM_HANDLES 0x1C > > /* Query sensor related information */ @@ -949,6 +951,14 @@ struct > > drm_amdgpu_info_firmware { > > __u32 feature; > > }; > > > > +struct drm_amdgpu_info_vbios { > > + __u8 name[64]; > > + __u8 vbios_pn[64]; > > + __u32 version; > > + __u8 vbios_ver_str[32]; > > + __u8 date[32]; > > +}; > > + > > #define AMDGPU_VRAM_TYPE_UNKNOWN 0 > > #define AMDGPU_VRAM_TYPE_GDDR1 1 > > #define AMDGPU_VRAM_TYPE_DDR2 2 > > -- > > 2.17.1 > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > > https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flists= .freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=3D04%7C01%7Ctom.st= denis%40amd.com%7C332524597a5e42ad491908d919ff414f%7C3dd8961fe4884e608e11a8= 2d994e183d%7C0%7C0%7C637569406377960645%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4= wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3D= ZFBUbqu1VjvQkpnQ4Wy6Q4XE9CB2IcFltOq3Iv12F7U%3D&reserved=3D0 > --000000000000afc74505c2a62c6b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Mesa doesn't have any use for this. It should be ok t= o expose just the ioctl without userspace because it's just vbios info.=

Marek

On Tue., May 18, 2= 021, 22:41 Gu, JiaWei (Will), <JiaW= ei.Gu@amd.com> wrote:
[AMD O= fficial Use Only - Internal Distribution Only]

Thanks Tom's suggestion.
I'm fine to replace ioctl with sysfs.

Hi all, how about this sysfs alternative?

And if it's a must to insist on ioctl, is there any Mesa expert to help= provide the patch?

Best regards,
Jiawei


-----Original Message-----
From: StDenis, Tom <Tom.StDenis@amd.com>
Sent: Tuesday, May 18, 2021 9:26 PM
To: Koenig, Christian <Christian.Koenig@amd.com>; Gu, JiaWe= i (Will) <JiaWei.Gu@amd.com>; amd-gfx@lists.freedesktop= .org; Nieto, David M <David.Nieto@amd.com>; maraeo@gmail.com<= /a>; Deucher, Alexander <Alexander.Deucher@amd.com>
Cc: Deng, Emily <Emily.Deng@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

[AMD Official Use Only - Internal Distribution Only]

If changing the ioctl is an issue why not just use sysfs?=C2=A0 umr already= makes uses of all three for it's purposes so it's fine by me for e= ither.

Tom

________________________________________
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org<= /a>> on behalf of Christian K=C3=B6nig <christian.koenig@amd.co= m>
Sent: Tuesday, May 18, 2021 09:17
To: Gu, JiaWei (Will); amd-gfx@lists.freedesktop.org; Nieto,= David M; maraeo@gmail.com; Deucher, Alexander
Cc: Deng, Emily
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

Well not an expert on that stuff, but looks like that should work for me.
Question is can you provide a patch to use that information in Mesa as well= ? Umr might be sufficient as well as justification for upstreaming, but I w= ant to be better save than sorry.

Unless Marek has a better idea maybe add the vbios version to the string re= turned by GLX_MESA_query_renderer or something like that.

Thanks,
Christian.

Am 18.05.21 um 14:19 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Please help confirm that we're all fine with this new struct in ua= pi in this V3 patch:
>
> +struct drm_amdgpu_info_vbios {
> +=C2=A0 =C2=A0 =C2=A0__u8 name[64];
> +=C2=A0 =C2=A0 =C2=A0__u8 vbios_pn[64];
> +=C2=A0 =C2=A0 =C2=A0__u32 version;
> +=C2=A0 =C2=A0 =C2=A0__u8 vbios_ver_str[32];
> +=C2=A0 =C2=A0 =C2=A0__u8 date[32];
> +};
>
> Best regards,
> Jiawei
>
> -----Original Message-----
> From: Jiawei Gu <Jiawei.Gu@amd.com>
> Sent: Tuesday, May 18, 2021 8:16 PM
> To: amd-gfx@lists.freedesktop.org; Koenig, Christian > <Christian.Koenig@amd.com>; Nieto, David M <David= .Nieto@amd.com>;
> maraeo@gmail.com; Deucher, Alexander <Alexander.Deucher@am= d.com>
> Cc: Deng, Emily <Emily.Deng@amd.com>; Gu, JiaWei (Will)
> <JiaWei.Gu@amd.com>
> Subject: [PATCH] drm/amdgpu: Add vbios info ioctl interface
>
> Add AMDGPU_INFO_VBIOS_INFO subquery id for detailed vbios info.
>
> Provides a way for the user application to get the VBIOS information w= ithout having to parse the binary.
> It is useful for the user to be able to display in a simple way the VB= IOS version in their system if they happen to encounter an issue.
>
> V2:
> Use numeric serial.
> Parse and expose vbios version string.
>
> V3:
> Remove redundant data in drm_amdgpu_info_vbios struct.
>
> Signed-off-by: Jiawei Gu <Jiawei.Gu@amd.com>
> ---
>=C2=A0 =C2=A0drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c=C2=A0 =C2=A0 |=C2= =A0 15 ++
>=C2=A0 =C2=A0drivers/gpu/drm/amd/amdgpu/atom.c=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 | 172 +++++++++++++++++++++
>=C2=A0 =C2=A0drivers/gpu/drm/amd/amdgpu/atom.h=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 |=C2=A0 10 ++
>=C2=A0 =C2=A0drivers/gpu/drm/amd/include/atomfirmware.h |=C2=A0 =C2=A05= +
>=C2=A0 =C2=A0include/uapi/drm/amdgpu_drm.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 |=C2=A0 10 ++
>=C2=A0 =C2=A05 files changed, 212 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 8d12e474745a..524e4fe5efe8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -861,6 +861,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, voi= d *data, struct drm_file *filp)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0min((size_t)size, (size_t)(bios_size - bios_offset)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0? -EFA= ULT : 0;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0case AMDGPU_INFO_VBIO= S_INFO: {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0struct drm_amdgpu_info_vbios vbios_info =3D {};
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0struct atom_context *atom_context;
> +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0atom_context =3D adev->mode_info.atom_context;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0memcpy(vbios_info.name, atom_context->name, sizeof(at= om_context->name));
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, sizeof(atom_c= ontext->vbios_pn));
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0vbios_info.version =3D atom_context->version;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0sizeof(atom_context->vbios_ver_str));
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0memcpy(vbios_info.date, atom_context->date,
> +sizeof(atom_context->date));
> +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0return copy_to_user(out, &vbios_info,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0min((size_t)size, sizeof(vbios_info))) ? -EFAULT : 0;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0default:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0DRM_DEBUG_KMS("Invalid request %d\n",
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0info-&= gt;vbios_info.type); diff
> --git a/drivers/gpu/drm/amd/amdgpu/atom.c
> b/drivers/gpu/drm/amd/amdgpu/atom.c
> index 3dcb8b32f48b..6fa2229b7229 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -31,6 +31,7 @@
>
>=C2=A0 =C2=A0#define ATOM_DEBUG
>
> +#include "atomfirmware.h"
>=C2=A0 =C2=A0#include "atom.h"
>=C2=A0 =C2=A0#include "atom-names.h"
>=C2=A0 =C2=A0#include "atom-bits.h"
> @@ -1299,12 +1300,168 @@ static void atom_index_iio(struct atom_contex= t *ctx, int base)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0}
>
> +static void atom_get_vbios_name(struct atom_context *ctx) {
> +=C2=A0 =C2=A0 =C2=A0unsigned char *p_rom;
> +=C2=A0 =C2=A0 =C2=A0unsigned char str_num;
> +=C2=A0 =C2=A0 =C2=A0unsigned short off_to_vbios_str;
> +=C2=A0 =C2=A0 =C2=A0unsigned char *c_ptr;
> +=C2=A0 =C2=A0 =C2=A0int name_size;
> +=C2=A0 =C2=A0 =C2=A0int i;
> +
> +=C2=A0 =C2=A0 =C2=A0const char *na =3D "--N/A--";
> +=C2=A0 =C2=A0 =C2=A0char *back;
> +
> +=C2=A0 =C2=A0 =C2=A0p_rom =3D ctx->bios;
> +
> +=C2=A0 =C2=A0 =C2=A0str_num =3D *(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMB= ER_OF_STRINGS);
> +=C2=A0 =C2=A0 =C2=A0if (str_num !=3D 0) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0off_to_vbios_str =3D<= br> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0*(unsigned short *)(p_rom +
> + OFFSET_TO_GET_ATOMBIOS_STRING_START);
> +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0c_ptr =3D (unsigned c= har *)(p_rom + off_to_vbios_str);
> +=C2=A0 =C2=A0 =C2=A0} else {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* do not know where = to find name */
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memcpy(ctx->name, = na, 7);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ctx->name[7] =3D 0= ;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return;
> +=C2=A0 =C2=A0 =C2=A0}
> +
> +=C2=A0 =C2=A0 =C2=A0/*
> +=C2=A0 =C2=A0 =C2=A0 * skip the atombios strings, usually 4
> +=C2=A0 =C2=A0 =C2=A0 * 1st is P/N, 2nd is ASIC, 3rd is PCI type, 4th = is Memory type
> +=C2=A0 =C2=A0 =C2=A0 */
> +=C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < str_num; i++) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0while (*c_ptr !=3D 0)=
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0c_ptr++;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0c_ptr++;
> +=C2=A0 =C2=A0 =C2=A0}
> +
> +=C2=A0 =C2=A0 =C2=A0/* skip the following 2 chars: 0x0D 0x0A */
> +=C2=A0 =C2=A0 =C2=A0c_ptr +=3D 2;
> +
> +=C2=A0 =C2=A0 =C2=A0name_size =3D strnlen(c_ptr, STRLEN_LONG - 1); > +=C2=A0 =C2=A0 =C2=A0memcpy(ctx->name, c_ptr, name_size);
> +=C2=A0 =C2=A0 =C2=A0back =3D ctx->name + name_size;
> +=C2=A0 =C2=A0 =C2=A0while ((*--back) =3D=3D ' ')
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;
> +=C2=A0 =C2=A0 =C2=A0*(back + 1) =3D '\0';
> +}
> +
> +static void atom_get_vbios_date(struct atom_context *ctx) {
> +=C2=A0 =C2=A0 =C2=A0unsigned char *p_rom;
> +=C2=A0 =C2=A0 =C2=A0unsigned char *date_in_rom;
> +
> +=C2=A0 =C2=A0 =C2=A0p_rom =3D ctx->bios;
> +
> +=C2=A0 =C2=A0 =C2=A0date_in_rom =3D p_rom + OFFSET_TO_VBIOS_DATE;
> +
> +=C2=A0 =C2=A0 =C2=A0ctx->date[0] =3D '2';
> +=C2=A0 =C2=A0 =C2=A0ctx->date[1] =3D '0';
> +=C2=A0 =C2=A0 =C2=A0ctx->date[2] =3D date_in_rom[6];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[3] =3D date_in_rom[7];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[4] =3D '/';
> +=C2=A0 =C2=A0 =C2=A0ctx->date[5] =3D date_in_rom[0];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[6] =3D date_in_rom[1];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[7] =3D '/';
> +=C2=A0 =C2=A0 =C2=A0ctx->date[8] =3D date_in_rom[3];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[9] =3D date_in_rom[4];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[10] =3D ' ';
> +=C2=A0 =C2=A0 =C2=A0ctx->date[11] =3D date_in_rom[9];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[12] =3D date_in_rom[10];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[13] =3D date_in_rom[11];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[14] =3D date_in_rom[12];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[15] =3D date_in_rom[13];
> +=C2=A0 =C2=A0 =C2=A0ctx->date[16] =3D '\0';
> +}
> +
> +static unsigned char *atom_find_str_in_rom(struct atom_context *ctx, = char *str, int start,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 int = end, int maxlen) {
> +=C2=A0 =C2=A0 =C2=A0unsigned long str_off;
> +=C2=A0 =C2=A0 =C2=A0unsigned char *p_rom;
> +=C2=A0 =C2=A0 =C2=A0unsigned short str_len;
> +
> +=C2=A0 =C2=A0 =C2=A0str_off =3D 0;
> +=C2=A0 =C2=A0 =C2=A0str_len =3D strnlen(str, maxlen);
> +=C2=A0 =C2=A0 =C2=A0p_rom =3D ctx->bios;
> +
> +=C2=A0 =C2=A0 =C2=A0for (; start <=3D end; ++start) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for (str_off =3D 0; s= tr_off < str_len; ++str_off) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0if (str[str_off] !=3D *(p_rom + start + str_off))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (str_off =3D=3D st= r_len || str[str_off] =3D=3D 0)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0return p_rom + start;
> +=C2=A0 =C2=A0 =C2=A0}
> +=C2=A0 =C2=A0 =C2=A0return NULL;
> +}
> +
> +static void atom_get_vbios_pn(struct atom_context *ctx) {
> +=C2=A0 =C2=A0 =C2=A0unsigned char *p_rom;
> +=C2=A0 =C2=A0 =C2=A0unsigned short off_to_vbios_str;
> +=C2=A0 =C2=A0 =C2=A0unsigned char *vbios_str;
> +=C2=A0 =C2=A0 =C2=A0int count;
> +
> +=C2=A0 =C2=A0 =C2=A0off_to_vbios_str =3D 0;
> +=C2=A0 =C2=A0 =C2=A0p_rom =3D ctx->bios;
> +
> +=C2=A0 =C2=A0 =C2=A0if (*(p_rom + OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_ST= RINGS) !=3D 0) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0off_to_vbios_str =3D<= br> > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0*(unsigned short *)(p_rom +
> + OFFSET_TO_GET_ATOMBIOS_STRING_START);
> +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vbios_str =3D (unsign= ed char *)(p_rom + off_to_vbios_str);
> +=C2=A0 =C2=A0 =C2=A0} else {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vbios_str =3D p_rom += OFFSET_TO_VBIOS_PART_NUMBER;
> +=C2=A0 =C2=A0 =C2=A0}
> +
> +=C2=A0 =C2=A0 =C2=A0if (*vbios_str =3D=3D 0) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vbios_str =3D atom_fi= nd_str_in_rom(ctx, BIOS_ATOM_PREFIX, 3, 1024, 64);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (vbios_str =3D=3D = NULL)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0vbios_str +=3D sizeof(BIOS_ATOM_PREFIX) - 1;
> +=C2=A0 =C2=A0 =C2=A0}
> +=C2=A0 =C2=A0 =C2=A0if (vbios_str !=3D NULL && *vbios_str =3D= =3D 0)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vbios_str++;
> +
> +=C2=A0 =C2=A0 =C2=A0if (vbios_str !=3D NULL) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0count =3D 0;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0while ((count < BI= OS_STRING_LENGTH) && vbios_str[count] >=3D ' ' &&= ;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= vbios_str[count] <=3D 'z') {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0ctx->vbios_pn[count] =3D vbios_str[count];
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0count++;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ctx->vbios_pn[coun= t] =3D 0;
> +=C2=A0 =C2=A0 =C2=A0}
> +}
> +
> +static void atom_get_vbios_version(struct atom_context *ctx) {
> +=C2=A0 =C2=A0 =C2=A0unsigned char *vbios_ver;
> +
> +=C2=A0 =C2=A0 =C2=A0/* find anchor ATOMBIOSBK-AMD */
> +=C2=A0 =C2=A0 =C2=A0vbios_ver =3D atom_find_str_in_rom(ctx, BIOS_VERS= ION_PREFIX, 3, 1024, 64);
> +=C2=A0 =C2=A0 =C2=A0if (vbios_ver !=3D NULL) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* skip ATOMBIOSBK-AM= D VER */
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vbios_ver +=3D 18; > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0memcpy(ctx->vbios_= ver_str, vbios_ver, STRLEN_NORMAL);
> +=C2=A0 =C2=A0 =C2=A0} else {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ctx->vbios_ver_str= [0] =3D '\0';
> +=C2=A0 =C2=A0 =C2=A0}
> +}
> +
>=C2=A0 =C2=A0struct atom_context *amdgpu_atom_parse(struct card_info *c= ard, void *bios)=C2=A0 {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0int base;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0struct atom_context *ctx =3D
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0kzalloc(sizeof(struct atom_con= text), GFP_KERNEL);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0char *str;
> +=C2=A0 =C2=A0 =C2=A0struct _ATOM_ROM_HEADER *atom_rom_header;
> +=C2=A0 =C2=A0 =C2=A0struct _ATOM_MASTER_DATA_TABLE *master_table;
> +=C2=A0 =C2=A0 =C2=A0struct _ATOM_FIRMWARE_INFO *atom_fw_info;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0u16 idx;
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!ctx)
> @@ -1353,6 +1510,21 @@ struct atom_context *amdgpu_atom_parse(struct c= ard_info *card, void *bios)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0strlcpy(ctx->= vbios_version, str, sizeof(ctx->vbios_version));
>=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>
> +=C2=A0 =C2=A0 =C2=A0atom_rom_header =3D (struct _ATOM_ROM_HEADER *)CS= TR(base);
> +=C2=A0 =C2=A0 =C2=A0if (atom_rom_header->usMasterDataTableOffset != =3D 0) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0master_table =3D (str= uct _ATOM_MASTER_DATA_TABLE *)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CSTR(atom_rom_header->usMasterDataTab= leOffset);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (master_table->= ListOfDataTables.FirmwareInfo !=3D 0) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0atom_fw_info =3D (struct _ATOM_FIRMWARE_INFO *)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CSTR(master_= table->ListOfDataTables.FirmwareInfo);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0ctx->version =3D atom_fw_info->ulFirmwareRevision;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> +=C2=A0 =C2=A0 =C2=A0}
> +
> +=C2=A0 =C2=A0 =C2=A0atom_get_vbios_name(ctx);
> +=C2=A0 =C2=A0 =C2=A0atom_get_vbios_pn(ctx);
> +=C2=A0 =C2=A0 =C2=A0atom_get_vbios_date(ctx);
> +=C2=A0 =C2=A0 =C2=A0atom_get_vbios_version(ctx);
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0return ctx;
>=C2=A0 =C2=A0}
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.h
> b/drivers/gpu/drm/amd/amdgpu/atom.h
> index d279759cab47..0c1839824520 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.h
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.h
> @@ -112,6 +112,10 @@ struct drm_device;
>=C2=A0 =C2=A0#define ATOM_IO_SYSIO=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A02
>=C2=A0 =C2=A0#define ATOM_IO_IIO=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x80<= br> >
> +#define STRLEN_NORMAL=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 32
> +#define STRLEN_LONG=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 64
> +#define STRLEN_VERYLONG=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 254
> +
>=C2=A0 =C2=A0struct card_info {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0struct drm_device *dev;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0void (* reg_write)(struct card_info *, uint3= 2_t, uint32_t);=C2=A0 =C2=A0/*=C2=A0 filled by driver */
> @@ -140,6 +144,12 @@ struct atom_context {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0uint32_t *scratch;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0int scratch_size_bytes;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0char vbios_version[20];
> +
> +=C2=A0 =C2=A0 =C2=A0uint8_t name[STRLEN_LONG];
> +=C2=A0 =C2=A0 =C2=A0uint8_t vbios_pn[STRLEN_LONG];
> +=C2=A0 =C2=A0 =C2=A0uint32_t version;
> +=C2=A0 =C2=A0 =C2=A0uint8_t vbios_ver_str[STRLEN_NORMAL];
> +=C2=A0 =C2=A0 =C2=A0uint8_t date[STRLEN_NORMAL];
>=C2=A0 =C2=A0};
>
>=C2=A0 =C2=A0extern int amdgpu_atom_debug;
> diff --git a/drivers/gpu/drm/amd/include/atomfirmware.h
> b/drivers/gpu/drm/amd/include/atomfirmware.h
> index 275468e4be60..28deecc2f990 100644
> --- a/drivers/gpu/drm/amd/include/atomfirmware.h
> +++ b/drivers/gpu/drm/amd/include/atomfirmware.h
> @@ -197,6 +197,9 @@ enum atom_dp_vs_preemph_def{
>=C2=A0 =C2=A0 =C2=A0DP_VS_LEVEL0_PREEMPH_LEVEL3 =3D 0x18,
>=C2=A0 =C2=A0};
>
> +#define BIOS_ATOM_PREFIX=C2=A0 =C2=A0"ATOMBIOS"
> +#define BIOS_VERSION_PREFIX=C2=A0 "ATOMBIOSBK-AMD"
> +#define BIOS_STRING_LENGTH 43
>
>=C2=A0 =C2=A0/*
>=C2=A0 =C2=A0enum atom_string_def{
> @@ -215,6 +218,8 @@ enum atombios_image_offset{
>=C2=A0 =C2=A0 =C2=A0MAXSIZE_OF_ATOMBIOS_ASIC_BUS_MEM_TYPE=C2=A0 =C2=A0 = =C2=A0 =3D 20,=C2=A0 /*including the terminator 0x0!*/
>=C2=A0 =C2=A0 =C2=A0OFFSET_TO_GET_ATOMBIOS_NUMBER_OF_STRINGS=C2=A0 =C2= =A0=3D 0x2f,
>=C2=A0 =C2=A0 =C2=A0OFFSET_TO_GET_ATOMBIOS_STRING_START=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =3D 0x6e,
> +=C2=A0 OFFSET_TO_VBIOS_PART_NUMBER=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =3D 0x80,
> +=C2=A0 OFFSET_TO_VBIOS_DATE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x50,
>=C2=A0 =C2=A0};
>
>=C2=A0 =C2=A0
> /*********************************************************************=
> ******* diff --git a/include/uapi/drm/amdgpu_drm.h
> b/include/uapi/drm/amdgpu_drm.h index 9169df7fadee..155fd9918b4d
> 100644
> --- a/include/uapi/drm/amdgpu_drm.h
> +++ b/include/uapi/drm/amdgpu_drm.h
> @@ -756,6 +756,8 @@ struct drm_amdgpu_cs_chunk_data {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0#define AMDGPU_INFO_VBIOS_SIZE=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 0x1
>=C2=A0 =C2=A0 =C2=A0 =C2=A0/* Subquery id: Query vbios image */
>=C2=A0 =C2=A0 =C2=A0 =C2=A0#define AMDGPU_INFO_VBIOS_IMAGE=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A00x2
> +=C2=A0 =C2=A0 =C2=A0/* Subquery id: Query vbios info */
> +=C2=A0 =C2=A0 =C2=A0#define AMDGPU_INFO_VBIOS_INFO=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 0x3
>=C2=A0 =C2=A0/* Query UVD handles */
>=C2=A0 =C2=A0#define AMDGPU_INFO_NUM_HANDLES=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x1C
>=C2=A0 =C2=A0/* Query sensor related information */ @@ -949,6 +951,14 @= @ struct
> drm_amdgpu_info_firmware {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0__u32 feature;
>=C2=A0 =C2=A0};
>
> +struct drm_amdgpu_info_vbios {
> +=C2=A0 =C2=A0 =C2=A0__u8 name[64];
> +=C2=A0 =C2=A0 =C2=A0__u8 vbios_pn[64];
> +=C2=A0 =C2=A0 =C2=A0__u32 version;
> +=C2=A0 =C2=A0 =C2=A0__u8 vbios_ver_str[32];
> +=C2=A0 =C2=A0 =C2=A0__u8 date[32];
> +};
> +
>=C2=A0 =C2=A0#define AMDGPU_VRAM_TYPE_UNKNOWN 0
>=C2=A0 =C2=A0#define AMDGPU_VRAM_TYPE_GDDR1 1
>=C2=A0 =C2=A0#define AMDGPU_VRAM_TYPE_DDR2=C2=A0 2
> --
> 2.17.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.sa= felinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flists.freedesktop.org%2= Fmailman%2Flistinfo%2Famd-gfx&amp;data=3D04%7C01%7Ctom.stdenis%40amd.co= m%7C332524597a5e42ad491908d919ff414f%7C3dd8961fe4884e608e11a82d994e183d%7C0= %7C0%7C637569406377960645%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQI= joiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=3DZFBUbqu1Vj= vQkpnQ4Wy6Q4XE9CB2IcFltOq3Iv12F7U%3D&amp;reserved=3D0
--000000000000afc74505c2a62c6b-- --===============1723184269== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx --===============1723184269==--