Missing default handler for the EmbeddedControl OpRegion
Subsystems (2)
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.
Br,
Signature · 1 line
heikki
Am 29.04.24 um 16:54 schrieb Heikki Krogerus:
Quoted 14 lines
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.
Quoted 2 lines
Br,
Hi,
i support your proposal, but i think we first have to figure out how Windows handles such cases. Those devices are build for and tested with Windows only, so Windows seems to specify some behavior which allows for this.
I will try to contact Microsoft and ask them how the Windows Kernel handles this OpRegions.
Thanks,
Armin Wolf
Rafael J. Wysocki
maintainerHi,
Quoted 6 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789
And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.
AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Thanks!
Quoted 25 lines · Rafael J. Wysocki
Hi,
Quoted 6 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.
Quoted 5 lines
AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Okay, thank you for the explanation. So can we simply change it like this (I may have still misunderstood something)?
drivers/acpi/ec.c +2 -2
@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);
@@ -1497,7 +1497,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,return -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; + ec->address_space_handler_holder =ACPI_ROOT_OBJECT ; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) {
thanks,
Signature · 1 line
heikki
[Resending because it appears to have got lost, sorry for duplicates.]
Quoted 26 lines · CEST Heikki Krogerus
Quoted 25 lines · Rafael J. Wysocki
Hi,
Quoted 6 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.
Quoted 8 lines
Quoted 5 lines
AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Okay, thank you for the explanation. So can we simply change it like this (I may have still misunderstood something)?
Roughly speaking, yes, but it is missing an analogous change around the removal.
Please see the appended patch (which I have created independently in the meantime). It doesn't break stuff for me and Andy points out that there are examples of EmbeddedControl OpRegions outside the EC device scope in the spec (see Section 9.17.15 in ACPI 6.5, for instance).
So I think that this change can be made relatively safely (but adding Hans and Mario to the CC in case they know something that might be broken by it).
Quoted 15 lines
drivers/acpi/ec.c +1
-1@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);
drivers/acpi/ec.c static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device, · line 1503
Quoted 8 lines
drivers/acpi/ec.c +1
-1@@ -1497,7 +1497,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,return -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; + ec->address_space_handler_holder =ACPI_ROOT_OBJECT ; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) {
--- drivers/acpi/ec.c | 10 +++++----- drivers/acpi/internal.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/acpi/ec.c +5 -5
@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acif (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);
@@ -1497,11 +1497,10 @@ static int ec_install_handlers(struct acreturn -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) { -acpi_execute_reg_methods (ec->handle,ACPI_ADR_SPACE_EC ); +acpi_execute_reg_methods (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC );set_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags); }
@@ -1555,8 +1554,9 @@ static void ec_remove_handlers(struct ac {if (test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {if (ACPI_FAILURE (acpi_remove_address_space_handler ( - ec->address_space_handler_holder, -ACPI_ADR_SPACE_EC , &acpi_ec_space_handler))) +ACPI_ROOT_OBJECT , +ACPI_ADR_SPACE_EC , + &acpi_ec_space_handler)))pr_err ("failed to remove space handler\n" );clear_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); }
drivers/acpi/internal.h +0 -1
@@ -186,7 +186,6 @@ enum acpi_ec_event_state {struct acpi_ec {acpi_handle handle; -acpi_handle address_space_handler_holder;int gpe;int irq;unsigned long command_addr;
Rafael J. Wysocki
maintainerQuoted 36 lines · Rafael J. Wysocki
[Resending because it appears to have got lost, sorry for duplicates.]
Quoted 32 lines · CEST Heikki Krogerus
Quoted 30 lines · Rafael J. Wysocki
Hi,
Quoted 6 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Quoted 5 lines
Quoted 2 lines
Okay, thank you for the explanation. So can we simply change it like this (I may have still misunderstood something)?
Roughly speaking, yes, but it is missing an analogous change around the removal.
Actually, not around the removal, but around the evaluation of _REG methods and dropping address_space_handler_holder is better IMO, because it will always be ACPI_ROOT_OBJECT now.
Quoted 91 lines
Please see the appended patch (which I have created independently in the meantime). It doesn't break stuff for me and Andy points out that there are examples of EmbeddedControl OpRegions outside the EC device scope in the spec (see Section 9.17.15 in ACPI 6.5, for instance).
So I think that this change can be made relatively safely (but adding Hans and Mario to the CC in case they know something that might be broken by it).
Quoted 15 lines
drivers/acpi/ec.c +1
-1@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);drivers/acpi/ec.c static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device, · line 1503
Quoted 8 lines
drivers/acpi/ec.c +1
-1@@ -1497,7 +1497,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,return -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; + ec->address_space_handler_holder =ACPI_ROOT_OBJECT ; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) {--- drivers/acpi/ec.c | 10 +++++----- drivers/acpi/internal.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-)Index:
linux-pm/drivers/acpi/ec.c
===================================================================drivers/acpi/ec.c +5
-5@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acif (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);@@ -1497,11 +1497,10 @@ static int ec_install_handlers(struct acreturn -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) { -acpi_execute_reg_methods (ec->handle,ACPI_ADR_SPACE_EC ); +acpi_execute_reg_methods (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC );set_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags); }@@ -1555,8 +1554,9 @@ static void ec_remove_handlers(struct ac {if (test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {if (ACPI_FAILURE (acpi_remove_address_space_handler ( - ec->address_space_handler_holder, -ACPI_ADR_SPACE_EC , &acpi_ec_space_handler))) +ACPI_ROOT_OBJECT , +ACPI_ADR_SPACE_EC , + &acpi_ec_space_handler)))pr_err ("failed to remove space handler\n" );clear_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); }Index:
linux-pm/drivers/acpi/internal.h
===================================================================drivers/acpi/internal.h +0
-1@@ -186,7 +186,6 @@ enum acpi_ec_event_state {struct acpi_ec {acpi_handle handle; -acpi_handle address_space_handler_holder;int gpe;int irq;unsigned long command_addr;
Quoted 41 lines · Rafael J. Wysocki
[Resending because it appears to have got lost, sorry for duplicates.]
Quoted 26 lines · CEST Heikki Krogerus
Quoted 25 lines · Rafael J. Wysocki
Hi,
Quoted 6 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.Quoted 8 lines
Quoted 5 lines
AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Okay, thank you for the explanation. So can we simply change it like this (I may have still misunderstood something)?
Roughly speaking, yes, but it is missing an analogous change around the removal.
Quoted 7 lines
Please see the appended patch (which I have created independently in the meantime). It doesn't break stuff for me and Andy points out that there are examples of EmbeddedControl OpRegions outside the EC device scope in the spec (see Section 9.17.15 in ACPI 6.5, for instance).
So I think that this change can be made relatively safely (but adding Hans and Mario to the CC in case they know something that might be broken by it).
Nothing jumps out at me, it looks like a good way to handle this issue.
Quoted 83 lines
Quoted 17 lines
drivers/acpi/ec.c +1
-1@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);drivers/acpi/ec.c static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device, · line 1503
Quoted 8 lines
drivers/acpi/ec.c +1
-1@@ -1497,7 +1497,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,return -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; + ec->address_space_handler_holder =ACPI_ROOT_OBJECT ; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) {--- drivers/acpi/ec.c | 10 +++++----- drivers/acpi/internal.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-)Index:
linux-pm/drivers/acpi/ec.c
===================================================================drivers/acpi/ec.c +5
-5@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acif (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);@@ -1497,11 +1497,10 @@ static int ec_install_handlers(struct acreturn -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) { -acpi_execute_reg_methods (ec->handle,ACPI_ADR_SPACE_EC ); +acpi_execute_reg_methods (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC );set_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags); }@@ -1555,8 +1554,9 @@ static void ec_remove_handlers(struct ac {if (test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {if (ACPI_FAILURE (acpi_remove_address_space_handler ( - ec->address_space_handler_holder, -ACPI_ADR_SPACE_EC , &acpi_ec_space_handler))) +ACPI_ROOT_OBJECT , +ACPI_ADR_SPACE_EC , + &acpi_ec_space_handler)))pr_err ("failed to remove space handler\n" );clear_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); }Index:
linux-pm/drivers/acpi/internal.h
===================================================================drivers/acpi/internal.h +0
-1@@ -186,7 +186,6 @@ enum acpi_ec_event_state {struct acpi_ec {acpi_handle handle; -acpi_handle address_space_handler_holder;int gpe;int irq;unsigned long command_addr;
Hi Rafael,
Quoted 41 lines · Rafael J. Wysocki
[Resending because it appears to have got lost, sorry for duplicates.]
Quoted 26 lines · CEST Heikki Krogerus
Quoted 25 lines · Rafael J. Wysocki
Hi,
Quoted 6 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.Quoted 8 lines
Quoted 5 lines
AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Okay, thank you for the explanation. So can we simply change it like this (I may have still misunderstood something)?
Roughly speaking, yes, but it is missing an analogous change around the removal.
Quoted 7 lines
Please see the appended patch (which I have created independently in the meantime). It doesn't break stuff for me and Andy points out that there are examples of EmbeddedControl OpRegions outside the EC device scope in the spec (see Section 9.17.15 in ACPI 6.5, for instance).
So I think that this change can be made relatively safely (but adding Hans and Mario to the CC in case they know something that might be broken by it).
+Cc Armin for WMI EC handler
No objections from me against registering the EC handler at the root, when I saw that the WMI driver was registering its own handler I was already wondering why we did not just register the acpi/ec.c handler at the root level but I did not have time to pursue this further.
One question which I have is does the drivers/acpi/ec.c version handle read/writes of a width other then 8 bits ? Armin recently added support for other widths to the WMI version of the OpRegion handler to fix issues on some laptop models:
Regards,
Hans
Quoted 81 lines
Quoted 15 lines
drivers/acpi/ec.c +1
-1@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);drivers/acpi/ec.c static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device, · line 1503
Quoted 8 lines
drivers/acpi/ec.c +1
-1@@ -1497,7 +1497,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,return -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; + ec->address_space_handler_holder =ACPI_ROOT_OBJECT ; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) {--- drivers/acpi/ec.c | 10 +++++----- drivers/acpi/internal.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-)Index:
linux-pm/drivers/acpi/ec.c
===================================================================drivers/acpi/ec.c +5
-5@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acif (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);@@ -1497,11 +1497,10 @@ static int ec_install_handlers(struct acreturn -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) { -acpi_execute_reg_methods (ec->handle,ACPI_ADR_SPACE_EC ); +acpi_execute_reg_methods (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC );set_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags); }@@ -1555,8 +1554,9 @@ static void ec_remove_handlers(struct ac {if (test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {if (ACPI_FAILURE (acpi_remove_address_space_handler ( - ec->address_space_handler_holder, -ACPI_ADR_SPACE_EC , &acpi_ec_space_handler))) +ACPI_ROOT_OBJECT , +ACPI_ADR_SPACE_EC , + &acpi_ec_space_handler)))pr_err ("failed to remove space handler\n" );clear_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); }Index:
linux-pm/drivers/acpi/internal.h
===================================================================drivers/acpi/internal.h +0
-1@@ -186,7 +186,6 @@ enum acpi_ec_event_state {struct acpi_ec {acpi_handle handle; -acpi_handle address_space_handler_holder;int gpe;int irq;unsigned long command_addr;
Am 09.05.24 um 12:35 schrieb Hans de Goede:
Quoted 58 lines
Hi Rafael,
Quoted 36 lines · Rafael J. Wysocki
[Resending because it appears to have got lost, sorry for duplicates.]
Quoted 23 lines · CEST Heikki Krogerus
Quoted 22 lines · Rafael J. Wysocki
Hi,
Quoted 5 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.Quoted 7 lines
Quoted 5 lines
AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Okay, thank you for the explanation. So can we simply change it like this (I may have still misunderstood something)?
Roughly speaking, yes, but it is missing an analogous change around the removal.
Quoted 7 lines
Please see the appended patch (which I have created independently in the meantime). It doesn't break stuff for me and Andy points out that there are examples of EmbeddedControl OpRegions outside the EC device scope in the spec (see Section 9.17.15 in ACPI 6.5, for instance).
So I think that this change can be made relatively safely (but adding Hans and Mario to the CC in case they know something that might be broken by it).
+Cc Armin for WMI EC handler
No objections from me against registering the EC handler at the root, when I saw that the WMI driver was registering its own handler I was already wondering why we did not just register the
acpi/ec.chandler at the root level but I did not have time to pursue this further.One question which I have is does the
drivers/acpi/ec.cversion handle read/writes of a width other then 8 bits ? Armin recently added support for other widths to the WMI version of the OpRegion handler to fix issues on some laptop models:
Quoted 5 lines
Regards,
Hans
Hi,
the handling of multi-byte reads/writes was taken from the ec driver itself, so using the standard ec handler should make no difference for the WMI driver.
Thanks,
Armin Wolf
Quoted 80 lines
Quoted 80 lines
Quoted 15 lines
drivers/acpi/ec.c +1
-1@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);drivers/acpi/ec.c static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device, · line 1503
Quoted 8 lines
drivers/acpi/ec.c +1
-1@@ -1497,7 +1497,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,return -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; + ec->address_space_handler_holder =ACPI_ROOT_OBJECT ; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) {--- drivers/acpi/ec.c | 10 +++++----- drivers/acpi/internal.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-)Index:
linux-pm/drivers/acpi/ec.c
===================================================================drivers/acpi/ec.c +5
-5@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acif (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);@@ -1497,11 +1497,10 @@ static int ec_install_handlers(struct acreturn -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) { -acpi_execute_reg_methods (ec->handle,ACPI_ADR_SPACE_EC ); +acpi_execute_reg_methods (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC );set_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags); }@@ -1555,8 +1554,9 @@ static void ec_remove_handlers(struct ac {if (test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {if (ACPI_FAILURE (acpi_remove_address_space_handler ( - ec->address_space_handler_holder, -ACPI_ADR_SPACE_EC , &acpi_ec_space_handler))) +ACPI_ROOT_OBJECT , +ACPI_ADR_SPACE_EC , + &acpi_ec_space_handler)))pr_err ("failed to remove space handler\n" );clear_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); }Index:
linux-pm/drivers/acpi/internal.h
===================================================================drivers/acpi/internal.h +0
-1@@ -186,7 +186,6 @@ enum acpi_ec_event_state {struct acpi_ec {acpi_handle handle; -acpi_handle address_space_handler_holder;int gpe;int irq;unsigned long command_addr;
Rafael J. Wysocki
maintainerQuoted 63 lines · Armin Wolf
Am 09.05.24 um 12:35 schrieb Hans de Goede:
Quoted 60 lines
Hi Rafael,
Quoted 36 lines · Rafael J. Wysocki
[Resending because it appears to have got lost, sorry for duplicates.]
Quoted 23 lines · CEST Heikki Krogerus
Quoted 22 lines · Rafael J. Wysocki
Hi,
Quoted 5 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.Quoted 7 lines
Quoted 5 lines
AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Okay, thank you for the explanation. So can we simply change it like this (I may have still misunderstood something)?
Roughly speaking, yes, but it is missing an analogous change around the removal.
Quoted 7 lines
Please see the appended patch (which I have created independently in the meantime). It doesn't break stuff for me and Andy points out that there are examples of EmbeddedControl OpRegions outside the EC device scope in the spec (see Section 9.17.15 in ACPI 6.5, for instance).
So I think that this change can be made relatively safely (but adding Hans and Mario to the CC in case they know something that might be broken by it).
+Cc Armin for WMI EC handler
No objections from me against registering the EC handler at the root, when I saw that the WMI driver was registering its own handler I was already wondering why we did not just register the
acpi/ec.chandler at the root level but I did not have time to pursue this further.One question which I have is does the
drivers/acpi/ec.cversion handle read/writes of a width other then 8 bits ? Armin recently added support for other widths to the WMI version of the OpRegion handler to fix issues on some laptop models:
Quoted 8 lines
Quoted 3 lines
Regards,
Hans
Hi,
the handling of multi-byte reads/writes was taken from the ec driver itself, so using the standard ec handler should make no difference for the WMI driver.
Thanks for the confirmation!
So AFAICS acpi_wmi_ec_space_handler() will not be necessary after this change, but so long as it is installed by acpi_wmi_probe(), it will be used for opregions in the WMI device scope, so I'd prefer to remove it in a separate patch to avoid making too many changes in one go.
Let me add a changelog to the patch posted here
https://lore.kernel.org/linux-acpi/5781917.DvuYhMxLoT@kreacher/
and submit it properly along with a separate change removing acpi_wmi_ec_space_handler().
Hi,
Quoted 73 lines · Rafael J. Wysocki
Quoted 63 lines · Armin Wolf
Am 09.05.24 um 12:35 schrieb Hans de Goede:
Quoted 60 lines
Hi Rafael,
Quoted 36 lines · Rafael J. Wysocki
[Resending because it appears to have got lost, sorry for duplicates.]
Quoted 23 lines · CEST Heikki Krogerus
Quoted 22 lines · Rafael J. Wysocki
Hi,
Quoted 5 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.Quoted 7 lines
Quoted 5 lines
AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Okay, thank you for the explanation. So can we simply change it like this (I may have still misunderstood something)?
Roughly speaking, yes, but it is missing an analogous change around the removal.
Quoted 7 lines
Please see the appended patch (which I have created independently in the meantime). It doesn't break stuff for me and Andy points out that there are examples of EmbeddedControl OpRegions outside the EC device scope in the spec (see Section 9.17.15 in ACPI 6.5, for instance).
So I think that this change can be made relatively safely (but adding Hans and Mario to the CC in case they know something that might be broken by it).
+Cc Armin for WMI EC handler
No objections from me against registering the EC handler at the root, when I saw that the WMI driver was registering its own handler I was already wondering why we did not just register the
acpi/ec.chandler at the root level but I did not have time to pursue this further.One question which I have is does the
drivers/acpi/ec.cversion handle read/writes of a width other then 8 bits ? Armin recently added support for other widths to the WMI version of the OpRegion handler to fix issues on some laptop models:Quoted 8 lines
Quoted 3 lines
Regards,
Hans
Hi,
the handling of multi-byte reads/writes was taken from the ec driver itself, so using the standard ec handler should make no difference for the WMI driver.
Quoted 6 lines
Thanks for the confirmation!
So AFAICS
acpi_wmi_ec_space_handler()will not be necessary after this change, but so long as it is installed byacpi_wmi_probe(), it will be used for opregions in the WMI device scope, so I'd prefer to remove it in a separate patch to avoid making too many changes in one go.
Ack.
Quoted 6 lines
Let me add a changelog to the patch posted here
https://lore.kernel.org/linux-acpi/5781917.DvuYhMxLoT@kreacher/
and submit it properly along with a separate change removing
acpi_wmi_ec_space_handler().
This sounds good to me.
Regards,
Hans
Quoted 26 lines · CEST Heikki Krogerus
Quoted 25 lines · Rafael J. Wysocki
Hi,
Quoted 6 lines · Heikki Krogerus
Hi,
There's a bug that is caused by an EmbeddedControl OpRegion which is declared inside the scope of a specific USB Type-C device (PNP0CA0):
https://bugzilla.kernel.org/show_bug.cgi?id=218789And in this bug you are essentially proposing to install the EC OpRegion handler at the namespace root instead of the EC device.
This sounds reasonable, although AFAICS this is a matter of modifying the EC driver (before the EC OpRegion handler is installed by the EC drvier, ACPICA has no way to handle EC address space accesses anyway).
Quoted 6 lines
It looks like that's not the only case where that OpRegion ID is used outside of the EC device scope. There is at least one driver in Linux Kernel (
drivers/platform/x86/wmi.c) that already has a custom handler for the EmbeddedControl OpRegion, and based on a quick search, the problem "Region EmbeddedControl (ID=3) has no handler" has happened with some other devices too.
Quoted 8 lines
Quoted 5 lines
AFAICS, installing the EC address space handler at the EC device object itself is not based on any sound technical arguments, it's just been always done this way in Linux. It's quite possible that the EC address space handler should have been installed at the namespace root from the outset.
Okay, thank you for the explanation. So can we simply change it like this (I may have still misunderstood something)?
Roughly speaking, yes, but it is missing an analogous change around the removal.
Please see the appended patch (which I have created independently in the meantime). It doesn't break stuff for me and Andy points out that there are examples of EmbeddedControl OpRegions outside the EC device scope in the spec (see Section 9.17.15 in ACPI 6.5, for instance).
So I think that this change can be made relatively safely (but adding Hans and Mario to the CC in case they know something that might be broken by it).
Quoted 15 lines
drivers/acpi/ec.c +1
-1@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,if (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);
drivers/acpi/ec.c static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device, · line 1503
Quoted 8 lines
drivers/acpi/ec.c +1
-1@@ -1497,7 +1497,7 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device,return -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; + ec->address_space_handler_holder =ACPI_ROOT_OBJECT ; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) {
--- drivers/acpi/ec.c | 10 +++++----- drivers/acpi/internal.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/acpi/ec.c +5 -5
@@ -1488,7 +1488,7 @@ static int ec_install_handlers(struct acif (!test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {acpi_ec_enter_noirq (ec); - status =acpi_install_address_space_handler_no_reg (ec->handle, + status =acpi_install_address_space_handler_no_reg (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC , &acpi_ec_space_handler,NULL , ec);
@@ -1497,11 +1497,10 @@ static int ec_install_handlers(struct acreturn -ENODEV ; }set_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); - ec->address_space_handler_holder = ec->handle; }if (call_reg && !test_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags)) { -acpi_execute_reg_methods (ec->handle,ACPI_ADR_SPACE_EC ); +acpi_execute_reg_methods (ACPI_ROOT_OBJECT ,ACPI_ADR_SPACE_EC );set_bit (EC_FLAGS_EC_REG_CALLED , &ec->flags); }
@@ -1555,8 +1554,9 @@ static void ec_remove_handlers(struct ac {if (test_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags)) {if (ACPI_FAILURE (acpi_remove_address_space_handler ( - ec->address_space_handler_holder, -ACPI_ADR_SPACE_EC , &acpi_ec_space_handler))) +ACPI_ROOT_OBJECT , +ACPI_ADR_SPACE_EC , + &acpi_ec_space_handler)))pr_err ("failed to remove space handler\n" );clear_bit (EC_FLAGS_EC_HANDLER_INSTALLED , &ec->flags); }
drivers/acpi/internal.h +0 -1
@@ -186,7 +186,6 @@ enum acpi_ec_event_state {struct acpi_ec {acpi_handle handle; -acpi_handle address_space_handler_holder;int gpe;int irq;unsigned long command_addr;