From: Hayes Wang <hidden> Date: 2014-12-19 08:56:47
Avoid r8152_submit_rx() from submitting rx during unexpected
moment. This could reduce the time of stopping rx.
For patch #1, the tp->speed should be updated early. Then,
the patch #2 could use it to check the current linking status.
Hayes Wang (2):
r8152: adjust set_carrier
r8152: check the status before submitting rx
drivers/net/usb/r8152.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
--
2.1.0
From: Hayes Wang <hidden> Date: 2014-12-19 08:57:00
Don't submit the rx if the device is unplugged, linking down,
or stopped.
Signed-off-by: Hayes Wang <redacted>
---
drivers/net/usb/r8152.c | 5 +++++
1 file changed, 5 insertions(+)
@@ -1789,6 +1789,11 @@ int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags){intret;+/* The rx would be stopped, so skip submitting */+if(test_bit(RTL8152_UNPLUG,&tp->flags)||+!test_bit(WORK_ENABLE,&tp->flags)||!(tp->speed&LINK_STATUS))+return0;+usb_fill_bulk_urb(agg->urb,tp->udev,usb_rcvbulkpipe(tp->udev,1),agg->head,agg_buf_sz,(usb_complete_t)read_bulk_callback,agg);
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Hayes Wang <hidden> Date: 2014-12-19 08:57:33
Update the tp->speed at the beginning of the function. Then,
the other fucntion could use it for checking linking status.
Signed-off-by: Hayes Wang <redacted>
---
drivers/net/usb/r8152.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
From: Hayes Wang <hidden> Date: 2014-12-22 02:53:51
David Miller [mailto:davem@davemloft.net]
Sent: Saturday, December 20, 2014 4:44 AM
[...]
quoted
Don't submit the rx if the device is unplugged, linking down,
or stopped.
...
quoted
@@ -1789,6 +1789,11 @@ int r8152_submit_rx(struct r8152
*tp, struct rx_agg *agg, gfp_t mem_flags)
quoted
{
int ret;
+ /* The rx would be stopped, so skip submitting */
+ if (test_bit(RTL8152_UNPLUG, &tp->flags) ||
+ !test_bit(WORK_ENABLE, &tp->flags) || !(tp->speed & LINK_STATUS))
+ return 0;
+
I think netif_carrier_off() should always be true in all three of those
situations, and would be a much simpler test than what you've coded
here.
When the device is unplugged or stopped, the linking status
may be true, so I add additional checks to avoid the submission.
Besides, in set_carrier() I set netif_carrier_on() after
ops.enable() to avoid any transmission before I finish
starting the tx/rx.
tp->rtl_ops.enable(tp);
set_bit(RTL8152_SET_RX_MODE, &tp->flags);
netif_carrier_on(netdev);
However, the r8152_submit_rx() would be called in ops.enable(),
and the check of netif_carrier_ok() would be always false. That
is why I use tp->speed, not netif_carrier_ok(), to check the
linking stauts.
Best Regards,
Hayes
From: David Miller <davem@davemloft.net> Date: 2014-12-22 05:22:59
From: Hayes Wang <redacted>
Date: Mon, 22 Dec 2014 02:53:42 +0000
David Miller [mailto:davem@davemloft.net]
quoted
Sent: Saturday, December 20, 2014 4:44 AM
[...]
quoted
quoted
Don't submit the rx if the device is unplugged, linking down,
or stopped.
...
quoted
@@ -1789,6 +1789,11 @@ int r8152_submit_rx(struct r8152
*tp, struct rx_agg *agg, gfp_t mem_flags)
quoted
{
int ret;
+ /* The rx would be stopped, so skip submitting */
+ if (test_bit(RTL8152_UNPLUG, &tp->flags) ||
+ !test_bit(WORK_ENABLE, &tp->flags) || !(tp->speed & LINK_STATUS))
+ return 0;
+
I think netif_carrier_off() should always be true in all three of those
situations, and would be a much simpler test than what you've coded
here.
When the device is unplugged or stopped, the linking status
may be true, so I add additional checks to avoid the submission.
Besides, in set_carrier() I set netif_carrier_on() after
ops.enable() to avoid any transmission before I finish
starting the tx/rx.
tp->rtl_ops.enable(tp);
set_bit(RTL8152_SET_RX_MODE, &tp->flags);
netif_carrier_on(netdev);
However, the r8152_submit_rx() would be called in ops.enable(),
and the check of netif_carrier_ok() would be always false. That
is why I use tp->speed, not netif_carrier_ok(), to check the
linking stauts.
I stil think your check is way too complicated for this fast path so I
would ask that you arrange things such that the simpler
netif_carrier_off() test works.
Especially because that is what the core networking stack uses
to decide whether to send packets to us as well.
From: Hayes Wang <hidden> Date: 2014-12-22 06:53:30
v2:
Replace the patch #1 with "call rtl_start_rx after netif_carrier_on".
For patch #2, replace checking tp->speed with netif_carrier_ok.
v1:
Avoid r8152_submit_rx() from submitting rx during unexpected
moment. This could reduce the time of stopping rx.
For patch #1, the tp->speed should be updated early. Then,
the patch #2 could use it to check the current linking status.
Hayes Wang (2):
r8152: call rtl_start_rx after netif_carrier_on
r8152: check the status before submitting rx
drivers/net/usb/r8152.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--
2.1.0
From: Hayes Wang <hidden> Date: 2014-12-22 06:53:31
Remove rtl_start_rx() from rtl_enable() and put it after calling
netif_carrier_on().
Signed-off-by: Hayes Wang <redacted>
---
drivers/net/usb/r8152.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
From: Hayes Wang <hidden> Date: 2014-12-22 06:53:47
Don't submit the rx if the device is unplugged, stopped, or
linking down.
Signed-off-by: Hayes Wang <redacted>
---
drivers/net/usb/r8152.c | 5 +++++
1 file changed, 5 insertions(+)
@@ -1789,6 +1789,11 @@ int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags){intret;+/* The rx would be stopped, so skip submitting */+if(test_bit(RTL8152_UNPLUG,&tp->flags)||+!test_bit(WORK_ENABLE,&tp->flags)||!netif_carrier_ok(tp->netdev))+return0;+usb_fill_bulk_urb(agg->urb,tp->udev,usb_rcvbulkpipe(tp->udev,1),agg->head,agg_buf_sz,(usb_complete_t)read_bulk_callback,agg);