Skip to contentSkip to conversation

sh_eth: fix TX buffer byte-swapping

PATCH Applied Sergei Shtylyov 3 participants 3 messages Dec 13, 2015 – Dec 15, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh_eth: fix TX buffer byte-swapping

For the little-endian SH771x kernels the driver has to byte-swap the RX/TX buffers, however yet unset physcial address from the TX descriptor is used to call sh_eth_soft_swap(). Use 'skb->data' instead...

Fixes 31fcb99d9958 ("net: sh_eth: remove __flush_purge_region")

---
The patch is against Dave Miller's 'net.git' repo.
Although there have been no complaints during 4+ years of this being broken, I think it's probably worth queuing the patch for the stable trees...

 drivers/net/ethernet/renesas/sh_eth.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: net/drivers/net/ethernet/renesas/sh_eth.c =================================--- net.orig/drivers/net/ethernet/renesas/sh_eth.c +++ net/drivers/net/ethernet/renesas/sh_eth.c
@@ -2372,8 +2372,7 @@ static int sh_eth_start_xmit(struct sk_b
txdesc = &mdp->tx_ring[entry];
/* soft swap. */
if (!mdp->cd->hw_swap)
- sh_eth_soft_swap(phys_to_virt(ALIGN(txdesc->addr, 4)),
- skb->len + 2);
+ sh_eth_soft_swap(PTR_ALIGN(skb->data, 4), skb->len + 2);
txdesc->addr = dma_map_single(&ndev->dev, skb->data, skb->len,
DMA_TO_DEVICE);
if (dma_mapping_error(&ndev->dev, txdesc->addr)) {

#1 lore raw
Quoted 3 lines · Sergei Shtylyov

For the little-endian SH771x kernels the driver has to byte-swap the RX/TX buffers, however yet unset physcial address from the TX descriptor is used to call sh_eth_soft_swap(). Use 'skb->data' instead...

Rummage rummage rummage...

Ah, my sh4 qemu system has an rtl-8139cp network driver, and the sh2 j-core numato board one is A) big endian, B) has an oddball version with its own driver.

That's why I haven't hit this.

Rob

maintainer Applied
#2 lore raw
In reply to Sergei Shtylyov

From: Sergei Shtylyov <[email protected]>
Date: Sun, 13 Dec 2015 21:27:04 +0300

Quoted 6 lines

For the little-endian SH771x kernels the driver has to byte-swap the RX/TX buffers, however yet unset physcial address from the TX descriptor is used to call sh_eth_soft_swap(). Use 'skb->data' instead...

Fixes 31fcb99d9958 ("net: sh_eth: remove __flush_purge_region")

Applied.