Skip to contentSkip to conversation

net: qcom/emac: extend DMA mask to 46bits

PATCH Superseded Wang Dongsheng 2 participants 2 messages Nov 17, 2017

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: qcom/emac: extend DMA mask to 46bits

Since PTP doesn't support yet, so extend the DMA address to 46bits. When PTP is supported, the dma_mask should be fixed dynamically.

---
v2:
- Changes PATCH subject.
- Dynamic fix TPD_BUFFER_ADDR_H_SET size.
- Modify DMA MASK to 46bits.
- Add Comments for DMA MASK.

---
 drivers/net/ethernet/qualcomm/emac/emac-mac.c | 9 ++++++---
 drivers/net/ethernet/qualcomm/emac/emac-mac.h | 5 ++++-
 drivers/net/ethernet/qualcomm/emac/emac.c     | 8 ++++++--
 3 files changed, 16 insertions(+), 6 deletions(-)
drivers/net/ethernet/qualcomm/emac/emac-mac.c +6 -3
index 9cbb2726..db73348 100644
@@ -1362,7 +1362,8 @@ static void emac_tx_fill_tpd(struct emac_adapter *adpt,
 			goto error;
 
 		TPD_BUFFER_ADDR_L_SET(tpd, lower_32_bits(tpbuf->dma_addr));
-		TPD_BUFFER_ADDR_H_SET(tpd, upper_32_bits(tpbuf->dma_addr));
+		TPD_BUFFER_ADDR_H_SET(adpt, tpd,
+				      upper_32_bits(tpbuf->dma_addr));
 		TPD_BUF_LEN_SET(tpd, tpbuf->length);
 		emac_tx_tpd_create(adpt, tx_q, tpd);
 		count++;
@@ -1380,7 +1381,8 @@ static void emac_tx_fill_tpd(struct emac_adapter *adpt,
 			goto error;
 
 		TPD_BUFFER_ADDR_L_SET(tpd, lower_32_bits(tpbuf->dma_addr));
-		TPD_BUFFER_ADDR_H_SET(tpd, upper_32_bits(tpbuf->dma_addr));
+		TPD_BUFFER_ADDR_H_SET(adpt, tpd,
+				      upper_32_bits(tpbuf->dma_addr));
 		TPD_BUF_LEN_SET(tpd, tpbuf->length);
 		emac_tx_tpd_create(adpt, tx_q, tpd);
 		count++;
@@ -1402,7 +1404,8 @@ static void emac_tx_fill_tpd(struct emac_adapter *adpt,
 			goto error;
 
 		TPD_BUFFER_ADDR_L_SET(tpd, lower_32_bits(tpbuf->dma_addr));
-		TPD_BUFFER_ADDR_H_SET(tpd, upper_32_bits(tpbuf->dma_addr));
+		TPD_BUFFER_ADDR_H_SET(adpt, tpd,
+				      upper_32_bits(tpbuf->dma_addr));
 		TPD_BUF_LEN_SET(tpd, tpbuf->length);
 		emac_tx_tpd_create(adpt, tx_q, tpd);
 		count++;
drivers/net/ethernet/qualcomm/emac/emac-mac.h +4 -1
index 5028fb4..31c1f21 100644
@@ -115,7 +115,10 @@ struct emac_tpd {
 /* High-14bit Buffer Address, So, the 64b-bit address is
  * {DESC_CTRL_11_TX_DATA_HIADDR[17:0],(register) BUFFER_ADDR_H, BUFFER_ADDR_L}
  */
-#define TPD_BUFFER_ADDR_H_SET(tpd, val)	BITS_SET((tpd)->word[3], 18, 30, val)
+#define TPD_BUFFER_ADDR_H_SET(adpt, tpd, val)	BITS_SET((tpd)->word[3], 18, \
+						TX_TS_ENABLE & \
+				readl((adpt)->csr + EMAC_EMAC_WRAPPER_CSR1) ? \
+						30 : 31, val)
 /* Format D. Word offset from the 1st byte of this packet to start to calculate
  * the custom checksum.
  */
drivers/net/ethernet/qualcomm/emac/emac.c +6 -2
index 70c92b6..de5a4fb 100644
@@ -615,8 +615,12 @@ static int emac_probe(struct platform_device *pdev)
 	u32 reg;
 	int ret;
 
-	/* The TPD buffer address is limited to 45 bits. */
-	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(45));
+	/*
+	 * The TPD buffer address is limited to:
+	 * 1. PTP:	45bits. (Driver doesn't support yet.)
+	 * 2. NON-PTP:	46bits.
+	 */
+	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(46));
 	if (ret) {
 		dev_err(&pdev->dev, "could not set DMA mask\n");
 		return ret;
Signature · 1 line
2.7.4
#1 lore raw

drivers/net/ethernet/qualcomm/emac/emac-mac.h struct emac_tpd { · line 121

Quoted 5 lines · Wang Dongsheng
drivers/net/ethernet/qualcomm/emac/emac-mac.h +4 -1
-#define TPD_BUFFER_ADDR_H_SET(tpd, val)	BITS_SET((tpd)->word[3], 18, 30, val)
+#define TPD_BUFFER_ADDR_H_SET(adpt, tpd, val)	BITS_SET((tpd)->word[3], 18, \
+						TX_TS_ENABLE & \
+				readl((adpt)->csr + EMAC_EMAC_WRAPPER_CSR1) ? \
+						30 : 31, val)

NAK.

Sorry, but this is terrible. Every write to the TPD forces a secret read from another register? No thank you.

Just do what you had in v1, but also set the DMA mask. Add a comment saying that we can support 46 bits because we never enable timestamping.

Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.