linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: mpi3mr: Emit uevent on controller diagnostic fault
@ 2025-07-16  1:31 Salomon Dushimirimana
  2025-07-16 15:51 ` Bart Van Assche
  0 siblings, 1 reply; 7+ messages in thread
From: Salomon Dushimirimana @ 2025-07-16  1:31 UTC (permalink / raw)
  To: Sathya Prakash Veerichetty, Kashyap Desai, Sumit Saxena,
	Sreekanth Reddy, James E.J. Bottomley, Martin K. Petersen
  Cc: mpi3mr-linuxdrv.pdl, linux-scsi, linux-kernel,
	Salomon Dushimirimana

Introduces a uevent mechanism to notify userspace when the controller
undergoes a reset due to a diagnostic fault. A new function,
mpi3mr_fault_event_emit(), is added and called from the reset path. This
function filters for a diagnostic fault type
(MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT) and generates a uevent
containing details about the event:

- DRIVER: mpi3mr in this case
- HBA_NUM: scsi host id
- EVENT_TYPE: indicates fatal error
- RESET_TYPE: type of reset that has occurred
- RESET_REASON: specific reason for the reset

This will allow userspace tools to subscribe to these events and take
appropriate action.

Signed-off-by: Salomon Dushimirimana <salomondush@google.com>
---
 drivers/scsi/mpi3mr/mpi3mr_fw.c | 42 +++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
index 1d7901a8f0e40..9c90569754305 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -1623,6 +1623,47 @@ static inline void mpi3mr_set_diagsave(struct mpi3mr_ioc *mrioc)
 	writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
 }
 
+/**
+ * mpi3mr_fault_uevent_emit - Emit a uevent for a controller diagnostic fault
+ * @mrioc: Pointer to the mpi3mr_ioc structure for the controller instance
+ * @reset_type: The type of reset that has occurred
+ * @reset_reason: The specific reason code for the reset
+ *
+ * This function is invoked when the controller undergoes a reset. It specifically
+ * filters for MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT) and ignores other
+ * reset types, such as soft resets.
+ */
+static void mpi3mr_fault_uevent_emit(struct mpi3mr_ioc *mrioc, u16 reset_type,
+	u16 reset_reason)
+{
+	struct kobj_uevent_env *env;
+
+	if (reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT)
+		return;
+
+	ioc_info(mrioc, "emitting fault exception uevent");
+
+	env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
+	if (!env)
+		return;
+
+	if (add_uevent_var(env, "DRIVER=%s", mrioc->driver_name))
+		goto exit;
+	if (add_uevent_var(env, "HBA_NUM=%u", mrioc->id))
+		goto exit;
+	if (add_uevent_var(env, "EVENT_TYPE=FATAL_ERROR"))
+		goto exit;
+	if (add_uevent_var(env, "RESET_TYPE=%s", mpi3mr_reset_type_name(reset_type)))
+		goto exit;
+	if (add_uevent_var(env, "RESET_REASON=%s", mpi3mr_reset_rc_name(reset_reason)))
+		goto exit;
+
+	kobject_uevent_env(&mrioc->shost->shost_gendev.kobj, KOBJ_CHANGE, env->envp);
+
+exit:
+	kfree(env);
+}
+
 /**
  * mpi3mr_issue_reset - Issue reset to the controller
  * @mrioc: Adapter reference
@@ -1741,6 +1782,7 @@ static int mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type,
 	    ioc_config);
 	if (retval)
 		mrioc->unrecoverable = 1;
+	mpi3mr_fault_uevent_emit(mrioc, reset_type, reset_reason);
 	return retval;
 }
 
-- 
2.50.0.727.gbf7dc18ff4-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] scsi: mpi3mr: Emit uevent on controller diagnostic fault
  2025-07-16  1:31 [PATCH] scsi: mpi3mr: Emit uevent on controller diagnostic fault Salomon Dushimirimana
@ 2025-07-16 15:51 ` Bart Van Assche
  2025-07-17 19:40   ` [PATCH v2] " Salomon Dushimirimana
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Van Assche @ 2025-07-16 15:51 UTC (permalink / raw)
  To: Salomon Dushimirimana, Sathya Prakash Veerichetty, Kashyap Desai,
	Sumit Saxena, Sreekanth Reddy, James E.J. Bottomley,
	Martin K. Petersen
  Cc: mpi3mr-linuxdrv.pdl, linux-scsi, linux-kernel

On 7/15/25 6:31 PM, Salomon Dushimirimana wrote:
> +	ioc_info(mrioc, "emitting fault exception uevent");

Is it really necessary to log that a uevent will be emitted?

> +exit:
> +	kfree(env);
> +}
Why an explicit kfree() call instead of adding __free(kfree) to
the declaration of "env"?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] scsi: mpi3mr: Emit uevent on controller diagnostic fault
  2025-07-16 15:51 ` Bart Van Assche
@ 2025-07-17 19:40   ` Salomon Dushimirimana
  2025-07-18 15:43     ` Sathya Prakash Veerichetty
  2025-07-31 15:45     ` Dan Carpenter
  0 siblings, 2 replies; 7+ messages in thread
From: Salomon Dushimirimana @ 2025-07-17 19:40 UTC (permalink / raw)
  To: bvanassche
  Cc: James.Bottomley, kashyap.desai, linux-kernel, linux-scsi,
	martin.petersen, mpi3mr-linuxdrv.pdl, salomondush, sathya.prakash,
	sreekanth.reddy, sumit.saxena

Introduces a uevent mechanism to notify userspace when the controller
undergoes a reset due to a diagnostic fault. A new function,
mpi3mr_fault_event_emit(), is added and called from the reset path. This
function filters for a diagnostic fault type
(MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT) and generates a uevent
containing details about the event:

- DRIVER: mpi3mr in this case
- HBA_NUM: scsi host id
- EVENT_TYPE: indicates fatal error
- RESET_TYPE: type of reset that has occurred
- RESET_REASON: specific reason for the reset

This will allow userspace tools to subscribe to these events and take
appropriate action.

Signed-off-by: Salomon Dushimirimana <salomondush@google.com>
---
Changes in v2:
- Addressed feedback from Bart regarding use of __free(kfree) and more

 drivers/scsi/mpi3mr/mpi3mr_fw.c | 37 +++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
index 1d7901a8f0e40..a050c4535ad82 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -1623,6 +1623,42 @@ static inline void mpi3mr_set_diagsave(struct mpi3mr_ioc *mrioc)
 	writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
 }
 
+/**
+ * mpi3mr_fault_uevent_emit - Emit uevent for a controller diagnostic fault
+ * @mrioc: Pointer to the mpi3mr_ioc structure for the controller instance
+ * @reset_type: The type of reset that has occurred
+ * @reset_reason: The specific reason code for the reset
+ *
+ * This function is invoked when the controller undergoes a reset. It specifically
+ * filters for MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT and ignores other
+ * reset types, such as soft resets.
+ */
+static void mpi3mr_fault_uevent_emit(struct mpi3mr_ioc *mrioc, u16 reset_type,
+	u16 reset_reason)
+{
+	struct kobj_uevent_env *env __free(kfree);
+
+	if (reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT)
+		return;
+
+	env = kzalloc(sizeof(*env), GFP_KERNEL);
+	if (!env)
+		return;
+
+	if (add_uevent_var(env, "DRIVER=%s", mrioc->driver_name))
+		return;
+	if (add_uevent_var(env, "HBA_NUM=%u", mrioc->id))
+		return;
+	if (add_uevent_var(env, "EVENT_TYPE=FATAL_ERROR"))
+		return;
+	if (add_uevent_var(env, "RESET_TYPE=%s", mpi3mr_reset_type_name(reset_type)))
+		return;
+	if (add_uevent_var(env, "RESET_REASON=%s", mpi3mr_reset_rc_name(reset_reason)))
+		return;
+
+	kobject_uevent_env(&mrioc->shost->shost_gendev.kobj, KOBJ_CHANGE, env->envp);
+}
+
 /**
  * mpi3mr_issue_reset - Issue reset to the controller
  * @mrioc: Adapter reference
@@ -1741,6 +1777,7 @@ static int mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type,
 	    ioc_config);
 	if (retval)
 		mrioc->unrecoverable = 1;
+	mpi3mr_fault_uevent_emit(mrioc, reset_type, reset_reason);
 	return retval;
 }
 
-- 
2.50.0.727.gbf7dc18ff4-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] scsi: mpi3mr: Emit uevent on controller diagnostic fault
  2025-07-17 19:40   ` [PATCH v2] " Salomon Dushimirimana
@ 2025-07-18 15:43     ` Sathya Prakash Veerichetty
  2025-07-18 23:31       ` Salomon Dushimirimana
  2025-07-31 15:45     ` Dan Carpenter
  1 sibling, 1 reply; 7+ messages in thread
From: Sathya Prakash Veerichetty @ 2025-07-18 15:43 UTC (permalink / raw)
  To: Salomon Dushimirimana
  Cc: bvanassche, James.Bottomley, kashyap.desai, linux-kernel,
	linux-scsi, martin.petersen, mpi3mr-linuxdrv.pdl, sreekanth.reddy,
	sumit.saxena

[-- Attachment #1: Type: text/plain, Size: 3809 bytes --]

On Thu, Jul 17, 2025 at 1:40 PM Salomon Dushimirimana
<salomondush@google.com> wrote:
>
> Introduces a uevent mechanism to notify userspace when the controller
> undergoes a reset due to a diagnostic fault. A new function,
> mpi3mr_fault_event_emit(), is added and called from the reset path. This
> function filters for a diagnostic fault type
> (MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT) and generates a uevent
> containing details about the event:
>
> - DRIVER: mpi3mr in this case
> - HBA_NUM: scsi host id
> - EVENT_TYPE: indicates fatal error
> - RESET_TYPE: type of reset that has occurred
> - RESET_REASON: specific reason for the reset
>
> This will allow userspace tools to subscribe to these events and take
> appropriate action.
What is the reason for userpace tools to know these events and what
user space tools we are talking about here?  Also, on what basis it is
decided only diag fault reset is considered as FATAL.  I would prefer
to understand the actual requirement before ACKing this patch.  If we
need this kind of user space notification then it would be better to
make it generic and let the notification sent for all firmware fault
codes.

>
> Signed-off-by: Salomon Dushimirimana <salomondush@google.com>
> ---
> Changes in v2:
> - Addressed feedback from Bart regarding use of __free(kfree) and more
>
>  drivers/scsi/mpi3mr/mpi3mr_fw.c | 37 +++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
> index 1d7901a8f0e40..a050c4535ad82 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
> @@ -1623,6 +1623,42 @@ static inline void mpi3mr_set_diagsave(struct mpi3mr_ioc *mrioc)
>         writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
>  }
>
> +/**
> + * mpi3mr_fault_uevent_emit - Emit uevent for a controller diagnostic fault
> + * @mrioc: Pointer to the mpi3mr_ioc structure for the controller instance
> + * @reset_type: The type of reset that has occurred
> + * @reset_reason: The specific reason code for the reset
> + *
> + * This function is invoked when the controller undergoes a reset. It specifically
> + * filters for MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT and ignores other
> + * reset types, such as soft resets.
> + */
> +static void mpi3mr_fault_uevent_emit(struct mpi3mr_ioc *mrioc, u16 reset_type,
> +       u16 reset_reason)
> +{
> +       struct kobj_uevent_env *env __free(kfree);
> +
> +       if (reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT)
> +               return;
> +
> +       env = kzalloc(sizeof(*env), GFP_KERNEL);
> +       if (!env)
> +               return;
> +
> +       if (add_uevent_var(env, "DRIVER=%s", mrioc->driver_name))
> +               return;
> +       if (add_uevent_var(env, "HBA_NUM=%u", mrioc->id))
> +               return;
> +       if (add_uevent_var(env, "EVENT_TYPE=FATAL_ERROR"))
> +               return;
> +       if (add_uevent_var(env, "RESET_TYPE=%s", mpi3mr_reset_type_name(reset_type)))
> +               return;
> +       if (add_uevent_var(env, "RESET_REASON=%s", mpi3mr_reset_rc_name(reset_reason)))
> +               return;
> +
> +       kobject_uevent_env(&mrioc->shost->shost_gendev.kobj, KOBJ_CHANGE, env->envp);
> +}
> +
>  /**
>   * mpi3mr_issue_reset - Issue reset to the controller
>   * @mrioc: Adapter reference
> @@ -1741,6 +1777,7 @@ static int mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type,
>             ioc_config);
>         if (retval)
>                 mrioc->unrecoverable = 1;
> +       mpi3mr_fault_uevent_emit(mrioc, reset_type, reset_reason);
>         return retval;
>  }
>
> --
> 2.50.0.727.gbf7dc18ff4-goog
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4214 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] scsi: mpi3mr: Emit uevent on controller diagnostic fault
  2025-07-18 15:43     ` Sathya Prakash Veerichetty
@ 2025-07-18 23:31       ` Salomon Dushimirimana
  2025-07-21 15:45         ` Sathya Prakash Veerichetty
  0 siblings, 1 reply; 7+ messages in thread
From: Salomon Dushimirimana @ 2025-07-18 23:31 UTC (permalink / raw)
  To: Sathya Prakash Veerichetty
  Cc: bvanassche, James.Bottomley, kashyap.desai, linux-kernel,
	linux-scsi, martin.petersen, mpi3mr-linuxdrv.pdl, sreekanth.reddy,
	sumit.saxena

When the controller encounters a fatal error event, we want to notify
our userspace tools to react to these events and pull the
corresponding logs/snapdump from the ioc. There's a list of other
drivers doing something similar, such as drivers/scsi/qla2xxx,
drivers/scsi/qedf/qedf_dbg.c, etc.

So the mpi3mr_issue_reset function only supports two types of resets,
i.e MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET and
MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT for now. From the code,
it seems like only diag fault reset generages a snapdump, soft resets
do not, hence why we only emit the fatal uevent on diag fault.

Thanks,
Salomon Dushimirimana

Salomon Dushimirimana


On Fri, Jul 18, 2025 at 8:43 AM Sathya Prakash Veerichetty
<sathya.prakash@broadcom.com> wrote:
>
> On Thu, Jul 17, 2025 at 1:40 PM Salomon Dushimirimana
> <salomondush@google.com> wrote:
> >
> > Introduces a uevent mechanism to notify userspace when the controller
> > undergoes a reset due to a diagnostic fault. A new function,
> > mpi3mr_fault_event_emit(), is added and called from the reset path. This
> > function filters for a diagnostic fault type
> > (MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT) and generates a uevent
> > containing details about the event:
> >
> > - DRIVER: mpi3mr in this case
> > - HBA_NUM: scsi host id
> > - EVENT_TYPE: indicates fatal error
> > - RESET_TYPE: type of reset that has occurred
> > - RESET_REASON: specific reason for the reset
> >
> > This will allow userspace tools to subscribe to these events and take
> > appropriate action.
> What is the reason for userpace tools to know these events and what
> user space tools we are talking about here?  Also, on what basis it is
> decided only diag fault reset is considered as FATAL.  I would prefer
> to understand the actual requirement before ACKing this patch.  If we
> need this kind of user space notification then it would be better to
> make it generic and let the notification sent for all firmware fault
> codes.
>
> >
> > Signed-off-by: Salomon Dushimirimana <salomondush@google.com>
> > ---
> > Changes in v2:
> > - Addressed feedback from Bart regarding use of __free(kfree) and more
> >
> >  drivers/scsi/mpi3mr/mpi3mr_fw.c | 37 +++++++++++++++++++++++++++++++++
> >  1 file changed, 37 insertions(+)
> >
> > diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
> > index 1d7901a8f0e40..a050c4535ad82 100644
> > --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
> > +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
> > @@ -1623,6 +1623,42 @@ static inline void mpi3mr_set_diagsave(struct mpi3mr_ioc *mrioc)
> >         writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
> >  }
> >
> > +/**
> > + * mpi3mr_fault_uevent_emit - Emit uevent for a controller diagnostic fault
> > + * @mrioc: Pointer to the mpi3mr_ioc structure for the controller instance
> > + * @reset_type: The type of reset that has occurred
> > + * @reset_reason: The specific reason code for the reset
> > + *
> > + * This function is invoked when the controller undergoes a reset. It specifically
> > + * filters for MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT and ignores other
> > + * reset types, such as soft resets.
> > + */
> > +static void mpi3mr_fault_uevent_emit(struct mpi3mr_ioc *mrioc, u16 reset_type,
> > +       u16 reset_reason)
> > +{
> > +       struct kobj_uevent_env *env __free(kfree);
> > +
> > +       if (reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT)
> > +               return;
> > +
> > +       env = kzalloc(sizeof(*env), GFP_KERNEL);
> > +       if (!env)
> > +               return;
> > +
> > +       if (add_uevent_var(env, "DRIVER=%s", mrioc->driver_name))
> > +               return;
> > +       if (add_uevent_var(env, "HBA_NUM=%u", mrioc->id))
> > +               return;
> > +       if (add_uevent_var(env, "EVENT_TYPE=FATAL_ERROR"))
> > +               return;
> > +       if (add_uevent_var(env, "RESET_TYPE=%s", mpi3mr_reset_type_name(reset_type)))
> > +               return;
> > +       if (add_uevent_var(env, "RESET_REASON=%s", mpi3mr_reset_rc_name(reset_reason)))
> > +               return;
> > +
> > +       kobject_uevent_env(&mrioc->shost->shost_gendev.kobj, KOBJ_CHANGE, env->envp);
> > +}
> > +
> >  /**
> >   * mpi3mr_issue_reset - Issue reset to the controller
> >   * @mrioc: Adapter reference
> > @@ -1741,6 +1777,7 @@ static int mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type,
> >             ioc_config);
> >         if (retval)
> >                 mrioc->unrecoverable = 1;
> > +       mpi3mr_fault_uevent_emit(mrioc, reset_type, reset_reason);
> >         return retval;
> >  }
> >
> > --
> > 2.50.0.727.gbf7dc18ff4-goog
> >

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] scsi: mpi3mr: Emit uevent on controller diagnostic fault
  2025-07-18 23:31       ` Salomon Dushimirimana
@ 2025-07-21 15:45         ` Sathya Prakash Veerichetty
  0 siblings, 0 replies; 7+ messages in thread
From: Sathya Prakash Veerichetty @ 2025-07-21 15:45 UTC (permalink / raw)
  To: Salomon Dushimirimana
  Cc: bvanassche, James.Bottomley, kashyap.desai, linux-kernel,
	linux-scsi, martin.petersen, mpi3mr-linuxdrv.pdl, sreekanth.reddy,
	sumit.saxena

[-- Attachment #1: Type: text/plain, Size: 5541 bytes --]

On Fri, Jul 18, 2025 at 5:31 PM Salomon Dushimirimana
<salomondush@google.com> wrote:
>
> When the controller encounters a fatal error event, we want to notify
> our userspace tools to react to these events and pull the
> corresponding logs/snapdump from the ioc. There's a list of other
> drivers doing something similar, such as drivers/scsi/qla2xxx,
> drivers/scsi/qedf/qedf_dbg.c, etc.
>
> So the mpi3mr_issue_reset function only supports two types of resets,
> i.e MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET and
> MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT for now. From the code,
> it seems like only diag fault reset generages a snapdump, soft resets
> do not, hence why we only emit the fatal uevent on diag fault.
The driver issues diag fault reset when it observes some anomaly at
the driver level, however, the firmware can fault asynchronously when
there is a problem detected at the firmware level and snapdumps will
be created for those too. So just emitting the event only for diag
fault reset will not help to capture diag data captured for firmware
faults and we may need to filter only based on reset reason and not
based on reset type.
> Thanks,
> Salomon Dushimirimana
>
> Salomon Dushimirimana
>
>
> On Fri, Jul 18, 2025 at 8:43 AM Sathya Prakash Veerichetty
> <sathya.prakash@broadcom.com> wrote:
> >
> > On Thu, Jul 17, 2025 at 1:40 PM Salomon Dushimirimana
> > <salomondush@google.com> wrote:
> > >
> > > Introduces a uevent mechanism to notify userspace when the controller
> > > undergoes a reset due to a diagnostic fault. A new function,
> > > mpi3mr_fault_event_emit(), is added and called from the reset path. This
> > > function filters for a diagnostic fault type
> > > (MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT) and generates a uevent
> > > containing details about the event:
> > >
> > > - DRIVER: mpi3mr in this case
> > > - HBA_NUM: scsi host id
> > > - EVENT_TYPE: indicates fatal error
> > > - RESET_TYPE: type of reset that has occurred
> > > - RESET_REASON: specific reason for the reset
> > >
> > > This will allow userspace tools to subscribe to these events and take
> > > appropriate action.
> > What is the reason for userpace tools to know these events and what
> > user space tools we are talking about here?  Also, on what basis it is
> > decided only diag fault reset is considered as FATAL.  I would prefer
> > to understand the actual requirement before ACKing this patch.  If we
> > need this kind of user space notification then it would be better to
> > make it generic and let the notification sent for all firmware fault
> > codes.
> >
> > >
> > > Signed-off-by: Salomon Dushimirimana <salomondush@google.com>
> > > ---
> > > Changes in v2:
> > > - Addressed feedback from Bart regarding use of __free(kfree) and more
> > >
> > >  drivers/scsi/mpi3mr/mpi3mr_fw.c | 37 +++++++++++++++++++++++++++++++++
> > >  1 file changed, 37 insertions(+)
> > >
> > > diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
> > > index 1d7901a8f0e40..a050c4535ad82 100644
> > > --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
> > > +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
> > > @@ -1623,6 +1623,42 @@ static inline void mpi3mr_set_diagsave(struct mpi3mr_ioc *mrioc)
> > >         writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
> > >  }
> > >
> > > +/**
> > > + * mpi3mr_fault_uevent_emit - Emit uevent for a controller diagnostic fault
> > > + * @mrioc: Pointer to the mpi3mr_ioc structure for the controller instance
> > > + * @reset_type: The type of reset that has occurred
> > > + * @reset_reason: The specific reason code for the reset
> > > + *
> > > + * This function is invoked when the controller undergoes a reset. It specifically
> > > + * filters for MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT and ignores other
> > > + * reset types, such as soft resets.
> > > + */
> > > +static void mpi3mr_fault_uevent_emit(struct mpi3mr_ioc *mrioc, u16 reset_type,
> > > +       u16 reset_reason)
> > > +{
> > > +       struct kobj_uevent_env *env __free(kfree);
> > > +
> > > +       if (reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT)
> > > +               return;
> > > +
> > > +       env = kzalloc(sizeof(*env), GFP_KERNEL);
> > > +       if (!env)
> > > +               return;
> > > +
> > > +       if (add_uevent_var(env, "DRIVER=%s", mrioc->driver_name))
> > > +               return;
> > > +       if (add_uevent_var(env, "HBA_NUM=%u", mrioc->id))
> > > +               return;
> > > +       if (add_uevent_var(env, "EVENT_TYPE=FATAL_ERROR"))
> > > +               return;
> > > +       if (add_uevent_var(env, "RESET_TYPE=%s", mpi3mr_reset_type_name(reset_type)))
> > > +               return;
> > > +       if (add_uevent_var(env, "RESET_REASON=%s", mpi3mr_reset_rc_name(reset_reason)))
> > > +               return;
> > > +
> > > +       kobject_uevent_env(&mrioc->shost->shost_gendev.kobj, KOBJ_CHANGE, env->envp);
> > > +}
> > > +
> > >  /**
> > >   * mpi3mr_issue_reset - Issue reset to the controller
> > >   * @mrioc: Adapter reference
> > > @@ -1741,6 +1777,7 @@ static int mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type,
> > >             ioc_config);
> > >         if (retval)
> > >                 mrioc->unrecoverable = 1;
> > > +       mpi3mr_fault_uevent_emit(mrioc, reset_type, reset_reason);
> > >         return retval;
> > >  }
> > >
> > > --
> > > 2.50.0.727.gbf7dc18ff4-goog
> > >

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4214 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] scsi: mpi3mr: Emit uevent on controller diagnostic fault
  2025-07-17 19:40   ` [PATCH v2] " Salomon Dushimirimana
  2025-07-18 15:43     ` Sathya Prakash Veerichetty
@ 2025-07-31 15:45     ` Dan Carpenter
  1 sibling, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2025-07-31 15:45 UTC (permalink / raw)
  To: oe-kbuild, Salomon Dushimirimana, bvanassche
  Cc: lkp, oe-kbuild-all, James.Bottomley, kashyap.desai, linux-kernel,
	linux-scsi, martin.petersen, mpi3mr-linuxdrv.pdl, salomondush,
	sathya.prakash, sreekanth.reddy, sumit.saxena

Hi Salomon,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Salomon-Dushimirimana/scsi-mpi3mr-Emit-uevent-on-controller-diagnostic-fault/20250718-034234
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link:    https://lore.kernel.org/r/20250717194025.3218107-1-salomondush%40google.com
patch subject: [PATCH v2] scsi: mpi3mr: Emit uevent on controller diagnostic fault
config: x86_64-randconfig-161-20250720 (https://download.01.org/0day-ci/archive/20250721/202507211423.eXWSnhP5-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202507211423.eXWSnhP5-lkp@intel.com/

New smatch warnings:
drivers/scsi/mpi3mr/mpi3mr_fw.c:1639 mpi3mr_fault_uevent_emit() error: uninitialized symbol 'env'.

vim +/env +1639 drivers/scsi/mpi3mr/mpi3mr_fw.c

8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1636  static void mpi3mr_fault_uevent_emit(struct mpi3mr_ioc *mrioc, u16 reset_type,
8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1637  	u16 reset_reason)
8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1638  {
8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17 @1639  	struct kobj_uevent_env *env __free(kfree);

This has to be initialized before we return

8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1640  
8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1641  	if (reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT)
8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1642  		return;

otherwise this is an uninitialized variable at this return.

8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1643  
8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1644  	env = kzalloc(sizeof(*env), GFP_KERNEL);
8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1645  	if (!env)
8fe63dbd42cc3b Salomon Dushimirimana 2025-07-17  1646  		return;

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-31 15:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16  1:31 [PATCH] scsi: mpi3mr: Emit uevent on controller diagnostic fault Salomon Dushimirimana
2025-07-16 15:51 ` Bart Van Assche
2025-07-17 19:40   ` [PATCH v2] " Salomon Dushimirimana
2025-07-18 15:43     ` Sathya Prakash Veerichetty
2025-07-18 23:31       ` Salomon Dushimirimana
2025-07-21 15:45         ` Sathya Prakash Veerichetty
2025-07-31 15:45     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).