linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>,
	Robert Moore <robert.moore@intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
	"Zhang Rui" <rui.zhang@intel.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	kai.heng.feng@canonical.com,
	"Johannes Penßel" <johannespenssel@posteo.net>,
	linux-acpi@vger.kernel.org, devel@acpica.org
Subject: [RFC v3 3/4] ACPI: EC: Fix EC address space handler unregistration
Date: Mon,  3 Oct 2022 16:42:13 +0200	[thread overview]
Message-ID: <20221003144214.345279-4-hdegoede@redhat.com> (raw)
In-Reply-To: <20221003144214.345279-1-hdegoede@redhat.com>

When an ECDT table is present the EC address space handler gets registered
on the root node. So to unregister it properly the unregister call also
must be done on the root node.

Store the ACPI handle used for the acpi_install_address_space_handler()
call and use te same handle for the acpi_remove_address_space_handler()
call.

Reported-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/ec.c       | 4 +++-
 drivers/acpi/internal.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index c95e535035a0..55c503225396 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1479,6 +1479,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;
 	}
 
 	if (!device)
@@ -1530,7 +1531,8 @@ static int ec_install_handlers(struct acpi_ec *ec, struct acpi_device *device)
 static void ec_remove_handlers(struct acpi_ec *ec)
 {
 	if (test_bit(EC_FLAGS_EC_HANDLER_INSTALLED, &ec->flags)) {
-		if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
+		if (ACPI_FAILURE(acpi_remove_address_space_handler(
+					ec->address_space_handler_holder,
 					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);
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 628bf8f18130..dd3bcbefbc06 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -173,6 +173,7 @@ 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;
-- 
2.37.3


  parent reply	other threads:[~2022-10-03 14:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03 14:42 [RFC v3 0/4] ACPI[CA]: fix ECDT EC probe ordering issues Hans de Goede
2022-10-03 14:42 ` [RFC v3 1/4] ACPICA: include/acpi/acpixf.h: Fix indentation Hans de Goede
2022-10-03 14:42 ` [RFC v3 2/4] ACPICA: Allow address_space_handler Install and _REG execution as 2 separate steps Hans de Goede
2022-10-03 14:42 ` Hans de Goede [this message]
2022-10-03 14:42 ` [RFC v3 4/4] ACPI: EC: fix ECDT probe ordering issues Hans de Goede
2022-10-04  8:24   ` Andy Shevchenko
2022-10-04  9:23     ` Hans de Goede
2022-10-13 16:53 ` [RFC v3 0/4] ACPI[CA]: fix ECDT EC " Rafael J. Wysocki
2022-10-13 17:43   ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221003144214.345279-4-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy@kernel.org \
    --cc=devel@acpica.org \
    --cc=johannespenssel@posteo.net \
    --cc=kai.heng.feng@canonical.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael@kernel.org \
    --cc=robert.moore@intel.com \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).