[Intel-wired-lan] [PATCH iwl-net v2] ice: Schedule service task in IRQ thread_fn

Yochai Hagvi yochai.hagvi at intel.com
Tue May 9 11:39:43 UTC 2023


On some RT kernels (E.g.: MontaVista), scheduling service task in
interrupt context may result in a kernel panic:

BUG: scheduling while atomic: swapper/4/0/0x00010002
Modules linked in: ip6t_REJECT nf_reject_ipv6 xt_multiport ipt_rpfilter ip6t_rpfilter xt_set ip6table_raw iptable_raw ip_set_hash_ip ip_set_hash_net ip_set veth ip_vs nf_conntrack_netlink xt_nat ip6t_MASQUERADE nf_nat_masquerade_ipv6 ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle nf_tables nfnetlink iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 xt_conntrack xt_comment xt_mark ip6table_filter ip6_tables ipip tunnel4 ip_tunnel xt_addrtype iptable_filter iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack br_netfilter bridge overlay(T) sunrpc dm_mirror dm_region_hash dm_log dm_mod dell_smbios dell_wmi_descriptor dcdbas i10nm_edac nfit libnvdimm intel_powerclamp coretemp intel_rapl iosf_mbi crc32_pclmul ghash_clmulni_intel aesni_intel
lrw gf128mul glue_helper ablk_helper cryptd vfat fat pcspkr joydev sg mei_me i2c_i801 mei wmi ipmi_si ipmi_devintf ipmi_msghandler pinctrl_lewisburg pinctrl_intel acpi_power_meter acpi_pad ip_tables xfs i40e sr_mod cdrom sd_mod crc_t10dif crct10dif_generic crct10dif_pclmul crct10dif_common crc32c_intel mgag200 i2c_algo_bit uas drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops usb_storage ttm ice(OE) bnxt_en ahci intel_auxiliary(OE) drm ptp devlink libahci pps_core drm_panel_orientation_quirks libata sctp libcrc32c 8021q garp stp llc mrp
CPU: 4 PID: 0 Comm: swapper/4 Kdump: loaded Tainted: G      OE ------------ T 3.10.0-1160.11.1.rt56.1145.mvista.test.6.el7.x86_64 #1
Hardware name: Dell Inc. PowerEdge XR11/0P2RNT, BIOS 1.8.2 09/14/2022
Call Trace:
 dump_stack+0x19/0x1b
 __schedule_bug+0x64/0x72
 __schedule+0x77b/0x920
 ? check_preempt_wakeup+0x146/0x220
 schedule+0x30/0xa0
 rt_spin_lock_slowlock_locked+0xf5/0x2d0
 rt_spin_lock_slowlock+0x57/0x90
 rt_spin_lock+0x25/0x30
 __queue_work+0xcf/0x440
 queue_work_on+0xfe/0x110
 ice_service_task_schedule+0x5c/0x60 [ice]
 ice_misc_intr+0x1b1/0x310 [ice]
 __handle_irq_event_percpu+0x5c/0x220
 ? native_safe_halt+0xb/0x20
 handle_irq_event_percpu+0x49/0xa0
 ? tick_nohz_stop_sched_tick+0x115/0x3e0
 handle_irq_event+0x6e/0xa0
 handle_edge_irq+0xa1/0x1b0
 handle_irq+0xe7/0x1b0
 ? atomic_notifier_call_chain+0x3a/0x50
 do_IRQ+0x4d/0xf0
 common_interrupt+0x16a/0x16a
 ? hrtimer_cancel+0x20/0x30
 ? __cpuidle_text_start+0x8/0x8
 ? native_safe_halt+0xb/0x20
 default_idle+0x1e/0x130
 arch_cpu_idle+0x20/0xc0
 cpu_startup_entry+0x14a/0x1d0
 start_secondary+0x1eb/0x260
 start_cpu+0x5/0x14

This is happening due to queue_work call.
Move ice_service_task_schedule to IRQ bottom half.

Fixes: 0b28b702e72a ("ice: Support link events, reset and rebuild")
Fixes: de75135b5c04 ("ice: Fix probe/open race condition")
Signed-off-by: Karol Kolacinski <karol.kolacinski at intel.com>
Signed-off-by: Yochai Hagvi <yochai.hagvi at intel.com>
---
v2:
- provided example in commit message, and fixed typo
- provided Fixes tag in commit message
- removed unnecessary braces around single line if

 drivers/net/ethernet/intel/ice/ice_main.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 7c04057c524c..ef6bc1f67887 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3058,7 +3058,6 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
 {
 	struct ice_pf *pf = (struct ice_pf *)data;
 	struct ice_hw *hw = &pf->hw;
-	irqreturn_t ret = IRQ_NONE;
 	struct device *dev;
 	u32 oicr, ena_mask;
 
@@ -3137,11 +3136,8 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
 		}
 	}
 
-	if (oicr & PFINT_OICR_TSYN_TX_M) {
+	if (oicr & PFINT_OICR_TSYN_TX_M)
 		ena_mask &= ~PFINT_OICR_TSYN_TX_M;
-		if (!hw->reset_ongoing)
-			ret = IRQ_WAKE_THREAD;
-	}
 
 	if (oicr & PFINT_OICR_TSYN_EVNT_M) {
 		u8 tmr_idx = hw->func_caps.ts_func_info.tmr_index_owned;
@@ -3170,18 +3166,13 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
 		 * reset the device.
 		 */
 		if (oicr & (PFINT_OICR_PCI_EXCEPTION_M |
-			    PFINT_OICR_ECC_ERR_M)) {
+			    PFINT_OICR_ECC_ERR_M))
 			set_bit(ICE_PFR_REQ, pf->state);
-			ice_service_task_schedule(pf);
-		}
 	}
-	if (!ret)
-		ret = IRQ_HANDLED;
 
-	ice_service_task_schedule(pf);
 	ice_irq_dynamic_ena(hw, NULL, NULL);
 
-	return ret;
+	return IRQ_WAKE_THREAD;
 }
 
 /**
@@ -3196,6 +3187,8 @@ static irqreturn_t ice_misc_intr_thread_fn(int __always_unused irq, void *data)
 	if (ice_is_reset_in_progress(pf->state))
 		return IRQ_HANDLED;
 
+	ice_service_task_schedule(pf);
+
 	while (!ice_ptp_process_ts(pf))
 		usleep_range(50, 100);
 

base-commit: d15a5df649ee6351197170c855148f07caf69d0b
-- 
2.21.3



More information about the Intel-wired-lan mailing list