diff options
author | David S. Miller <davem@davemloft.net> | 2016-02-21 22:51:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-02-21 22:51:55 -0500 |
commit | d856626d3b051a3ad7139ba59463b692c131f844 (patch) | |
tree | ab5658f9b7126a0111d8ad37a5d5db218a1e0e18 | |
parent | dd78dac893bc66de0bc241bdf54c2211c2c55567 (diff) | |
parent | 90cfde46586d2286488d8ed636929e936c0c9ab2 (diff) |
Merge tag 'linux-can-fixes-for-4.5-20160221' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
Marc Kleine-Budde says:
====================
pull-request: can 2016-02-21
this is a pull reqeust of one patch for net/master.
The patch is by Gerhard Uttenthaler and fixes a potential tx overflow in the
ems_usb driver.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/can/usb/ems_usb.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index fc5b75675cd8..eb7192fab593 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c | |||
@@ -117,6 +117,9 @@ MODULE_LICENSE("GPL v2"); | |||
117 | */ | 117 | */ |
118 | #define EMS_USB_ARM7_CLOCK 8000000 | 118 | #define EMS_USB_ARM7_CLOCK 8000000 |
119 | 119 | ||
120 | #define CPC_TX_QUEUE_TRIGGER_LOW 25 | ||
121 | #define CPC_TX_QUEUE_TRIGGER_HIGH 35 | ||
122 | |||
120 | /* | 123 | /* |
121 | * CAN-Message representation in a CPC_MSG. Message object type is | 124 | * CAN-Message representation in a CPC_MSG. Message object type is |
122 | * CPC_MSG_TYPE_CAN_FRAME or CPC_MSG_TYPE_RTR_FRAME or | 125 | * CPC_MSG_TYPE_CAN_FRAME or CPC_MSG_TYPE_RTR_FRAME or |
@@ -278,6 +281,11 @@ static void ems_usb_read_interrupt_callback(struct urb *urb) | |||
278 | switch (urb->status) { | 281 | switch (urb->status) { |
279 | case 0: | 282 | case 0: |
280 | dev->free_slots = dev->intr_in_buffer[1]; | 283 | dev->free_slots = dev->intr_in_buffer[1]; |
284 | if(dev->free_slots > CPC_TX_QUEUE_TRIGGER_HIGH){ | ||
285 | if (netif_queue_stopped(netdev)){ | ||
286 | netif_wake_queue(netdev); | ||
287 | } | ||
288 | } | ||
281 | break; | 289 | break; |
282 | 290 | ||
283 | case -ECONNRESET: /* unlink */ | 291 | case -ECONNRESET: /* unlink */ |
@@ -526,8 +534,6 @@ static void ems_usb_write_bulk_callback(struct urb *urb) | |||
526 | /* Release context */ | 534 | /* Release context */ |
527 | context->echo_index = MAX_TX_URBS; | 535 | context->echo_index = MAX_TX_URBS; |
528 | 536 | ||
529 | if (netif_queue_stopped(netdev)) | ||
530 | netif_wake_queue(netdev); | ||
531 | } | 537 | } |
532 | 538 | ||
533 | /* | 539 | /* |
@@ -587,7 +593,7 @@ static int ems_usb_start(struct ems_usb *dev) | |||
587 | int err, i; | 593 | int err, i; |
588 | 594 | ||
589 | dev->intr_in_buffer[0] = 0; | 595 | dev->intr_in_buffer[0] = 0; |
590 | dev->free_slots = 15; /* initial size */ | 596 | dev->free_slots = 50; /* initial size */ |
591 | 597 | ||
592 | for (i = 0; i < MAX_RX_URBS; i++) { | 598 | for (i = 0; i < MAX_RX_URBS; i++) { |
593 | struct urb *urb = NULL; | 599 | struct urb *urb = NULL; |
@@ -835,7 +841,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne | |||
835 | 841 | ||
836 | /* Slow down tx path */ | 842 | /* Slow down tx path */ |
837 | if (atomic_read(&dev->active_tx_urbs) >= MAX_TX_URBS || | 843 | if (atomic_read(&dev->active_tx_urbs) >= MAX_TX_URBS || |
838 | dev->free_slots < 5) { | 844 | dev->free_slots < CPC_TX_QUEUE_TRIGGER_LOW) { |
839 | netif_stop_queue(netdev); | 845 | netif_stop_queue(netdev); |
840 | } | 846 | } |
841 | } | 847 | } |