From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Suma Hegde <suma.hegde@amd.com>
Cc: platform-driver-x86@vger.kernel.org,
Hans de Goede <hdegoede@redhat.com>,
Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
Subject: Re: [PATCH 02/10] platform/x86/amd/hsmp: Create wrapper function init_acpi()
Date: Tue, 9 Jul 2024 13:24:25 +0300 (EEST) [thread overview]
Message-ID: <a9a9b967-b656-fd75-479d-1558f1e4e567@linux.intel.com> (raw)
In-Reply-To: <20240627053958.2533860-3-suma.hegde@amd.com>
[-- Attachment #1: Type: text/plain, Size: 4357 bytes --]
On Thu, 27 Jun 2024, Suma Hegde wrote:
> This is in preparation to splitting ACPI and platform device drivers.
> Having init_acpi() helps in smooth code movement.
>
> Signed-off-by: Suma Hegde <suma.hegde@amd.com>
> Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
> ---
> drivers/platform/x86/amd/hsmp/hsmp.c | 91 ++++++++++++++++++----------
> 1 file changed, 59 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c
> index 8fcf38eed7f0..10ab9b2437f1 100644
> --- a/drivers/platform/x86/amd/hsmp/hsmp.c
> +++ b/drivers/platform/x86/amd/hsmp/hsmp.c
> @@ -778,6 +778,11 @@ static int init_platform_device(struct device *dev)
> dev_err(dev, "Is HSMP disabled in BIOS ?\n");
> return ret;
> }
> + ret = hsmp_cache_proto_ver(i);
> + if (ret) {
> + dev_err(dev, "Failed to read HSMP protocol version\n");
> + return ret;
> + }
> }
>
> return 0;
> @@ -789,10 +794,53 @@ static const struct acpi_device_id amd_hsmp_acpi_ids[] = {
> };
> MODULE_DEVICE_TABLE(acpi, amd_hsmp_acpi_ids);
>
> +static bool check_acpi_support(struct device *dev)
> +{
> + struct acpi_device *adev = ACPI_COMPANION(dev);
> +
> + if (adev && !acpi_match_device_ids(adev, amd_hsmp_acpi_ids))
> + return true;
> +
> + return false;
> +}
> +
> +static int init_acpi(struct device *dev)
> +{
> + u16 sock_ind;
> + int ret;
> +
> + ret = hsmp_get_uid(dev, &sock_ind);
> + if (ret)
> + return ret;
> + if (sock_ind >= plat_dev.num_sockets)
> + return -EINVAL;
> +
> + ret = hsmp_parse_acpi_table(dev, sock_ind);
> + if (ret) {
> + dev_err(dev, "Failed to parse ACPI table\n");
> + return ret;
> + }
> +
> + /* Test the hsmp interface */
> + ret = hsmp_test(sock_ind, 0xDEADBEEF);
> + if (ret) {
> + dev_err(dev, "HSMP test message failed on Fam:%x model:%x\n",
> + boot_cpu_data.x86, boot_cpu_data.x86_model);
> + dev_err(dev, "Is HSMP disabled in BIOS ?\n");
> + return ret;
> + }
> +
> + ret = hsmp_cache_proto_ver(sock_ind);
> + if (ret) {
> + dev_err(dev, "Failed to read HSMP protocol version\n");
> + return ret;
> + }
> +
> + return ret;
> +}
> +
> static int hsmp_pltdrv_probe(struct platform_device *pdev)
> {
> - struct acpi_device *adev;
> - u16 sock_ind = 0;
> int ret;
>
> /*
> @@ -809,46 +857,25 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev)
> if (!plat_dev.sock)
> return -ENOMEM;
> }
> - adev = ACPI_COMPANION(&pdev->dev);
> - if (adev && !acpi_match_device_ids(adev, amd_hsmp_acpi_ids)) {
> - ret = hsmp_get_uid(&pdev->dev, &sock_ind);
> - if (ret)
> - return ret;
> - if (sock_ind >= plat_dev.num_sockets)
> - return -EINVAL;
> - ret = hsmp_parse_acpi_table(&pdev->dev, sock_ind);
> - if (ret) {
> - dev_err(&pdev->dev, "Failed to parse ACPI table\n");
> - return ret;
> - }
> - /* Test the hsmp interface */
> - ret = hsmp_test(sock_ind, 0xDEADBEEF);
> + if (check_acpi_support(&pdev->dev)) {
> + ret = init_acpi(&pdev->dev);
> if (ret) {
> - dev_err(&pdev->dev, "HSMP test message failed on Fam:%x model:%x\n",
> - boot_cpu_data.x86, boot_cpu_data.x86_model);
> - dev_err(&pdev->dev, "Is HSMP disabled in BIOS ?\n");
> + dev_err(&pdev->dev, "Failed to init HSMP mailbox\n");
> return ret;
> }
> + ret = hsmp_create_acpi_sysfs_if(&pdev->dev);
> + if (ret)
> + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n");
> } else {
> ret = init_platform_device(&pdev->dev);
> if (ret) {
> dev_err(&pdev->dev, "Failed to init HSMP mailbox\n");
> return ret;
> }
> - }
> -
> - ret = hsmp_cache_proto_ver(sock_ind);
> - if (ret) {
> - dev_err(&pdev->dev, "Failed to read HSMP protocol version\n");
> - return ret;
> - }
> -
> - if (plat_dev.is_acpi_device)
> - ret = hsmp_create_acpi_sysfs_if(&pdev->dev);
> - else
> ret = hsmp_create_non_acpi_sysfs_if(&pdev->dev);
> - if (ret)
> - dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n");
> + if (ret)
> + dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n");
> + }
>
> if (!plat_dev.is_probed) {
> plat_dev.hsmp_device.name = HSMP_CDEV_NAME;
>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
next prev parent reply other threads:[~2024-07-09 10:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 5:39 [PATCH 00/10] platform/x86/amd/hsmp: Split ACPI and plat device driver Suma Hegde
2024-06-27 5:39 ` [PATCH 01/10] platform/x86/amd/hsmp: Create hsmp/ directory Suma Hegde
2024-06-27 5:39 ` [PATCH 02/10] platform/x86/amd/hsmp: Create wrapper function init_acpi() Suma Hegde
2024-07-09 10:24 ` Ilpo Järvinen [this message]
2024-06-27 5:39 ` [PATCH 03/10] platform/x86/amd/hsmp: Move strcuture and macros to header file Suma Hegde
2024-06-27 19:30 ` Mario Limonciello
2024-07-09 10:21 ` Ilpo Järvinen
2024-06-27 5:39 ` [PATCH 04/10] platform/x86/amd/hsmp: Move platform device specific code to plat.c Suma Hegde
2024-07-09 10:20 ` Ilpo Järvinen
2024-06-27 5:39 ` [PATCH 05/10] platform/x86/amd/hsmp: Move ACPI code to acpi.c Suma Hegde
2024-07-09 10:09 ` Ilpo Järvinen
2024-07-09 10:50 ` Suma Hegde
2024-06-27 5:39 ` [PATCH 06/10] platform/x86/amd/hsmp: Create mutually exclusive ACPI and plat drivers Suma Hegde
2024-07-08 10:15 ` Ilpo Järvinen
2024-07-09 6:41 ` Suma Hegde
2024-06-27 5:39 ` [PATCH 07/10] platform/x86/amd/hsmp: Use name space while exporting module symbols Suma Hegde
2024-07-08 10:23 ` Ilpo Järvinen
2024-06-27 5:39 ` [PATCH 08/10] platform/x86/amd/hsmp: Move read and is_visible to respective files Suma Hegde
2024-06-27 19:48 ` Mario Limonciello
2024-06-28 3:50 ` Suma Hegde
2024-06-27 5:39 ` [PATCH 09/10] platform/x86/amd/hsmp: Use dev_groups in the driver structure Suma Hegde
2024-06-27 5:39 ` [PATCH 10/10] platform/x86/amd/hsmp: Fix potential spectre issue Suma Hegde
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=a9a9b967-b656-fd75-479d-1558f1e4e567@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=naveenkrishna.chatradhi@amd.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=suma.hegde@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