Skip to content

Commit

Permalink
net: wwan: iosm: initialize pc_wwan->if_mutex earlier
Browse files Browse the repository at this point in the history
wwan_register_ops() ends up calls ipc_wwan_newlink() before it returns.

ipc_wwan_newlink() uses pc_wwan->if_mutex, so we must initialize it
before calling wwan_register_ops(). This fixes the following WARN()
when lock-debugging is enabled:

[  610.708713] ------------[ cut here ]------------
[  610.708721] DEBUG_LOCKS_WARN_ON(lock->magic != lock)
[  610.708727] WARNING: CPU: 11 PID: 506 at kernel/locking/mutex.c:582 __mutex_lock+0x3e4/0x7e0
[  610.708736] Modules linked in: iosm snd_seq_dummy snd_hrtimer rfcomm qrtr bnep binfmt_misc snd_ctl_led snd_soc_skl_hda_dsp snd_soc_intel_hda_dsp_common snd_soc_hdac_hdmi snd_sof_probes snd_soc_dmic iTCO_wdt intel_pmc_bxt mei_hdcp mei_pxp iTCO_vendor_support pmt_telemetry intel_rapl_msr pmt_class intel_tcc_cooling x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm irqbypass rapl intel_cstate intel_uncore pcspkr think_lmi firmware_attributes_class wmi_bmof snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic snd_sof_pci_intel_tgl snd_sof_intel_hda_common soundwire_intel soundwire_generic_allocation soundwire_cadence snd_sof_intel_hda snd_sof_pci snd_sof_xtensa_dsp snd_sof snd_sof_utils snd_soc_hdac_hda snd_hda_ext_core snd_soc_acpi_intel_match snd_soc_acpi soundwire_bus snd_soc_core snd_compress ac97_bus snd_pcm_dmaengine snd_hda_intel snd_intel_dspcfg snd_intel_sdw_acpi snd_hda_codec snd_hda_core iwlmvm snd_hwdep snd_seq btusb snd_seq_device btrtl btbcm snd_pcm
[  610.708767]  btintel mei_me mac80211 i2c_i801 btmtk libarc4 i2c_smbus snd_timer mei bluetooth hid_sensor_gyro_3d iwlwifi hid_sensor_accel_3d idma64 hid_sensor_trigger hid_sensor_iio_common ecdh_generic industrialio_triggered_buffer kfifo_buf cfg80211 joydev industrialio int3403_thermal soc_button_array ov2740 v4l2_fwnode v4l2_async videodev mc intel_skl_int3472_tps68470 tps68470_regulator clk_tps68470 intel_skl_int3472_discrete intel_hid sparse_keymap int3400_thermal acpi_thermal_rel acpi_tad acpi_pad vfat fat processor_thermal_device_pci processor_thermal_device processor_thermal_rfim processor_thermal_mbox processor_thermal_rapl thunderbolt intel_rapl_common intel_vsec int340x_thermal_zone igen6_edac zram dm_crypt hid_sensor_hub intel_ishtp_hid i915 thinkpad_acpi drm_buddy drm_display_helper snd soundcore ledtrig_audio crct10dif_pclmul wacom platform_profile crc32_pclmul cec nvme intel_ish_ipc rfkill crc32c_intel ucsi_acpi hid_multitouch serio_raw typec_ucsi ghash_clmulni_intel
[  610.708798]  nvme_core video intel_ishtp ttm typec i2c_hid_acpi i2c_hid wmi pinctrl_tigerlake ip6_tables ip_tables i2c_dev fuse
[  610.708806] CPU: 11 PID: 506 Comm: kworker/11:2 Tainted: G        W          6.0.0+ torvalds#505
[  610.708809] Hardware name: LENOVO 21CEZ9Q3US/21CEZ9Q3US, BIOS N3AET66W (1.31 ) 09/09/2022
[  610.708811] Workqueue: events ipc_imem_run_state_worker [iosm]
[  610.708831] RIP: 0010:__mutex_lock+0x3e4/0x7e0
[  610.708836] Code: ff 85 c0 0f 84 9b fc ff ff 8b 15 6f 54 11 01 85 d2 0f 85 8d fc ff ff 48 c7 c6 f0 f0 84 94 48 c7 c7 83 07 83 94 e8 91 33 f8 ff <0f> 0b e9 73 fc ff ff f6 83 d1 0c 00 00 01 0f 85 4b ff ff ff 4c 89
[  610.708837] RSP: 0018:ffffaf0b80767a50 EFLAGS: 00010282
[  610.708840] RAX: 0000000000000028 RBX: 0000000000000000 RCX: 0000000000000000
[  610.708841] RDX: 0000000000000001 RSI: ffffffff948b357c RDI: 00000000ffffffff
[  610.708842] RBP: ffffaf0b80767ae0 R08: 0000000000000000 R09: ffffaf0b80767900
[  610.708843] R10: 0000000000000003 R11: ffff9c191b7fffe8 R12: 0000000000000002
[  610.708845] R13: 0000000000000000 R14: ffff9c16a3044450 R15: ffff9c15e342ce40
[  610.708846] FS:  0000000000000000(0000) GS:ffff9c18fd6c0000(0000) knlGS:0000000000000000
[  610.708848] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  610.708849] CR2: 00001d40ba7bd008 CR3: 00000001d6c26002 CR4: 0000000000770ee0
[  610.708850] PKRU: 55555554
[  610.708851] Call Trace:
[  610.708852]  <TASK>
[  610.708856]  ? ipc_wwan_newlink+0x46/0xb0 [iosm]
[  610.708862]  ? wwan_port_fops_read+0x1b0/0x1b0
[  610.708867]  ? ipc_wwan_newlink+0x46/0xb0 [iosm]
[  610.708872]  ipc_wwan_newlink+0x46/0xb0 [iosm]
[  610.708877]  wwan_rtnl_newlink+0x7e/0xd0
[  610.708880]  wwan_create_default_link+0x24c/0x2e0
[  610.708890]  wwan_register_ops+0x71/0x90
[  610.708893]  ipc_wwan_init+0x48/0x90 [iosm]
[  610.708897]  ipc_imem_wwan_channel_init+0x81/0xa0 [iosm]
[  610.708902]  ipc_imem_run_state_worker+0xab/0x1b0 [iosm]
[  610.708907]  process_one_work+0x254/0x570
[  610.708914]  worker_thread+0x4f/0x3a0
[  610.708917]  ? process_one_work+0x570/0x570
[  610.708919]  kthread+0xf2/0x120
[  610.708922]  ? kthread_complete_and_exit+0x20/0x20
[  610.708924]  ret_from_fork+0x1f/0x30
[  610.708931]  </TASK>
[  610.708931] irq event stamp: 89949
[  610.708933] hardirqs last  enabled at (89949): [<ffffffff93ebc630>] _raw_spin_unlock_irqrestore+0x30/0x60
[  610.708936] hardirqs last disabled at (89948): [<ffffffff93ebc3bf>] _raw_spin_lock_irqsave+0x5f/0x70
[  610.708938] softirqs last  enabled at (89876): [<ffffffff93bc2509>] __netdev_alloc_skb+0xe9/0x150
[  610.708942] softirqs last disabled at (89874): [<ffffffff93bc2509>] __netdev_alloc_skb+0xe9/0x150
[  610.708944] ---[ end trace 0000000000000000 ]---

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
jwrdegoede committed Oct 15, 2022
1 parent 7905372 commit c1a3f00
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/net/wwan/iosm/iosm_ipc_wwan.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ struct iosm_wwan *ipc_wwan_init(struct iosm_imem *ipc_imem, struct device *dev)

ipc_wwan->dev = dev;
ipc_wwan->ipc_imem = ipc_imem;
mutex_init(&ipc_wwan->if_mutex);

/* WWAN core will create a netdev for the default IP MUX channel */
if (wwan_register_ops(ipc_wwan->dev, &iosm_wwan_ops, ipc_wwan,
Expand All @@ -330,8 +331,6 @@ struct iosm_wwan *ipc_wwan_init(struct iosm_imem *ipc_imem, struct device *dev)
return NULL;
}

mutex_init(&ipc_wwan->if_mutex);

return ipc_wwan;
}

Expand Down

0 comments on commit c1a3f00

Please sign in to comment.