@@ -938,7 +938,7 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
938
938
{
939
939
const struct mtk_soc_data * soc = eth -> soc ;
940
940
dma_addr_t phy_ring_tail ;
941
- int cnt = MTK_DMA_SIZE ;
941
+ int cnt = MTK_QDMA_RING_SIZE ;
942
942
dma_addr_t dma_addr ;
943
943
int i ;
944
944
@@ -2208,19 +2208,25 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
2208
2208
struct mtk_tx_ring * ring = & eth -> tx_ring ;
2209
2209
int i , sz = soc -> txrx .txd_size ;
2210
2210
struct mtk_tx_dma_v2 * txd ;
2211
+ int ring_size ;
2211
2212
2212
- ring -> buf = kcalloc (MTK_DMA_SIZE , sizeof (* ring -> buf ),
2213
+ if (MTK_HAS_CAPS (soc -> caps , MTK_QDMA ))
2214
+ ring_size = MTK_QDMA_RING_SIZE ;
2215
+ else
2216
+ ring_size = MTK_DMA_SIZE ;
2217
+
2218
+ ring -> buf = kcalloc (ring_size , sizeof (* ring -> buf ),
2213
2219
GFP_KERNEL );
2214
2220
if (!ring -> buf )
2215
2221
goto no_tx_mem ;
2216
2222
2217
- ring -> dma = dma_alloc_coherent (eth -> dma_dev , MTK_DMA_SIZE * sz ,
2223
+ ring -> dma = dma_alloc_coherent (eth -> dma_dev , ring_size * sz ,
2218
2224
& ring -> phys , GFP_KERNEL );
2219
2225
if (!ring -> dma )
2220
2226
goto no_tx_mem ;
2221
2227
2222
- for (i = 0 ; i < MTK_DMA_SIZE ; i ++ ) {
2223
- int next = (i + 1 ) % MTK_DMA_SIZE ;
2228
+ for (i = 0 ; i < ring_size ; i ++ ) {
2229
+ int next = (i + 1 ) % ring_size ;
2224
2230
u32 next_ptr = ring -> phys + next * sz ;
2225
2231
2226
2232
txd = ring -> dma + i * sz ;
@@ -2240,22 +2246,22 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
2240
2246
* descriptors in ring->dma_pdma.
2241
2247
*/
2242
2248
if (!MTK_HAS_CAPS (soc -> caps , MTK_QDMA )) {
2243
- ring -> dma_pdma = dma_alloc_coherent (eth -> dma_dev , MTK_DMA_SIZE * sz ,
2249
+ ring -> dma_pdma = dma_alloc_coherent (eth -> dma_dev , ring_size * sz ,
2244
2250
& ring -> phys_pdma , GFP_KERNEL );
2245
2251
if (!ring -> dma_pdma )
2246
2252
goto no_tx_mem ;
2247
2253
2248
- for (i = 0 ; i < MTK_DMA_SIZE ; i ++ ) {
2254
+ for (i = 0 ; i < ring_size ; i ++ ) {
2249
2255
ring -> dma_pdma [i ].txd2 = TX_DMA_DESP2_DEF ;
2250
2256
ring -> dma_pdma [i ].txd4 = 0 ;
2251
2257
}
2252
2258
}
2253
2259
2254
- ring -> dma_size = MTK_DMA_SIZE ;
2255
- atomic_set (& ring -> free_count , MTK_DMA_SIZE - 2 );
2260
+ ring -> dma_size = ring_size ;
2261
+ atomic_set (& ring -> free_count , ring_size - 2 );
2256
2262
ring -> next_free = ring -> dma ;
2257
2263
ring -> last_free = (void * )txd ;
2258
- ring -> last_free_ptr = (u32 )(ring -> phys + ((MTK_DMA_SIZE - 1 ) * sz ));
2264
+ ring -> last_free_ptr = (u32 )(ring -> phys + ((ring_size - 1 ) * sz ));
2259
2265
ring -> thresh = MAX_SKB_FRAGS ;
2260
2266
2261
2267
/* make sure that all changes to the dma ring are flushed before we
@@ -2267,14 +2273,14 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
2267
2273
mtk_w32 (eth , ring -> phys , soc -> reg_map -> qdma .ctx_ptr );
2268
2274
mtk_w32 (eth , ring -> phys , soc -> reg_map -> qdma .dtx_ptr );
2269
2275
mtk_w32 (eth ,
2270
- ring -> phys + ((MTK_DMA_SIZE - 1 ) * sz ),
2276
+ ring -> phys + ((ring_size - 1 ) * sz ),
2271
2277
soc -> reg_map -> qdma .crx_ptr );
2272
2278
mtk_w32 (eth , ring -> last_free_ptr , soc -> reg_map -> qdma .drx_ptr );
2273
2279
mtk_w32 (eth , (QDMA_RES_THRES << 8 ) | QDMA_RES_THRES ,
2274
2280
soc -> reg_map -> qdma .qtx_cfg );
2275
2281
} else {
2276
2282
mtk_w32 (eth , ring -> phys_pdma , MT7628_TX_BASE_PTR0 );
2277
- mtk_w32 (eth , MTK_DMA_SIZE , MT7628_TX_MAX_CNT0 );
2283
+ mtk_w32 (eth , ring_size , MT7628_TX_MAX_CNT0 );
2278
2284
mtk_w32 (eth , 0 , MT7628_TX_CTX_IDX0 );
2279
2285
mtk_w32 (eth , MT7628_PST_DTX_IDX0 , soc -> reg_map -> pdma .rst_idx );
2280
2286
}
@@ -2292,22 +2298,22 @@ static void mtk_tx_clean(struct mtk_eth *eth)
2292
2298
int i ;
2293
2299
2294
2300
if (ring -> buf ) {
2295
- for (i = 0 ; i < MTK_DMA_SIZE ; i ++ )
2301
+ for (i = 0 ; i < ring -> dma_size ; i ++ )
2296
2302
mtk_tx_unmap (eth , & ring -> buf [i ], NULL , false);
2297
2303
kfree (ring -> buf );
2298
2304
ring -> buf = NULL ;
2299
2305
}
2300
2306
2301
2307
if (ring -> dma ) {
2302
2308
dma_free_coherent (eth -> dma_dev ,
2303
- MTK_DMA_SIZE * soc -> txrx .txd_size ,
2309
+ ring -> dma_size * soc -> txrx .txd_size ,
2304
2310
ring -> dma , ring -> phys );
2305
2311
ring -> dma = NULL ;
2306
2312
}
2307
2313
2308
2314
if (ring -> dma_pdma ) {
2309
2315
dma_free_coherent (eth -> dma_dev ,
2310
- MTK_DMA_SIZE * soc -> txrx .txd_size ,
2316
+ ring -> dma_size * soc -> txrx .txd_size ,
2311
2317
ring -> dma_pdma , ring -> phys_pdma );
2312
2318
ring -> dma_pdma = NULL ;
2313
2319
}
@@ -2842,7 +2848,7 @@ static void mtk_dma_free(struct mtk_eth *eth)
2842
2848
netdev_reset_queue (eth -> netdev [i ]);
2843
2849
if (eth -> scratch_ring ) {
2844
2850
dma_free_coherent (eth -> dma_dev ,
2845
- MTK_DMA_SIZE * soc -> txrx .txd_size ,
2851
+ MTK_QDMA_RING_SIZE * soc -> txrx .txd_size ,
2846
2852
eth -> scratch_ring , eth -> phy_scratch_ring );
2847
2853
eth -> scratch_ring = NULL ;
2848
2854
eth -> phy_scratch_ring = 0 ;
0 commit comments