summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/amd/hsmp.c
AgeCommit message (Collapse)AuthorFilesLines
2024-06-03platform/x86/amd/hsmp: Check HSMP support on AMD family of processorsSuma Hegde1-7/+43
HSMP interface is supported only on few x86 processors from AMD. Accessing HSMP registers on rest of the platforms might cause unexpected behaviour. So add a check. Also unavailability of this interface on rest of the processors is not an error. Hence, use pr_info() instead of the pr_err() to log the message. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com> Link: https://lore.kernel.org/r/20240603081512.142909-1-suma.hegde@amd.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2024-04-08platform/x86/amd/hsmp: switch to use device_add_groups()Greg Kroah-Hartman1-1/+1
devm_device_add_groups() is being removed from the kernel, so move the hsmp driver to use device_add_groups() instead. The logic is identical, when the device is removed the driver core will properly clean up and remove the groups, and the memory used by the attribute groups will be freed because it was created with dev_* calls, so this is functionally identical overall. Cc: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com> Cc: Carlos Bilbao <carlos.bilbao@amd.com> Cc: Hans de Goede <hdegoede@redhat.com> Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com> Cc: platform-driver-x86@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/2024032732-thigh-smite-f5dd@gregkh Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2024-01-31platform/x86/amd/hsmp: Change devm_kzalloc() to devm_kcalloc()Suma Hegde1-6/+8
Use the standard array allocation variant of devm memory allocation APIs. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Link: https://lore.kernel.org/r/20240125125401.597617-1-suma.hegde@amd.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-31platform/x86/amd/hsmp: Remove extra parenthesis and add a spaceSuma Hegde1-2/+2
Remove unnecessary parenthesis around hsmp_get_tbl_dram_base(). Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240106022532.1746932-11-suma.hegde@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-31platform/x86/amd/hsmp: Check num_sockets against MAX_AMD_SOCKETSSuma Hegde1-5/+3
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> Link: https://lore.kernel.org/r/20240106022532.1746932-9-suma.hegde@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-31platform/x86/amd/hsmp: Non-ACPI support for AMD F1A_M00~0FhSuma Hegde1-1/+19
AMD EPYC family 0x1A and Model 0x0-0xF are having different mailbox message ID offset compared to previous platforms. In case of ACPI based BIOS, this information will be read from ACPI table, for non-ACPI BIOS, this needs to be #defined. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240106022532.1746932-8-suma.hegde@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-31platform/x86/amd/hsmp: Add support for ACPI based probingSuma Hegde1-30/+321
ACPI table provides mailbox base address and register offset information. The base address is provided as part of CRS method and mailbox offsets are provided through DSD table. Sockets are differentiated by UIDs. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240106022532.1746932-7-suma.hegde@amd.com [ij: Removed extra parenthesis.] Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-31platform/x86/amd/hsmp: Restructure sysfs group creationSuma Hegde1-20/+24
Split the creation of array of attribute groups and array of attributes into different functions. This will ease the ACPI support. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240106022532.1746932-6-suma.hegde@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-31platform/x86/amd/hsmp: Move dev from platdev to hsmp_socketSuma Hegde1-24/+24
On an ACPI enabled platforms the probe is called for each socket and the struct dev is different for each socket. This change will help in handling both ACPI and non-ACPI platforms. Also change pr_err() to dev_err() API. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240106022532.1746932-5-suma.hegde@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-25platform/x86/amd/hsmp: Define a struct to hold mailbox regsSuma Hegde1-22/+52
Define struct hsmp_mbaddr_info with register offsets and populate them during probe, which avoids the usage of macros in core functions. During ACPI probe, the same fields can be populated from ACPI table. Also move plat dev init to a static function. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240106022532.1746932-4-suma.hegde@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-25platform/x86/amd/hsmp: Create static func to handle platdevSuma Hegde1-15/+18
Create a static function and call platform device alloc and add device, which will simplify handling acpi and plat device probing. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240106022532.1746932-3-suma.hegde@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-25platform/x86/amd/hsmp: Cache pci_dev in struct hsmp_socketSuma Hegde1-18/+24
Cache pci_dev obj during probe as part of struct hsmp_socket and use in amd_hsmp_rdwr(). This change will make it easier to support both non-ACPI and ACPI devices. Also add a check for sock_index agsint number of sockets in the hsmp_send_message(). Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240106022532.1746932-2-suma.hegde@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-01-25platform/x86/amd/hsmp: Move hsmp_test to probeSuma Hegde1-19/+11
This is in advance to supporting ACPI based probe. In case of non-ACPI driver, hsmp_test() can be performed either in plat init() or in probe(). however, in case of ACPI probing, hsmp_test() cannot be called in init(), as the mailbox reg offsets and base addresses are read from ACPI table in the probe(). Hence, move hsmp_test() to probe as preparation for ACPI support. Also use hsmp_send_message() directly in hsmp_test() as the semaphore is already initialized in probe. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240106022532.1746932-1-suma.hegde@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2023-10-25platform/x86/amd/hsmp: Fix iomem handlingArmin Wolf1-1/+1
Since the metrics table is marked as io memory, use memcpy_fromio() when copying its contents. Compile-tested only. Fixes: 5150542b8ec5 ("platform/x86/amd/hsmp: add support for metrics tbl") Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231019135122.21774-1-W_Armin@gmx.de Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2023-10-12platform/x86/amd/hsmp: improve the error logSuma Hegde1-3/+3
1. Change print message during platform init to a more meaningful clear message. 2. Return the error code returned by hsmp_test() itself, rather then returning a common EOPNOTSUPP error. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Reviewed-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Link: https://lore.kernel.org/r/20231010120310.3464066-3-suma.hegde@amd.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2023-10-12platform/x86/amd/hsmp: add support for metrics tblSuma Hegde1-2/+172
AMD MI300 MCM provides GET_METRICS_TABLE message to retrieve all the system management information from SMU. The metrics table is made available as hexadecimal sysfs binary file under per socket sysfs directory created at /sys/devices/platform/amd_hsmp/socket%d/metrics_bin Metrics table definitions will be documented as part of Public PPR. The same is defined in the amd_hsmp.h header. Signed-off-by: Suma Hegde <suma.hegde@amd.com> Reviewed-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Link: https://lore.kernel.org/r/20231010120310.3464066-2-suma.hegde@amd.com [ij: lseek -> lseek(), dram -> DRAM in dev_err()] [ij: added period to terminate a documentation sentence] Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2023-10-12platform/x86/amd/hsmp: create plat specific structSuma Hegde1-23/+38
Having a separate platform device structure helps in future, to contain platform specific variables and other data. Also, define macros for dev nodes Signed-off-by: Suma Hegde <suma.hegde@amd.com> Reviewed-by: Naveen Krishna Chatradhi <nchatrad@amd.com> Link: https://lore.kernel.org/r/20231010120310.3464066-1-suma.hegde@amd.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2023-03-07platform/x86: amd: hsmp: Convert to platform remove callback returning voidUwe Kleine-König1-4/+2
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230302144732.1903781-4-u.kleine-koenig@pengutronix.de Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-10-03platform/x86: use PLATFORM_DEVID_NONE instead of -1Barnabás Pőcze1-1/+1
Use the `PLATFORM_DEVID_NONE` constant instead of hard-coding -1 when creating a platform device. No functional changes are intended. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20220930104857.2796923-1-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-06-22platform/x86: Move AMD platform drivers to separate directoryShyam Sundar S K1-0/+425
Currently, AMD supported platform drivers are grouped under generic "x86" folder structure. Move the current drivers (amd-pmc and amd_hsmp) to a separate directory. This would also mean the newer driver submissions to pdx86 subsystem in the future will also land in AMD specific directory. Reviewed-by: Naveen Krishna Chatradhi <NaveenKrishna.Chatradhi@amd.com> Tested-by: Suma Hegde <suma.hegde@amd.com> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Link: https://lore.kernel.org/r/20220608193212.2827257-1-Shyam-sundar.S-k@amd.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>