From: Cosmo Chou <chou.cosmo@gmail.com>
Implement GPIO-based alert mechanism in the SSIF BMC driver to notify
the host when a response is ready.
This improves host-BMC communication efficiency by providing immediate
notification, potentially reducing host polling overhead.
Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com>
---
drivers/char/ipmi/ssif_bmc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/char/ipmi/ssif_bmc.c b/drivers/char/ipmi/ssif_bmc.c
index a14fafc583d4..73be166b0042 100644
--- a/drivers/char/ipmi/ssif_bmc.c
+++ b/drivers/char/ipmi/ssif_bmc.c
@@ -17,6 +17,7 @@
#include <linux/spinlock.h>
#include <linux/timer.h>
#include <linux/jiffies.h>
+#include <linux/gpio/consumer.h>
#include <linux/ipmi_ssif_bmc.h>
#define DEVICE_NAME "ipmi-ssif-host"
@@ -102,6 +103,7 @@ struct ssif_bmc_ctx {
struct ssif_part_buffer part_buf;
struct ipmi_ssif_msg response;
struct ipmi_ssif_msg request;
+ struct gpio_desc *alert;
};
static inline struct ssif_bmc_ctx *to_ssif_bmc(struct file *file)
@@ -222,6 +224,9 @@ static ssize_t ssif_bmc_write(struct file *file, const char __user *buf, size_t
/* Clean old request buffer */
memset(&ssif_bmc->request, 0, sizeof(struct ipmi_ssif_msg));
+
+ if (!IS_ERR(ssif_bmc->alert))
+ gpiod_set_value(ssif_bmc->alert, 1);
exit:
spin_unlock_irqrestore(&ssif_bmc->lock, flags);
@@ -584,6 +589,9 @@ static void process_smbus_cmd(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
memset(&ssif_bmc->part_buf.payload[0], 0, MAX_PAYLOAD_PER_TRANSACTION);
if (*val == SSIF_IPMI_SINGLEPART_WRITE || *val == SSIF_IPMI_MULTIPART_WRITE_START) {
+ if (!IS_ERR(ssif_bmc->alert))
+ gpiod_set_value(ssif_bmc->alert, 0);
+
/*
* The response maybe not come in-time, causing host SSIF driver
* to timeout and resend a new request. In such case check for
@@ -640,6 +648,8 @@ static void on_read_requested_event(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
calculate_response_part_pec(&ssif_bmc->part_buf);
ssif_bmc->part_buf.index = 0;
*val = ssif_bmc->part_buf.length;
+ if (!IS_ERR(ssif_bmc->alert))
+ gpiod_set_value(ssif_bmc->alert, 0);
}
static void on_read_processed_event(struct ssif_bmc_ctx *ssif_bmc, u8 *val)
@@ -808,6 +818,11 @@ static int ssif_bmc_probe(struct i2c_client *client)
if (!ssif_bmc)
return -ENOMEM;
+ /* Request GPIO for alerting the host that response is ready */
+ ssif_bmc->alert = devm_gpiod_get(&client->dev, "alert", GPIOD_ASIS);
+ if (!IS_ERR(ssif_bmc->alert))
+ gpiod_direction_output(ssif_bmc->alert, 0);
+
spin_lock_init(&ssif_bmc->lock);
init_waitqueue_head(&ssif_bmc->wait_queue);
--
2.31.1
On 22/10/2024 08:20, Potin Lai wrote: > From: Cosmo Chou <chou.cosmo@gmail.com> > > Implement GPIO-based alert mechanism in the SSIF BMC driver to notify > the host when a response is ready. > > This improves host-BMC communication efficiency by providing immediate > notification, potentially reducing host polling overhead. > > Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com> > --- > drivers/char/ipmi/ssif_bmc.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > Thanks for adding feature to this driver, the code looks good to me. Reviewed-by: Quan Nguyen <quan@os.amperecomputing.com> I'm just have a bit of curious on how the ipmi_ssif in host side to work with this mechanism? Will there be patches for ipmi_ssif to use this feature followed? Thanks and Best regards, - Quan
On Wed, Oct 23, 2024 at 11:30 PM Quan Nguyen <quan@os.amperecomputing.com> wrote: > > > > On 22/10/2024 08:20, Potin Lai wrote: > > From: Cosmo Chou <chou.cosmo@gmail.com> > > > > Implement GPIO-based alert mechanism in the SSIF BMC driver to notify > > the host when a response is ready. > > > > This improves host-BMC communication efficiency by providing immediate > > notification, potentially reducing host polling overhead. > > > > Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com> > > --- > > drivers/char/ipmi/ssif_bmc.c | 15 +++++++++++++++ > > 1 file changed, 15 insertions(+) > > > > Thanks for adding feature to this driver, the code looks good to me. > > Reviewed-by: Quan Nguyen <quan@os.amperecomputing.com> > > I'm just have a bit of curious on how the ipmi_ssif in host side to work > with this mechanism? Will there be patches for ipmi_ssif to use this > feature followed? I just saw this. What makes you think alerts are not supported in ipmi_ssif? -corey > > Thanks and Best regards, > - Quan
On 19/11/2024 18:30, Corey Minyard wrote: > On Wed, Oct 23, 2024 at 11:30 PM Quan Nguyen > <quan@os.amperecomputing.com> wrote: >> >> >> >> On 22/10/2024 08:20, Potin Lai wrote: >>> From: Cosmo Chou <chou.cosmo@gmail.com> >>> >>> Implement GPIO-based alert mechanism in the SSIF BMC driver to notify >>> the host when a response is ready. >>> >>> This improves host-BMC communication efficiency by providing immediate >>> notification, potentially reducing host polling overhead. >>> >>> Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com> >>> --- >>> drivers/char/ipmi/ssif_bmc.c | 15 +++++++++++++++ >>> 1 file changed, 15 insertions(+) >>> >> >> Thanks for adding feature to this driver, the code looks good to me. >> >> Reviewed-by: Quan Nguyen <quan@os.amperecomputing.com> >> >> I'm just have a bit of curious on how the ipmi_ssif in host side to work >> with this mechanism? Will there be patches for ipmi_ssif to use this >> feature followed? > > I just saw this. What makes you think alerts are not supported in ipmi_ssif? > Yes, Corey, I see alerts are supported in ipmi_ssif. My apology about the unclear question, I was just curious about whether this gpio-based alerts mechanism is confirmed through test with current ipmi_ssif without any extra patches. Thanks, - Quan
On Wed, Nov 20, 2024 at 08:58:47AM +0700, Quan Nguyen wrote: > On 19/11/2024 18:30, Corey Minyard wrote: > > I just saw this. What makes you think alerts are not supported in ipmi_ssif? > > Yes, Corey, I see alerts are supported in ipmi_ssif. > > My apology about the unclear question, I was just curious about whether this > gpio-based alerts mechanism is confirmed through test with current ipmi_ssif > without any extra patches. Ah. The way this would work would be that the GPIO is run to an interrupt on the host processor. Generally all the alerting devices on the SMBus will "or" into that interrupt somehow. When the interrupt comes in, the host will issue a request to the SMBus alert address and each device that has an alert pending will respond with their address. Because of the wire or of the SMBus, the lowest address will win. On Linux, the driver for that particular device will be told that an alert came in if it has registered for that alert. The GPIO is just an interrupt, so that should just work. That's not the hard part. There has to be some device tree work on the host side to map the interrupt to an SMBus alert for a specific bus. (I think you can do this with ACPI, too, but I'm not sure.) And the device, of course, must respond properly to the alert request. So the GPIO is not something that's unusual. If it generates an interrupt (and all the other stuff is in place on the host side) it will work. -corey
On Thu, Oct 24, 2024 at 12:29 PM Quan Nguyen <quan@os.amperecomputing.com> wrote: > > > > On 22/10/2024 08:20, Potin Lai wrote: > > From: Cosmo Chou <chou.cosmo@gmail.com> > > > > Implement GPIO-based alert mechanism in the SSIF BMC driver to notify > > the host when a response is ready. > > > > This improves host-BMC communication efficiency by providing immediate > > notification, potentially reducing host polling overhead. > > > > Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com> > > --- > > drivers/char/ipmi/ssif_bmc.c | 15 +++++++++++++++ > > 1 file changed, 15 insertions(+) > > > > Thanks for adding feature to this driver, the code looks good to me. > > Reviewed-by: Quan Nguyen <quan@os.amperecomputing.com> > > I'm just have a bit of curious on how the ipmi_ssif in host side to work > with this mechanism? Will there be patches for ipmi_ssif to use this > feature followed? > > Thanks and Best regards, > - Quan Hi Quan, Sorry for the late reply. This implementation is only tested with our BIOS team, and they are not using linux driver for ssif feature. At moment, we don't have plan to add changes in ipmi_ssif. Thanks, Potin
© 2016 - 2024 Red Hat, Inc.