Skip to content

Commit 386d325

Browse files
tlendackydavem330
authored andcommitted
amd-xgbe: Set DMA mask based on hardware register value
The hardware supplies a value that indicates the DMA range that it is capable of using. Use this value rather than hard-coding it in the driver. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ceb8f6b commit 386d325

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

drivers/net/ethernet/amd/xgbe/xgbe-common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@
365365
#define MAC_HWF0R_TXCOESEL_WIDTH 1
366366
#define MAC_HWF0R_VLHASH_INDEX 4
367367
#define MAC_HWF0R_VLHASH_WIDTH 1
368+
#define MAC_HWF1R_ADDR64_INDEX 14
369+
#define MAC_HWF1R_ADDR64_WIDTH 2
368370
#define MAC_HWF1R_ADVTHWORD_INDEX 13
369371
#define MAC_HWF1R_ADVTHWORD_WIDTH 1
370372
#define MAC_HWF1R_DBGMEMA_INDEX 19

drivers/net/ethernet/amd/xgbe/xgbe-drv.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata)
519519
RXFIFOSIZE);
520520
hw_feat->tx_fifo_size = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R,
521521
TXFIFOSIZE);
522+
hw_feat->dma_width = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, ADDR64);
522523
hw_feat->dcb = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, DCBEN);
523524
hw_feat->sph = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, SPHEN);
524525
hw_feat->tso = XGMAC_GET_BITS(mac_hfr1, MAC_HWF1R, TSOEN);
@@ -553,6 +554,21 @@ void xgbe_get_all_hw_features(struct xgbe_prv_data *pdata)
553554
break;
554555
}
555556

557+
/* Translate the address width setting into actual number */
558+
switch (hw_feat->dma_width) {
559+
case 0:
560+
hw_feat->dma_width = 32;
561+
break;
562+
case 1:
563+
hw_feat->dma_width = 40;
564+
break;
565+
case 2:
566+
hw_feat->dma_width = 48;
567+
break;
568+
default:
569+
hw_feat->dma_width = 32;
570+
}
571+
556572
/* The Queue, Channel and TC counts are zero based so increment them
557573
* to get the actual number
558574
*/

drivers/net/ethernet/amd/xgbe/xgbe-main.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,6 @@ static int xgbe_probe(struct platform_device *pdev)
374374
pdata->awcache = XGBE_DMA_SYS_AWCACHE;
375375
}
376376

377-
/* Set the DMA mask */
378-
if (!dev->dma_mask)
379-
dev->dma_mask = &dev->coherent_dma_mask;
380-
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(40));
381-
if (ret) {
382-
dev_err(dev, "dma_set_mask_and_coherent failed\n");
383-
goto err_io;
384-
}
385-
386377
/* Get the device interrupt */
387378
ret = platform_get_irq(pdev, 0);
388379
if (ret < 0) {
@@ -409,6 +400,16 @@ static int xgbe_probe(struct platform_device *pdev)
409400
/* Set default configuration data */
410401
xgbe_default_config(pdata);
411402

403+
/* Set the DMA mask */
404+
if (!dev->dma_mask)
405+
dev->dma_mask = &dev->coherent_dma_mask;
406+
ret = dma_set_mask_and_coherent(dev,
407+
DMA_BIT_MASK(pdata->hw_feat.dma_width));
408+
if (ret) {
409+
dev_err(dev, "dma_set_mask_and_coherent failed\n");
410+
goto err_io;
411+
}
412+
412413
/* Calculate the number of Tx and Rx rings to be created
413414
* -Tx (DMA) Channels map 1-to-1 to Tx Queues so set
414415
* the number of Tx queues to the number of Tx channels

drivers/net/ethernet/amd/xgbe/xgbe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ struct xgbe_hw_features {
632632
unsigned int rx_fifo_size; /* MTL Receive FIFO Size */
633633
unsigned int tx_fifo_size; /* MTL Transmit FIFO Size */
634634
unsigned int adv_ts_hi; /* Advance Timestamping High Word */
635+
unsigned int dma_width; /* DMA width */
635636
unsigned int dcb; /* DCB Feature */
636637
unsigned int sph; /* Split Header Feature */
637638
unsigned int tso; /* TCP Segmentation Offload */

0 commit comments

Comments
 (0)