X86 platform drivers
 help / color / mirror / Atom feed
From: Suma Hegde <suma.hegde@amd.com>
To: <platform-driver-x86@vger.kernel.org>
Cc: <ilpo.jarvinen@linux.intel.com>, <hdegoede@redhat.com>,
	Suma Hegde <suma.hegde@amd.com>,
	Naveen Krishna Chatradhi <nchatrad@amd.com>
Subject: [PATCH v5 09/11] platform/x86/amd/hsmp: Check num_sockets against MAX_AMD_SOCKETS
Date: Sat, 6 Jan 2024 02:25:30 +0000	[thread overview]
Message-ID: <20240106022532.1746932-9-suma.hegde@amd.com> (raw)
In-Reply-To: <20240106022532.1746932-1-suma.hegde@amd.com>

AMD supports connecting up to 8 AMD EPYCs in a system.
Hence, verify the num_sockets returned from amd_nb_num().
Also remove the WARN_ON() since the num_sockets is already verified.

Signed-off-by: Suma Hegde <suma.hegde@amd.com>
Reviewed-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
Changes since v4:
Add Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Changes since v3:
New patch

 drivers/platform/x86/amd/hsmp.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/amd/hsmp.c b/drivers/platform/x86/amd/hsmp.c
index 05255102e0a0..99bebb0ca5a9 100644
--- a/drivers/platform/x86/amd/hsmp.c
+++ b/drivers/platform/x86/amd/hsmp.c
@@ -62,6 +62,8 @@
 #define MSG_ARGOFF_STR		"MsgArgOffset"
 #define MSG_RESPOFF_STR		"MsgRspOffset"
 
+#define MAX_AMD_SOCKETS 8
+
 struct hsmp_mbaddr_info {
 	u32 base_addr;
 	u32 msg_id_off;
@@ -671,10 +673,6 @@ static int hsmp_create_non_acpi_sysfs_if(struct device *dev)
 	struct attribute_group *attr_grp;
 	u16 i;
 
-	/* String formatting is currently limited to u8 sockets */
-	if (WARN_ON(plat_dev.num_sockets > U8_MAX))
-		return -ERANGE;
-
 	hsmp_attr_grps = devm_kzalloc(dev, sizeof(struct attribute_group *) *
 				      (plat_dev.num_sockets + 1), GFP_KERNEL);
 	if (!hsmp_attr_grps)
@@ -925,7 +923,7 @@ static int __init hsmp_plt_init(void)
 	 * if we have N SMN/DF interfaces that ideally means N sockets
 	 */
 	plat_dev.num_sockets = amd_nb_num();
-	if (plat_dev.num_sockets == 0)
+	if (plat_dev.num_sockets == 0 || plat_dev.num_sockets > MAX_AMD_SOCKETS)
 		return ret;
 
 	ret = platform_driver_register(&amd_hsmp_driver);
-- 
2.25.1


  parent reply	other threads:[~2024-01-06  2:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-06  2:25 [PATCH v5 01/11] platform/x86/amd/hsmp: Move hsmp_test to probe Suma Hegde
2024-01-06  2:25 ` [PATCH v5 02/11] platform/x86/amd/hsmp: Cache pci_dev in struct hsmp_socket Suma Hegde
2024-01-06  2:25 ` [PATCH v5 03/11] platform/x86/amd/hsmp: Create static func to handle platdev Suma Hegde
2024-01-06  2:25 ` [PATCH v5 04/11] platform/x86/amd/hsmp: Define a struct to hold mailbox regs Suma Hegde
2024-01-06  2:25 ` [PATCH v5 05/11] platform/x86/amd/hsmp: Move dev from platdev to hsmp_socket Suma Hegde
2024-01-06  2:25 ` [PATCH v5 06/11] platform/x86/amd/hsmp: Restructure sysfs group creation Suma Hegde
2024-01-24 12:34   ` Ilpo Järvinen
2024-01-06  2:25 ` [PATCH v5 07/11] platform/x86/amd/hsmp: Add support for ACPI based probing Suma Hegde
2024-01-24 13:02   ` Ilpo Järvinen
2024-01-06  2:25 ` [PATCH v5 08/11] platform/x86/amd/hsmp: Non-ACPI support for AMD F1A_M00~0Fh Suma Hegde
2024-01-06  2:25 ` Suma Hegde [this message]
2024-01-06  2:25 ` [PATCH v5 10/11] platform/x86/amd/hsmp: Change devm_kzalloc() to devm_kcalloc() Suma Hegde
2024-01-24 12:29   ` Ilpo Järvinen
2024-01-25 12:33   ` Ilpo Järvinen
2024-01-29 12:44     ` Ilpo Järvinen
2024-01-29 13:24       ` Hegde, Suma
2024-01-31 10:32         ` Ilpo Järvinen
2024-02-06  6:38           ` Hegde, Suma
2024-02-06  9:04             ` Ilpo Järvinen
2024-02-06  9:46               ` Hegde, Suma
2024-01-06  2:25 ` [PATCH v5 11/11] platform/x86/amd/hsmp: Remove extra parenthesis and add a space Suma Hegde
2024-01-24 12:25   ` Ilpo Järvinen

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=20240106022532.1746932-9-suma.hegde@amd.com \
    --to=suma.hegde@amd.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=nchatrad@amd.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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