Commit a8d22396 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

PNP / ACPI: Do not return errors if _DIS or _SRS are not present

The ACPI PNP subsystem returns errors from pnpacpi_set_resources()
and pnpacpi_disable_resources() if the _SRS or _DIS methods are not
present, respectively, but it should not do that, because those
methods are optional.  For this reason, modify pnpacpi_set_resources()
and pnpacpi_disable_resources(), respectively, to ignore missing _SRS
or _DIS.

This problem has been uncovered by commit 202317a5 (ACPI / scan:
Add acpi_device objects for all device nodes in the namespace) and
manifested itself by causing serial port suspend to fail on some
systems.

Fixes: 202317a5 (ACPI / scan: Add acpi_device objects for all device nodes in the namespace)
References: https://bugzilla.kernel.org/show_bug.cgi?id=74371Reported-by: default avatarwxg4net <wxg4net@gmail.com>
Reported-and-tested-by: <nonproffessional@gmail.com>
Cc: 3.14+ <stable@vger.kernel.org> # 3.14+
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent b3413afb
...@@ -83,8 +83,7 @@ static int pnpacpi_set_resources(struct pnp_dev *dev) ...@@ -83,8 +83,7 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
{ {
struct acpi_device *acpi_dev; struct acpi_device *acpi_dev;
acpi_handle handle; acpi_handle handle;
struct acpi_buffer buffer; int ret = 0;
int ret;
pnp_dbg(&dev->dev, "set resources\n"); pnp_dbg(&dev->dev, "set resources\n");
...@@ -97,19 +96,26 @@ static int pnpacpi_set_resources(struct pnp_dev *dev) ...@@ -97,19 +96,26 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
if (WARN_ON_ONCE(acpi_dev != dev->data)) if (WARN_ON_ONCE(acpi_dev != dev->data))
dev->data = acpi_dev; dev->data = acpi_dev;
if (acpi_has_method(handle, METHOD_NAME__SRS)) {
struct acpi_buffer buffer;
ret = pnpacpi_build_resource_template(dev, &buffer); ret = pnpacpi_build_resource_template(dev, &buffer);
if (ret) if (ret)
return ret; return ret;
ret = pnpacpi_encode_resources(dev, &buffer); ret = pnpacpi_encode_resources(dev, &buffer);
if (ret) { if (!ret) {
acpi_status status;
status = acpi_set_current_resources(handle, &buffer);
if (ACPI_FAILURE(status))
ret = -EIO;
}
kfree(buffer.pointer); kfree(buffer.pointer);
return ret;
} }
if (ACPI_FAILURE(acpi_set_current_resources(handle, &buffer))) if (!ret && acpi_bus_power_manageable(handle))
ret = -EINVAL;
else if (acpi_bus_power_manageable(handle))
ret = acpi_bus_set_power(handle, ACPI_STATE_D0); ret = acpi_bus_set_power(handle, ACPI_STATE_D0);
kfree(buffer.pointer);
return ret; return ret;
} }
...@@ -117,7 +123,7 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev) ...@@ -117,7 +123,7 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
{ {
struct acpi_device *acpi_dev; struct acpi_device *acpi_dev;
acpi_handle handle; acpi_handle handle;
int ret; acpi_status status;
dev_dbg(&dev->dev, "disable resources\n"); dev_dbg(&dev->dev, "disable resources\n");
...@@ -128,13 +134,15 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev) ...@@ -128,13 +134,15 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
} }
/* acpi_unregister_gsi(pnp_irq(dev, 0)); */ /* acpi_unregister_gsi(pnp_irq(dev, 0)); */
ret = 0;
if (acpi_bus_power_manageable(handle)) if (acpi_bus_power_manageable(handle))
acpi_bus_set_power(handle, ACPI_STATE_D3_COLD); acpi_bus_set_power(handle, ACPI_STATE_D3_COLD);
/* continue even if acpi_bus_set_power() fails */ /* continue even if acpi_bus_set_power() fails */
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL))) status = acpi_evaluate_object(handle, "_DIS", NULL, NULL);
ret = -ENODEV; if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
return ret; return -ENODEV;
return 0;
} }
#ifdef CONFIG_ACPI_SLEEP #ifdef CONFIG_ACPI_SLEEP
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment