From: "Gupta, Akshay" <Akshay.Gupta@amd.com>
To: Arnd Bergmann <arnd@arndb.de>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Guenter Roeck <linux@roeck-us.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
shyam-sundar.s-k@amd.com, gautham.shenoy@amd.com,
Mario Limonciello <mario.limonciello@amd.com>,
naveenkrishna.chatradhi@amd.com, anand.umarji@amd.com
Subject: Re: [PATCH v6 06/11] misc: amd-sbi: Add support for AMD_SBI IOCTL
Date: Tue, 25 Mar 2025 18:05:38 +0530 [thread overview]
Message-ID: <b26e9abc-10bb-46a0-be05-d0cd2ce835bd@amd.com> (raw)
In-Reply-To: <c9138dd3-6a09-47a2-a8fe-716c8894042e@app.fastmail.com>
On 3/24/2025 9:10 PM, Arnd Bergmann wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> On Mon, Mar 24, 2025, at 15:58, Akshay Gupta wrote:
>> ---
>> Changes since v5:
>> - Address review comment
>> - Address Arnd comments
>> - Add check for cmd in ioctl
> I think you missed one of my comments.
>
>> +static long sbrmi_ioctl(struct file *fp, unsigned int cmd, unsigned
>> long arg)
>> +{
>> + struct apml_message msg = { 0 };
>> + struct sbrmi_data *data;
>> + bool read = false;
>> + int ret;
>> +
>> + if (cmd != SBRMI_IOCTL_CMD)
>> + return -ENOTTY;
>> +
>> + if (_IOC_SIZE(cmd) != sizeof(msg))
>> + return -EINVAL;
> You are checking the 'cmd' argument to the function now, which
> is good. There is no need to also check _IOC_SIZE, since
> that is implied by the definition.
> rue;
Ack.
>
>> +
>> + switch (msg.cmd) {
>> + case 0 ... 0x999:
>> + /* Mailbox protocol */
>> + ret = rmi_mailbox_xfer(data, &msg);
>> + break;
> What is however missing here is a specific check for the
> individual commands: I don't think it's a good idea to
> treat all 2458 mailbox commands the same way and just
> pass them through unfiltered here, and I would also not
> pass the specific 'cmd' as part of a multiplexer structure.
>
> Instead, I think there should be a separate ioctl command
> for each thing you can do with the mailbox. From the existing
> driver it appears that these are the commands currently
> supported:
>
> enum sbrmi_msg_id {
> SBRMI_READ_PKG_PWR_CONSUMPTION = 0x1,
> SBRMI_WRITE_PKG_PWR_LIMIT,
> SBRMI_READ_PKG_PWR_LIMIT,
> SBRMI_READ_PKG_MAX_PWR_LIMIT,
> };
>
> which is just the first four out of the 2458, and clearly small
> enough to justify one ioctl command each. I don't know what
> the command specific arguments would look like, so it's
> possible you may also want to define a separate structure
> for each one.
>
> Arnd
Link for the documentation:
https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/programmer-references/57883.zip
<https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/programmer-references/57883.zip>
You may refer to section: 5.4.2.2 SB-RMI Mailbox Service
At present, more than 70 mailbox commands ids are supported.
The number is increasing with each platforms.
however, the input and output for all mailbox commands are maintained as
32 bit,
hence, we can use the same structure and differentiate the functionality.
As per current AMD's implementation the maximum can go up to 0xFF, I
will update the
case to 0 ... 0XFF
next prev parent reply other threads:[~2025-03-25 12:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 14:58 [PATCH v6 00/11] misc: Move AMD side band interface(SBI) functionality Akshay Gupta
2025-03-24 14:58 ` [PATCH v6 01/11] hwmon/misc: amd-sbi: Move core sbrmi from hwmon to misc Akshay Gupta
2025-03-24 14:58 ` [PATCH v6 02/11] misc: amd-sbi: Move protocol functionality to core file Akshay Gupta
2025-03-24 14:58 ` [PATCH v6 03/11] misc: amd-sbi: Move hwmon device sensor as separate entity Akshay Gupta
2025-03-24 14:58 ` [PATCH v6 04/11] misc: amd-sbi: Use regmap subsystem Akshay Gupta
2025-03-24 14:58 ` [PATCH v6 05/11] misc: amd-sbi: Optimize the wait condition for mailbox command completion Akshay Gupta
2025-03-24 14:58 ` [PATCH v6 06/11] misc: amd-sbi: Add support for AMD_SBI IOCTL Akshay Gupta
2025-03-24 15:40 ` Arnd Bergmann
2025-03-25 12:35 ` Gupta, Akshay [this message]
2025-03-25 13:37 ` Arnd Bergmann
2025-03-26 11:46 ` Gupta, Akshay
2025-03-24 14:58 ` [PATCH v6 07/11] misc: amd-sbi: Add support for mailbox error codes Akshay Gupta
2025-03-24 15:26 ` Arnd Bergmann
2025-03-25 12:35 ` Gupta, Akshay
2025-03-24 14:58 ` [PATCH v6 08/11] misc: amd-sbi: Add support for CPUID protocol Akshay Gupta
2025-03-24 15:29 ` Arnd Bergmann
2025-03-25 12:35 ` Gupta, Akshay
2025-03-24 14:58 ` [PATCH v6 09/11] misc: amd-sbi: Add support for read MCA register protocol Akshay Gupta
2025-03-24 14:58 ` [PATCH v6 10/11] misc: amd-sbi: Add support for register xfer Akshay Gupta
2025-03-24 14:58 ` [PATCH v6 11/11] misc: amd-sbi: Add document for AMD SB IOCTL description Akshay Gupta
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=b26e9abc-10bb-46a0-be05-d0cd2ce835bd@amd.com \
--to=akshay.gupta@amd.com \
--cc=anand.umarji@amd.com \
--cc=arnd@arndb.de \
--cc=gautham.shenoy@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mario.limonciello@amd.com \
--cc=naveenkrishna.chatradhi@amd.com \
--cc=shyam-sundar.s-k@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