Skip to contentSkip to conversation

eth/r8152: fix issues

PATCH New Hayes Wang 2 participants 4 messages Dec 16, 2020 USB

lore
Share & tools
lore

Hayes Wang

author
#0 lore raw

cover eth/r8152: fix issues

The two patch are used to fix known issues.

Hayes Wang (2):
eth/r8152: free previous memory if r8152_eth_probe fail eth/r8152: fix the aggregation issue

 drivers/usb/eth/r8152.c | 26 ++++++++++++++++++++++----
 drivers/usb/eth/r8152.h |  5 +++++
 2 files changed, 27 insertions(+), 4 deletions(-)
Signature · 1 line
2.26.2
author
#1 lore raw

PATCH 1/2 eth/r8152: free previous memory if r8152_eth_probe fail

The r8152_eth_probe() may allocate a memory for ss->dev_priv. It has to be freed if r8152_eth_probe() fails finally.

---
 drivers/usb/eth/r8152.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/usb/eth/r8152.c +7 -2
index 215bcbbef8..82a05a9c35 100644
@@ -1647,7 +1647,7 @@ int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum,
 	if (usb_set_interface(dev, iface_desc->bInterfaceNumber, 0) ||
 	    !ss->ep_in || !ss->ep_out || !ss->ep_int) {
 		debug("Problems with device\n");
-		return 0;
+		goto error;
 	}
 
 	dev->privptr = (void *)ss;
@@ -1659,7 +1659,7 @@ int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum,
 	r8152b_get_version(tp);
 
 	if (rtl_ops_init(tp))
-		return 0;
+		goto error;
 
 	tp->rtl_ops.init(tp);
 	tp->rtl_ops.up(tp);
@@ -1669,6 +1669,11 @@ int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum,
 			  DUPLEX_FULL);
 
 	return 1;
+
+error:
+	cfree(ss->dev_priv);
+	ss->dev_priv = 0;
+	return 0;
 }
 
 int r8152_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
Signature · 1 line
2.26.2
author
#2 lore raw

PATCH 2/2 eth/r8152: fix the aggregation issue

In reply to Hayes Wang

Remove the redundant setting for USB_RX_EARLY_SIZE. Besides, for RTL8153B, it is necessary to notify the hardware of the changes of the aggregation settings.

---
 drivers/usb/eth/r8152.c | 17 +++++++++++++++--
 drivers/usb/eth/r8152.h |  5 +++++
 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/usb/eth/r8152.c +15 -2
index 82a05a9c35..5f309192b4 100644
@@ -447,6 +447,12 @@ static void rtl8152_set_rx_mode(struct r8152 *tp)
 	ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
 }
 
+static inline void r8153b_rx_agg_chg_indicate(struct r8152 *tp)
+{
+	ocp_write_byte(tp, MCU_TYPE_USB, USB_UPT_RXDMA_OWN,
+		       OWN_UPDATE | OWN_CLEAR);
+}
+
 static int rtl_enable(struct r8152 *tp)
 {
 	u32 ocp_data;
@@ -457,6 +463,15 @@ static int rtl_enable(struct r8152 *tp)
 	ocp_data |= PLA_CR_RE | PLA_CR_TE;
 	ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, ocp_data);
 
+	switch (tp->version) {
+	case RTL_VER_08:
+	case RTL_VER_09:
+		r8153b_rx_agg_chg_indicate(tp);
+		break;
+	default:
+		break;
+	}
+
 	rxdy_gated_en(tp, false);
 
 	rtl8152_set_rx_mode(tp);
@@ -525,8 +540,6 @@ static void r8153_set_rx_early_size(struct r8152 *tp)
 		debug("** %s Invalid Device\n", __func__);
 		break;
 	}
-
-	ocp_write_word(tp, MCU_TYPE_USB, USB_RX_EARLY_SIZE, ocp_data);
 }
 
 static int rtl8153_enable(struct r8152 *tp)
drivers/usb/eth/r8152.h +5 -0
index fa57e42502..45172c055f 100644
@@ -92,6 +92,7 @@
 #define USB_PM_CTRL_STATUS	0xd432	/* RTL8153A */
 #define USB_RX_EXTRA_AGGR_TMR	0xd432	/* RTL8153B */
 #define USB_TX_DMA		0xd434
+#define USB_UPT_RXDMA_OWN	0xd437
 #define USB_TOLERANCE		0xd490
 #define USB_LPM_CTRL		0xd41a
 #define USB_BMU_RESET		0xd4b0
@@ -346,6 +347,10 @@
 #define BMU_RESET_EP_IN		0x01
 #define BMU_RESET_EP_OUT	0x02
 
+/* USB_UPT_RXDMA_OWN */
+#define OWN_UPDATE		BIT(0)
+#define OWN_CLEAR		BIT(1)
+
 /* USB_UPS_CTRL */
 #define POWER_CUT		0x0100
 
Signature · 1 line
2.26.2