diff mbox

video: backlight: Remove backlight sysfs uevent

Message ID 20131111235700.GA29987@july (mailing list archive)
State New, archived
Headers show

Commit Message

Kyungmin Park Nov. 11, 2013, 11:57 p.m. UTC
From: Kyungmin Park <kyungmin.park@samsung.com>

The most mobile phones have Ambient Light Sensors and it changes brightness according lux.
It means it changes backlight brightness frequently by just writing sysfs node, so it generates uevent.
 
Usually there's no user to use this backlight changes. But it forks udev worker threads and it takes about 5ms. The main problem is that it hurts other process activities. so remove it.

Kay said 
"Uevents are for the major, low-frequent, global device state-changes,
 not for carrying-out any sort of measurement data. Subsystems which
 need that should use other facilities like poll()-able sysfs file or
 any other subscription-based, client-tracking interface which does not
 cause overhead if it isn't used. Uevents are not the right thing to
 use here, and upstream udev should not paper-over broken kernel
 subsystems."

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jingoo Han Nov. 12, 2013, 12:18 a.m. UTC | #1
On Tuesday, November 12, 2013 8:57 AM, Kyungmin Park wrote:
> 
> From: Kyungmin Park <kyungmin.park@samsung.com>
> 
> The most mobile phones have Ambient Light Sensors and it changes brightness according lux.
> It means it changes backlight brightness frequently by just writing sysfs node, so it generates uevent.
> 
> Usually there's no user to use this backlight changes. But it forks udev worker threads and it takes
> about 5ms. The main problem is that it hurts other process activities. so remove it.
> 
> Kay said
> "Uevents are for the major, low-frequent, global device state-changes,
>  not for carrying-out any sort of measurement data. Subsystems which
>  need that should use other facilities like poll()-able sysfs file or
>  any other subscription-based, client-tracking interface which does not
>  cause overhead if it isn't used. Uevents are not the right thing to
>  use here, and upstream udev should not paper-over broken kernel
>  subsystems."
> 
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index 94a403a..441272d 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -88,9 +88,6 @@ static void backlight_generate_event(struct backlight_device *bd,
>  	char *envp[2];
> 
>  	switch (reason) {
> -	case BACKLIGHT_UPDATE_SYSFS:
> -		envp[0] = "SOURCE=sysfs";
> -		break;
>  	case BACKLIGHT_UPDATE_HOTKEY:
>  		envp[0] = "SOURCE=hotkey";
>  		break;
> @@ -172,8 +169,6 @@ static ssize_t brightness_store(struct device *dev,
>  	}
>  	mutex_unlock(&bd->ops_lock);
> 
> -	backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS);
> -
>  	return rc;
>  }
>  static DEVICE_ATTR_RW(brightness);
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 53b7794..d2a27dd 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -29,7 +29,6 @@
> 
>  enum backlight_update_reason {
>  	BACKLIGHT_UPDATE_HOTKEY,
> -	BACKLIGHT_UPDATE_SYSFS,

+cc Henrique de Moraes Holschuh (Maintainer of thinkpad_acpi)

Hi Henrique de Moraes Holschuh,

'thinkpad_acpi.c' uses the 'BACKLIGHT_UPDATE_SYSFS'.
Henrique, can we remove it?

drivers/platform/x86/thinkpad_acpi.c
if (!rc && ibm_backlight_device)
                backlight_force_update(ibm_backlight_device,
                                        BACKLIGHT_UPDATE_SYSFS);

Best regards,
Jingoo Han

>  };
> 
>  enum backlight_type {

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Henrique de Moraes Holschuh Nov. 12, 2013, 12:56 a.m. UTC | #2
On Tue, 12 Nov 2013, Jingoo Han wrote:
> On Tuesday, November 12, 2013 8:57 AM, Kyungmin Park wrote:
> > From: Kyungmin Park <kyungmin.park@samsung.com>
> > 
> > The most mobile phones have Ambient Light Sensors and it changes brightness according lux.
> > It means it changes backlight brightness frequently by just writing sysfs node, so it generates uevent.
> > 
> > Usually there's no user to use this backlight changes. But it forks udev worker threads and it takes
> > about 5ms. The main problem is that it hurts other process activities. so remove it.
> > 
> > Kay said
> > "Uevents are for the major, low-frequent, global device state-changes,
> >  not for carrying-out any sort of measurement data. Subsystems which
> >  need that should use other facilities like poll()-able sysfs file or
> >  any other subscription-based, client-tracking interface which does not
> >  cause overhead if it isn't used. Uevents are not the right thing to
> >  use here, and upstream udev should not paper-over broken kernel
> >  subsystems."

True.

Now, let's take a look at reality: should you poll()/select() on a sysfs
node that doesn't suport it, it will wait until the poll/select timeout
happens (or EINTR happens), and userspace has absolutely NO way to detect
whether a sysfs node has poll/select support.

What happens if the sysfs interface did not provide poll/select support
since day one, but rather added it later?  Nobody will use it for a *long*
time, if ever... unless you actually took pains to version the sysfs
interface, and people actually care.

> 'thinkpad_acpi.c' uses the 'BACKLIGHT_UPDATE_SYSFS'.
> Henrique, can we remove it?

Can't you fix this by rate-limiting, or otherwise adding an attribute that
backlight devices should set when they need to supress change events?

Is there a proper on-screen-display support path for the backlight class
nowadays?  Otherwise, you'd be removing the only way userspace ever had to
do proper OSD of backlight changes...
Kyungmin Park Nov. 12, 2013, 1:07 a.m. UTC | #3
On Tue, Nov 12, 2013 at 9:56 AM, Henrique de Moraes Holschuh
<hmh@hmh.eng.br> wrote:
> On Tue, 12 Nov 2013, Jingoo Han wrote:
>> On Tuesday, November 12, 2013 8:57 AM, Kyungmin Park wrote:
>> > From: Kyungmin Park <kyungmin.park@samsung.com>
>> >
>> > The most mobile phones have Ambient Light Sensors and it changes brightness according lux.
>> > It means it changes backlight brightness frequently by just writing sysfs node, so it generates uevent.
>> >
>> > Usually there's no user to use this backlight changes. But it forks udev worker threads and it takes
>> > about 5ms. The main problem is that it hurts other process activities. so remove it.
>> >
>> > Kay said
>> > "Uevents are for the major, low-frequent, global device state-changes,
>> >  not for carrying-out any sort of measurement data. Subsystems which
>> >  need that should use other facilities like poll()-able sysfs file or
>> >  any other subscription-based, client-tracking interface which does not
>> >  cause overhead if it isn't used. Uevents are not the right thing to
>> >  use here, and upstream udev should not paper-over broken kernel
>> >  subsystems."
>
> True.
>
> Now, let's take a look at reality: should you poll()/select() on a sysfs
> node that doesn't suport it, it will wait until the poll/select timeout
> happens (or EINTR happens), and userspace has absolutely NO way to detect
> whether a sysfs node has poll/select support.
>
> What happens if the sysfs interface did not provide poll/select support
> since day one, but rather added it later?  Nobody will use it for a *long*
> time, if ever... unless you actually took pains to version the sysfs
> interface, and people actually care.
>
>> 'thinkpad_acpi.c' uses the 'BACKLIGHT_UPDATE_SYSFS'.
>> Henrique, can we remove it?
>
> Can't you fix this by rate-limiting, or otherwise adding an attribute that
> backlight devices should set when they need to supress change events?

other way is that just remove sysfs node store update then you can use
current API, force_update as is.

are there any other good ideas?

Thank you,
Kyungmin Park
>
> Is there a proper on-screen-display support path for the backlight class
> nowadays?  Otherwise, you'd be removing the only way userspace ever had to
> do proper OSD of backlight changes...
>
> --
>   "One disk to rule them all, One disk to find them. One disk to bring
>   them all and in the darkness grind them. In the Land of Redmond
>   where the shadows lie." -- The Silicon Valley Tarot
>   Henrique Holschuh
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kay Sievers Nov. 12, 2013, 1:19 a.m. UTC | #4
On Tue, Nov 12, 2013 at 1:56 AM, Henrique de Moraes Holschuh
<hmh@hmh.eng.br> wrote:
> On Tue, 12 Nov 2013, Jingoo Han wrote:
>> On Tuesday, November 12, 2013 8:57 AM, Kyungmin Park wrote:
>> > From: Kyungmin Park <kyungmin.park@samsung.com>
>> >
>> > The most mobile phones have Ambient Light Sensors and it changes brightness according lux.
>> > It means it changes backlight brightness frequently by just writing sysfs node, so it generates uevent.
>> >
>> > Usually there's no user to use this backlight changes. But it forks udev worker threads and it takes
>> > about 5ms. The main problem is that it hurts other process activities. so remove it.
>> >
>> > Kay said
>> > "Uevents are for the major, low-frequent, global device state-changes,
>> >  not for carrying-out any sort of measurement data. Subsystems which
>> >  need that should use other facilities like poll()-able sysfs file or
>> >  any other subscription-based, client-tracking interface which does not
>> >  cause overhead if it isn't used. Uevents are not the right thing to
>> >  use here, and upstream udev should not paper-over broken kernel
>> >  subsystems."
>
> True.
>
> Now, let's take a look at reality: should you poll()/select() on a sysfs
> node that doesn't suport it, it will wait until the poll/select timeout
> happens (or EINTR happens), and userspace has absolutely NO way to detect
> whether a sysfs node has poll/select support.
>
> What happens if the sysfs interface did not provide poll/select support
> since day one, but rather added it later?  Nobody will use it for a *long*
> time, if ever... unless you actually took pains to version the sysfs
> interface, and people actually care.

If that's an issue, we can add a new "event" file, just for that.

>> 'thinkpad_acpi.c' uses the 'BACKLIGHT_UPDATE_SYSFS'.
>> Henrique, can we remove it?
>
> Can't you fix this by rate-limiting, or otherwise adding an attribute that
> backlight devices should set when they need to supress change events?

Yeah, great idea, fix a bad hack with another bad one on top. :)
Passing measurement data through uevents is just an utterly broken
idea which cannot be fixed.

> Is there a proper on-screen-display support path for the backlight class
> nowadays?  Otherwise, you'd be removing the only way userspace ever had to
> do proper OSD of backlight changes...

OSD drawing and event sounds usually happen as a fedback for
keypresses of brightness control, it would be weird to show up when
something else, like a light-sensor, adjusts the brightness in the
background.

Anyway, there might be the need for coordination and a new interface,
but uevents for measurement data need to die entirely; they make no
sense, never made any; and the sooner they are gone the better.

Kay
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kyungmin Park Nov. 12, 2013, 2:08 a.m. UTC | #5
On Tue, Nov 12, 2013 at 10:19 AM, Kay Sievers <kay@vrfy.org> wrote:
> On Tue, Nov 12, 2013 at 1:56 AM, Henrique de Moraes Holschuh
> <hmh@hmh.eng.br> wrote:
>> On Tue, 12 Nov 2013, Jingoo Han wrote:
>>> On Tuesday, November 12, 2013 8:57 AM, Kyungmin Park wrote:
>>> > From: Kyungmin Park <kyungmin.park@samsung.com>
>>> >
>>> > The most mobile phones have Ambient Light Sensors and it changes brightness according lux.
>>> > It means it changes backlight brightness frequently by just writing sysfs node, so it generates uevent.
>>> >
>>> > Usually there's no user to use this backlight changes. But it forks udev worker threads and it takes
>>> > about 5ms. The main problem is that it hurts other process activities. so remove it.
>>> >
>>> > Kay said
>>> > "Uevents are for the major, low-frequent, global device state-changes,
>>> >  not for carrying-out any sort of measurement data. Subsystems which
>>> >  need that should use other facilities like poll()-able sysfs file or
>>> >  any other subscription-based, client-tracking interface which does not
>>> >  cause overhead if it isn't used. Uevents are not the right thing to
>>> >  use here, and upstream udev should not paper-over broken kernel
>>> >  subsystems."
>>
>> True.
>>
>> Now, let's take a look at reality: should you poll()/select() on a sysfs
>> node that doesn't suport it, it will wait until the poll/select timeout
>> happens (or EINTR happens), and userspace has absolutely NO way to detect
>> whether a sysfs node has poll/select support.
>>
>> What happens if the sysfs interface did not provide poll/select support
>> since day one, but rather added it later?  Nobody will use it for a *long*
>> time, if ever... unless you actually took pains to version the sysfs
>> interface, and people actually care.
>
> If that's an issue, we can add a new "event" file, just for that.
>
>>> 'thinkpad_acpi.c' uses the 'BACKLIGHT_UPDATE_SYSFS'.
>>> Henrique, can we remove it?
>>
>> Can't you fix this by rate-limiting, or otherwise adding an attribute that
>> backlight devices should set when they need to supress change events?
>
> Yeah, great idea, fix a bad hack with another bad one on top. :)
> Passing measurement data through uevents is just an utterly broken
> idea which cannot be fixed.
>
>> Is there a proper on-screen-display support path for the backlight class
>> nowadays?  Otherwise, you'd be removing the only way userspace ever had to
>> do proper OSD of backlight changes...
>
> OSD drawing and event sounds usually happen as a fedback for
> keypresses of brightness control, it would be weird to show up when
> something else, like a light-sensor, adjusts the brightness in the
> background.
>
> Anyway, there might be the need for coordination and a new interface,
> but uevents for measurement data need to die entirely; they make no
> sense, never made any; and the sooner they are gone the better.

Now power_supply, especially battery uses this scheme. it passes
battery data using uevent.
do you have any idea to kill it?

Thank you,
Kyungmin Park
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kay Sievers Nov. 12, 2013, 2:22 a.m. UTC | #6
On Tue, Nov 12, 2013 at 3:08 AM, Kyungmin Park <kmpark@infradead.org> wrote:
> On Tue, Nov 12, 2013 at 10:19 AM, Kay Sievers <kay@vrfy.org> wrote:
>> On Tue, Nov 12, 2013 at 1:56 AM, Henrique de Moraes Holschuh
>> <hmh@hmh.eng.br> wrote:
>>> On Tue, 12 Nov 2013, Jingoo Han wrote:
>>>> On Tuesday, November 12, 2013 8:57 AM, Kyungmin Park wrote:
>>>> > From: Kyungmin Park <kyungmin.park@samsung.com>
>>>> >
>>>> > The most mobile phones have Ambient Light Sensors and it changes brightness according lux.
>>>> > It means it changes backlight brightness frequently by just writing sysfs node, so it generates uevent.
>>>> >
>>>> > Usually there's no user to use this backlight changes. But it forks udev worker threads and it takes
>>>> > about 5ms. The main problem is that it hurts other process activities. so remove it.
>>>> >
>>>> > Kay said
>>>> > "Uevents are for the major, low-frequent, global device state-changes,
>>>> >  not for carrying-out any sort of measurement data. Subsystems which
>>>> >  need that should use other facilities like poll()-able sysfs file or
>>>> >  any other subscription-based, client-tracking interface which does not
>>>> >  cause overhead if it isn't used. Uevents are not the right thing to
>>>> >  use here, and upstream udev should not paper-over broken kernel
>>>> >  subsystems."
>>>
>>> True.
>>>
>>> Now, let's take a look at reality: should you poll()/select() on a sysfs
>>> node that doesn't suport it, it will wait until the poll/select timeout
>>> happens (or EINTR happens), and userspace has absolutely NO way to detect
>>> whether a sysfs node has poll/select support.
>>>
>>> What happens if the sysfs interface did not provide poll/select support
>>> since day one, but rather added it later?  Nobody will use it for a *long*
>>> time, if ever... unless you actually took pains to version the sysfs
>>> interface, and people actually care.
>>
>> If that's an issue, we can add a new "event" file, just for that.
>>
>>>> 'thinkpad_acpi.c' uses the 'BACKLIGHT_UPDATE_SYSFS'.
>>>> Henrique, can we remove it?
>>>
>>> Can't you fix this by rate-limiting, or otherwise adding an attribute that
>>> backlight devices should set when they need to supress change events?
>>
>> Yeah, great idea, fix a bad hack with another bad one on top. :)
>> Passing measurement data through uevents is just an utterly broken
>> idea which cannot be fixed.
>>
>>> Is there a proper on-screen-display support path for the backlight class
>>> nowadays?  Otherwise, you'd be removing the only way userspace ever had to
>>> do proper OSD of backlight changes...
>>
>> OSD drawing and event sounds usually happen as a fedback for
>> keypresses of brightness control, it would be weird to show up when
>> something else, like a light-sensor, adjusts the brightness in the
>> background.
>>
>> Anyway, there might be the need for coordination and a new interface,
>> but uevents for measurement data need to die entirely; they make no
>> sense, never made any; and the sooner they are gone the better.
>
> Now power_supply, especially battery uses this scheme. it passes
> battery data using uevent.
> do you have any idea to kill it?

It should be removed too, the same applies to power_supply as to everything
else; uevents are a broken interface for any kind of device data which
is not meant as a trigger to re-configure the device itself.

But power_supply events are at least not as unfixable as backlight,
the number of events can be kept relatively low during normal
operation. So it can happen after the backlight thing is sorted out.

Note: The same rule as for generating uevents applies also to device
properties exported in the environment too; measurement data has no
place there. Reading the "uevent" file of a battery in sysfs (we need to
do that at bootup) sometimes synchronously blocks 1 second to return,
just because it tries to add measurement data reading it live from the
hardware to add it to the event itself.

Kay
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Matthew Garrett Nov. 20, 2013, 11:40 p.m. UTC | #7
On Mon, 2013-11-11 at 22:56 -0200, Henrique de Moraes Holschuh wrote:
> On Tue, 12 Nov 2013, Jingoo Han wrote:
> > 'thinkpad_acpi.c' uses the 'BACKLIGHT_UPDATE_SYSFS'.
> > Henrique, can we remove it?
> 
> Can't you fix this by rate-limiting, or otherwise adding an attribute that
> backlight devices should set when they need to supress change events?

It looks like this is just to force synchronisation to sysfs when using
the /proc interface? In which case we should probably just kill
the /proc interface.
Henrique de Moraes Holschuh Nov. 21, 2013, 11:43 a.m. UTC | #8
On Wed, 20 Nov 2013, Matthew Garrett wrote:
> On Mon, 2013-11-11 at 22:56 -0200, Henrique de Moraes Holschuh wrote:
> > On Tue, 12 Nov 2013, Jingoo Han wrote:
> > > 'thinkpad_acpi.c' uses the 'BACKLIGHT_UPDATE_SYSFS'.
> > > Henrique, can we remove it?
> > 
> > Can't you fix this by rate-limiting, or otherwise adding an attribute that
> > backlight devices should set when they need to supress change events?
> 
> It looks like this is just to force synchronisation to sysfs when using
> the /proc interface? In which case we should probably just kill
> the /proc interface.

Well, we can remove the thinkpad-acpi /proc interface as far as I'm
concerned, and that would do away with the use of BACKLIGHT_UPDATE_SYSFS by
thinkpad-acpi.  It is a major userspace ABI break, but removing everything
under /proc/acpi is one of the very few ABI breaks we actually have the
green light to do.

However, the patchset is not about this.

With this patchset applied, as far as I can tell anything that used to be
uevent-driven by the backlight class will break: when a process changes the
backlight using sysfs, other processes will not be notified of the change
anymore.  This patchset seems to break backlight uevent support in such a
way that basically renders the entire thing useless and you might as well
just remove uevent support entirely.

It is also an userspace ABI break, which we do not do lightly.

So, as far as I'm concerned, this patchset should be rejected in its present
form.  IMO, either one that preserves BACKLIGHT_UPDATE_SYSFS and fixes the
urgent issue, or one that removes uevent support entirely from the backlight
class should be proposed instead.
Matthew Garrett Nov. 21, 2013, 2:33 p.m. UTC | #9
On Thu, Nov 21, 2013 at 09:43:32AM -0200, Henrique de Moraes Holschuh wrote:

> With this patchset applied, as far as I can tell anything that used to be
> uevent-driven by the backlight class will break: when a process changes the
> backlight using sysfs, other processes will not be notified of the change
> anymore.  This patchset seems to break backlight uevent support in such a
> way that basically renders the entire thing useless and you might as well
> just remove uevent support entirely.

The uevent support was initially added to handle systems where pressing 
a hotkey generates an event (good) but the firmware automatically 
changes the brightness (bad). I have absolutely no idea why I added 
BACKLIGHT_UPDATE_SYSFS - BACKLIGHT_UPDATE_HOTKEY solves the problem I 
was trying to solve. I'm not aware of any userspace that relies on 
BACKLIGHT_UPDATE_SYSFS.
Henrique de Moraes Holschuh Nov. 22, 2013, 11:36 a.m. UTC | #10
On Thu, 21 Nov 2013, Matthew Garrett wrote:
> On Thu, Nov 21, 2013 at 09:43:32AM -0200, Henrique de Moraes Holschuh wrote:
> > With this patchset applied, as far as I can tell anything that used to be
> > uevent-driven by the backlight class will break: when a process changes the
> > backlight using sysfs, other processes will not be notified of the change
> > anymore.  This patchset seems to break backlight uevent support in such a
> > way that basically renders the entire thing useless and you might as well
> > just remove uevent support entirely.
> 
> The uevent support was initially added to handle systems where pressing 
> a hotkey generates an event (good) but the firmware automatically 
> changes the brightness (bad). I have absolutely no idea why I added 
> BACKLIGHT_UPDATE_SYSFS - BACKLIGHT_UPDATE_HOTKEY solves the problem I 
> was trying to solve. I'm not aware of any userspace that relies on 
> BACKLIGHT_UPDATE_SYSFS.

Well, either we have userspace that rely on the uevents, or we don't. 

If we don't have any uevent users of the backlight notifications, we might
as well just rip out the feature entirely and replace it with something with
a proper design.  But that would mean all OSD is being done by time-based
open-read-close polling of sysfs or keyed to input events (and therefore
half-baked).

However, if we do have anything that rely on the uevents, it needs
BACKLIGHT_UPDATE_SYSFS.  Without it, there will be no notifications when the
backlight level is changed through sysfs.  And we *DO* have applications
that change the backlight level through sysfs.  From the top of my head, I
know KDE does when it starts, and also as a response to power management
events.  Also, userspace hotkey daemons do use the sysfs interface.
Matthew Garrett Nov. 22, 2013, 5:15 p.m. UTC | #11
On Fri, Nov 22, 2013 at 09:36:01AM -0200, Henrique de Moraes Holschuh wrote:
> On Thu, 21 Nov 2013, Matthew Garrett wrote:
> > The uevent support was initially added to handle systems where pressing 
> > a hotkey generates an event (good) but the firmware automatically 
> > changes the brightness (bad). I have absolutely no idea why I added 
> > BACKLIGHT_UPDATE_SYSFS - BACKLIGHT_UPDATE_HOTKEY solves the problem I 
> > was trying to solve. I'm not aware of any userspace that relies on 
> > BACKLIGHT_UPDATE_SYSFS.
> 
> Well, either we have userspace that rely on the uevents, or we don't. 

We have userspace that relies on uevents of type 
BACKLIGHT_UPDATE_HOTKEY. I don't know that we have userspace that relies 
on uevents of type BACKLIGHT_UPDATE_SYSFS.
Henrique de Moraes Holschuh Nov. 24, 2013, 12:40 a.m. UTC | #12
On Fri, 22 Nov 2013, Matthew Garrett wrote:
> On Fri, Nov 22, 2013 at 09:36:01AM -0200, Henrique de Moraes Holschuh wrote:
> > On Thu, 21 Nov 2013, Matthew Garrett wrote:
> > > The uevent support was initially added to handle systems where pressing 
> > > a hotkey generates an event (good) but the firmware automatically 
> > > changes the brightness (bad). I have absolutely no idea why I added 
> > > BACKLIGHT_UPDATE_SYSFS - BACKLIGHT_UPDATE_HOTKEY solves the problem I 
> > > was trying to solve. I'm not aware of any userspace that relies on 
> > > BACKLIGHT_UPDATE_SYSFS.
> > 
> > Well, either we have userspace that rely on the uevents, or we don't. 
> 
> We have userspace that relies on uevents of type 
> BACKLIGHT_UPDATE_HOTKEY. I don't know that we have userspace that relies 
> on uevents of type BACKLIGHT_UPDATE_SYSFS.

Any OSD application would have to rely on both uevent types, or it is broken
(and to test that, just write a level to sysfs and watch the OSD app fail to
tell you about the backlight level change...)

I don't know about other types of applications, though.  What other type of
applications pay attention to backlight uevents?
Matthew Garrett Nov. 24, 2013, 1:02 a.m. UTC | #13
On Sat, Nov 23, 2013 at 10:40:15PM -0200, Henrique de Moraes Holschuh wrote:
> On Fri, 22 Nov 2013, Matthew Garrett wrote:
> > We have userspace that relies on uevents of type 
> > BACKLIGHT_UPDATE_HOTKEY. I don't know that we have userspace that relies 
> > on uevents of type BACKLIGHT_UPDATE_SYSFS.
> 
> Any OSD application would have to rely on both uevent types, or it is broken
> (and to test that, just write a level to sysfs and watch the OSD app fail to
> tell you about the backlight level change...)

Right, OSDs are supposed to respond to keypresses, not arbitrary changes 
of backlight. If the user's just echoed 8 into brightness, they know 
they set the brightness to 8 - they don't need an OSD to tell them that. 
BACKLIGHT_UPDATE_HOTKEY is when the firmware itself has changed the 
brightness in response to a keypress, and so reporting the keypress 
would result in additional backlight changes.
Henrique de Moraes Holschuh Nov. 24, 2013, 3:53 a.m. UTC | #14
On Sun, 24 Nov 2013, Matthew Garrett wrote:
> On Sat, Nov 23, 2013 at 10:40:15PM -0200, Henrique de Moraes Holschuh wrote:
> > On Fri, 22 Nov 2013, Matthew Garrett wrote:
> > > We have userspace that relies on uevents of type 
> > > BACKLIGHT_UPDATE_HOTKEY. I don't know that we have userspace that relies 
> > > on uevents of type BACKLIGHT_UPDATE_SYSFS.
> > 
> > Any OSD application would have to rely on both uevent types, or it is broken
> > (and to test that, just write a level to sysfs and watch the OSD app fail to
> > tell you about the backlight level change...)
> 
> Right, OSDs are supposed to respond to keypresses, not arbitrary changes 
> of backlight. If the user's just echoed 8 into brightness, they know 
> they set the brightness to 8 - they don't need an OSD to tell them that. 

It is not just the user that sets the brightness.

Still, if you're sure that all userspace users react only to the hotkey type
of event, removing the sysfs one won't break anything any further.

But it will be *really* annoying the day we revisit this because someone
started abusing the hotkey uevent and we have to deploy a proper fix (rate
limiting or switching to a proper event report interface that doesn't use
uevents).

> BACKLIGHT_UPDATE_HOTKEY is when the firmware itself has changed the 
> brightness in response to a keypress, and so reporting the keypress 
> would result in additional backlight changes.

Yeah, I know that bug quite well, thinkpads were the first victims of
idiotic feedback event loops caused by braindead userspace.
diff mbox

Patch

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 94a403a..441272d 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -88,9 +88,6 @@  static void backlight_generate_event(struct backlight_device *bd,
 	char *envp[2];
 
 	switch (reason) {
-	case BACKLIGHT_UPDATE_SYSFS:
-		envp[0] = "SOURCE=sysfs";
-		break;
 	case BACKLIGHT_UPDATE_HOTKEY:
 		envp[0] = "SOURCE=hotkey";
 		break;
@@ -172,8 +169,6 @@  static ssize_t brightness_store(struct device *dev,
 	}
 	mutex_unlock(&bd->ops_lock);
 
-	backlight_generate_event(bd, BACKLIGHT_UPDATE_SYSFS);
-
 	return rc;
 }
 static DEVICE_ATTR_RW(brightness);
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 53b7794..d2a27dd 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -29,7 +29,6 @@ 
 
 enum backlight_update_reason {
 	BACKLIGHT_UPDATE_HOTKEY,
-	BACKLIGHT_UPDATE_SYSFS,
 };
 
 enum backlight_type {