From patchwork Thu Jun 1 13:17:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263757 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C54423423; Thu, 1 Jun 2023 13:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627015; x=1717163015; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xy9OgUL61th3jROVwjpCmagDUUoL2L/+PFsZiahG3m4=; b=k/hFLdDspdeYNgByIMpob5ABSkLTdVRkHMkSujI3O1+BRt22fcupYY76 lAJ8h58oNHKuQWiKeeVvbCB1+I1YBweWZYTqFbi3y3EEjmM0Gaz/I0Rgk 0hmRXbJBoiEybcHY5X21giuE9BH5r1WGCQAv/rVR6gAl1nmmnSHBoxzZg 65Ifd4sLzTyeIErvlnAJ9P478IVx4w0r3NPcQNPAANIfJNK7pd4Fl8Y8e Gv1LIWmOFddh4/t7vC/teRX1r+q9ylltBZP1G9o1ou0m8emUwpSFmxBc/ xzaBINsHlpaE71ZXY54UffAnRd4XiNGxKb9iA1aqjz8HnnFmohQDID3JZ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="421350831" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="421350831" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:17:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="851678057" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="851678057" Received: from hextor.igk.intel.com ([10.123.220.6]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:17:23 -0700 From: Michal Wilczynski To: rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org, lars@metafoo.de, bleung@chromium.org, yu.c.chen@intel.com, hdegoede@redhat.com, markgross@kernel.org, luzmaximilian@gmail.com, corentin.chary@gmail.com, jprvita@gmail.com, cascardo@holoscopio.com, don@syst.com.br, pali@kernel.org, jwoithe@just42.net, matan@svgalib.org, kenneth.t.chan@gmail.com, malattia@linux.it, jeremy@system76.com, productdev@system76.com, herton@canonical.com, coproscefalo@gmail.com, tytso@mit.edu, Jason@zx2c4.com, robert.moore@intel.com Cc: linux-acpi@vger.kernel.org, nvdimm@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, Michal Wilczynski , acpica-devel@lists.linuxfoundation.org Subject: [PATCH v4 01/35] acpi: Adjust functions installing bus event handlers Date: Thu, 1 Jun 2023 15:17:19 +0200 Message-Id: <20230601131719.300720-1-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently acpi_device_install_notify_handler() and acpi_device_remove_notify_handler() always install acpi_notify_device() as a function handler, and only then the real .notify callback gets called. This is not efficient and doesn't provide any real advantage. Introduce new acpi_device_install_event_handler() and acpi_device_remove_event_handler(). Those functions are replacing old installers, and after all drivers switch to the new model, old installers will be removed at the end of the patchset. Make new installer/removal function arguments to take function pointer as an argument instead of using .notify callback. Introduce new variable in struct acpi_device, as fixed events still needs to be handled by an intermediary that would schedule them for later execution. This is due to fixed hardware event handlers being executed in interrupt context. Make acpi_device_install_event_handler() and acpi_device_remove_event_handler() non-static, and export symbols. This will allow the drivers to call them directly, instead of relying on .notify callback. Signed-off-by: Michal Wilczynski --- drivers/acpi/bus.c | 59 ++++++++++++++++++++++++++++++++++++++++- include/acpi/acpi_bus.h | 7 +++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index d161ff707de4..cf2c2bfe29a0 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -535,7 +535,7 @@ static void acpi_notify_device_fixed(void *data) struct acpi_device *device = data; /* Fixed hardware devices have no handles */ - acpi_notify_device(NULL, ACPI_FIXED_HARDWARE_EVENT, device); + device->fixed_event_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); } static u32 acpi_device_fixed_event(void *data) @@ -550,11 +550,13 @@ static int acpi_device_install_notify_handler(struct acpi_device *device, acpi_status status; if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { + device->fixed_event_notify = acpi_notify_device; status = acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, acpi_device_fixed_event, device); } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { + device->fixed_event_notify = acpi_notify_device; status = acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, acpi_device_fixed_event, @@ -579,9 +581,11 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device, if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, acpi_device_fixed_event); + device->fixed_event_notify = NULL; } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, acpi_device_fixed_event); + device->fixed_event_notify = NULL; } else { u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ? ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY; @@ -592,6 +596,59 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device, acpi_os_wait_events_complete(); } +int acpi_device_install_event_handler(struct acpi_device *device, + u32 type, + void (*notify)(acpi_handle, u32, void*)) +{ + acpi_status status; + + if (!notify) + return -EINVAL; + + if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { + device->fixed_event_notify = notify; + status = + acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_device_fixed_event, + device); + } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { + device->fixed_event_notify = notify; + status = + acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, + acpi_device_fixed_event, + device); + } else { + status = acpi_install_notify_handler(device->handle, type, + notify, + device); + } + + if (ACPI_FAILURE(status)) + return -EINVAL; + return 0; +} +EXPORT_SYMBOL(acpi_device_install_event_handler); + +void acpi_device_remove_event_handler(struct acpi_device *device, + u32 type, + void (*notify)(acpi_handle, u32, void*)) +{ + if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { + acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, + acpi_device_fixed_event); + device->fixed_event_notify = NULL; + } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { + acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, + acpi_device_fixed_event); + device->fixed_event_notify = NULL; + } else { + acpi_remove_notify_handler(device->handle, type, + notify); + } + acpi_os_wait_events_complete(); +} +EXPORT_SYMBOL(acpi_device_remove_event_handler); + /* Handle events targeting \_SB device (at present only graceful shutdown) */ #define ACPI_SB_NOTIFY_SHUTDOWN_REQUEST 0x81 diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index a6affc0550b0..7fb411438b6f 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -387,6 +387,7 @@ struct acpi_device { struct list_head physical_node_list; struct mutex physical_node_lock; void (*remove)(struct acpi_device *); + void (*fixed_event_notify)(acpi_handle handle, u32 type, void *data); }; /* Non-device subnode */ @@ -513,6 +514,12 @@ void acpi_bus_private_data_handler(acpi_handle, void *); int acpi_bus_get_private_data(acpi_handle, void **); int acpi_bus_attach_private_data(acpi_handle, void *); void acpi_bus_detach_private_data(acpi_handle); +int acpi_device_install_event_handler(struct acpi_device *device, + u32 type, + void (*notify)(acpi_handle, u32, void*)); +void acpi_device_remove_event_handler(struct acpi_device *device, + u32 type, + void (*notify)(acpi_handle, u32, void*)); extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32); extern int register_acpi_notifier(struct notifier_block *); extern int unregister_acpi_notifier(struct notifier_block *); From patchwork Thu Jun 1 13:17:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263758 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E74121CC9 for ; Thu, 1 Jun 2023 13:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627047; x=1717163047; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kqgNW8OvryYyrV4L3xPcxq88n689A4LPp2Kr4WOs0mw=; b=FzLAAXFe6w8TCT/0niALQpj4bSC6Vy/6M5tH1UozmXOxGEaXYAZNL+iJ DtARd5tnOG97bzgfPAgTn9YGzuY1pX51NWB2hnaOhpRTX2MEiEybzhh1i iCJLh9EDS+VdwltVkQ6ToTFS4VmdG6CWos/fm0PAbfQTpozGMSOC3kinm 5ejDpIGD/6YoIWmLi7KACG2bNwMrVTNeL+BMdZDb/JehMp2C2KoDihzL9 +ZqVgdqdNI5zNRldqDBoDzanekyYZ84JBEoTuaaPlvuJa9vTq4jz6sKAb +G6cLxqw4LLQdhDILw23xoT0lAEW7Im+xf1GVgl+x+3WFIH8/cX2KSUl1 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067472" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067472" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601692" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601692" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:08 -0700 From: Michal Wilczynski To: Benson Leung Cc: Michal Wilczynski , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 12/35] platform/chromeos_tbmc: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:15 +0200 Message-Id: <20230601131739.300760-13-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/chrome/chromeos_tbmc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/platform/chrome/chromeos_tbmc.c b/drivers/platform/chrome/chromeos_tbmc.c index d1cf8f3463ce..ac0f43fc530a 100644 --- a/drivers/platform/chrome/chromeos_tbmc.c +++ b/drivers/platform/chrome/chromeos_tbmc.c @@ -45,8 +45,10 @@ static __maybe_unused int chromeos_tbmc_resume(struct device *dev) return chromeos_tbmc_query_switch(adev, adev->driver_data); } -static void chromeos_tbmc_notify(struct acpi_device *adev, u32 event) +static void chromeos_tbmc_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *adev = data; + acpi_pm_wakeup_event(&adev->dev); switch (event) { case 0x80: @@ -92,7 +94,13 @@ static int chromeos_tbmc_add(struct acpi_device *adev) return ret; } device_init_wakeup(dev, true); - return 0; + + return acpi_device_install_event_handler(adev, ACPI_DEVICE_NOTIFY, chromeos_tbmc_notify); +} + +static void chromeos_tbmc_remove(struct acpi_device *adev) +{ + acpi_device_remove_event_handler(adev, ACPI_DEVICE_NOTIFY, chromeos_tbmc_notify); } static const struct acpi_device_id chromeos_tbmc_acpi_device_ids[] = { @@ -110,7 +118,7 @@ static struct acpi_driver chromeos_tbmc_driver = { .ids = chromeos_tbmc_acpi_device_ids, .ops = { .add = chromeos_tbmc_add, - .notify = chromeos_tbmc_notify, + .remove = chromeos_tbmc_remove, }, .drv.pm = &chromeos_tbmc_pm_ops, }; From patchwork Thu Jun 1 13:17:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263759 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 105E721CC9 for ; Thu, 1 Jun 2023 13:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685627056; x=1717163056; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/zOt8Ip/74RNexXI8wybJ/13PRTBt2DlRVAtzxRcwFc=; b=RNCf9kLucznwD/QqcJdtyVSQUaWDQ+aYnzBz4Bjrb8GHbmhVC13OGCFi IUr7C7Px4RqN+a9rZpSWklIUG50xOWfiqhbWJ6kWfj9YUKvu+Tr9ul7kp SS/BSoaX+2EKc0ZI6+zTnQnxwMCWc5FQNcuJHswTkyrnfYBtm0w5RLE1a ZoxrK8SV878HvH6oNhLX19PWqWBkJU9nV6Ofb4Retnvp2ydse4p1EToFm igNNwVQlxsMbCkKJwR7QXxiO+EQiZiGCrQwqkfAVE3YKdmeinw+wEZ5cq hfge5KCcMhBAPvqansNrtCeRoE6OkQzld+ZyIRu6Fm5bLcm5BJdQeHd09 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="419067547" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="419067547" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="881601714" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="881601714" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:19:12 -0700 From: Michal Wilczynski To: Benson Leung Cc: Michal Wilczynski , chrome-platform@lists.linux.dev, linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, rafael@kernel.org Subject: [PATCH v4 13/35] platform/wilco_ec: Move handler installing logic to driver Date: Thu, 1 Jun 2023 15:17:16 +0200 Message-Id: <20230601131739.300760-14-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230601131739.300760-3-michal.wilczynski@intel.com> References: <20230601131739.300760-3-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/chrome/wilco_ec/event.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/platform/chrome/wilco_ec/event.c b/drivers/platform/chrome/wilco_ec/event.c index a40f60bcefb6..23fd6de623f4 100644 --- a/drivers/platform/chrome/wilco_ec/event.c +++ b/drivers/platform/chrome/wilco_ec/event.c @@ -251,16 +251,10 @@ static int enqueue_events(struct acpi_device *adev, const u8 *buf, u32 length) return 0; } -/** - * event_device_notify() - Callback when EC generates an event over ACPI. - * @adev: The device that the event is coming from. - * @value: Value passed to Notify() in ACPI. - * - * This function will read the events from the device and enqueue them. - */ -static void event_device_notify(struct acpi_device *adev, u32 value) +static void event_device_notify(acpi_handle handle, u32 value, void *data) { struct acpi_buffer event_buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_device *adev = data; union acpi_object *obj; acpi_status status; @@ -490,6 +484,11 @@ static int event_device_add(struct acpi_device *adev) if (error) goto free_dev_data; + error = acpi_device_install_event_handler(adev, ACPI_DEVICE_NOTIFY, + event_device_notify); + if (error) + goto free_dev_data; + return 0; free_dev_data: @@ -503,6 +502,7 @@ static void event_device_remove(struct acpi_device *adev) { struct event_device_data *dev_data = adev->driver_data; + acpi_device_remove_event_handler(adev, ACPI_DEVICE_NOTIFY, event_device_notify); cdev_device_del(&dev_data->cdev, &dev_data->dev); ida_simple_remove(&event_ida, MINOR(dev_data->dev.devt)); hangup_device(dev_data); @@ -520,7 +520,6 @@ static struct acpi_driver event_driver = { .ids = event_acpi_ids, .ops = { .add = event_device_add, - .notify = event_device_notify, .remove = event_device_remove, }, .owner = THIS_MODULE, From patchwork Thu Jun 1 13:21:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263719 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1AC0E574; Thu, 1 Jun 2023 13:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685625676; x=1717161676; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=WwIcbTmw5qfuyP7ZCrrzP68VAul4AG0APywRqVEBBYg=; b=Ailu3SZbl3p6iqkH0ht8PcNHg+TglhGd2ty+f1L+L6qvkNBgvmjzpgKa +jzSW/AvNZBNOsCij8pdwlRXEUScT3n553/SLZwCVBq+O/OJzRkcXrzco Y7dY52syeYdvVFTuE2hzJCYQUOsUtd2HxycQe8sTgM1bNFdvyHARGaumO gZDorGAc1gaHMI55mvxky8yQKgzNbTK4EE/dIueFrZr5k1hAoupusDHkg KjtEo2YqXsAzJbFSIW1bqciXPQqmvahp0sz/fvop1pQHFG+JZLNNjMgvj si1DV+R6evNd1yOef1ZP9suUzkh44lwqfXPODBO2oqVju/hVsV0jFooBT g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="383826279" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="383826279" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="701539286" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="701539286" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:06 -0700 From: Michal Wilczynski To: rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org, lars@metafoo.de, bleung@chromium.org, yu.c.chen@intel.com, hdegoede@redhat.com, markgross@kernel.org, luzmaximilian@gmail.com, corentin.chary@gmail.com, jprvita@gmail.com, cascardo@holoscopio.com, don@syst.com.br, pali@kernel.org, jwoithe@just42.net, matan@svgalib.org, kenneth.t.chan@gmail.com, malattia@linux.it, jeremy@system76.com, productdev@system76.com, herton@canonical.com, coproscefalo@gmail.com, tytso@mit.edu, Jason@zx2c4.com, robert.moore@intel.com Cc: linux-acpi@vger.kernel.org, nvdimm@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, Michal Wilczynski Subject: [PATCH v4 33/35] acpi/bus: Remove installing/removing notify handlers from probe/remove Date: Thu, 1 Jun 2023 15:21:02 +0200 Message-Id: <20230601132102.301718-1-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove installing/removing .notify callback handlers, to prepare for notify callback removal. Remove logic calling .remove callback, as .add should be expected to clean after itself in case of the failure, and event handler installation was moved to .add in all drivers already. Signed-off-by: Michal Wilczynski --- drivers/acpi/bus.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index cf2c2bfe29a0..6436ac4d6322 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1089,20 +1089,6 @@ static int acpi_device_probe(struct device *dev) pr_debug("Driver [%s] successfully bound to device [%s]\n", acpi_drv->name, acpi_dev->pnp.bus_id); - if (acpi_drv->ops.notify) { - ret = acpi_device_install_notify_handler(acpi_dev, acpi_drv); - if (ret) { - if (acpi_drv->ops.remove) - acpi_drv->ops.remove(acpi_dev); - - acpi_dev->driver_data = NULL; - return ret; - } - } - - pr_debug("Found driver [%s] for device [%s]\n", acpi_drv->name, - acpi_dev->pnp.bus_id); - get_device(dev); return 0; } @@ -1112,9 +1098,6 @@ static void acpi_device_remove(struct device *dev) struct acpi_device *acpi_dev = to_acpi_device(dev); struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver); - if (acpi_drv->ops.notify) - acpi_device_remove_notify_handler(acpi_dev, acpi_drv); - if (acpi_drv->ops.remove) acpi_drv->ops.remove(acpi_dev); From patchwork Thu Jun 1 13:21:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263720 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8494FE574; Thu, 1 Jun 2023 13:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685625694; x=1717161694; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=D/DR88O008rjn2oDCy8f/NbpgBynR6wiHSrqme+u5DA=; b=MNNZRSf8nsplv0S1df1K8gU8X7aztZ1H6QyPqSt9NOYPCauqoQ+vOu3l AuBx4elvPlPRt58PekUhs28svf3p96YGZgCQr94+McaVGNxVONp7j9kwV LtxeWsMZK33WHYoqrG5rYGq5Zk5newyTXzY2lOCtZb7gkvPkTggVNDg7H LKMX/fH7m3ik4U8bWmxYGiHIXacSYNDQBDqDks6xilLzNxexukpZK5S3p CLZbil5LVJgelJxsxER9stduavPzZqkgYxPi/2KHCm/0HvK7jn+CgCrKy 6Vst/mFHqC65wEWrxrSUMSJCNENQKeoFvEDZ3j3vvMxlVumhCWd5Zxip3 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="441916177" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="441916177" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="797150450" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="797150450" Received: from hextor.igk.intel.com ([10.123.220.6]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:25 -0700 From: Michal Wilczynski To: rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org, lars@metafoo.de, bleung@chromium.org, yu.c.chen@intel.com, hdegoede@redhat.com, markgross@kernel.org, luzmaximilian@gmail.com, corentin.chary@gmail.com, jprvita@gmail.com, cascardo@holoscopio.com, don@syst.com.br, pali@kernel.org, jwoithe@just42.net, matan@svgalib.org, kenneth.t.chan@gmail.com, malattia@linux.it, jeremy@system76.com, productdev@system76.com, herton@canonical.com, coproscefalo@gmail.com, tytso@mit.edu, Jason@zx2c4.com, robert.moore@intel.com Cc: linux-acpi@vger.kernel.org, nvdimm@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, Michal Wilczynski Subject: [PATCH v4 34/35] acpi/bus: Remove redundant functions Date: Thu, 1 Jun 2023 15:21:21 +0200 Message-Id: <20230601132122.301760-1-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 By this point all drivers switched from using .notify callback to installing event handlers on their own. Remove redundant functions acpi_device_install_notify_handler(), acpi_device_remove_notify_handler() and acpi_notify_device(). Signed-off-by: Michal Wilczynski --- drivers/acpi/bus.c | 60 ---------------------------------------------- 1 file changed, 60 deletions(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 6436ac4d6322..d700b65f5a37 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -522,14 +522,6 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) acpi_evaluate_ost(handle, type, ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL); } -static void acpi_notify_device(acpi_handle handle, u32 event, void *data) -{ - struct acpi_device *device = data; - struct acpi_driver *acpi_drv = to_acpi_driver(device->dev.driver); - - acpi_drv->ops.notify(device, event); -} - static void acpi_notify_device_fixed(void *data) { struct acpi_device *device = data; @@ -544,58 +536,6 @@ static u32 acpi_device_fixed_event(void *data) return ACPI_INTERRUPT_HANDLED; } -static int acpi_device_install_notify_handler(struct acpi_device *device, - struct acpi_driver *acpi_drv) -{ - acpi_status status; - - if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { - device->fixed_event_notify = acpi_notify_device; - status = - acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, - acpi_device_fixed_event, - device); - } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { - device->fixed_event_notify = acpi_notify_device; - status = - acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, - acpi_device_fixed_event, - device); - } else { - u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ? - ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY; - - status = acpi_install_notify_handler(device->handle, type, - acpi_notify_device, - device); - } - - if (ACPI_FAILURE(status)) - return -EINVAL; - return 0; -} - -static void acpi_device_remove_notify_handler(struct acpi_device *device, - struct acpi_driver *acpi_drv) -{ - if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON) { - acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, - acpi_device_fixed_event); - device->fixed_event_notify = NULL; - } else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON) { - acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, - acpi_device_fixed_event); - device->fixed_event_notify = NULL; - } else { - u32 type = acpi_drv->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS ? - ACPI_ALL_NOTIFY : ACPI_DEVICE_NOTIFY; - - acpi_remove_notify_handler(device->handle, type, - acpi_notify_device); - } - acpi_os_wait_events_complete(); -} - int acpi_device_install_event_handler(struct acpi_device *device, u32 type, void (*notify)(acpi_handle, u32, void*)) From patchwork Thu Jun 1 13:21:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13263721 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BB89FBE8; Thu, 1 Jun 2023 13:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685625709; x=1717161709; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LDh3/ulcjpVzc1kWMXWyk72lw2x2F5XCJG1Yb1dhhKw=; b=IIifFB/XN7cmxihAwzfPaOsSrnwyTQa4g/nwQeIkyX7s+6NMiOI4eNIW pw9v3j8cHzqARqPY5CIVqhW1z/SWMcWVNMXPsuQmv5svvEtSsP3nf/QRg ktc+Q5cXPm8l3nOXXWQTHTm6gwzyTKTbi9gsXg0H9lrC1eQMOJFhgeA4Y NsFbMX5X5IdobzoGGwp3aki2kUAZaPx0MkpTKpT8xHJwgtlstYFUQTG3H KiICLv90iFWOTY5Se8r9HR9Y8wmlXeq43DPXxKv6Lho/+Ym+D9XredWrq WvfAZ1xz+wQVQAC6C318CHV4WADG6qy3lyssLxL7DTjTT5Jux0Ndfg0uD g==; X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="335174006" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="335174006" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="1037487848" X-IronPort-AV: E=Sophos;i="6.00,210,1681196400"; d="scan'208";a="1037487848" Received: from hextor.igk.intel.com ([10.123.220.6]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2023 06:21:40 -0700 From: Michal Wilczynski To: rafael@kernel.org, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org, lars@metafoo.de, bleung@chromium.org, yu.c.chen@intel.com, hdegoede@redhat.com, markgross@kernel.org, luzmaximilian@gmail.com, corentin.chary@gmail.com, jprvita@gmail.com, cascardo@holoscopio.com, don@syst.com.br, pali@kernel.org, jwoithe@just42.net, matan@svgalib.org, kenneth.t.chan@gmail.com, malattia@linux.it, jeremy@system76.com, productdev@system76.com, herton@canonical.com, coproscefalo@gmail.com, tytso@mit.edu, Jason@zx2c4.com, robert.moore@intel.com Cc: linux-acpi@vger.kernel.org, nvdimm@lists.linux.dev, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, chrome-platform@lists.linux.dev, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, Michal Wilczynski , acpica-devel@lists.linuxfoundation.org Subject: [PATCH v4 35/35] acpi/bus: Remove notify callback and flags Date: Thu, 1 Jun 2023 15:21:37 +0200 Message-Id: <20230601132137.301802-1-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As callback has been replaced by drivers installing their handlers in .add it's presence is not useful anymore. Remove .notify callback and flags variable from struct acpi_driver, as they're not needed anymore. Signed-off-by: Michal Wilczynski --- include/acpi/acpi_bus.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 7fb411438b6f..3326794d5b70 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -151,12 +151,10 @@ struct acpi_hotplug_context { typedef int (*acpi_op_add) (struct acpi_device * device); typedef void (*acpi_op_remove) (struct acpi_device *device); -typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event); struct acpi_device_ops { acpi_op_add add; acpi_op_remove remove; - acpi_op_notify notify; }; #define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */ @@ -165,7 +163,6 @@ struct acpi_driver { char name[80]; char class[80]; const struct acpi_device_id *ids; /* Supported Hardware IDs */ - unsigned int flags; struct acpi_device_ops ops; struct device_driver drv; struct module *owner;