* [PATCH] drm/amdgpu: Replace deprecated function strcpy() with strscpy()
@ 2025-03-25 0:07 Andres Urian Florez
2025-03-25 8:38 ` Christian König
2025-03-25 14:14 ` Alex Deucher
0 siblings, 2 replies; 6+ messages in thread
From: Andres Urian Florez @ 2025-03-25 0:07 UTC (permalink / raw)
To: alexander.deucher, christian.koenig, airlied, simona,
mario.limonciello, arnd, Tim.Huang
Cc: Andres Urian Florez, skhan, amd-gfx, dri-devel
Instead of using the strcpy() deprecated function to populate the
fw_name, use the strscpy() function
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 68 ++++++++++++-------------
1 file changed, 34 insertions(+), 34 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index 68bce6a6d09d..525e53c94f4f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -253,16 +253,16 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
if (!adev->pm.fw) {
switch (adev->asic_type) {
case CHIP_TAHITI:
- strcpy(fw_name, "radeon/tahiti_smc.bin");
+ strscpy(fw_name, "radeon/tahiti_smc.bin");
break;
case CHIP_PITCAIRN:
if ((adev->pdev->revision == 0x81) &&
((adev->pdev->device == 0x6810) ||
(adev->pdev->device == 0x6811))) {
info->is_kicker = true;
- strcpy(fw_name, "radeon/pitcairn_k_smc.bin");
+ strscpy(fw_name, "radeon/pitcairn_k_smc.bin");
} else {
- strcpy(fw_name, "radeon/pitcairn_smc.bin");
+ strscpy(fw_name, "radeon/pitcairn_smc.bin");
}
break;
case CHIP_VERDE:
@@ -276,9 +276,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
((adev->pdev->device == 0x6823) ||
(adev->pdev->device == 0x682b)))) {
info->is_kicker = true;
- strcpy(fw_name, "radeon/verde_k_smc.bin");
+ strscpy(fw_name, "radeon/verde_k_smc.bin");
} else {
- strcpy(fw_name, "radeon/verde_smc.bin");
+ strscpy(fw_name, "radeon/verde_smc.bin");
}
break;
case CHIP_OLAND:
@@ -290,9 +290,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
((adev->pdev->revision == 0x83) &&
(adev->pdev->device == 0x6610))) {
info->is_kicker = true;
- strcpy(fw_name, "radeon/oland_k_smc.bin");
+ strscpy(fw_name, "radeon/oland_k_smc.bin");
} else {
- strcpy(fw_name, "radeon/oland_smc.bin");
+ strscpy(fw_name, "radeon/oland_smc.bin");
}
break;
case CHIP_HAINAN:
@@ -304,13 +304,13 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
(adev->pdev->device == 0x6665) ||
(adev->pdev->device == 0x6667)))) {
info->is_kicker = true;
- strcpy(fw_name, "radeon/hainan_k_smc.bin");
+ strscpy(fw_name, "radeon/hainan_k_smc.bin");
} else if ((adev->pdev->revision == 0xc3) &&
(adev->pdev->device == 0x6665)) {
info->is_kicker = true;
- strcpy(fw_name, "radeon/banks_k_2_smc.bin");
+ strscpy(fw_name, "radeon/banks_k_2_smc.bin");
} else {
- strcpy(fw_name, "radeon/hainan_smc.bin");
+ strscpy(fw_name, "radeon/hainan_smc.bin");
}
break;
case CHIP_BONAIRE:
@@ -318,17 +318,17 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
(adev->pdev->revision == 0x81) ||
(adev->pdev->device == 0x665f)) {
info->is_kicker = true;
- strcpy(fw_name, "amdgpu/bonaire_k_smc.bin");
+ strscpy(fw_name, "amdgpu/bonaire_k_smc.bin");
} else {
- strcpy(fw_name, "amdgpu/bonaire_smc.bin");
+ strscpy(fw_name, "amdgpu/bonaire_smc.bin");
}
break;
case CHIP_HAWAII:
if (adev->pdev->revision == 0x80) {
info->is_kicker = true;
- strcpy(fw_name, "amdgpu/hawaii_k_smc.bin");
+ strscpy(fw_name, "amdgpu/hawaii_k_smc.bin");
} else {
- strcpy(fw_name, "amdgpu/hawaii_smc.bin");
+ strscpy(fw_name, "amdgpu/hawaii_smc.bin");
}
break;
case CHIP_TOPAZ:
@@ -338,76 +338,76 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD1)) ||
((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD3))) {
info->is_kicker = true;
- strcpy(fw_name, "amdgpu/topaz_k_smc.bin");
+ strscpy(fw_name, "amdgpu/topaz_k_smc.bin");
} else
- strcpy(fw_name, "amdgpu/topaz_smc.bin");
+ strscpy(fw_name, "amdgpu/topaz_smc.bin");
break;
case CHIP_TONGA:
if (((adev->pdev->device == 0x6939) && (adev->pdev->revision == 0xf1)) ||
((adev->pdev->device == 0x6938) && (adev->pdev->revision == 0xf1))) {
info->is_kicker = true;
- strcpy(fw_name, "amdgpu/tonga_k_smc.bin");
+ strscpy(fw_name, "amdgpu/tonga_k_smc.bin");
} else
- strcpy(fw_name, "amdgpu/tonga_smc.bin");
+ strscpy(fw_name, "amdgpu/tonga_smc.bin");
break;
case CHIP_FIJI:
- strcpy(fw_name, "amdgpu/fiji_smc.bin");
+ strscpy(fw_name, "amdgpu/fiji_smc.bin");
break;
case CHIP_POLARIS11:
if (type == CGS_UCODE_ID_SMU) {
if (ASICID_IS_P21(adev->pdev->device, adev->pdev->revision)) {
info->is_kicker = true;
- strcpy(fw_name, "amdgpu/polaris11_k_smc.bin");
+ strscpy(fw_name, "amdgpu/polaris11_k_smc.bin");
} else if (ASICID_IS_P31(adev->pdev->device, adev->pdev->revision)) {
info->is_kicker = true;
- strcpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
+ strscpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
} else {
- strcpy(fw_name, "amdgpu/polaris11_smc.bin");
+ strscpy(fw_name, "amdgpu/polaris11_smc.bin");
}
} else if (type == CGS_UCODE_ID_SMU_SK) {
- strcpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
+ strscpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
}
break;
case CHIP_POLARIS10:
if (type == CGS_UCODE_ID_SMU) {
if (ASICID_IS_P20(adev->pdev->device, adev->pdev->revision)) {
info->is_kicker = true;
- strcpy(fw_name, "amdgpu/polaris10_k_smc.bin");
+ strscpy(fw_name, "amdgpu/polaris10_k_smc.bin");
} else if (ASICID_IS_P30(adev->pdev->device, adev->pdev->revision)) {
info->is_kicker = true;
- strcpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
+ strscpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
} else {
- strcpy(fw_name, "amdgpu/polaris10_smc.bin");
+ strscpy(fw_name, "amdgpu/polaris10_smc.bin");
}
} else if (type == CGS_UCODE_ID_SMU_SK) {
- strcpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
+ strscpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
}
break;
case CHIP_POLARIS12:
if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision)) {
info->is_kicker = true;
- strcpy(fw_name, "amdgpu/polaris12_k_smc.bin");
+ strscpy(fw_name, "amdgpu/polaris12_k_smc.bin");
} else {
- strcpy(fw_name, "amdgpu/polaris12_smc.bin");
+ strscpy(fw_name, "amdgpu/polaris12_smc.bin");
}
break;
case CHIP_VEGAM:
- strcpy(fw_name, "amdgpu/vegam_smc.bin");
+ strscpy(fw_name, "amdgpu/vegam_smc.bin");
break;
case CHIP_VEGA10:
if ((adev->pdev->device == 0x687f) &&
((adev->pdev->revision == 0xc0) ||
(adev->pdev->revision == 0xc1) ||
(adev->pdev->revision == 0xc3)))
- strcpy(fw_name, "amdgpu/vega10_acg_smc.bin");
+ strscpy(fw_name, "amdgpu/vega10_acg_smc.bin");
else
- strcpy(fw_name, "amdgpu/vega10_smc.bin");
+ strscpy(fw_name, "amdgpu/vega10_smc.bin");
break;
case CHIP_VEGA12:
- strcpy(fw_name, "amdgpu/vega12_smc.bin");
+ strscpy(fw_name, "amdgpu/vega12_smc.bin");
break;
case CHIP_VEGA20:
- strcpy(fw_name, "amdgpu/vega20_smc.bin");
+ strscpy(fw_name, "amdgpu/vega20_smc.bin");
break;
default:
DRM_ERROR("SMC firmware not supported\n");
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: Replace deprecated function strcpy() with strscpy()
2025-03-25 0:07 [PATCH] drm/amdgpu: Replace deprecated function strcpy() with strscpy() Andres Urian Florez
@ 2025-03-25 8:38 ` Christian König
2025-03-25 13:30 ` Alex Deucher
2025-03-25 14:14 ` Alex Deucher
1 sibling, 1 reply; 6+ messages in thread
From: Christian König @ 2025-03-25 8:38 UTC (permalink / raw)
To: Andres Urian Florez, alexander.deucher, airlied, simona,
mario.limonciello, arnd, Tim.Huang
Cc: skhan, amd-gfx, dri-devel
Alex shouldn't be try to completely nuke the CGS functions?
Christian.
Am 25.03.25 um 01:07 schrieb Andres Urian Florez:
> Instead of using the strcpy() deprecated function to populate the
> fw_name, use the strscpy() function
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
>
> Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 68 ++++++++++++-------------
> 1 file changed, 34 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> index 68bce6a6d09d..525e53c94f4f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> @@ -253,16 +253,16 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> if (!adev->pm.fw) {
> switch (adev->asic_type) {
> case CHIP_TAHITI:
> - strcpy(fw_name, "radeon/tahiti_smc.bin");
> + strscpy(fw_name, "radeon/tahiti_smc.bin");
> break;
> case CHIP_PITCAIRN:
> if ((adev->pdev->revision == 0x81) &&
> ((adev->pdev->device == 0x6810) ||
> (adev->pdev->device == 0x6811))) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/pitcairn_k_smc.bin");
> + strscpy(fw_name, "radeon/pitcairn_k_smc.bin");
> } else {
> - strcpy(fw_name, "radeon/pitcairn_smc.bin");
> + strscpy(fw_name, "radeon/pitcairn_smc.bin");
> }
> break;
> case CHIP_VERDE:
> @@ -276,9 +276,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> ((adev->pdev->device == 0x6823) ||
> (adev->pdev->device == 0x682b)))) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/verde_k_smc.bin");
> + strscpy(fw_name, "radeon/verde_k_smc.bin");
> } else {
> - strcpy(fw_name, "radeon/verde_smc.bin");
> + strscpy(fw_name, "radeon/verde_smc.bin");
> }
> break;
> case CHIP_OLAND:
> @@ -290,9 +290,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> ((adev->pdev->revision == 0x83) &&
> (adev->pdev->device == 0x6610))) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/oland_k_smc.bin");
> + strscpy(fw_name, "radeon/oland_k_smc.bin");
> } else {
> - strcpy(fw_name, "radeon/oland_smc.bin");
> + strscpy(fw_name, "radeon/oland_smc.bin");
> }
> break;
> case CHIP_HAINAN:
> @@ -304,13 +304,13 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> (adev->pdev->device == 0x6665) ||
> (adev->pdev->device == 0x6667)))) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/hainan_k_smc.bin");
> + strscpy(fw_name, "radeon/hainan_k_smc.bin");
> } else if ((adev->pdev->revision == 0xc3) &&
> (adev->pdev->device == 0x6665)) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/banks_k_2_smc.bin");
> + strscpy(fw_name, "radeon/banks_k_2_smc.bin");
> } else {
> - strcpy(fw_name, "radeon/hainan_smc.bin");
> + strscpy(fw_name, "radeon/hainan_smc.bin");
> }
> break;
> case CHIP_BONAIRE:
> @@ -318,17 +318,17 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> (adev->pdev->revision == 0x81) ||
> (adev->pdev->device == 0x665f)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/bonaire_k_smc.bin");
> + strscpy(fw_name, "amdgpu/bonaire_k_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/bonaire_smc.bin");
> + strscpy(fw_name, "amdgpu/bonaire_smc.bin");
> }
> break;
> case CHIP_HAWAII:
> if (adev->pdev->revision == 0x80) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/hawaii_k_smc.bin");
> + strscpy(fw_name, "amdgpu/hawaii_k_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/hawaii_smc.bin");
> + strscpy(fw_name, "amdgpu/hawaii_smc.bin");
> }
> break;
> case CHIP_TOPAZ:
> @@ -338,76 +338,76 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD1)) ||
> ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD3))) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/topaz_k_smc.bin");
> + strscpy(fw_name, "amdgpu/topaz_k_smc.bin");
> } else
> - strcpy(fw_name, "amdgpu/topaz_smc.bin");
> + strscpy(fw_name, "amdgpu/topaz_smc.bin");
> break;
> case CHIP_TONGA:
> if (((adev->pdev->device == 0x6939) && (adev->pdev->revision == 0xf1)) ||
> ((adev->pdev->device == 0x6938) && (adev->pdev->revision == 0xf1))) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/tonga_k_smc.bin");
> + strscpy(fw_name, "amdgpu/tonga_k_smc.bin");
> } else
> - strcpy(fw_name, "amdgpu/tonga_smc.bin");
> + strscpy(fw_name, "amdgpu/tonga_smc.bin");
> break;
> case CHIP_FIJI:
> - strcpy(fw_name, "amdgpu/fiji_smc.bin");
> + strscpy(fw_name, "amdgpu/fiji_smc.bin");
> break;
> case CHIP_POLARIS11:
> if (type == CGS_UCODE_ID_SMU) {
> if (ASICID_IS_P21(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris11_k_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris11_k_smc.bin");
> } else if (ASICID_IS_P31(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/polaris11_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris11_smc.bin");
> }
> } else if (type == CGS_UCODE_ID_SMU_SK) {
> - strcpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
> + strscpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
> }
> break;
> case CHIP_POLARIS10:
> if (type == CGS_UCODE_ID_SMU) {
> if (ASICID_IS_P20(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris10_k_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris10_k_smc.bin");
> } else if (ASICID_IS_P30(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/polaris10_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris10_smc.bin");
> }
> } else if (type == CGS_UCODE_ID_SMU_SK) {
> - strcpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
> + strscpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
> }
> break;
> case CHIP_POLARIS12:
> if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris12_k_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris12_k_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/polaris12_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris12_smc.bin");
> }
> break;
> case CHIP_VEGAM:
> - strcpy(fw_name, "amdgpu/vegam_smc.bin");
> + strscpy(fw_name, "amdgpu/vegam_smc.bin");
> break;
> case CHIP_VEGA10:
> if ((adev->pdev->device == 0x687f) &&
> ((adev->pdev->revision == 0xc0) ||
> (adev->pdev->revision == 0xc1) ||
> (adev->pdev->revision == 0xc3)))
> - strcpy(fw_name, "amdgpu/vega10_acg_smc.bin");
> + strscpy(fw_name, "amdgpu/vega10_acg_smc.bin");
> else
> - strcpy(fw_name, "amdgpu/vega10_smc.bin");
> + strscpy(fw_name, "amdgpu/vega10_smc.bin");
> break;
> case CHIP_VEGA12:
> - strcpy(fw_name, "amdgpu/vega12_smc.bin");
> + strscpy(fw_name, "amdgpu/vega12_smc.bin");
> break;
> case CHIP_VEGA20:
> - strcpy(fw_name, "amdgpu/vega20_smc.bin");
> + strscpy(fw_name, "amdgpu/vega20_smc.bin");
> break;
> default:
> DRM_ERROR("SMC firmware not supported\n");
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: Replace deprecated function strcpy() with strscpy()
2025-03-25 8:38 ` Christian König
@ 2025-03-25 13:30 ` Alex Deucher
2025-03-25 13:50 ` Christian König
0 siblings, 1 reply; 6+ messages in thread
From: Alex Deucher @ 2025-03-25 13:30 UTC (permalink / raw)
To: Christian König
Cc: Andres Urian Florez, alexander.deucher, airlied, simona,
mario.limonciello, arnd, Tim.Huang, skhan, amd-gfx, dri-devel
On Tue, Mar 25, 2025 at 4:38 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Alex shouldn't be try to completely nuke the CGS functions?
Sure, but it would need to be replaced with something else so I'm not
sure it's worth the effort since it's only used by a few older GPUs.
Alex
>
> Christian.
>
> Am 25.03.25 um 01:07 schrieb Andres Urian Florez:
> > Instead of using the strcpy() deprecated function to populate the
> > fw_name, use the strscpy() function
> >
> > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
> >
> > Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 68 ++++++++++++-------------
> > 1 file changed, 34 insertions(+), 34 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> > index 68bce6a6d09d..525e53c94f4f 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> > @@ -253,16 +253,16 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> > if (!adev->pm.fw) {
> > switch (adev->asic_type) {
> > case CHIP_TAHITI:
> > - strcpy(fw_name, "radeon/tahiti_smc.bin");
> > + strscpy(fw_name, "radeon/tahiti_smc.bin");
> > break;
> > case CHIP_PITCAIRN:
> > if ((adev->pdev->revision == 0x81) &&
> > ((adev->pdev->device == 0x6810) ||
> > (adev->pdev->device == 0x6811))) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "radeon/pitcairn_k_smc.bin");
> > + strscpy(fw_name, "radeon/pitcairn_k_smc.bin");
> > } else {
> > - strcpy(fw_name, "radeon/pitcairn_smc.bin");
> > + strscpy(fw_name, "radeon/pitcairn_smc.bin");
> > }
> > break;
> > case CHIP_VERDE:
> > @@ -276,9 +276,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> > ((adev->pdev->device == 0x6823) ||
> > (adev->pdev->device == 0x682b)))) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "radeon/verde_k_smc.bin");
> > + strscpy(fw_name, "radeon/verde_k_smc.bin");
> > } else {
> > - strcpy(fw_name, "radeon/verde_smc.bin");
> > + strscpy(fw_name, "radeon/verde_smc.bin");
> > }
> > break;
> > case CHIP_OLAND:
> > @@ -290,9 +290,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> > ((adev->pdev->revision == 0x83) &&
> > (adev->pdev->device == 0x6610))) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "radeon/oland_k_smc.bin");
> > + strscpy(fw_name, "radeon/oland_k_smc.bin");
> > } else {
> > - strcpy(fw_name, "radeon/oland_smc.bin");
> > + strscpy(fw_name, "radeon/oland_smc.bin");
> > }
> > break;
> > case CHIP_HAINAN:
> > @@ -304,13 +304,13 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> > (adev->pdev->device == 0x6665) ||
> > (adev->pdev->device == 0x6667)))) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "radeon/hainan_k_smc.bin");
> > + strscpy(fw_name, "radeon/hainan_k_smc.bin");
> > } else if ((adev->pdev->revision == 0xc3) &&
> > (adev->pdev->device == 0x6665)) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "radeon/banks_k_2_smc.bin");
> > + strscpy(fw_name, "radeon/banks_k_2_smc.bin");
> > } else {
> > - strcpy(fw_name, "radeon/hainan_smc.bin");
> > + strscpy(fw_name, "radeon/hainan_smc.bin");
> > }
> > break;
> > case CHIP_BONAIRE:
> > @@ -318,17 +318,17 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> > (adev->pdev->revision == 0x81) ||
> > (adev->pdev->device == 0x665f)) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "amdgpu/bonaire_k_smc.bin");
> > + strscpy(fw_name, "amdgpu/bonaire_k_smc.bin");
> > } else {
> > - strcpy(fw_name, "amdgpu/bonaire_smc.bin");
> > + strscpy(fw_name, "amdgpu/bonaire_smc.bin");
> > }
> > break;
> > case CHIP_HAWAII:
> > if (adev->pdev->revision == 0x80) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "amdgpu/hawaii_k_smc.bin");
> > + strscpy(fw_name, "amdgpu/hawaii_k_smc.bin");
> > } else {
> > - strcpy(fw_name, "amdgpu/hawaii_smc.bin");
> > + strscpy(fw_name, "amdgpu/hawaii_smc.bin");
> > }
> > break;
> > case CHIP_TOPAZ:
> > @@ -338,76 +338,76 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> > ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD1)) ||
> > ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD3))) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "amdgpu/topaz_k_smc.bin");
> > + strscpy(fw_name, "amdgpu/topaz_k_smc.bin");
> > } else
> > - strcpy(fw_name, "amdgpu/topaz_smc.bin");
> > + strscpy(fw_name, "amdgpu/topaz_smc.bin");
> > break;
> > case CHIP_TONGA:
> > if (((adev->pdev->device == 0x6939) && (adev->pdev->revision == 0xf1)) ||
> > ((adev->pdev->device == 0x6938) && (adev->pdev->revision == 0xf1))) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "amdgpu/tonga_k_smc.bin");
> > + strscpy(fw_name, "amdgpu/tonga_k_smc.bin");
> > } else
> > - strcpy(fw_name, "amdgpu/tonga_smc.bin");
> > + strscpy(fw_name, "amdgpu/tonga_smc.bin");
> > break;
> > case CHIP_FIJI:
> > - strcpy(fw_name, "amdgpu/fiji_smc.bin");
> > + strscpy(fw_name, "amdgpu/fiji_smc.bin");
> > break;
> > case CHIP_POLARIS11:
> > if (type == CGS_UCODE_ID_SMU) {
> > if (ASICID_IS_P21(adev->pdev->device, adev->pdev->revision)) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "amdgpu/polaris11_k_smc.bin");
> > + strscpy(fw_name, "amdgpu/polaris11_k_smc.bin");
> > } else if (ASICID_IS_P31(adev->pdev->device, adev->pdev->revision)) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
> > + strscpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
> > } else {
> > - strcpy(fw_name, "amdgpu/polaris11_smc.bin");
> > + strscpy(fw_name, "amdgpu/polaris11_smc.bin");
> > }
> > } else if (type == CGS_UCODE_ID_SMU_SK) {
> > - strcpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
> > + strscpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
> > }
> > break;
> > case CHIP_POLARIS10:
> > if (type == CGS_UCODE_ID_SMU) {
> > if (ASICID_IS_P20(adev->pdev->device, adev->pdev->revision)) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "amdgpu/polaris10_k_smc.bin");
> > + strscpy(fw_name, "amdgpu/polaris10_k_smc.bin");
> > } else if (ASICID_IS_P30(adev->pdev->device, adev->pdev->revision)) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
> > + strscpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
> > } else {
> > - strcpy(fw_name, "amdgpu/polaris10_smc.bin");
> > + strscpy(fw_name, "amdgpu/polaris10_smc.bin");
> > }
> > } else if (type == CGS_UCODE_ID_SMU_SK) {
> > - strcpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
> > + strscpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
> > }
> > break;
> > case CHIP_POLARIS12:
> > if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision)) {
> > info->is_kicker = true;
> > - strcpy(fw_name, "amdgpu/polaris12_k_smc.bin");
> > + strscpy(fw_name, "amdgpu/polaris12_k_smc.bin");
> > } else {
> > - strcpy(fw_name, "amdgpu/polaris12_smc.bin");
> > + strscpy(fw_name, "amdgpu/polaris12_smc.bin");
> > }
> > break;
> > case CHIP_VEGAM:
> > - strcpy(fw_name, "amdgpu/vegam_smc.bin");
> > + strscpy(fw_name, "amdgpu/vegam_smc.bin");
> > break;
> > case CHIP_VEGA10:
> > if ((adev->pdev->device == 0x687f) &&
> > ((adev->pdev->revision == 0xc0) ||
> > (adev->pdev->revision == 0xc1) ||
> > (adev->pdev->revision == 0xc3)))
> > - strcpy(fw_name, "amdgpu/vega10_acg_smc.bin");
> > + strscpy(fw_name, "amdgpu/vega10_acg_smc.bin");
> > else
> > - strcpy(fw_name, "amdgpu/vega10_smc.bin");
> > + strscpy(fw_name, "amdgpu/vega10_smc.bin");
> > break;
> > case CHIP_VEGA12:
> > - strcpy(fw_name, "amdgpu/vega12_smc.bin");
> > + strscpy(fw_name, "amdgpu/vega12_smc.bin");
> > break;
> > case CHIP_VEGA20:
> > - strcpy(fw_name, "amdgpu/vega20_smc.bin");
> > + strscpy(fw_name, "amdgpu/vega20_smc.bin");
> > break;
> > default:
> > DRM_ERROR("SMC firmware not supported\n");
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: Replace deprecated function strcpy() with strscpy()
2025-03-25 13:30 ` Alex Deucher
@ 2025-03-25 13:50 ` Christian König
2025-03-25 13:59 ` Alex Deucher
0 siblings, 1 reply; 6+ messages in thread
From: Christian König @ 2025-03-25 13:50 UTC (permalink / raw)
To: Alex Deucher
Cc: Andres Urian Florez, alexander.deucher, airlied, simona,
mario.limonciello, arnd, Tim.Huang, skhan, amd-gfx, dri-devel
Am 25.03.25 um 14:30 schrieb Alex Deucher:
> On Tue, Mar 25, 2025 at 4:38 AM Christian König
> <christian.koenig@amd.com> wrote:
>> Alex shouldn't be try to completely nuke the CGS functions?
> Sure, but it would need to be replaced with something else so I'm not
> sure it's worth the effort since it's only used by a few older GPUs.
Well how about at least nuking this code here? Take a closer look it's trying to pull in firmware from "radeon/*".
That is certainly not used :)
Christian.
>
> Alex
>
>> Christian.
>>
>> Am 25.03.25 um 01:07 schrieb Andres Urian Florez:
>>> Instead of using the strcpy() deprecated function to populate the
>>> fw_name, use the strscpy() function
>>>
>>> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
>>>
>>> Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
>>> ---
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 68 ++++++++++++-------------
>>> 1 file changed, 34 insertions(+), 34 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
>>> index 68bce6a6d09d..525e53c94f4f 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
>>> @@ -253,16 +253,16 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
>>> if (!adev->pm.fw) {
>>> switch (adev->asic_type) {
>>> case CHIP_TAHITI:
>>> - strcpy(fw_name, "radeon/tahiti_smc.bin");
>>> + strscpy(fw_name, "radeon/tahiti_smc.bin");
>>> break;
>>> case CHIP_PITCAIRN:
>>> if ((adev->pdev->revision == 0x81) &&
>>> ((adev->pdev->device == 0x6810) ||
>>> (adev->pdev->device == 0x6811))) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "radeon/pitcairn_k_smc.bin");
>>> + strscpy(fw_name, "radeon/pitcairn_k_smc.bin");
>>> } else {
>>> - strcpy(fw_name, "radeon/pitcairn_smc.bin");
>>> + strscpy(fw_name, "radeon/pitcairn_smc.bin");
>>> }
>>> break;
>>> case CHIP_VERDE:
>>> @@ -276,9 +276,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
>>> ((adev->pdev->device == 0x6823) ||
>>> (adev->pdev->device == 0x682b)))) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "radeon/verde_k_smc.bin");
>>> + strscpy(fw_name, "radeon/verde_k_smc.bin");
>>> } else {
>>> - strcpy(fw_name, "radeon/verde_smc.bin");
>>> + strscpy(fw_name, "radeon/verde_smc.bin");
>>> }
>>> break;
>>> case CHIP_OLAND:
>>> @@ -290,9 +290,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
>>> ((adev->pdev->revision == 0x83) &&
>>> (adev->pdev->device == 0x6610))) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "radeon/oland_k_smc.bin");
>>> + strscpy(fw_name, "radeon/oland_k_smc.bin");
>>> } else {
>>> - strcpy(fw_name, "radeon/oland_smc.bin");
>>> + strscpy(fw_name, "radeon/oland_smc.bin");
>>> }
>>> break;
>>> case CHIP_HAINAN:
>>> @@ -304,13 +304,13 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
>>> (adev->pdev->device == 0x6665) ||
>>> (adev->pdev->device == 0x6667)))) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "radeon/hainan_k_smc.bin");
>>> + strscpy(fw_name, "radeon/hainan_k_smc.bin");
>>> } else if ((adev->pdev->revision == 0xc3) &&
>>> (adev->pdev->device == 0x6665)) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "radeon/banks_k_2_smc.bin");
>>> + strscpy(fw_name, "radeon/banks_k_2_smc.bin");
>>> } else {
>>> - strcpy(fw_name, "radeon/hainan_smc.bin");
>>> + strscpy(fw_name, "radeon/hainan_smc.bin");
>>> }
>>> break;
>>> case CHIP_BONAIRE:
>>> @@ -318,17 +318,17 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
>>> (adev->pdev->revision == 0x81) ||
>>> (adev->pdev->device == 0x665f)) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "amdgpu/bonaire_k_smc.bin");
>>> + strscpy(fw_name, "amdgpu/bonaire_k_smc.bin");
>>> } else {
>>> - strcpy(fw_name, "amdgpu/bonaire_smc.bin");
>>> + strscpy(fw_name, "amdgpu/bonaire_smc.bin");
>>> }
>>> break;
>>> case CHIP_HAWAII:
>>> if (adev->pdev->revision == 0x80) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "amdgpu/hawaii_k_smc.bin");
>>> + strscpy(fw_name, "amdgpu/hawaii_k_smc.bin");
>>> } else {
>>> - strcpy(fw_name, "amdgpu/hawaii_smc.bin");
>>> + strscpy(fw_name, "amdgpu/hawaii_smc.bin");
>>> }
>>> break;
>>> case CHIP_TOPAZ:
>>> @@ -338,76 +338,76 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
>>> ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD1)) ||
>>> ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD3))) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "amdgpu/topaz_k_smc.bin");
>>> + strscpy(fw_name, "amdgpu/topaz_k_smc.bin");
>>> } else
>>> - strcpy(fw_name, "amdgpu/topaz_smc.bin");
>>> + strscpy(fw_name, "amdgpu/topaz_smc.bin");
>>> break;
>>> case CHIP_TONGA:
>>> if (((adev->pdev->device == 0x6939) && (adev->pdev->revision == 0xf1)) ||
>>> ((adev->pdev->device == 0x6938) && (adev->pdev->revision == 0xf1))) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "amdgpu/tonga_k_smc.bin");
>>> + strscpy(fw_name, "amdgpu/tonga_k_smc.bin");
>>> } else
>>> - strcpy(fw_name, "amdgpu/tonga_smc.bin");
>>> + strscpy(fw_name, "amdgpu/tonga_smc.bin");
>>> break;
>>> case CHIP_FIJI:
>>> - strcpy(fw_name, "amdgpu/fiji_smc.bin");
>>> + strscpy(fw_name, "amdgpu/fiji_smc.bin");
>>> break;
>>> case CHIP_POLARIS11:
>>> if (type == CGS_UCODE_ID_SMU) {
>>> if (ASICID_IS_P21(adev->pdev->device, adev->pdev->revision)) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "amdgpu/polaris11_k_smc.bin");
>>> + strscpy(fw_name, "amdgpu/polaris11_k_smc.bin");
>>> } else if (ASICID_IS_P31(adev->pdev->device, adev->pdev->revision)) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
>>> + strscpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
>>> } else {
>>> - strcpy(fw_name, "amdgpu/polaris11_smc.bin");
>>> + strscpy(fw_name, "amdgpu/polaris11_smc.bin");
>>> }
>>> } else if (type == CGS_UCODE_ID_SMU_SK) {
>>> - strcpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
>>> + strscpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
>>> }
>>> break;
>>> case CHIP_POLARIS10:
>>> if (type == CGS_UCODE_ID_SMU) {
>>> if (ASICID_IS_P20(adev->pdev->device, adev->pdev->revision)) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "amdgpu/polaris10_k_smc.bin");
>>> + strscpy(fw_name, "amdgpu/polaris10_k_smc.bin");
>>> } else if (ASICID_IS_P30(adev->pdev->device, adev->pdev->revision)) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
>>> + strscpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
>>> } else {
>>> - strcpy(fw_name, "amdgpu/polaris10_smc.bin");
>>> + strscpy(fw_name, "amdgpu/polaris10_smc.bin");
>>> }
>>> } else if (type == CGS_UCODE_ID_SMU_SK) {
>>> - strcpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
>>> + strscpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
>>> }
>>> break;
>>> case CHIP_POLARIS12:
>>> if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision)) {
>>> info->is_kicker = true;
>>> - strcpy(fw_name, "amdgpu/polaris12_k_smc.bin");
>>> + strscpy(fw_name, "amdgpu/polaris12_k_smc.bin");
>>> } else {
>>> - strcpy(fw_name, "amdgpu/polaris12_smc.bin");
>>> + strscpy(fw_name, "amdgpu/polaris12_smc.bin");
>>> }
>>> break;
>>> case CHIP_VEGAM:
>>> - strcpy(fw_name, "amdgpu/vegam_smc.bin");
>>> + strscpy(fw_name, "amdgpu/vegam_smc.bin");
>>> break;
>>> case CHIP_VEGA10:
>>> if ((adev->pdev->device == 0x687f) &&
>>> ((adev->pdev->revision == 0xc0) ||
>>> (adev->pdev->revision == 0xc1) ||
>>> (adev->pdev->revision == 0xc3)))
>>> - strcpy(fw_name, "amdgpu/vega10_acg_smc.bin");
>>> + strscpy(fw_name, "amdgpu/vega10_acg_smc.bin");
>>> else
>>> - strcpy(fw_name, "amdgpu/vega10_smc.bin");
>>> + strscpy(fw_name, "amdgpu/vega10_smc.bin");
>>> break;
>>> case CHIP_VEGA12:
>>> - strcpy(fw_name, "amdgpu/vega12_smc.bin");
>>> + strscpy(fw_name, "amdgpu/vega12_smc.bin");
>>> break;
>>> case CHIP_VEGA20:
>>> - strcpy(fw_name, "amdgpu/vega20_smc.bin");
>>> + strscpy(fw_name, "amdgpu/vega20_smc.bin");
>>> break;
>>> default:
>>> DRM_ERROR("SMC firmware not supported\n");
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: Replace deprecated function strcpy() with strscpy()
2025-03-25 13:50 ` Christian König
@ 2025-03-25 13:59 ` Alex Deucher
0 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2025-03-25 13:59 UTC (permalink / raw)
To: Christian König
Cc: Andres Urian Florez, alexander.deucher, airlied, simona,
mario.limonciello, arnd, Tim.Huang, skhan, amd-gfx, dri-devel
On Tue, Mar 25, 2025 at 9:50 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 25.03.25 um 14:30 schrieb Alex Deucher:
> > On Tue, Mar 25, 2025 at 4:38 AM Christian König
> > <christian.koenig@amd.com> wrote:
> >> Alex shouldn't be try to completely nuke the CGS functions?
> > Sure, but it would need to be replaced with something else so I'm not
> > sure it's worth the effort since it's only used by a few older GPUs.
>
> Well how about at least nuking this code here? Take a closer look it's trying to pull in firmware from "radeon/*".
>
> That is certainly not used :)
Yes, that can be removed.
Alex
>
> Christian.
>
> >
> > Alex
> >
> >> Christian.
> >>
> >> Am 25.03.25 um 01:07 schrieb Andres Urian Florez:
> >>> Instead of using the strcpy() deprecated function to populate the
> >>> fw_name, use the strscpy() function
> >>>
> >>> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
> >>>
> >>> Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
> >>> ---
> >>> drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 68 ++++++++++++-------------
> >>> 1 file changed, 34 insertions(+), 34 deletions(-)
> >>>
> >>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> >>> index 68bce6a6d09d..525e53c94f4f 100644
> >>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> >>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> >>> @@ -253,16 +253,16 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> >>> if (!adev->pm.fw) {
> >>> switch (adev->asic_type) {
> >>> case CHIP_TAHITI:
> >>> - strcpy(fw_name, "radeon/tahiti_smc.bin");
> >>> + strscpy(fw_name, "radeon/tahiti_smc.bin");
> >>> break;
> >>> case CHIP_PITCAIRN:
> >>> if ((adev->pdev->revision == 0x81) &&
> >>> ((adev->pdev->device == 0x6810) ||
> >>> (adev->pdev->device == 0x6811))) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "radeon/pitcairn_k_smc.bin");
> >>> + strscpy(fw_name, "radeon/pitcairn_k_smc.bin");
> >>> } else {
> >>> - strcpy(fw_name, "radeon/pitcairn_smc.bin");
> >>> + strscpy(fw_name, "radeon/pitcairn_smc.bin");
> >>> }
> >>> break;
> >>> case CHIP_VERDE:
> >>> @@ -276,9 +276,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> >>> ((adev->pdev->device == 0x6823) ||
> >>> (adev->pdev->device == 0x682b)))) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "radeon/verde_k_smc.bin");
> >>> + strscpy(fw_name, "radeon/verde_k_smc.bin");
> >>> } else {
> >>> - strcpy(fw_name, "radeon/verde_smc.bin");
> >>> + strscpy(fw_name, "radeon/verde_smc.bin");
> >>> }
> >>> break;
> >>> case CHIP_OLAND:
> >>> @@ -290,9 +290,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> >>> ((adev->pdev->revision == 0x83) &&
> >>> (adev->pdev->device == 0x6610))) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "radeon/oland_k_smc.bin");
> >>> + strscpy(fw_name, "radeon/oland_k_smc.bin");
> >>> } else {
> >>> - strcpy(fw_name, "radeon/oland_smc.bin");
> >>> + strscpy(fw_name, "radeon/oland_smc.bin");
> >>> }
> >>> break;
> >>> case CHIP_HAINAN:
> >>> @@ -304,13 +304,13 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> >>> (adev->pdev->device == 0x6665) ||
> >>> (adev->pdev->device == 0x6667)))) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "radeon/hainan_k_smc.bin");
> >>> + strscpy(fw_name, "radeon/hainan_k_smc.bin");
> >>> } else if ((adev->pdev->revision == 0xc3) &&
> >>> (adev->pdev->device == 0x6665)) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "radeon/banks_k_2_smc.bin");
> >>> + strscpy(fw_name, "radeon/banks_k_2_smc.bin");
> >>> } else {
> >>> - strcpy(fw_name, "radeon/hainan_smc.bin");
> >>> + strscpy(fw_name, "radeon/hainan_smc.bin");
> >>> }
> >>> break;
> >>> case CHIP_BONAIRE:
> >>> @@ -318,17 +318,17 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> >>> (adev->pdev->revision == 0x81) ||
> >>> (adev->pdev->device == 0x665f)) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "amdgpu/bonaire_k_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/bonaire_k_smc.bin");
> >>> } else {
> >>> - strcpy(fw_name, "amdgpu/bonaire_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/bonaire_smc.bin");
> >>> }
> >>> break;
> >>> case CHIP_HAWAII:
> >>> if (adev->pdev->revision == 0x80) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "amdgpu/hawaii_k_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/hawaii_k_smc.bin");
> >>> } else {
> >>> - strcpy(fw_name, "amdgpu/hawaii_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/hawaii_smc.bin");
> >>> }
> >>> break;
> >>> case CHIP_TOPAZ:
> >>> @@ -338,76 +338,76 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> >>> ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD1)) ||
> >>> ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD3))) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "amdgpu/topaz_k_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/topaz_k_smc.bin");
> >>> } else
> >>> - strcpy(fw_name, "amdgpu/topaz_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/topaz_smc.bin");
> >>> break;
> >>> case CHIP_TONGA:
> >>> if (((adev->pdev->device == 0x6939) && (adev->pdev->revision == 0xf1)) ||
> >>> ((adev->pdev->device == 0x6938) && (adev->pdev->revision == 0xf1))) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "amdgpu/tonga_k_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/tonga_k_smc.bin");
> >>> } else
> >>> - strcpy(fw_name, "amdgpu/tonga_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/tonga_smc.bin");
> >>> break;
> >>> case CHIP_FIJI:
> >>> - strcpy(fw_name, "amdgpu/fiji_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/fiji_smc.bin");
> >>> break;
> >>> case CHIP_POLARIS11:
> >>> if (type == CGS_UCODE_ID_SMU) {
> >>> if (ASICID_IS_P21(adev->pdev->device, adev->pdev->revision)) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "amdgpu/polaris11_k_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris11_k_smc.bin");
> >>> } else if (ASICID_IS_P31(adev->pdev->device, adev->pdev->revision)) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
> >>> } else {
> >>> - strcpy(fw_name, "amdgpu/polaris11_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris11_smc.bin");
> >>> }
> >>> } else if (type == CGS_UCODE_ID_SMU_SK) {
> >>> - strcpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
> >>> }
> >>> break;
> >>> case CHIP_POLARIS10:
> >>> if (type == CGS_UCODE_ID_SMU) {
> >>> if (ASICID_IS_P20(adev->pdev->device, adev->pdev->revision)) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "amdgpu/polaris10_k_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris10_k_smc.bin");
> >>> } else if (ASICID_IS_P30(adev->pdev->device, adev->pdev->revision)) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
> >>> } else {
> >>> - strcpy(fw_name, "amdgpu/polaris10_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris10_smc.bin");
> >>> }
> >>> } else if (type == CGS_UCODE_ID_SMU_SK) {
> >>> - strcpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
> >>> }
> >>> break;
> >>> case CHIP_POLARIS12:
> >>> if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision)) {
> >>> info->is_kicker = true;
> >>> - strcpy(fw_name, "amdgpu/polaris12_k_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris12_k_smc.bin");
> >>> } else {
> >>> - strcpy(fw_name, "amdgpu/polaris12_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/polaris12_smc.bin");
> >>> }
> >>> break;
> >>> case CHIP_VEGAM:
> >>> - strcpy(fw_name, "amdgpu/vegam_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/vegam_smc.bin");
> >>> break;
> >>> case CHIP_VEGA10:
> >>> if ((adev->pdev->device == 0x687f) &&
> >>> ((adev->pdev->revision == 0xc0) ||
> >>> (adev->pdev->revision == 0xc1) ||
> >>> (adev->pdev->revision == 0xc3)))
> >>> - strcpy(fw_name, "amdgpu/vega10_acg_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/vega10_acg_smc.bin");
> >>> else
> >>> - strcpy(fw_name, "amdgpu/vega10_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/vega10_smc.bin");
> >>> break;
> >>> case CHIP_VEGA12:
> >>> - strcpy(fw_name, "amdgpu/vega12_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/vega12_smc.bin");
> >>> break;
> >>> case CHIP_VEGA20:
> >>> - strcpy(fw_name, "amdgpu/vega20_smc.bin");
> >>> + strscpy(fw_name, "amdgpu/vega20_smc.bin");
> >>> break;
> >>> default:
> >>> DRM_ERROR("SMC firmware not supported\n");
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/amdgpu: Replace deprecated function strcpy() with strscpy()
2025-03-25 0:07 [PATCH] drm/amdgpu: Replace deprecated function strcpy() with strscpy() Andres Urian Florez
2025-03-25 8:38 ` Christian König
@ 2025-03-25 14:14 ` Alex Deucher
1 sibling, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2025-03-25 14:14 UTC (permalink / raw)
To: Andres Urian Florez
Cc: alexander.deucher, christian.koenig, airlied, simona,
mario.limonciello, arnd, Tim.Huang, skhan, amd-gfx, dri-devel
Applied. Thanks!
Alex
On Mon, Mar 24, 2025 at 8:08 PM Andres Urian Florez
<andres.emb.sys@gmail.com> wrote:
>
> Instead of using the strcpy() deprecated function to populate the
> fw_name, use the strscpy() function
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
>
> Signed-off-by: Andres Urian Florez <andres.emb.sys@gmail.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 68 ++++++++++++-------------
> 1 file changed, 34 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> index 68bce6a6d09d..525e53c94f4f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
> @@ -253,16 +253,16 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> if (!adev->pm.fw) {
> switch (adev->asic_type) {
> case CHIP_TAHITI:
> - strcpy(fw_name, "radeon/tahiti_smc.bin");
> + strscpy(fw_name, "radeon/tahiti_smc.bin");
> break;
> case CHIP_PITCAIRN:
> if ((adev->pdev->revision == 0x81) &&
> ((adev->pdev->device == 0x6810) ||
> (adev->pdev->device == 0x6811))) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/pitcairn_k_smc.bin");
> + strscpy(fw_name, "radeon/pitcairn_k_smc.bin");
> } else {
> - strcpy(fw_name, "radeon/pitcairn_smc.bin");
> + strscpy(fw_name, "radeon/pitcairn_smc.bin");
> }
> break;
> case CHIP_VERDE:
> @@ -276,9 +276,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> ((adev->pdev->device == 0x6823) ||
> (adev->pdev->device == 0x682b)))) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/verde_k_smc.bin");
> + strscpy(fw_name, "radeon/verde_k_smc.bin");
> } else {
> - strcpy(fw_name, "radeon/verde_smc.bin");
> + strscpy(fw_name, "radeon/verde_smc.bin");
> }
> break;
> case CHIP_OLAND:
> @@ -290,9 +290,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> ((adev->pdev->revision == 0x83) &&
> (adev->pdev->device == 0x6610))) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/oland_k_smc.bin");
> + strscpy(fw_name, "radeon/oland_k_smc.bin");
> } else {
> - strcpy(fw_name, "radeon/oland_smc.bin");
> + strscpy(fw_name, "radeon/oland_smc.bin");
> }
> break;
> case CHIP_HAINAN:
> @@ -304,13 +304,13 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> (adev->pdev->device == 0x6665) ||
> (adev->pdev->device == 0x6667)))) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/hainan_k_smc.bin");
> + strscpy(fw_name, "radeon/hainan_k_smc.bin");
> } else if ((adev->pdev->revision == 0xc3) &&
> (adev->pdev->device == 0x6665)) {
> info->is_kicker = true;
> - strcpy(fw_name, "radeon/banks_k_2_smc.bin");
> + strscpy(fw_name, "radeon/banks_k_2_smc.bin");
> } else {
> - strcpy(fw_name, "radeon/hainan_smc.bin");
> + strscpy(fw_name, "radeon/hainan_smc.bin");
> }
> break;
> case CHIP_BONAIRE:
> @@ -318,17 +318,17 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> (adev->pdev->revision == 0x81) ||
> (adev->pdev->device == 0x665f)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/bonaire_k_smc.bin");
> + strscpy(fw_name, "amdgpu/bonaire_k_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/bonaire_smc.bin");
> + strscpy(fw_name, "amdgpu/bonaire_smc.bin");
> }
> break;
> case CHIP_HAWAII:
> if (adev->pdev->revision == 0x80) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/hawaii_k_smc.bin");
> + strscpy(fw_name, "amdgpu/hawaii_k_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/hawaii_smc.bin");
> + strscpy(fw_name, "amdgpu/hawaii_smc.bin");
> }
> break;
> case CHIP_TOPAZ:
> @@ -338,76 +338,76 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device,
> ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD1)) ||
> ((adev->pdev->device == 0x6900) && (adev->pdev->revision == 0xD3))) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/topaz_k_smc.bin");
> + strscpy(fw_name, "amdgpu/topaz_k_smc.bin");
> } else
> - strcpy(fw_name, "amdgpu/topaz_smc.bin");
> + strscpy(fw_name, "amdgpu/topaz_smc.bin");
> break;
> case CHIP_TONGA:
> if (((adev->pdev->device == 0x6939) && (adev->pdev->revision == 0xf1)) ||
> ((adev->pdev->device == 0x6938) && (adev->pdev->revision == 0xf1))) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/tonga_k_smc.bin");
> + strscpy(fw_name, "amdgpu/tonga_k_smc.bin");
> } else
> - strcpy(fw_name, "amdgpu/tonga_smc.bin");
> + strscpy(fw_name, "amdgpu/tonga_smc.bin");
> break;
> case CHIP_FIJI:
> - strcpy(fw_name, "amdgpu/fiji_smc.bin");
> + strscpy(fw_name, "amdgpu/fiji_smc.bin");
> break;
> case CHIP_POLARIS11:
> if (type == CGS_UCODE_ID_SMU) {
> if (ASICID_IS_P21(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris11_k_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris11_k_smc.bin");
> } else if (ASICID_IS_P31(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris11_k2_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/polaris11_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris11_smc.bin");
> }
> } else if (type == CGS_UCODE_ID_SMU_SK) {
> - strcpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
> + strscpy(fw_name, "amdgpu/polaris11_smc_sk.bin");
> }
> break;
> case CHIP_POLARIS10:
> if (type == CGS_UCODE_ID_SMU) {
> if (ASICID_IS_P20(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris10_k_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris10_k_smc.bin");
> } else if (ASICID_IS_P30(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris10_k2_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/polaris10_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris10_smc.bin");
> }
> } else if (type == CGS_UCODE_ID_SMU_SK) {
> - strcpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
> + strscpy(fw_name, "amdgpu/polaris10_smc_sk.bin");
> }
> break;
> case CHIP_POLARIS12:
> if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision)) {
> info->is_kicker = true;
> - strcpy(fw_name, "amdgpu/polaris12_k_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris12_k_smc.bin");
> } else {
> - strcpy(fw_name, "amdgpu/polaris12_smc.bin");
> + strscpy(fw_name, "amdgpu/polaris12_smc.bin");
> }
> break;
> case CHIP_VEGAM:
> - strcpy(fw_name, "amdgpu/vegam_smc.bin");
> + strscpy(fw_name, "amdgpu/vegam_smc.bin");
> break;
> case CHIP_VEGA10:
> if ((adev->pdev->device == 0x687f) &&
> ((adev->pdev->revision == 0xc0) ||
> (adev->pdev->revision == 0xc1) ||
> (adev->pdev->revision == 0xc3)))
> - strcpy(fw_name, "amdgpu/vega10_acg_smc.bin");
> + strscpy(fw_name, "amdgpu/vega10_acg_smc.bin");
> else
> - strcpy(fw_name, "amdgpu/vega10_smc.bin");
> + strscpy(fw_name, "amdgpu/vega10_smc.bin");
> break;
> case CHIP_VEGA12:
> - strcpy(fw_name, "amdgpu/vega12_smc.bin");
> + strscpy(fw_name, "amdgpu/vega12_smc.bin");
> break;
> case CHIP_VEGA20:
> - strcpy(fw_name, "amdgpu/vega20_smc.bin");
> + strscpy(fw_name, "amdgpu/vega20_smc.bin");
> break;
> default:
> DRM_ERROR("SMC firmware not supported\n");
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-03-25 14:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 0:07 [PATCH] drm/amdgpu: Replace deprecated function strcpy() with strscpy() Andres Urian Florez
2025-03-25 8:38 ` Christian König
2025-03-25 13:30 ` Alex Deucher
2025-03-25 13:50 ` Christian König
2025-03-25 13:59 ` Alex Deucher
2025-03-25 14:14 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).