diff mbox

mpt3sas: correct reset of smid while clearing scsi tracker

Message ID 1531891375-31216-1-git-send-email-sreekanth.reddy@broadcom.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Sreekanth Reddy July 18, 2018, 5:22 a.m. UTC
In mpt3sas_base_clear_st() function smid value is reseted in wrong line,
i.e. driver should reset smid value to zero after decrementing chain_offset
counter in chain_lookup table but in current code, driver is resetting smid
value before decrementing the chain_offset counter. which we are correcting
with this patch.

Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tomas Henzl July 18, 2018, 11:36 a.m. UTC | #1
On 07/18/2018 07:22 AM, Sreekanth Reddy wrote:
> In mpt3sas_base_clear_st() function smid value is reseted in wrong line,
> i.e. driver should reset smid value to zero after decrementing chain_offset
> counter in chain_lookup table but in current code, driver is resetting smid
> value before decrementing the chain_offset counter. which we are correcting
> with this patch.
>
> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>

Fixes: 2b548dd3790f95c2e174d51c2c8ada71b6505b4e
scsi: mpt3sas: Fix calltrace observed while running IO & reset

Maybe both patches could be merged. 

Reviewed-by: Tomas Henzl <thenzl@redhat.com>

Tomas

> ---
>  drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
> index 902610d..94b939b 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
> @@ -3283,8 +3283,8 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc,
>  		return;
>  	st->cb_idx = 0xFF;
>  	st->direct_io = 0;
> -	st->smid = 0;
>  	atomic_set(&ioc->chain_lookup[st->smid - 1].chain_offset, 0);
> +	st->smid = 0;
>  }
>  
>  /**
Bart Van Assche July 18, 2018, 2:08 p.m. UTC | #2
On Wed, 2018-07-18 at 01:22 -0400, Sreekanth Reddy wrote:
> In mpt3sas_base_clear_st() function smid value is reseted in wrong line,
> i.e. driver should reset smid value to zero after decrementing chain_offset
> counter in chain_lookup table but in current code, driver is resetting smid
> value before decrementing the chain_offset counter. which we are correcting
> with this patch.
> 
> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> ---
>  drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
> index 902610d..94b939b 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
> @@ -3283,8 +3283,8 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc,
>  		return;
>  	st->cb_idx = 0xFF;
>  	st->direct_io = 0;
> -	st->smid = 0;
>  	atomic_set(&ioc->chain_lookup[st->smid - 1].chain_offset, 0);
> +	st->smid = 0;
>  }

How can this patch be correct without memory barrier between the atomic set and the
st->smid assignment?

Bart.
Sreekanth Reddy July 19, 2018, 6:33 a.m. UTC | #3
On Wed, Jul 18, 2018 at 7:38 PM, Bart Van Assche <Bart.VanAssche@wdc.com> wrote:
> On Wed, 2018-07-18 at 01:22 -0400, Sreekanth Reddy wrote:
>> In mpt3sas_base_clear_st() function smid value is reseted in wrong line,
>> i.e. driver should reset smid value to zero after decrementing chain_offset
>> counter in chain_lookup table but in current code, driver is resetting smid
>> value before decrementing the chain_offset counter. which we are correcting
>> with this patch.
>>
>> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
>> ---
>>  drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
>> index 902610d..94b939b 100644
>> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
>> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
>> @@ -3283,8 +3283,8 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc,
>>               return;
>>       st->cb_idx = 0xFF;
>>       st->direct_io = 0;
>> -     st->smid = 0;
>>       atomic_set(&ioc->chain_lookup[st->smid - 1].chain_offset, 0);
>> +     st->smid = 0;
>>  }
>
> How can this patch be correct without memory barrier between the atomic set and the
> st->smid assignment?

Yes I agree that I need to add memory barrier around atomic_set() API.
I was not aware of this before.

Is it fine to use smp_mb__before_atomic() API before atomic_set() &
smp_mb__after_atomic() API after atomic_set?

Also in other places in driver, we are using atomic_inc() &
atomic_dec() APIs without memory barrier, I need to add memory barrier
their too. So is it fine to post separate patch for adding memory
barrier around atomic_xyz() APIs? if yes then please consider this
patch and I will post separate patch for adding memory barriers around
the atomic_xyz() APIs.

Thanks,
Sreekanth

>
> Bart.
>
>
Bart Van Assche Aug. 8, 2018, 3:07 p.m. UTC | #4
On Wed, 2018-07-18 at 01:22 -0400, Sreekanth Reddy wrote:
> In mpt3sas_base_clear_st() function smid value is reseted in wrong line,
> i.e. driver should reset smid value to zero after decrementing chain_offset
> counter in chain_lookup table but in current code, driver is resetting smid
> value before decrementing the chain_offset counter. which we are correcting
> with this patch.
> 
> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
> ---
>  drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
> index 902610d..94b939b 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
> @@ -3283,8 +3283,8 @@ void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc,
>  		return;
>  	st->cb_idx = 0xFF;
>  	st->direct_io = 0;
> -	st->smid = 0;
>  	atomic_set(&ioc->chain_lookup[st->smid - 1].chain_offset, 0);
> +	st->smid = 0;
>  }
>  
>  /**

Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Martin K. Petersen Aug. 9, 2018, 1:29 a.m. UTC | #5
Tomas,

> Fixes: 2b548dd3790f95c2e174d51c2c8ada71b6505b4e
> scsi: mpt3sas: Fix calltrace observed while running IO & reset
>
> Maybe both patches could be merged. 

Merged the fix into the patch above.
diff mbox

Patch

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 902610d..94b939b 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -3283,8 +3283,8 @@  void mpt3sas_base_clear_st(struct MPT3SAS_ADAPTER *ioc,
 		return;
 	st->cb_idx = 0xFF;
 	st->direct_io = 0;
-	st->smid = 0;
 	atomic_set(&ioc->chain_lookup[st->smid - 1].chain_offset, 0);
+	st->smid = 0;
 }
 
 /**