Skip to contentSkip to conversation

net: taint when the device driver firmware crashes

PATCH Superseded Luis Chamberlain 8 participants 33 messages May 9, 2020 – May 15, 2020

Subsystems (17)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Luis Chamberlain

author maintainer
#0 lore raw

cover net: taint when the device driver firmware crashes

Device driver firmware can crash, and sometimes, this can leave your system in a state which makes the device or subsystem completely useless. Detecting this by inspecting /proc/sys/kernel/tainted instead of scraping some magical words from the kernel log, which is driver specific, is much easier. So instead this series provides a helper which lets drivers annotate this and shows how to use this on networking drivers.

My methodology for finding when firmware crashes is to git grep for "crash" and then doing some study of the code to see if this indeed a place where the firmware crashes. In some places this is quite obvious.

I'm starting off with networking first, if this gets merged later on I can focus on the other drivers, but I already have some work done on other subsytems.

Review, flames, etc are greatly appreciated.

This work, only on networking drivers, can be found on my git tree as well:

https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log/?h=20200509-taint-firmware-net

Luis Chamberlain (15):
taint: add module firmware crash taint support ethernet/839: use new module_firmware_crashed()
bnx2x: use new module_firmware_crashed()
bnxt: use new module_firmware_crashed()
bna: use new module_firmware_crashed()
liquidio: use new module_firmware_crashed()
cxgb4: use new module_firmware_crashed()
ehea: use new module_firmware_crashed()
qed: use new module_firmware_crashed()
soc: qcom: ipa: use new module_firmware_crashed() wimax/i2400m: use new module_firmware_crashed()
ath10k: use new module_firmware_crashed()
ath6kl: use new module_firmware_crashed()
brcm80211: use new module_firmware_crashed()
mwl8k: use new module_firmware_crashed()

 drivers/net/ethernet/8390/axnet_cs.c                |  4 +++-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c    |  1 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c   |  1 +
 drivers/net/ethernet/brocade/bna/bfa_ioc.c          |  1 +
 drivers/net/ethernet/cavium/liquidio/lio_main.c     |  1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c     |  1 +
 drivers/net/ethernet/ibm/ehea/ehea_main.c           |  2 ++
 drivers/net/ethernet/qlogic/qed/qed_debug.c         |  3 +++
 drivers/net/ipa/ipa_modem.c                         |  1 +
 drivers/net/wimax/i2400m/rx.c                       |  1 +
 drivers/net/wireless/ath/ath10k/pci.c               |  2 ++
 drivers/net/wireless/ath/ath10k/sdio.c              |  2 ++
 drivers/net/wireless/ath/ath10k/snoc.c              |  1 +
 drivers/net/wireless/ath/ath6kl/hif.c               |  1 +
 .../net/wireless/broadcom/brcm80211/brcmfmac/core.c |  1 +
 drivers/net/wireless/marvell/mwl8k.c                |  1 +
 include/linux/kernel.h                              |  3 ++-
 include/linux/module.h                              | 13 +++++++++++++
 include/trace/events/module.h                       |  3 ++-
 kernel/module.c                                     |  5 +++--
 kernel/panic.c                                      |  1 +
 21 files changed, 44 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 1/15 taint: add module firmware crash taint support

Device driver firmware can crash, and sometimes, this can leave your system in a state which makes the device or subsystem completely useless. Detecting this by inspecting /proc/sys/kernel/tainted instead of scraping some magical words from the kernel log, which is driver specific, is much easier. So instead provide a helper which lets drivers annotate this.

Once this happens, scrapers can easily look for modules taint flags for a firmware crash. This will taint both the kernel and respective calling module.

The new helper module_firmware_crashed() uses LOCKDEP_STILL_OK as this fact should in no way shape or form affect lockdep. This taint is device driver specific.

---
 include/linux/kernel.h        |  3 ++-
 include/linux/module.h        | 13 +++++++++++++
 include/trace/events/module.h |  3 ++-
 kernel/module.c               |  5 +++--
 kernel/panic.c                |  1 +
 5 files changed, 21 insertions(+), 4 deletions(-)
include/linux/kernel.h +2 -1
index 04a5885cec1b..19e1541c82c7 100644
@@ -601,7 +601,8 @@ extern enum system_states {
 #define TAINT_LIVEPATCH			15
 #define TAINT_AUX			16
 #define TAINT_RANDSTRUCT		17
-#define TAINT_FLAGS_COUNT		18
+#define TAINT_FIRMWARE_CRASH		18
+#define TAINT_FLAGS_COUNT		19
 
 struct taint_flag {
 	char c_true;	/* character printed when tainted */
include/linux/module.h +13 -0
index 2c2e988bcf10..221200078180 100644
@@ -697,6 +697,14 @@ static inline bool is_livepatch_module(struct module *mod)
 bool is_module_sig_enforced(void);
 void set_module_sig_enforced(void);
 
+void add_taint_module(struct module *mod, unsigned flag,
+		      enum lockdep_ok lockdep_ok);
+
+static inline void module_firmware_crashed(void)
+{
+	add_taint_module(THIS_MODULE, TAINT_FIRMWARE_CRASH, LOCKDEP_STILL_OK);
+}
+
 #else /* !CONFIG_MODULES... */
 
 static inline struct module *__module_address(unsigned long addr)
@@ -844,6 +852,11 @@ void *dereference_module_function_descriptor(struct module *mod, void *ptr)
 	return ptr;
 }
 
+static inline void module_firmware_crashed(void)
+{
+	add_taint(TAINT_FIRMWARE_CRASH, LOCKDEP_STILL_OK);
+}
+
 #endif /* CONFIG_MODULES */
 
 #ifdef CONFIG_SYSFS
include/trace/events/module.h +2 -1
index 097485c73c01..b749ea25affd 100644
@@ -26,7 +26,8 @@ struct module;
 	{ (1UL << TAINT_OOT_MODULE),		"O" },		\
 	{ (1UL << TAINT_FORCED_MODULE),		"F" },		\
 	{ (1UL << TAINT_CRAP),			"C" },		\
-	{ (1UL << TAINT_UNSIGNED_MODULE),	"E" })
+	{ (1UL << TAINT_UNSIGNED_MODULE),	"E" },		\
+	{ (1UL << TAINT_FIRMWARE_CRASH),	"Q" })
 
 TRACE_EVENT(module_load,
 
kernel/module.c +3 -2
index 80faaf2116dd..f98e8c25c6b4 100644
@@ -325,12 +325,13 @@ static inline int strong_try_module_get(struct module *mod)
 		return -ENOENT;
 }
 
-static inline void add_taint_module(struct module *mod, unsigned flag,
-				    enum lockdep_ok lockdep_ok)
+void add_taint_module(struct module *mod, unsigned flag,
+		      enum lockdep_ok lockdep_ok)
 {
 	add_taint(flag, lockdep_ok);
 	set_bit(flag, &mod->taints);
 }
+EXPORT_SYMBOL_GPL(add_taint_module);
 
 /*
  * A thread that wants to hold a reference to a module only while it
kernel/panic.c +1 -0
index ec6d7d788ce7..504fb926947e 100644
@@ -384,6 +384,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
 	[ TAINT_LIVEPATCH ]		= { 'K', ' ', true },
 	[ TAINT_AUX ]			= { 'X', ' ', true },
 	[ TAINT_RANDSTRUCT ]		= { 'T', ' ', true },
+	[ TAINT_FIRMWARE_CRASH ]	= { 'Q', ' ', true },
 };
 
 /**
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 01/15] taint: add module firmware crash taint support

Quoted 29 lines · Luis Chamberlain

Device driver firmware can crash, and sometimes, this can leave your system in a state which makes the device or subsystem completely useless. Detecting this by inspecting /proc/sys/kernel/tainted instead of scraping some magical words from the kernel log, which is driver specific, is much easier. So instead provide a helper which lets drivers annotate this.

Once this happens, scrapers can easily look for modules taint flags for a firmware crash. This will taint both the kernel and respective calling module.

The new helper module_firmware_crashed() uses LOCKDEP_STILL_OK as this fact should in no way shape or form affect lockdep. This taint is device driver specific.

---
 include/linux/kernel.h        |  3 ++-
 include/linux/module.h        | 13 +++++++++++++
 include/trace/events/module.h |  3 ++-
 kernel/module.c               |  5 +++--
 kernel/panic.c                |  1 +
 5 files changed, 21 insertions(+), 4 deletions(-)
include/linux/kernel.h +0 -0
index 04a5885cec1b..19e1541c82c7 100644

include/linux/kernel.h extern enum system_states { · line 606

Quoted 7 lines
include/linux/kernel.h +2 -1
@@ -601,7 +601,8 @@ extern enum system_states {
 #define TAINT_LIVEPATCH			15
 #define TAINT_AUX			16
 #define TAINT_RANDSTRUCT		17
-#define TAINT_FLAGS_COUNT		18
+#define TAINT_FIRMWARE_CRASH		18
+#define TAINT_FLAGS_COUNT		19
 

We are still missing the documentation bits for this new flag, though.

How about having a blurb similar to:

Documentation/admin-guide/tainted-kernels.rst +5 -0
index 71e9184a9079..5c6a9e2478b0 100644
@@ -100,6 +100,7 @@ Bit  Log  Number  Reason that got the kernel tainted
  15  _/K   32768  kernel has been live patched
  16  _/X   65536  auxiliary taint, defined for and used by distros
  17  _/T  131072  kernel was built with the struct randomization plugin
+ 18  _/Q  262144  driver firmware crash annotation
 ===  ===  ======  ========================================================
 
 Note: The character ``_`` is representing a blank in this table to make reading
@@ -162,3 +163,7 @@ More detailed explanation for tainting
      produce extremely unusual kernel structure layouts (even performance
      pathological ones), which is important to know when debugging. Set at
      build time.
+
+ 18) ``Q`` Device drivers might annotate the kernel with this taint, in cases
+     their firmware might have crashed leaving the driver in a crippled and
+     potentially useless state.
Quoted 82 lines
include/linux/kernel.h +0 -0
 struct taint_flag {
 	char c_true;	/* character printed when tainted */
include/linux/module.h +13 -0
index 2c2e988bcf10..221200078180 100644
@@ -697,6 +697,14 @@ static inline bool is_livepatch_module(struct module *mod)
 bool is_module_sig_enforced(void);
 void set_module_sig_enforced(void);
 
+void add_taint_module(struct module *mod, unsigned flag,
+		      enum lockdep_ok lockdep_ok);
+
+static inline void module_firmware_crashed(void)
+{
+	add_taint_module(THIS_MODULE, TAINT_FIRMWARE_CRASH, LOCKDEP_STILL_OK);
+}
+
 #else /* !CONFIG_MODULES... */
 
 static inline struct module *__module_address(unsigned long addr)
@@ -844,6 +852,11 @@ void *dereference_module_function_descriptor(struct module *mod, void *ptr)
 	return ptr;
 }
 
+static inline void module_firmware_crashed(void)
+{
+	add_taint(TAINT_FIRMWARE_CRASH, LOCKDEP_STILL_OK);
+}
+
 #endif /* CONFIG_MODULES */
 
 #ifdef CONFIG_SYSFS
include/trace/events/module.h +2 -1
index 097485c73c01..b749ea25affd 100644
@@ -26,7 +26,8 @@ struct module;
 	{ (1UL << TAINT_OOT_MODULE),		"O" },		\
 	{ (1UL << TAINT_FORCED_MODULE),		"F" },		\
 	{ (1UL << TAINT_CRAP),			"C" },		\
-	{ (1UL << TAINT_UNSIGNED_MODULE),	"E" })
+	{ (1UL << TAINT_UNSIGNED_MODULE),	"E" },		\
+	{ (1UL << TAINT_FIRMWARE_CRASH),	"Q" })
 
 TRACE_EVENT(module_load,
 
kernel/module.c +3 -2
index 80faaf2116dd..f98e8c25c6b4 100644
@@ -325,12 +325,13 @@ static inline int strong_try_module_get(struct module *mod)
 		return -ENOENT;
 }
 
-static inline void add_taint_module(struct module *mod, unsigned flag,
-				    enum lockdep_ok lockdep_ok)
+void add_taint_module(struct module *mod, unsigned flag,
+		      enum lockdep_ok lockdep_ok)
 {
 	add_taint(flag, lockdep_ok);
 	set_bit(flag, &mod->taints);
 }
+EXPORT_SYMBOL_GPL(add_taint_module);
 
 /*
  * A thread that wants to hold a reference to a module only while it
kernel/panic.c +1 -0
index ec6d7d788ce7..504fb926947e 100644
@@ -384,6 +384,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
 	[ TAINT_LIVEPATCH ]		= { 'K', ' ', true },
 	[ TAINT_AUX ]			= { 'X', ' ', true },
 	[ TAINT_RANDSTRUCT ]		= { 'T', ' ', true },
+	[ TAINT_FIRMWARE_CRASH ]	= { 'Q', ' ', true },
 };
 
 /**
Signature · 1 line
2.25.1
author maintainer
#3 lore raw

Re: [PATCH 01/15] taint: add module firmware crash taint support

Quoted 2 lines · Rafael Aquini

We are still missing the documentation bits for this new flag, though.

Ah yeah sorry about that.

Quoted 15 lines

How about having a blurb similar to:

Documentation/admin-guide/tainted-kernels.rst +1 -0
index 71e9184a9079..5c6a9e2478b0 100644
@@ -100,6 +100,7 @@ Bit  Log  Number  Reason that got the kernel tainted
  15  _/K   32768  kernel has been live patched
  16  _/X   65536  auxiliary taint, defined for and used by distros
  17  _/T  131072  kernel was built with the struct randomization plugin
+ 18  _/Q  262144  driver firmware crash annotation
 ===  ===  ======  ========================================================
 
 Note: The character ``_`` is representing a blank in this table to make reading

Documentation/admin-guide/tainted-kernels.rst More detailed explanation for tainting · line 169

Quoted 7 lines
Documentation/admin-guide/tainted-kernels.rst +4 -0
@@ -162,3 +163,7 @@ More detailed explanation for tainting
      produce extremely unusual kernel structure layouts (even performance
      pathological ones), which is important to know when debugging. Set at
      build time.
+
+ 18) ``Q`` Device drivers might annotate the kernel with this taint, in cases
+     their firmware might have crashed leaving the driver in a crippled and
+     potentially useless state.

Sure, I'll modify it a bit to add the use case to help with support issues, ie, to help rule out firmware issues.

I'm starting to think that to make this even more usesul later we may want to add a uevent to add_taint() so that userspace can decide to look into this, ignore it, or report something to the user, say on their desktop.

Luis

reviewer
#4 lore raw

Re: [PATCH 01/15] taint: add module firmware crash taint support

Quoted 19 lines · Luis Chamberlain
Quoted 2 lines · Rafael Aquini

We are still missing the documentation bits for this new flag, though.

Ah yeah sorry about that.

Quoted 13 lines

How about having a blurb similar to:

Documentation/admin-guide/tainted-kernels.rst +1 -0
index 71e9184a9079..5c6a9e2478b0 100644
@@ -100,6 +100,7 @@ Bit  Log  Number  Reason that got the kernel tainted
  15  _/K   32768  kernel has been live patched
  16  _/X   65536  auxiliary taint, defined for and used by distros
  17  _/T  131072  kernel was built with the struct randomization plugin
+ 18  _/Q  262144  driver firmware crash annotation
 ===  ===  ======  ========================================================
 
Quoted 12 lines

Documentation/admin-guide/tainted-kernels.rst More detailed explanation for tainting · line 169

Quoted 9 lines
Documentation/admin-guide/tainted-kernels.rst +4 -0
 Note: The character ``_`` is representing a blank in this table to make reading
@@ -162,3 +163,7 @@ More detailed explanation for tainting
      produce extremely unusual kernel structure layouts (even performance
      pathological ones), which is important to know when debugging. Set at
      build time.
+
+ 18) ``Q`` Device drivers might annotate the kernel with this taint, in cases
+     their firmware might have crashed leaving the driver in a crippled and
+     potentially useless state.

Sure, I'll modify it a bit to add the use case to help with support issues, ie, to help rule out firmware issues.

Please also update tools/debugging/kernel-chktaint.

Quoted 4 lines

I'm starting to think that to make this even more usesul later we may want to add a uevent to add_taint() so that userspace can decide to look into this, ignore it, or report something to the user, say on their desktop.

thanks.

Signature · 1 line
~Randy
author maintainer
#5 lore raw

PATCH 2/15 ethernet/839: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Shannon Nelson <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Heiner Kallweit <[email protected]>
---
 drivers/net/ethernet/8390/axnet_cs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/8390/axnet_cs.c +3 -1
index aeae7966a082..8ad0200db8e9 100644
@@ -1358,9 +1358,11 @@ static void ei_receive(struct net_device *dev)
 		 */
 		if ((netif_msg_rx_err(ei_local)) &&
 		    this_frame != ei_local->current_page &&
-		    (this_frame != 0x0 || rxing_page != 0xFF))
+		    (this_frame != 0x0 || rxing_page != 0xFF)) {
+			module_firmware_crashed();
 			netdev_err(dev, "mismatched read page pointers %2x vs %2x\n",
 				   this_frame, ei_local->current_page);
+		}
 		
 		if (this_frame == rxing_page)	/* Read all the frames? */
 			break;				/* Done for now */
Signature · 1 line
2.25.1
author maintainer
#6 lore raw

PATCH 3/15 bnx2x: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1 -0
index db5107e7937c..c38b8c9c8af0 100644
@@ -909,6 +909,7 @@ void bnx2x_panic_dump(struct bnx2x *bp, bool disable_int)
 	bp->eth_stats.unrecoverable_error++;
 	DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n");
 
+	module_firmware_crashed();
 	BNX2X_ERR("begin crash dump -----------------\n");
 
 	/* Indices */
Signature · 1 line
2.25.1
author maintainer
#7 lore raw

PATCH 4/15 bnxt: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -0
index dd0c3f227009..5ba1bd0734e9 100644
@@ -3503,6 +3503,7 @@ static int bnxt_get_dump_data(struct net_device *dev, struct ethtool_dump *dump,
 
 	dump->flag = bp->dump_flag;
 	if (dump->flag == BNXT_DUMP_CRASH) {
+		module_firmware_crashed();
 #ifdef CONFIG_TEE_BNXT_FW
 		return tee_bnxt_copy_coredump(buf, 0, dump->len);
 #endif
Signature · 1 line
2.25.1
author maintainer
#8 lore raw

PATCH 5/15 bna: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/ethernet/brocade/bna/bfa_ioc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/brocade/bna/bfa_ioc.c +1 -0
index e17bfc87da90..b3f44a912574 100644
@@ -927,6 +927,7 @@ bfa_iocpf_sm_disabled(struct bfa_iocpf *iocpf, enum iocpf_event event)
 static void
 bfa_iocpf_sm_initfail_sync_entry(struct bfa_iocpf *iocpf)
 {
+	module_firmware_crashed();
 	bfa_nw_ioc_debug_save_ftrc(iocpf->ioc);
 	bfa_ioc_hw_sem_get(iocpf->ioc);
 }
Signature · 1 line
2.25.1
author maintainer
#9 lore raw

PATCH 6/15 liquidio: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

Cc Derek Chickles <[email protected]>
Cc Satanand Burla <[email protected]>
Cc Felix Manlunas <[email protected]>
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/cavium/liquidio/lio_main.c +1 -0
index 66d31c018c7e..f18085262982 100644
@@ -801,6 +801,7 @@ static int liquidio_watchdog(void *param)
 			continue;
 
 		WRITE_ONCE(oct->cores_crashed, true);
+		module_firmware_crashed();
 		other_oct = get_other_octeon_device(oct);
 		if (other_oct)
 			WRITE_ONCE(other_oct->cores_crashed, true);
Signature · 1 line
2.25.1
author maintainer
#10 lore raw

PATCH 7/15 cxgb4: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1 -0
index a70018f067aa..c67fc86c0e42 100644
@@ -3646,6 +3646,7 @@ void t4_fatal_err(struct adapter *adap)
 	 * could be exposed to the adapter.  RDMA MWs for example...
 	 */
 	t4_shutdown_adapter(adap);
+	module_firmware_crashed();
 	for_each_port(adap, port) {
 		struct net_device *dev = adap->port[port];
 
Signature · 1 line
2.25.1
author maintainer
#11 lore raw

PATCH 8/15 ehea: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/ethernet/ibm/ehea/ehea_main.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/ibm/ehea/ehea_main.c +2 -0
index 0273fb7a9d01..6ae35067003f 100644
@@ -3285,6 +3285,8 @@ static void ehea_crash_handler(void)
 {
 	int i;
 
+	module_firmware_crashed();
+
 	if (ehea_fw_handles.arr)
 		for (i = 0; i < ehea_fw_handles.num_entries; i++)
 			ehea_h_free_resource(ehea_fw_handles.arr[i].adh,
Signature · 1 line
2.25.1
author maintainer
#12 lore raw

PATCH 9/15 qed: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/qlogic/qed/qed_debug.c +3 -0
index f4eebaabb6d0..9cc6287b889b 100644
@@ -7854,6 +7854,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void *buffer)
 						 REGDUMP_HEADER_SIZE,
 						 &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev, PROTECTION_OVERRIDE,
 						    cur_engine,
@@ -7869,6 +7870,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void *buffer)
 		rc = qed_dbg_fw_asserts(cdev, (u8 *)buffer + offset +
 					REGDUMP_HEADER_SIZE, &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev, FW_ASSERTS,
 						    cur_engine, feature_size,
@@ -7906,6 +7908,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void *buffer)
 		rc = qed_dbg_grc(cdev, (u8 *)buffer + offset +
 				 REGDUMP_HEADER_SIZE, &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev, GRC_DUMP,
 						    cur_engine,
Signature · 1 line
2.25.1
#13 lore raw

Re: [EXT] [PATCH 09/15] qed: use new module_firmware_crashed()

Quoted 50 lines

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
index f4eebaabb6d0..9cc6287b889b 100644
@@ -7854,6 +7854,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void
 *buffer)
 						 REGDUMP_HEADER_SIZE,
 						 &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev,

PROTECTION_OVERRIDE,

drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
 						    cur_engine,
@@ -7869,6 +7870,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void
 *buffer)
 		rc = qed_dbg_fw_asserts(cdev, (u8 *)buffer + offset +
 					REGDUMP_HEADER_SIZE,
 &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
drivers/net/ethernet/qlogic/qed/qed_debug.c +0 -0
 			    qed_calc_regdump_header(cdev, FW_ASSERTS,
 						    cur_engine,

feature_size,

drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
@@ -7906,6 +7908,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void
 *buffer)
 		rc = qed_dbg_grc(cdev, (u8 *)buffer + offset +
 				 REGDUMP_HEADER_SIZE, &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev, GRC_DUMP,
Quoted 1 line

cur_engine,

Hi Luis,

qed_dbg_all_data is being used to gather debug dump from device. Failures inside it may happen due to various reasons, but they normally do not indicate FW failure.

So I think its not a good place to insert this call.

Its hard to find exact good place to insert it in qed.

One more thing is that AFAIU taint flag gets permanent on kernel, but for example our device can recover itself from some FW crashes, thus it'd be transparent for user.

Whats the logical purpose of module_firmware_crashed? Does it mean fatal unrecoverable error on device?

Thanks,
Igor

author maintainer
#14 lore raw

Re: [EXT] [PATCH 09/15] qed: use new module_firmware_crashed()

Quoted 55 lines · Igor Russkikh
Quoted 50 lines

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/ethernet/qlogic/qed/qed_debug.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
index f4eebaabb6d0..9cc6287b889b 100644
@@ -7854,6 +7854,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void
 *buffer)
 						 REGDUMP_HEADER_SIZE,
 						 &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev,

PROTECTION_OVERRIDE,

drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
 						    cur_engine,
@@ -7869,6 +7870,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void
 *buffer)
 		rc = qed_dbg_fw_asserts(cdev, (u8 *)buffer + offset +
 					REGDUMP_HEADER_SIZE,
 &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
drivers/net/ethernet/qlogic/qed/qed_debug.c +0 -0
 			    qed_calc_regdump_header(cdev, FW_ASSERTS,
 						    cur_engine,

feature_size,

drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
@@ -7906,6 +7908,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void
 *buffer)
 		rc = qed_dbg_grc(cdev, (u8 *)buffer + offset +
 				 REGDUMP_HEADER_SIZE, &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev, GRC_DUMP,
Quoted 1 line

cur_engine,

Hi Luis,

Quoted 6 lines

qed_dbg_all_data is being used to gather debug dump from device. Failures inside it may happen due to various reasons, but they normally do not indicate FW failure.

So I think its not a good place to insert this call. Its hard to find exact good place to insert it in qed.

Is there a way to check if what happened was indeed a fw crash?

Quoted 3 lines

One more thing is that AFAIU taint flag gets permanent on kernel, but for example our device can recover itself from some FW crashes, thus it'd be transparent for user.

Similar things are *supposed* to recoverable with other device, however this can also sometimes lead to a situation where devices are not usable anymore, and require a full driver unload / load.

Quoted 2 lines

Whats the logical purpose of module_firmware_crashed? Does it mean fatal unrecoverable error on device?

Its just to annotate on the module and kernel that this has happened.

I take it you may agree that, firmware crashing *often* is not good design, and these issues should be reported to / fixed by vendors. In cases where driver bugs are reported it is good to see if a firmware crash has happened before, so that during analysis this is ruled out.

Luis

#15 lore raw

Re: [EXT] [PATCH 09/15] qed: use new module_firmware_crashed()

Quoted 5 lines
Quoted 3 lines

So I think its not a good place to insert this call. Its hard to find exact good place to insert it in qed.

Is there a way to check if what happened was indeed a fw crash?

Our driver has two firmwares (slowpath and fastpath).
For slowpath firmware the way to understand it crashed is to observe command response timeout. This is in qed_mcp.c, around "The MFW failed to respond to command" traceout.

For fastpath this is tricky, think you may leave the above place as the only place to invoke module_firmware_crashed()

Quoted 13 lines
Quoted 2 lines

One more thing is that AFAIU taint flag gets permanent on kernel, but

for

Quoted 2 lines

example our device can recover itself from some FW crashes, thus it'd be transparent for user.

Similar things are *supposed* to recoverable with other device, however this can also sometimes lead to a situation where devices are not usable anymore, and require a full driver unload / load.

Quoted 2 lines

Whats the logical purpose of module_firmware_crashed? Does it mean fatal unrecoverable error on device?

Quoted 7 lines

Its just to annotate on the module and kernel that this has happened.

I take it you may agree that, firmware crashing *often* is not good design,
and these issues should be reported to / fixed by vendors. In cases where driver bugs are reported it is good to see if a firmware crash has happened before, so that during analysis this is ruled out.

Probably, but still I see some misalignment here, in sense that taint is about the kernel state, not about a hardware state indication.

devlink health could really be a much better candidate for such things.

Regards
Igor

author maintainer
#16 lore raw

Re: [EXT] [PATCH 09/15] qed: use new module_firmware_crashed()

Quoted 10 lines · Igor Russkikh
Quoted 5 lines
Quoted 3 lines

So I think its not a good place to insert this call. Its hard to find exact good place to insert it in qed.

Is there a way to check if what happened was indeed a fw crash?

Our driver has two firmwares (slowpath and fastpath).
For slowpath firmware the way to understand it crashed is to observe command response timeout. This is in qed_mcp.c, around "The MFW failed to respond to command" traceout.

Ok thanks.

Quoted 2 lines

For fastpath this is tricky, think you may leave the above place as the only place to invoke module_firmware_crashed()

So do you mean like the changes below?

drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
index f4eebaabb6d0..95cb7da2542e 100644
@@ -7906,6 +7906,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void *buffer)
 		rc = qed_dbg_grc(cdev, (u8 *)buffer + offset +
 				 REGDUMP_HEADER_SIZE, &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev, GRC_DUMP,
 						    cur_engine,
drivers/net/ethernet/qlogic/qed/qed_mcp.c +1 -0
index 280527cc0578..a818cf09dccf 100644
@@ -566,6 +566,7 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
 		DP_NOTICE(p_hwfn,
 			  "The MFW failed to respond to command 0x%08x [param 0x%08x].\n",
 			  p_mb_params->cmd, p_mb_params->param);
+		module_firmware_crashed();
 		qed_mcp_print_cpu_info(p_hwfn, p_ptt);
 
 		spin_lock_bh(&p_hwfn->mcp_info->cmd_lock);
Quoted 14 lines
Quoted 14 lines
Quoted 1 line

One more thing is that AFAIU taint flag gets permanent on kernel, but

for

Quoted 2 lines

example our device can recover itself from some FW crashes, thus it'd be transparent for user.

Similar things are *supposed* to recoverable with other device, however this can also sometimes lead to a situation where devices are not usable anymore, and require a full driver unload / load.

Quoted 2 lines

Whats the logical purpose of module_firmware_crashed? Does it mean fatal unrecoverable error on device?

Its just to annotate on the module and kernel that this has happened.

Quoted 8 lines
Quoted 5 lines

I take it you may agree that, firmware crashing *often* is not good design,
and these issues should be reported to / fixed by vendors. In cases where driver bugs are reported it is good to see if a firmware crash has happened before, so that during analysis this is ruled out.

Probably, but still I see some misalignment here, in sense that taint is about the kernel state, not about a hardware state indication.

The kernel carries the driver though, and the driver / subsystem can often times act strange when this happens.

Quoted 1 line

devlink health could really be a much better candidate for such things.

That sounds fantastic, please Cc me on patches! However I still believe we should register this event in the kernel for support purposes.

Luis

#17 lore raw

Re: [EXT] [PATCH 09/15] qed: use new module_firmware_crashed()

Quoted 16 lines

So do you mean like the changes below?

drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
index f4eebaabb6d0..95cb7da2542e 100644
@@ -7906,6 +7906,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void
 *buffer)
 		rc = qed_dbg_grc(cdev, (u8 *)buffer + offset +
 				 REGDUMP_HEADER_SIZE, &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev, GRC_DUMP,
Quoted 1 line

cur_engine,

Please remove this invocation. Its not a place where FW crash is happening.

drivers/net/ethernet/qlogic/qed/qed_debug.c

Quoted 6 lines
drivers/net/ethernet/qlogic/qed/qed_debug.c +0 -0
 		DP_NOTICE(p_hwfn,
 			  "The MFW failed to respond to command 0x%08x

[param 0x%08x].\n",

drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
 			  p_mb_params->cmd, p_mb_params->param);
+		module_firmware_crashed();
 		qed_mcp_print_cpu_info(p_hwfn, p_ptt);

This one is perfect, thanks!

Regards
Igor

author maintainer
#18 lore raw

Re: [EXT] [PATCH 09/15] qed: use new module_firmware_crashed()

Quoted 19 lines · Igor Russkikh
Quoted 16 lines

So do you mean like the changes below?

drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
index f4eebaabb6d0..95cb7da2542e 100644
@@ -7906,6 +7906,7 @@ int qed_dbg_all_data(struct qed_dev *cdev, void
 *buffer)
 		rc = qed_dbg_grc(cdev, (u8 *)buffer + offset +
 				 REGDUMP_HEADER_SIZE, &feature_size);
 		if (!rc) {
+			module_firmware_crashed();
 			*(u32 *)((u8 *)buffer + offset) =
 			    qed_calc_regdump_header(cdev, GRC_DUMP,
Quoted 1 line

cur_engine,

Please remove this invocation. Its not a place where FW crash is happening.

Will do!

Quoted 9 lines

drivers/net/ethernet/qlogic/qed/qed_debug.c

Quoted 7 lines
drivers/net/ethernet/qlogic/qed/qed_debug.c +0 -0
 		DP_NOTICE(p_hwfn,
 			  "The MFW failed to respond to command 0x%08x

[param 0x%08x].\n",

drivers/net/ethernet/qlogic/qed/qed_debug.c +1 -0
 			  p_mb_params->cmd, p_mb_params->param);
+		module_firmware_crashed();
 		qed_mcp_print_cpu_info(p_hwfn, p_ptt);

This one is perfect, thanks!

Can I add your Reviewed-by provided I remove the hunk above?

Luis

#19 lore raw

RE: [EXT] [PATCH 09/15] qed: use new module_firmware_crashed()

Quoted 7 lines
Quoted 3 lines

This one is perfect, thanks!

Can I add your Reviewed-by provided I remove the hunk above?

Luis

Sure, I'm OK.

Regards,
Igor

author maintainer
#20 lore raw

PATCH 10/15 soc: qcom: ipa: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/ipa/ipa_modem.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ipa/ipa_modem.c +1 -0
index ed10818dd99f..1790b87446ed 100644
@@ -285,6 +285,7 @@ static void ipa_modem_crashed(struct ipa *ipa)
 	struct device *dev = &ipa->pdev->dev;
 	int ret;
 
+	module_firmware_crashed();
 	ipa_endpoint_modem_pause_all(ipa, true);
 
 	ipa_endpoint_modem_hol_block_clear_all(ipa);
Signature · 1 line
2.25.1
author maintainer
#21 lore raw

PATCH 11/15 wimax/i2400m: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/wimax/i2400m/rx.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wimax/i2400m/rx.c +1 -0
index c9fb619a9e01..307a62ca183f 100644
@@ -712,6 +712,7 @@ void __i2400m_roq_queue(struct i2400m *i2400m, struct i2400m_roq *roq,
 	dev_err(dev, "SW BUG? failed to insert packet\n");
 	dev_err(dev, "ERX: roq %p [ws %u] skb %p nsn %d sn %u\n",
 		roq, roq->ws, skb, nsn, roq_data->sn);
+	module_firmware_crashed();
 	skb_queue_walk(&roq->queue, skb_itr) {
 		roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb;
 		nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn);
Signature · 1 line
2.25.1
author maintainer
#22 lore raw

PATCH 12/15 ath10k: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/wireless/ath/ath10k/pci.c  | 2 ++
 drivers/net/wireless/ath/ath10k/sdio.c | 2 ++
 drivers/net/wireless/ath/ath10k/snoc.c | 1 +
 3 files changed, 5 insertions(+)
drivers/net/wireless/ath/ath10k/pci.c +2 -0
index 1d941d53fdc9..6bd0f3b518b9 100644
@@ -1767,6 +1767,7 @@ static void ath10k_pci_fw_dump_work(struct work_struct *work)
 		scnprintf(guid, sizeof(guid), "n/a");
 
 	ath10k_err(ar, "firmware crashed! (guid %s)\n", guid);
+	module_firmware_crashed();
 	ath10k_print_driver_info(ar);
 	ath10k_pci_dump_registers(ar, crash_data);
 	ath10k_ce_dump_registers(ar, crash_data);
@@ -2837,6 +2838,7 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar,
 	if (ret) {
 		if (ath10k_pci_has_fw_crashed(ar)) {
 			ath10k_warn(ar, "firmware crashed during chip reset\n");
+			module_firmware_crashed();
 			ath10k_pci_fw_crashed_clear(ar);
 			ath10k_pci_fw_crashed_dump(ar);
 		}
drivers/net/wireless/ath/ath10k/sdio.c +2 -0
index e2aff2254a40..d34ad289380f 100644
@@ -794,6 +794,7 @@ static int ath10k_sdio_mbox_proc_dbg_intr(struct ath10k *ar)
 
 	/* TODO: Add firmware crash handling */
 	ath10k_warn(ar, "firmware crashed\n");
+	module_firmware_crashed();
 
 	/* read counter to clear the interrupt, the debug error interrupt is
 	 * counter 0.
@@ -915,6 +916,7 @@ static int ath10k_sdio_mbox_proc_cpu_intr(struct ath10k *ar)
 	if (cpu_int_status & MBOX_CPU_STATUS_ENABLE_ASSERT_MASK) {
 		ath10k_err(ar, "firmware crashed!\n");
 		queue_work(ar->workqueue, &ar->restart_work);
+		module_firmware_crashed();
 	}
 	return ret;
 }
drivers/net/wireless/ath/ath10k/snoc.c +1 -0
index 354d49b1cd45..7cfc123c345c 100644
@@ -1451,6 +1451,7 @@ void ath10k_snoc_fw_crashed_dump(struct ath10k *ar)
 		scnprintf(guid, sizeof(guid), "n/a");
 
 	ath10k_err(ar, "firmware crashed! (guid %s)\n", guid);
+	module_firmware_crashed();
 	ath10k_print_driver_info(ar);
 	ath10k_msa_dump_memory(ar, crash_data);
 	mutex_unlock(&ar->dump_mutex);
Signature · 7 lines
2.25.1


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
author maintainer
#23 lore raw

PATCH 13/15 ath6kl: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

---
 drivers/net/wireless/ath/ath6kl/hif.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath6kl/hif.c +1 -0
index d1942537ea10..cfd838607544 100644
@@ -120,6 +120,7 @@ static int ath6kl_hif_proc_dbg_intr(struct ath6kl_device *dev)
 	int ret;
 
 	ath6kl_warn("firmware crashed\n");
+	module_firmware_crashed();
 
 	/*
 	 * read counter to clear the interrupt, the debug error interrupt is
Signature · 7 lines
2.25.1


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
author maintainer
#24 lore raw

PATCH 14/15 brcm80211: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

Cc Arend van Spriel <[email protected]>
Cc Franky Lin <[email protected]>
Cc Hante Meuleman <[email protected]>
Cc Chi-Hsien Lin <[email protected]>
Cc Wright Feng <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "Rafał Miłecki" <[email protected]>
Cc Pieter-Paul Giesberts <[email protected]>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +1 -0
index c88655acc78c..d623f83568b3 100644
@@ -1393,6 +1393,7 @@ void brcmf_fw_crashed(struct device *dev)
 	struct brcmf_pub *drvr = bus_if->drvr;
 
 	bphy_err(drvr, "Firmware has halted or crashed\n");
+	module_firmware_crashed();
 
 	brcmf_dev_coredump(dev);
 
Signature · 1 line
2.25.1
author maintainer
#25 lore raw

PATCH 15/15 mwl8k: use new module_firmware_crashed()

In reply to Luis Chamberlain

This makes use of the new module_firmware_crashed() to help annotate when firmware for device drivers crash. When firmware crashes devices can sometimes become unresponsive, and recovery sometimes requires a driver unload / reload and in the worst cases a reboot.

Using a taint flag allows us to annotate when this happens clearly.

Cc Lennert Buytenhek <[email protected]>
Cc Kalle Valo <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Johannes Berg <[email protected]>
Cc Ganapathi Bhat <[email protected]>
---
 drivers/net/wireless/marvell/mwl8k.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/marvell/mwl8k.c +1 -0
index 97f23f93f6e7..d609ef1bb879 100644
@@ -1551,6 +1551,7 @@ static int mwl8k_tx_wait_empty(struct ieee80211_hw *hw)
 	 * the firmware has crashed
 	 */
 	if (priv->hw_restart_in_progress) {
+		module_firmware_crashed();
 		if (priv->hw_restart_owner == current)
 			return 0;
 		else
Signature · 1 line
2.25.1
maintainer
#26 lore raw
In reply to Luis Chamberlain
Quoted 13 lines · On Sat, 9 May 2020 04:35:37 +0000 Luis Chamberlain wrote:

Device driver firmware can crash, and sometimes, this can leave your system in a state which makes the device or subsystem completely useless. Detecting this by inspecting /proc/sys/kernel/tainted instead of scraping some magical words from the kernel log, which is driver specific, is much easier. So instead this series provides a helper which lets drivers annotate this and shows how to use this on networking drivers.

My methodology for finding when firmware crashes is to git grep for "crash" and then doing some study of the code to see if this indeed a place where the firmware crashes. In some places this is quite obvious.

Quoted 5 lines

I'm starting off with networking first, if this gets merged later on I can focus on the other drivers, but I already have some work done on other subsytems.

Review, flames, etc are greatly appreciated.

Tainting itself may be useful, but that's just the first step. I'd much rather see folks start using the devlink health infrastructure. Devlink is netlink based, but it's _not_ networking specific (many of its optional features obviously are, but don't let that mislead you).

With devlink health we get (a) a standard notification on the failure;
(b) information/state dump in a (somewhat) structured form, which can be collected & shared with vendors; (c) automatic remediation (usually device reset of some scope).

Now regarding the tainting - as I said it may be useful, but don't we have to define what constitutes a "firmware crash"? There are many failure modes, some perfectly recoverable (e.g. processing queue hang), some mere bugs (e.g. device fails to initialize some functions). All of them may impact the functioning of the system. How do we choose those that taint?

author maintainer
#27 lore raw
Quoted 25 lines · Jakub Kicinski
Quoted 13 lines · On Sat, 9 May 2020 04:35:37 +0000 Luis Chamberlain wrote:

Device driver firmware can crash, and sometimes, this can leave your system in a state which makes the device or subsystem completely useless. Detecting this by inspecting /proc/sys/kernel/tainted instead of scraping some magical words from the kernel log, which is driver specific, is much easier. So instead this series provides a helper which lets drivers annotate this and shows how to use this on networking drivers.

My methodology for finding when firmware crashes is to git grep for "crash" and then doing some study of the code to see if this indeed a place where the firmware crashes. In some places this is quite obvious.

Quoted 5 lines

I'm starting off with networking first, if this gets merged later on I can focus on the other drivers, but I already have some work done on other subsytems.

Review, flames, etc are greatly appreciated.

Tainting itself may be useful, but that's just the first step. I'd much rather see folks start using the devlink health infrastructure. Devlink is netlink based, but it's _not_ networking specific (many of its optional features obviously are, but don't let that mislead you).

Quoted 4 lines

With devlink health we get (a) a standard notification on the failure;
(b) information/state dump in a (somewhat) structured form, which can be collected & shared with vendors; (c) automatic remediation (usually device reset of some scope).

It indeed sounds very useful!

Quoted 2 lines

Now regarding the tainting - as I said it may be useful, but don't we have to define what constitutes a "firmware crash"?

Yes indeed, I missed clarifying this in the documentation. I'll do so in my next respin.

Quoted 5 lines

There are many
failure modes, some perfectly recoverable (e.g. processing queue hang), some mere bugs (e.g. device fails to initialize some functions). All of them may impact the functioning of the system. How do we choose those that taint?

Its up to the maintainers of the device driver, what I was aiming for were those firmware crashes which indeed *can* have an impact on user experience, and can *even* potentially require a driver removal / addition to to get things back in order again.

Luis

#28 lore raw
In reply to Luis Chamberlain
Quoted 8 lines · Luis Chamberlain

Device driver firmware can crash, and sometimes, this can leave your system in a state which makes the device or subsystem completely useless. Detecting this by inspecting /proc/sys/kernel/tainted instead of scraping some magical words from the kernel log, which is driver specific, is much easier. So instead this series provides a helper which lets drivers annotate this and shows how to use this on networking drivers.

If the driver is able to detect that the device firmware has come back alive, through user intervention or whatever, should there be a way to "untaint" the kernel?  Or would you expect it to remain tainted?

sln

#29 lore raw
Quoted 9 lines · Shannon Nelson
Quoted 8 lines · Luis Chamberlain

Device driver firmware can crash, and sometimes, this can leave your system in a state which makes the device or subsystem completely useless. Detecting this by inspecting /proc/sys/kernel/tainted instead of scraping some magical words from the kernel log, which is driver specific, is much easier. So instead this series provides a helper which lets drivers annotate this and shows how to use this on networking drivers.

Quoted 3 lines

If the driver is able to detect that the device firmware has come back alive, through user intervention or whatever, should there be a way to "untaint" the kernel?  Or would you expect it to remain tainted?

Hi Shannon

In general, you don't want to be able to untained. Say a non-GPL licenced module is loaded, which taints the kernel. It might then try to untaint the kernel to hide its.

As for firmware, how much damage can the firmware do as it crashed? If it is a DMA master, it could of splattered stuff through memory. Restarting the firmware is not going to reverse the damage it has done.

Andrew

#30 lore raw
Quoted 10 lines · Andrew Lunn
Quoted 9 lines · Shannon Nelson
Quoted 8 lines · Luis Chamberlain

Device driver firmware can crash, and sometimes, this can leave your system in a state which makes the device or subsystem completely useless. Detecting this by inspecting /proc/sys/kernel/tainted instead of scraping some magical words from the kernel log, which is driver specific, is much easier. So instead this series provides a helper which lets drivers annotate this and shows how to use this on networking drivers.

Quoted 8 lines
Quoted 3 lines

If the driver is able to detect that the device firmware has come back alive, through user intervention or whatever, should there be a way to "untaint" the kernel?  Or would you expect it to remain tainted?

Hi Shannon

In general, you don't want to be able to untained. Say a non-GPL licenced module is loaded, which taints the kernel. It might then try to untaint the kernel to hide its.

Yeah, obviously we don't want this to be abuseable.  I was just wondering about reversing this particular status if the broken device could get itself fixed.

Quoted 6 lines

As for firmware, how much damage can the firmware do as it crashed? If it is a DMA master, it could of splattered stuff through memory. Restarting the firmware is not going to reverse the damage it has done.

True, and tho' the driver might get the thing restarted, it wouldn't necessarily know what kind of damage had ensued.

Carry on,
sln

author maintainer
#31 lore raw
Quoted 9 lines · Shannon Nelson
Quoted 6 lines · Andrew Lunn

On Sat, May 09, 2020 at 06:01:51PM -0700, Shannon Nelson wrote:
As for firmware, how much damage can the firmware do as it crashed? If it is a DMA master, it could of splattered stuff through memory. Restarting the firmware is not going to reverse the damage it has done.

True, and tho' the driver might get the thing restarted, it wouldn't necessarily know what kind of damage had ensued.

Indeed, it is those uknowns which we currently assume is just fine, but in reality can be damaging. Today we just move on with life, but such information is useful for analysis.

Luis

maintainer
#32 lore raw
In reply to Shannon Nelson
Quoted 3 lines · On Sat, 9 May 2020 18:01:51 -0700 Shannon Nelson <[email protected]> wrote:

If the driver is able to detect that the device firmware has come back alive, through user intervention or whatever, should there be a way to "untaint" the kernel?  Or would you expect it to remain tainted?

The only way to untaint a kernel is a reboot. A taint just means "something happened to this kernel since it was booted". It's used as a hint, and that's all.

I agree with the other comments in this thread. Use devlink health or whatever tool to look further into causes. But from what I see here, this code is "good enough" for a taint.

-- Steve