diff mbox series

megaraid_sas: fix for a potential deadlock

Message ID 20240923174833.45345-1-thenzl@redhat.com
State New
Headers show
Series megaraid_sas: fix for a potential deadlock | expand

Commit Message

Tomas Henzl Sept. 23, 2024, 5:48 p.m. UTC
This fixes a 'possible circular locking dependency detected' warning
      CPU0                    CPU1 
      ----                    ---- 
 lock(&instance->reset_mutex); 
                              lock(&shost->scan_mutex); 
                              lock(&instance->reset_mutex); 
 lock(&shost->scan_mutex); 
 

Fix this but temporarily releasing the reset_mutex.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Tomas Henzl Nov. 5, 2024, 4:27 p.m. UTC | #1
On 9/23/24 19:48, Tomas Henzl wrote:
> This fixes a 'possible circular locking dependency detected' warning
>       CPU0                    CPU1 
>       ----                    ---- 
>  lock(&instance->reset_mutex); 
>                               lock(&shost->scan_mutex); 
>                               lock(&instance->reset_mutex); 
>  lock(&shost->scan_mutex); 
>  
> 
> Fix this but temporarily releasing the reset_mutex.
> 
> Signed-off-by: Tomas Henzl <thenzl@redhat.com>
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> index 6c79c350a4d5..253cc1159661 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -8907,8 +8907,11 @@ megasas_aen_polling(struct work_struct *work)
>  						   (ld_target_id / MEGASAS_MAX_DEV_PER_CHANNEL),
>  						   (ld_target_id % MEGASAS_MAX_DEV_PER_CHANNEL),
>  						   0);
> -			if (sdev1)
> +			if (sdev1) {
> +				mutex_unlock(&instance->reset_mutex);
>  				megasas_remove_scsi_device(sdev1);
> +				mutex_lock(&instance->reset_mutex);
> +			}
>  
>  			event_type = SCAN_VD_CHANNEL;
>  			break;

Hi Chandrakanth,

can you please review this patch?

Thanks, Tomas
Chandrakanth Patil Nov. 7, 2024, 8:56 a.m. UTC | #2
On Tue, Nov 5, 2024 at 9:57 PM Tomas Henzl <thenzl@redhat.com> wrote:
>
> On 9/23/24 19:48, Tomas Henzl wrote:
> > This fixes a 'possible circular locking dependency detected' warning
> >       CPU0                    CPU1
> >       ----                    ----
> >  lock(&instance->reset_mutex);
> >                               lock(&shost->scan_mutex);
> >                               lock(&instance->reset_mutex);
> >  lock(&shost->scan_mutex);
> >
> >
> > Fix this but temporarily releasing the reset_mutex.
> >
> > Signed-off-by: Tomas Henzl <thenzl@redhat.com>
> > ---
> >  drivers/scsi/megaraid/megaraid_sas_base.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> > index 6c79c350a4d5..253cc1159661 100644
> > --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> > +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> > @@ -8907,8 +8907,11 @@ megasas_aen_polling(struct work_struct *work)
> >                                                  (ld_target_id / MEGASAS_MAX_DEV_PER_CHANNEL),
> >                                                  (ld_target_id % MEGASAS_MAX_DEV_PER_CHANNEL),
> >                                                  0);
> > -                     if (sdev1)
> > +                     if (sdev1) {
> > +                             mutex_unlock(&instance->reset_mutex);
> >                               megasas_remove_scsi_device(sdev1);
> > +                             mutex_lock(&instance->reset_mutex);
> > +                     }
> >
> >                       event_type = SCAN_VD_CHANNEL;
> >                       break;
>
> Hi Chandrakanth,
>
> can you please review this patch?
>
> Thanks, Tomas
>

Patch looks good to me.

Acked-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Chandrakanth Patil Nov. 7, 2024, 8:57 a.m. UTC | #3
On Mon, Sep 23, 2024 at 11:18 PM Tomas Henzl <thenzl@redhat.com> wrote:
>
> This fixes a 'possible circular locking dependency detected' warning
>       CPU0                    CPU1
>       ----                    ----
>  lock(&instance->reset_mutex);
>                               lock(&shost->scan_mutex);
>                               lock(&instance->reset_mutex);
>  lock(&shost->scan_mutex);
>
>
> Fix this but temporarily releasing the reset_mutex.
>
> Signed-off-by: Tomas Henzl <thenzl@redhat.com>
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> index 6c79c350a4d5..253cc1159661 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -8907,8 +8907,11 @@ megasas_aen_polling(struct work_struct *work)
>                                                    (ld_target_id / MEGASAS_MAX_DEV_PER_CHANNEL),
>                                                    (ld_target_id % MEGASAS_MAX_DEV_PER_CHANNEL),
>                                                    0);
> -                       if (sdev1)
> +                       if (sdev1) {
> +                               mutex_unlock(&instance->reset_mutex);
>                                 megasas_remove_scsi_device(sdev1);
> +                               mutex_lock(&instance->reset_mutex);
> +                       }
>
>                         event_type = SCAN_VD_CHANNEL;
>                         break;
> --
> 2.46.0
>

Patch looks good to me.
Acked-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
diff mbox series

Patch

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 6c79c350a4d5..253cc1159661 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -8907,8 +8907,11 @@  megasas_aen_polling(struct work_struct *work)
 						   (ld_target_id / MEGASAS_MAX_DEV_PER_CHANNEL),
 						   (ld_target_id % MEGASAS_MAX_DEV_PER_CHANNEL),
 						   0);
-			if (sdev1)
+			if (sdev1) {
+				mutex_unlock(&instance->reset_mutex);
 				megasas_remove_scsi_device(sdev1);
+				mutex_lock(&instance->reset_mutex);
+			}
 
 			event_type = SCAN_VD_CHANNEL;
 			break;