linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] acpi: allow usage of acpi_tad without PRW
@ 2022-12-02 15:34 Bart Groeneveld | GPX Solutions B.V
  2022-12-02 18:04 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Groeneveld | GPX Solutions B.V @ 2022-12-02 15:34 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel
  Cc: Bart Groeneveld | GPX Solutions B.V.

From: "Bart Groeneveld | GPX Solutions B.V." <bart@gpxbv.nl>

Not all tads have the PRW capability, which is totally OK,
according to the ACPI spec [1]:

> _PRW is only required for devices that have the ability to wake
> the system from a system sleeping state.

This partially solves [2] and [3].

[1]: https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf
[2]: https://bugzilla.kernel.org/show_bug.cgi?id=212313
[3]: https://github.com/linux-surface/linux-surface/issues/415

Signed-off-by: Bart Groeneveld | GPX Solutions B.V. <bart@gpxbv.nl>
---
 drivers/acpi/acpi_tad.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c
index e9b8e8305e23..67f71fa4362f 100644
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -604,11 +604,6 @@ static int acpi_tad_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	if (!acpi_has_method(handle, "_PRW")) {
-		dev_info(dev, "Missing _PRW\n");
-		return -ENODEV;
-	}
-
 	dd = devm_kzalloc(dev, sizeof(*dd), GFP_KERNEL);
 	if (!dd)
 		return -ENOMEM;
-- 
2.38.1


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

* Re: [PATCH] acpi: allow usage of acpi_tad without PRW
  2022-12-02 15:34 [PATCH] acpi: allow usage of acpi_tad without PRW Bart Groeneveld | GPX Solutions B.V
@ 2022-12-02 18:04 ` Rafael J. Wysocki
  2022-12-05 15:08   ` [PATCH v2] acpi: allow usage of acpi_tad on HW-reduced platforms Bart Groeneveld | GPX Solutions B.V
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2022-12-02 18:04 UTC (permalink / raw)
  To: Bart Groeneveld | GPX Solutions B.V
  Cc: Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel

On Fri, Dec 2, 2022 at 4:36 PM Bart Groeneveld | GPX Solutions B.V
<bart@gpxbv.nl> wrote:
>
> From: "Bart Groeneveld | GPX Solutions B.V." <bart@gpxbv.nl>
>
> Not all tads have the PRW capability, which is totally OK,
> according to the ACPI spec [1]:
>
> > _PRW is only required for devices that have the ability to wake
> > the system from a system sleeping state.

No, the ACPI TAD definition in Section 9.17 (ACPI 6.5) specifically
requires _PRW to be present unless the system is hardware-reduced.

Anyway, the RTC part can still be supported without _PRW, but then the
wakeup-related attributes should not be present in such cases.

> This partially solves [2] and [3].
>
> [1]: https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf
> [2]: https://bugzilla.kernel.org/show_bug.cgi?id=212313
> [3]: https://github.com/linux-surface/linux-surface/issues/415
>
> Signed-off-by: Bart Groeneveld | GPX Solutions B.V. <bart@gpxbv.nl>
> ---
>  drivers/acpi/acpi_tad.c | 5 -----
>  1 file changed, 5 deletions(-)
>
> diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c
> index e9b8e8305e23..67f71fa4362f 100644
> --- a/drivers/acpi/acpi_tad.c
> +++ b/drivers/acpi/acpi_tad.c
> @@ -604,11 +604,6 @@ static int acpi_tad_probe(struct platform_device *pdev)
>                 return -ENODEV;
>         }
>
> -       if (!acpi_has_method(handle, "_PRW")) {
> -               dev_info(dev, "Missing _PRW\n");
> -               return -ENODEV;
> -       }
> -

This may be sufficient for the RTC part alone to work, but making the
wakeup-related attributes available doesn't really make sense in the
_PRW absent case, so they all should be made optional.

>         dd = devm_kzalloc(dev, sizeof(*dd), GFP_KERNEL);
>         if (!dd)
>                 return -ENOMEM;
> --

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

* [PATCH v2] acpi: allow usage of acpi_tad on HW-reduced platforms
  2022-12-02 18:04 ` Rafael J. Wysocki
@ 2022-12-05 15:08   ` Bart Groeneveld | GPX Solutions B.V
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Groeneveld | GPX Solutions B.V @ 2022-12-05 15:08 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel
  Cc: Bart Groeneveld | GPX Solutions B.V.

From: "Bart Groeneveld | GPX Solutions B.V." <bart@gpxbv.nl>

The specification [1] allows so-called HW-reduced platforms,
which do not implement everything, especially the wakeup related stuff.

In that case, it is still usable as a RTC. This is helpful for [2]
and [3], which is about a device with no other working RTC,
but it does have an HW-reduced TAD, which can be used as a RTC instead.

[1]: https://uefi.org/specs/ACPI/6.5/09_ACPI_Defined_Devices_and_Device_Specific_Objects.html#time-and-alarm-device
[2]: https://bugzilla.kernel.org/show_bug.cgi?id=212313
[3]: https://github.com/linux-surface/linux-surface/issues/415

Signed-off-by: Bart Groeneveld | GPX Solutions B.V. <bart@gpxbv.nl>
---
 drivers/acpi/acpi_tad.c | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/drivers/acpi/acpi_tad.c b/drivers/acpi/acpi_tad.c
index e9b8e8305e23..944276934e7e 100644
--- a/drivers/acpi/acpi_tad.c
+++ b/drivers/acpi/acpi_tad.c
@@ -432,6 +432,14 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR_RO(caps);
 
+static struct attribute *acpi_tad_attrs[] = {
+	&dev_attr_caps.attr,
+	NULL,
+};
+static const struct attribute_group acpi_tad_attr_group = {
+	.attrs	= acpi_tad_attrs,
+};
+
 static ssize_t ac_alarm_store(struct device *dev, struct device_attribute *attr,
 			      const char *buf, size_t count)
 {
@@ -480,15 +488,14 @@ static ssize_t ac_status_show(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR_RW(ac_status);
 
-static struct attribute *acpi_tad_attrs[] = {
-	&dev_attr_caps.attr,
+static struct attribute *acpi_tad_ac_attrs[] = {
 	&dev_attr_ac_alarm.attr,
 	&dev_attr_ac_policy.attr,
 	&dev_attr_ac_status.attr,
 	NULL,
 };
-static const struct attribute_group acpi_tad_attr_group = {
-	.attrs	= acpi_tad_attrs,
+static const struct attribute_group acpi_tad_ac_attr_group = {
+	.attrs	= acpi_tad_ac_attrs,
 };
 
 static ssize_t dc_alarm_store(struct device *dev, struct device_attribute *attr,
@@ -563,13 +570,18 @@ static int acpi_tad_remove(struct platform_device *pdev)
 
 	pm_runtime_get_sync(dev);
 
+	if (dd->capabilities & ACPI_TAD_AC_WAKE)
+		sysfs_remove_group(&dev->kobj, &acpi_tad_ac_attr_group);
+
 	if (dd->capabilities & ACPI_TAD_DC_WAKE)
 		sysfs_remove_group(&dev->kobj, &acpi_tad_dc_attr_group);
 
 	sysfs_remove_group(&dev->kobj, &acpi_tad_attr_group);
 
-	acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER);
-	acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER);
+	if (dd->capabilities & ACPI_TAD_AC_WAKE) {
+		acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER);
+		acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER);
+	}
 	if (dd->capabilities & ACPI_TAD_DC_WAKE) {
 		acpi_tad_disable_timer(dev, ACPI_TAD_DC_TIMER);
 		acpi_tad_clear_status(dev, ACPI_TAD_DC_TIMER);
@@ -604,11 +616,6 @@ static int acpi_tad_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	if (!acpi_has_method(handle, "_PRW")) {
-		dev_info(dev, "Missing _PRW\n");
-		return -ENODEV;
-	}
-
 	dd = devm_kzalloc(dev, sizeof(*dd), GFP_KERNEL);
 	if (!dd)
 		return -ENOMEM;
@@ -637,6 +644,12 @@ static int acpi_tad_probe(struct platform_device *pdev)
 	if (ret)
 		goto fail;
 
+	if (caps & ACPI_TAD_AC_WAKE) {
+		ret = sysfs_create_group(&dev->kobj, &acpi_tad_ac_attr_group);
+		if (ret)
+			goto fail;
+	}
+
 	if (caps & ACPI_TAD_DC_WAKE) {
 		ret = sysfs_create_group(&dev->kobj, &acpi_tad_dc_attr_group);
 		if (ret)
-- 
2.38.1


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

end of thread, other threads:[~2022-12-05 15:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02 15:34 [PATCH] acpi: allow usage of acpi_tad without PRW Bart Groeneveld | GPX Solutions B.V
2022-12-02 18:04 ` Rafael J. Wysocki
2022-12-05 15:08   ` [PATCH v2] acpi: allow usage of acpi_tad on HW-reduced platforms Bart Groeneveld | GPX Solutions B.V

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).