Skip to content

Commit c635eaa

Browse files
tlendackydavem330
authored andcommitted
amd-xgbe: Remove Tx coalescing
The Tx coalescing support in the driver was a software implementation for something lacking in the hardware. Using hrtimers, the idea was to trigger a timer interrupt after having queued a packet for transmit. Unfortunately, as the timer value was lowered, the timer expired before the hardware actually did the transmit and so it was racey and resulted in unnecessary interrupts. Remove the Tx coalescing support and hrtimer and replace with a Tx timer that is used as a reclaim timer in case of inactivity. Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 386d325 commit c635eaa

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,12 +1367,11 @@ static void xgbe_tx_start_xmit(struct xgbe_channel *channel,
13671367
XGMAC_DMA_IOWRITE(channel, DMA_CH_TDTR_LO,
13681368
lower_32_bits(rdata->rdesc_dma));
13691369

1370-
/* Start the Tx coalescing timer */
1370+
/* Start the Tx timer */
13711371
if (pdata->tx_usecs && !channel->tx_timer_active) {
13721372
channel->tx_timer_active = 1;
1373-
hrtimer_start(&channel->tx_timer,
1374-
ktime_set(0, pdata->tx_usecs * NSEC_PER_USEC),
1375-
HRTIMER_MODE_REL);
1373+
mod_timer(&channel->tx_timer,
1374+
jiffies + usecs_to_jiffies(pdata->tx_usecs));
13761375
}
13771376

13781377
ring->tx.xmit_more = 0;

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,9 @@ static irqreturn_t xgbe_dma_isr(int irq, void *data)
411411
return IRQ_HANDLED;
412412
}
413413

414-
static enum hrtimer_restart xgbe_tx_timer(struct hrtimer *timer)
414+
static void xgbe_tx_timer(unsigned long data)
415415
{
416-
struct xgbe_channel *channel = container_of(timer,
417-
struct xgbe_channel,
418-
tx_timer);
416+
struct xgbe_channel *channel = (struct xgbe_channel *)data;
419417
struct xgbe_prv_data *pdata = channel->pdata;
420418
struct napi_struct *napi;
421419

@@ -437,8 +435,6 @@ static enum hrtimer_restart xgbe_tx_timer(struct hrtimer *timer)
437435
channel->tx_timer_active = 0;
438436

439437
DBGPR("<--xgbe_tx_timer\n");
440-
441-
return HRTIMER_NORESTART;
442438
}
443439

444440
static void xgbe_init_tx_timers(struct xgbe_prv_data *pdata)
@@ -454,9 +450,8 @@ static void xgbe_init_tx_timers(struct xgbe_prv_data *pdata)
454450
break;
455451

456452
DBGPR(" %s adding tx timer\n", channel->name);
457-
hrtimer_init(&channel->tx_timer, CLOCK_MONOTONIC,
458-
HRTIMER_MODE_REL);
459-
channel->tx_timer.function = xgbe_tx_timer;
453+
setup_timer(&channel->tx_timer, xgbe_tx_timer,
454+
(unsigned long)channel);
460455
}
461456

462457
DBGPR("<--xgbe_init_tx_timers\n");
@@ -475,8 +470,7 @@ static void xgbe_stop_tx_timers(struct xgbe_prv_data *pdata)
475470
break;
476471

477472
DBGPR(" %s deleting tx timer\n", channel->name);
478-
channel->tx_timer_active = 0;
479-
hrtimer_cancel(&channel->tx_timer);
473+
del_timer_sync(&channel->tx_timer);
480474
}
481475

482476
DBGPR("<--xgbe_stop_tx_timers\n");

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ static int xgbe_get_coalesce(struct net_device *netdev,
388388
ec->rx_coalesce_usecs = hw_if->riwt_to_usec(pdata, riwt);
389389
ec->rx_max_coalesced_frames = pdata->rx_frames;
390390

391-
ec->tx_coalesce_usecs = pdata->tx_usecs;
392391
ec->tx_max_coalesced_frames = pdata->tx_frames;
393392

394393
DBGPR("<--xgbe_get_coalesce\n");
@@ -402,13 +401,14 @@ static int xgbe_set_coalesce(struct net_device *netdev,
402401
struct xgbe_prv_data *pdata = netdev_priv(netdev);
403402
struct xgbe_hw_if *hw_if = &pdata->hw_if;
404403
unsigned int rx_frames, rx_riwt, rx_usecs;
405-
unsigned int tx_frames, tx_usecs;
404+
unsigned int tx_frames;
406405

407406
DBGPR("-->xgbe_set_coalesce\n");
408407

409408
/* Check for not supported parameters */
410409
if ((ec->rx_coalesce_usecs_irq) ||
411410
(ec->rx_max_coalesced_frames_irq) ||
411+
(ec->tx_coalesce_usecs) ||
412412
(ec->tx_coalesce_usecs_irq) ||
413413
(ec->tx_max_coalesced_frames_irq) ||
414414
(ec->stats_block_coalesce_usecs) ||
@@ -457,7 +457,6 @@ static int xgbe_set_coalesce(struct net_device *netdev,
457457
return -EINVAL;
458458
}
459459

460-
tx_usecs = ec->tx_coalesce_usecs;
461460
tx_frames = ec->tx_max_coalesced_frames;
462461

463462
/* Check the bounds of values for Tx */
@@ -471,7 +470,6 @@ static int xgbe_set_coalesce(struct net_device *netdev,
471470
pdata->rx_frames = rx_frames;
472471
hw_if->config_rx_coalesce(pdata);
473472

474-
pdata->tx_usecs = tx_usecs;
475473
pdata->tx_frames = tx_frames;
476474
hw_if->config_tx_coalesce(pdata);
477475

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
((_idx) & ((_ring)->rdesc_count - 1)))
223223

224224
/* Default coalescing parameters */
225-
#define XGMAC_INIT_DMA_TX_USECS 50
225+
#define XGMAC_INIT_DMA_TX_USECS 1000
226226
#define XGMAC_INIT_DMA_TX_FRAMES 25
227227

228228
#define XGMAC_MAX_DMA_RIWT 0xff
@@ -410,7 +410,7 @@ struct xgbe_channel {
410410
unsigned int saved_ier;
411411

412412
unsigned int tx_timer_active;
413-
struct hrtimer tx_timer;
413+
struct timer_list tx_timer;
414414

415415
struct xgbe_ring *tx_ring;
416416
struct xgbe_ring *rx_ring;

0 commit comments

Comments
 (0)