public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Rfkill rewrite
@ 2009-07-18 15:46 Alan Jenkins
  2009-07-18 17:40 ` Johannes Berg
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Jenkins @ 2009-07-18 15:46 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless@vger.kernel.org

On 4/18/09, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Sat, 2009-04-18 at 14:29 +0100, Alan Jenkins wrote:
>
>> API nit:
>> 
>>  * This function tells the rfkill core that the device is capable of
>>  * remembering soft blocks (which it is notified of via the set_block
>>  * method) -- this means that the driver may ignore the return value
>>  * from rfkill_set_hw_state().
>> 
>> Doesn't this conflict with the declaration of rfkill_set_hw_state() as
>> __must_check?
>
> Yeah, in a way it does, but I figure it's rare enough that those who
> really can ignore it can write
> 	(void) rfkill_set_hw_state(...)
>
> Don't really have a strong opinion, it just seemed the mistake in the
> other direction would be more common.

It seems my GCC has a stronger definition of "must" than you do :-).  I can't get rid of the warning by casting it to void.  So I'm not sure __must_check is really appropriate here.

drivers/platform/x86/hp-wmi.c: In function ‘hp_wmi_bios_setup’:
drivers/platform/x86/hp-wmi.c:467: warning: ignoring return value of ‘rfkill_set_hw_state’, declared with attribute warn_unused_result

$ grep -n rfkill_set_hw_state drivers/platform/x86/hp-wmi.c
467:            (void) rfkill_set_hw_state(wifi_rfkill,

$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)


Thanks
Alan

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: rfkill rewrite
@ 2009-05-01  9:42 Alan Jenkins
  2009-05-05  8:15 ` Johannes Berg
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Jenkins @ 2009-05-01  9:42 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless@vger.kernel.org

On 4/18/09, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Sat, 2009-04-18 at 10:43 +0100, Alan Jenkins wrote:
>
>> >> When I looked at the code earlier, I saw no obvious replacement for
>> >> rfkill_set_default().  So I tried disabling the wireless and rebooting
>> >> to see what happened.  It didn't like that :-).
>> >>
>> >
>> > Ok that wasn't too hard -- try this on top if you get a chance:
>> >
>>
>> Great, that fixes the crash.
>>
>>
>> 1) I think we need to add a resume method to eeepc-laptop.
>>
>> Without this, funny things happen when I hibernate, disable wireless in
>> the BIOS, and resume:
>>
>>     ath5k phy0: failed to wake up the MAC chip
>>
>> It's an really stupid thing to do, but it can happen.  It's bad from a
>> UI point of view.  E.g. in network-manager, you can see a "wlan0"
>> device, but it doesn't work.
>>
>> The EEE rfkill is unusual in that it hotplugs the PCI device, making
>> eeepc-laptop something like a custom pci hotplug driver.  With your
>> rewrite, eeepc-laptop doesn't notice the state change on resume.
>> Previously, the rfkill-core would restore the pre-hibernation state,
>> which would sort everything out.  I don't think anything else does this,
>> so we can just add a resume method to eeepc-laptop.  The resume method
>> would re-check the state and do the PCI hotplug dance if necessary.
>>
>> If you agree, I can do the patch for this and send it to you.
>
> Sounds good to me, yeah.
>
> I could make the rfkill core do that at resume, but I'm not really sure
> it's what we want -- there are too many cases imho:
>  * hard rfkill might have changed
>  * soft rfkill might still be ok in hw
>  * soft rfkill might need reconfiguring
> etc. I think generally it's saner to let the driver sort it out -- it
> can always ask for the current state by using set_hw_state() or so.

I just realized or remembered something non-obvious.  This means _all_
rfkill drivers need a resume handler.  They don't at the moment, so
this would need to be fixed and documented.  In which case, it's
probably simpler for the core to do it.

You need this to handle hibernation.  If the rfkill state persists
across hibernation (which mine does, even in S5), you can always cause
the state to change, by pressing the wireless toggle key _while the
hibernation image is being written to disk_.  At that stage, all
devices are active, so that s2disk can interact with the user and
write the image wherever it chooses.  The kernel will not "remember"
the state change on resume, since it happened after the kernel image
was snapshotted.

If the rfkill state does _not_ persist over hibernation, then clearly
the state can change on resume and you will again need a resume
handler,

On my EeePC, this is just more dramatic because it can de-power a PCI
device without notifying the driver.  But the new rfkill design will
require all devices to have a resume method, because there is no
get_state() callback.  Otherwise, reading  of
/sys/class/rfkill/rfkill*/state after resume from hibernation may
return an incorrect result.  I don't think we should allow that to
happen.

Regards
Alan

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-07-18 18:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-18 15:46 Rfkill rewrite Alan Jenkins
2009-07-18 17:40 ` Johannes Berg
2009-07-18 18:20   ` [PATCH] rfkill: remove too-strict __must_check Alan Jenkins
2009-07-18 18:22     ` Johannes Berg
  -- strict thread matches above, loose matches on Subject: below --
2009-05-01  9:42 rfkill rewrite Alan Jenkins
2009-05-05  8:15 ` Johannes Berg
2009-05-05 14:04   ` Alan Jenkins
2009-05-05 14:11     ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox