1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-03-09 15:40:20 +00:00

Full coherent pool patch and fix tx buffer

This commit is contained in:
Ycarus 2019-05-16 23:00:57 +02:00
parent 6d624d9f12
commit db7f4677c1
2 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,66 @@
From dfb8fa6937612f8239a109685ede188a7d98295c Mon Sep 17 00:00:00 2001
From: P33M <p33m@github.com>
Date: Wed, 1 May 2019 17:04:32 +0100
Subject: [PATCH] smsc95xx: dynamically fix up TX buffer alignment with padding
bytes
dwc_otg requires a 32-bit aligned buffer start address, otherwise
expensive bounce buffers are used. The LAN951x hardware can skip up to
3 bytes between the TX header and the start of frame data, which can
be used to force alignment of the URB passed to dwc_otg.
As found in https://github.com/raspberrypi/linux/issues/2924
---
drivers/net/usb/smsc95xx.c | 12 +++++++-----
drivers/net/usb/smsc95xx.h | 2 +-
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index a5bbec75f22dc..c087b6d75753e 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -2082,7 +2082,9 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev,
struct sk_buff *skb, gfp_t flags)
{
bool csum = skb->ip_summed == CHECKSUM_PARTIAL;
- int overhead = csum ? SMSC95XX_TX_OVERHEAD_CSUM : SMSC95XX_TX_OVERHEAD;
+ unsigned int align_bytes = -((uintptr_t)skb->data) & 0x3;
+ int overhead = csum ? SMSC95XX_TX_OVERHEAD_CSUM + align_bytes
+ : SMSC95XX_TX_OVERHEAD + align_bytes;
u32 tx_cmd_a, tx_cmd_b;
/* We do not advertise SG, so skbs should be already linearized */
@@ -2116,16 +2118,16 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev,
}
}
- skb_push(skb, 4);
- tx_cmd_b = (u32)(skb->len - 4);
+ skb_push(skb, 4 + align_bytes);
+ tx_cmd_b = (u32)(skb->len - 4 - align_bytes);
if (csum)
tx_cmd_b |= TX_CMD_B_CSUM_ENABLE;
cpu_to_le32s(&tx_cmd_b);
memcpy(skb->data, &tx_cmd_b, 4);
skb_push(skb, 4);
- tx_cmd_a = (u32)(skb->len - 8) | TX_CMD_A_FIRST_SEG_ |
- TX_CMD_A_LAST_SEG_;
+ tx_cmd_a = (u32)(skb->len - 8 - align_bytes) | TX_CMD_A_FIRST_SEG_ |
+ (align_bytes << 16) | TX_CMD_A_LAST_SEG_;
cpu_to_le32s(&tx_cmd_a);
memcpy(skb->data, &tx_cmd_a, 4);
diff --git a/drivers/net/usb/smsc95xx.h b/drivers/net/usb/smsc95xx.h
index cfc704f3a4608..55f9f03e1a0c9 100644
--- a/drivers/net/usb/smsc95xx.h
+++ b/drivers/net/usb/smsc95xx.h
@@ -21,7 +21,7 @@
#define _SMSC95XX_H
/* Tx command words */
-#define TX_CMD_A_DATA_OFFSET_ (0x001F0000) /* Data Start Offset */
+#define TX_CMD_A_DATA_OFFSET_ (0x00030000) /* Data Start Offset */
#define TX_CMD_A_FIRST_SEG_ (0x00002000) /* First Segment */
#define TX_CMD_A_LAST_SEG_ (0x00001000) /* Last Segment */
#define TX_CMD_A_BUF_SIZE_ (0x000007FF) /* Buffer Size */

View file

@ -1,3 +1,32 @@
From 23a6584975f29ca1a23e60f4ea09c382693d3693 Mon Sep 17 00:00:00 2001
From: P33M <p33m@github.com>
Date: Wed, 1 May 2019 15:00:05 +0100
Subject: [PATCH] dts: Increase default coherent pool size
dwc_otg allocates DMA-coherent buffers in atomic context for misaligned
transfer buffers. The pool that these allocations come from is set up
at boot-time but can be overridden by a commandline parameter -
increase this for now to prevent failures seen on 4.19 with multiple
USB Ethernet devices.
see: https://github.com/raspberrypi/linux/issues/2924
---
arch/arm/boot/dts/bcm270x.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/bcm270x.dtsi b/arch/arm/boot/dts/bcm270x.dtsi
index 55a03c0d5e1c5..ecdb36e69c873 100644
--- a/arch/arm/boot/dts/bcm270x.dtsi
+++ b/arch/arm/boot/dts/bcm270x.dtsi
@@ -3,7 +3,7 @@
/ {
chosen {
- bootargs = "";
+ bootargs = "coherent_pool=1M";
/delete-property/ stdout-path;
};
From 591bd5452ad361deedc19d21d3f98bf1eab623ca Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.org>
Date: Thu, 2 May 2019 22:14:34 +0100