Skip to content

Commit 53515a0

Browse files
committed
Merge branch 'net-renesas-rswitch-fixes'
Yoshihiro Shimoda says: ==================== net: renesas: rswitch: Fix rx and timestamp I got reports locally about issues on the rswitch driver. So, fix the issues. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 90de546 + 2c59e99 commit 53515a0

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

drivers/net/ethernet/renesas/rswitch.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,13 +702,14 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
702702
u16 pkt_len;
703703
u32 get_ts;
704704

705+
if (*quota <= 0)
706+
return true;
707+
705708
boguscnt = min_t(int, gq->ring_size, *quota);
706709
limit = boguscnt;
707710

708711
desc = &gq->rx_ring[gq->cur];
709712
while ((desc->desc.die_dt & DT_MASK) != DT_FEMPTY) {
710-
if (--boguscnt < 0)
711-
break;
712713
dma_rmb();
713714
pkt_len = le16_to_cpu(desc->desc.info_ds) & RX_DS;
714715
skb = gq->skbs[gq->cur];
@@ -734,6 +735,9 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
734735

735736
gq->cur = rswitch_next_queue_index(gq, true, 1);
736737
desc = &gq->rx_ring[gq->cur];
738+
739+
if (--boguscnt <= 0)
740+
break;
737741
}
738742

739743
num = rswitch_get_num_cur_queues(gq);
@@ -745,7 +749,7 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
745749
goto err;
746750
gq->dirty = rswitch_next_queue_index(gq, false, num);
747751

748-
*quota -= limit - (++boguscnt);
752+
*quota -= limit - boguscnt;
749753

750754
return boguscnt <= 0;
751755

@@ -1437,7 +1441,10 @@ static int rswitch_open(struct net_device *ndev)
14371441
rswitch_enadis_data_irq(rdev->priv, rdev->tx_queue->index, true);
14381442
rswitch_enadis_data_irq(rdev->priv, rdev->rx_queue->index, true);
14391443

1440-
iowrite32(GWCA_TS_IRQ_BIT, rdev->priv->addr + GWTSDIE);
1444+
if (bitmap_empty(rdev->priv->opened_ports, RSWITCH_NUM_PORTS))
1445+
iowrite32(GWCA_TS_IRQ_BIT, rdev->priv->addr + GWTSDIE);
1446+
1447+
bitmap_set(rdev->priv->opened_ports, rdev->port, 1);
14411448

14421449
return 0;
14431450
};
@@ -1448,8 +1455,10 @@ static int rswitch_stop(struct net_device *ndev)
14481455
struct rswitch_gwca_ts_info *ts_info, *ts_info2;
14491456

14501457
netif_tx_stop_all_queues(ndev);
1458+
bitmap_clear(rdev->priv->opened_ports, rdev->port, 1);
14511459

1452-
iowrite32(GWCA_TS_IRQ_BIT, rdev->priv->addr + GWTSDID);
1460+
if (bitmap_empty(rdev->priv->opened_ports, RSWITCH_NUM_PORTS))
1461+
iowrite32(GWCA_TS_IRQ_BIT, rdev->priv->addr + GWTSDID);
14531462

14541463
list_for_each_entry_safe(ts_info, ts_info2, &rdev->priv->gwca.ts_info_list, list) {
14551464
if (ts_info->port != rdev->port)

drivers/net/ethernet/renesas/rswitch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,7 @@ struct rswitch_private {
998998
struct rcar_gen4_ptp_private *ptp_priv;
999999

10001000
struct rswitch_device *rdev[RSWITCH_NUM_PORTS];
1001+
DECLARE_BITMAP(opened_ports, RSWITCH_NUM_PORTS);
10011002

10021003
struct rswitch_gwca gwca;
10031004
struct rswitch_etha etha[RSWITCH_NUM_PORTS];

0 commit comments

Comments
 (0)