X86 platform drivers
 help / color / mirror / Atom feed
From: Suma Hegde <Suma.Hegde@amd.com>
To: Mario Limonciello <mario.limonciello@amd.com>,
	platform-driver-x86@vger.kernel.org
Cc: ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com,
	Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
Subject: Re: [PATCH 08/10] platform/x86/amd/hsmp: Move read and is_visible to respective files
Date: Fri, 28 Jun 2024 09:20:38 +0530	[thread overview]
Message-ID: <27aa9e58-4dea-42f0-901a-0c9ee696fe2e@amd.com> (raw)
In-Reply-To: <24f48c77-42bf-48f7-8e79-a97285bf4fc3@amd.com>

Hi Mario,

Thank you for your review. I will address these review comments in v2.

On 6/28/2024 1:18 AM, Mario Limonciello wrote:
> On 6/27/2024 00:39, Suma Hegde wrote:
>> The .read() and .is_visibile() needs to be handled differently in 
>> acpi and
>
> is_visible()
>
>> platform drivers, due to the way the sysfs files are created.
>>
>> This is in preparation to using .dev_groups instead of dynamic sysfs
>> creation. The sysfs at this point is not functional, it will be 
>> enabled in
>> the next patch.
>>
>> Signed-off-by: Suma Hegde <suma.hegde@amd.com>
>> Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
>> ---
>>   drivers/platform/x86/amd/hsmp/acpi.c | 41 ++++++++++++++++++++
>>   drivers/platform/x86/amd/hsmp/hsmp.c | 37 ------------------
>>   drivers/platform/x86/amd/hsmp/plat.c | 57 ++++++++++++++++++++++++++++
>>   3 files changed, 98 insertions(+), 37 deletions(-)
>>
>> diff --git a/drivers/platform/x86/amd/hsmp/acpi.c 
>> b/drivers/platform/x86/amd/hsmp/acpi.c
>> index 0307f4e7176d..1ea17aa296c7 100644
>> --- a/drivers/platform/x86/amd/hsmp/acpi.c
>> +++ b/drivers/platform/x86/amd/hsmp/acpi.c
>> @@ -12,6 +12,7 @@
>>   #include "hsmp.h"
>>     #include <linux/acpi.h>
>> +#include <asm/amd_hsmp.h>
>>   #include <asm/amd_nb.h>
>>   #include <linux/platform_device.h>
>>   @@ -206,6 +207,8 @@ static int hsmp_parse_acpi_table(struct device 
>> *dev, u16 sock_ind)
>>         sema_init(&sock->hsmp_sem, 1);
>>   +    dev_set_drvdata(dev, sock);
>> +
>>       /* Read MP1 base address from CRS method */
>>       ret = hsmp_read_acpi_crs(sock);
>>       if (ret)
>> @@ -238,6 +241,44 @@ static int hsmp_create_acpi_sysfs_if(struct 
>> device *dev)
>>       return devm_device_add_group(dev, attr_grp);
>>   }
>>   +ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj,
>> +                 struct bin_attribute *bin_attr, char *buf,
>> +                 loff_t off, size_t count)
>> +{
>> +    struct device *dev = container_of(kobj, struct device, kobj);
>> +    struct hsmp_socket *sock = dev_get_drvdata(dev);
>> +    struct hsmp_message msg = { 0 };
>> +    int ret;
>> +
>> +    if (!sock)
>> +        return -EINVAL;
>> +
>> +    /* Do not support lseek(), reads entire metric table */
>> +    if (count < bin_attr->size) {
>> +        dev_err(sock->dev, "Wrong buffer size\n");
>> +        return -EINVAL;
>> +    }
>> +
>> +    msg.msg_id      = HSMP_GET_METRIC_TABLE;
>> +    msg.sock_ind    = sock->sock_ind;
>> +
>> +    ret = hsmp_send_message(&msg);
>> +    if (ret)
>> +        return ret;
>> +    memcpy_fromio(buf, sock->metric_tbl_addr, bin_attr->size);
>> +
>> +    return bin_attr->size;
>> +}
>> +
>> +umode_t hsmp_is_sock_attr_visible(struct kobject *kobj,
>> +                  struct bin_attribute *battr, int id)
>> +{
>> +    if (plat_dev.proto_ver == HSMP_PROTO_VER6)
>> +        return battr->attr.mode;
>> +    else
>
> Since your only path in the "if" returns this else is redundant.
>
>> +        return 0;
>> +}
>> +
>>   static int init_acpi(struct device *dev)
>>   {
>>       u16 sock_ind;
>> diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c 
>> b/drivers/platform/x86/amd/hsmp/hsmp.c
>> index 4bf598021f4a..c199a0ff457d 100644
>> --- a/drivers/platform/x86/amd/hsmp/hsmp.c
>> +++ b/drivers/platform/x86/amd/hsmp/hsmp.c
>> @@ -273,34 +273,6 @@ long hsmp_ioctl(struct file *fp, unsigned int 
>> cmd, unsigned long arg)
>>       return 0;
>>   }
>>   -ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj,
>> -                 struct bin_attribute *bin_attr, char *buf,
>> -                 loff_t off, size_t count)
>> -{
>> -    struct hsmp_socket *sock = bin_attr->private;
>> -    struct hsmp_message msg = { 0 };
>> -    int ret;
>> -
>> -    if (!sock)
>> -        return -EINVAL;
>> -
>> -    /* Do not support lseek(), reads entire metric table */
>> -    if (count < bin_attr->size) {
>> -        dev_err(sock->dev, "Wrong buffer size\n");
>> -        return -EINVAL;
>> -    }
>> -
>> -    msg.msg_id    = HSMP_GET_METRIC_TABLE;
>> -    msg.sock_ind    = sock->sock_ind;
>> -
>> -    ret = hsmp_send_message(&msg);
>> -    if (ret)
>> -        return ret;
>> -    memcpy_fromio(buf, sock->metric_tbl_addr, bin_attr->size);
>> -
>> -    return bin_attr->size;
>> -}
>> -
>>   static int hsmp_get_tbl_dram_base(u16 sock_ind)
>>   {
>>       struct hsmp_socket *sock = &plat_dev.sock[sock_ind];
>> @@ -334,15 +306,6 @@ static int hsmp_get_tbl_dram_base(u16 sock_ind)
>>       return 0;
>>   }
>>   -umode_t hsmp_is_sock_attr_visible(struct kobject *kobj,
>> -                  struct bin_attribute *battr, int id)
>> -{
>> -    if (plat_dev.proto_ver == HSMP_PROTO_VER6)
>> -        return battr->attr.mode;
>> -    else
>> -        return 0;
>> -}
>> -
>>   static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute 
>> **hattrs, u16 sock_ind)
>>   {
>>       struct bin_attribute *hattr = &plat_dev.sock[sock_ind].hsmp_attr;
>> diff --git a/drivers/platform/x86/amd/hsmp/plat.c 
>> b/drivers/platform/x86/amd/hsmp/plat.c
>> index 62423581d839..57aa64b18e0d 100644
>> --- a/drivers/platform/x86/amd/hsmp/plat.c
>> +++ b/drivers/platform/x86/amd/hsmp/plat.c
>> @@ -11,6 +11,7 @@
>>     #include "hsmp.h"
>>   +#include <asm/amd_hsmp.h>
>>   #include <asm/amd_nb.h>
>>   #include <linux/module.h>
>>   #include <linux/pci.h>
>> @@ -88,6 +89,62 @@ static int hsmp_create_non_acpi_sysfs_if(struct 
>> device *dev)
>>       return device_add_groups(dev, hsmp_attr_grps);
>>   }
>>   +ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj,
>> +                 struct bin_attribute *bin_attr, char *buf,
>> +                 loff_t off, size_t count)
>> +{
>> +    struct hsmp_message msg = { 0 };
>> +    struct hsmp_socket *sock;
>> +    u8 sock_ind;
>> +    int ret;
>> +
>> +    ret = kstrtou8(bin_attr->private, 10, &sock_ind);
>> +    if (ret)
>> +        return ret;
>> +
>> +    if (sock_ind >= plat_dev.num_sockets)
>> +        return -EINVAL;
>> +
>> +    sock = &plat_dev.sock[sock_ind];
>> +    if (!sock)
>> +        return -EINVAL;
>> +
>> +    /* Do not support lseek(), reads entire metric table */
>> +    if (count < bin_attr->size) {
>> +        dev_err(sock->dev, "Wrong buffer size\n");
>> +        return -EINVAL;
>> +    }
>> +
>> +    msg.msg_id    = HSMP_GET_METRIC_TABLE;
>> +    msg.sock_ind    = sock_ind;
>> +
>> +    ret = hsmp_send_message(&msg);
>> +    if (ret)
>> +        return ret;
>> +    memcpy_fromio(buf, sock->metric_tbl_addr, bin_attr->size);
>> +
>> +    return bin_attr->size;
>> +}
>> +
>> +umode_t hsmp_is_sock_attr_visible(struct kobject *kobj,
>> +                  struct bin_attribute *battr, int id)
>> +{
>> +    u8 sock_ind;
>> +    int ret;
>> +
>> +    ret = kstrtou8(battr->private, 10, &sock_ind);
>> +    if (ret)
>> +        return ret;
>> +
>> +    if (id == 0 && sock_ind >= plat_dev.num_sockets)
>> +        return SYSFS_GROUP_INVISIBLE;
>> +
>> +    if (plat_dev.proto_ver == HSMP_PROTO_VER6)
>> +        return battr->attr.mode;
>> +    else
>> +        return 0;
>
> Since your only path in the "if" returns this else is redundant.
>
>> +}
>> +
>>   static inline bool is_f1a_m0h(void)
>>   {
>>       if (boot_cpu_data.x86 == 0x1A && boot_cpu_data.x86_model <= 0x0F)

Thanks and Regards,

Suma


  reply	other threads:[~2024-06-28  3:50 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
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 [this message]
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=27aa9e58-4dea-42f0-901a-0c9ee696fe2e@amd.com \
    --to=suma.hegde@amd.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=mario.limonciello@amd.com \
    --cc=naveenkrishna.chatradhi@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