linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ACPI / LPSS: Do not instiate a platform_dev for devs without a mmio resource
@ 2018-01-14 20:01 Hans de Goede
  2018-01-14 23:36 ` Rafael J. Wysocki
  2018-01-15  9:36 ` Mika Westerberg
  0 siblings, 2 replies; 5+ messages in thread
From: Hans de Goede @ 2018-01-14 20:01 UTC (permalink / raw)
  To: Rafael J . Wysocki, Len Brown, Andy Shevchenko, Mika Westerberg,
	MyungJoo Ham, Chanwoo Choi, Chen-Yu Tsai
  Cc: Hans de Goede, Thierry Reding, linux-pwm, linux-acpi,
	linux-kernel

acpi_lpss_create_device() skips handling LPSS devices which do not have
a mmio resources in their resource list (typically these devices are
disabled by the firmware). But since the LPSS code does not bind to the
device, acpi_bus_attach() ends up still creating a platform device for
it and the regular platform_driver for the ACPI HID still tries to bind
to it.

This happens e.g. on some boards which do not use the pwm-controller
and have an empty or invalid resource-table for it. Currently this causes
these error messages to get logged:
[    3.281966] pwm-lpss 80862288:00: invalid resource
[    3.287098] pwm-lpss: probe of 80862288:00 failed with error -22

This commit stops the undesirable creation of a platform_device for
disabled LPSS devices by setting pnp.type.platform_id to 0. Note that
acpi_scan_attach_handler() also sets pnp.type.platform_id to 0 when there
is a matching handler for the device and that handler has no attach
callback, so we simply behave as a handler without an attach function
in this case.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/acpi_lpss.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 9cfe6b71078b..166a8e582d96 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -610,6 +610,8 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
 	acpi_dev_free_resource_list(&resource_list);
 
 	if (!pdata->mmio_base) {
+		/* Avoid acpi_bus_attach() instantiating a pdev for this dev. */
+		adev->pnp.type.platform_id = 0;
 		/* Skip the device, but continue the namespace scan. */
 		ret = 0;
 		goto err_out;
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI / LPSS: Do not instiate a platform_dev for devs without a mmio resource
  2018-01-14 20:01 [PATCH] ACPI / LPSS: Do not instiate a platform_dev for devs without a mmio resource Hans de Goede
@ 2018-01-14 23:36 ` Rafael J. Wysocki
  2018-01-15  8:42   ` Hans de Goede
  2018-01-15  9:36 ` Mika Westerberg
  1 sibling, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2018-01-14 23:36 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Len Brown, Andy Shevchenko, Mika Westerberg,
	MyungJoo Ham, Chanwoo Choi, Chen-Yu Tsai, Thierry Reding,
	Linux PWM List, ACPI Devel Maling List, Linux Kernel Mailing List

On Sun, Jan 14, 2018 at 9:01 PM, Hans de Goede <hdegoede@redhat.com> wrote:
> acpi_lpss_create_device() skips handling LPSS devices which do not have
> a mmio resources in their resource list (typically these devices are
> disabled by the firmware). But since the LPSS code does not bind to the
> device, acpi_bus_attach() ends up still creating a platform device for
> it and the regular platform_driver for the ACPI HID still tries to bind
> to it.
>
> This happens e.g. on some boards which do not use the pwm-controller
> and have an empty or invalid resource-table for it. Currently this causes
> these error messages to get logged:
> [    3.281966] pwm-lpss 80862288:00: invalid resource
> [    3.287098] pwm-lpss: probe of 80862288:00 failed with error -22
>
> This commit stops the undesirable creation of a platform_device for
> disabled LPSS devices by setting pnp.type.platform_id to 0. Note that
> acpi_scan_attach_handler() also sets pnp.type.platform_id to 0 when there
> is a matching handler for the device and that handler has no attach
> callback, so we simply behave as a handler without an attach function
> in this case.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Does this fix new behavior or is it an old issue?

> ---
>  drivers/acpi/acpi_lpss.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index 9cfe6b71078b..166a8e582d96 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -610,6 +610,8 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
>         acpi_dev_free_resource_list(&resource_list);
>
>         if (!pdata->mmio_base) {
> +               /* Avoid acpi_bus_attach() instantiating a pdev for this dev. */
> +               adev->pnp.type.platform_id = 0;
>                 /* Skip the device, but continue the namespace scan. */
>                 ret = 0;
>                 goto err_out;
> --
> 2.14.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI / LPSS: Do not instiate a platform_dev for devs without a mmio resource
  2018-01-14 23:36 ` Rafael J. Wysocki
@ 2018-01-15  8:42   ` Hans de Goede
  0 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2018-01-15  8:42 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael J . Wysocki, Len Brown, Andy Shevchenko, Mika Westerberg,
	MyungJoo Ham, Chanwoo Choi, Chen-Yu Tsai, Thierry Reding,
	Linux PWM List, ACPI Devel Maling List, Linux Kernel Mailing List

Hi,

On 15-01-18 00:36, Rafael J. Wysocki wrote:
> On Sun, Jan 14, 2018 at 9:01 PM, Hans de Goede <hdegoede@redhat.com> wrote:
>> acpi_lpss_create_device() skips handling LPSS devices which do not have
>> a mmio resources in their resource list (typically these devices are
>> disabled by the firmware). But since the LPSS code does not bind to the
>> device, acpi_bus_attach() ends up still creating a platform device for
>> it and the regular platform_driver for the ACPI HID still tries to bind
>> to it.
>>
>> This happens e.g. on some boards which do not use the pwm-controller
>> and have an empty or invalid resource-table for it. Currently this causes
>> these error messages to get logged:
>> [    3.281966] pwm-lpss 80862288:00: invalid resource
>> [    3.287098] pwm-lpss: probe of 80862288:00 failed with error -22
>>
>> This commit stops the undesirable creation of a platform_device for
>> disabled LPSS devices by setting pnp.type.platform_id to 0. Note that
>> acpi_scan_attach_handler() also sets pnp.type.platform_id to 0 when there
>> is a matching handler for the device and that handler has no attach
>> callback, so we simply behave as a handler without an attach function
>> in this case.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> Does this fix new behavior or is it an old issue?

The problem this addresses is likely caused by the acpi_always_present
entry for the CHT 80862288 PWM devices in drivers/acpi/x86/utils.c.

The problem is that under Windows the Intel GPU driver has hardcoded
addresses for the PWM LPSS bits (or so I believe), rather then having
it as a separate device with a separate driver, so the CHT LPSS PWM
device's _STA returns 0 on all x86 devices which ship with Windows.

On most CHT laptops / tablets it is used to control the backlight
brightness so we do need the device under Linux, where we've a
separate PWM driver and we don't want to be hardcoding stuff like
this.

So we really cannot do without the acpi_always_present entry, and thus
need this extra check for devices where the pwm is actually unused
and disabled by the firmware.

Regards,

Hans

>> ---
>>   drivers/acpi/acpi_lpss.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
>> index 9cfe6b71078b..166a8e582d96 100644
>> --- a/drivers/acpi/acpi_lpss.c
>> +++ b/drivers/acpi/acpi_lpss.c
>> @@ -610,6 +610,8 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
>>          acpi_dev_free_resource_list(&resource_list);
>>
>>          if (!pdata->mmio_base) {
>> +               /* Avoid acpi_bus_attach() instantiating a pdev for this dev. */
>> +               adev->pnp.type.platform_id = 0;
>>                  /* Skip the device, but continue the namespace scan. */
>>                  ret = 0;
>>                  goto err_out;
>> --
>> 2.14.3
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI / LPSS: Do not instiate a platform_dev for devs without a mmio resource
  2018-01-14 20:01 [PATCH] ACPI / LPSS: Do not instiate a platform_dev for devs without a mmio resource Hans de Goede
  2018-01-14 23:36 ` Rafael J. Wysocki
@ 2018-01-15  9:36 ` Mika Westerberg
  2018-01-15 11:33   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Mika Westerberg @ 2018-01-15  9:36 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Len Brown, Andy Shevchenko, MyungJoo Ham,
	Chanwoo Choi, Chen-Yu Tsai, Thierry Reding, linux-pwm, linux-acpi,
	linux-kernel

On Sun, Jan 14, 2018 at 09:01:48PM +0100, Hans de Goede wrote:
> acpi_lpss_create_device() skips handling LPSS devices which do not have
> a mmio resources in their resource list (typically these devices are
> disabled by the firmware). But since the LPSS code does not bind to the
> device, acpi_bus_attach() ends up still creating a platform device for
> it and the regular platform_driver for the ACPI HID still tries to bind
> to it.
> 
> This happens e.g. on some boards which do not use the pwm-controller
> and have an empty or invalid resource-table for it. Currently this causes
> these error messages to get logged:
> [    3.281966] pwm-lpss 80862288:00: invalid resource
> [    3.287098] pwm-lpss: probe of 80862288:00 failed with error -22
> 
> This commit stops the undesirable creation of a platform_device for
> disabled LPSS devices by setting pnp.type.platform_id to 0. Note that
> acpi_scan_attach_handler() also sets pnp.type.platform_id to 0 when there
> is a matching handler for the device and that handler has no attach
> callback, so we simply behave as a handler without an attach function
> in this case.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Seems like a good way to fix it IMHO,

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI / LPSS: Do not instiate a platform_dev for devs without a mmio resource
  2018-01-15  9:36 ` Mika Westerberg
@ 2018-01-15 11:33   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-01-15 11:33 UTC (permalink / raw)
  To: Mika Westerberg, Hans de Goede
  Cc: Rafael J . Wysocki, Len Brown, MyungJoo Ham, Chanwoo Choi,
	Chen-Yu Tsai, Thierry Reding, linux-pwm, linux-acpi, linux-kernel

On Mon, 2018-01-15 at 11:36 +0200, Mika Westerberg wrote:
> On Sun, Jan 14, 2018 at 09:01:48PM +0100, Hans de Goede wrote:
> > acpi_lpss_create_device() skips handling LPSS devices which do not
> > have
> > a mmio resources in their resource list (typically these devices are
> > disabled by the firmware). But since the LPSS code does not bind to
> > the
> > device, acpi_bus_attach() ends up still creating a platform device
> > for
> > it and the regular platform_driver for the ACPI HID still tries to
> > bind
> > to it.
> > 
> > This happens e.g. on some boards which do not use the pwm-controller
> > and have an empty or invalid resource-table for it. Currently this
> > causes
> > these error messages to get logged:
> > [    3.281966] pwm-lpss 80862288:00: invalid resource
> > [    3.287098] pwm-lpss: probe of 80862288:00 failed with error -22
> > 
> > This commit stops the undesirable creation of a platform_device for
> > disabled LPSS devices by setting pnp.type.platform_id to 0. Note
> > that
> > acpi_scan_attach_handler() also sets pnp.type.platform_id to 0 when
> > there
> > is a matching handler for the device and that handler has no attach
> > callback, so we simply behave as a handler without an attach
> > function
> > in this case.
> > 
> > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> Seems like a good way to fix it IMHO,

Yeah, looks much better for my opinion than previous hack to PWM
platform driver.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> 
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-15 11:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-14 20:01 [PATCH] ACPI / LPSS: Do not instiate a platform_dev for devs without a mmio resource Hans de Goede
2018-01-14 23:36 ` Rafael J. Wysocki
2018-01-15  8:42   ` Hans de Goede
2018-01-15  9:36 ` Mika Westerberg
2018-01-15 11:33   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).