linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] rt2x00 random fixes
@ 2019-03-12  9:51 Stanislaw Gruszka
  2019-03-12  9:51 ` [PATCH v3 1/4] cfg80211: add ratelimited variants of err and warn Stanislaw Gruszka
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Stanislaw Gruszka @ 2019-03-12  9:51 UTC (permalink / raw)
  To: linux-wireless
  Cc: Tomislav Požega, Daniel Golle, Felix Fietkau, Mathias Kresin

This is new version of:
https://lore.kernel.org/linux-wireless/1545318971-28351-1-git-send-email-sgruszka@redhat.com/

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(-)

-- 
2.7.5


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/4] cfg80211: add ratelimited variants of err and warn
  2019-03-12  9:51 [PATCH v3 0/4] rt2x00 random fixes Stanislaw Gruszka
@ 2019-03-12  9:51 ` Stanislaw Gruszka
  2019-03-12  9:51 ` [PATCH v3 2/4] rt2x00: use ratelimited variants dev_warn/dev_err Stanislaw Gruszka
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Stanislaw Gruszka @ 2019-03-12  9:51 UTC (permalink / raw)
  To: linux-wireless
  Cc: Tomislav Požega, Daniel Golle, Felix Fietkau, Mathias Kresin

wiphy_{err,warn}_ratelimited will be used by rt2x00

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 include/net/cfg80211.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index bb307a11ee63..13bfeb712d36 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -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)
 
-- 
2.7.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/4] rt2x00: use ratelimited variants dev_warn/dev_err
  2019-03-12  9:51 [PATCH v3 0/4] rt2x00 random fixes Stanislaw Gruszka
  2019-03-12  9:51 ` [PATCH v3 1/4] cfg80211: add ratelimited variants of err and warn Stanislaw Gruszka
@ 2019-03-12  9:51 ` Stanislaw Gruszka
  2019-04-25 16:41   ` Kalle Valo
  2019-03-12  9:51 ` [PATCH v3 3/4] rt2x00: check number of EPROTO errors Stanislaw Gruszka
  2019-03-12  9:51 ` [PATCH v3 4/4] rt2x00: do not print error when queue is full Stanislaw Gruszka
  3 siblings, 1 reply; 7+ messages in thread
From: Stanislaw Gruszka @ 2019-03-12  9:51 UTC (permalink / raw)
  To: linux-wireless
  Cc: Tomislav Požega, Daniel Golle, Felix Fietkau, Mathias Kresin

As reported by Randy we can overwhelm logs on some USB error conditions.
To avoid that use dev_warn_ratelimited() and dev_err_ratelimitd().

Reported-and-tested-by: Randy Oostdyk <linux-kernel@oostdyk.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
index 4b1744e9fb78..5657495cf626 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
@@ -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,			\
-- 
2.7.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 3/4] rt2x00: check number of EPROTO errors
  2019-03-12  9:51 [PATCH v3 0/4] rt2x00 random fixes Stanislaw Gruszka
  2019-03-12  9:51 ` [PATCH v3 1/4] cfg80211: add ratelimited variants of err and warn Stanislaw Gruszka
  2019-03-12  9:51 ` [PATCH v3 2/4] rt2x00: use ratelimited variants dev_warn/dev_err Stanislaw Gruszka
@ 2019-03-12  9:51 ` Stanislaw Gruszka
  2019-03-12  9:51 ` [PATCH v3 4/4] rt2x00: do not print error when queue is full Stanislaw Gruszka
  3 siblings, 0 replies; 7+ messages in thread
From: Stanislaw Gruszka @ 2019-03-12  9:51 UTC (permalink / raw)
  To: linux-wireless
  Cc: Tomislav Požega, Daniel Golle, Felix Fietkau, Mathias Kresin

Some 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.

Reported-and-tested-by: Randy Oostdyk <linux-kernel@oostdyk.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00.h    |  1 +
 drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 22 +++++++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00.h b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
index 5657495cf626..c1519c98ad41 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
@@ -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;
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
index 086aad22743d..9cdd7f2c92b5 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
@@ -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);
-- 
2.7.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 4/4] rt2x00: do not print error when queue is full
  2019-03-12  9:51 [PATCH v3 0/4] rt2x00 random fixes Stanislaw Gruszka
                   ` (2 preceding siblings ...)
  2019-03-12  9:51 ` [PATCH v3 3/4] rt2x00: check number of EPROTO errors Stanislaw Gruszka
@ 2019-03-12  9:51 ` Stanislaw Gruszka
  2019-03-19  2:12   ` Tom Psyborg
  3 siblings, 1 reply; 7+ messages in thread
From: Stanislaw Gruszka @ 2019-03-12  9:51 UTC (permalink / raw)
  To: linux-wireless
  Cc: Tomislav Požega, Daniel Golle, Felix Fietkau, Mathias Kresin

For 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.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
index 92ddc19e7bf7..947fc8964e9a 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
@@ -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;
-- 
2.7.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 4/4] rt2x00: do not print error when queue is full
  2019-03-12  9:51 ` [PATCH v3 4/4] rt2x00: do not print error when queue is full Stanislaw Gruszka
@ 2019-03-19  2:12   ` Tom Psyborg
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Psyborg @ 2019-03-19  2:12 UTC (permalink / raw)
  To: Stanislaw Gruszka
  Cc: linux-wireless, Daniel Golle, Felix Fietkau, Mathias Kresin

On 12/03/2019, Stanislaw Gruszka <sgruszka@redhat.com> wrote:
> This make MT7620 OpenWRT routers more stable, what was reported
> by various users.

Confirmed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/4] rt2x00: use ratelimited variants dev_warn/dev_err
  2019-03-12  9:51 ` [PATCH v3 2/4] rt2x00: use ratelimited variants dev_warn/dev_err Stanislaw Gruszka
@ 2019-04-25 16:41   ` Kalle Valo
  0 siblings, 0 replies; 7+ messages in thread
From: Kalle Valo @ 2019-04-25 16:41 UTC (permalink / raw)
  To: Stanislaw Gruszka
  Cc: linux-wireless, Tomislav Požega, Daniel Golle,
	Felix Fietkau, Mathias Kresin

Stanislaw Gruszka <sgruszka@redhat.com> wrote:

> As reported by Randy we can overwhelm logs on some USB error conditions.
> To avoid that use dev_warn_ratelimited() and dev_err_ratelimitd().
> 
> Reported-and-tested-by: Randy Oostdyk <linux-kernel@oostdyk.com>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>

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

-- 
https://patchwork.kernel.org/patch/10848959/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-25 16:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12  9:51 [PATCH v3 0/4] rt2x00 random fixes Stanislaw Gruszka
2019-03-12  9:51 ` [PATCH v3 1/4] cfg80211: add ratelimited variants of err and warn Stanislaw Gruszka
2019-03-12  9:51 ` [PATCH v3 2/4] rt2x00: use ratelimited variants dev_warn/dev_err Stanislaw Gruszka
2019-04-25 16:41   ` Kalle Valo
2019-03-12  9:51 ` [PATCH v3 3/4] rt2x00: check number of EPROTO errors Stanislaw Gruszka
2019-03-12  9:51 ` [PATCH v3 4/4] rt2x00: do not print error when queue is full Stanislaw Gruszka
2019-03-19  2:12   ` Tom Psyborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).