From patchwork Thu Sep 10 15:53:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fujinaka, Todd" X-Patchwork-Id: 516326 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8240D140180 for ; Fri, 11 Sep 2015 01:53:52 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752132AbbIJPxs (ORCPT ); Thu, 10 Sep 2015 11:53:48 -0400 Received: from mga02.intel.com ([134.134.136.20]:46050 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751323AbbIJPxp convert rfc822-to-8bit (ORCPT ); Thu, 10 Sep 2015 11:53:45 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 10 Sep 2015 08:53:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,505,1437462000"; d="scan'208";a="802384482" Received: from orsmsx109.amr.corp.intel.com ([10.22.240.7]) by fmsmga002.fm.intel.com with ESMTP; 10 Sep 2015 08:53:44 -0700 Received: from orsmsx152.amr.corp.intel.com (10.22.226.39) by ORSMSX109.amr.corp.intel.com (10.22.240.7) with Microsoft SMTP Server (TLS) id 14.3.224.2; Thu, 10 Sep 2015 08:53:44 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.101]) by ORSMSX152.amr.corp.intel.com ([169.254.8.94]) with mapi id 14.03.0224.002; Thu, 10 Sep 2015 08:53:43 -0700 From: "Fujinaka, Todd" To: Jarod Wilson , "linux-kernel@vger.kernel.org" CC: "netdev@vger.kernel.org" , "intel-wired-lan@lists.osuosl.org" Subject: RE: [Intel-wired-lan] [PATCH] igb: don't unmap hw_addr if its NULL Thread-Topic: [Intel-wired-lan] [PATCH] igb: don't unmap hw_addr if its NULL Thread-Index: AQHQ65nvgAlgBa3ZDkm21L05zthirp416KQg Date: Thu, 10 Sep 2015 15:53:42 +0000 Message-ID: <9B4A1B1917080E46B64F07F2989DADD6535EA162@ORSMSX114.amr.corp.intel.com> References: <1441858049-44827-1-git-send-email-jarod@redhat.com> In-Reply-To: <1441858049-44827-1-git-send-email-jarod@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Thanks! I tried testing this sort of thing last spring, but there just wasn't a lot of hardware available to me and things weren't breaking with my setup (not sure why). ACK. Todd Fujinaka Software Application Engineer Networking Division (ND) Intel Corporation todd.fujinaka@intel.com (503) 712-4565 -----Original Message----- From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.org] On Behalf Of Jarod Wilson Sent: Wednesday, September 09, 2015 9:07 PM To: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org; Jarod Wilson Subject: [Intel-wired-lan] [PATCH] igb: don't unmap hw_addr if its NULL I've got a startech thunderbolt dock someone loaned me, which among other things, has the following device in it: 08:00.0 Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03) This hotplugs just fine (kernel 4.2.0 plus a patch or two here): [ 863.020315] igb: Intel(R) Gigabit Ethernet Network Driver - version 5.2.18-k [ 863.020316] igb: Copyright (c) 2007-2014 Intel Corporation. [ 863.028657] igb 0000:08:00.0: enabling device (0000 -> 0002) [ 863.062089] igb 0000:08:00.0: added PHC on eth0 [ 863.062090] igb 0000:08:00.0: Intel(R) Gigabit Ethernet Network Connection [ 863.062091] igb 0000:08:00.0: eth0: (PCIe:2.5Gb/s:Width x1) e8:ea:6a:00:1b:2a [ 863.062194] igb 0000:08:00.0: eth0: PBA No: 000200-000 [ 863.062196] igb 0000:08:00.0: Using MSI-X interrupts. 4 rx queue(s), 4 tx queue(s) [ 863.064889] igb 0000:08:00.0 enp8s0: renamed from eth0 But disconnecting it is another story: [ 1002.807932] igb 0000:08:00.0: removed PHC on enp8s0 [ 1002.807944] igb 0000:08:00.0 enp8s0: PCIe link lost, device now detached [ 1003.341141] ------------[ cut here ]------------ [ 1003.341148] WARNING: CPU: 0 PID: 199 at lib/iomap.c:43 bad_io_access+0x38/0x40() [ 1003.341149] Bad IO access at port 0x0 () [ 1003.342767] Modules linked in: snd_usb_audio snd_usbmidi_lib snd_rawmidi igb dca firewire_ohci firewire_core crc_itu_t rfcomm ctr ccm arc4 iwlmvm mac80211 fuse xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 xt_conntrack ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw iptable_filter bnep dm_mirror dm_region_hash dm_log dm_mod coretemp x86_pkg_temp_thermal intel_powerclamp kvm_intel snd_hda_codec_hdmi kvm crct10dif_pclmul crc32_pclmul ghash_clmulni_intel drbg [ 1003.342793] ansi_cprng aesni_intel hp_wmi aes_x86_64 iTCO_wdt lrw iTCO_vendor_support ppdev gf128mul sparse_keymap glue_helper ablk_helper cryptd snd_hda_codec_realtek snd_hda_codec_generic microcode snd_hda_intel uvcvideo iwlwifi snd_hda_codec videobuf2_vmalloc videobuf2_memops snd_hda_core videobuf2_core snd_hwdep btusb v4l2_common btrtl snd_seq btbcm btintel videodev cfg80211 snd_seq_device rtsx_pci_ms bluetooth pcspkr input_leds i2c_i801 media parport_pc memstick rfkill sg lpc_ich snd_pcm 8250_fintek parport joydev snd_timer snd soundcore hp_accel ie31200_edac mei_me lis3lv02d edac_core input_polldev mei hp_wireless shpchp tpm_infineon sch_fq_codel nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables autofs4 xfs libcrc32c sd_mod sr_mod cdrom rtsx_pci_sdmmc mmc_core crc32c_intel serio_raw rtsx_pci [ 1003.342822] nouveau ahci libahci mxm_wmi e1000e xhci_pci hwmon ptp drm_kms_helper pps_core xhci_hcd ttm wmi video ipv6 [ 1003.342839] CPU: 0 PID: 199 Comm: kworker/0:2 Not tainted 4.2.0-2.el7_UNSUPPORTED.x86_64 #1 [ 1003.342840] Hardware name: Hewlett-Packard HP ZBook 15 G2/2253, BIOS M70 Ver. 01.07 02/26/2015 [ 1003.342843] Workqueue: pciehp-3 pciehp_power_thread [ 1003.342844] ffffffff81a90655 ffff8804866d3b48 ffffffff8164763a 0000000000000000 [ 1003.342846] ffff8804866d3b98 ffff8804866d3b88 ffffffff8107134a ffff8804866d3b88 [ 1003.342847] ffff880486f46000 ffff88046c8a8000 ffff880486f46840 ffff88046c8a8098 [ 1003.342848] Call Trace: [ 1003.342852] [] dump_stack+0x45/0x57 [ 1003.342855] [] warn_slowpath_common+0x8a/0xc0 [ 1003.342857] [] warn_slowpath_fmt+0x46/0x50 [ 1003.342859] [] ? pci_disable_msix+0x3e/0x50 [ 1003.342860] [] bad_io_access+0x38/0x40 [ 1003.342861] [] pci_iounmap+0x27/0x40 [ 1003.342865] [] igb_remove+0xc7/0x160 [igb] [ 1003.342867] [] pci_device_remove+0x3f/0xc0 [ 1003.342869] [] __device_release_driver+0x96/0x130 [ 1003.342870] [] device_release_driver+0x23/0x30 [ 1003.342871] [] pci_stop_bus_device+0x94/0xa0 [ 1003.342872] [] pci_stop_bus_device+0x3d/0xa0 [ 1003.342873] [] pci_stop_bus_device+0x3d/0xa0 [ 1003.342874] [] pci_stop_and_remove_bus_device+0x16/0x30 [ 1003.342876] [] pciehp_unconfigure_device+0x9b/0x180 [ 1003.342877] [] pciehp_disable_slot+0x43/0xb0 [ 1003.342878] [] pciehp_power_thread+0x8d/0xb0 [ 1003.342885] [] process_one_work+0x152/0x3d0 [ 1003.342886] [] worker_thread+0x11a/0x460 [ 1003.342887] [] ? process_one_work+0x3d0/0x3d0 [ 1003.342890] [] kthread+0xc9/0xe0 [ 1003.342891] [] ? kthread_create_on_node+0x180/0x180 [ 1003.342893] [] ret_from_fork+0x3f/0x70 [ 1003.342894] [] ? kthread_create_on_node+0x180/0x180 [ 1003.342895] ---[ end trace 65a77e06d5aa9358 ]--- Upon looking at the igb driver, I see that igb_rd32() attempted to read from hw_addr and failed, so it set hw->hw_addr to NULL and spit out the message in the log output above, "PCIe link lost, device now detached". Well, now that hw_addr is NULL, the attempt to call pci_iounmap in igb_remove() is obviously not going to go well. Simple solution here is to simply make sure hw_addr is not NULL before we try to call pci_iounmap on it, and now I can hot-unplug this thunderbolt dock without a problem. CC: Jeff Kirsher CC: intel-wired-lan@lists.osuosl.org CC: netdev@vger.kernel.org Signed-off-by: Jarod Wilson --- drivers/net/ethernet/intel/igb/igb_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.8.3.1 diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index e174fbb..a5e0022 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -2823,7 +2823,8 @@ static void igb_remove(struct pci_dev *pdev) igb_clear_interrupt_scheme(adapter); - pci_iounmap(pdev, hw->hw_addr); + if (hw->hw_addr) + pci_iounmap(pdev, hw->hw_addr); if (hw->flash_address) iounmap(hw->flash_address); pci_release_selected_regions(pdev,