Oliver Neukum wrote:
> On Friday 12 April 2002 02:44, you wrote:
>
>>OK, this is the final patch which should cover the case we are
>>low on memory and if usb_submit_urb() fail. Comments?
>
>
> I'd like to see the patch. Would you please include it ? ;-)
Here we go again. :-)
Petko
--- /usr/src/usb-2.5/drivers/usb/net/rtl8150.c Thu Apr 11 13:45:20 2002
+++ rtl8150.c Thu Apr 11 17:41:07 2002
@@ -65,6 +65,7 @@
#define RTL8150_HW_CRC 0
#define RX_REG_SET 1
#define RTL8150_UNPLUG 2
+#define RX_URB_FAIL 3
/* Define these values to match your device */
#define VENDOR_ID_REALTEK 0x0bda
@@ -318,6 +319,8 @@
goto goon;
}
+ tasklet_schedule(&dev->tl);
+
if (!dev->rx_skb) {
/* lost packets++ */
return;
@@ -333,8 +336,6 @@
dev->stats.rx_packets++;
dev->stats.rx_bytes += pkt_len;
- tasklet_schedule(&dev->tl);
-
skb = pull_skb(dev);
if (!skb) {
dev->rx_skb = NULL;
@@ -347,8 +348,10 @@
goon:
FILL_BULK_URB(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev);
- if ((res = usb_submit_urb(dev->rx_urb, GFP_ATOMIC)))
- warn("%s: Rx urb submission failed %d", netdev->name, res);
+ if (usb_submit_urb(dev->rx_urb, GFP_ATOMIC))
+ set_bit(RX_URB_FAIL, &dev->flags);
+ else
+ clear_bit(RX_URB_FAIL, &dev->flags);
}
static void rx_fixup(unsigned long data)
@@ -357,18 +360,24 @@
struct sk_buff *skb;
dev = (rtl8150_t *)data;
+
fill_skb_pool(dev);
- skb = pull_skb(dev);
- if (!skb) {
+ if (test_bit(RX_URB_FAIL, &dev->flags))
+ goto try_again;
+ if (dev->rx_skb)
+ return;
+ if (!(skb = pull_skb(dev))) {
tasklet_schedule(&dev->tl);
return;
}
- if (dev->rx_skb)
- return;
dev->rx_skb = skb;
FILL_BULK_URB(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev);
- usb_submit_urb(dev->rx_urb, GFP_ATOMIC);
+try_again:
+ if (usb_submit_urb(dev->rx_urb, GFP_ATOMIC))
+ set_bit(RX_URB_FAIL, &dev->flags);
+ else
+ clear_bit(RX_URB_FAIL, &dev->flags);
}
static void write_bulk_callback(struct urb *urb)