Skip to contentSkip to conversation

ACPI: EC: Abort address space access upon error

PATCH In review Armin Wolf 2 participants 3 messages May 22, 2024 – May 27, 2024 ACPI

lore
Share & tools
lore

Armin Wolf

author
#0 lore raw

PATCH 1/2 ACPI: EC: Abort address space access upon error

Then a multi-byte address space access is requested, acpi_ec_read()/ acpi_ec_write() is being called multiple times.

Abort such operations if a single call to acpi_ec_read()/ acpi_ec_write() fails, as the data read from/written to the EC might be incomplete.

---
 drivers/acpi/ec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +4 -1
index e7793ee9e649..a68dce2147a4 100644
@@ -1333,10 +1333,13 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
 	if (ec->busy_polling || bits > 8)
 		acpi_ec_burst_enable(ec);
 
-	for (i = 0; i < bytes; ++i, ++address, ++value)
+	for (i = 0; i < bytes; ++i, ++address, ++value) {
 		result = (function == ACPI_READ) ?
 			acpi_ec_read(ec, address, value) :
 			acpi_ec_write(ec, address, *value);
+		if (result < 0)
+			break;
+	}
 
 	if (ec->busy_polling || bits > 8)
 		acpi_ec_burst_disable(ec);

--
2.39.2

author
#1 lore raw

PATCH 2/2 ACPI: EC: Avoid returning AE_OK upon unknown error

If an error code other than EINVAL, ENODEV or ETIME is returned by acpi_ec_read()/acpi_ec_write(), then AE_OK is wrongly returned.

Fix this by only returning AE_OK if the return code is 0, and return AE_ERROR otherwise.

---
 drivers/acpi/ec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +3 -1
index a68dce2147a4..68dd17f96f63 100644
@@ -1351,8 +1351,10 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
 		return AE_NOT_FOUND;
 	case -ETIME:
 		return AE_TIME;
-	default:
+	case 0:
 		return AE_OK;
+	default:
+		return AE_ERROR;
 	}
 }
 

--
2.39.2

#2 lore raw

Re: [PATCH 2/2] ACPI: EC: Avoid returning AE_OK upon unknown error

Quoted 19 lines · Armin Wolf

If an error code other than EINVAL, ENODEV or ETIME is returned by acpi_ec_read()/acpi_ec_write(), then AE_OK is wrongly returned.

Fix this by only returning AE_OK if the return code is 0, and return AE_ERROR otherwise.

---
 drivers/acpi/ec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +0 -0
index a68dce2147a4..68dd17f96f63 100644
@@ -1351,8 +1351,10 @@ acpi_ec_space_handler(u32 function, acpi_physical_address address,
                return AE_NOT_FOUND;
        case -ETIME:

drivers/acpi/ec.c acpi_ec_space_handler(u32 function, acpi_physical_address address,

Quoted 10 lines
drivers/acpi/ec.c +3 -2
                return AE_TIME;
-       default:
+       case 0:
                return AE_OK;
+       default:
+               return AE_ERROR;
        }
 }
 
--

Applied (with some edits in the subject and changelog) along with the [1/2] as 6.10-rc material, thanks!