rt2x00 random fixes
v3 cover rt2x00 random fixes
This is new version of:
https://lore.kernel.org/linux-wireless/[email protected]/
v3:
- move printing errors routines to cfg80211 (patch 1)
- handle ETIMEDOUT error and decrees number of error checks (patch 3)
Stanislaw Gruszka (4):
cfg80211: add ratelimited variants of err and warn
rt2x00: use ratelimited variants dev_warn/dev_err
rt2x00: check number of EPROTO errors
rt2x00: do not print error when queue is full
drivers/net/wireless/ralink/rt2x00/rt2x00.h | 5 +++-- drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 2 +- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 22 +++++++++++++++++++--- include/net/cfg80211.h | 5 +++++ 4 files changed, 28 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.5
PATCH v3 1/4 cfg80211: add ratelimited variants of err and warn
wiphy_{err,warn}_ratelimited will be used by rt2x00
--- include/net/cfg80211.h | 5 +++++ 1 file changed, 5 insertions(+)
include/net/cfg80211.h +5 -0
@@ -7183,6 +7183,11 @@ void cfg80211_pmsr_complete(struct wireless_dev *wdev, #define wiphy_info(wiphy, format, args...) \ dev_info(&(wiphy)->dev, format, ##args) +#define wiphy_err_ratelimited(wiphy, format, args...) \ + dev_err_ratelimited(&(wiphy)->dev, format, ##args) +#define wiphy_warn_ratelimited(wiphy, format, args...) \ + dev_warn_ratelimited(&(wiphy)->dev, format, ##args) + #define wiphy_debug(wiphy, format, args...) \ wiphy_printk(KERN_DEBUG, wiphy, format, ##args)
Signature · 1 line
2.7.5
PATCH v3 2/4 rt2x00: use ratelimited variants dev_warn/dev_err
In reply to Stanislaw GruszkaAs reported by Randy we can overwhelm logs on some USB error conditions. To avoid that use dev_warn_ratelimited() and dev_err_ratelimitd().
--- drivers/net/wireless/ralink/rt2x00/rt2x00.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2x00.h +2 -2
@@ -69,10 +69,10 @@ printk(KERN_ERR KBUILD_MODNAME ": %s: Error - " fmt, \ __func__, ##__VA_ARGS__)#define rt2x00_err (dev, fmt, ...) \ - wiphy_err((dev)->hw->wiphy, "%s: Error - " fmt, \ + wiphy_err_ratelimited((dev)->hw->wiphy, "%s: Error - " fmt, \ __func__, ##__VA_ARGS__)#define rt2x00_warn (dev, fmt, ...) \ - wiphy_warn((dev)->hw->wiphy, "%s: Warning - " fmt, \ + wiphy_warn_ratelimited((dev)->hw->wiphy, "%s: Warning - " fmt, \ __func__, ##__VA_ARGS__)#define rt2x00_info (dev, fmt, ...) \ wiphy_info((dev)->hw->wiphy, "%s: Info - " fmt, \
Signature · 1 line
2.7.5
PATCH v3 3/4 rt2x00: check number of EPROTO errors
In reply to Stanislaw GruszkaSome USB host devices/drivers on some conditions can always return EPROTO error on submitted URBs. That can cause infinity loop in the rt2x00 driver.
Since we can have single EPROTO errors we can not mark as device as removed to avoid infinity loop. However we can count consecutive EPROTO errors and mark device as removed if get lot of it. I choose number 10 as threshold.
--- drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 + drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2x00.h +1 -0
@@ -1017,6 +1017,7 @@ struct rt2x00_dev {unsigned int extra_tx_headroom;struct usb_anchor *anchor; +unsigned int num_proto_errs;/* Clock for System On Chip devices. */ struct clk *clk;
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +19 -3
@@ -31,6 +31,22 @@#include "rt2x00.h" #include "rt2x00usb.h" +static bool rt2x00usb_check_usb_error (struct rt2x00_dev *rt2x00dev,int status) +{ +if (status == -ENODEV || status == -ENOENT ) +return true; + +if (status == -EPROTO || status == -ETIMEDOUT ) + rt2x00dev->num_proto_errs++; +else + rt2x00dev->num_proto_errs =0 ; + +if (rt2x00dev->num_proto_errs >3 ) +return true; + +return false; +} +/* * Interfacing with the HW. */
@@ -57,7 +73,7 @@ int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,if (status >=0 )return 0 ; -if (status == -ENODEV || status == -ENOENT ) { +if (rt2x00usb_check_usb_error (rt2x00dev, status)) {/* Device has disappeared. */ clear_bit (DEVICE_STATE_PRESENT , &rt2x00dev->flags);break ;
@@ -321,7 +337,7 @@ static bool rt2x00usb_kick_tx_entry(struct queue_entry *entry, void *data) status =usb_submit_urb (entry_priv->urb,GFP_ATOMIC );if (status) { -if (status == -ENODEV || status == -ENOENT ) +if (rt2x00usb_check_usb_error (rt2x00dev, status))clear_bit (DEVICE_STATE_PRESENT , &rt2x00dev->flags);set_bit (ENTRY_DATA_IO_FAILED , &entry->flags);rt2x00lib_dmadone (entry);
@@ -410,7 +426,7 @@ static bool rt2x00usb_kick_rx_entry(struct queue_entry *entry, void *data) status =usb_submit_urb (entry_priv->urb,GFP_ATOMIC );if (status) { -if (status == -ENODEV || status == -ENOENT ) +if (rt2x00usb_check_usb_error (rt2x00dev, status))clear_bit (DEVICE_STATE_PRESENT , &rt2x00dev->flags);set_bit (ENTRY_DATA_IO_FAILED , &entry->flags);rt2x00lib_dmadone (entry);
Signature · 1 line
2.7.5
PATCH v3 4/4 rt2x00: do not print error when queue is full
In reply to Stanislaw GruszkaFor unknown reasons printk() on some context can cause CPU hung on embedded MT7620 AP/router MIPS platforms. What can result on wifi disconnects.
This patch move queue full messages to debug level what is consistent with other mac80211 drivers which drop packet silently if tx queue is full. This make MT7620 OpenWRT routers more stable, what was reported by various users.
--- drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c +1 -1
@@ -671,7 +671,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,spin_lock (&queue->tx_lock);if (unlikely (rt2x00queue_full (queue))) { -rt2x00_err (queue->rt2x00dev,"Dropping frame due to full tx queue %d\n" , +rt2x00_dbg (queue->rt2x00dev,"Dropping frame due to full tx queue %d\n" , queue->qid); ret = -ENOBUFS ; goto out;
Signature · 1 line
2.7.5
Re: [PATCH v3 4/4] rt2x00: do not print error when queue is full
Quoted 2 lines · Stanislaw Gruszka
This make MT7620 OpenWRT routers more stable, what was reported by various users.
Confirmed.
Re: [PATCH v3 2/4] rt2x00: use ratelimited variants dev_warn/dev_err
In reply to Stanislaw GruszkaQuoted 5 lines · Stanislaw Gruszka
As reported by Randy we can overwhelm logs on some USB error conditions. To avoid that use
dev_warn_ratelimited()anddev_err_ratelimitd().Reported-and-tested-by Randy Oostdyk <[email protected]>Signed-off-by Stanislaw Gruszka <[email protected]>
3 patches applied to wireless-drivers-next.git, thanks.
bb3b18c92533 rt2x00: use ratelimited variants dev_warn/dev_err e383c70474db rt2x00: check number of EPROTO errors 61a4e5ff0d72 rt2x00: do not print error when queue is full
Signature · 3 lines
https://patchwork.kernel.org/patch/10848959/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches