linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion
@ 2023-02-15 12:37 Po-Wen Kao
  2023-02-15 12:37 ` [PATCH 2/2] scsi: ufs: core: Export symbol ufshcd_mcq_read_cqis() Po-Wen Kao
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Po-Wen Kao @ 2023-02-15 12:37 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
	Martin K. Petersen, Matthias Brugger
  Cc: wsd_upstream, peter.wang, stanley.chu, powen.kao, alice.chao,
	chun-hung.wu, cc.chou, chaotian.jing, jiajie.hao, mason.zhang,
	quic_asutoshd, linux-scsi, linux-kernel, linux-arm-kernel,
	linux-mediatek

Transfer command descriptor is allocated in ufshcd_memory_alloc()
and referenced by transfer request descriptor with stride size
sizeof_utp_transfer_cmd_desc()
instead of
sizeof(struct utp_transfer_cmd_desc).

Consequently, computing tag by address offset should also refer to the
same stride.

Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
---
 drivers/ufs/core/ufs-mcq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
index 31df052fbc41..3a27fa4b0024 100644
--- a/drivers/ufs/core/ufs-mcq.c
+++ b/drivers/ufs/core/ufs-mcq.c
@@ -265,7 +265,7 @@ static int ufshcd_mcq_get_tag(struct ufs_hba *hba,
 	addr = (le64_to_cpu(cqe->command_desc_base_addr) & CQE_UCD_BA) -
 		hba->ucdl_dma_addr;
 
-	return div_u64(addr, sizeof(struct utp_transfer_cmd_desc));
+	return div_u64(addr, sizeof_utp_transfer_cmd_desc(hba));
 }
 
 static void ufshcd_mcq_process_cqe(struct ufs_hba *hba,
-- 
2.18.0



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

* [PATCH 2/2] scsi: ufs: core: Export symbol ufshcd_mcq_read_cqis()
  2023-02-15 12:37 [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion Po-Wen Kao
@ 2023-02-15 12:37 ` Po-Wen Kao
  2023-02-15 17:52   ` Christoph Hellwig
  2023-02-15 17:34 ` [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion Bart Van Assche
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Po-Wen Kao @ 2023-02-15 12:37 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
	Martin K. Petersen, Matthias Brugger
  Cc: wsd_upstream, peter.wang, stanley.chu, powen.kao, alice.chao,
	chun-hung.wu, cc.chou, chaotian.jing, jiajie.hao, mason.zhang,
	quic_asutoshd, linux-scsi, linux-kernel, linux-arm-kernel,
	linux-mediatek

Export symbol for driver module

Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
---
 drivers/ufs/core/ufs-mcq.c | 1 +
 include/ufs/ufshcd.h       | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
index 3a27fa4b0024..c97b45cd94ee 100644
--- a/drivers/ufs/core/ufs-mcq.c
+++ b/drivers/ufs/core/ufs-mcq.c
@@ -241,6 +241,7 @@ u32 ufshcd_mcq_read_cqis(struct ufs_hba *hba, int i)
 {
 	return readl(mcq_opr_base(hba, OPR_CQIS, i) + REG_CQIS);
 }
+EXPORT_SYMBOL_GPL(ufshcd_mcq_read_cqis);
 
 void ufshcd_mcq_write_cqis(struct ufs_hba *hba, u32 val, int i)
 {
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index ed9e3d5addb3..57e3b9524b1b 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -1243,6 +1243,8 @@ void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val);
 void ufshcd_hba_stop(struct ufs_hba *hba);
 void ufshcd_schedule_eh_work(struct ufs_hba *hba);
 void ufshcd_mcq_write_cqis(struct ufs_hba *hba, u32 val, int i);
+u32 ufshcd_mcq_read_cqis(struct ufs_hba *hba, int i);
+
 unsigned long ufshcd_mcq_poll_cqe_nolock(struct ufs_hba *hba,
 					 struct ufs_hw_queue *hwq);
 void ufshcd_mcq_enable_esi(struct ufs_hba *hba);
-- 
2.18.0



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

* Re: [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion
  2023-02-15 12:37 [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion Po-Wen Kao
  2023-02-15 12:37 ` [PATCH 2/2] scsi: ufs: core: Export symbol ufshcd_mcq_read_cqis() Po-Wen Kao
@ 2023-02-15 17:34 ` Bart Van Assche
  2023-02-16  0:51 ` Stanley Chu
  2023-02-16  7:40 ` Manivannan Sadhasivam
  3 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2023-02-15 17:34 UTC (permalink / raw)
  To: Po-Wen Kao, Alim Akhtar, Avri Altman, James E.J. Bottomley,
	Martin K. Petersen, Matthias Brugger
  Cc: wsd_upstream, peter.wang, stanley.chu, alice.chao, chun-hung.wu,
	cc.chou, chaotian.jing, jiajie.hao, mason.zhang, quic_asutoshd,
	linux-scsi, linux-kernel, linux-arm-kernel, linux-mediatek

On 2/15/23 04:37, Po-Wen Kao wrote:
> Transfer command descriptor is allocated in ufshcd_memory_alloc()
> and referenced by transfer request descriptor with stride size
> sizeof_utp_transfer_cmd_desc()
> instead of
> sizeof(struct utp_transfer_cmd_desc).
> 
> Consequently, computing tag by address offset should also refer to the
> same stride.
> 
> Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
> ---
>   drivers/ufs/core/ufs-mcq.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
> index 31df052fbc41..3a27fa4b0024 100644
> --- a/drivers/ufs/core/ufs-mcq.c
> +++ b/drivers/ufs/core/ufs-mcq.c
> @@ -265,7 +265,7 @@ static int ufshcd_mcq_get_tag(struct ufs_hba *hba,
>   	addr = (le64_to_cpu(cqe->command_desc_base_addr) & CQE_UCD_BA) -
>   		hba->ucdl_dma_addr;
>   
> -	return div_u64(addr, sizeof(struct utp_transfer_cmd_desc));
> +	return div_u64(addr, sizeof_utp_transfer_cmd_desc(hba));
>   }
>   
>   static void ufshcd_mcq_process_cqe(struct ufs_hba *hba,

Reviewed-by: Bart Van Assche <bvanassche@acm.org>


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

* Re: [PATCH 2/2] scsi: ufs: core: Export symbol ufshcd_mcq_read_cqis()
  2023-02-15 12:37 ` [PATCH 2/2] scsi: ufs: core: Export symbol ufshcd_mcq_read_cqis() Po-Wen Kao
@ 2023-02-15 17:52   ` Christoph Hellwig
  2023-02-21  4:46     ` Powen Kao (高伯文)
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2023-02-15 17:52 UTC (permalink / raw)
  To: Po-Wen Kao
  Cc: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
	Martin K. Petersen, Matthias Brugger, wsd_upstream, peter.wang,
	stanley.chu, alice.chao, chun-hung.wu, cc.chou, chaotian.jing,
	jiajie.hao, mason.zhang, quic_asutoshd, linux-scsi, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Wed, Feb 15, 2023 at 08:37:46PM +0800, Po-Wen Kao wrote:
> Export symbol for driver module

Which one?  We don't export symbols without an actual user.


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

* Re: [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion
  2023-02-15 12:37 [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion Po-Wen Kao
  2023-02-15 12:37 ` [PATCH 2/2] scsi: ufs: core: Export symbol ufshcd_mcq_read_cqis() Po-Wen Kao
  2023-02-15 17:34 ` [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion Bart Van Assche
@ 2023-02-16  0:51 ` Stanley Chu
  2023-02-16  7:40 ` Manivannan Sadhasivam
  3 siblings, 0 replies; 7+ messages in thread
From: Stanley Chu @ 2023-02-16  0:51 UTC (permalink / raw)
  To: Po-Wen Kao
  Cc: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
	Martin K. Petersen, Matthias Brugger, wsd_upstream, peter.wang,
	stanley.chu, alice.chao, chun-hung.wu, cc.chou, chaotian.jing,
	jiajie.hao, mason.zhang, quic_asutoshd, linux-scsi, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Wed, Feb 15, 2023 at 8:38 PM Po-Wen Kao <powen.kao@mediatek.com> wrote:
>
> Transfer command descriptor is allocated in ufshcd_memory_alloc()
> and referenced by transfer request descriptor with stride size
> sizeof_utp_transfer_cmd_desc()
> instead of
> sizeof(struct utp_transfer_cmd_desc).
>
> Consequently, computing tag by address offset should also refer to the
> same stride.
>
> Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>

Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>


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

* Re: [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion
  2023-02-15 12:37 [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion Po-Wen Kao
                   ` (2 preceding siblings ...)
  2023-02-16  0:51 ` Stanley Chu
@ 2023-02-16  7:40 ` Manivannan Sadhasivam
  3 siblings, 0 replies; 7+ messages in thread
From: Manivannan Sadhasivam @ 2023-02-16  7:40 UTC (permalink / raw)
  To: Po-Wen Kao
  Cc: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
	Martin K. Petersen, Matthias Brugger, wsd_upstream, peter.wang,
	stanley.chu, alice.chao, chun-hung.wu, cc.chou, chaotian.jing,
	jiajie.hao, mason.zhang, quic_asutoshd, linux-scsi, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Wed, Feb 15, 2023 at 08:37:45PM +0800, Po-Wen Kao wrote:
> Transfer command descriptor is allocated in ufshcd_memory_alloc()
> and referenced by transfer request descriptor with stride size
> sizeof_utp_transfer_cmd_desc()
> instead of
> sizeof(struct utp_transfer_cmd_desc).
> 
> Consequently, computing tag by address offset should also refer to the
> same stride.
> 
> Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>

Fixes tag?

> ---
>  drivers/ufs/core/ufs-mcq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
> index 31df052fbc41..3a27fa4b0024 100644
> --- a/drivers/ufs/core/ufs-mcq.c
> +++ b/drivers/ufs/core/ufs-mcq.c
> @@ -265,7 +265,7 @@ static int ufshcd_mcq_get_tag(struct ufs_hba *hba,
>  	addr = (le64_to_cpu(cqe->command_desc_base_addr) & CQE_UCD_BA) -
>  		hba->ucdl_dma_addr;
>  
> -	return div_u64(addr, sizeof(struct utp_transfer_cmd_desc));
> +	return div_u64(addr, sizeof_utp_transfer_cmd_desc(hba));

I think it is not a good practice to name variables after the standard
operators like sizeof(). It is confusing at its best.

How about renaming this function to get_ucd_size() or something relevant?

But the change itself LGTM!

Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Thanks,
Mani

>  }
>  
>  static void ufshcd_mcq_process_cqe(struct ufs_hba *hba,
> -- 
> 2.18.0
> 

-- 
மணிவண்ணன் சதாசிவம்


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

* Re: [PATCH 2/2] scsi: ufs: core: Export symbol ufshcd_mcq_read_cqis()
  2023-02-15 17:52   ` Christoph Hellwig
@ 2023-02-21  4:46     ` Powen Kao (高伯文)
  0 siblings, 0 replies; 7+ messages in thread
From: Powen Kao (高伯文) @ 2023-02-21  4:46 UTC (permalink / raw)
  To: hch@infradead.org
  Cc: Peter Wang (王信友),
	linux-kernel@vger.kernel.org,
	Jiajie Hao (郝加节),
	CC Chou (周志杰),
	linux-mediatek@lists.infradead.org,
	Alice Chao (�w��均),
	jejb@linux.ibm.com, wsd_upstream, avri.altman@wdc.com,
	bvanassche@acm.org, martin.petersen@oracle.com,
	Chun-Hung Wu (巫�E宏), alim.akhtar@samsung.com,
	quic_asutoshd@quicinc.com,
	Chaotian Jing (井朝天),
	linux-scsi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Stanley Chu (朱原��),
	matthias.bgg@gmail.com, Mason Zhang (章辉)

Then I will upstream together with our driver change later.

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

end of thread, other threads:[~2023-02-21  5:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-15 12:37 [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion Po-Wen Kao
2023-02-15 12:37 ` [PATCH 2/2] scsi: ufs: core: Export symbol ufshcd_mcq_read_cqis() Po-Wen Kao
2023-02-15 17:52   ` Christoph Hellwig
2023-02-21  4:46     ` Powen Kao (高伯文)
2023-02-15 17:34 ` [PATCH 1/2] scsi: ufs: core: Fix mcq tag calcualtion Bart Van Assche
2023-02-16  0:51 ` Stanley Chu
2023-02-16  7:40 ` Manivannan Sadhasivam

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).