mmc: dw_mmc: Add desc_num field for clarity
Subsystems (2)
PATCH v2 1/1 mmc: dw_mmc: Add desc_num field for clarity
From: Shawn Lin <[email protected]>
The ring_size field in struct dw_mci is misleadingly named. Despite its name, it does not represent the size of the descriptor ring buffer in bytes, but rather the number of descriptors allocated within the fixed-size ring buffer.
The actual ring buffer size is fixed at PAGE_SIZE (or DESC_RING_BUF_SZ, which equals PAGE_SIZE). Within this buffer, we allocate either struct idmac_desc or struct idmac_desc_64addr descriptors, and ring_size stores the count of these descriptors.
This naming has caused confusion, as it's also used to set mmc->max_segs (the maximum number of scatter-gather segments), which logically corresponds to the number of descriptors, not a size in bytes.
No functional change is introduced by this naming-only patch.
---
Changes v2:
- remove ring_size
drivers/mmc/host/dw_mmc.c | 16 ++++++++-------- drivers/mmc/host/dw_mmc.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/mmc/host/dw_mmc.c +8 -8
@@ -490,12 +490,12 @@ static int dw_mci_idmac_init(struct dw_mci *host)if (host->dma_64bit_address ==1 ) {struct idmac_desc_64addr *p; -/* Number of descriptors in the ring buffer */ - host->ring_size = + + host->desc_num =DESC_RING_BUF_SZ /sizeof (struct idmac_desc_64addr );/* Forward link the descriptor list */ -for (i =0 , p = host->sg_cpu; i < host->ring_size -1 ; +for (i =0 , p = host->sg_cpu; i < host->desc_num -1 ; i++, p++) { p->des6 = (host->sg_dma + (sizeof(struct idmac_desc_64addr) *
@@ -518,13 +518,13 @@ static int dw_mci_idmac_init(struct dw_mci *host) }else {struct idmac_desc *p; -/* Number of descriptors in the ring buffer */ - host->ring_size = + + host->desc_num =DESC_RING_BUF_SZ /sizeof (struct idmac_desc );/* Forward link the descriptor list */ for (i =0 , p = host->sg_cpu; - i < host->ring_size -1 ; + i < host->desc_num -1 ; i++, p++) { p->des3 =cpu_to_le32 (host->sg_dma + (sizeof (struct idmac_desc ) * (i +1 )));
@@ -2857,10 +2857,10 @@ static int dw_mci_init_host(struct dw_mci *host)/* Useful defaults if platform data is unset. */ if (host->use_dma ==TRANS_MODE_IDMAC ) { - mmc->max_segs = host->ring_size; + mmc->max_segs = host->desc_num; mmc->max_blk_size =65535 ; mmc->max_seg_size =0x1000 ; - mmc->max_req_size = mmc->max_seg_size * host->ring_size; + mmc->max_req_size = mmc->max_seg_size * host->desc_num; mmc->max_blk_count = mmc->max_req_size /512 ; }else if (host->use_dma ==TRANS_MODE_EDMAC ) { mmc->max_segs =64 ;
drivers/mmc/host/dw_mmc.h +2 -2
@@ -79,7 +79,7 @@ struct dw_mci_dma_slave {* @dma_ops: Pointer to DMA callbacks. * @cmd_status: Snapshot of SR taken upon completion of the current * command. Only valid when EVENT_CMD_COMPLETE is pending. -* @ring_size: Buffer size for idma descriptors. +* @desc_num: Number of idmac descriptors available. * @dms: structure of slave-dma private data. * @phy_regs: physical address of controller's register map * @data_status: Snapshot of SR taken upon completion of the current
@@ -186,7 +186,7 @@ struct dw_mci {void *sg_cpu;const struct dw_mci_dma_ops *dma_ops;/* For idmac */ -unsigned int ring_size; +unsigned short desc_num;/* For edmac */ struct dw_mci_dma_slave *dms;
Signature · 1 line
2.25.1
Quoted 13 lines · Shawn Lin
From: Shawn Lin <[email protected]>
The
ring_sizefield in structdw_mciis misleadingly named. Despite its name, it does not represent the size of the descriptor ring buffer in bytes, but rather the number of descriptors allocated within the fixed-size ring buffer.The actual ring buffer size is fixed at
PAGE_SIZE(orDESC_RING_BUF_SZ, which equalsPAGE_SIZE). Within this buffer, we allocate either structidmac_descor structidmac_desc_64addrdescriptors, andring_sizestores the count of these descriptors.
Quoted 8 lines
This naming has caused confusion, as it's also used to set
mmc->max_segs(the maximum number of scatter-gather segments), which logically corresponds to the number of descriptors, not a size in bytes.No functional change is introduced by this naming-only patch.
Signed-off-by Shawn Lin <[email protected]>
Applied for next, thanks!
Kind regards
Uffe
Quoted 84 lines
---
Changes v2:
- removering_sizedrivers/mmc/host/dw_mmc.c | 16 ++++++++-------- drivers/mmc/host/dw_mmc.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-)drivers/mmc/host/dw_mmc.c +8
-8@@ -490,12 +490,12 @@ static int dw_mci_idmac_init(struct dw_mci *host)if (host->dma_64bit_address ==1 ) {struct idmac_desc_64addr *p; -/* Number of descriptors in the ring buffer */ - host->ring_size = + + host->desc_num =DESC_RING_BUF_SZ /sizeof (struct idmac_desc_64addr );/* Forward link the descriptor list */ -for (i =0 , p = host->sg_cpu; i < host->ring_size -1 ; +for (i =0 , p = host->sg_cpu; i < host->desc_num -1 ; i++, p++) { p->des6 = (host->sg_dma + (sizeof(struct idmac_desc_64addr) *@@ -518,13 +518,13 @@ static int dw_mci_idmac_init(struct dw_mci *host) }else {struct idmac_desc *p; -/* Number of descriptors in the ring buffer */ - host->ring_size = + + host->desc_num =DESC_RING_BUF_SZ /sizeof (struct idmac_desc );/* Forward link the descriptor list */ for (i =0 , p = host->sg_cpu; - i < host->ring_size -1 ; + i < host->desc_num -1 ; i++, p++) { p->des3 =cpu_to_le32 (host->sg_dma + (sizeof (struct idmac_desc ) * (i +1 )));@@ -2857,10 +2857,10 @@ static int dw_mci_init_host(struct dw_mci *host)/* Useful defaults if platform data is unset. */ if (host->use_dma ==TRANS_MODE_IDMAC ) { - mmc->max_segs = host->ring_size; + mmc->max_segs = host->desc_num; mmc->max_blk_size =65535 ; mmc->max_seg_size =0x1000 ; - mmc->max_req_size = mmc->max_seg_size * host->ring_size; + mmc->max_req_size = mmc->max_seg_size * host->desc_num; mmc->max_blk_count = mmc->max_req_size /512 ; }else if (host->use_dma ==TRANS_MODE_EDMAC ) { mmc->max_segs =64 ;drivers/mmc/host/dw_mmc.h +2
-3@@ -79,7 +79,7 @@ struct dw_mci_dma_slave {* @dma_ops: Pointer to DMA callbacks. * @cmd_status: Snapshot of SR taken upon completion of the current * command. Only valid when EVENT_CMD_COMPLETE is pending. -* @ring_size: Buffer size for idma descriptors. +* @desc_num: Number of idmac descriptors available. * @dms: structure of slave-dma private data. * @phy_regs: physical address of controller's register map * @data_status: Snapshot of SR taken upon completion of the current @@ -186,7 +186,7 @@ struct dw_mci {void *sg_cpu;const struct dw_mci_dma_ops *dma_ops;/* For idmac */ -unsigned int ring_size; +unsigned short desc_num;/* For edmac */ struct dw_mci_dma_slave *dms; --2.25.1