linux/drivers/net/ethernet
Kai-Heng Feng 271ea70729 igc: Report speed and duplex as unknown when device is runtime suspended
commit 2e99dedc73f004f650b197c9b269c15c7e01ad15 upstream.

Similar to commit 165ae7a8fe ("igb: Report speed and duplex as unknown
when device is runtime suspended"), if we try to read speed and duplex
sysfs while the device is runtime suspended, igc will complain and
stops working:

[  123.449883] igc 0000:03:00.0 enp3s0: PCIe link lost, device now detached
[  123.450052] BUG: kernel NULL pointer dereference, address: 0000000000000008
[  123.450056] #PF: supervisor read access in kernel mode
[  123.450058] #PF: error_code(0x0000) - not-present page
[  123.450059] PGD 0 P4D 0
[  123.450064] Oops: 0000 [#1] SMP NOPTI
[  123.450068] CPU: 0 PID: 2525 Comm: udevadm Tainted: G     U  W  OE     5.10.0-1002-oem #2+rkl2-Ubuntu
[  123.450078] RIP: 0010:igc_rd32+0x1c/0x90 [igc]
[  123.450080] Code: c0 5d c3 b8 fd ff ff ff c3 0f 1f 44 00 00 0f 1f 44 00 00 55 89 f0 48 89 e5 41 56 41 55 41 54 49 89 c4 53 48 8b 57 08 48 01 d0 <44> 8b 28 41 83 fd ff 74 0c 5b 44 89 e8 41 5c 41 5d 4

[  123.450083] RSP: 0018:ffffb0d100d6fcc0 EFLAGS: 00010202
[  123.450085] RAX: 0000000000000008 RBX: ffffb0d100d6fd30 RCX: 0000000000000000
[  123.450087] RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff945a12716c10
[  123.450089] RBP: ffffb0d100d6fce0 R08: ffff945a12716550 R09: ffff945a09874000
[  123.450090] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000008
[  123.450092] R13: ffff945a12716000 R14: ffff945a037da280 R15: ffff945a037da290
[  123.450094] FS:  00007f3b34c868c0(0000) GS:ffff945b89200000(0000) knlGS:0000000000000000
[  123.450096] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  123.450098] CR2: 0000000000000008 CR3: 00000001144de006 CR4: 0000000000770ef0
[  123.450100] PKRU: 55555554
[  123.450101] Call Trace:
[  123.450111]  igc_ethtool_get_link_ksettings+0xd6/0x1b0 [igc]
[  123.450118]  __ethtool_get_link_ksettings+0x71/0xb0
[  123.450123]  duplex_show+0x74/0xc0
[  123.450129]  dev_attr_show+0x1d/0x40
[  123.450134]  sysfs_kf_seq_show+0xa1/0x100
[  123.450137]  kernfs_seq_show+0x27/0x30
[  123.450142]  seq_read+0xb7/0x400
[  123.450148]  ? common_file_perm+0x72/0x170
[  123.450151]  kernfs_fop_read+0x35/0x1b0
[  123.450155]  vfs_read+0xb5/0x1b0
[  123.450157]  ksys_read+0x67/0xe0
[  123.450160]  __x64_sys_read+0x1a/0x20
[  123.450164]  do_syscall_64+0x38/0x90
[  123.450168]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[  123.450170] RIP: 0033:0x7f3b351fe142
[  123.450173] Code: c0 e9 c2 fe ff ff 50 48 8d 3d 3a ca 0a 00 e8 f5 19 02 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24
[  123.450174] RSP: 002b:00007fffef2ec138 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[  123.450177] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3b351fe142
[  123.450179] RDX: 0000000000001001 RSI: 00005644c047f070 RDI: 0000000000000003
[  123.450180] RBP: 00007fffef2ec340 R08: 00005644c047f070 R09: 00007f3b352d9320
[  123.450182] R10: 00005644c047c010 R11: 0000000000000246 R12: 00005644c047cbf0
[  123.450184] R13: 00005644c047e6d0 R14: 0000000000000003 R15: 00007fffef2ec140
[  123.450189] Modules linked in: rfcomm ccm cmac algif_hash algif_skcipher af_alg bnep toshiba_acpi industrialio toshiba_haps hp_accel lis3lv02d btusb btrtl btbcm btintel bluetooth ecdh_generic ecc joydev input_leds nls_iso8859_1 snd_sof_pci snd_sof_intel_byt snd_sof_intel_ipc snd_sof_intel_hda_common snd_soc_hdac_hda snd_hda_codec_hdmi snd_sof_xtensa_dsp snd_sof_intel_hda snd_sof snd_hda_ext_core snd_soc_acpi_intel_match snd_soc_acpi snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio snd_hda_intel snd_intel_dspcfg soundwire_intel soundwire_generic_allocation soundwire_cadence snd_hda_codec snd_hda_core ath10k_pci snd_hwdep intel_rapl_msr intel_rapl_common ath10k_core soundwire_bus snd_soc_core x86_pkg_temp_thermal ath intel_powerclamp snd_compress ac97_bus snd_pcm_dmaengine mac80211 snd_pcm coretemp snd_seq_midi snd_seq_midi_event snd_rawmidi kvm_intel cfg80211 snd_seq snd_seq_device snd_timer mei_hdcp kvm libarc4 snd crct10dif_pclmul ghash_clmulni_intel aesni_intel
 mei_me dell_wmi
[  123.450266]  dell_smbios soundcore sparse_keymap dcdbas crypto_simd cryptd mei dell_uart_backlight glue_helper ee1004 wmi_bmof intel_wmi_thunderbolt dell_wmi_descriptor mac_hid efi_pstore acpi_pad acpi_tad intel_cstate sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear dm_mirror dm_region_hash dm_log hid_generic usbhid hid i915 i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops cec crc32_pclmul rc_core drm intel_lpss_pci i2c_i801 ahci igc intel_lpss i2c_smbus idma64 xhci_pci libahci virt_dma xhci_pci_renesas wmi video pinctrl_tigerlake
[  123.450335] CR2: 0000000000000008
[  123.450338] ---[ end trace 9f731e38b53c35cc ]---

The more generic approach will be wrap get_link_ksettings() with begin()
and complete() callbacks, and calls runtime resume and runtime suspend
routine respectively. However, igc is like igb, runtime resume routine
uses rtnl_lock() which upper ethtool layer also uses.

So to prevent a deadlock on rtnl, take a different approach, use
pm_runtime_suspended() to avoid reading register while device is runtime
suspended.

Fixes: 8c5ad0dae9 ("igc: Add ethtool support")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Acked-by: Sasha Neftin <sasha.neftin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-10 09:25:32 +01:00
..
3com
8390
adaptec
aeroflex
agere
alacritech
allwinner net: allwinner: Fix some resources leak in the error handling path of the probe and in the remove function 2020-12-30 11:51:27 +01:00
alteon
altera
amazon net: ena: set initial DMA width to avoid intel iommu issue 2020-12-02 08:49:52 +01:00
amd
apm
apple
aquantia
arc
atheros
aurora
broadcom bnxt_en: Improve stats context resource accounting with RDMA driver loaded. 2021-01-19 18:26:18 +01:00
brocade
cadence cadence: force nonlinear buffers to be cloned 2020-11-10 12:37:24 +01:00
calxeda
cavium net: ethernet: cavium: octeon_mgmt: use phy_start and phy_stop 2020-10-14 10:33:03 +02:00
chelsio cxgb3: fix error return code in t3_sge_alloc_qset() 2020-12-08 10:40:26 +01:00
cirrus
cisco net: enic: Cure the enic api locking trainwreck 2020-10-29 09:57:43 +01:00
cortina
davicom
dec
dlink
emulex
ezchip
faraday net: ftgmac100: Fix crash when removing driver 2020-11-24 13:29:00 +01:00
freescale net: ethernet: fs_enet: Add missing MODULE_LICENSE 2021-01-19 18:26:15 +01:00
fujitsu
google
hisilicon net: hns3: fix a phy loopback fail issue 2021-01-17 14:05:31 +01:00
hp
huawei
i825xx
ibm ibmvnic: Ensure that CRQ entry read are correctly ordered 2021-02-07 15:35:46 +01:00
intel igc: Report speed and duplex as unknown when device is runtime suspended 2021-02-10 09:25:32 +01:00
marvell net: mvpp2: TCAM entry enable should be written after SRAM data 2021-02-10 09:25:28 +01:00
mediatek
mellanox net/mlx5: Fix leak upon failure of rule creation 2021-02-10 09:25:27 +01:00
micrel
microchip lan743x: fix rx_napi_poll/interrupt ping-pong 2020-12-30 11:51:27 +01:00
moxa
mscc net: mscc: ocelot: allow offloading of bridge on top of LAG 2021-01-27 11:47:54 +01:00
myricom
natsemi net/sonic: Fix some resource leaks in error handling paths 2021-01-17 14:05:31 +01:00
neterion
netronome
ni
nvidia
nxp
oki-semi
packetengines
pasemi net: pasemi: fix error return code in pasemi_mac_open() 2020-12-08 10:40:26 +01:00
pensando ionic: account for vlan tag len in rx buffer len 2021-01-12 20:16:16 +01:00
qlogic netxen_nic: fix MSI/MSI-x interrupts 2021-01-23 15:57:57 +01:00
qualcomm net: qualcomm: rmnet: Fix incorrect receive packet handling during cleanup 2020-11-24 13:28:58 +01:00
rdc
realtek r8169: fix WoL on shutdown if CONFIG_DEBUG_SHIRQ is set 2021-02-10 09:25:28 +01:00
renesas sh_eth: Fix power down vs. is_opened flag ordering 2021-01-27 11:47:52 +01:00
rocker
samsung
seeq
sfc
sgi
silan
sis
smsc
socionext
stmicro net: stmmac: Fixed mtu channged by cache aligned 2021-01-23 15:57:59 +01:00
sun
synopsys
tehuti
ti net: ethernet: ti: cpts: fix ethtool output when no ptp_clock registered 2021-01-12 20:16:14 +01:00
toshiba
tundra
via
wiznet
xilinx net: ll_temac: Fix potential NULL dereference in temac_probe() 2020-12-21 13:27:05 +01:00
xircom
xscale
Kconfig
Makefile
dnet.c
dnet.h
ec_bhf.c
ethoc.c net: ethernet: Fix memleak in ethoc_probe 2021-01-12 20:16:13 +01:00
fealnx.c
jme.c
jme.h
korina.c net: korina: fix return value 2020-12-30 11:51:27 +01:00
lantiq_etop.c
lantiq_xrx200.c net: lantiq: Add locking for TX DMA channel 2020-11-22 10:14:12 +01:00