public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: "Lazar, Lijo" <lijo.lazar@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	linux-kernel@vger.kernel.org
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>,
	Javier Martinez Canillas <javierm@redhat.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	Daniel Vetter <daniel@ffwll.ch>,
	Carlos Soriano Sanchez <csoriano@redhat.com>,
	David Airlie <airlied@gmail.com>,
	christian.koenig@amd.com
Subject: Re: [PATCH v4 05/27] drm/amd: Add a new helper for loading/validating microcode
Date: Wed, 4 Jan 2023 10:37:31 +0100	[thread overview]
Message-ID: <a8ed4887-e4f9-7e5e-3fe7-430d3814cc2b@gmail.com> (raw)
In-Reply-To: <151bb1ab-8b2b-afaf-2976-5f60b756c4ca@amd.com>

Am 04.01.23 um 05:53 schrieb Lazar, Lijo:
>
>
> On 1/4/2023 3:48 AM, Mario Limonciello wrote:
>> All microcode runs a basic validation after it's been loaded. Each
>> IP block as part of init will run both.
>>
>> Introduce a wrapper for request_firmware and amdgpu_ucode_validate.
>> This wrapper will also remap any error codes from request_firmware
>> to -ENODEV.  This is so that early_init will fail if firmware couldn't
>> be loaded instead of the IP block being disabled.
>>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> v3-v4:
>>   * New patch
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 24 +++++++++++++++++++++++
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h |  1 +
>>   2 files changed, 25 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
>> index eafcddce58d3..8c4a7b09e344 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
>> @@ -1312,3 +1312,27 @@ void amdgpu_ucode_ip_version_decode(struct 
>> amdgpu_device *adev, int block_type,
>>         snprintf(ucode_prefix, len, "%s_%d_%d_%d", ip_name, maj, min, 
>> rev);
>>   }
>> +
>> +/*
>> + * amdgpu_ucode_load - Load and validate amdgpu microcode
>> + *
>> + * @adev: amdgpu device
>> + * @fw: pointer to load firmware to
>> + * @fw_name: firmware to load
>> + *
>> + * This is a helper that will use request_firmware and 
>> amdgpu_ucode_validate
>> + * to load and run basic validation on firmware. If the load fails, 
>> remap
>> + * the error code to -ENODEV, so that early_init functions will fail 
>> to load.
>> + */
>> +int amdgpu_ucode_load(struct amdgpu_device *adev, const struct 
>> firmware **fw, char *fw_name)
>
> 'load' also takes a different meaning of loading firmware to ASIC. 
> Maybe keep it as 'get' and keep another corresponding common 'put' for 
> release_firmware?

get/put are usually used for reference counting, how about sticking with 
request/release instead? That's used by the underlying functionality as 
well IIRC.

Christian.

>
> Thanks,
> Lijo
>
>> +{
>> +    int err = request_firmware(fw, fw_name, adev->dev);
>> +
>> +    if (err)
>> +        return -ENODEV;
>> +    err = amdgpu_ucode_validate(*fw);
>> +    if (err)
>> +        dev_dbg(adev->dev, "\"%s\" failed to validate\n", fw_name);
>> +
>> +    return err;
>> +}
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
>> index 552e06929229..b9139fb44506 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
>> @@ -544,6 +544,7 @@ void amdgpu_ucode_print_sdma_hdr(const struct 
>> common_firmware_header *hdr);
>>   void amdgpu_ucode_print_psp_hdr(const struct common_firmware_header 
>> *hdr);
>>   void amdgpu_ucode_print_gpu_info_hdr(const struct 
>> common_firmware_header *hdr);
>>   int amdgpu_ucode_validate(const struct firmware *fw);
>> +int amdgpu_ucode_load(struct amdgpu_device *adev, const struct 
>> firmware **fw, char *fw_name);
>>   bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr,
>>                   uint16_t hdr_major, uint16_t hdr_minor);


  reply	other threads:[~2023-01-04  9:38 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 22:18 [PATCH v4 00/27] Recover from failure to probe GPU Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 01/27] drm/amd: Delay removal of the firmware framebuffer Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 02/27] drm/amd: Add a legacy mapping to "amdgpu_ucode_ip_version_decode" Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 03/27] drm/amd: Convert SMUv11 microcode to use `amdgpu_ucode_ip_version_decode` Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 04/27] drm/amd: Convert SMUv13 " Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 05/27] drm/amd: Add a new helper for loading/validating microcode Mario Limonciello
2023-01-04  4:53   ` Lazar, Lijo
2023-01-04  9:37     ` Christian König [this message]
2023-01-03 22:18 ` [PATCH v4 06/27] drm/amd: Use `amdgpu_ucode_load` helper for SDMA Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 07/27] drm/amd: Convert SDMA to use `amdgpu_ucode_ip_version_decode` Mario Limonciello
2023-01-04  4:54   ` Lazar, Lijo
2023-01-03 22:18 ` [PATCH v4 08/27] drm/amd: Make SDMA firmware load failures less noisy Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 09/27] drm/amd: Use `amdgpu_ucode_load` helper for VCN Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 10/27] drm/amd: Load VCN microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 11/27] drm/amd: Load MES " Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 12/27] drm/amd: Use `amdgpu_ucode_load` helper for MES Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 13/27] drm/amd: Remove superfluous assignment for `adev->mes.adev` Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 14/27] drm/amd: Use `amdgpu_ucode_load` helper for GFX9 Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 15/27] drm/amd: Load GFX9 microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 16/27] drm/amd: Use `amdgpu_ucode_load` helper for GFX10 Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 17/27] drm/amd: Load GFX10 microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 18/27] drm/amd: Use `amdgpu_ucode_load` helper for GFX11 Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 19/27] drm/amd: Load GFX11 microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 20/27] drm/amd: Parse both v1 and v2 TA microcode headers using same function Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 21/27] drm/amd: Avoid BUG() for case of SRIOV missing IP version Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 22/27] drm/amd: Load PSP microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 23/27] drm/amd: Use `amdgpu_ucode_load` helper for PSP Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 24/27] drm/amd/display: Load DMUB microcode during early_init Mario Limonciello
2023-01-04 15:52   ` Harry Wentland
2023-01-03 22:18 ` [PATCH v4 25/27] drm/amd: Use `amdgpu_ucode_load` helper for SMU Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 26/27] drm/amd: Load SMU microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 27/27] drm/amd: Optimize SRIOV switch/case for PSP microcode load Mario Limonciello
2023-01-04 13:18   ` Christian König
2023-01-04 15:42     ` Limonciello, Mario

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a8ed4887-e4f9-7e5e-3fe7-430d3814cc2b@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=csoriano@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=lijo.lazar@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox