Re: [PATCH v3] rfkill: Add rfkill-any LED trigger

From: Johannes Berg
Date: Mon Jan 02 2017 - 06:12:22 EST



> Â - Handle the global mutex properly when rfkill_set_{hw,sw}_state()
> or
> ÂÂÂÂrfkill_set_states() is called from within an rfkill callback.ÂÂv2
> ÂÂÂÂalways tried to lock the global mutex in such a case, which led
> to a
> ÂÂÂÂdeadlock when an rfkill driver called one of the above functions
> ÂÂÂÂfrom its query or set_block callback.ÂÂThis is solved by defining
> a
> ÂÂÂÂnew bitfield, RFKILL_BLOCK_SW_HASLOCK, which is set before the
> above
> ÂÂÂÂcallbacks are invoked and cleared afterwards; the functions
> listed
> ÂÂÂÂabove use this bitfield to tell rfkill_any_led_trigger_event()
> ÂÂÂÂwhether the global mutex is currently held or not.
> ÂÂÂÂRFKILL_BLOCK_SW_SETCALL cannot be reused for this purpose as
> setting
> ÂÂÂÂit before invoking the query callback would cause any calls to
> ÂÂÂÂrfkill_set_sw_state() made from within that callback to work on
> ÂÂÂÂRFKILL_BLOCK_SW_PREV instead of RFKILL_BLOCK_SW and thus change
> the
> ÂÂÂÂway rfkill_set_block() behaves.

I'm not super happy with this conditional locking - can't we instead
defer the necessary work to a workqueue, or so, for purposes of the
LED?

johannes