* [PATCH] ACPI: Run fixed button devices' notify callback in the process context @ 2014-08-22 7:37 Lan Tianyu 2014-08-22 7:41 ` Lan Tianyu 2014-08-22 17:33 ` Rafael J. Wysocki 0 siblings, 2 replies; 5+ messages in thread From: Lan Tianyu @ 2014-08-22 7:37 UTC (permalink / raw) To: rjw, lenb, bebl, davem; +Cc: Lan Tianyu, linux-acpi, linux-kernel Currently fixed button devices' notify callbacks are running in the interrupt context. It's not necessary and prevent calling functions with mutex lock(E,G evaluating ACPI method). Otherwise, it's different with non-fixed button device whose notify callback is running in the process context. This patch is to make fixed button device's notify callback in the process context and this also can avoid dead lock when using netlink to report button event to user space. Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> --- drivers/acpi/scan.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 0a817ad..bfb7fc5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -922,12 +922,17 @@ static void acpi_device_notify(acpi_handle handle, u32 event, void *data) device->driver->ops.notify(device, event); } -static acpi_status acpi_device_notify_fixed(void *data) +static void acpi_device_notify_fixed_run(void *data) { struct acpi_device *device = data; - /* Fixed hardware devices have no handles */ acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); +} + +static acpi_status acpi_device_notify_fixed(void *data) +{ + /* Fixed hardware devices have no handles */ + acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed_run, data); return AE_OK; } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI: Run fixed button devices' notify callback in the process context 2014-08-22 7:37 [PATCH] ACPI: Run fixed button devices' notify callback in the process context Lan Tianyu @ 2014-08-22 7:41 ` Lan Tianyu 2014-08-22 17:33 ` Rafael J. Wysocki 1 sibling, 0 replies; 5+ messages in thread From: Lan Tianyu @ 2014-08-22 7:41 UTC (permalink / raw) To: rjw, lenb, bebl, davem; +Cc: linux-acpi, linux-kernel On 08/22/2014 03:37 PM, Lan Tianyu wrote: > Currently fixed button devices' notify callbacks are running in the > interrupt context. It's not necessary and prevent calling functions > with mutex lock(E,G evaluating ACPI method). Otherwise, it's different > with non-fixed button device whose notify callback is running in the process > context. This patch is to make fixed button device's notify > callback in the process context and this also can avoid dead lock > when using netlink to report button event to user space. > Hi David: Could you try this patch on your machine? So far, I don't have fixed button machine on the hand. > Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> > --- > drivers/acpi/scan.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 0a817ad..bfb7fc5 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -922,12 +922,17 @@ static void acpi_device_notify(acpi_handle handle, u32 event, void *data) > device->driver->ops.notify(device, event); > } > > -static acpi_status acpi_device_notify_fixed(void *data) > +static void acpi_device_notify_fixed_run(void *data) > { > struct acpi_device *device = data; > > - /* Fixed hardware devices have no handles */ > acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); > +} > + > +static acpi_status acpi_device_notify_fixed(void *data) > +{ > + /* Fixed hardware devices have no handles */ > + acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed_run, data); > return AE_OK; > } > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI: Run fixed button devices' notify callback in the process context 2014-08-22 7:37 [PATCH] ACPI: Run fixed button devices' notify callback in the process context Lan Tianyu 2014-08-22 7:41 ` Lan Tianyu @ 2014-08-22 17:33 ` Rafael J. Wysocki 2014-08-22 17:59 ` Benjamin Block 1 sibling, 1 reply; 5+ messages in thread From: Rafael J. Wysocki @ 2014-08-22 17:33 UTC (permalink / raw) To: Lan Tianyu; +Cc: lenb, bebl, davem, linux-acpi, linux-kernel On Friday, August 22, 2014 03:37:55 PM Lan Tianyu wrote: > Currently fixed button devices' notify callbacks are running in the > interrupt context. It's not necessary and prevent calling functions > with mutex lock(E,G evaluating ACPI method). Otherwise, it's different > with non-fixed button device whose notify callback is running in the process > context. This patch is to make fixed button device's notify > callback in the process context and this also can avoid dead lock > when using netlink to report button event to user space. I guess this is the main reason for the patch? Is there a bug report regarding this? > Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> > --- > drivers/acpi/scan.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 0a817ad..bfb7fc5 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -922,12 +922,17 @@ static void acpi_device_notify(acpi_handle handle, u32 event, void *data) > device->driver->ops.notify(device, event); > } > > -static acpi_status acpi_device_notify_fixed(void *data) > +static void acpi_device_notify_fixed_run(void *data) > { > struct acpi_device *device = data; > > - /* Fixed hardware devices have no handles */ > acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); > +} > + > +static acpi_status acpi_device_notify_fixed(void *data) > +{ > + /* Fixed hardware devices have no handles */ > + acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed_run, data); > return AE_OK; > } > > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI: Run fixed button devices' notify callback in the process context 2014-08-22 17:33 ` Rafael J. Wysocki @ 2014-08-22 17:59 ` Benjamin Block 2014-08-25 23:33 ` Rafael J. Wysocki 0 siblings, 1 reply; 5+ messages in thread From: Benjamin Block @ 2014-08-22 17:59 UTC (permalink / raw) To: Rafael J. Wysocki, Lan Tianyu; +Cc: lenb, davem, linux-acpi, linux-kernel [-- Attachment #1: Type: text/plain, Size: 1781 bytes --] On 08/22/2014 07:33 PM, Rafael J. Wysocki wrote: > On Friday, August 22, 2014 03:37:55 PM Lan Tianyu wrote: >> Currently fixed button devices' notify callbacks are running in the >> interrupt context. It's not necessary and prevent calling functions >> with mutex lock(E,G evaluating ACPI method). Otherwise, it's different >> with non-fixed button device whose notify callback is running in the process >> context. This patch is to make fixed button device's notify >> callback in the process context and this also can avoid dead lock >> when using netlink to report button event to user space. > > I guess this is the main reason for the patch? > > Is there a bug report regarding this? > There is: https://lkml.org/lkml/2014/8/21/606 > >> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> >> --- >> drivers/acpi/scan.c | 9 +++++++-- >> 1 file changed, 7 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c >> index 0a817ad..bfb7fc5 100644 >> --- a/drivers/acpi/scan.c >> +++ b/drivers/acpi/scan.c >> @@ -922,12 +922,17 @@ static void acpi_device_notify(acpi_handle handle, u32 event, void *data) >> device->driver->ops.notify(device, event); >> } >> >> -static acpi_status acpi_device_notify_fixed(void *data) >> +static void acpi_device_notify_fixed_run(void *data) >> { >> struct acpi_device *device = data; >> >> - /* Fixed hardware devices have no handles */ >> acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); >> +} >> + >> +static acpi_status acpi_device_notify_fixed(void *data) >> +{ >> + /* Fixed hardware devices have no handles */ >> + acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed_run, data); >> return AE_OK; >> } >> >> > [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 648 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI: Run fixed button devices' notify callback in the process context 2014-08-22 17:59 ` Benjamin Block @ 2014-08-25 23:33 ` Rafael J. Wysocki 0 siblings, 0 replies; 5+ messages in thread From: Rafael J. Wysocki @ 2014-08-25 23:33 UTC (permalink / raw) To: bebl, Lan Tianyu, Knut Petersen Cc: lenb, davem, linux-acpi, linux-kernel, Linus Torvalds On Friday, August 22, 2014 07:59:50 PM Benjamin Block wrote: > This is an OpenPGP/MIME signed message (RFC 4880 and 3156) > --jcnP2A9R7oLCVKLLsxCrieJLxfXGKbBUw > Content-Type: text/plain; charset=utf-8 > Content-Transfer-Encoding: quoted-printable > > On 08/22/2014 07:33 PM, Rafael J. Wysocki wrote: > > On Friday, August 22, 2014 03:37:55 PM Lan Tianyu wrote: > >> Currently fixed button devices' notify callbacks are running in the > >> interrupt context. It's not necessary and prevent calling functions > >> with mutex lock(E,G evaluating ACPI method). Otherwise, it's different= > > >> with non-fixed button device whose notify callback is running in the p= > rocess > >> context. This patch is to make fixed button device's notify > >> callback in the process context and this also can avoid dead lock > >> when using netlink to report button event to user space. > >=20 > > I guess this is the main reason for the patch? > >=20 > > Is there a bug report regarding this? > > > > There is: https://lkml.org/lkml/2014/8/21/606 OK, below is my version. Benjamin, Knut, can you please test this one just in case? Rafael --- From: Lan Tianyu <tianyu.lan@intel.com> Subject: ACPI: Run fixed event device notifications in process context Currently, notify callbacks for fixed button events are run from interrupt context. That is not necessary and after commit 0bf6368ee8f2 (ACPI / button: Add ACPI Button event via netlink routine) it causes netlink routines to be called from interrupt context which is not correct. Also, that is different from non-fixed device events (including non-fixed button events) whose notify callbacks are all executed from process context. For the above reasons, make fixed button device notify callbacks run in process context which will avoid the deadlock when using netlink to report button events to user space. Fixes: 0bf6368ee8f2 (ACPI / button: Add ACPI Button event via netlink routine) Link: https://lkml.org/lkml/2014/8/21/606 Reported-by: Benjamin Block <bebl@mageta.org> Reported-by: Knut Petersen <Knut_Petersen@t-online.de> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> [rjw: Function names, subject and changelog.] Cc: 3.15+ <stable@vger.kernel.org> # 3.15+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- drivers/acpi/scan.c | 9 +++++++-- drivers/acpi/scan.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c +++ linux-pm/drivers/acpi/scan.c @@ -922,12 +922,17 @@ static void acpi_device_notify(acpi_hand device->driver->ops.notify(device, event); } -static acpi_status acpi_device_notify_fixed(void *data) +static void acpi_device_notify_fixed(void *data) { struct acpi_device *device = data; /* Fixed hardware devices have no handles */ acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); +} + +static acpi_status acpi_device_fixed_event(void *data) +{ + acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data); return AE_OK; } @@ -938,12 +943,12 @@ static int acpi_device_install_notify_ha if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) status = acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, - acpi_device_notify_fixed, + acpi_device_fixed_event, device); else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) status = acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, - acpi_device_notify_fixed, + acpi_device_fixed_event, device); else status = acpi_install_notify_handler(device->handle, @@ -960,10 +965,10 @@ static void acpi_device_remove_notify_ha { if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, - acpi_device_notify_fixed); + acpi_device_fixed_event); else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, - acpi_device_notify_fixed); + acpi_device_fixed_event); else acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_device_notify); ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-25 23:14 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-08-22 7:37 [PATCH] ACPI: Run fixed button devices' notify callback in the process context Lan Tianyu 2014-08-22 7:41 ` Lan Tianyu 2014-08-22 17:33 ` Rafael J. Wysocki 2014-08-22 17:59 ` Benjamin Block 2014-08-25 23:33 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox