diff mbox series

[RESEND,v1] scsi: ufs: exclude UECxx from SFR dump list

Message ID 1646621010-118886-1-git-send-email-kwmad.kim@samsung.com
State Superseded
Headers show
Series [RESEND,v1] scsi: ufs: exclude UECxx from SFR dump list | expand

Commit Message

Kiwoong Kim March 7, 2022, 2:43 a.m. UTC
These are ROC type things that means their values
are cleared when the SFRs are read.
They are usually read in ISR when an UIC error occur.
Thus, their values would be zero at many cases. And
there might be a little bit risky when they are read to
be cleared before the ISR reads them, e.g. the case that
a command is timed-out, ufshcd_dump_regs is called in
ufshcd_abort and an UIC error occurs at the nearly
same time. In this case, ISR will be called but UFS error handler
will not be scheduled.
This patch is to make UFS driver not read those SFRs in the
dump function, i.e. ufshcd_dump_regs.

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Adrian Hunter March 8, 2022, 5:15 a.m. UTC | #1
On 07/03/2022 04:43, Kiwoong Kim wrote:
> These are ROC type things that means their values
> are cleared when the SFRs are read.
> They are usually read in ISR when an UIC error occur.
> Thus, their values would be zero at many cases. And
> there might be a little bit risky when they are read to
> be cleared before the ISR reads them, e.g. the case that
> a command is timed-out, ufshcd_dump_regs is called in
> ufshcd_abort and an UIC error occurs at the nearly
> same time. In this case, ISR will be called but UFS error handler
> will not be scheduled.
> This patch is to make UFS driver not read those SFRs in the
> dump function, i.e. ufshcd_dump_regs.
> 
> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
> ---
>  drivers/scsi/ufs/ufshcd.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 460d2b4..8b65c081 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -115,8 +115,12 @@ int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
>  	if (!regs)
>  		return -ENOMEM;
>  
> -	for (pos = 0; pos < len; pos += 4)
> +	for (pos = 0; pos < len; pos += 4) {
> +		if (pos >= REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER	&&
> +		    pos <= REG_UIC_ERROR_CODE_DME)

Doesn't that need to be 'pos + offset' not just 'pos'

> +			continue;
>  		regs[pos / 4] = ufshcd_readl(hba, offset + pos);
> +	}
>  
>  	ufshcd_hex_dump(prefix, regs, len);
>  	kfree(regs);
Kiwoong Kim March 8, 2022, 8:10 a.m. UTC | #2
> > -	for (pos = 0; pos < len; pos += 4)
> > +	for (pos = 0; pos < len; pos += 4) {
> > +		if (pos >= REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER	&&
> > +		    pos <= REG_UIC_ERROR_CODE_DME)
> 
> Doesn't that need to be 'pos + offset' not just 'pos'
> 

For only ufshcd.c, offset is always zero, so 'offset' doesn't need to be referred to.
But now I think the function is currently public to external modules.

Okay, let me modify this.

Thanks.
Kiwoong Kim
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 460d2b4..8b65c081 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -115,8 +115,12 @@  int ufshcd_dump_regs(struct ufs_hba *hba, size_t offset, size_t len,
 	if (!regs)
 		return -ENOMEM;
 
-	for (pos = 0; pos < len; pos += 4)
+	for (pos = 0; pos < len; pos += 4) {
+		if (pos >= REG_UIC_ERROR_CODE_PHY_ADAPTER_LAYER	&&
+		    pos <= REG_UIC_ERROR_CODE_DME)
+			continue;
 		regs[pos / 4] = ufshcd_readl(hba, offset + pos);
+	}
 
 	ufshcd_hex_dump(prefix, regs, len);
 	kfree(regs);