Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'acpi-6.10-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI fixes from Rafael Wysocki:
"These make the ACPI EC driver always install the EC address space
handler at the root of the ACPI namespace which causes it to take care
of all EC operation regions everywhere.

This means that the custom EC address space handler in the WMI driver
is not needed any more and accordingly it gets removed altogether"

* tag 'acpi-6.10-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
platform/x86: wmi: Remove custom EC address space handler
ACPI: EC: Install address space handler at the namespace root

+16 -102
+16 -9
drivers/acpi/ec.c
··· 1482 1482 static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device, 1483 1483 bool call_reg) 1484 1484 { 1485 + acpi_handle scope_handle = ec == first_ec ? ACPI_ROOT_OBJECT : ec->handle; 1485 1486 acpi_status status; 1486 1487 1487 1488 acpi_ec_start(ec, false); 1488 1489 1489 1490 if (!test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { 1490 1491 acpi_ec_enter_noirq(ec); 1491 - status = acpi_install_address_space_handler_no_reg(ec->handle, 1492 + status = acpi_install_address_space_handler_no_reg(scope_handle, 1492 1493 ACPI_ADR_SPACE_EC, 1493 1494 &acpi_ec_space_handler, 1494 1495 NULL, ec); ··· 1498 1497 return -ENODEV; 1499 1498 } 1500 1499 set_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); 1501 - ec->address_space_handler_holder = ec->handle; 1502 1500 } 1503 1501 1504 1502 if (call_reg && !test_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags)) { 1505 - acpi_execute_reg_methods(ec->handle, ACPI_ADR_SPACE_EC); 1503 + acpi_execute_reg_methods(scope_handle, ACPI_ADR_SPACE_EC); 1506 1504 set_bit(EC_FLAGS_EC_REG_CALLED, &ec->flags); 1507 1505 } 1508 1506 ··· 1553 1553 1554 1554 static void ec_remove_handlers(struct acpi_ec *ec) 1555 1555 { 1556 + acpi_handle scope_handle = ec == first_ec ? ACPI_ROOT_OBJECT : ec->handle; 1557 + 1556 1558 if (test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) { 1557 1559 if (ACPI_FAILURE(acpi_remove_address_space_handler( 1558 - ec->address_space_handler_holder, 1559 - ACPI_ADR_SPACE_EC, &acpi_ec_space_handler))) 1560 + scope_handle, 1561 + ACPI_ADR_SPACE_EC, 1562 + &acpi_ec_space_handler))) 1560 1563 pr_err("failed to remove space handler\n"); 1561 1564 clear_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags); 1562 1565 } ··· 1598 1595 { 1599 1596 int ret; 1600 1597 1601 - ret = ec_install_handlers(ec, device, call_reg); 1602 - if (ret) 1603 - return ret; 1604 - 1605 1598 /* First EC capable of handling transactions */ 1606 1599 if (!first_ec) 1607 1600 first_ec = ec; 1601 + 1602 + ret = ec_install_handlers(ec, device, call_reg); 1603 + if (ret) { 1604 + if (ec == first_ec) 1605 + first_ec = NULL; 1606 + 1607 + return ret; 1608 + } 1608 1609 1609 1610 pr_info("EC_CMD/EC_SC=0x%lx, EC_DATA=0x%lx\n", ec->command_addr, 1610 1611 ec->data_addr);
-1
drivers/acpi/internal.h
··· 186 186 187 187 struct acpi_ec { 188 188 acpi_handle handle; 189 - acpi_handle address_space_handler_holder; 190 189 int gpe; 191 190 int irq; 192 191 unsigned long command_addr;
-92
drivers/platform/x86/wmi.c
··· 1153 1153 return 0; 1154 1154 } 1155 1155 1156 - static int ec_read_multiple(u8 address, u8 *buffer, size_t bytes) 1157 - { 1158 - size_t i; 1159 - int ret; 1160 - 1161 - for (i = 0; i < bytes; i++) { 1162 - ret = ec_read(address + i, &buffer[i]); 1163 - if (ret < 0) 1164 - return ret; 1165 - } 1166 - 1167 - return 0; 1168 - } 1169 - 1170 - static int ec_write_multiple(u8 address, u8 *buffer, size_t bytes) 1171 - { 1172 - size_t i; 1173 - int ret; 1174 - 1175 - for (i = 0; i < bytes; i++) { 1176 - ret = ec_write(address + i, buffer[i]); 1177 - if (ret < 0) 1178 - return ret; 1179 - } 1180 - 1181 - return 0; 1182 - } 1183 - 1184 - /* 1185 - * WMI can have EmbeddedControl access regions. In which case, we just want to 1186 - * hand these off to the EC driver. 1187 - */ 1188 - static acpi_status 1189 - acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, 1190 - u32 bits, u64 *value, 1191 - void *handler_context, void *region_context) 1192 - { 1193 - int bytes = bits / BITS_PER_BYTE; 1194 - int ret; 1195 - 1196 - if (!value) 1197 - return AE_NULL_ENTRY; 1198 - 1199 - if (!bytes || bytes > sizeof(*value)) 1200 - return AE_BAD_PARAMETER; 1201 - 1202 - if (address > U8_MAX || address + bytes - 1 > U8_MAX) 1203 - return AE_BAD_PARAMETER; 1204 - 1205 - if (function != ACPI_READ && function != ACPI_WRITE) 1206 - return AE_BAD_PARAMETER; 1207 - 1208 - if (function == ACPI_READ) 1209 - ret = ec_read_multiple(address, (u8 *)value, bytes); 1210 - else 1211 - ret = ec_write_multiple(address, (u8 *)value, bytes); 1212 - 1213 - switch (ret) { 1214 - case -EINVAL: 1215 - return AE_BAD_PARAMETER; 1216 - case -ENODEV: 1217 - return AE_NOT_FOUND; 1218 - case -ETIME: 1219 - return AE_TIME; 1220 - case 0: 1221 - return AE_OK; 1222 - default: 1223 - return AE_ERROR; 1224 - } 1225 - } 1226 - 1227 1156 static int wmi_get_notify_data(struct wmi_block *wblock, union acpi_object **obj) 1228 1157 { 1229 1158 struct acpi_buffer data = { ACPI_ALLOCATE_BUFFER, NULL }; ··· 1267 1338 acpi_remove_notify_handler(acpi_device->handle, ACPI_ALL_NOTIFY, acpi_wmi_notify_handler); 1268 1339 } 1269 1340 1270 - static void acpi_wmi_remove_address_space_handler(void *data) 1271 - { 1272 - struct acpi_device *acpi_device = data; 1273 - 1274 - acpi_remove_address_space_handler(acpi_device->handle, ACPI_ADR_SPACE_EC, 1275 - &acpi_wmi_ec_space_handler); 1276 - } 1277 - 1278 1341 static void acpi_wmi_remove_bus_device(void *data) 1279 1342 { 1280 1343 struct device *wmi_bus_dev = data; ··· 1297 1376 return error; 1298 1377 1299 1378 dev_set_drvdata(&device->dev, wmi_bus_dev); 1300 - 1301 - status = acpi_install_address_space_handler(acpi_device->handle, 1302 - ACPI_ADR_SPACE_EC, 1303 - &acpi_wmi_ec_space_handler, 1304 - NULL, NULL); 1305 - if (ACPI_FAILURE(status)) { 1306 - dev_err(&device->dev, "Error installing EC region handler\n"); 1307 - return -ENODEV; 1308 - } 1309 - error = devm_add_action_or_reset(&device->dev, acpi_wmi_remove_address_space_handler, 1310 - acpi_device); 1311 - if (error < 0) 1312 - return error; 1313 1379 1314 1380 status = acpi_install_notify_handler(acpi_device->handle, ACPI_ALL_NOTIFY, 1315 1381 acpi_wmi_notify_handler, wmi_bus_dev);