Skip to contentSkip to conversation

wifi: rtw89: acpi: check for _DSM function support before evaluating it

PATCH Superseded Rosen Penev 2 participants 6 messages Nov 3 – Nov 4 Realtek wireless driver (rtw89)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 wifi: rtw89: acpi: check for _DSM function support before evaluating it

When the WiFi device has no ACPI companion, or the firmware does not implement a given rtw89 _DSM function, rtw89_acpi_evaluate_dsm() calls acpi_evaluate_dsm() anyway. ACPI core then warns on every probe:

ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:10 (0x1001)
ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:6 (0x1001)

Here the handle is NULL, and acpi_evaluate_object() returns AE_BAD_PARAMETER. All callers already treat failure as "no policy provided by the platform", so this is only noise.

Bail out early when there is no ACPI handle, as acpi_check_dsm() would otherwise hit the same warning while querying function 0. Then use acpi_check_dsm() so that functions the firmware does not advertise fail quietly at debug level, as rtw89_acpi_evaluate_method() already does.

Seen on an RTL8852BE in a desktop PCIe slot.

---
v2: check handle separately. Remove Fixes.

 drivers/net/wireless/realtek/rtw89/acpi.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/acpi.c +13 -2
index ebb6cf555747..3396d42594b3 100644
@@ -372,11 +372,22 @@ int rtw89_acpi_evaluate_dsm(struct rtw89_dev *rtwdev,
 			    enum rtw89_acpi_dsm_func func,
 			    struct rtw89_acpi_dsm_result *res)
 {
+	acpi_handle handle = ACPI_HANDLE(rtwdev->dev);
 	union acpi_object *obj;
 	int ret;
 
-	obj = acpi_evaluate_dsm(ACPI_HANDLE(rtwdev->dev), &rtw89_guid,
-				0, func, NULL);
+	if (!handle) {
+		rtw89_debug(rtwdev, RTW89_DBG_ACPI, "acpi dsm no handle\n");
+		return -ENODEV;
+	}
+
+	if (!acpi_check_dsm(handle, &rtw89_guid, 0, BIT(func))) {
+		rtw89_debug(rtwdev, RTW89_DBG_ACPI,
+			    "acpi dsm func %d not supported\n", func);
+		return -ENOENT;
+	}
+
+	obj = acpi_evaluate_dsm(handle, &rtw89_guid, 0, func, NULL);
 	if (!obj) {
 		rtw89_debug(rtwdev, RTW89_DBG_ACPI,
 			    "acpi dsm fail to evaluate func: %d\n", func);
Signature · 1 line
2.56.0
maintainer
#1 lore raw
Quoted 7 lines · Rosen Penev

When the WiFi device has no ACPI companion, or the firmware does not implement a given rtw89 _DSM function, rtw89_acpi_evaluate_dsm() calls acpi_evaluate_dsm() anyway. ACPI core then warns on every probe:

ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:10 (0x1001)
ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:6 (0x1001)

Quoted 8 lines

Here the handle is NULL, and acpi_evaluate_object() returns AE_BAD_PARAMETER. All callers already treat failure as "no policy provided by the platform", so this is only noise.

Bail out early when there is no ACPI handle, as acpi_check_dsm() would otherwise hit the same warning while querying function 0. Then use acpi_check_dsm() so that functions the firmware does not advertise fail quietly at debug level, as rtw89_acpi_evaluate_method() already does.

Adding this check is fine to me. But my question in v1 is that acpi_check_dsm() checks func 0 to determine if BIT(func) is existing. Is it possible func 0 not existing, but BIT(func) existing?

Quoted 40 lines

Seen on an RTL8852BE in a desktop PCIe slot.

---
v2: check handle separately. Remove Fixes.

 drivers/net/wireless/realtek/rtw89/acpi.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/acpi.c +13 -3
index ebb6cf555747..3396d42594b3 100644
@@ -372,11 +372,22 @@ int rtw89_acpi_evaluate_dsm(struct rtw89_dev *rtwdev,
                            enum rtw89_acpi_dsm_func func,
                            struct rtw89_acpi_dsm_result *res)
 {
+       acpi_handle handle = ACPI_HANDLE(rtwdev->dev);
        union acpi_object *obj;
        int ret;
 
-       obj = acpi_evaluate_dsm(ACPI_HANDLE(rtwdev->dev), &rtw89_guid,
-                               0, func, NULL);
+       if (!handle) {
+               rtw89_debug(rtwdev, RTW89_DBG_ACPI, "acpi dsm no handle\n");
+               return -ENODEV;
+       }
+
+       if (!acpi_check_dsm(handle, &rtw89_guid, 0, BIT(func))) {
+               rtw89_debug(rtwdev, RTW89_DBG_ACPI,
+                           "acpi dsm func %d not supported\n", func);
+               return -ENOENT;
+       }
+
+       obj = acpi_evaluate_dsm(handle, &rtw89_guid, 0, func, NULL);
        if (!obj) {
                rtw89_debug(rtwdev, RTW89_DBG_ACPI,
                            "acpi dsm fail to evaluate func: %d\n", func);
--

2.56.0

#2 lore raw
Quoted 13 lines · Ping-Ke Shih
Quoted 11 lines · Rosen Penev

When the WiFi device has no ACPI companion, or the firmware does not implement a given rtw89 _DSM function, rtw89_acpi_evaluate_dsm() calls acpi_evaluate_dsm() anyway. ACPI core then warns on every probe:

ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:10 (0x1001)
ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:6 (0x1001)

Here the handle is NULL, and acpi_evaluate_object() returns AE_BAD_PARAMETER. All callers already treat failure as "no policy provided by the platform", so this is only noise.

Quoted 8 lines
Quoted 4 lines

Bail out early when there is no ACPI handle, as acpi_check_dsm() would otherwise hit the same warning while querying function 0. Then use acpi_check_dsm() so that functions the firmware does not advertise fail quietly at debug level, as rtw89_acpi_evaluate_method() already does.

Adding this check is fine to me. But my question in v1 is that acpi_check_dsm() checks func 0 to determine if BIT(func) is existing. Is it possible func 0 not existing, but BIT(func) existing?

Shouldn't happen, but who knows. I can drop the acpi_check_dsm() part.

7bf2dfccc2dd70821104d15cbab7b6fca21872be

is effectively the same as this.

Note that this specific card was taken out of a laptop and placed in a desktop, hence the warning.

Quoted 42 lines
Quoted 41 lines

Seen on an RTL8852BE in a desktop PCIe slot.

---
v2: check handle separately. Remove Fixes.

 drivers/net/wireless/realtek/rtw89/acpi.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/acpi.c +13 -3
index ebb6cf555747..3396d42594b3 100644
@@ -372,11 +372,22 @@ int rtw89_acpi_evaluate_dsm(struct rtw89_dev *rtwdev,
                            enum rtw89_acpi_dsm_func func,
                            struct rtw89_acpi_dsm_result *res)
 {
+       acpi_handle handle = ACPI_HANDLE(rtwdev->dev);
        union acpi_object *obj;
        int ret;
 
-       obj = acpi_evaluate_dsm(ACPI_HANDLE(rtwdev->dev), &rtw89_guid,
-                               0, func, NULL);
+       if (!handle) {
+               rtw89_debug(rtwdev, RTW89_DBG_ACPI, "acpi dsm no handle\n");
+               return -ENODEV;
+       }
+
+       if (!acpi_check_dsm(handle, &rtw89_guid, 0, BIT(func))) {
+               rtw89_debug(rtwdev, RTW89_DBG_ACPI,
+                           "acpi dsm func %d not supported\n", func);
+               return -ENOENT;
+       }
+
+       obj = acpi_evaluate_dsm(handle, &rtw89_guid, 0, func, NULL);
        if (!obj) {
                rtw89_debug(rtwdev, RTW89_DBG_ACPI,
                            "acpi dsm fail to evaluate func: %d\n", func);
--

2.56.0

maintainer
#3 lore raw
Quoted 19 lines · Rosen Penev
Quoted 18 lines · Ping-Ke Shih
Quoted 15 lines · Rosen Penev

When the WiFi device has no ACPI companion, or the firmware does not implement a given rtw89 _DSM function, rtw89_acpi_evaluate_dsm() calls acpi_evaluate_dsm() anyway. ACPI core then warns on every probe:

ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:10 (0x1001)
ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:6 (0x1001)

Here the handle is NULL, and acpi_evaluate_object() returns AE_BAD_PARAMETER. All callers already treat failure as "no policy provided by the platform", so this is only noise.

Bail out early when there is no ACPI handle, as acpi_check_dsm() would otherwise hit the same warning while querying function 0. Then use acpi_check_dsm() so that functions the firmware does not advertise fail quietly at debug level, as rtw89_acpi_evaluate_method() already does.

Quoted 4 lines
Quoted 3 lines

Adding this check is fine to me. But my question in v1 is that acpi_check_dsm() checks func 0 to determine if BIT(func) is existing. Is it possible func 0 not existing, but BIT(func) existing?

Shouldn't happen, but who knows.

I don't mind taking this patch, but this is the only one point I don't know.

Quoted 1 line

I can drop the acpi_check_dsm() part.

If you drop the part, what will this patch do? almost nothing.

Quoted 4 lines

7bf2dfccc2dd70821104d15cbab7b6fca21872be

is effectively the same as this.

Since rtw89_acpi_evaluate_dsm() is called at probe stage, I don't mind acpi_check_dsm() being called on every call.

Quoted 3 lines

Note that this specific card was taken out of a laptop and placed in a desktop, hence the warning.

So, the warnings really bother you?

#4 lore raw
Quoted 24 lines · Ping-Ke Shih
Quoted 22 lines · Rosen Penev
Quoted 21 lines · Ping-Ke Shih
Quoted 7 lines · Rosen Penev

When the WiFi device has no ACPI companion, or the firmware does not implement a given rtw89 _DSM function, rtw89_acpi_evaluate_dsm() calls acpi_evaluate_dsm() anyway. ACPI core then warns on every probe:

ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:10 (0x1001)
ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:6 (0x1001)

Quoted 8 lines

Here the handle is NULL, and acpi_evaluate_object() returns AE_BAD_PARAMETER. All callers already treat failure as "no policy provided by the platform", so this is only noise.

Bail out early when there is no ACPI handle, as acpi_check_dsm() would otherwise hit the same warning while querying function 0. Then use acpi_check_dsm() so that functions the firmware does not advertise fail quietly at debug level, as rtw89_acpi_evaluate_method() already does.

Adding this check is fine to me. But my question in v1 is that acpi_check_dsm() checks func 0 to determine if BIT(func) is existing. Is it possible func 0 not existing, but BIT(func) existing?

Quoted 7 lines
Quoted 1 line

Shouldn't happen, but who knows.

I don't mind taking this patch, but this is the only one point I don't know.

Quoted 1 line

I can drop the acpi_check_dsm() part.

If you drop the part, what will this patch do? almost nothing.

The !handle check is the big one that silences it.

Quoted 6 lines
Quoted 5 lines

7bf2dfccc2dd70821104d15cbab7b6fca21872be

is effectively the same as this.

Quoted 8 lines

Since rtw89_acpi_evaluate_dsm() is called at probe stage, I don't mind acpi_check_dsm() being called on every call.

Quoted 3 lines

Note that this specific card was taken out of a laptop and placed in a desktop, hence the warning.

So, the warnings really bother you?

Yeah why not.

Quoted 3 lines
maintainer
#5 lore raw
Quoted 25 lines · Rosen Penev
Quoted 24 lines · Ping-Ke Shih
Quoted 22 lines · Rosen Penev
Quoted 21 lines · Ping-Ke Shih
Quoted 7 lines · Rosen Penev

When the WiFi device has no ACPI companion, or the firmware does not implement a given rtw89 _DSM function, rtw89_acpi_evaluate_dsm() calls acpi_evaluate_dsm() anyway. ACPI core then warns on every probe:

ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:10 (0x1001)
ACPI: \: failed to evaluate _DSM e8c3a8d2-694b-004f-82bd-fe8607803aa7 rev:0 func:6 (0x1001)

Quoted 8 lines

Here the handle is NULL, and acpi_evaluate_object() returns AE_BAD_PARAMETER. All callers already treat failure as "no policy provided by the platform", so this is only noise.

Bail out early when there is no ACPI handle, as acpi_check_dsm() would otherwise hit the same warning while querying function 0. Then use acpi_check_dsm() so that functions the firmware does not advertise fail quietly at debug level, as rtw89_acpi_evaluate_method() already does.

Adding this check is fine to me. But my question in v1 is that acpi_check_dsm() checks func 0 to determine if BIT(func) is existing. Is it possible func 0 not existing, but BIT(func) existing?

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

Shouldn't happen, but who knows.

I don't mind taking this patch, but this is the only one point I don't know.

Quoted 1 line

I can drop the acpi_check_dsm() part.

If you drop the part, what will this patch do? almost nothing.

The !handle check is the big one that silences it.

I'm not aware of that. Let's do this only by v3.