From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: [BUG] atomic mode violation probably caused by pm code Date: Sun, 24 Oct 2010 16:06:34 +0200 Message-ID: <201010241606.34176.rjw@sisk.pl> References: <1287866524.3322.7.camel@maxim-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1287866524.3322.7.camel@maxim-laptop> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org To: Maxim Levitsky Cc: linux-pm@lists.linux-foundation.org List-Id: linux-pm@vger.kernel.org On Saturday, October 23, 2010, Maxim Levitsky wrote: > Hi, Hi, > On today's mainline I get this: > > [ 41.755886] BUG: sleeping function called from invalid context at /home/maxim/software/kernel/linux-2.6/mm/slub.c:1701 > [ 41.755907] in_atomic(): 1, irqs_disabled(): 0, pid: 2629, name: ethtool > [ 41.755920] 2 locks held by ethtool/2629: > [ 41.755928] #0: (rtnl_mutex){......}, at: [] rtnl_lock+0x12/0x20 > [ 41.755952] #1: (&(&tp->lock)->rlock){......}, at: [] tg3_set_wol+0x51/0xe0 [tg3] > [ 41.755982] Pid: 2629, comm: ethtool Not tainted 2.6.36+ #191 > [ 41.755993] Call Trace: > [ 41.756004] [] __might_sleep+0xfe/0x120 > [ 41.756018] [] kmem_cache_alloc+0xd3/0xf0 > [ 41.756033] [] wakeup_source_create+0x25/0x70 > [ 41.756046] [] wakeup_source_register+0xe/0x30 > [ 41.756059] [] device_wakeup_enable+0x47/0xa0 > [ 41.756072] [] device_set_wakeup_enable+0x23/0x40 > [ 41.756088] [] tg3_set_wol+0xa8/0xe0 [tg3] > [ 41.756101] [] dev_ethtool+0x1619/0x1880 > [ 41.756113] [] ? rtnl_lock+0x12/0x20 > [ 41.756126] [] dev_ioctl+0x556/0x8d0 > [ 41.756138] [] ? get_parent_ip+0x11/0x50 > [ 41.756150] [] ? get_parent_ip+0x11/0x50 > [ 41.756163] [] ? sub_preempt_count+0x9d/0xd0 > [ 41.756176] [] ? put_lock_stats+0xe/0x40 > [ 41.756188] [] ? lock_release_holdtime+0xac/0x150 > [ 41.756204] [] sock_do_ioctl+0x55/0x60 > [ 41.756216] [] sock_ioctl+0x82/0x2b0 > [ 41.756229] [] do_vfs_ioctl+0xa1/0x640 > [ 41.756242] [] ? _raw_spin_unlock+0x30/0x60 > [ 41.756255] [] ? fd_install+0x62/0x80 > [ 41.756267] [] sys_ioctl+0x4a/0x80 > [ 41.756278] [] ? lock_release_holdtime+0xac/0x150 > [ 41.756293] [] system_call_fastpath+0x16/0x1b > [ 41.756333] BUG: scheduling while atomic: ethtool/2629/0x00000202 > [ 41.756345] 2 locks held by ethtool/2629: > [ 41.756353] #0: (rtnl_mutex){......}, at: [] rtnl_lock+0x12/0x20 > [ 41.756371] #1: (&(&tp->lock)->rlock){......}, at: [] tg3_set_wol+0x51/0xe0 [tg3] > [ 41.756394] Modules linked in: af_packet nfsd exportfs nfs lockd nfs_acl auth_rpcgss dm_crypt iwl3945 uvcvideo videodev iwlcore v4l2_compat_ioctl32 mac80211 sunrpc firewire_net usb_storage uhci_hcd snd_hda_codec_realtek usb_libusual cpufreq_powersave cpufreq_conservative r852 ir_lirc_codec lirc_dev cpufreq_userspace ir_sony_decoder joydev acpi_cpufreq sm_common ehci_hcd snd_hda_intel tg3 ir_jvc_decoder mperf nand iTCO_wdt coretemp ir_rc6_decoder ac snd_hda_codec sbp2 usbcore cfg80211 sdhci_pci snd_hwdep battery firewire_ohci ir_rc5_decoder ieee1394 psmouse ene_ir snd_pcm sdhci ir_nec_decoder serio_raw mmc_core libphy nand_ids r592 memstick nand_ecc firewire_core mtd ir_core snd_page_alloc evdev sg dm_mirror dm_region_hash dm_log dm_mod nouveau ttm drm_kms_helper drm i2c_algo_bit therm al video > [ 41.756592] Pid: 2629, comm: ethtool Not tainted 2.6.36+ #191 > [ 41.756602] Call Trace: > [ 41.756611] [] __schedule_bug+0x63/0x70 > [ 41.756623] [] schedule+0x941/0xaf0 > [ 41.756637] [] ? native_sched_clock+0x29/0x80 > [ 41.756650] [] schedule_timeout+0x245/0x2c0 > [ 41.756663] [] ? sched_clock_cpu+0xc0/0x110 > [ 41.756676] [] ? put_lock_stats+0xe/0x40 > [ 41.756688] [] ? lock_release_holdtime+0xac/0x150 > [ 41.756702] [] wait_for_common+0xd7/0x170 > [ 41.756715] [] ? default_wake_function+0x0/0x10 > [ 41.756730] [] wait_for_completion+0x18/0x20 > [ 41.756744] [] synchronize_rcu+0x5b/0x80 > [ 41.756756] [] ? wakeme_after_rcu+0x0/0x10 > [ 41.756770] [] ? wait_for_common+0x44/0x170 > [ 41.756783] [] wakeup_source_add+0x80/0xa0 > [ 41.756795] [] wakeup_source_register+0x1e/0x30 > [ 41.756809] [] device_wakeup_enable+0x47/0xa0 > [ 41.756822] [] device_set_wakeup_enable+0x23/0x40 > [ 41.756837] [] tg3_set_wol+0xa8/0xe0 [tg3] > [ 41.756851] [] dev_ethtool+0x1619/0x1880 > [ 41.756863] [] ? rtnl_lock+0x12/0x20 > [ 41.756875] [] dev_ioctl+0x556/0x8d0 > [ 41.756887] [] ? get_parent_ip+0x11/0x50 > [ 41.756899] [] ? get_parent_ip+0x11/0x50 > [ 41.756912] [] ? sub_preempt_count+0x9d/0xd0 > [ 41.756925] [] ? put_lock_stats+0xe/0x40 > [ 41.756937] [] ? lock_release_holdtime+0xac/0x150 > [ 41.756951] [] sock_do_ioctl+0x55/0x60 > [ 41.756964] [] sock_ioctl+0x82/0x2b0 > [ 41.756975] [] do_vfs_ioctl+0xa1/0x640 > [ 41.756988] [] ? _raw_spin_unlock+0x30/0x60 > [ 41.757000] [] ? fd_install+0x62/0x80 > [ 41.757012] [] sys_ioctl+0x4a/0x80 > [ 41.757024] [] ? lock_release_holdtime+0xac/0x150 > [ 41.757038] [] system_call_fastpath+0x16/0x1b > [ 41.770189] BUG: scheduling while atomic: ethtool/2629/0x00000202 > [ 41.770194] 2 locks held by ethtool/2629: > [ 41.770197] #0: (rtnl_mutex){......}, at: [] rtnl_lock+0x12/0x20 > [ 41.770206] #1: (&(&tp->lock)->rlock){......}, at: [] tg3_set_wol+0x51/0xe0 [tg3] > [ 41.770218] Modules linked in: af_packet nfsd exportfs nfs lockd nfs_acl auth_rpcgss dm_crypt iwl3945 uvcvideo videodev iwlcore v4l2_compat_ioctl32 mac80211 sunrpc firewire_net usb_storage uhci_hcd snd_hda_codec_realtek usb_libusual cpufreq_powersave cpufreq_conservative r852 ir_lirc_codec lirc_dev cpufreq_userspace ir_sony_decoder joydev acpi_cpufreq sm_common ehci_hcd snd_hda_intel tg3 ir_jvc_decoder mperf nand iTCO_wdt coretemp ir_rc6_decoder ac snd_hda_codec sbp2 usbcore cfg80211 sdhci_pci snd_hwdep battery firewire_ohci ir_rc5_decoder ieee1394 psmouse ene_ir snd_pcm sdhci ir_nec_decoder serio_raw mmc_core libphy nand_ids r592 memstick nand_ecc firewire_core mtd ir_core snd_page_alloc evdev sg dm_mirror dm_region_hash dm_log dm_mod nouveau ttm drm_kms_helper drm i2c_algo_bit therm al video > [ 41.770294] Pid: 2629, comm: ethtool Not tainted 2.6.36+ #191 > [ 41.770298] Call Trace: > [ 41.770303] [] __schedule_bug+0x63/0x70 > [ 41.770309] [] schedule+0x941/0xaf0 > [ 41.770316] [] ? native_sched_clock+0x29/0x80 > [ 41.770322] [] schedule_timeout+0x245/0x2c0 > [ 41.770327] [] ? sched_clock_cpu+0xc0/0x110 > [ 41.770333] [] ? put_lock_stats+0xe/0x40 > [ 41.770338] [] ? lock_release_holdtime+0xac/0x150 > [ 41.770345] [] wait_for_common+0xd7/0x170 > [ 41.770351] [] ? default_wake_function+0x0/0x10 > [ 41.770357] [] wait_for_completion+0x18/0x20 > [ 41.770363] [] synchronize_rcu+0x5b/0x80 > [ 41.770369] [] ? wakeme_after_rcu+0x0/0x10 > [ 41.770374] [] ? wait_for_common+0x44/0x170 > [ 41.770381] [] wakeup_source_remove+0x4b/0x70 > [ 41.770386] [] wakeup_source_unregister+0x11/0x20 > [ 41.770392] [] device_wakeup_enable+0x7d/0xa0 > [ 41.770398] [] device_set_wakeup_enable+0x23/0x40 > [ 41.770406] [] tg3_set_wol+0xa8/0xe0 [tg3] > [ 41.770412] [] dev_ethtool+0x1619/0x1880 > [ 41.770418] [] ? rtnl_lock+0x12/0x20 > [ 41.770423] [] dev_ioctl+0x556/0x8d0 > [ 41.770429] [] ? get_parent_ip+0x11/0x50 > [ 41.770434] [] ? get_parent_ip+0x11/0x50 > [ 41.770440] [] ? sub_preempt_count+0x9d/0xd0 > [ 41.770446] [] ? put_lock_stats+0xe/0x40 > [ 41.770451] [] ? lock_release_holdtime+0xac/0x150 > [ 41.770458] [] sock_do_ioctl+0x55/0x60 > [ 41.770464] [] sock_ioctl+0x82/0x2b0 > [ 41.770469] [] do_vfs_ioctl+0xa1/0x640 > [ 41.770475] [] ? _raw_spin_unlock+0x30/0x60 > [ 41.770482] [] ? fd_install+0x62/0x80 > [ 41.770487] [] sys_ioctl+0x4a/0x80 > [ 41.770492] [] ? lock_release_holdtime+0xac/0x150 > [ 41.770499] [] system_call_fastpath+0x16/0x1b > [ 42.688343] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro,commit=0 > [ 44.524491] EXT4-fs (sda3): re-mounted. Opts: errors=remount-ro,commit=0 > [ 51.277608] fuse init (API version 7.15) > [ 55.215763] BUG: sleeping function called from invalid context at /home/maxim/software/kernel/linux-2.6/mm/slub.c:1701 > [ 55.215787] in_atomic(): 1, irqs_disabled(): 0, pid: 2852, name: ethtool > [ 55.215801] 2 locks held by ethtool/2852: > [ 55.215810] #0: (rtnl_mutex){......}, at: [] rtnl_lock+0x12/0x20 > [ 55.215837] #1: (&(&tp->lock)->rlock){......}, at: [] tg3_set_wol+0x51/0xe0 [tg3] > [ 55.215875] Pid: 2852, comm: ethtool Not tainted 2.6.36+ #191 > [ 55.215887] Call Trace: > [ 55.215901] [] __might_sleep+0xfe/0x120 > [ 55.215916] [] kmem_cache_alloc+0xd3/0xf0 > [ 55.215932] [] wakeup_source_create+0x25/0x70 > [ 55.215946] [] wakeup_source_register+0xe/0x30 > [ 55.215960] [] device_wakeup_enable+0x47/0xa0 > [ 55.215974] [] device_set_wakeup_enable+0x23/0x40 > [ 55.215991] [] tg3_set_wol+0xa8/0xe0 [tg3] > [ 55.216006] [] dev_ethtool+0x1619/0x1880 > [ 55.216019] [] ? rtnl_lock+0x12/0x20 > [ 55.216032] [] dev_ioctl+0x556/0x8d0 > [ 55.216045] [] ? get_parent_ip+0x11/0x50 > [ 55.216058] [] ? get_parent_ip+0x11/0x50 > [ 55.216072] [] ? sub_preempt_count+0x9d/0xd0 > [ 55.216087] [] ? put_lock_stats+0xe/0x40 > [ 55.216100] [] ? lock_release_holdtime+0xac/0x150 > [ 55.216117] [] sock_do_ioctl+0x55/0x60 > [ 55.216130] [] sock_ioctl+0x82/0x2b0 > [ 55.216143] [] do_vfs_ioctl+0xa1/0x640 > [ 55.216158] [] ? _raw_spin_unlock+0x30/0x60 > [ 55.216172] [] ? fd_install+0x62/0x80 > [ 55.216185] [] sys_ioctl+0x4a/0x80 > [ 55.216197] [] ? lock_release_holdtime+0xac/0x150 > [ 55.216213] [] system_call_fastpath+0x16/0x1b > [ 55.216254] BUG: scheduling while atomic: ethtool/2852/0x00000202 > [ 55.216277] 2 locks held by ethtool/2852: > [ 55.216285] #0: (rtnl_mutex){......}, at: [] rtnl_lock+0x12/0x20 > [ 55.216305] #1: (&(&tp->lock)->rlock){......}, at: [] tg3_set_wol+0x51/0xe0 [tg3] > [ 55.216330] Modules linked in: fuse af_packet nfsd exportfs nfs lockd nfs_acl auth_rpcgss dm_crypt iwl3945 uvcvideo videodev iwlcore v4l2_compat_ioctl32 mac80211 sunrpc firewire_net usb_storage uhci_hcd snd_hda_codec_realtek usb_libusual cpufreq_powersave cpufreq_conservative r852 ir_lirc_codec lirc_dev cpufreq_userspace ir_sony_decoder joydev acpi_cpufreq sm_common ehci_hcd snd_hda_intel tg3 ir_jvc_decoder mperf nand iTCO_wdt coretemp ir_rc6_decoder ac snd_hda_codec sbp2 usbcore cfg80211 sdhci_pci snd_hwdep battery firewire_ohci ir_rc5_decoder ieee1394 psmouse ene_ir snd_pcm sdhci ir_nec_decoder serio_raw mmc_core libphy nand_ids r592 memstick nand_ecc firewire_core mtd ir_core snd_page_alloc evdev sg dm_mirror dm_region_hash dm_log dm_mod nouveau ttm drm_kms_helper drm i2c_algo_bit thermal video > [ 55.216543] Pid: 2852, comm: ethtool Not tainted 2.6.36+ #191 > [ 55.216554] Call Trace: > [ 55.216563] [] __schedule_bug+0x63/0x70 > [ 55.216576] [] schedule+0x941/0xaf0 > [ 55.216591] [] ? native_sched_clock+0x29/0x80 > [ 55.216605] [] schedule_timeout+0x245/0x2c0 > [ 55.216619] [] ? sched_clock_cpu+0xc0/0x110 > [ 55.216633] [] ? put_lock_stats+0xe/0x40 > [ 55.216646] [] ? lock_release_holdtime+0xac/0x150 > [ 55.216661] [] wait_for_common+0xd7/0x170 > [ 55.216675] [] ? default_wake_function+0x0/0x10 > [ 55.216690] [] wait_for_completion+0x18/0x20 > [ 55.216705] [] synchronize_rcu+0x5b/0x80 > [ 55.216719] [] ? wakeme_after_rcu+0x0/0x10 > [ 55.216732] [] ? wait_for_common+0x44/0x170 > [ 55.216746] [] wakeup_source_add+0x80/0xa0 > [ 55.216760] [] wakeup_source_register+0x1e/0x30 > [ 55.216774] [] device_wakeup_enable+0x47/0xa0 > [ 55.216788] [] device_set_wakeup_enable+0x23/0x40 > [ 55.216804] [] tg3_set_wol+0xa8/0xe0 [tg3] > [ 55.216818] [] dev_ethtool+0x1619/0x1880 > [ 55.216831] [] ? rtnl_lock+0x12/0x20 > [ 55.216845] [] dev_ioctl+0x556/0x8d0 > [ 55.216857] [] ? get_parent_ip+0x11/0x50 > [ 55.216870] [] ? get_parent_ip+0x11/0x50 > [ 55.216884] [] ? sub_preempt_count+0x9d/0xd0 > [ 55.216897] [] ? put_lock_stats+0xe/0x40 > [ 55.216910] [] ? lock_release_holdtime+0xac/0x150 > [ 55.216926] [] sock_do_ioctl+0x55/0x60 > [ 55.216939] [] sock_ioctl+0x82/0x2b0 > [ 55.216951] [] do_vfs_ioctl+0xa1/0x640 > [ 55.216964] [] ? _raw_spin_unlock+0x30/0x60 > [ 55.216978] [] ? fd_install+0x62/0x80 > [ 55.216991] [] sys_ioctl+0x4a/0x80 > [ 55.217003] [] ? lock_release_holdtime+0xac/0x150 > [ 55.217018] [] system_call_fastpath+0x16/0x1b > [ 55.217038] NOHZ: local_softirq_pending 10 > [ 55.250502] BUG: scheduling while atomic: ethtool/2852/0x00000202 > [ 55.250518] 2 locks held by ethtool/2852: > [ 55.250528] #0: (rtnl_mutex){......}, at: [] rtnl_lock+0x12/0x20 > [ 55.250556] #1: (&(&tp->lock)->rlock){......}, at: [] tg3_set_wol+0x51/0xe0 [tg3] > [ 55.250592] Modules linked in: fuse af_packet nfsd exportfs nfs lockd nfs_acl auth_rpcgss dm_crypt iwl3945 uvcvideo videodev iwlcore v4l2_compat_ioctl32 mac80211 sunrpc firewire_net usb_storage uhci_hcd snd_hda_codec_realtek usb_libusual cpufreq_powersave cpufreq_conservative r852 ir_lirc_codec lirc_dev cpufreq_userspace ir_sony_decoder joydev acpi_cpufreq sm_common ehci_hcd snd_hda_intel tg3 ir_jvc_decoder mperf nand iTCO_wdt coretemp ir_rc6_decoder ac snd_hda_codec sbp2 usbcore cfg80211 sdhci_pci snd_hwdep battery firewire_ohci ir_rc5_decoder ieee1394 psmouse ene_ir snd_pcm sdhci ir_nec_decoder serio_raw mmc_core libphy nand_ids r592 memstick nand_ecc firewire_core mtd ir_core snd_page_alloc evdev sg dm_mirror dm_region_hash dm_log dm_mod nouveau ttm drm_kms_helper drm i2c_algo_bit thermal video > [ 55.250835] Pid: 2852, comm: ethtool Not tainted 2.6.36+ #191 > [ 55.250849] Call Trace: > [ 55.250861] [] __schedule_bug+0x63/0x70 > [ 55.250877] [] schedule+0x941/0xaf0 > [ 55.250894] [] ? native_sched_clock+0x29/0x80 > [ 55.250910] [] schedule_timeout+0x245/0x2c0 > [ 55.250926] [] ? sched_clock_cpu+0xc0/0x110 > [ 55.250943] [] ? put_lock_stats+0xe/0x40 > [ 55.250957] [] ? lock_release_holdtime+0xac/0x150 > [ 55.250974] [] wait_for_common+0xd7/0x170 > [ 55.250989] [] ? default_wake_function+0x0/0x10 > [ 55.251007] [] wait_for_completion+0x18/0x20 > [ 55.251023] [] synchronize_rcu+0x5b/0x80 > [ 55.251039] [] ? wakeme_after_rcu+0x0/0x10 > [ 55.251054] [] ? wait_for_common+0x44/0x170 > [ 55.251072] [] wakeup_source_remove+0x4b/0x70 > [ 55.251087] [] wakeup_source_unregister+0x11/0x20 > [ 55.251104] [] device_wakeup_enable+0x7d/0xa0 > [ 55.251120] [] device_set_wakeup_enable+0x23/0x40 > [ 55.251139] [] tg3_set_wol+0xa8/0xe0 [tg3] > [ 55.251155] [] dev_ethtool+0x1619/0x1880 > [ 55.251170] [] ? rtnl_lock+0x12/0x20 > [ 55.251185] [] dev_ioctl+0x556/0x8d0 > [ 55.251199] [] ? get_parent_ip+0x11/0x50 > [ 55.251214] [] ? get_parent_ip+0x11/0x50 > [ 55.251229] [] ? sub_preempt_count+0x9d/0xd0 > [ 55.251245] [] ? put_lock_stats+0xe/0x40 > [ 55.251259] [] ? lock_release_holdtime+0xac/0x150 > [ 55.251278] [] sock_do_ioctl+0x55/0x60 > [ 55.251293] [] sock_ioctl+0x82/0x2b0 > [ 55.251308] [] do_vfs_ioctl+0xa1/0x640 > [ 55.251323] [] ? _raw_spin_unlock+0x30/0x60 > [ 55.251340] [] ? fd_install+0x62/0x80 > [ 55.251354] [] sys_ioctl+0x4a/0x80 > [ 55.251368] [] ? lock_release_holdtime+0xac/0x150 > [ 55.251386] [] system_call_fastpath+0x16/0x1b > [ 55.290319] BUG: spinlock wrong CPU on CPU#1, ethtool/2852 > [ 55.302939] lock: ffff88007975aa48, .magic: dead4ead, .owner: ethtool/2852, .owner_cpu: 0 > [ 55.309875] Pid: 2852, comm: ethtool Not tainted 2.6.36+ #191 > [ 55.315910] Call Trace: > [ 55.322675] [] spin_bug+0xa2/0xf0 > [ 55.322681] [] do_raw_spin_unlock+0x71/0xa0 > [ 55.322688] [] _raw_spin_unlock_bh+0x26/0x40 > [ 55.322704] [] tg3_set_wol+0x75/0xe0 [tg3] > [ 55.322711] [] dev_ethtool+0x1619/0x1880 > [ 55.322717] [] ? rtnl_lock+0x12/0x20 > [ 55.322723] [] dev_ioctl+0x556/0x8d0 > [ 55.322729] [] ? get_parent_ip+0x11/0x50 > [ 55.322735] [] ? get_parent_ip+0x11/0x50 > [ 55.322741] [] ? sub_preempt_count+0x9d/0xd0 > [ 55.322748] [] ? put_lock_stats+0xe/0x40 > [ 55.322753] [] ? lock_release_holdtime+0xac/0x150 > [ 55.322763] [] sock_do_ioctl+0x55/0x60 > [ 55.322769] [] sock_ioctl+0x82/0x2b0 > [ 55.322775] [] do_vfs_ioctl+0xa1/0x640 > [ 55.322782] [] ? _raw_spin_unlock+0x30/0x60 > [ 55.322790] [] ? fd_install+0x62/0x80 > [ 55.322796] [] sys_ioctl+0x4a/0x80 > [ 55.322802] [] ? lock_release_holdtime+0xac/0x150 > [ 55.322809] [] system_call_fastpath+0x16/0x1b Incidentally, I have a patch for this issue, which is appended. Please test and let me know if it helps (and WoL still works for you). Thanks, Rafael --- From: Rafael J. Wysocki Subject: tg3: Do not call device_set_wakeup_enable() under a spinlock The tg3 driver calls device_set_wakeup_enable() under a spinlock, which causes a problem to happen after the recent core power management changes, because this function can sleep now. Fix this by moving the device_set_wakeup_enable() call out of the spinlock-protected area. Signed-off-by: Rafael J. Wysocki --- drivers/net/tg3.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) Index: linux-2.6/drivers/net/tg3.c =================================================================== --- linux-2.6.orig/drivers/net/tg3.c +++ linux-2.6/drivers/net/tg3.c @@ -9732,16 +9732,16 @@ static int tg3_set_wol(struct net_device !((tp->tg3_flags & TG3_FLAG_WOL_CAP) && device_can_wakeup(dp))) return -EINVAL; + device_set_wakeup_enable(dp, wol->wolopts & WAKE_MAGIC); + spin_lock_bh(&tp->lock); - if (wol->wolopts & WAKE_MAGIC) { + if (device_may_wakeup(dp)) tp->tg3_flags |= TG3_FLAG_WOL_ENABLE; - device_set_wakeup_enable(dp, true); - } else { + else tp->tg3_flags &= ~TG3_FLAG_WOL_ENABLE; - device_set_wakeup_enable(dp, false); - } spin_unlock_bh(&tp->lock); + return 0; }