@@ -2252,8 +2252,6 @@ static void am65_cpsw_nuss_remove_tx_chns(struct am65_cpsw_common *common)
2252
2252
struct device * dev = common -> dev ;
2253
2253
int i ;
2254
2254
2255
- devm_remove_action (dev , am65_cpsw_nuss_free_tx_chns , common );
2256
-
2257
2255
common -> tx_ch_rate_msk = 0 ;
2258
2256
for (i = 0 ; i < common -> tx_ch_num ; i ++ ) {
2259
2257
struct am65_cpsw_tx_chn * tx_chn = & common -> tx_chns [i ];
@@ -2275,8 +2273,6 @@ static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common)
2275
2273
for (i = 0 ; i < common -> tx_ch_num ; i ++ ) {
2276
2274
struct am65_cpsw_tx_chn * tx_chn = & common -> tx_chns [i ];
2277
2275
2278
- netif_napi_add_tx (common -> dma_ndev , & tx_chn -> napi_tx ,
2279
- am65_cpsw_nuss_tx_poll );
2280
2276
hrtimer_init (& tx_chn -> tx_hrtimer , CLOCK_MONOTONIC , HRTIMER_MODE_REL_PINNED );
2281
2277
tx_chn -> tx_hrtimer .function = & am65_cpsw_nuss_tx_timer_callback ;
2282
2278
@@ -2289,9 +2285,21 @@ static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common)
2289
2285
tx_chn -> id , tx_chn -> irq , ret );
2290
2286
goto err ;
2291
2287
}
2288
+
2289
+ netif_napi_add_tx (common -> dma_ndev , & tx_chn -> napi_tx ,
2290
+ am65_cpsw_nuss_tx_poll );
2292
2291
}
2293
2292
2293
+ return 0 ;
2294
+
2294
2295
err :
2296
+ for (-- i ; i >= 0 ; i -- ) {
2297
+ struct am65_cpsw_tx_chn * tx_chn = & common -> tx_chns [i ];
2298
+
2299
+ netif_napi_del (& tx_chn -> napi_tx );
2300
+ devm_free_irq (dev , tx_chn -> irq , tx_chn );
2301
+ }
2302
+
2295
2303
return ret ;
2296
2304
}
2297
2305
@@ -2372,12 +2380,10 @@ static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common)
2372
2380
goto err ;
2373
2381
}
2374
2382
2383
+ return 0 ;
2384
+
2375
2385
err :
2376
- i = devm_add_action (dev , am65_cpsw_nuss_free_tx_chns , common );
2377
- if (i ) {
2378
- dev_err (dev , "Failed to add free_tx_chns action %d\n" , i );
2379
- return i ;
2380
- }
2386
+ am65_cpsw_nuss_free_tx_chns (common );
2381
2387
2382
2388
return ret ;
2383
2389
}
@@ -2405,7 +2411,6 @@ static void am65_cpsw_nuss_remove_rx_chns(struct am65_cpsw_common *common)
2405
2411
2406
2412
rx_chn = & common -> rx_chns ;
2407
2413
flows = rx_chn -> flows ;
2408
- devm_remove_action (dev , am65_cpsw_nuss_free_rx_chns , common );
2409
2414
2410
2415
for (i = 0 ; i < common -> rx_ch_num_flows ; i ++ ) {
2411
2416
if (!(flows [i ].irq < 0 ))
@@ -2504,7 +2509,7 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common)
2504
2509
i , & rx_flow_cfg );
2505
2510
if (ret ) {
2506
2511
dev_err (dev , "Failed to init rx flow%d %d\n" , i , ret );
2507
- goto err ;
2512
+ goto err_flow ;
2508
2513
}
2509
2514
if (!i )
2510
2515
fdqring_id =
@@ -2516,14 +2521,12 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common)
2516
2521
dev_err (dev , "Failed to get rx dma irq %d\n" ,
2517
2522
flow -> irq );
2518
2523
ret = flow -> irq ;
2519
- goto err ;
2524
+ goto err_flow ;
2520
2525
}
2521
2526
2522
2527
snprintf (flow -> name ,
2523
2528
sizeof (flow -> name ), "%s-rx%d" ,
2524
2529
dev_name (dev ), i );
2525
- netif_napi_add (common -> dma_ndev , & flow -> napi_rx ,
2526
- am65_cpsw_nuss_rx_poll );
2527
2530
hrtimer_init (& flow -> rx_hrtimer , CLOCK_MONOTONIC ,
2528
2531
HRTIMER_MODE_REL_PINNED );
2529
2532
flow -> rx_hrtimer .function = & am65_cpsw_nuss_rx_timer_callback ;
@@ -2536,20 +2539,28 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common)
2536
2539
dev_err (dev , "failure requesting rx %d irq %u, %d\n" ,
2537
2540
i , flow -> irq , ret );
2538
2541
flow -> irq = - EINVAL ;
2539
- goto err ;
2542
+ goto err_flow ;
2540
2543
}
2544
+
2545
+ netif_napi_add (common -> dma_ndev , & flow -> napi_rx ,
2546
+ am65_cpsw_nuss_rx_poll );
2541
2547
}
2542
2548
2543
2549
/* setup classifier to route priorities to flows */
2544
2550
cpsw_ale_classifier_setup_default (common -> ale , common -> rx_ch_num_flows );
2545
2551
2546
- err :
2547
- i = devm_add_action (dev , am65_cpsw_nuss_free_rx_chns , common );
2548
- if (i ) {
2549
- dev_err (dev , "Failed to add free_rx_chns action %d\n" , i );
2550
- return i ;
2552
+ return 0 ;
2553
+
2554
+ err_flow :
2555
+ for (-- i ; i >= 0 ; i -- ) {
2556
+ flow = & rx_chn -> flows [i ];
2557
+ netif_napi_del (& flow -> napi_rx );
2558
+ devm_free_irq (dev , flow -> irq , flow );
2551
2559
}
2552
2560
2561
+ err :
2562
+ am65_cpsw_nuss_free_rx_chns (common );
2563
+
2553
2564
return ret ;
2554
2565
}
2555
2566
@@ -3354,7 +3365,7 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
3354
3365
return ret ;
3355
3366
ret = am65_cpsw_nuss_init_rx_chns (common );
3356
3367
if (ret )
3357
- return ret ;
3368
+ goto err_remove_tx ;
3358
3369
3359
3370
/* The DMA Channels are not guaranteed to be in a clean state.
3360
3371
* Reset and disable them to ensure that they are back to the
@@ -3375,7 +3386,7 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
3375
3386
3376
3387
ret = am65_cpsw_nuss_register_devlink (common );
3377
3388
if (ret )
3378
- return ret ;
3389
+ goto err_remove_rx ;
3379
3390
3380
3391
for (i = 0 ; i < common -> port_num ; i ++ ) {
3381
3392
port = & common -> ports [i ];
@@ -3406,6 +3417,10 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
3406
3417
err_cleanup_ndev :
3407
3418
am65_cpsw_nuss_cleanup_ndev (common );
3408
3419
am65_cpsw_unregister_devlink (common );
3420
+ err_remove_rx :
3421
+ am65_cpsw_nuss_remove_rx_chns (common );
3422
+ err_remove_tx :
3423
+ am65_cpsw_nuss_remove_tx_chns (common );
3409
3424
3410
3425
return ret ;
3411
3426
}
@@ -3425,6 +3440,8 @@ int am65_cpsw_nuss_update_tx_rx_chns(struct am65_cpsw_common *common,
3425
3440
return ret ;
3426
3441
3427
3442
ret = am65_cpsw_nuss_init_rx_chns (common );
3443
+ if (ret )
3444
+ am65_cpsw_nuss_remove_tx_chns (common );
3428
3445
3429
3446
return ret ;
3430
3447
}
@@ -3683,6 +3700,8 @@ static void am65_cpsw_nuss_remove(struct platform_device *pdev)
3683
3700
*/
3684
3701
am65_cpsw_nuss_cleanup_ndev (common );
3685
3702
am65_cpsw_unregister_devlink (common );
3703
+ am65_cpsw_nuss_remove_rx_chns (common );
3704
+ am65_cpsw_nuss_remove_tx_chns (common );
3686
3705
am65_cpsw_nuss_phylink_cleanup (common );
3687
3706
am65_cpts_release (common -> cpts );
3688
3707
am65_cpsw_disable_serdes_phy (common );
@@ -3744,8 +3763,10 @@ static int am65_cpsw_nuss_resume(struct device *dev)
3744
3763
if (ret )
3745
3764
return ret ;
3746
3765
ret = am65_cpsw_nuss_init_rx_chns (common );
3747
- if (ret )
3766
+ if (ret ) {
3767
+ am65_cpsw_nuss_remove_tx_chns (common );
3748
3768
return ret ;
3769
+ }
3749
3770
3750
3771
/* If RX IRQ was disabled before suspend, keep it disabled */
3751
3772
for (i = 0 ; i < common -> rx_ch_num_flows ; i ++ ) {
0 commit comments