From: Hans de Goede <hdegoede@redhat.com>
To: Jacek Anaszewski <j.anaszewski@samsung.com>,
Jacek Anaszewski <jacek.anaszewski@gmail.com>,
Pavel Machek <pavel@ucw.cz>
Cc: Tony Lindgren <tony@atomide.com>,
linux-leds@vger.kernel.org, linux-omap@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Darren Hart <dvhart@infradead.org>
Subject: Re: PM regression with LED changes in next-20161109
Date: Mon, 14 Nov 2016 13:51:41 +0100 [thread overview]
Message-ID: <15cafbf5-d842-e184-2fd4-65f8272f505a@redhat.com> (raw)
In-Reply-To: <127cdd42-6fd8-c671-60b7-3826b351577f@samsung.com>
Hi,
On 14-11-16 10:12, Jacek Anaszewski wrote:
> Hi,
>
> On 11/13/2016 02:52 PM, Hans de Goede wrote:
>> Hi,
>>
>> On 13-11-16 12:44, Jacek Anaszewski wrote:
>>> Hi,
>>>
>>> On 11/12/2016 10:14 PM, Hans de Goede wrote:
>>
>> <snip>
>>
>>>>>> So I would like to propose creating a new read-write
>>>>>> user_brightness file.
>>>>>>
>>>>>> The write behavior would be 100% identical to the brightness
>>>>>> file (in code terms it will call the same store function).
>>>>>>
>>>>>> The the read behavior otoh will be different: it will shows
>>>>>> the last brightness as set by the user, this would show the
>>>>>> read behavior we really want of brightness: show the real
>>>>>> brightness when not blinking / triggers are active and show
>>>>>> the brightness used when on when blinking / triggers are active.
>>>>>>
>>>>>> We could then add poll support on this new user_brightness
>>>>>> file, thus avoiding the problem with the extra cpu-load on
>>>>>> notifications on blinking / triggers.
>>>>>
>>>>> I agree that user_brightness allows to solve the issues you raised
>>>>> about inconsistent write and read brightness' semantics
>>>>> (which is not that painful IMHO).
>>>>>
>>>>> Reporting non-user brightness changes on user_brightness file
>>>>> doesn't sound reasonable though.
>>>>
>>>> The changes I'm interested in are user brightness changes they
>>>> are just not done through sysfs, but through a hardwired hotkey,
>>>> they are however very much done by the user.
>>>
>>> Ah, so this file name would be misleading especially taking into account
>>> the context in which "user" is used in kernel, which predominantly
>>> means "userspace", e.g. copy_to_user(), copy_from_user().
>>>
>>>>> Also, how would we read the
>>>>> brightness set by the firmware? We'd have to read brightness
>>>>> file, so still two files would have to be opened which is
>>>>> a second drawback of this approach.
>>>>
>>>> No, look carefully at the definition of the read behavior
>>>> I plan to put in the ABI doc:
>>>
>>> OK, "user" was what confused me. So in this case changes made
>>> by the firmware even if in a result of user activity
>>> (pressing hardware key) obviously cannot be treated similarly
>>> to the changes made from the userspace context.
>>
>> In the end both result on the brightness of the device
>> changing, so any userspace process interested in monitoring
>> the brightness will want to know about both type of changes.
>>
>>> Unless you're able to give references to the kernel code which
>>> contradict my judgement.
>>
>> AFAIK the audio code will signal volume changes done by
>> hardwired buttons the same way as audio changes done
>> by userspace calling into the kernel. This also makes
>> sense because in the end, what is interesting for a
>> mixer app, is that the volume changed, and what the
>> new volume is.
>
> OK, so it is indeed similar to your LED use case. Nonetheless
> in case of LED controllers it is also possible that hardware
> adjusts LED brightness in case of low battery voltage.
>
> If a device is able e.g. to generate an interrupt to notify this
> kind of event, then we would like also to be able to notify the client
> about that. It wouldn't be user generated brightness change though.
>
>>>> "Reading this file will return the actual led brightness
>>>> when not blinking and no triggers are active; reading this
>>>> file will return the brightness used when the led is on
>>>> when blinking or triggers are active."
>>>
>>> This is unnecessarily entangled. Blinking means timer trigger
>>> is active.
>>
>> Ok.
>>
>>>> So for e.g. the backlit keyboard case reading this single
>>>> file will return the actual brightness of the backlight,
>>>> since this does not involve blinking or triggers.
>>>>
>>>> Basically the idea is that the user_brightness file
>>>> will have the semantics which IMHO the brightness file
>>>> itself should have had from the beginning, but which
>>>> we can't change now due to ABI reasons.
>>>
>>> And in fact introducing user_brightness file would indeed
>>> fix that shortcoming. However without providing notifications
>>> of hw brightness changes on it.
>>
>> See above, I believe such a file should report any
>> changes in brightness, except those caused by triggers,
>> so it would report hw brightness changes.
>>
>> Anyways if you're not interested in fixing the
>> shortcomings of the current read behavior on the
>> brightness file (I'm fine with that, I can live
>> with the shortcomings) I suggest that we simply go
>> with v2 of my poll() patch.
>
> v2 entails power consumption related issues.
>
> Generally I think that we could add the file you proposed,
> however it would be good to devise a name which will cover
> also the cases when brightness is changed by firmware without
> user interaction.
>
>>>>> Having no difference in this area between the two approaches
>>>>> I'm still in favour of the read-only file for notifying
>>>>> brightness changes procured by hardware.
>>>>
>>>> That brings back the needing 2 fds problem; and does
>>>> not solve userspace not being able to reliably read
>>>> the led on brightness when blinking or using triggers.
>>>>
>>>> And this also has the issue that one is doing poll() on
>>>> one fd to detect changes on another fd,
>>>
>>> It is not necessarily true. We can treat the polling on
>>> hw_brightness_change file as a means to detect brightness
>>> changes procured by hardware and we can read that brightness
>>> by executing read on this same fd. It could return -ENODATA
>>> if no such an event has occurred so far.
>>
>> That would still require 2 fds as userspace also wants to
>> be able to set the keyboard backlight, but allowing read()
>> on the hw_brightness_change file at least fixes the weirdness
>> where userspace gets woken from poll() without being able to
>> read. So if you insist on going the hw_brightness_change file
>> route, then I can live with that (and upower will simply
>> need to open 2 fds, that is doable).
>>
>> But, BUT, I would greatly prefer to just go for v4 of my
>> patch, which fixes the only real problem we've seen with
>> my patch as original merged without adding a new, somewhat
>> convoluted sysfs attribute.
>
> Hmm, v4 still calls led_notify_brightness_change(led_cdev)
> from both __led_set_brightness() and __led_set_brightness_blocking().
Ugh, I see I accidentally send a v4 twice, instead of
calling the version which dropped those called v5 as
I should have, sorry.
The v4 which I would like to see merged, the one with
those calls dropped, is here:
https://patchwork.kernel.org/patch/9423093/
Regards,
Hans
next prev parent reply other threads:[~2016-11-14 12:51 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-09 19:23 Tony Lindgren
2016-11-09 20:45 ` Jacek Anaszewski
2016-11-10 8:49 ` Hans de Goede
2016-11-10 12:56 ` Jacek Anaszewski
2016-11-10 13:04 ` Hans de Goede
2016-11-10 13:55 ` Jacek Anaszewski
2016-11-10 16:36 ` Pavel Machek
2016-11-10 16:29 ` Pavel Machek
2016-11-10 16:44 ` Hans de Goede
2016-11-10 20:48 ` Pavel Machek
2016-11-11 8:25 ` Hans de Goede
2016-11-10 17:55 ` Tony Lindgren
2016-11-10 20:29 ` Pavel Machek
2016-11-10 21:34 ` Jacek Anaszewski
2016-11-11 12:01 ` Pavel Machek
2016-11-11 17:03 ` Jacek Anaszewski
2016-11-11 19:28 ` Hans de Goede
2016-11-11 22:12 ` Pavel Machek
2016-11-12 8:03 ` Hans de Goede
2016-11-13 9:10 ` Three different LED brightnesses (was Re: PM regression with LED changes in next-20161109) Pavel Machek
2016-11-13 9:44 ` Hans de Goede
2016-11-13 20:45 ` Pavel Machek
2016-11-12 10:24 ` PM regression with LED changes in next-20161109 Jacek Anaszewski
2016-11-12 10:33 ` Hans de Goede
2016-11-12 19:14 ` Jacek Anaszewski
2016-11-12 21:14 ` Hans de Goede
2016-11-13 11:44 ` Jacek Anaszewski
2016-11-13 13:52 ` Hans de Goede
2016-11-14 9:12 ` Jacek Anaszewski
2016-11-14 12:51 ` Hans de Goede [this message]
2016-11-15 10:01 ` Jacek Anaszewski
2016-11-15 10:09 ` Hans de Goede
2016-11-15 10:31 ` LEDs that change brightness "itself" -- that's a trigger. " Pavel Machek
2016-11-15 10:58 ` Jacek Anaszewski
2016-11-15 11:11 ` Pavel Machek
2016-11-15 11:21 ` Hans de Goede
2016-11-15 11:48 ` Pavel Machek
2016-11-15 12:06 ` Hans de Goede
2016-11-15 12:11 ` Pavel Machek
2016-11-15 13:28 ` Jacek Anaszewski
2016-11-15 13:48 ` Hans de Goede
2016-11-15 14:04 ` Jacek Anaszewski
2016-11-15 14:30 ` Hans de Goede
2016-11-15 14:41 ` Jacek Anaszewski
2016-11-17 22:12 ` Hans de Goede
2016-11-15 11:17 ` Hans de Goede
2016-11-14 8:31 ` Pavel Machek
2016-11-11 22:06 ` Pavel Machek
2016-11-10 8:34 ` Hans de Goede
2016-11-10 15:11 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15cafbf5-d842-e184-2fd4-65f8272f505a@redhat.com \
--to=hdegoede@redhat.com \
--cc=dvhart@infradead.org \
--cc=j.anaszewski@samsung.com \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®