Skip to content

Commit cbf9ca6

Browse files
Matt Carlsondavem330
authored andcommitted
tg3: Allow DMAs to cross cacheline boundaries
By default, the 5717 (and future chips) break up PCIe DMA packets across cacheline boundaries. This isn't necessary on x86. This patch selectively loosens the restriction. Signed-off-by: Matt Carlson <[email protected]> Reviewed-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 615774f commit cbf9ca6

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

drivers/net/tg3.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7294,9 +7294,12 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
72947294
if (err)
72957295
return err;
72967296

7297-
if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5784 &&
7298-
GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5761 &&
7299-
GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5717) {
7297+
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717) {
7298+
val = tr32(TG3PCI_DMA_RW_CTRL) &
7299+
~DMA_RWCTRL_DIS_CACHE_ALIGNMENT;
7300+
tw32(TG3PCI_DMA_RW_CTRL, val | tp->dma_rwctrl);
7301+
} else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5784 &&
7302+
GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5761) {
73007303
/* This value is determined during the probe time DMA
73017304
* engine test, tg3_test_dma.
73027305
*/
@@ -13329,6 +13332,11 @@ static u32 __devinit tg3_calc_dma_bndry(struct tg3 *tp, u32 val)
1332913332
#endif
1333013333
#endif
1333113334

13335+
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717) {
13336+
val = goal ? 0 : DMA_RWCTRL_DIS_CACHE_ALIGNMENT;
13337+
goto out;
13338+
}
13339+
1333213340
if (!goal)
1333313341
goto out;
1333413342

@@ -13523,7 +13531,7 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
1352313531
{
1352413532
dma_addr_t buf_dma;
1352513533
u32 *buf, saved_dma_rwctrl;
13526-
int ret;
13534+
int ret = 0;
1352713535

1352813536
buf = pci_alloc_consistent(tp->pdev, TEST_BUFFER_SIZE, &buf_dma);
1352913537
if (!buf) {
@@ -13536,6 +13544,9 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
1353613544

1353713545
tp->dma_rwctrl = tg3_calc_dma_bndry(tp, tp->dma_rwctrl);
1353813546

13547+
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717)
13548+
goto out;
13549+
1353913550
if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
1354013551
/* DMA read watermark not used on PCIE */
1354113552
tp->dma_rwctrl |= 0x00180000;
@@ -13608,7 +13619,6 @@ static int __devinit tg3_test_dma(struct tg3 *tp)
1360813619
tg3_switch_clocks(tp);
1360913620
#endif
1361013621

13611-
ret = 0;
1361213622
if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
1361313623
GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701)
1361413624
goto out;

drivers/net/tg3.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@
142142
#define METAL_REV_B1 0x01
143143
#define METAL_REV_B2 0x02
144144
#define TG3PCI_DMA_RW_CTRL 0x0000006c
145-
#define DMA_RWCTRL_MIN_DMA 0x000000ff
146-
#define DMA_RWCTRL_MIN_DMA_SHIFT 0
145+
#define DMA_RWCTRL_DIS_CACHE_ALIGNMENT 0x00000001
147146
#define DMA_RWCTRL_READ_BNDRY_MASK 0x00000700
148147
#define DMA_RWCTRL_READ_BNDRY_DISAB 0x00000000
149148
#define DMA_RWCTRL_READ_BNDRY_16 0x00000100

0 commit comments

Comments
 (0)