From patchwork Mon Jul 3 08:02:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13299695 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 B94AD1379 for ; Mon, 3 Jul 2023 08:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688371397; x=1719907397; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lc4+OfSbvvX57NjX05OtAekCe3S3QQ2eQi+GYzBA354=; b=fmEdNkRsMI+I+gDPCg2lHzq2W4bDzL1t7qjgfleNydurANKzTZpFNWLb HgN8sNRQmO6QTkqA3AhSQhTROqaX5zH/X2FSHxzuZtPRZsp8OafnYYV5a E+NYQgP1CzuzIfVdQEY7NXDfViExgwrPyKrpqTKufWpztcDKEfQXP11zy v8j5FphXonrTS8iBVkvGl71JlW6OeFZcG6XrPPeZ28gKDlgT5rON5w6/6 TGBttG2LhFfbcqTT1GvegQslWk3hZUrOVMV2RSuS3x5CdnBDRKxjg3kO1 ai+9b4PSPVFdOXYJahecRP2Qjbf0zR16xM61H0Kn6DCKGXLhMGIALE1Jl Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="366304009" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="366304009" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="862994510" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="862994510" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:14 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski , "Rafael J . Wysocki" Subject: [PATCH v7 1/9] acpi/bus: Introduce wrappers for ACPICA event handler install/remove Date: Mon, 3 Jul 2023 11:02:44 +0300 Message-ID: <20230703080252.2899090-2-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703080252.2899090-1-michal.wilczynski@intel.com> References: <20230703080252.2899090-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce new acpi_dev_install_notify_handler() and acpi_dev_remove_notify_handler(). Those functions are replacing old installers, and after all drivers switch to the new model, old installers will be removed. Make acpi_dev_install_notify_handler() and acpi_dev_remove_notify_handler() non-static, and export symbols. This will allow the drivers to call them directly, instead of relying on .notify callback. Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/bus.c | 26 ++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 20cdfb37da79..2d6f1f45d44e 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -554,6 +554,32 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device, acpi_os_wait_events_complete(); } +int acpi_dev_install_notify_handler(struct acpi_device *adev, + u32 handler_type, + acpi_notify_handler handler) +{ + acpi_status status; + + status = acpi_install_notify_handler(adev->handle, + handler_type, + handler, + adev); + if (ACPI_FAILURE(status)) + return -ENODEV; + + return 0; +} +EXPORT_SYMBOL(acpi_dev_install_notify_handler); + +void acpi_dev_remove_notify_handler(struct acpi_device *adev, + u32 handler_type, + acpi_notify_handler handler) +{ + acpi_remove_notify_handler(adev->handle, handler_type, handler); + acpi_os_wait_events_complete(); +} +EXPORT_SYMBOL(acpi_dev_remove_notify_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 c941d99162c0..23fbe4a16972 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -515,6 +515,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_dev_install_notify_handler(struct acpi_device *adev, + u32 handler_type, + acpi_notify_handler handler); +void acpi_dev_remove_notify_handler(struct acpi_device *adev, + u32 handler_type, + acpi_notify_handler handler); 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 Mon Jul 3 08:02:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13299696 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 BE86417F0 for ; Mon, 3 Jul 2023 08:03:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688371400; x=1719907400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tVvPfhy1pq/F5VIaRT5AzqUsJQrfr238yG1EqHj9ZCg=; b=eMlSjlEZ8ieLNTp8kzrimPZmRUYruJk3dhoKRKPcCu1Jjgx3oEYHmYj3 b8IbZvPIysoBFipFDkc1T9zUF35jU7bkK696oZRp8It+EnqPUEwS3ac7z Bl51fy7j0o5AKg7dknrWeym7IQrh3yxYBJFMAGItjrrKJGgmwaXLx8TZW 9UiebxRarmgTQU+I0eKHSriCd9rp9Hgc5L9ppVlgcSyyanKpWW3Jvg9S/ vNWrLGAurE2xv7T5Y+GMBZGLA2hoWnmw34MRqIqddH4ZSpxoujKyZhcbB ov9CLcuCbvSVcsgLPTrJd4eNqUaV1ZCii+umGpc6D3q6ccbUfurnDYj32 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="366304020" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="366304020" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="862994525" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="862994525" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:17 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski Subject: [PATCH v7 2/9] acpi/bus: Set driver_data to NULL every time .add() fails Date: Mon, 3 Jul 2023 11:02:45 +0300 Message-ID: <20230703080252.2899090-3-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703080252.2899090-1-michal.wilczynski@intel.com> References: <20230703080252.2899090-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most drivers set driver_data during .add() callback, but usually they don't set it back to NULL in case of a failure. Set driver_data to NULL in acpi_device_probe() to avoid code duplication. Signed-off-by: Michal Wilczynski --- drivers/acpi/bus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 2d6f1f45d44e..c087fd6e8398 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1014,8 +1014,10 @@ static int acpi_device_probe(struct device *dev) return -ENOSYS; ret = acpi_drv->ops.add(acpi_dev); - if (ret) + if (ret) { + acpi_dev->driver_data = NULL; return ret; + } pr_debug("Driver [%s] successfully bound to device [%s]\n", acpi_drv->name, acpi_dev->pnp.bus_id); From patchwork Mon Jul 3 08:02:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13299697 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 EB46217F0 for ; Mon, 3 Jul 2023 08:03:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688371403; x=1719907403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+TtSlxKV+HOo4L7ax/yjcsU33lOHTI/V/imUAW6Fx3I=; b=MWEi2Lcb+R+D/U+IkCpTI76KyG8cUZWkTD10RcY75VKA+A+WZVYPm2oD NDMAtzXH3zEJi+EaShPk8WPedoNGpi/8CCCl7/SJq/olPea1HPW59vreo i9Ct+m/yThBS5CHsjmEvATKq/261VpY0NnrwNwAzFhjYE41d8p1578dZM MVLdsyc9CzSH1BXPpRHA/tsol1NVrt3IBtpxIikBPc9JW4GnEspwa+iyB V4IMpN4vCnj3MSPKD30pntnVsgNJMcFfC3hvcLu04nLbPfNPBe5EaysIx hjt+3FgIPUwaNzw0OkL78t2Vj/1MsjqzRq6KdPIkDE9KXpwW7m8yw6Y8V w==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="366304035" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="366304035" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="862994538" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="862994538" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:20 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski , "Rafael J . Wysocki" Subject: [PATCH v7 3/9] acpi/ac: Move handler installing logic to driver Date: Mon, 3 Jul 2023 11:02:46 +0300 Message-ID: <20230703080252.2899090-4-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703080252.2899090-1-michal.wilczynski@intel.com> References: <20230703080252.2899090-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: nvdimm@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_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver. Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/ac.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 1ace70b831cd..f6feff1f3118 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -34,7 +34,7 @@ MODULE_LICENSE("GPL"); static int acpi_ac_add(struct acpi_device *device); static void acpi_ac_remove(struct acpi_device *device); -static void acpi_ac_notify(struct acpi_device *device, u32 event); +static void acpi_ac_notify(acpi_handle handle, u32 event, void *data); static const struct acpi_device_id ac_device_ids[] = { {"ACPI0003", 0}, @@ -54,11 +54,9 @@ static struct acpi_driver acpi_ac_driver = { .name = "ac", .class = ACPI_AC_CLASS, .ids = ac_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = acpi_ac_add, .remove = acpi_ac_remove, - .notify = acpi_ac_notify, }, .drv.pm = &acpi_ac_pm, }; @@ -128,8 +126,9 @@ static enum power_supply_property ac_props[] = { }; /* Driver Model */ -static void acpi_ac_notify(struct acpi_device *device, u32 event) +static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; struct acpi_ac *ac = acpi_driver_data(device); if (!ac) @@ -235,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device) result = acpi_ac_get_state(ac); if (result) - goto end; + goto err_release_ac; psy_cfg.drv_data = ac; @@ -248,7 +247,7 @@ static int acpi_ac_add(struct acpi_device *device) &ac->charger_desc, &psy_cfg); if (IS_ERR(ac->charger)) { result = PTR_ERR(ac->charger); - goto end; + goto err_release_ac; } pr_info("%s [%s] (%s)\n", acpi_device_name(device), @@ -256,9 +255,20 @@ static int acpi_ac_add(struct acpi_device *device) ac->battery_nb.notifier_call = acpi_ac_battery_notify; register_acpi_notifier(&ac->battery_nb); -end: + + result = acpi_dev_install_notify_handler(device, + ACPI_ALL_NOTIFY, + acpi_ac_notify); if (result) - kfree(ac); + goto err_unregister; + + return 0; + +err_unregister: + power_supply_unregister(ac->charger); + unregister_acpi_notifier(&ac->battery_nb); +err_release_ac: + kfree(ac); return result; } @@ -297,6 +307,9 @@ static void acpi_ac_remove(struct acpi_device *device) ac = acpi_driver_data(device); + acpi_dev_remove_notify_handler(device, + ACPI_ALL_NOTIFY, + acpi_ac_notify); power_supply_unregister(ac->charger); unregister_acpi_notifier(&ac->battery_nb); From patchwork Mon Jul 3 08:02:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13299698 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 2CB0B1873 for ; Mon, 3 Jul 2023 08:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688371407; x=1719907407; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OhNb4diD7c3/96GlreLql7JOogYRt1zgUXPKOSDhXMw=; b=Ejvv1Xz/A99NYeiomddcCpGM+4BzMPfaZwiEh7DOD9kH66++VGWIvPfr SRylkncnrHjoXYsc0DiwnLzfsyNDmdh/S+fSd0KJqm9Rma+2tpMMWQPyr gclSeujAIie2GjITMNi8reGgaDkg6tEnLha0pObxlL4h+POA2t6PHoRiV lc43lWgVyPFFIUklvzmtU2AguovQIHYPzYzO+SPX5OBZE4D/Rika65CR7 CFgvHiq+vObPkwonCBQSLJLDPWgElt35L1AFaYlJ8Xyc3OsbcBDpY93JY TQMynb4tr1BFiKDIIg8G39faDwgZb3h1DYZR7+eeDy6pVq1WRXkZfolhP Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="366304050" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="366304050" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="862994547" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="862994547" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:23 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski , "Rafael J . Wysocki" Subject: [PATCH v7 4/9] acpi/video: Move handler installing logic to driver Date: Mon, 3 Jul 2023 11:02:47 +0300 Message-ID: <20230703080252.2899090-5-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703080252.2899090-1-michal.wilczynski@intel.com> References: <20230703080252.2899090-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: nvdimm@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_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver. Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_video.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 62f4364e4460..168bb43e0c65 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -77,7 +77,7 @@ static DEFINE_MUTEX(video_list_lock); static LIST_HEAD(video_bus_head); static int acpi_video_bus_add(struct acpi_device *device); static void acpi_video_bus_remove(struct acpi_device *device); -static void acpi_video_bus_notify(struct acpi_device *device, u32 event); +static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data); /* * Indices in the _BCL method response: the first two items are special, @@ -104,7 +104,6 @@ static struct acpi_driver acpi_video_bus = { .ops = { .add = acpi_video_bus_add, .remove = acpi_video_bus_remove, - .notify = acpi_video_bus_notify, }, }; @@ -1527,8 +1526,9 @@ static int acpi_video_bus_stop_devices(struct acpi_video_bus *video) acpi_osi_is_win8() ? 0 : 1); } -static void acpi_video_bus_notify(struct acpi_device *device, u32 event) +static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; struct acpi_video_bus *video = acpi_driver_data(device); struct input_dev *input; int keycode = 0; @@ -2053,8 +2053,20 @@ static int acpi_video_bus_add(struct acpi_device *device) acpi_video_bus_add_notify_handler(video); + error = acpi_dev_install_notify_handler(device, + ACPI_DEVICE_NOTIFY, + acpi_video_bus_notify); + if (error) + goto err_remove; + return 0; +err_remove: + mutex_lock(&video_list_lock); + list_del(&video->entry); + mutex_unlock(&video_list_lock); + acpi_video_bus_remove_notify_handler(video); + acpi_video_bus_unregister_backlight(video); err_put_video: acpi_video_bus_put_devices(video); kfree(video->attached_array); @@ -2075,6 +2087,10 @@ static void acpi_video_bus_remove(struct acpi_device *device) video = acpi_driver_data(device); + acpi_dev_remove_notify_handler(device, + ACPI_DEVICE_NOTIFY, + acpi_video_bus_notify); + mutex_lock(&video_list_lock); list_del(&video->entry); mutex_unlock(&video_list_lock); From patchwork Mon Jul 3 08:02:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13299699 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 A798720EF for ; Mon, 3 Jul 2023 08:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688371410; x=1719907410; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ro1KbsI0sCyRbPkzkXqtarOGFnBsPGqpRQpQUovj/YY=; b=BzvdmLVJIa/DQ5E+/Bbhe9dXyVqe4YO1FV2VkuiODRGjTU1+oZ8eOrqH FvzI3ji6dWVl8WBEBJFawLCzB/89CQtPl6cYNqrzrEcDMg66rUwCuMYjE gnkF1q7LCoSAaJZDqPx4sRWPUVGq3KUPwtSMKzcs7PdmH9+NOpUiFy3QD v3eOv2HVrU+k+iYXmsU2SR1/SkFM36o2PlKPTmoSqsfwNzYPP08IwoRAQ tNUhDpMAHhn8Yj1hfkteQTPFTV2iG2M9uLKQ+bZvZmhm8zTcd7UpkeRJ1 0QguE35BqLYNcMe4i2SPJg7XTwlHa/bmgOphAzfgPL1Wjrzry9eI1ErFi A==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="366304062" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="366304062" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="862994555" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="862994555" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:26 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski , "Rafael J . Wysocki" Subject: [PATCH v7 5/9] acpi/battery: Move handler installing logic to driver Date: Mon, 3 Jul 2023 11:02:48 +0300 Message-ID: <20230703080252.2899090-6-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703080252.2899090-1-michal.wilczynski@intel.com> References: <20230703080252.2899090-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: nvdimm@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_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver. While at it, fix lack of whitespaces in .remove() callback. Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/battery.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9c67ed02d797..4c634a4c32dd 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -1034,8 +1034,9 @@ static void acpi_battery_refresh(struct acpi_battery *battery) } /* Driver Interface */ -static void acpi_battery_notify(struct acpi_device *device, u32 event) +static void acpi_battery_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; struct acpi_battery *battery = acpi_driver_data(device); struct power_supply *old; @@ -1212,13 +1213,23 @@ static int acpi_battery_add(struct acpi_device *device) device_init_wakeup(&device->dev, 1); - return result; + result = acpi_dev_install_notify_handler(device, + ACPI_ALL_NOTIFY, + acpi_battery_notify); + if (result) + goto fail_pm; + + return 0; +fail_pm: + device_init_wakeup(&device->dev, 0); + unregister_pm_notifier(&battery->pm_nb); fail: sysfs_remove_battery(battery); mutex_destroy(&battery->lock); mutex_destroy(&battery->sysfs_lock); kfree(battery); + return result; } @@ -1228,10 +1239,17 @@ static void acpi_battery_remove(struct acpi_device *device) if (!device || !acpi_driver_data(device)) return; - device_init_wakeup(&device->dev, 0); + battery = acpi_driver_data(device); + + acpi_dev_remove_notify_handler(device, + ACPI_ALL_NOTIFY, + acpi_battery_notify); + + device_init_wakeup(&device->dev, 0); unregister_pm_notifier(&battery->pm_nb); sysfs_remove_battery(battery); + mutex_destroy(&battery->lock); mutex_destroy(&battery->sysfs_lock); kfree(battery); @@ -1264,11 +1282,9 @@ static struct acpi_driver acpi_battery_driver = { .name = "battery", .class = ACPI_BATTERY_CLASS, .ids = battery_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = acpi_battery_add, .remove = acpi_battery_remove, - .notify = acpi_battery_notify, }, .drv.pm = &acpi_battery_pm, }; From patchwork Mon Jul 3 08:02:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13299700 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 A299720EF for ; Mon, 3 Jul 2023 08:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688371413; x=1719907413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OLu9Y5+jm3VDC/cj5GwgBm61aIT2JGxMD1esABlzzPE=; b=d8ez2/P4DvFq4/jrQB4TVsErpYIYEStPAh8EXCPvLsneOjUWPu07Ewj3 dGQ+UH1Ckw/Y/OteZ/QBoT7C0UJCQuVXAe9DTHozq2FfA1jPsrYEaawYm 8WndqkGgQ5Pp1E3CAF1XwO8uvUfs7QTrlx04q+5QYH+Hczf9/keqhYkgJ +x6ZK6orY791I1vDBT0r3iR0atqsTHox4DUmJMUJG98/ixx5nPagMbf9U xpa7VXn1XoQ2gH0TwUMWpig7Kn8/+Ckp9Do9flAVEWhaADtNHWhM/EFOY 8SVXy50HTor+JmTApeeh9vPs3DuAmx+E7m1Z5VJpGSuMW3B78bnKb6yBG w==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="366304075" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="366304075" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="862994563" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="862994563" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:30 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski , "Rafael J . Wysocki" Subject: [PATCH v7 6/9] acpi/hed: Move handler installing logic to driver Date: Mon, 3 Jul 2023 11:02:49 +0300 Message-ID: <20230703080252.2899090-7-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703080252.2899090-1-michal.wilczynski@intel.com> References: <20230703080252.2899090-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: nvdimm@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_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver. Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/hed.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c index 78d44e3fe129..8f54560c6d1c 100644 --- a/drivers/acpi/hed.c +++ b/drivers/acpi/hed.c @@ -42,22 +42,34 @@ EXPORT_SYMBOL_GPL(unregister_acpi_hed_notifier); * it is used by HEST Generic Hardware Error Source with notify type * SCI. */ -static void acpi_hed_notify(struct acpi_device *device, u32 event) +static void acpi_hed_notify(acpi_handle handle, u32 event, void *data) { blocking_notifier_call_chain(&acpi_hed_notify_list, 0, NULL); } static int acpi_hed_add(struct acpi_device *device) { + int err; + /* Only one hardware error device */ if (hed_handle) return -EINVAL; hed_handle = device->handle; - return 0; + + err = acpi_dev_install_notify_handler(device, + ACPI_DEVICE_NOTIFY, + acpi_hed_notify); + if (err) + hed_handle = NULL; + + return err; } static void acpi_hed_remove(struct acpi_device *device) { + acpi_dev_remove_notify_handler(device, + ACPI_DEVICE_NOTIFY, + acpi_hed_notify); hed_handle = NULL; } @@ -68,7 +80,6 @@ static struct acpi_driver acpi_hed_driver = { .ops = { .add = acpi_hed_add, .remove = acpi_hed_remove, - .notify = acpi_hed_notify, }, }; module_acpi_driver(acpi_hed_driver); From patchwork Mon Jul 3 08:02:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13299701 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 0D28220EF for ; Mon, 3 Jul 2023 08:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688371417; x=1719907417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=epFJB+pC8Cnb2bJxMzw10oc2jXbHbhRfW4dq8aHrchQ=; b=GbKrYpbkZmIUKaeCIbEGyNphXXcow2r7gtt2a3LI66nLamMMQSsG3f0C Nm5l/AgO4LquDUltU5+eGZrY36KkYAXha23oxBshoJhhGumEALtKVnvIJ uYy1124FjhWjrDeX2gwPL1lcslRlmQ7vjCxwqa2NeWBMgNwOMdbo8bEwO be8b4VTbdFKwm5T40SioVcYW/fa3jSxOI3VWvf3Ova5M2YckZ3u4hioY5 tVU0bJX/i33uEuqfMKQMOJff3xu2Cvfw69giVeri3OfZ5rQAYM4PGlclM k01jP2mFHIVG50sLUYKTOBZEwILj0tHAdjSoUhFP7pMirbYNK+T9B2TWJ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="366304088" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="366304088" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="862994572" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="862994572" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:33 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski , "Rafael J . Wysocki" Subject: [PATCH v7 7/9] acpi/nfit: Move handler installing logic to driver Date: Mon, 3 Jul 2023 11:02:50 +0300 Message-ID: <20230703080252.2899090-8-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703080252.2899090-1-michal.wilczynski@intel.com> References: <20230703080252.2899090-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: nvdimm@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_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of acpi_nfit_shutdown(). Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver. Introduce a new devm action acpi_nfit_remove_notify_handler. Move acpi_nfit_notify() upwards in the file, so it can be used inside acpi_nfit_add() and acpi_nfit_remove_notify_handler(). Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/nfit/core.c | 41 +++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 07204d482968..124e928647d3 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -3282,6 +3282,24 @@ static void acpi_nfit_put_table(void *table) acpi_put_table(table); } +static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data) +{ + struct acpi_device *adev = data; + + device_lock(&adev->dev); + __acpi_nfit_notify(&adev->dev, handle, event); + device_unlock(&adev->dev); +} + +static void acpi_nfit_remove_notify_handler(void *data) +{ + struct acpi_device *adev = data; + + acpi_dev_remove_notify_handler(adev, + ACPI_DEVICE_NOTIFY, + acpi_nfit_notify); +} + void acpi_nfit_shutdown(void *data) { struct acpi_nfit_desc *acpi_desc = data; @@ -3368,7 +3386,20 @@ static int acpi_nfit_add(struct acpi_device *adev) if (rc) return rc; - return devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc); + + rc = devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc); + if (rc) + return rc; + + rc = acpi_dev_install_notify_handler(adev, + ACPI_DEVICE_NOTIFY, + acpi_nfit_notify); + if (rc) + return rc; + + return devm_add_action_or_reset(dev, + acpi_nfit_remove_notify_handler, + adev); } static void acpi_nfit_remove(struct acpi_device *adev) @@ -3446,13 +3477,6 @@ void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event) } EXPORT_SYMBOL_GPL(__acpi_nfit_notify); -static void acpi_nfit_notify(struct acpi_device *adev, u32 event) -{ - device_lock(&adev->dev); - __acpi_nfit_notify(&adev->dev, adev->handle, event); - device_unlock(&adev->dev); -} - static const struct acpi_device_id acpi_nfit_ids[] = { { "ACPI0012", 0 }, { "", 0 }, @@ -3465,7 +3489,6 @@ static struct acpi_driver acpi_nfit_driver = { .ops = { .add = acpi_nfit_add, .remove = acpi_nfit_remove, - .notify = acpi_nfit_notify, }, }; From patchwork Mon Jul 3 08:02:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13299702 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 0A36820EF for ; Mon, 3 Jul 2023 08:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688371420; x=1719907420; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+KEWHKPpqNaiI+WNm1olqE9/TBQfa5bBD6OIb1rqfsw=; b=BbkJoKxLvvN6eDEe2q0v8TG4DzG7e52YWak2cTLwKKnI3Ums547kXORw EpctEI1QahswjcHXi15/UN46RIEuQuzeIGVcEStmdHLEC0r5JgOppvwco HkwFNckvQubv5TnergqoFGjvukL+g+n1QDtHQX7HQY8z99jumjTuKqzFg PsDY9iPJrEs0O1DkCFbuZQMbVs0GfXVJzhktOxGWSxHTIXma2CF84LrY/ ga8Y2r3G73ynYnQNWMnKRxLoGr2uXMo6pZBxyEjHSEiLtwmdzDBq1eBWH ApNHsQxN4/S3t5KxhFGdavgfXoZ7keJSibiEJ17xEl1BHG+qg49/PhlOe A==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="366304102" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="366304102" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="862994575" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="862994575" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:36 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski Subject: [PATCH v7 8/9] acpi/nfit: Remove unnecessary .remove callback Date: Mon, 3 Jul 2023 11:02:51 +0300 Message-ID: <20230703080252.2899090-9-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703080252.2899090-1-michal.wilczynski@intel.com> References: <20230703080252.2899090-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Nfit driver doesn't use .remove() callback and provide an empty function as it's .remove() callback. Remove empty acpi_nfit_remove() and initialization of callback. Suggested-by: Dan Williams Signed-off-by: Michal Wilczynski --- drivers/acpi/nfit/core.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 124e928647d3..16bf17a3d6ff 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -3402,11 +3402,6 @@ static int acpi_nfit_add(struct acpi_device *adev) adev); } -static void acpi_nfit_remove(struct acpi_device *adev) -{ - /* see acpi_nfit_unregister */ -} - static void acpi_nfit_update_notify(struct device *dev, acpi_handle handle) { struct acpi_nfit_desc *acpi_desc = dev_get_drvdata(dev); @@ -3488,7 +3483,6 @@ static struct acpi_driver acpi_nfit_driver = { .ids = acpi_nfit_ids, .ops = { .add = acpi_nfit_add, - .remove = acpi_nfit_remove, }, }; From patchwork Mon Jul 3 08:02:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 13299703 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 7569A1FA6 for ; Mon, 3 Jul 2023 08:04:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688371443; x=1719907443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8UyXWfKO7yUPN8MnLg1ywaUXI/b1qFb1tKTsv4NWR/I=; b=Koy46bzStrvFknCchs3w34G1gOAs14x9aJwx7PVYI73Lqb/B2ak0NVpq h0Jk4YeshPgOjPV9KOfoWa0VZrrBssU7bEY907jCL93XowJ57zvbVNFNp 66Md6ixlADWzzAZTAqM56tUmlXyfS9TZmIEdm0vVM5SeHm9ik3Z3DCQ2J bkwSmSyYRvDsHbrF2W2Ca+t6jJVlCrEAX8vDkv+L/thaLsdGUnZgBFIHs CcLdCNs+PFc7Zf3EVL7H0xMIXbSD+2IX3gs7jkjPT5RnCd/4Svrev3Ld3 bMeOTUQKlEM45evnvaZwCcLfJhOc99sd6t169BmrGl4SOgiYlFsbK2FhE A==; X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="366304116" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="366304116" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10759"; a="862994579" X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="862994579" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 01:03:39 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski , "Rafael J . Wysocki" Subject: [PATCH v7 9/9] acpi/thermal: Move handler installing logic to driver Date: Mon, 3 Jul 2023 11:02:52 +0300 Message-ID: <20230703080252.2899090-10-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703080252.2899090-1-michal.wilczynski@intel.com> References: <20230703080252.2899090-1-michal.wilczynski@intel.com> Precedence: bulk X-Mailing-List: nvdimm@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_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver. While at it, fix whitespaces in .remove() callback. Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/thermal.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index f9f6ebb08fdb..97858ad59d68 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -825,8 +825,9 @@ static void acpi_queue_thermal_check(struct acpi_thermal *tz) queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); } -static void acpi_thermal_notify(struct acpi_device *device, u32 event) +static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; struct acpi_thermal *tz = acpi_driver_data(device); if (!tz) @@ -997,11 +998,21 @@ static int acpi_thermal_add(struct acpi_device *device) pr_info("%s [%s] (%ld C)\n", acpi_device_name(device), acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); - goto end; + result = acpi_dev_install_notify_handler(device, + ACPI_DEVICE_NOTIFY, + acpi_thermal_notify); + if (result) + goto flush_wq; + + return 0; + +flush_wq: + flush_workqueue(acpi_thermal_pm_queue); + acpi_thermal_unregister_thermal_zone(tz); free_memory: kfree(tz); -end: + return result; } @@ -1012,10 +1023,15 @@ static void acpi_thermal_remove(struct acpi_device *device) if (!device || !acpi_driver_data(device)) return; - flush_workqueue(acpi_thermal_pm_queue); tz = acpi_driver_data(device); + acpi_dev_remove_notify_handler(device, + ACPI_DEVICE_NOTIFY, + acpi_thermal_notify); + + flush_workqueue(acpi_thermal_pm_queue); acpi_thermal_unregister_thermal_zone(tz); + kfree(tz); } @@ -1078,7 +1094,6 @@ static struct acpi_driver acpi_thermal_driver = { .ops = { .add = acpi_thermal_add, .remove = acpi_thermal_remove, - .notify = acpi_thermal_notify, }, .drv.pm = &acpi_thermal_pm, };