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.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,HTTPS_HTTP_MISMATCH, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_HTML_MOSTLY, PDS_BAD_THREAD_QP_64,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 D1942C433ED for ; Wed, 19 May 2021 16:10:44 +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 86AA9611BF for ; Wed, 19 May 2021 16:10:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86AA9611BF 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 120EB6EE0E; Wed, 19 May 2021 16:10:44 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 54CD26EE0E for ; Wed, 19 May 2021 16:10:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CiZC7HT1miqohSICK+i9cmcPPknASk9h291kAQuPqs/d/UgpWTxh4NpEZA+kAO02b0uv/EtHAbC5c2jq/VJh917Rs5xHLZhdI/7vC3PGjl8yRbprdiA/PSlUdnafqQptws2MMMwCefdS4BlAddy+Oe6nX7UkW4BXaeb5UbyuwXsGMBwiJpsO8Nm61IrArkYG3Ze3ijqRbDI9jUrV+jEl13dl4i90QGfx16eQzyO4W3rToVYkVqQG5CG2gFWFjQcCvAbgNnZ6yFDK4IQq28bNTEiv1C4GPOOeuykr1VbMjEMXirxtS/zzswifBh7au18F3VVWz7xoC8TXdnFclVh4jw== 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=SlSWXSEBHE1LmaPg/CR917kbjZgbAx7e7yZc4NfwUnA=; b=C5MQzr2t8KC8pdQ1GqkGUCLy9/U9Vx7JUrnXvbdho5DUoBQSjlXXOTBkA4NN3tdwRf9eeV5RzaMtWoKZkYkRnW2jSXiuiXcwC8Pp5jaESwmWz7p3VUuUVFpP6Vq32hjfU9U2JixaewVteTgcCjt29SJQlZ0Dzh7tTCPq+88cPMVO3XWOxtfGbR3tR91WTl7KDXAS0kTXeKGXD4LPayk4mznoVA1gYXfI79/m6+znVlG2+UBVIdLZz1ou0dz/rPlgRrqfw2FCf4G5qWQ07QOi+2hhmYtp9djH4WEwetGfZAPfXysJempBeU38tNLBt9UAmBKuI0ffAEMCYxoiaEBzWw== 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=SlSWXSEBHE1LmaPg/CR917kbjZgbAx7e7yZc4NfwUnA=; b=j/3KfrA2x+w15DAQJ36c0LgZWWlBzfyAhHnF4/wx1GsRJa0uiDyXtedxJsTNujACvCj39mtXE3ungtaciNsKA05vQgMY/acrJVJmfOiR1Ma/F9zOXM3cNKGtFUEPxmyUFunSP2g8plXZykV/2PiKeK+h+YejLtMCN36cJZUObSg= Received: from BYAPR12MB2840.namprd12.prod.outlook.com (2603:10b6:a03:62::32) by BY5PR12MB3876.namprd12.prod.outlook.com (2603:10b6:a03:1a7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Wed, 19 May 2021 16:10:39 +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; Wed, 19 May 2021 16:10:39 +0000 From: "Nieto, David M" To: =?iso-8859-1?Q?Christian_K=F6nig?= , Alex Deucher , "Gu, JiaWei (Will)" Subject: Re: [PATCH] drm/amdgpu: Expose rfc4122 compliant UUID Thread-Topic: [PATCH] drm/amdgpu: Expose rfc4122 compliant UUID Thread-Index: AQHXSuEcuETPwjKslkm6HnhXoDebuarpSgcAgABpw8iAAPJHgIAAVltn Date: Wed, 19 May 2021 16:10:39 +0000 Message-ID: References: <20210517055413.28417-1-Jiawei.Gu@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_88914ebd-7e6c-4e12-a031-a9906be2db14_Enabled=True; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_SetDate=2021-05-19T16:07:39.5188183Z; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_ContentBits=0; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Method=Standard authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=amd.com; x-originating-ip: [2607:fb90:3021:582b:f456:88fd:d521:b375] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e0560a8a-6d42-4838-7306-08d91ae0a549 x-ms-traffictypediagnostic: BY5PR12MB3876: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: V+i0izbKg699GqRi+U4/oERbWEn7L1hBvuih6TUJ56uujPQcZJMsrfnDBe31TI8Vi+tJHiplCm6sf6CX0k/RfVZQ5odF5RXe6vtI00yOC0SITtwIhSvy/mSBZiqyc+5ZbX7K96D9ptL14Xd9SLjsEk547zina/s1I4W6nJwpwWoiJOOP1tgkuP6P2XzBgfTlC0L4be9Y0ShxevkrEMLTzCudwwgKBrnjb0qqj21f9JnVBR6CizLPjdcYtoiK5RP3vZBn792y+5wHgkPEc5c6HaHAolP5PZUgbwCx5D64+4+g1LZvZAfL7bF4OtOUg5OG/q39i0qZ1qP96GuktZmKiB16ZUMFy4ZORykNNtTEqm1LHdmwzJvDxGNoG2fZKfatlcLDCziYJB1UInwhKAhX+Xj1s6epZNBNXgaD2HjAYZc18d8+l0VbSq6i753e3YfE4bSZbcq5HAcwXqmm57CHjSpiKyi77/uhw9QOQkWp0flr58/sLKD3WpZb5wQFLRpcRaBkc83w3goZZdpLyyrSkT2RP7l06geHcy9HnJWzVTa6fWR0XgN8Z1POm+UaMsGy9gjs2iRPTqluYytZM2Pg6AcJJty1YnTy+kCg5HHLydAGxKE0KReQTKe0IQtjGVvKbUuYsjnbfUGd6Jg1xywj4Q== 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)(346002)(376002)(396003)(366004)(39860400002)(136003)(5660300002)(86362001)(83380400001)(38100700002)(122000001)(2906002)(6636002)(19627405001)(52536014)(478600001)(45080400002)(4326008)(966005)(166002)(186003)(66476007)(66446008)(8676002)(66556008)(33656002)(64756008)(7696005)(71200400001)(55016002)(316002)(30864003)(6506007)(53546011)(9686003)(54906003)(8936002)(66946007)(110136005)(76116006); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?iso-8859-1?Q?zWZD+c5tpRG75KXIWbp2PCljoPjbt7Buz9GH2W005JGUG9LeBhW/DwdjP8?= =?iso-8859-1?Q?h8mexewihWU5H5E5lsvOwdavLPglIEXUCUSdiZXy75A5kqNy+gDGGlyTQn?= =?iso-8859-1?Q?VfMYT1bJhh1/YiMHxag+vc7hhNrMzs3snx7lOrqq/RSjeA6C7XBWQUSBWU?= =?iso-8859-1?Q?TwmFU+8+he/5QWsmB5jWK3ZJ4UkyvP2+QbtRAE+6VVebzA7LUx+vgk8vCI?= =?iso-8859-1?Q?xlT+k0Qqs8FXpe/C/KrN8N/rLa74vZ/rDHSb8KzUTP+FnC037VUYuso94B?= =?iso-8859-1?Q?QVijLpY9yqIl+7Y8Hl5OaHkCX48xXITl9o5iJ6ANX9J8FtUZaAdLYc0fx6?= =?iso-8859-1?Q?CT3zU7AUEkAouL+TjVBGip0JYVxyBkYOUSfFGLLHt0PMAwL/ICzW+TcnKU?= =?iso-8859-1?Q?hiOoC6NPA6Gh47TAETOTNAUjZ0HKlOFG1P4zkUf2m9y9MFBJbPp8vBvKTy?= =?iso-8859-1?Q?5MuXd9e8NcNHaDawlhCwbxwEFJivW/68Y0HEwsC/W2Wqm5ObwaRPm5Q/zi?= =?iso-8859-1?Q?H2+acLg/qK0G0dh+I6pxeUzbYvFd1GjA4ma37bjq4cvQ3pkjGQBGfOUyyI?= =?iso-8859-1?Q?VDALRoW9Coejmbr0ZTjp+7wDAKbX86wiQodm2tEVbzv5gILsGqpPZJrXJv?= =?iso-8859-1?Q?w3rw8f1B4OWx20R5i7ZcszqxLX3slelSIPAf4jZXqN94UofaV56WJU+9eR?= =?iso-8859-1?Q?edFkrnO4KzIVH1ZrTljJl7lMianAIuBk25Lu4XhVtf7B2ewLGW2KHWzZ8B?= =?iso-8859-1?Q?bs0cXtLChCZX04jSVgzfKQqJDjgoAQxAoMe9xjzw1PO0h22KpH+g0Ys6vf?= =?iso-8859-1?Q?L+EivUBzj6qFahKqEV0qGdFxUn9AZUKYC49abmqubotd3D0c1iNbm1WMJL?= =?iso-8859-1?Q?PAODaC220Us+PbNMv0nEUcFNyAuPOPKI0FlXV32aUH9XL2K+8XxiwkT0UB?= =?iso-8859-1?Q?06RfZmmFqWrFoOjjMw0RAg6248RlYwPxMx8LojkBN/teJ5hb3y/Co/5N5N?= =?iso-8859-1?Q?YiSSmA4/7ZBajmugwR2gxR+diO4VAr9oCajAEiYyWf1jaZck3wnP/4YFNr?= =?iso-8859-1?Q?TGOf2376wGSNbwW8BXErjMJrEHg0Lx8ARV96NCSr+7EmJDh0AzsPrGxCV2?= =?iso-8859-1?Q?vrSpemwrhdsIx4Al+UtJS0shkd8UFxzDIaxXKQuOW92/MhglRxIpUfdSqD?= =?iso-8859-1?Q?rqzq8Xtd+2ttY1LAmjkmgxIuX9jq5rPQC5D7RssDUqtKnv9gVhWXyeo6GX?= =?iso-8859-1?Q?1TO8w9oZcp8vs+3avD5z9gpUnYck9HxSIWygSemR603naZ4ua6wltvGy+4?= =?iso-8859-1?Q?m2orLezNEUYkMYGf3IJciT0Xc+RqjnTF6utnGgaVi8H08+SextiP7Zp5P1?= =?iso-8859-1?Q?LhSFxoSNc+FP0NrGzauYjnAawbf7HClblVk7DoY7dAeURiB3vnzJMtm633?= =?iso-8859-1?Q?tGTO0WuE0tTy9wXcQ1uWblxjYcG1dqDAwxWy+w=3D=3D?= 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: e0560a8a-6d42-4838-7306-08d91ae0a549 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 May 2021 16:10:39.6637 (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: gFMMwJQ0g9w0eO6mnVZXIWYMu/LDvp2yypXYoh5Bksld6sSGDIPnI9HLdGYoUtjB X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3876 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" , amd-gfx list Content-Type: multipart/mixed; boundary="===============0274452409==" Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" --===============0274452409== Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_BYAPR12MB2840896BAF9A9C1E3AEE0B88F42B9BYAPR12MB2840namp_" --_000_BYAPR12MB2840896BAF9A9C1E3AEE0B88F42B9BYAPR12MB2840namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only] For the case of virtualization, for example, the serial number has no relat= ion to the uuid. Which means that at least for virtualization the node need= s to be created. This may also be the case on other gpus. ________________________________ From: Christian K=F6nig Sent: Wednesday, May 19, 2021 3:58:35 AM To: Nieto, David M ; Alex Deucher ; Gu, JiaWei (Will) Cc: Deng, Emily ; amd-gfx list Subject: Re: [PATCH] drm/amdgpu: Expose rfc4122 compliant UUID Well I don't think generating an UUID in the kernel makes sense in general. What we can do is to expose the serial number of the device, so that usersp= ace can create an UUID if necessary. Christian. Am 18.05.21 um 22:37 schrieb Nieto, David M: [AMD Official Use Only] I think the sysfs node should be moved into amdgpu_pm instead of the amdgpu= _device.c and generation of the unique_id should be moved to navi10_ppt.c, = similarly to other chips. Thinking it better, generating a random UUID makes no sense in the driver l= evel, any application can do the same thing on userspace if the UUID sysfs = node is empty. So, I think we should do the same as with the unique_id node, if the unique= _id is not present, just return. David ________________________________ From: Alex Deucher Sent: Tuesday, May 18, 2021 7:12 AM To: Gu, JiaWei (Will) Cc: amd-gfx list ; Deng, Emily ; N= ieto, David M Subject: Re: [PATCH] drm/amdgpu: Expose rfc4122 compliant UUID On Mon, May 17, 2021 at 1:54 AM Jiawei Gu wrote: > > Introduce an RFC 4122 compliant UUID for the GPUs derived > from the unique GPU serial number (from Vega10) on gpus. > Where this serial number is not available, use a compliant > random UUID. > > For virtualization, the unique ID is passed by the host driver > in the PF2VF structure. > > Signed-off-by: Jiawei Gu > --- > drivers/gpu/drm/amd/amdgpu/amdgpu.h | 36 ++++++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 96 +++++++++++++++++++++ > drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 4 + > drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h | 4 +- > drivers/gpu/drm/amd/amdgpu/nv.c | 5 ++ > drivers/gpu/drm/amd/amdgpu/nv.h | 3 + > 6 files changed, 146 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/am= dgpu/amdgpu.h > index 3147c1c935c8..ad6d4b55be6c 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h > @@ -802,6 +802,40 @@ struct amd_powerplay { > (rid =3D=3D 0x01) || \ > (rid =3D=3D 0x10)))) > > +union amdgpu_uuid_info { > + struct { > + union { > + struct { > + uint32_t did : 16; > + uint32_t fcn : 8; > + uint32_t asic_7 : 8; > + }; > + uint32_t time_low; > + }; > + > + struct { > + uint32_t time_mid : 16; > + uint32_t time_high : 12; > + uint32_t version : 4; > + }; > + > + struct { > + struct { > + uint8_t clk_seq_hi : 6; > + uint8_t variant : 2; > + }; > + union { > + uint8_t clk_seq_low; > + uint8_t asic_6; > + }; > + uint16_t asic_4; > + }; > + > + uint32_t asic_0; > + }; > + char as_char[16]; > +}; > + > #define AMDGPU_RESET_MAGIC_NUM 64 > #define AMDGPU_MAX_DF_PERFMONS 4 > struct amdgpu_device { > @@ -1074,6 +1108,8 @@ struct amdgpu_device { > char product_name[32]; > char serial[20]; > > + union amdgpu_uuid_info uuid_info; > + > struct amdgpu_autodump autodump; > > atomic_t throttling_logging_enabled; > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm= /amd/amdgpu/amdgpu_device.c > index 7c6c435e5d02..079841e1cb52 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c > @@ -37,6 +37,7 @@ > #include > #include > #include > +#include > #include "amdgpu.h" > #include "amdgpu_trace.h" > #include "amdgpu_i2c.h" > @@ -3239,11 +3240,104 @@ static int amdgpu_device_get_job_timeout_setting= s(struct amdgpu_device *adev) > return ret; > } > > +static bool amdgpu_is_uuid_info_empty(union amdgpu_uuid_info *uuid_info) > +{ > + return (uuid_info->time_low =3D=3D 0 && > + uuid_info->time_mid =3D=3D 0 && > + uuid_info->time_high =3D=3D 0 && > + uuid_info->version =3D=3D 0 && > + uuid_info->clk_seq_hi =3D=3D 0 && > + uuid_info->variant =3D=3D 0 && > + uuid_info->clk_seq_low =3D=3D 0 && > + uuid_info->asic_4 =3D=3D 0 && > + uuid_info->asic_0 =3D=3D 0); > +} > + > +static void amdgpu_gen_uuid_info(union amdgpu_uuid_info *uuid_info, > + uint64_t serial, uint16_t did, uint8_t id= x) > +{ > + uint16_t clk_seq =3D 0; > + > + /* Step1: insert clk_seq */ > + uuid_info->clk_seq_low =3D (uint8_t)clk_seq; > + uuid_info->clk_seq_hi =3D (uint8_t)(clk_seq >> 8) & 0x3F; > + > + /* Step2: insert did */ > + uuid_info->did =3D did; > + > + /* Step3: insert vf idx */ > + uuid_info->fcn =3D idx; > + > + /* Step4: insert serial */ > + uuid_info->asic_0 =3D (uint32_t)serial; > + uuid_info->asic_4 =3D (uint16_t)(serial >> 4 * 8) & 0xFFFF; > + uuid_info->asic_6 =3D (uint8_t)(serial >> 6 * 8) & 0xFF; > + uuid_info->asic_7 =3D (uint8_t)(serial >> 7 * 8) & 0xFF; > + > + /* Step5: insert version */ > + uuid_info->version =3D 1; > + /* Step6: insert variant */ > + uuid_info->variant =3D 2; > +} > + > +/* byte reverse random uuid */ > +static void amdgpu_gen_uuid_random(union amdgpu_uuid_info *uuid_info) > +{ > + char b0, b1; > + int i; > + > + generate_random_uuid(uuid_info->as_char); > + for (i =3D 0; i < 8; i++) { > + b0 =3D uuid_info->as_char[i]; > + b1 =3D uuid_info->as_char[16-i]; > + uuid_info->as_char[16-i] =3D b0; > + uuid_info->as_char[i] =3D b1; > + } > +} > + > +/** > + * > + * The amdgpu driver provides a sysfs API for providing uuid data. > + * The file uuid_info is used for this, and returns string of amdgpu uui= d. > + */ > +static ssize_t amdgpu_get_uuid_info(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct drm_device *ddev =3D dev_get_drvdata(dev); > + struct amdgpu_device *adev =3D drm_to_adev(ddev);//ddev->dev_priv= ate; > + union amdgpu_uuid_info *uuid =3D &adev->uuid_info; > + > + return sysfs_emit(buf, > + "%08x-%04x-%x%03x-%02x%02x-%04x%0= 8x\n", > + uuid->time_low, > + uuid->time_mid, > + uuid->version, > + uuid->time_high, > + uuid->clk_seq_hi | > + uuid->variant << 6, > + uuid->clk_seq_low, > + uuid->asic_4, > + uuid->asic_0); > +} > +static DEVICE_ATTR(uuid_info, S_IRUGO, amdgpu_get_uuid_info, NULL); > + > +static void amdgpu_uuid_init(struct amdgpu_device *adev) > +{ > + if (amdgpu_is_uuid_info_empty(&adev->uuid_info)) { > + if (adev->unique_id) > + amdgpu_gen_uuid_info(&adev->uuid_info, adev->uniq= ue_id, adev->pdev->device, 31); > + else > + amdgpu_gen_uuid_random(&adev->uuid_info); > + } > +} > + > static const struct attribute *amdgpu_dev_attributes[] =3D { > &dev_attr_product_name.attr, > &dev_attr_product_number.attr, > &dev_attr_serial_number.attr, > &dev_attr_pcie_replay_count.attr, > + &dev_attr_uuid_info.attr, > NULL > }; > > @@ -3551,6 +3645,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, > > amdgpu_fbdev_init(adev); > > + amdgpu_uuid_init(adev); > + > r =3D amdgpu_pm_sysfs_init(adev); > if (r) { > adev->pm_sysfs_en =3D false; > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_virt.c > index b71dd1deeb2d..2dfebfe38079 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c > @@ -429,6 +429,7 @@ static void amdgpu_virt_add_bad_page(struct amdgpu_de= vice *adev, > static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *adev) > { > struct amd_sriov_msg_pf2vf_info_header *pf2vf_info =3D adev->virt= .fw_reserve.p_pf2vf; > + union amdgpu_uuid_info *uuid =3D &adev->uuid_info; > uint32_t checksum; > uint32_t checkval; > > @@ -498,6 +499,9 @@ static int amdgpu_virt_read_pf2vf_data(struct amdgpu_= device *adev) > > adev->unique_id =3D > ((struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->= uuid; > + > + memcpy(uuid, &((struct amd_sriov_msg_pf2vf_info *)pf2vf_i= nfo)->uuid_info_reserved, > + sizeof(union amdgpu_uuid_info)); > break; > default: > DRM_ERROR("invalid pf2vf version\n"); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h b/drivers/gpu/dr= m/amd/amdgpu/amdgv_sriovmsg.h > index a434c71fde8e..0d1d36e82aeb 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h > +++ b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h > @@ -203,9 +203,9 @@ struct amd_sriov_msg_pf2vf_info { > uint32_t encode_max_frame_pixels; > } mm_bw_management[AMD_SRIOV_MSG_RESERVE_VCN_INST]; > /* UUID info */ > - struct amd_sriov_msg_uuid_info uuid_info; > + uint32_t uuid_info_reserved[4]; > /* reserved */ > - uint32_t reserved[256 - 47]; > + uint32_t reserved[256-47]; > }; > > struct amd_sriov_msg_vf2pf_info_header { > diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amdgpu= /nv.c > index 32c34470404c..16d4a480f4c0 100644 > --- a/drivers/gpu/drm/amd/amdgpu/nv.c > +++ b/drivers/gpu/drm/amd/amdgpu/nv.c > @@ -1167,6 +1167,11 @@ static int nv_common_early_init(void *handle) > if (amdgpu_sriov_vf(adev)) > adev->rev_id =3D 0; > adev->external_rev_id =3D adev->rev_id + 0xa; > + if (!amdgpu_sriov_vf(adev)) { > + adev->unique_id =3D RREG32(mmFUSE_DATA_730); > + adev->unique_id <<=3D 32; > + adev->unique_id |=3D RREG32(mmFUSE_DATA_729); > + } I would suggest putting this in navi10_get_unique_id() in navi10_ppt.c for consistency since we query this from the SMU on most other asics. Alex > break; > case CHIP_SIENNA_CICHLID: > adev->cg_flags =3D AMD_CG_SUPPORT_GFX_MGCG | > diff --git a/drivers/gpu/drm/amd/amdgpu/nv.h b/drivers/gpu/drm/amd/amdgpu= /nv.h > index 515d67bf249f..520ac2b98744 100644 > --- a/drivers/gpu/drm/amd/amdgpu/nv.h > +++ b/drivers/gpu/drm/amd/amdgpu/nv.h > @@ -26,6 +26,9 @@ > > #include "nbio_v2_3.h" > > +#define mmFUSE_DATA_729 (0x176D9) > +#define mmFUSE_DATA_730 (0x176DA) > + > void nv_grbm_select(struct amdgpu_device *adev, > u32 me, u32 pipe, u32 queue, u32 vmid); > void nv_set_virt_ops(struct amdgpu_device *adev); > -- > 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%7Cdavid.= nieto%40amd.com%7Cb6a43b8c156c4a6964e208d91a070e84%7C3dd8961fe4884e608e11a8= 2d994e183d%7C0%7C0%7C637569439877514988%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4= wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=3D= 7lpRnRgRwKASGUmfr3RChO0P6QfRbcpMFggQl6HO%2Bss%3D&reserved=3D0 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx --_000_BYAPR12MB2840896BAF9A9C1E3AEE0B88F42B9BYAPR12MB2840namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

[AMD Official Use Only]


For the case of virtualization, for example, the serial number has no relat= ion to the uuid. Which means that at least for virtualization the node need= s to be created. This may also be the case on other gpus.


From: Christian K=F6nig <= ;ckoenig.leichtzumerken@gmail.com>
Sent: Wednesday, May 19, 2021 3:58:35 AM
To: Nieto, David M <David.Nieto@amd.com>; Alex Deucher <ale= xdeucher@gmail.com>; Gu, JiaWei (Will) <JiaWei.Gu@amd.com>
Cc: Deng, Emily <Emily.Deng@amd.com>; amd-gfx list <amd-gfx= @lists.freedesktop.org>
Subject: Re: [PATCH] drm/amdgpu: Expose rfc4122 compliant UUID
 
Well I don't think generating an UUID in the kernel makes sense in gen= eral.

What we can do is to expose the serial number of the device, so that usersp= ace can create an UUID if necessary.

Christian.

Am 18.05.21 um 22:37 schrieb Nieto, David = M:

[AMD Official Use Only]


I think the sysfs node should be moved into amdgpu_pm instead of the amdgpu= _device.c and generation of the unique_id should be moved to navi10_ppt.c, = similarly to other chips.

Thinking it better, generating a random UUID makes no sense in the driver l= evel, any application can do the same thing on userspace if the UUID sysfs = node is empty.

So, I think we should do the same as with the unique_id node, if the unique= _id is not present, just return.

David

From: Alex Deucher = <alexdeucher@gmail.com>
Sent: Tuesday, May 18, 2021 7:12 AM
To: Gu, JiaWei (Will) <JiaWei.Gu@amd.com>
Cc: amd-gfx list <amd-gfx@lists.freedesktop.org>; Deng, Emily <Emily.Deng@amd.com>; Nieto, David M <David.Nieto@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Expose rfc4122 compliant UUID
 
On Mon, May 17, 2021 at 1:54 AM Jiawei Gu <Jiawei.Gu@amd.com> wrote:
>
> Introduce an RFC 4122 compliant UUID for the GPUs derived
> from the unique GPU serial number (from Vega10) on gpus.
> Where this serial number is not available, use a compliant
> random UUID.
>
> For virtualization, the unique ID is passed by the host driver
> in the PF2VF structure.
>
> Signed-off-by: Jiawei Gu <Jiawei.Gu@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h     = ;    | 36 ++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c  | 96 ++++++++++= +++++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c    |&nbs= p; 4 +
>  drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h |  4 +-
>  drivers/gpu/drm/amd/amdgpu/nv.c     &nb= sp;       |  5 ++
>  drivers/gpu/drm/amd/amdgpu/nv.h     &nb= sp;       |  3 +
>  6 files changed, 146 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd= /amdgpu/amdgpu.h
> index 3147c1c935c8..ad6d4b55be6c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -802,6 +802,40 @@ struct amd_powerplay {
>            = ;            &n= bsp;            = ;      (rid =3D=3D 0x01) || \
>            = ;            &n= bsp;            = ;      (rid =3D=3D 0x10))))
>
> +union amdgpu_uuid_info {
> +       struct {
> +           &nb= sp;   union {
> +           &nb= sp;           struct { > +           &nb= sp;            =        uint32_t did    : 16; > +           &nb= sp;            =        uint32_t fcn    : 8; > +           &nb= sp;            =        uint32_t asic_7 : 8;
> +           &nb= sp;           };
> +           &nb= sp;           uint32_t ti= me_low;
> +           &nb= sp;   };
> +
> +           &nb= sp;   struct {
> +           &nb= sp;           uint32_t ti= me_mid  : 16;
> +           &nb= sp;           uint32_t ti= me_high : 12;
> +           &nb= sp;           uint32_t ve= rsion   : 4;
> +           &nb= sp;   };
> +
> +           &nb= sp;   struct {
> +           &nb= sp;           struct { > +           &nb= sp;            =        uint8_t clk_seq_hi : 6;
> +           &nb= sp;            =        uint8_t variant    : 2;=
> +           &nb= sp;           };
> +           &nb= sp;           union {
> +           &nb= sp;            =        uint8_t clk_seq_low;
> +           &nb= sp;            =        uint8_t asic_6;
> +           &nb= sp;           };
> +           &nb= sp;           uint16_t as= ic_4;
> +           &nb= sp;   };
> +
> +           &nb= sp;   uint32_t asic_0;
> +       };
> +       char as_char[16];
> +};
> +
>  #define AMDGPU_RESET_MAGIC_NUM 64
>  #define AMDGPU_MAX_DF_PERFMONS 4
>  struct amdgpu_device {
> @@ -1074,6 +1108,8 @@ struct amdgpu_device {
>         char   =             &nb= sp;            produ= ct_name[32];
>         char   =             &nb= sp;            seria= l[20];
>
> +       union amdgpu_uuid_info uuid_info= ;
> +
>         struct amdgpu_autodump=           autodump;
>
>         atomic_t  &n= bsp;            = ;         throttling_logging_enable= d;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/= drm/amd/amdgpu/amdgpu_device.c
> index 7c6c435e5d02..079841e1cb52 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -37,6 +37,7 @@
>  #include <linux/vgaarb.h>
>  #include <linux/vga_switcheroo.h>
>  #include <linux/efi.h>
> +#include <linux/uuid.h>
>  #include "amdgpu.h"
>  #include "amdgpu_trace.h"
>  #include "amdgpu_i2c.h"
> @@ -3239,11 +3240,104 @@ static int amdgpu_device_get_job_timeout_sett= ings(struct amdgpu_device *adev)
>         return ret;
>  }
>
> +static bool amdgpu_is_uuid_info_empty(union amdgpu_uuid_info *uuid_in= fo)
> +{
> +       return (uuid_info->time_low&n= bsp;   =3D=3D 0 &&
> +           &nb= sp;           uuid_info-&= gt;time_mid    =3D=3D 0 &&
> +           &nb= sp;           uuid_info-&= gt;time_high   =3D=3D 0 &&
> +           &nb= sp;           uuid_info-&= gt;version     =3D=3D 0 &&
> +           &nb= sp;           uuid_info-&= gt;clk_seq_hi  =3D=3D 0 &&
> +           &nb= sp;           uuid_info-&= gt;variant     =3D=3D 0 &&
> +           &nb= sp;           uuid_info-&= gt;clk_seq_low =3D=3D 0 &&
> +           &nb= sp;           uuid_info-&= gt;asic_4      =3D=3D 0 &&
> +           &nb= sp;           uuid_info-&= gt;asic_0      =3D=3D 0);
> +}
> +
> +static void amdgpu_gen_uuid_info(union amdgpu_uuid_info *uuid_info, > +           &nb= sp;            =        uint64_t serial, uint16_t did, uint8_t= idx)
> +{
> +       uint16_t clk_seq =3D 0;
> +
> +       /* Step1: insert clk_seq */
> +       uuid_info->clk_seq_low =3D (u= int8_t)clk_seq;
> +       uuid_info->clk_seq_hi  = =3D (uint8_t)(clk_seq >> 8) & 0x3F;
> +
> +       /* Step2: insert did */
> +       uuid_info->did =3D did;
> +
> +       /* Step3: insert vf idx */
> +       uuid_info->fcn =3D idx;
> +
> +       /* Step4: insert serial */
> +       uuid_info->asic_0 =3D (uint32= _t)serial;
> +       uuid_info->asic_4 =3D (uint16= _t)(serial >> 4 * 8) & 0xFFFF;
> +       uuid_info->asic_6 =3D (uint8_= t)(serial >> 6 * 8) & 0xFF;
> +       uuid_info->asic_7 =3D (uint8_= t)(serial >> 7 * 8) & 0xFF;
> +
> +       /* Step5: insert version */
> +       uuid_info->version =3D 1;
> +       /* Step6: insert variant */
> +       uuid_info->variant =3D 2;
> +}
> +
> +/* byte reverse random uuid */
> +static void amdgpu_gen_uuid_random(union amdgpu_uuid_info *uuid_info)=
> +{
> +       char b0, b1;
> +       int i;
> +
> +       generate_random_uuid(uuid_info-&= gt;as_char);
> +       for (i =3D 0; i < 8; i++) { > +           &nb= sp;   b0 =3D uuid_info->as_char[i];
> +           &nb= sp;   b1 =3D uuid_info->as_char[16-i];
> +           &nb= sp;   uuid_info->as_char[16-i] =3D b0;
> +           &nb= sp;   uuid_info->as_char[i] =3D b1;
> +       }
> +}
> +
> +/**
> + *
> + * The amdgpu driver provides a sysfs API for providing uuid data. > + * The file uuid_info is used for this, and returns string of amdgpu = uuid.
> + */
> +static ssize_t amdgpu_get_uuid_info(struct device *dev,
> +           &nb= sp;            =              st= ruct device_attribute *attr,
> +           &nb= sp;            =              ch= ar *buf)
> +{
> +       struct drm_device *ddev =3D dev_= get_drvdata(dev);
> +       struct amdgpu_device *adev =3D d= rm_to_adev(ddev);//ddev->dev_private;
> +       union amdgpu_uuid_info *uuid =3D= &adev->uuid_info;
> +
> +       return sysfs_emit(buf,
> +           &nb= sp;            =             &nb= sp;  "%08x-%04x-%x%03x-%02x%02x-%04x%08x\n",
> +           &nb= sp;            =             &nb= sp;  uuid->time_low,
> +           &nb= sp;            =             &nb= sp;  uuid->time_mid,
> +           &nb= sp;            =             &nb= sp;  uuid->version,
> +           &nb= sp;            =             &nb= sp;  uuid->time_high,
> +           &nb= sp;            =             &nb= sp;  uuid->clk_seq_hi |
> +           &nb= sp;            =             &nb= sp;  uuid->variant << 6,
> +           &nb= sp;            =             &nb= sp;  uuid->clk_seq_low,
> +           &nb= sp;            =             &nb= sp;  uuid->asic_4,
> +           &nb= sp;            =             &nb= sp;  uuid->asic_0);
> +}
> +static DEVICE_ATTR(uuid_info, S_IRUGO, amdgpu_get_uuid_info, NULL); > +
> +static void amdgpu_uuid_init(struct amdgpu_device *adev)
> +{
> +       if (amdgpu_is_uuid_info_empty(&a= mp;adev->uuid_info)) {
> +           &nb= sp;   if (adev->unique_id)
> +           &nb= sp;           amdgpu_gen_= uuid_info(&adev->uuid_info, adev->unique_id, adev->pdev->de= vice, 31);
> +           &nb= sp;   else
> +           &nb= sp;           amdgpu_gen_= uuid_random(&adev->uuid_info);
> +       }
> +}
> +
>  static const struct attribute *amdgpu_dev_attributes[] =3D {
>         &dev_attr_product_= name.attr,
>         &dev_attr_product_= number.attr,
>         &dev_attr_serial_n= umber.attr,
>         &dev_attr_pcie_rep= lay_count.attr,
> +       &dev_attr_uuid_info.attr, >         NULL
>  };
>
> @@ -3551,6 +3645,8 @@ int amdgpu_device_init(struct amdgpu_device *ade= v,
>
>         amdgpu_fbdev_init(adev= );
>
> +       amdgpu_uuid_init(adev);
> +
>         r =3D amdgpu_pm_sysfs_= init(adev);
>         if (r) {
>            = ;     adev->pm_sysfs_en =3D false;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/dr= m/amd/amdgpu/amdgpu_virt.c
> index b71dd1deeb2d..2dfebfe38079 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> @@ -429,6 +429,7 @@ static void amdgpu_virt_add_bad_page(struct amdgpu= _device *adev,
>  static int amdgpu_virt_read_pf2vf_data(struct amdgpu_device *ade= v)
>  {
>         struct amd_sriov_msg_p= f2vf_info_header *pf2vf_info =3D adev->virt.fw_reserve.p_pf2vf;
> +       union amdgpu_uuid_info *uuid =3D= &adev->uuid_info;
>         uint32_t checksum;
>         uint32_t checkval;
>
> @@ -498,6 +499,9 @@ static int amdgpu_virt_read_pf2vf_data(struct amdg= pu_device *adev)
>
>            = ;     adev->unique_id =3D
>            = ;             (= (struct amd_sriov_msg_pf2vf_info *)pf2vf_info)->uuid;
> +
> +           &nb= sp;   memcpy(uuid, &((struct amd_sriov_msg_pf2vf_info *)pf2vf= _info)->uuid_info_reserved,
> +           &nb= sp;           sizeof(unio= n amdgpu_uuid_info));
>            = ;     break;
>         default:
>            = ;     DRM_ERROR("invalid pf2vf version\n"); > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h b/drivers/gpu= /drm/amd/amdgpu/amdgv_sriovmsg.h
> index a434c71fde8e..0d1d36e82aeb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgv_sriovmsg.h
> @@ -203,9 +203,9 @@ struct amd_sriov_msg_pf2vf_info {
>            = ;     uint32_t encode_max_frame_pixels;
>         } mm_bw_management[AMD= _SRIOV_MSG_RESERVE_VCN_INST];
>         /* UUID info */
> -       struct amd_sriov_msg_uuid_info u= uid_info;
> +       uint32_t uuid_info_reserved[4];<= br> >         /* reserved */
> -       uint32_t reserved[256 - 47];
> +       uint32_t reserved[256-47];
>  };
>
>  struct amd_sriov_msg_vf2pf_info_header {
> diff --git a/drivers/gpu/drm/amd/amdgpu/nv.c b/drivers/gpu/drm/amd/amd= gpu/nv.c
> index 32c34470404c..16d4a480f4c0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/nv.c
> +++ b/drivers/gpu/drm/amd/amdgpu/nv.c
> @@ -1167,6 +1167,11 @@ static int nv_common_early_init(void *handle) >            = ;     if (amdgpu_sriov_vf(adev))
>            = ;             a= dev->rev_id =3D 0;
>            = ;     adev->external_rev_id =3D adev->rev_id + 0x= a;
> +           &nb= sp;   if (!amdgpu_sriov_vf(adev)) {
> +           &nb= sp;           adev->un= ique_id =3D RREG32(mmFUSE_DATA_730);
> +           &nb= sp;           adev->un= ique_id <<=3D 32;
> +           &nb= sp;           adev->un= ique_id |=3D RREG32(mmFUSE_DATA_729);
> +           &nb= sp;   }

I would suggest putting this in navi10_get_unique_id() in navi10_ppt.c
for consistency since we query this from the SMU on most other asics.

Alex



>            = ;     break;
>         case CHIP_SIENNA_CICHL= ID:
>            = ;     adev->cg_flags =3D AMD_CG_SUPPORT_GFX_MGCG | > diff --git a/drivers/gpu/drm/amd/amdgpu/nv.h b/drivers/gpu/drm/amd/amd= gpu/nv.h
> index 515d67bf249f..520ac2b98744 100644
> --- a/drivers/gpu/drm/amd/amdgpu/nv.h
> +++ b/drivers/gpu/drm/amd/amdgpu/nv.h
> @@ -26,6 +26,9 @@
>
>  #include "nbio_v2_3.h"
>
> +#define mmFUSE_DATA_729 (0x176D9)
> +#define mmFUSE_DATA_730 (0x176DA)
> +
>  void nv_grbm_select(struct amdgpu_device *adev,
>            = ;         u32 me, u32 pipe, u32 que= ue, u32 vmid);
>  void nv_set_virt_ops(struct amdgpu_device *adev);
> --
> 2.17.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flists.f= reedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=3D04%7C01%7Cdavi= d.nieto%40amd.com%7Cb6a43b8c156c4a6964e208d91a070e84%7C3dd8961fe4884e608e11= a82d994e183d%7C0%7C0%7C637569439877514988%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiM= C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sd= ata=3D7lpRnRgRwKASGUmfr3RChO0P6QfRbcpMFggQl6HO%2Bss%3D&amp;reserved=3D0=

____________________________________________=
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://l=
ists.freedesktop.org/mailman/listinfo/amd-gfx

--_000_BYAPR12MB2840896BAF9A9C1E3AEE0B88F42B9BYAPR12MB2840namp_-- --===============0274452409== 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 --===============0274452409==--