scsi: mpi3mr: Emit uevent on controller diagnostic fault
Subsystems (2)
PATCH 1/1 scsi: mpi3mr: Emit uevent on controller diagnostic fault
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.
--- drivers/scsi/mpi3mr/mpi3mr_fw.c | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_fw.c +42 -0
@@ -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; }
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
drivers/scsi/mpi3mr/mpi3mr_fw.c static inline void mpi3mr_set_diagsave(struct mpi3mr_ioc *mrioc) · line 1644
Quoted 1 line · Salomon Dushimirimana
drivers/scsi/mpi3mr/mpi3mr_fw.c +1
-0+ioc_info (mrioc,"emitting fault exception uevent" );
Is it really necessary to log that a uevent will be emitted?
drivers/scsi/mpi3mr/mpi3mr_fw.c static inline void mpi3mr_set_diagsave(struct mpi3mr_ioc *mrioc) · line 1665
Quoted 3 lines
drivers/scsi/mpi3mr/mpi3mr_fw.c +3
-0+exit: +kfree (env); +}
Why an explicit kfree() call instead of adding __free(kfree) to the declaration of "env"?
Thanks,
Bart.
PATCH v2 1/1 scsi: mpi3mr: Emit uevent on controller diagnostic fault
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.
---
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(+)
drivers/scsi/mpi3mr/mpi3mr_fw.c +37 -0
@@ -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; }
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
Sathya Prakash Veerichetty
maintainerQuoted 8 lines · 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:
Quoted 8 lines
- 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 resetThis 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.
Quoted 67 lines
Signed-off-by Salomon Dushimirimana <[email protected]>---
Changes in v2:
- Addressed feedback from Bart regarding use of__free(kfree)and moredrivers/scsi/mpi3mr/mpi3mr_fw.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)drivers/scsi/mpi3mr/mpi3mr_fw.c +37
-1@@ -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
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
Quoted 94 lines · Sathya Prakash Veerichetty
Quoted 8 lines · 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:Quoted 8 lines
- 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 resetThis 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.
Quoted 67 lines
Signed-off-by Salomon Dushimirimana <[email protected]>---
Changes in v2:
- Addressed feedback from Bart regarding use of__free(kfree)and moredrivers/scsi/mpi3mr/mpi3mr_fw.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)drivers/scsi/mpi3mr/mpi3mr_fw.c +37
-1@@ -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
Sathya Prakash Veerichetty
maintainerQuoted 7 lines · Salomon Dushimirimana
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.
Quoted 5 lines
So the
mpi3mr_issue_resetfunction only supports two types of resets, i.eMPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESETandMPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULTfor 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.
Quoted 102 lines
Thanks,
Salomon DushimirimanaSalomon Dushimirimana
Quoted 94 lines · Sathya Prakash Veerichetty
Quoted 8 lines · 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:Quoted 8 lines
- 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 resetThis 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.
Quoted 67 lines
Signed-off-by Salomon Dushimirimana <[email protected]>---
Changes in v2:
- Addressed feedback from Bart regarding use of__free(kfree)and moredrivers/scsi/mpi3mr/mpi3mr_fw.c | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)drivers/scsi/mpi3mr/mpi3mr_fw.c +37
-1@@ -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
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/[email protected]/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 <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
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;
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki