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=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_HTML_MOSTLY,PDS_BAD_THREAD_QP_64, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 96AF3C433ED for ; Tue, 18 May 2021 04:40:36 +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 2D002610E9 for ; Tue, 18 May 2021 04:40:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D002610E9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amd.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 69D5A6E5D3; Tue, 18 May 2021 04:40:34 +0000 (UTC) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE70F6E5CC for ; Tue, 18 May 2021 04:40:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oRPv47csKfehVro2r7b45FBY+vTovc9O8Y5qmRXkCfA4vdd7RYG2g4fwX4yYH8FgWSpyxrQ2fSWddTNGrWV6C0jYnU2K4UpE6hDGfHGcMSB7Yx+O/SVdaX20lDq8+wrxWbsFJ9HhtYDiW8Qkh/iBDUtVieRqOVORoUZXcBH7BRPLjRETNcZh9Wd4grMLqpSwLXycD3aZMgok03hE/ymuYkEdfyKrdhUIS9XiH5p0pwaPFkFajOn188Z7ugeWzDCbx3i7cCduTjb0tLereRXAw+mGSp1mb0gWxfhPr55R0Zl51mfdkqMYn8GL7voofHEfyBZM7T5nXU9/20pc5bq1Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wP1g9+FGw2THk6ZionHYy//JrUno3EwMGrVqeU2nFVI=; b=QNGHvyVT8nCighCTQe09zQtr1zkwSoCL3u+u08ltXY3QCIgibJ5AQ9gAgfrNH4uV0CAJYmWkF8pQh4BscqnhM1lteSWdToerayTQgCy241aohNo4Ndjsp+4g+eMGkyMHHNXM2E3OCFJa9FzIZ5xREeHwK+6Ku8b9wfCTkLHKMmxR00bSpDiRFTr2TNQOSQEfa3laDQBwkqaod+dQrnt0+gZTLcACQbxeTto4gy+cbPSwGvW13JvNjNnMchvTcAkl6WkK0X3QdbOTajaOCx5hIU52hys7Yru8ajYWD3GW/K26hJCdPNYucnp2gZG5EBDqZ78E5OkGtHQScWYI7qEWVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wP1g9+FGw2THk6ZionHYy//JrUno3EwMGrVqeU2nFVI=; b=HD8umutCePz2i/97I1nML/gTVzMP45lxAxr2IoZcfK6h601pHUIhHabYbvA0PSHPIi8abgfdlTvgDs5jmmr6LEIP0SGEaswus5D84XQX4L0xRyOI3lcNNDXkL5oTgpefL5RQWiGnyPrEQ2TtJOkC+47wwNXncKfXEpmEcDYA5vg= Received: from BYAPR12MB2840.namprd12.prod.outlook.com (2603:10b6:a03:62::32) by BYAPR12MB4695.namprd12.prod.outlook.com (2603:10b6:a03:a4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Tue, 18 May 2021 04:40:26 +0000 Received: from BYAPR12MB2840.namprd12.prod.outlook.com ([fe80::7c65:7181:6d1d:8616]) by BYAPR12MB2840.namprd12.prod.outlook.com ([fe80::7c65:7181:6d1d:8616%7]) with mapi id 15.20.4129.031; Tue, 18 May 2021 04:40:26 +0000 From: "Nieto, David M" To: "Gu, JiaWei (Will)" , "Koenig, Christian" , "amd-gfx@lists.freedesktop.org" , "maraeo@gmail.com" , "Deucher, Alexander" Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface Thread-Topic: [PATCH] drm/amdgpu: Add vbios info ioctl interface Thread-Index: AQHXSxVPBvM50M0wZkSTUB4XlW18fKrnlu0AgAACYYCAAObDgIAACKsHgAAHFACAABmoHQ== Date: Tue, 18 May 2021 04:40:26 +0000 Message-ID: References: <20210517120804.27052-1-Jiawei.Gu@amd.com> <51161d6d-a6be-90f0-262d-5215402e25dd@amd.com>, , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Enabled=True; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_SetDate=2021-05-18T04:40:25.624Z; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Name=Public; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_ContentBits=0; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Method=Privileged; authentication-results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; x-originating-ip: [165.204.53.104] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a2a0a63e-b474-4993-d2be-08d919b70e90 x-ms-traffictypediagnostic: BYAPR12MB4695: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pIudc/3ETn03J6vthtLvmdwfKf+pYNTOFkr30uDtdRD4j0rZ/Q9i8B6EdXJGSpxDIVxIqpcbmtmqnMnZQsoJzmfsLxzWggPRLTOfd2oz8usCPs3onWZkcXCbbVPLiAO+mcIr8xvHVXaoGGmNGd3S3KzpyjRXsoE1detADZjLotxrakc6MO6XYOo9inH2X31FlJVtJOC6gXJMACtM/JSp1DCNKZoy3H1m7lEwhHNXiDHRvCrDnmZmOb1AjWkJlA3Rovsqmr95/M26UcoqcMprWRyI28qIUtJDZ+4jfOYR7KMP5KQ87TQPJZJH8nsuBb0wC6nzeGVfrWJeKxaCt1l/HP/mcujsvOxOcZr2EhClhCAxunmouUKTHT2u/A0colAOYj/rkiEb0MZBN2V7F8IHRDptanC8Urgz2aVJB0gHnf+yFs/DTd1ziJmg3NwufVx/zcW/QNED5Z8OAaersaSCIr7qT6OiJiDpDU2gedVHlukLyI730cVUfBP24uS5Fdztpldm2U6cR0L9GV0BGqmKrH1HpEVnuXQx+QRLhmjz0ZjGp1nmvlqGmSY3ig8r41rFgCDJkpcZVLihzAlCSdRGsUEchA9kA8e/0mBAfdiSxog= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR12MB2840.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(346002)(366004)(39860400002)(136003)(478600001)(38100700002)(7696005)(83380400001)(6636002)(5660300002)(30864003)(52536014)(4326008)(71200400001)(26005)(66446008)(64756008)(66556008)(122000001)(6506007)(53546011)(66946007)(186003)(66476007)(76116006)(8676002)(86362001)(19627405001)(8936002)(19627235002)(33656002)(110136005)(2906002)(55016002)(9686003)(316002)(66574015); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?Windows-1252?Q?3vRMwIkOSFx8vYvev/q0+vv/cACUw4aXKGfcTczEFdxeybcJzqHWXXls?= =?Windows-1252?Q?1UoprjYmTN+YFCELnC6sctUkZGl7YwWL20H/080wb8vSfMzzuEILIZF2?= =?Windows-1252?Q?Dwn5YvQNRwr6xptVF0vMBc4xxNM7XmlxZkZbGoeIMc7Ke4t2E+wFSSW3?= =?Windows-1252?Q?EosW6CfcQQcyjMh8kZ85DnIqxqW9n/772dStBwFF8ZkfsPZgl1spwdc4?= =?Windows-1252?Q?tNcY7sQCEDIa07DFhQrt/3W70Fz2ha/zAkEkhoxfjgLqRqPNzzY4c1e2?= =?Windows-1252?Q?1stmLBPrICSFlRxIsS1bE/0CNsoQ70Ebkzxrze3Ydg8CiJDipmp5vZds?= =?Windows-1252?Q?SpdCtRcqh2cJ6dCepG+cuSwhQ0QFH2EHZvZLhdRnPgo4rxeAn/HM1kOq?= =?Windows-1252?Q?nsunuXcden5894eqjeNDFry8eF/teDi9wzfytD5rf+lZ0oLMglH8KPfK?= =?Windows-1252?Q?29hgzueWrmc77lA56sd4hKaIm2r2m1FoBNK2fcAaFa15fNbPbLTTb/cY?= =?Windows-1252?Q?4jrDlUEdIvhfqmqb32JFCDoGG/0VR0+YR4QRkZeMtva32pmVUUWcz48C?= =?Windows-1252?Q?d7rTcMWbG9pNiIWBczNs5EzVu6IQj8HASVV+znS+2A4qgVolBQRd78I7?= =?Windows-1252?Q?B/MWE0hZjluHOxuyBI6zdgBu8FBSIbYN96KqsR+PtpbUMy5KrCRzN9jB?= =?Windows-1252?Q?SRuHq8f0ejKeV9wVU21G90pRkDNc5MXfqRTKhTKeQ2+IYHyQMn7jvrqB?= =?Windows-1252?Q?t4p0pb1B/cYL4Lj+gfvGyS741pV58RqIAeDwjZc/PmUNM5mtIvwzL4RA?= =?Windows-1252?Q?mUwGXJGmEOPaVtzFWrPVlU51Kh98RecdBjrvPy26MUMc+Nc9M5mifFUi?= =?Windows-1252?Q?aMNuHmLFEYbxHmVVQPVze5Dt/226zzpsIph89/vDqhc4iPRD8xZRf7zx?= =?Windows-1252?Q?xVEciUjO/9PslTfpeOK2hggzgku75k8wtbX4ZfcF9MGkSzz0uCFocqCX?= =?Windows-1252?Q?useW5RIiZZhTfGnq+jY4z3VO4g+r/nz0gqOz4Iomjq4BPx0siwtBhlQd?= =?Windows-1252?Q?SQxVzM+9RbKeGc2TTyR373Bv0Pk0yi1k1eJZvrB1ya4m/6uvqBu6uf8g?= =?Windows-1252?Q?dGGEyjshd06Cvl8fwX4WF091OWeiF/fG0kK+kXNpuh2TyLbsJhtmNscD?= =?Windows-1252?Q?VQGhUn9AKEpOoYr802zhwi8gYcppw309zsX0jXU/5T8XCgiUN9I9VfWQ?= =?Windows-1252?Q?3IP13OFZ4WefcnAW0OBMVG8Lq3oWI0uVgk61IlsSY8hWL1d30stg/d/0?= =?Windows-1252?Q?dtY15F/NFvqpewryXnhwnsmhzJoB/Nmi9Yt6mIC2w2zj2iQJVaiCBMvb?= =?Windows-1252?Q?6YjJf6A/BbrH843STtLZG7c0j6padaadvCJL6SYn943CzvmWlwPONqp5?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2840.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2a0a63e-b474-4993-d2be-08d919b70e90 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 May 2021 04:40:26.1458 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Q2svj+lU71BpP54OSdXF9NGLhX0t3VAhkQjd8b78dBAhsTv3o0+Mgt7qNqELa8Lo X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4695 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: "Deng, Emily" Content-Type: multipart/mixed; boundary="===============1722405634==" Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" --===============1722405634== Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_BYAPR12MB284005A19E99B1D7AC43ABE5F42C9BYAPR12MB2840namp_" --_000_BYAPR12MB284005A19E99B1D7AC43ABE5F42C9BYAPR12MB2840namp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable [Public] Yes, let's remove that too, Thanks, David ________________________________ From: Gu, JiaWei (Will) Sent: Monday, May 17, 2021 8:07 PM To: Nieto, David M ; Koenig, Christian ; amd-gfx@lists.freedesktop.org ;= maraeo@gmail.com ; Deucher, Alexander Cc: Deng, Emily Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface [AMD Official Use Only - Internal Distribution Only] OK let=92s remove serial. dbdf comes from this: vbios_info.dbdf =3D PCI_DEVID(adev->pdev->bus->number, adev->pdev->devfn); I think we can remove dbdf as well. Best regards, Jiawei From: Nieto, David M Sent: Tuesday, May 18, 2021 10:45 AM To: Gu, JiaWei (Will) ; Koenig, Christian ; amd-gfx@lists.freedesktop.org; maraeo@gmail.com; Deucher, Ale= xander Cc: Deng, Emily Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface [AMD Official Use Only - Internal Distribution Only] The serial number is ASIC information, not VBIOS information, and it is sti= ll available as a sysfs node... I don't think we should put it there. Not sure what dbdf stands for. ________________________________ From: Gu, JiaWei (Will) > Sent: Monday, May 17, 2021 7:11 PM To: Koenig, Christian >; amd-gfx@lists.freedesktop.org= >; Nie= to, David M >; maraeo@gmail= .com >; = Deucher, Alexander > Cc: Deng, Emily > Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface [AMD Official Use Only - Internal Distribution Only] So I guess the dbdf is also needed to be removed? And how about serial? > +struct drm_amdgpu_info_vbios { > + __u8 name[64]; > + __u32 dbdf; // do we need this? > + __u8 vbios_pn[64]; > + __u32 version; > + __u8 vbios_ver_str[32]; > + __u8 date[32]; > + __u64 serial; // do we need this? > +}; Best regards, Jiawei -----Original Message----- From: Koenig, Christian > Sent: Monday, May 17, 2021 8:26 PM To: Gu, JiaWei (Will) >; amd-gf= x@lists.freedesktop.org; Nieto, David= M >; maraeo@gmail.com; Deucher, Alexander > Cc: Deng, Emily > Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface I'm not very familiar with the technical background why we have the fields = here once more. But of hand we should at least remove everything which is also available fr= om the PCI information. E.g. dev_id, rev_id, sub_dev_id, sub_ved_id. Regards, Christian. Am 17.05.21 um 14:17 schrieb Gu, JiaWei (Will): > [AMD Official Use Only - Internal Distribution Only] > > Hi all, > > Thanks Christian's suggestion. > I reverted the previous patches and squash them into this single one. > > As this patch shows, the current uapi change looks like this: > > +struct drm_amdgpu_info_vbios { > + __u8 name[64]; > + __u32 dbdf; > + __u8 vbios_pn[64]; > + __u32 version; > + __u8 vbios_ver_str[32]; > + __u8 date[32]; > + __u64 serial; > + __u32 dev_id; > + __u32 rev_id; > + __u32 sub_dev_id; > + __u32 sub_ved_id; > +}; > > As we know there's some redundant info in this struct. > Please feel free to give any comments or suggestion about what it should = & shouldn't include. > > Best regards, > Jiawei > > -----Original Message----- > From: Jiawei Gu > > Sent: Monday, May 17, 2021 8:08 PM > To: amd-gfx@lists.freedesktop.org; = Koenig, Christian > >; Nieto, David= M >; > maraeo@gmail.com; Deucher, Alexander > > Cc: Deng, Emily >; Gu, JiaW= ei (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 with= out 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. > > Signed-off-by: Jiawei Gu > > Acked-by: Christian K=F6nig > > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21 +++ > drivers/gpu/drm/amd/amdgpu/atom.c | 174 +++++++++++++++++++++ > drivers/gpu/drm/amd/amdgpu/atom.h | 12 ++ > drivers/gpu/drm/amd/include/atomfirmware.h | 5 + > include/uapi/drm/amdgpu_drm.h | 16 ++ > 5 files changed, 228 insertions(+) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > index 8d12e474745a..30e4fed3de22 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > @@ -861,6 +861,27 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *= data, struct drm_file *filp) > min((size_t)size, (size_t)(bio= s_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)); > + vbios_info.dbdf =3D PCI_DEVID(adev->pdev->bus->numb= er, adev->pdev->devfn); > + 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->vbio= s_ver_str, > + sizeof(atom_context->vbios_= ver_str)); > + memcpy(vbios_info.date, atom_context->date, sizeof(= atom_context->date)); > + vbios_info.serial =3D adev->unique_id; > + vbios_info.dev_id =3D adev->pdev->device; > + vbios_info.rev_id =3D adev->pdev->revision; > + vbios_info.sub_dev_id =3D atom_context->sub_dev_id; > + vbios_info.sub_ved_id =3D atom_context->sub_ved_id; > + > + return copy_to_user(out, &vbios_info, > + min((size_t)size, sizeof(vb= ios_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..542b2c2414e4 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, cha= r *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, 102= 4, 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 *bi= os) { > 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,23 @@ 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); > + ctx->sub_dev_id =3D atom_rom_header->usSubsystemVendorID; > + ctx->sub_ved_id =3D atom_rom_header->usSubsystemID; > + if (atom_rom_header->usMasterDataTableOffset !=3D 0) { > + master_table =3D (struct _ATOM_MASTER_DATA_TABLE *) > + CSTR(atom_rom_header->usMasterDataTableOffs= et); > + 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..6463ce6e756d 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,14 @@ 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]; > + uint32_t sub_dev_id; > + uint32_t sub_ved_id; > }; > > 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 t= erminator 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..e0f98ca9a755 > 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,20 @@ struct > drm_amdgpu_info_firmware { > __u32 feature; > }; > > +struct drm_amdgpu_info_vbios { > + __u8 name[64]; > + __u32 dbdf; > + __u8 vbios_pn[64]; > + __u32 version; > + __u8 vbios_ver_str[32]; > + __u8 date[32]; > + __u64 serial; > + __u32 dev_id; > + __u32 rev_id; > + __u32 sub_dev_id; > + __u32 sub_ved_id; > +}; > + > #define AMDGPU_VRAM_TYPE_UNKNOWN 0 > #define AMDGPU_VRAM_TYPE_GDDR1 1 > #define AMDGPU_VRAM_TYPE_DDR2 2 > -- > 2.17.1 --_000_BYAPR12MB284005A19E99B1D7AC43ABE5F42C9BYAPR12MB2840namp_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

[Public]


Yes, let's remove that too,

Thanks,

David

From: Gu, JiaWei (Will) <= ;JiaWei.Gu@amd.com>
Sent: Monday, May 17, 2021 8:07 PM
To: Nieto, David M <David.Nieto@amd.com>; Koenig, Christian &l= t;Christian.Koenig@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@l= ists.freedesktop.org>; maraeo@gmail.com <maraeo@gmail.com>; Deuche= r, 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]

 

OK let=92s remove serial.

 

dbdf comes from this:

vbios_info.dbdf =3D PCI_DEVID(adev->pdev->bu= s->number, adev->pdev->devfn);

 

I think we can remove dbdf as well.

 

Best regards,

Jiawei

 

From: Nieto, David M <David.Nieto@amd.co= m>
Sent: Tuesday, May 18, 2021 10:45 AM
To: Gu, JiaWei (Will) <JiaWei.Gu@amd.com>; Koenig, Christian &= lt;Christian.Koenig@amd.com>; amd-gfx@lists.freedesktop.org; maraeo@gmai= l.com; 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]=

 

The serial number is ASIC information, not VBIO= S information, and it is still available as a sysfs node... I don't think w= e should put it there.

 

Not sure what dbdf stands for.


From: Gu, JiaWei (Will) <JiaWei.Gu@amd.com>
Sent: Monday, May 17, 2021 7:11 PM
To: Koenig, Christian <Christian.Koenig@amd.com>; amd-gfx@lists.freedesktop.= org <amd-gfx@lists.= freedesktop.org>; Nieto, David M <David.Nieto@amd.com>; maraeo@gmail.com <maraeo@gmail.com>; Deucher, Alexander <Alexander.Deucher@amd.com><= br> Cc: Deng, Emily <Emily.Deng= @amd.com>
Subject: RE: [PATCH] drm/amdgpu: Add vbios info ioctl interface

 

[AMD Official Use Only - Internal Distribution Onl= y]

So I guess the dbdf is also needed to be removed?
And how about serial?

> +struct drm_amdgpu_info_vbios {
> +     __u8 name[64];
> +     __u32 dbdf; // do we need this?
> +     __u8 vbios_pn[64];
> +     __u32 version;
> +     __u8 vbios_ver_str[32];
> +     __u8 date[32];
> +     __u64 serial; // do we need this?
> +};

Best regards,
Jiawei

-----Original Message-----
From: Koenig, Christian <Chr= istian.Koenig@amd.com>
Sent: Monday, May 17, 2021 8:26 PM
To: Gu, JiaWei (Will) <JiaWei.Gu@am= d.com>; amd-gfx@lists.freedesktop.= org; Nieto, David M <David.Ni= eto@amd.com>; maraeo@gmail.com; Deucher, Alexande= r <Alexander.Deucher@amd.co= m>
Cc: Deng, Emily <Emily.Deng@amd.co= m>
Subject: Re: [PATCH] drm/amdgpu: Add vbios info ioctl interface

I'm not very familiar with the technical background why we have the fields = here once more.

But of hand we should at least remove everything which is also available fr= om the PCI information.

E.g. dev_id, rev_id, sub_dev_id, sub_ved_id.

Regards,
Christian.

Am 17.05.21 um 14:17 schrieb Gu, JiaWei (Will):
> [AMD Official Use Only - Internal Distribution Only]
>
> Hi all,
>
> Thanks Christian's suggestion.
> I reverted the previous patches and squash them into this single one.<= br> >
> As this patch shows, the current uapi change looks like this:
>
> +struct drm_amdgpu_info_vbios {
> +     __u8 name[64];
> +     __u32 dbdf;
> +     __u8 vbios_pn[64];
> +     __u32 version;
> +     __u8 vbios_ver_str[32];
> +     __u8 date[32];
> +     __u64 serial;
> +     __u32 dev_id;
> +     __u32 rev_id;
> +     __u32 sub_dev_id;
> +     __u32 sub_ved_id;
> +};
>
> As we know there's some redundant info in this struct.
> Please feel free to give any comments or suggestion about what it shou= ld & shouldn't include.
>
> Best regards,
> Jiawei
>
> -----Original Message-----
> From: Jiawei Gu <Jiawei.Gu@amd= .com>
> Sent: Monday, May 17, 2021 8:08 PM
> To: amd-gfx@lists.fre= edesktop.org; Koenig, Christian
> <Christian.Koenig@amd.c= om>; Nieto, David M <David= .Nieto@amd.com>;
> maraeo@gmail.com; Deucher, Ale= xander <Alexander.Deucher@a= md.com>
> Cc: Deng, Emily <Emily.Deng@a= md.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.
>
> Signed-off-by: Jiawei Gu <Jiaw= ei.Gu@amd.com>
> Acked-by: Christian K=F6nig <christian.koenig@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    = |  21 +++
>   drivers/gpu/drm/amd/amdgpu/atom.c    &= nbsp;     | 174 +++++++++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/atom.h    &= nbsp;     |  12 ++
>   drivers/gpu/drm/amd/include/atomfirmware.h |   5= +
>   include/uapi/drm/amdgpu_drm.h     = ;         |  16 ++
>   5 files changed, 228 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 8d12e474745a..30e4fed3de22 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -861,6 +861,27 @@ int amdgpu_info_ioctl(struct drm_device *dev, voi= d *data, struct drm_file *filp)
>            = ;            &n= bsp;            = ;       min((size_t)size, (size_t)(bios_size = - bios_offset)))
>            = ;            &n= bsp;            = ;   ? -EFAULT : 0;
>            = ;    }
> +           &nb= sp; case AMDGPU_INFO_VBIOS_INFO: {
> +           &nb= sp;         struct drm_amdgpu_info_= vbios vbios_info =3D {};
> +           &nb= sp;         struct atom_context *at= om_context;
> +
> +           &nb= sp;         atom_context =3D adev-&= gt;mode_info.atom_context;
> +           &nb= sp;         memcpy(vbios_info.name,= atom_context->name, sizeof(atom_context->name));
> +           &nb= sp;         vbios_info.dbdf =3D PCI= _DEVID(adev->pdev->bus->number, adev->pdev->devfn);
> +           &nb= sp;         memcpy(vbios_info.vbios= _pn, atom_context->vbios_pn, sizeof(atom_context->vbios_pn));
> +           &nb= sp;         vbios_info.version =3D = atom_context->version;
> +           &nb= sp;         memcpy(vbios_info.vbios= _ver_str, atom_context->vbios_ver_str,
> +           &nb= sp;            =             &nb= sp;        sizeof(atom_context->vbios= _ver_str));
> +           &nb= sp;         memcpy(vbios_info.date,= atom_context->date, sizeof(atom_context->date));
> +           &nb= sp;         vbios_info.serial =3D a= dev->unique_id;
> +           &nb= sp;         vbios_info.dev_id =3D a= dev->pdev->device;
> +           &nb= sp;         vbios_info.rev_id =3D a= dev->pdev->revision;
> +           &nb= sp;         vbios_info.sub_dev_id = =3D atom_context->sub_dev_id;
> +           &nb= sp;         vbios_info.sub_ved_id = =3D atom_context->sub_ved_id;
> +
> +           &nb= sp;         return copy_to_user(out= , &vbios_info,
> +           &nb= sp;            =             &nb= sp;        min((size_t)size, sizeof(vbio= s_info))) ? -EFAULT : 0;
> +           &nb= sp; }
>            = ;    default:
>            = ;            DRM_DEB= UG_KMS("Invalid request %d\n",
>            = ;            &n= bsp;            = ;   info->vbios_info.type);
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c
> b/drivers/gpu/drm/amd/amdgpu/atom.c
> index 3dcb8b32f48b..542b2c2414e4 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_contex= t *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) {
> +           &nb= sp; off_to_vbios_str =3D
> +           &nb= sp;         *(unsigned short *)(p_r= om + OFFSET_TO_GET_ATOMBIOS_STRING_START);
> +
> +           &nb= sp; c_ptr =3D (unsigned char *)(p_rom + off_to_vbios_str);
> +     } else {
> +           &nb= sp; /* do not know where to find name */
> +           &nb= sp; memcpy(ctx->name, na, 7);
> +           &nb= sp; ctx->name[7] =3D 0;
> +           &nb= sp; 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++) {
> +           &nb= sp; while (*c_ptr !=3D 0)
> +           &nb= sp;         c_ptr++;
> +           &nb= sp; c_ptr++;
> +     }
> +
> +     /* skip the following 2 chars: 0x0D 0x0A */<= br> > +     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 ' ')
> +           &nb= sp; ;
> +     *(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,
> +           &nb= sp;            =             &nb= sp;   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) {
> +           &nb= sp; for (str_off =3D 0; str_off < str_len; ++str_off) {
> +           &nb= sp;         if (str[str_off] !=3D *= (p_rom + start + str_off))
> +           &nb= sp;            =      break;
> +           &nb= sp; }
> +
> +           &nb= sp; if (str_off =3D=3D str_len || str[str_off] =3D=3D 0)
> +           &nb= sp;         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) {
> +           &nb= sp; off_to_vbios_str =3D
> +           &nb= sp;         *(unsigned short *)(p_r= om + OFFSET_TO_GET_ATOMBIOS_STRING_START);
> +
> +           &nb= sp; vbios_str =3D (unsigned char *)(p_rom + off_to_vbios_str);
> +     } else {
> +           &nb= sp; vbios_str =3D p_rom + OFFSET_TO_VBIOS_PART_NUMBER;
> +     }
> +
> +     if (*vbios_str =3D=3D 0) {
> +           &nb= sp; vbios_str =3D atom_find_str_in_rom(ctx, BIOS_ATOM_PREFIX, 3, 1024, 64);=
> +           &nb= sp; if (vbios_str =3D=3D NULL)
> +           &nb= sp;         vbios_str +=3D sizeof(B= IOS_ATOM_PREFIX) - 1;
> +     }
> +     if (vbios_str !=3D NULL && *vbios_st= r =3D=3D 0)
> +           &nb= sp; vbios_str++;
> +
> +     if (vbios_str !=3D NULL) {
> +           &nb= sp; count =3D 0;
> +           &nb= sp; while ((count < BIOS_STRING_LENGTH) && vbios_str[count] >= =3D ' ' &&
> +           &nb= sp;        vbios_str[count] <=3D 'z')= {
> +           &nb= sp;         ctx->vbios_pn[count]= =3D vbios_str[count];
> +           &nb= sp;         count++;
> +           &nb= sp; }
> +
> +           &nb= sp; 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) {
> +           &nb= sp; /* skip ATOMBIOSBK-AMD VER */
> +           &nb= sp; vbios_ver +=3D 18;
> +           &nb= sp; memcpy(ctx->vbios_ver_str, vbios_ver, STRLEN_NORMAL);
> +     } else {
> +           &nb= sp; ctx->vbios_ver_str[0] =3D '\0';
> +     }
> +}
> +
>   struct atom_context *amdgpu_atom_parse(struct card_info *c= ard, void *bios)  {
>        int base;
>        struct atom_context *ctx =3D=
>            kzal= loc(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,23 @@ struct atom_context *amdgpu_atom_parse(struct c= ard_info *card, void *bios)
>            = ;    strlcpy(ctx->vbios_version, str, sizeof(ctx->vbio= s_version));
>        }
>  
> +     atom_rom_header =3D (struct _ATOM_ROM_HEADER= *)CSTR(base);
> +     ctx->sub_dev_id =3D atom_rom_header->u= sSubsystemVendorID;
> +     ctx->sub_ved_id =3D atom_rom_header->u= sSubsystemID;
> +     if (atom_rom_header->usMasterDataTableOff= set !=3D 0) {
> +           &nb= sp; master_table =3D (struct _ATOM_MASTER_DATA_TABLE *)
> +           &nb= sp;            =      CSTR(atom_rom_header->usMasterDataTableOffset);=
> +           &nb= sp; if (master_table->ListOfDataTables.FirmwareInfo !=3D 0) {
> +           &nb= sp;         atom_fw_info =3D (struc= t _ATOM_FIRMWARE_INFO *)
> +           &nb= sp;            =              CS= TR(master_table->ListOfDataTables.FirmwareInfo);
> +           &nb= sp;         ctx->version =3D ato= m_fw_info->ulFirmwareRevision;
> +           &nb= sp; }
> +     }
> +
> +     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..6463ce6e756d 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      &= nbsp;        2
>   #define ATOM_IO_IIO      &nb= sp;  0x80
>  
> +#define STRLEN_NORMAL        =         32
> +#define STRLEN_LONG        &n= bsp; 64
> +#define STRLEN_VERYLONG       &nbs= p;      254
> +
>   struct card_info {
>        struct drm_device *dev;
>        void (* reg_write)(struct ca= rd_info *, uint32_t, uint32_t);   /*  filled by driver */ > @@ -140,6 +144,14 @@ 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];
> +     uint32_t sub_dev_id;
> +     uint32_t sub_ved_id;
>   };
>  
>   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 &nb= sp;    =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       =             &nb= sp;   =3D 0x50,
>   };
>  
>  
> /*********************************************************************=
> ******* diff --git a/include/uapi/drm/amdgpu_drm.h
> b/include/uapi/drm/amdgpu_drm.h index 9169df7fadee..e0f98ca9a755
> 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_SI= ZE          0x1
>        /* Subquery id: Query vbios = image */
>        #define AMDGPU_INFO_VBIOS_IM= AGE         0x2
> +     /* Subquery id: Query vbios info */
> +     #define AMDGPU_INFO_VBIOS_INFO  &n= bsp;       0x3
>   /* Query UVD handles */
>   #define AMDGPU_INFO_NUM_HANDLES    &nb= sp;            =     0x1C
>   /* Query sensor related information */ @@ -949,6 +951,20 @= @ struct
> drm_amdgpu_info_firmware {
>        __u32 feature;
>   };
>  
> +struct drm_amdgpu_info_vbios {
> +     __u8 name[64];
> +     __u32 dbdf;
> +     __u8 vbios_pn[64];
> +     __u32 version;
> +     __u8 vbios_ver_str[32];
> +     __u8 date[32];
> +     __u64 serial;
> +     __u32 dev_id;
> +     __u32 rev_id;
> +     __u32 sub_dev_id;
> +     __u32 sub_ved_id;
> +};
> +
>   #define AMDGPU_VRAM_TYPE_UNKNOWN 0
>   #define AMDGPU_VRAM_TYPE_GDDR1 1
>   #define AMDGPU_VRAM_TYPE_DDR2  2
> --
> 2.17.1

--_000_BYAPR12MB284005A19E99B1D7AC43ABE5F42C9BYAPR12MB2840namp_-- --===============1722405634== 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 --===============1722405634==--