* [PATCH 0/2] platform/x86/amd: hfi: A couple of cleanups
@ 2025-10-11 6:38 Kuan-Wei Chiu
2025-10-11 6:38 ` [PATCH 1/2] platform/x86/amd: hfi: Remove unused cpumask from cpuinfo struct Kuan-Wei Chiu
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Kuan-Wei Chiu @ 2025-10-11 6:38 UTC (permalink / raw)
To: mario.limonciello
Cc: perry.yuan, hansg, ilpo.jarvinen, jserv, platform-driver-x86,
linux-kernel, Kuan-Wei Chiu
This patch series provides a couple of cleanups for the AMD HFI driver
by removing unused and redundant code.
The changes remove an unused cpumask field from the amd_hfi_cpuinfo
struct, along with a boilerplate .owner assignment that is already
handled by the driver core and was flagged by coccicheck.
Kuan-Wei Chiu (2):
platform/x86/amd: hfi: Remove unused cpumask from cpuinfo struct
platform/x86/amd: hfi: Remove redundant assignment to .owner
drivers/platform/x86/amd/hfi/hfi.c | 11 -----------
1 file changed, 11 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] platform/x86/amd: hfi: Remove unused cpumask from cpuinfo struct
2025-10-11 6:38 [PATCH 0/2] platform/x86/amd: hfi: A couple of cleanups Kuan-Wei Chiu
@ 2025-10-11 6:38 ` Kuan-Wei Chiu
2025-10-13 18:52 ` Mario Limonciello
2025-10-11 6:38 ` [PATCH 2/2] platform/x86/amd: hfi: Remove redundant assignment to .owner Kuan-Wei Chiu
2025-10-15 10:19 ` [PATCH 0/2] platform/x86/amd: hfi: A couple of cleanups Ilpo Järvinen
2 siblings, 1 reply; 6+ messages in thread
From: Kuan-Wei Chiu @ 2025-10-11 6:38 UTC (permalink / raw)
To: mario.limonciello
Cc: perry.yuan, hansg, ilpo.jarvinen, jserv, platform-driver-x86,
linux-kernel, Kuan-Wei Chiu
The cpus field within the struct amd_hfi_cpuinfo was allocated and set
in the amd_hfi_online() CPU hotplug callback, and subsequently freed in
the amd_hfi_offline() callback.
However, after being initialized, this cpumask was never read or used
for any purpose within the driver. It represents dead code that serves
no functional role.
This change has no impact on the driver's functionality as the removed
code was entirely superfluous.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
Build test only.
drivers/platform/x86/amd/hfi/hfi.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c
index a465ac6f607e..5d5d2cf23a75 100644
--- a/drivers/platform/x86/amd/hfi/hfi.c
+++ b/drivers/platform/x86/amd/hfi/hfi.c
@@ -12,7 +12,6 @@
#include <linux/acpi.h>
#include <linux/cpu.h>
-#include <linux/cpumask.h>
#include <linux/debugfs.h>
#include <linux/gfp.h>
#include <linux/init.h>
@@ -95,7 +94,6 @@ struct amd_hfi_classes {
* struct amd_hfi_cpuinfo - HFI workload class info per CPU
* @cpu: CPU index
* @apic_id: APIC id of the current CPU
- * @cpus: mask of CPUs associated with amd_hfi_cpuinfo
* @class_index: workload class ID index
* @nr_class: max number of workload class supported
* @ipcc_scores: ipcc scores for each class
@@ -106,7 +104,6 @@ struct amd_hfi_classes {
struct amd_hfi_cpuinfo {
int cpu;
u32 apic_id;
- cpumask_var_t cpus;
s16 class_index;
u8 nr_class;
int *ipcc_scores;
@@ -295,11 +292,6 @@ static int amd_hfi_online(unsigned int cpu)
guard(mutex)(&hfi_cpuinfo_lock);
- if (!zalloc_cpumask_var(&hfi_info->cpus, GFP_KERNEL))
- return -ENOMEM;
-
- cpumask_set_cpu(cpu, hfi_info->cpus);
-
ret = amd_hfi_set_state(cpu, true);
if (ret)
pr_err("WCT enable failed for CPU %u\n", cpu);
@@ -329,8 +321,6 @@ static int amd_hfi_offline(unsigned int cpu)
if (ret)
pr_err("WCT disable failed for CPU %u\n", cpu);
- free_cpumask_var(hfi_info->cpus);
-
return ret;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] platform/x86/amd: hfi: Remove redundant assignment to .owner
2025-10-11 6:38 [PATCH 0/2] platform/x86/amd: hfi: A couple of cleanups Kuan-Wei Chiu
2025-10-11 6:38 ` [PATCH 1/2] platform/x86/amd: hfi: Remove unused cpumask from cpuinfo struct Kuan-Wei Chiu
@ 2025-10-11 6:38 ` Kuan-Wei Chiu
2025-10-13 18:53 ` Mario Limonciello
2025-10-15 10:19 ` [PATCH 0/2] platform/x86/amd: hfi: A couple of cleanups Ilpo Järvinen
2 siblings, 1 reply; 6+ messages in thread
From: Kuan-Wei Chiu @ 2025-10-11 6:38 UTC (permalink / raw)
To: mario.limonciello
Cc: perry.yuan, hansg, ilpo.jarvinen, jserv, platform-driver-x86,
linux-kernel, Kuan-Wei Chiu
The coccicheck tool reports the following warning for this driver:
./hfi.c:509:3-8: No need to set .owner here. The core will do it.
The manual assignment of .owner = THIS_MODULE; in the platform_driver
struct is redundant. The platform_driver_register() function, which is
called to register the driver, is a macro that automatically sets the
driver's owner to THIS_MODULE.
The driver core handles this assignment internally, making the explicit
initialization in the struct definition unnecessary. Remove the
unnecessary line.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
Build test only.
drivers/platform/x86/amd/hfi/hfi.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c
index 5d5d2cf23a75..83863a5e0fbc 100644
--- a/drivers/platform/x86/amd/hfi/hfi.c
+++ b/drivers/platform/x86/amd/hfi/hfi.c
@@ -505,7 +505,6 @@ static int amd_hfi_probe(struct platform_device *pdev)
static struct platform_driver amd_hfi_driver = {
.driver = {
.name = AMD_HFI_DRIVER,
- .owner = THIS_MODULE,
.pm = &amd_hfi_pm_ops,
.acpi_match_table = ACPI_PTR(amd_hfi_platform_match),
},
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] platform/x86/amd: hfi: Remove unused cpumask from cpuinfo struct
2025-10-11 6:38 ` [PATCH 1/2] platform/x86/amd: hfi: Remove unused cpumask from cpuinfo struct Kuan-Wei Chiu
@ 2025-10-13 18:52 ` Mario Limonciello
0 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2025-10-13 18:52 UTC (permalink / raw)
To: Kuan-Wei Chiu
Cc: perry.yuan, hansg, ilpo.jarvinen, jserv, platform-driver-x86,
linux-kernel
On 10/11/25 1:38 AM, Kuan-Wei Chiu wrote:
> The cpus field within the struct amd_hfi_cpuinfo was allocated and set
> in the amd_hfi_online() CPU hotplug callback, and subsequently freed in
> the amd_hfi_offline() callback.
>
> However, after being initialized, this cpumask was never read or used
> for any purpose within the driver. It represents dead code that serves
> no functional role.
>
> This change has no impact on the driver's functionality as the removed
> code was entirely superfluous.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> ---
> Build test only.
Thanks, this LGTM. There is other code that was going to use these, but
it's not upstream ready still. If we end up using them we can bring 'em
back later.
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
>
> drivers/platform/x86/amd/hfi/hfi.c | 10 ----------
> 1 file changed, 10 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c
> index a465ac6f607e..5d5d2cf23a75 100644
> --- a/drivers/platform/x86/amd/hfi/hfi.c
> +++ b/drivers/platform/x86/amd/hfi/hfi.c
> @@ -12,7 +12,6 @@
>
> #include <linux/acpi.h>
> #include <linux/cpu.h>
> -#include <linux/cpumask.h>
> #include <linux/debugfs.h>
> #include <linux/gfp.h>
> #include <linux/init.h>
> @@ -95,7 +94,6 @@ struct amd_hfi_classes {
> * struct amd_hfi_cpuinfo - HFI workload class info per CPU
> * @cpu: CPU index
> * @apic_id: APIC id of the current CPU
> - * @cpus: mask of CPUs associated with amd_hfi_cpuinfo
> * @class_index: workload class ID index
> * @nr_class: max number of workload class supported
> * @ipcc_scores: ipcc scores for each class
> @@ -106,7 +104,6 @@ struct amd_hfi_classes {
> struct amd_hfi_cpuinfo {
> int cpu;
> u32 apic_id;
> - cpumask_var_t cpus;
> s16 class_index;
> u8 nr_class;
> int *ipcc_scores;
> @@ -295,11 +292,6 @@ static int amd_hfi_online(unsigned int cpu)
>
> guard(mutex)(&hfi_cpuinfo_lock);
>
> - if (!zalloc_cpumask_var(&hfi_info->cpus, GFP_KERNEL))
> - return -ENOMEM;
> -
> - cpumask_set_cpu(cpu, hfi_info->cpus);
> -
> ret = amd_hfi_set_state(cpu, true);
> if (ret)
> pr_err("WCT enable failed for CPU %u\n", cpu);
> @@ -329,8 +321,6 @@ static int amd_hfi_offline(unsigned int cpu)
> if (ret)
> pr_err("WCT disable failed for CPU %u\n", cpu);
>
> - free_cpumask_var(hfi_info->cpus);
> -
> return ret;
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] platform/x86/amd: hfi: Remove redundant assignment to .owner
2025-10-11 6:38 ` [PATCH 2/2] platform/x86/amd: hfi: Remove redundant assignment to .owner Kuan-Wei Chiu
@ 2025-10-13 18:53 ` Mario Limonciello
0 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2025-10-13 18:53 UTC (permalink / raw)
To: Kuan-Wei Chiu
Cc: perry.yuan, hansg, ilpo.jarvinen, jserv, platform-driver-x86,
linux-kernel
On 10/11/25 1:38 AM, Kuan-Wei Chiu wrote:
> The coccicheck tool reports the following warning for this driver:
>
> ./hfi.c:509:3-8: No need to set .owner here. The core will do it.
>
> The manual assignment of .owner = THIS_MODULE; in the platform_driver
> struct is redundant. The platform_driver_register() function, which is
> called to register the driver, is a macro that automatically sets the
> driver's owner to THIS_MODULE.
>
> The driver core handles this assignment internally, making the explicit
> initialization in the struct definition unnecessary. Remove the
> unnecessary line.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> ---
> Build test only.
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>>
> drivers/platform/x86/amd/hfi/hfi.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/platform/x86/amd/hfi/hfi.c b/drivers/platform/x86/amd/hfi/hfi.c
> index 5d5d2cf23a75..83863a5e0fbc 100644
> --- a/drivers/platform/x86/amd/hfi/hfi.c
> +++ b/drivers/platform/x86/amd/hfi/hfi.c
> @@ -505,7 +505,6 @@ static int amd_hfi_probe(struct platform_device *pdev)
> static struct platform_driver amd_hfi_driver = {
> .driver = {
> .name = AMD_HFI_DRIVER,
> - .owner = THIS_MODULE,
> .pm = &amd_hfi_pm_ops,
> .acpi_match_table = ACPI_PTR(amd_hfi_platform_match),
> },
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] platform/x86/amd: hfi: A couple of cleanups
2025-10-11 6:38 [PATCH 0/2] platform/x86/amd: hfi: A couple of cleanups Kuan-Wei Chiu
2025-10-11 6:38 ` [PATCH 1/2] platform/x86/amd: hfi: Remove unused cpumask from cpuinfo struct Kuan-Wei Chiu
2025-10-11 6:38 ` [PATCH 2/2] platform/x86/amd: hfi: Remove redundant assignment to .owner Kuan-Wei Chiu
@ 2025-10-15 10:19 ` Ilpo Järvinen
2 siblings, 0 replies; 6+ messages in thread
From: Ilpo Järvinen @ 2025-10-15 10:19 UTC (permalink / raw)
To: mario.limonciello, Kuan-Wei Chiu
Cc: perry.yuan, hansg, jserv, platform-driver-x86, linux-kernel
On Sat, 11 Oct 2025 14:38:35 +0800, Kuan-Wei Chiu wrote:
> This patch series provides a couple of cleanups for the AMD HFI driver
> by removing unused and redundant code.
>
> The changes remove an unused cpumask field from the amd_hfi_cpuinfo
> struct, along with a boilerplate .owner assignment that is already
> handled by the driver core and was flagged by coccicheck.
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/2] platform/x86/amd: hfi: Remove unused cpumask from cpuinfo struct
commit: 32647324c77012b7aed7ef48752909510d3c7ec7
[2/2] platform/x86/amd: hfi: Remove redundant assignment to .owner
commit: 0254329897495c42646144376230add710078937
--
i.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-15 10:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-11 6:38 [PATCH 0/2] platform/x86/amd: hfi: A couple of cleanups Kuan-Wei Chiu
2025-10-11 6:38 ` [PATCH 1/2] platform/x86/amd: hfi: Remove unused cpumask from cpuinfo struct Kuan-Wei Chiu
2025-10-13 18:52 ` Mario Limonciello
2025-10-11 6:38 ` [PATCH 2/2] platform/x86/amd: hfi: Remove redundant assignment to .owner Kuan-Wei Chiu
2025-10-13 18:53 ` Mario Limonciello
2025-10-15 10:19 ` [PATCH 0/2] platform/x86/amd: hfi: A couple of cleanups Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox