Return-path: Received: from cantor2.suse.de ([195.135.220.15]:50767 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751687Ab2DPTYE (ORCPT ); Mon, 16 Apr 2012 15:24:04 -0400 Date: Mon, 16 Apr 2012 21:24:02 +0200 Message-ID: (sfid-20120416_212408_695597_7B6C0174) From: Takashi Iwai To: Johannes Berg Cc: Matt Chen , linux-wireless , users@rt2x00.serialmonkey.com, ath9k-devel@lists.ath9k.org Subject: Re: About rfkill racing issue. In-Reply-To: <4F8C5816.8070402@sipsolutions.net> References: <4F8C5816.8070402@sipsolutions.net> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-wireless-owner@vger.kernel.org List-ID: At Mon, 16 Apr 2012 10:34:14 -0700, Johannes Berg wrote: > > On 4/11/2012 11:15 PM, Matt Chen wrote: > > Hi list, > > It is found by notebook that rfkill doesn't work very right. I don't > > know where to post this discussion, so I choose here to start the > > talk. > > Basically we found the input handler in net/rfkill/input.c , because > > the nature of stateless key events, it can only toggle the saved > > state. This screws up when started as blocked at > > boot, as already suspected. > > Now we thought Synchronizing to the > > hard block state looks as if working, but it's also dangerous because > > the operation is racy. The hard block check on ath9k driver is done > > in a poll basis, for example. Thus, the polling might happen just > > before the key event is handled, and it might happen after the key > > event. > > Another option would be to get synchronize the soft block state at the > > driver initialization time. But, this doesn't work always because we > > never know whether ther rfkill key event is generated. The rfkill key > > event depends on BIOS. Thus, if we set the soft block as same as the > > hard block at the init time (and set as blocked), the soft block will > > be never unblocked if some BIOS version doesn't emit a key event. > > > > So we would like to discuss with the all experts here for this issue. > > Do you have a good idea to fix the rfkill for the issue ? > > How is hard rfkill related to input handling? It shouldn't be. > > I don't understand what you're saying I think. The probblem we faced was that the hardware changes the hard rfkill _and_ sends the WLAN key at the same time. Since the rfkill input handler toggles the soft rfkill at each WLAN key, if the rfkill state at boot is like hard: block soft: unblock then it'll change like hard: unblock soft: block so the WLAN is never activated. In the end, we fixed the problem by disabling the keymap for WLAN key. But this is also assuming that BIOS does always rfkill. If BIOS behavior suddenly changes, you'll loose the rfkill behavior. Also, another drawback is that now rfkill isn't triggered immediately with WLAN key but it waits for some seconds until hard block is polled. Ideally, it'd be good if the rfkill hard state can be checked immediately when WLAN key is issued (but without touching soft block). thanks, Takashi