From: "Arnd Bergmann" <arnd@arndb.de>
To: "Akshay Gupta" <akshay.gupta@amd.com>,
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: Mon, 24 Mar 2025 16:40:12 +0100 [thread overview]
Message-ID: <c9138dd3-6a09-47a2-a8fe-716c8894042e@app.fastmail.com> (raw)
In-Reply-To: <20250324145815.1026314-7-akshay.gupta@amd.com>
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;
> +
> + 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
next prev parent reply other threads:[~2025-03-24 15:40 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 [this message]
2025-03-25 12:35 ` Gupta, Akshay
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=c9138dd3-6a09-47a2-a8fe-716c8894042e@app.fastmail.com \
--to=arnd@arndb.de \
--cc=akshay.gupta@amd.com \
--cc=anand.umarji@amd.com \
--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