From patchwork Wed May 17 07:56:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 606C7C77B7F for ; Wed, 17 May 2023 07:58:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbjEQH6k (ORCPT ); Wed, 17 May 2023 03:58:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbjEQH6Z (ORCPT ); Wed, 17 May 2023 03:58:25 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B38681701 for ; Wed, 17 May 2023 00:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310297; x=1715846297; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wNzFAp+2Askmwe3Z0I4i+TRfnPUKD8KrFQAyDNVZazs=; b=DVwuUKofWgLjv6pxOyhYD9hRoxJ0djdE+JMTlXHwZS40+Ja+16/DckxU pu2r4qnQQ7Eg2MCTCfQ7U5hrErd7bJgso5xw5s+9PFyIXU+qUpPMkwVxA tPQF1IlQhuYZCIVZv/F9DL7NNioWExObEHzppau3KukJ9fIG2WlQTPO7b ze67ZsMBDD7spINUPmvxQ7v75sVkVJ9C0lmKcIl3NMBtVNGoEb3Qpmd1M uMY1LlU5PMd+nQwkDYjj7c/ApNJF/daINVcW+e86cwr6+uYrCj2MH7aVR brkuczu7uRnPCec554fAPQcGko9qWxbPslJUE5hmXaAqf2UomrrILTkdJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105364" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105364" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877256" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877256" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:00 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 02/34] acpi/ac: Move handler installing logic to driver Date: Wed, 17 May 2023 09:56:52 +0200 Message-Id: <20230517075724.153992-3-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/acpi/ac.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 1ace70b831cd..208af5a3106e 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,9 +126,12 @@ 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_ac *ac = acpi_driver_data(device); + struct acpi_device *device = data; + struct acpi_ac *ac; + + ac = acpi_driver_data(device); if (!ac) return; @@ -256,6 +257,8 @@ static int acpi_ac_add(struct acpi_device *device) ac->battery_nb.notifier_call = acpi_ac_battery_notify; register_acpi_notifier(&ac->battery_nb); + + result = acpi_device_install_event_handler(device, ACPI_ALL_NOTIFY, acpi_ac_notify); end: if (result) kfree(ac); @@ -297,6 +300,7 @@ static void acpi_ac_remove(struct acpi_device *device) ac = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_ALL_NOTIFY, acpi_ac_notify); power_supply_unregister(ac->charger); unregister_acpi_notifier(&ac->battery_nb); From patchwork Wed May 17 07:56:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7CD9C7EE23 for ; Wed, 17 May 2023 07:59:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229520AbjEQH67 (ORCPT ); Wed, 17 May 2023 03:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229803AbjEQH6b (ORCPT ); Wed, 17 May 2023 03:58:31 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2CE123 for ; Wed, 17 May 2023 00:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310303; x=1715846303; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lp/kxYtx5BEFPRdFsLdyjtEl8gwzWV0k0B49HXp6xmE=; b=ZkjhdRXALpIKRXXUoKhXjUDqLgKEK/IFLT6xlVi6LIug0FPV3Sw4OGD8 GrVEHtDzL/nsKmwSGGS30lMjRM31BnQKNtc8HYvNuBXlmGtEcNSPk02nw Evv9+AQU26OX1eTmv/wvbESVGLHaM+wP8FMnLH2TLKx9V0hQHPrYROwtN KLkks39b7KdYz9TudSCPem+Vpcmkq0agC2wcLDkqV7wfYEXc+MWfMMzT6 lDnVAjL3G+xeNxV9olLBqihUiPWlwNHrZF7Ot9a/F8h2WwKtREpg9DUEB GmT3wsb0S8JAgERkxNQjRq/YULCO6supYulvI1Cj2wOjoqzv1yT4Tpf7y A==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105376" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105376" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877272" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877272" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:04 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 05/34] acpi/button: Move handler installing logic to driver Date: Wed, 17 May 2023 09:56:55 +0200 Message-Id: <20230517075724.153992-6-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/acpi/button.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index 475e1eddfa3b..e978b2eafb27 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -126,7 +126,7 @@ static const struct dmi_system_id dmi_lid_quirks[] = { static int acpi_button_add(struct acpi_device *device); static void acpi_button_remove(struct acpi_device *device); -static void acpi_button_notify(struct acpi_device *device, u32 event); +static void acpi_button_notify(acpi_handle handle, u32 event, void *data); #ifdef CONFIG_PM_SLEEP static int acpi_button_suspend(struct device *dev); @@ -144,7 +144,6 @@ static struct acpi_driver acpi_button_driver = { .ops = { .add = acpi_button_add, .remove = acpi_button_remove, - .notify = acpi_button_notify, }, .drv.pm = &acpi_button_pm, }; @@ -400,11 +399,14 @@ static void acpi_lid_initialize_state(struct acpi_device *device) button->lid_state_initialized = true; } -static void acpi_button_notify(struct acpi_device *device, u32 event) +static void acpi_button_notify(acpi_handle handle, u32 event, void *data) { - struct acpi_button *button = acpi_driver_data(device); + struct acpi_device *device = data; + struct acpi_button *button; struct input_dev *input; + button = acpi_driver_data(device); + switch (event) { case ACPI_FIXED_HARDWARE_EVENT: event = ACPI_BUTTON_NOTIFY_STATUS; @@ -569,7 +571,12 @@ static int acpi_button_add(struct acpi_device *device) device_init_wakeup(&device->dev, true); pr_info("%s [%s]\n", name, acpi_device_bid(device)); - return 0; + + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_button_notify); + if (error) + goto err_remove_fs; + + return error; err_remove_fs: acpi_button_remove_fs(device); @@ -584,6 +591,7 @@ static void acpi_button_remove(struct acpi_device *device) { struct acpi_button *button = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_button_notify); acpi_button_remove_fs(device); input_unregister_device(button->input); kfree(button); From patchwork Wed May 17 07:56:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682952 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2808C77B7A for ; Wed, 17 May 2023 07:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbjEQH66 (ORCPT ); Wed, 17 May 2023 03:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjEQH6b (ORCPT ); Wed, 17 May 2023 03:58:31 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED98910F for ; Wed, 17 May 2023 00:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310303; x=1715846303; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BncRc/ualuZ8LcPyw+ub2qXe2KebX9KMoBldPR/5MXE=; b=JgHparphMB8+ZFY4kWL94fuibtmxykE6GYVdxxcS7Buq8k3wJWHwD9ns HfXftGVBbiSRFfkRqby03FJlVlh1Gq36NV2iATOZipniYcW4vw/VOLyeO IdLbZBy7idMVjag0mnY8cgdcBLdPzyu7WhBAq1+ibcMDeuOxO7hHiyNXB OISG3JbIrsuQ0eB30WNoZxwIRONqNcOsVE3b7Om+exL1GVih7ATdQjgIo /3ZjwPRJslN0NdfUoPb1GKD22FxP2ywi5j/hso6z6GmI9nof8gVhNwq// G0yMKZr+fPi8QigExNutVzPr4GOu1XWw9i+DQHlWPgVNgpNzakZTM4XGG Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105384" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105384" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877280" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877280" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:05 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 06/34] acpi/hed: Move handler installing logic to driver Date: Wed, 17 May 2023 09:56:56 +0200 Message-Id: <20230517075724.153992-7-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/acpi/hed.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c index 78d44e3fe129..2a476415817f 100644 --- a/drivers/acpi/hed.c +++ b/drivers/acpi/hed.c @@ -42,7 +42,7 @@ 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); } @@ -53,11 +53,12 @@ static int acpi_hed_add(struct acpi_device *device) if (hed_handle) return -EINVAL; hed_handle = device->handle; - return 0; + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_hed_notify); } static void acpi_hed_remove(struct acpi_device *device) { + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_hed_notify); hed_handle = NULL; } @@ -68,7 +69,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 Wed May 17 07:56:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682950 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26671C7EE2C for ; Wed, 17 May 2023 07:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbjEQH7B (ORCPT ); Wed, 17 May 2023 03:59:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230070AbjEQH6b (ORCPT ); Wed, 17 May 2023 03:58:31 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F2943AA3 for ; Wed, 17 May 2023 00:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310307; x=1715846307; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hM51g4LvmO5TXW4gm++QbkwmPKMxxaZZYt1NUl8p1KA=; b=BgUJfKKSqqdM6KmY3lK9IVb1azCP8aiCfvW64OS24KpqbUSb35MnrT7m x5LHl4jlSfGqyWZdml6nwbncRyu0dkCO89ywhWedcUNzTXP9KFsqGg/6G /tK4Sbdrg8qohz4iEhqaAiM4EF5sufn1HGes4N1uBbU6LLNY/b2iVeyg6 HXvbRbNFMMKNt4C2DcRxyzgFwFBcHDz/oCU9YPN9Spw8kpOUvPKQ0ZR2N 31ahF+Y95QASGSWeHygrhHXSomGorbGtRFLQD2ThdzFjW8BtFuAamDuiV nG2pk+T/OSlWgK/pUDf9Z9QDNffwvNQqANsXykBuRBp76MQh2M/KoVof/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105388" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105388" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877283" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877283" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:07 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 07/34] acpi/nfit: Move handler installing logic to driver Date: Wed, 17 May 2023 09:56:57 +0200 Message-Id: <20230517075724.153992-8-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/acpi/nfit/core.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 07204d482968..633c34513071 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -3312,6 +3312,15 @@ void acpi_nfit_shutdown(void *data) } EXPORT_SYMBOL_GPL(acpi_nfit_shutdown); +static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data) +{ + struct acpi_device *device = data; + + device_lock(&device->dev); + __acpi_nfit_notify(&device->dev, handle, event); + device_unlock(&device->dev); +} + static int acpi_nfit_add(struct acpi_device *adev) { struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; @@ -3368,12 +3377,18 @@ 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; + + return acpi_device_install_event_handler(adev, ACPI_DEVICE_NOTIFY, acpi_nfit_notify); } static void acpi_nfit_remove(struct acpi_device *adev) { /* see acpi_nfit_unregister */ + acpi_device_remove_event_handler(adev, ACPI_DEVICE_NOTIFY, acpi_nfit_notify); } static void acpi_nfit_update_notify(struct device *dev, acpi_handle handle) @@ -3446,13 +3461,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 +3473,6 @@ static struct acpi_driver acpi_nfit_driver = { .ops = { .add = acpi_nfit_add, .remove = acpi_nfit_remove, - .notify = acpi_nfit_notify, }, }; From patchwork Wed May 17 07:57:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9645DC7EE2D for ; Wed, 17 May 2023 07:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230002AbjEQH7C (ORCPT ); Wed, 17 May 2023 03:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230052AbjEQH6c (ORCPT ); Wed, 17 May 2023 03:58:32 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76F0344AB for ; Wed, 17 May 2023 00:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310308; x=1715846308; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wGccJ78CLi03k6nca7s4EOYG5mUfzdzU9KNUU7GPysY=; b=NEjJAgB416g4oNFTp/QzVLQv/ro2YeDQuDItAug8sccZFgoifSfnaAo1 sfjxM+6McpFU2kT6WWxNAXGV/qK1qJyZvFhYonxQZC+rGx+Lmh5tNk6Nx zToY/Q+FvlWnGDDVGqUQGm2Yjb4kWxjIMmNcAPugIzctIUGmKVLLP4KD3 tsw6lOUrc4EqShhE/J81HMKsRaI3Wm0fNIClWvxnC404RCYsoenTXuFbF DvrvmbR09FNR4DQusPqopzG0DfdsuPGPp4QojY8JT2s6vf86YqlVn1zZZ u105cp1Elrv7RJk/gQm7G85LO2BcezxQchWs7xL7ZAwMpfMa4mhshPNp7 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105401" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105401" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877314" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877314" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:11 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 10/34] hwmon: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:00 +0200 Message-Id: <20230517075724.153992-11-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/hwmon/acpi_power_meter.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c index fa28d447f0df..5cc43986d9ab 100644 --- a/drivers/hwmon/acpi_power_meter.c +++ b/drivers/hwmon/acpi_power_meter.c @@ -817,9 +817,10 @@ static int read_capabilities(struct acpi_power_meter_resource *resource) } /* Handle ACPI event notifications */ -static void acpi_power_meter_notify(struct acpi_device *device, u32 event) +static void acpi_power_meter_notify(acpi_handle handle, u32 event, void *data) { struct acpi_power_meter_resource *resource; + struct acpi_device *device = data; int res; if (!device || !acpi_driver_data(device)) @@ -897,8 +898,12 @@ static int acpi_power_meter_add(struct acpi_device *device) goto exit_remove; } - res = 0; - goto exit; + res = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_power_meter_notify); + if (res) + goto exit_remove; + + return res; exit_remove: remove_attrs(resource); @@ -906,7 +911,7 @@ static int acpi_power_meter_add(struct acpi_device *device) free_capabilities(resource); exit_free: kfree(resource); -exit: + return res; } @@ -917,6 +922,7 @@ static void acpi_power_meter_remove(struct acpi_device *device) if (!device || !acpi_driver_data(device)) return; + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_power_meter_notify); resource = acpi_driver_data(device); hwmon_device_unregister(resource->hwmon_dev); @@ -953,7 +959,6 @@ static struct acpi_driver acpi_power_meter_driver = { .ops = { .add = acpi_power_meter_add, .remove = acpi_power_meter_remove, - .notify = acpi_power_meter_notify, }, .drv.pm = pm_sleep_ptr(&acpi_power_meter_pm), }; From patchwork Wed May 17 07:57:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7BD1C77B7A for ; Wed, 17 May 2023 07:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230025AbjEQH7E (ORCPT ); Wed, 17 May 2023 03:59:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjEQH6c (ORCPT ); Wed, 17 May 2023 03:58:32 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CEC5468A for ; Wed, 17 May 2023 00:58:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310309; x=1715846309; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dpQXRY65iSYpMYBGCqugkZMcPMypiiSUk2q3EXCvg0U=; b=Lgh8DZlSeTq3LIz2/4M8wC7ovVl7QGVB1R2HSsrgEbVtdJRcQ2RSgCQc PkkLKECBL+xGpz2tu56lYNR8SexK79ZpErI3wL+ZNpfkkPYvqVU7xk72r Q7QyTFl3/7G7uQOIiDYPy3BQYj0kYNMxhOJU5wklQRgFC3IU+7bZHdGYJ Ed9wR5/jpmbhPkkHL7cAq4EX4PV3VJvAQl/2TajO9SqkNKbIF9X2MASeu bnNHq8O9VGt9q5zbpjOONuEHyn5qSGUB0Sqy15LKrv+b+dbQ4GGMx+dik qpOdLdo3CGTFdZpdwzcvmAEx79oJU1Aycw42mJ0GppFagRpO/F89zFIOu Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105415" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105415" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877378" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877378" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:16 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 13/34] platform/wilco_ec: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:03 +0200 Message-Id: <20230517075724.153992-14-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/platform/chrome/wilco_ec/event.c b/drivers/platform/chrome/wilco_ec/event.c index a40f60bcefb6..37b83e83f617 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,7 +484,12 @@ static int event_device_add(struct acpi_device *adev) if (error) goto free_dev_data; - return 0; + error = acpi_device_install_event_handler(adev, ACPI_DEVICE_NOTIFY, + event_device_notify); + if (error) + goto free_dev_data; + + return error; free_dev_data: hangup_device(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 Wed May 17 07:57:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D8C5C7EE2C for ; Wed, 17 May 2023 07:59:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbjEQH7F (ORCPT ); Wed, 17 May 2023 03:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230172AbjEQH6c (ORCPT ); Wed, 17 May 2023 03:58:32 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26C7A448C for ; Wed, 17 May 2023 00:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310310; x=1715846310; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sUDWyX/uI73hT1c0+d8t2xHxeHNXiv2b+eO60dyWbj0=; b=YC6YPh3+BiJoKOyzYjmNzkTu6UJNHPAkhicgkCVCarL5RiLwpIMrMDwN 5LD/As6rwPmoy3gjGAudcXfU3qrT3wgd2+B/a5Sal2BCZEo3Dr+xuaejf V72uOuI3tND/6OgT2QsjMfF3RiyXftgHR59LfJQlRc37OKYGmyQQv7g1Q b35rbhYrKayGtw7MgVy+FlHdpyFBSMi7B1awWMBe4P01ygfz2uTu22Pf1 Z8+PdMK3RYgTOGi9asGut3Qyh2cZniDjh20/KyfZ4YQpJ/GO142gBhNrB jJ7cirgd59kr/0avFoqpcE++A6jL72A72of1TaKdV7TjUnNo66/FEp3js A==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105419" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105419" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877387" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877387" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:17 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 14/34] platform/surface/button: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:04 +0200 Message-Id: <20230517075724.153992-15-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/surface/surfacepro3_button.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/platform/surface/surfacepro3_button.c b/drivers/platform/surface/surfacepro3_button.c index 2755601f979c..a6892242f747 100644 --- a/drivers/platform/surface/surfacepro3_button.c +++ b/drivers/platform/surface/surfacepro3_button.c @@ -71,13 +71,16 @@ struct surface_button { bool suspended; }; -static void surface_button_notify(struct acpi_device *device, u32 event) +static void surface_button_notify(acpi_handle handle, u32 event, void *data) { - struct surface_button *button = acpi_driver_data(device); - struct input_dev *input; + struct acpi_device *device = data; + struct surface_button *button; int key_code = KEY_RESERVED; + struct input_dev *input; bool pressed = false; + button = acpi_driver_data(device); + switch (event) { /* Power button press,release handle */ case SURFACE_BUTTON_NOTIFY_PRESS_POWER: @@ -230,7 +233,13 @@ static int surface_button_add(struct acpi_device *device) device_init_wakeup(&device->dev, true); dev_info(&device->dev, "%s [%s]\n", name, acpi_device_bid(device)); - return 0; + + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + surface_button_notify); + if (error) + goto err_free_input; + + return error; err_free_input: input_free_device(input); @@ -243,6 +252,7 @@ static void surface_button_remove(struct acpi_device *device) { struct surface_button *button = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, surface_button_notify); input_unregister_device(button->input); kfree(button); } @@ -257,7 +267,6 @@ static struct acpi_driver surface_button_driver = { .ops = { .add = surface_button_add, .remove = surface_button_remove, - .notify = surface_button_notify, }, .drv.pm = &surface_button_pm, }; From patchwork Wed May 17 07:57:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A924CC77B7F for ; Wed, 17 May 2023 07:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230061AbjEQH7H (ORCPT ); Wed, 17 May 2023 03:59:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbjEQH6c (ORCPT ); Wed, 17 May 2023 03:58:32 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A60E95256 for ; Wed, 17 May 2023 00:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310310; x=1715846310; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g78n4JtrV5AuyACtMRvoWGwc1OTpMBYSGKwkHgUu8Lc=; b=YnE8Ht4UMMZ0a6U5Tcn95cqn4XGmLdBYkPn0RYzP7VCoFCvZ7O/LBIS9 aRjO+cvUQZ4rsK9LNFmCW6UOghYZ6O0vEnEx6JdckCbZMg0/bg68Omu1q 1XGCJE9Z7CWLxK6z9dJkbhKyzH11Z0qHjf8BrH550fdOxo3/Cahm2DtvJ xrB5CdNzaINBW9bvSskayHNx9QtyzSftrZJS2De6rhkepmlZgJVVWRj8Y DVy8zn3KIAZD1xU+sIPm+i0fE5rVzG+JERs//DsnLFi8Dp50MulHfSy/g rHz+rYEc5+qnP/9ytfqclIQmylww1VsczWbh+/0Nocg4H181HYx2TCyyn g==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105431" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105431" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877401" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877401" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:20 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 16/34] platform/x86/asus-laptop: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:06 +0200 Message-Id: <20230517075724.153992-17-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/x86/asus-laptop.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 761029f39314..fa348c96be16 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -1515,11 +1515,14 @@ static void asus_input_exit(struct asus_laptop *asus) /* * ACPI driver */ -static void asus_acpi_notify(struct acpi_device *device, u32 event) +static void asus_acpi_notify(acpi_handle handle, u32 event, void *data) { - struct asus_laptop *asus = acpi_driver_data(device); + struct acpi_device *device = data; + struct asus_laptop *asus; u16 count; + asus = acpi_driver_data(device); + /* TODO Find a better way to handle events count. */ count = asus->event_count[event % 128]++; acpi_bus_generate_netlink_event(asus->device->pnp.device_class, @@ -1880,8 +1883,12 @@ static int asus_acpi_add(struct acpi_device *device) if (result && result != -ENODEV) goto fail_pega_rfkill; + result = acpi_device_install_event_handler(device, ACPI_ALL_NOTIFY, asus_acpi_notify); + if (result) + goto fail_pega_rfkill; + asus_device_present = true; - return 0; + return result; fail_pega_rfkill: pega_accel_exit(asus); @@ -1905,6 +1912,7 @@ static void asus_acpi_remove(struct acpi_device *device) { struct asus_laptop *asus = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_ALL_NOTIFY, asus_acpi_notify); asus_backlight_exit(asus); asus_rfkill_exit(asus); asus_led_exit(asus); @@ -1928,11 +1936,9 @@ static struct acpi_driver asus_acpi_driver = { .class = ASUS_LAPTOP_CLASS, .owner = THIS_MODULE, .ids = asus_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = asus_acpi_add, .remove = asus_acpi_remove, - .notify = asus_acpi_notify, }, }; From patchwork Wed May 17 07:57:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66C7CC77B7A for ; Wed, 17 May 2023 07:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230095AbjEQH7J (ORCPT ); Wed, 17 May 2023 03:59:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230130AbjEQH6d (ORCPT ); Wed, 17 May 2023 03:58:33 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C58EE76 for ; Wed, 17 May 2023 00:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310311; x=1715846311; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sz9IE9cEgIQ2ESLugoWDtFHJtdLMme7uINSzOKz8WUA=; b=L3oZAe3KqD9nfRg9WG2XcBLxUGLC2vDACA7R0IhCTTAmlYs0usKErHQ+ 8iBAVllCK3OK0QUqQH/ve6uaXxf/Ah9aKlBBu/VrvDJ3PMaGiXMblxfyf X4PQWtsbDv5jFegt/9ju7cb3kFMLVLozkzWtTcrYB9+qyKlWB8kOCDu1K IgxM6I1As2tfOp7n2Do/4fA2UrrVKXYh/oPfN5lktC7cnjRdk9kQ7u3e8 DKLI6Uqs2cEUqGax87M+UH836LhYz5CTPbvJPuUOAggdZHtJI+Gb3yH6Z K7abJXc3IXAcZ/zgnMVdCp1XMLJ9a386dFe2hJsRhh+grvYS1YD1STCJV w==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105448" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105448" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877416" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877416" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:23 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 18/34] platform/x86/classmate-laptop: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:08 +0200 Message-Id: <20230517075724.153992-19-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/x86/classmate-laptop.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c index 2edaea2492df..f8f84ee9de33 100644 --- a/drivers/platform/x86/classmate-laptop.c +++ b/drivers/platform/x86/classmate-laptop.c @@ -180,8 +180,9 @@ static acpi_status cmpc_get_accel_v4(acpi_handle handle, return status; } -static void cmpc_accel_handler_v4(struct acpi_device *dev, u32 event) +static void cmpc_accel_handler_v4(acpi_handle handle, u32 event, void *data) { + struct acpi_device *dev = data; if (event == 0x81) { int16_t x, y, z; acpi_status status; @@ -407,7 +408,12 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi) inputdev = dev_get_drvdata(&acpi->dev); dev_set_drvdata(&inputdev->dev, accel); - return 0; + error = acpi_device_install_event_handler(acpi, ACPI_DEVICE_NOTIFY, + cmpc_accel_handler_v4); + if (error) + goto failed_input; + + return error; failed_input: device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4); @@ -420,6 +426,7 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi) static void cmpc_accel_remove_v4(struct acpi_device *acpi) { + acpi_device_remove_event_handler(acpi, ACPI_DEVICE_NOTIFY, cmpc_accel_handler_v4); device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4); device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4); cmpc_remove_acpi_notify_device(acpi); @@ -1071,7 +1078,6 @@ static struct acpi_driver cmpc_keys_acpi_driver = { .ops = { .add = cmpc_keys_add, .remove = cmpc_keys_remove, - .notify = cmpc_keys_handler, } }; From patchwork Wed May 17 07:57:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 117E3C77B7F for ; Wed, 17 May 2023 07:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230154AbjEQH7K (ORCPT ); Wed, 17 May 2023 03:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbjEQH6d (ORCPT ); Wed, 17 May 2023 03:58:33 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 081FE448A for ; Wed, 17 May 2023 00:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310312; x=1715846312; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M18Y4ESYBbWWb1sZBQk4GchI+XsAWtvKvgHYAo/nLJA=; b=OP6OXWjJVsqww9O3BSJ42oxsetz9eMQN1k/RCZXv11qXY89H6Il3b9gR FObOVTxUi9DhcbJV5LxmSpyhydLb/HXdvnyzxS9UG5Hq7bnBLugDyc12C 2x2Jq5W1+9Fup6/TNxR7bQpC+xveJiDUUGcwcW9xerC8wogh6BYH/uXdi mrdDd99ccCT/idrMZuECZQPsDAW3JlZjWlkRMq2PqEPGcTwo9GRM1FCO3 QTj8dOh9JZkgFhjb/yglfWdDsTnzIFxL1v2cHGryX0YsehrqA4rCLBlV3 5xBzvkYogz+zFXjrUG1Iri84OLAOfURExDKqKZSyBY+isq4KZ/73MJrO3 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105458" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105458" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877432" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877432" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:26 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 20/34] platform/x86/eeepc-laptop: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:10 +0200 Message-Id: <20230517075724.153992-21-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/x86/eeepc-laptop.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index 62b71e8e3567..65c3101ea431 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c @@ -1204,12 +1204,15 @@ static void eeepc_input_notify(struct eeepc_laptop *eeepc, int event) pr_info("Unknown key %x pressed\n", event); } -static void eeepc_acpi_notify(struct acpi_device *device, u32 event) +static void eeepc_acpi_notify(acpi_handle handle, u32 event, void *data) { - struct eeepc_laptop *eeepc = acpi_driver_data(device); int old_brightness, new_brightness; + struct acpi_device *device = data; + struct eeepc_laptop *eeepc; u16 count; + eeepc = acpi_driver_data(device); + if (event > ACPI_MAX_SYS_NOTIFY) return; count = eeepc->event_count[event % 128]++; @@ -1423,7 +1426,12 @@ static int eeepc_acpi_add(struct acpi_device *device) goto fail_rfkill; eeepc_device_present = true; - return 0; + result = acpi_device_install_event_handler(device, ACPI_ALL_NOTIFY, + eeepc_acpi_notify); + if (result) + goto fail_rfkill; + + return result; fail_rfkill: eeepc_led_exit(eeepc); @@ -1444,6 +1452,8 @@ static void eeepc_acpi_remove(struct acpi_device *device) { struct eeepc_laptop *eeepc = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_ALL_NOTIFY, + eeepc_acpi_notify); eeepc_backlight_exit(eeepc); eeepc_rfkill_exit(eeepc); eeepc_input_exit(eeepc); @@ -1465,11 +1475,9 @@ static struct acpi_driver eeepc_acpi_driver = { .class = EEEPC_ACPI_CLASS, .owner = THIS_MODULE, .ids = eeepc_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = eeepc_acpi_add, .remove = eeepc_acpi_remove, - .notify = eeepc_acpi_notify, }, }; From patchwork Wed May 17 07:57:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85884C7EE23 for ; Wed, 17 May 2023 07:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbjEQH7P (ORCPT ); Wed, 17 May 2023 03:59:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbjEQH6e (ORCPT ); Wed, 17 May 2023 03:58:34 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD3A4225 for ; Wed, 17 May 2023 00:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310312; x=1715846312; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FeWTR1TcYGn2nHZn1Di77iaxrb5GIaXYv/p/XtxkbXs=; b=UF8CyPbzHj+uuB5xo9ivoGOVg+JcUEtAyvrsq8+xSCghA9c7sP56/ZNw 2eAcLk9XQlPycU0zdd0V0xY0OINHu1H/4ay4iPBG4hXl+mW9yZmbRXKSr n+tCXonMGjz54GBUvtPzrwclF9Jf76d2X731MdhBJyvKF+gWzRqMqSZFb ZMpNRjih3taXNNaRLrn87o1DByUCvBAByi2o5QQM9l40W2urMOG3w7igS hIZVhaSaDE97MgefHAIMzCF074hLPmG0yCqG0XNSzyqX/UqwnQA5cBLP3 RISurdy/GuQebGTZqOtp1cwmeS2tUZwpwbXnTcod5N2uHstxpIBnpx2e1 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105462" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105462" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877437" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877437" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:28 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 21/34] platform/x86/fujitsu-laptop: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:11 +0200 Message-Id: <20230517075724.153992-22-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/x86/fujitsu-laptop.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c index 085e044e888e..e270660c0762 100644 --- a/drivers/platform/x86/fujitsu-laptop.c +++ b/drivers/platform/x86/fujitsu-laptop.c @@ -136,6 +136,8 @@ struct fujitsu_laptop { static struct acpi_device *fext; +static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data); + /* Fujitsu ACPI interface function */ static int call_fext_func(struct acpi_device *device, @@ -839,7 +841,12 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device) if (ret) goto err_free_fifo; - return 0; + ret = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, + acpi_fujitsu_laptop_notify); + if (ret) + goto err_free_fifo; + + return ret; err_free_fifo: kfifo_free(&priv->fifo); @@ -851,6 +858,8 @@ static void acpi_fujitsu_laptop_remove(struct acpi_device *device) { struct fujitsu_laptop *priv = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acpi_fujitsu_laptop_notify); + fujitsu_laptop_platform_remove(device); kfifo_free(&priv->fifo); @@ -889,13 +898,16 @@ static void acpi_fujitsu_laptop_release(struct acpi_device *device) } } -static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event) +static void acpi_fujitsu_laptop_notify(acpi_handle handle, u32 event, void *data) { - struct fujitsu_laptop *priv = acpi_driver_data(device); + struct acpi_device *device = data; + struct fujitsu_laptop *priv; unsigned long flags; int scancode, i = 0; unsigned int irb; + priv = acpi_driver_data(device); + if (event != ACPI_FUJITSU_NOTIFY_CODE) { acpi_handle_info(device->handle, "Unsupported event [0x%x]\n", event); @@ -963,7 +975,6 @@ static struct acpi_driver acpi_fujitsu_laptop_driver = { .ops = { .add = acpi_fujitsu_laptop_add, .remove = acpi_fujitsu_laptop_remove, - .notify = acpi_fujitsu_laptop_notify, }, }; From patchwork Wed May 17 07:57:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682942 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EFCCC7EE2A for ; Wed, 17 May 2023 07:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230273AbjEQH7P (ORCPT ); Wed, 17 May 2023 03:59:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229867AbjEQH6f (ORCPT ); Wed, 17 May 2023 03:58:35 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 618143C3A for ; Wed, 17 May 2023 00:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310314; x=1715846314; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=txzmCeCA/MPyNx/npYsx9yZon2/dCun/SRz4VGygQnU=; b=fNxb5hFv1o4GdSU088Tag/KvdrUpDA7P/TiHCThAE6LRIV6xufWvKXpW tU0bl5hgMuFGg57Kp8PZb+X3BnTXtiJT9zFPvmdot4mKY45xbJhBbL3jV PdjaKVHepR/IRvvWsYtx4RiYOphyTnyArYNw3KBYr9zThhHlg+SWPRRMt m9yD2Fs1B1tsQ4MDIsrVWToIWDlsP83DBt4K7nl8Wlmog2rSpi4/ubT2o O0EBPWo/jr0/5dyYhWQD6fzguU8XwiOjuO5hOMmxbZVjJIY9NrkQbJcvT I5Iq2pm1jJ5TFCL/bf34pE9Dm7lDMsUSwS0uYWGsDUqDY8VB1u0O4GoJ/ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105477" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105477" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877463" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877463" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:32 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 24/34] platform/x86/system76_acpi: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:14 +0200 Message-Id: <20230517075724.153992-25-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/x86/system76_acpi.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/platform/x86/system76_acpi.c b/drivers/platform/x86/system76_acpi.c index 97f5a8255b91..3e729ec08b8b 100644 --- a/drivers/platform/x86/system76_acpi.c +++ b/drivers/platform/x86/system76_acpi.c @@ -627,29 +627,30 @@ static void input_key(struct system76_data *data, unsigned int code) } // Handle ACPI notification -static void system76_notify(struct acpi_device *acpi_dev, u32 event) +static void system76_notify(acpi_handle handle, u32 event, void *data) { - struct system76_data *data; + struct acpi_device *acpi_dev = data; + struct system76_data *s_data; - data = acpi_driver_data(acpi_dev); + s_data = acpi_driver_data(acpi_dev); switch (event) { case 0x80: - kb_led_hotkey_hardware(data); + kb_led_hotkey_hardware(s_data); break; case 0x81: - kb_led_hotkey_toggle(data); + kb_led_hotkey_toggle(s_data); break; case 0x82: - kb_led_hotkey_down(data); + kb_led_hotkey_down(s_data); break; case 0x83: - kb_led_hotkey_up(data); + kb_led_hotkey_up(s_data); break; case 0x84: - kb_led_hotkey_color(data); + kb_led_hotkey_color(s_data); break; case 0x85: - input_key(data, KEY_SCREENLOCK); + input_key(s_data, KEY_SCREENLOCK); break; } } @@ -733,7 +734,11 @@ static int system76_add(struct acpi_device *acpi_dev) system76_battery_init(); } - return 0; + err = acpi_device_install_event_handler(acpi_dev, ACPI_DEVICE_NOTIFY, system76_notify); + if (err) + goto error; + + return err; error: if (data->has_open_ec) { @@ -750,6 +755,8 @@ static void system76_remove(struct acpi_device *acpi_dev) data = acpi_driver_data(acpi_dev); + acpi_device_remove_event_handler(acpi_dev, ACPI_DEVICE_NOTIFY, system76_notify); + if (data->has_open_ec) { system76_battery_exit(); kfree(data->nfan); @@ -769,7 +776,6 @@ static struct acpi_driver system76_driver = { .ops = { .add = system76_add, .remove = system76_remove, - .notify = system76_notify, }, }; module_acpi_driver(system76_driver); From patchwork Wed May 17 07:57:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9F28C77B7A for ; Wed, 17 May 2023 07:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbjEQH7S (ORCPT ); Wed, 17 May 2023 03:59:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbjEQH6i (ORCPT ); Wed, 17 May 2023 03:58:38 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57272E4 for ; Wed, 17 May 2023 00:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310317; x=1715846317; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6qztspbuvFvAW/W8wYhffgZucSx6tOdeUUrglpHXvAY=; b=XZXoXmy8FX4oH5Z81J0Bezddbfs+uSWzjvyw5Qe0sJVcYfS0z1XW3KOQ mdl6IBq6HhxHIdnXqcXUhBrCLdBX7EuKH56C99mgcaAuR+lA7Bq8ZKJWy zosNTHIeqqRnVVZFuqb1CZgZN5E1PP/EPVYlFrn8XW2zKG6N9VxNWO9yD v/kV/WVLBXfKg+XBjtpqEbUEbEe91eV6z30yfAUKHrH5xgXrLRn9cUwzw HLd2/mgmSaj6wL91YdPDXdlMPu7qgqZFMs/tGmoERiwuioF1PyTZd+hfW VrIiIyNPHMzPfUaxa1uKrPi5tK3+lhrpw7wrV8hK8mRRGimBnUPVwu/5c w==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105487" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105487" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877489" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877489" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:35 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 26/34] platform/x86/toshiba_acpi: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:16 +0200 Message-Id: <20230517075724.153992-27-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/x86/toshiba_acpi.c | 131 +++++++++++++++------------- 1 file changed, 69 insertions(+), 62 deletions(-) diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index b34984bbee33..628c7910d653 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c @@ -3186,10 +3186,74 @@ static void print_supported_features(struct toshiba_acpi_dev *dev) pr_cont("\n"); } +static void toshiba_acpi_notify(acpi_handle handle, u32 event, void *data) +{ + struct acpi_device *acpi_dev = data; + struct toshiba_acpi_dev *dev; + + dev = acpi_driver_data(acpi_dev); + + switch (event) { + case 0x80: /* Hotkeys and some system events */ + /* + * Machines with this WMI GUID aren't supported due to bugs in + * their AML. + * + * Return silently to avoid triggering a netlink event. + */ + if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID)) + return; + toshiba_acpi_process_hotkeys(dev); + break; + case 0x81: /* Dock events */ + case 0x82: + case 0x83: + pr_info("Dock event received %x\n", event); + break; + case 0x88: /* Thermal events */ + pr_info("Thermal event received\n"); + break; + case 0x8f: /* LID closed */ + case 0x90: /* LID is closed and Dock has been ejected */ + break; + case 0x8c: /* SATA power events */ + case 0x8b: + pr_info("SATA power event received %x\n", event); + break; + case 0x92: /* Keyboard backlight mode changed */ + dev->kbd_event_generated = true; + /* Update sysfs entries */ + if (sysfs_update_group(&acpi_dev->dev.kobj, + &toshiba_attr_group)) + pr_err("Unable to update sysfs entries\n"); + /* Notify LED subsystem about keyboard backlight change */ + if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO) + led_classdev_notify_brightness_hw_changed(&dev->kbd_led, + (dev->kbd_mode == SCI_KBD_MODE_ON) ? + LED_FULL : LED_OFF); + break; + case 0x85: /* Unknown */ + case 0x8d: /* Unknown */ + case 0x8e: /* Unknown */ + case 0x94: /* Unknown */ + case 0x95: /* Unknown */ + default: + pr_info("Unknown event received %x\n", event); + break; + } + + acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class, + dev_name(&acpi_dev->dev), + event, (event == 0x80) ? + dev->last_key_event : 0); +} + static void toshiba_acpi_remove(struct acpi_device *acpi_dev) { struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); + acpi_device_remove_event_handler(acpi_dev, ACPI_ALL_NOTIFY, toshiba_acpi_notify); + misc_deregister(&dev->miscdev); remove_toshiba_proc_entries(dev); @@ -3473,72 +3537,17 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) if (dev->battery_charge_mode_supported) battery_hook_register(&battery_hook); - return 0; + ret = acpi_device_install_event_handler(acpi_dev, ACPI_ALL_NOTIFY, toshiba_acpi_notify); + if (ret) + goto error; + + return ret; error: toshiba_acpi_remove(acpi_dev); return ret; } -static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event) -{ - struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); - - switch (event) { - case 0x80: /* Hotkeys and some system events */ - /* - * Machines with this WMI GUID aren't supported due to bugs in - * their AML. - * - * Return silently to avoid triggering a netlink event. - */ - if (wmi_has_guid(TOSHIBA_WMI_EVENT_GUID)) - return; - toshiba_acpi_process_hotkeys(dev); - break; - case 0x81: /* Dock events */ - case 0x82: - case 0x83: - pr_info("Dock event received %x\n", event); - break; - case 0x88: /* Thermal events */ - pr_info("Thermal event received\n"); - break; - case 0x8f: /* LID closed */ - case 0x90: /* LID is closed and Dock has been ejected */ - break; - case 0x8c: /* SATA power events */ - case 0x8b: - pr_info("SATA power event received %x\n", event); - break; - case 0x92: /* Keyboard backlight mode changed */ - dev->kbd_event_generated = true; - /* Update sysfs entries */ - if (sysfs_update_group(&acpi_dev->dev.kobj, - &toshiba_attr_group)) - pr_err("Unable to update sysfs entries\n"); - /* Notify LED subsystem about keyboard backlight change */ - if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO) - led_classdev_notify_brightness_hw_changed(&dev->kbd_led, - (dev->kbd_mode == SCI_KBD_MODE_ON) ? - LED_FULL : LED_OFF); - break; - case 0x85: /* Unknown */ - case 0x8d: /* Unknown */ - case 0x8e: /* Unknown */ - case 0x94: /* Unknown */ - case 0x95: /* Unknown */ - default: - pr_info("Unknown event received %x\n", event); - break; - } - - acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class, - dev_name(&acpi_dev->dev), - event, (event == 0x80) ? - dev->last_key_event : 0); -} - #ifdef CONFIG_PM_SLEEP static int toshiba_acpi_suspend(struct device *device) { @@ -3583,11 +3592,9 @@ static struct acpi_driver toshiba_acpi_driver = { .name = "Toshiba ACPI driver", .owner = THIS_MODULE, .ids = toshiba_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = toshiba_acpi_add, .remove = toshiba_acpi_remove, - .notify = toshiba_acpi_notify, }, .drv.pm = &toshiba_acpi_pm, }; From patchwork Wed May 17 07:57:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682940 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA7BEC77B7F for ; Wed, 17 May 2023 07:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbjEQH7V (ORCPT ); Wed, 17 May 2023 03:59:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230187AbjEQH6l (ORCPT ); Wed, 17 May 2023 03:58:41 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E085CEA for ; Wed, 17 May 2023 00:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310319; x=1715846319; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vPErQFvNbDQV5UxbBwjTeZS4Z3UrzYSQ/WcQgm1VIHs=; b=WaJylMIS2wnnFk4jmCFsovqcM4oKy8a2XAp+tKiiOo6wk357xuMLx6dk 8dxokD1qFS1p1Q+759a1lc/8mmUthQjCEWUMBBHZTSL+rIAx8gbBR9DYi WSdOg72eflKD6pekStuVydkuJaGAwjwrMzSwBdFHn3v5PtoNiOWjW5Z6K 1scPz+CQhULur/3AZUr3GpcwyGiJ5Lmr6Tx6qWxHwKFvhiYqb/oMWTUUm ip350QXi/4oq0IzCmwG2ptrSMrjEKJ44I3qn2kVo8oLHaxOzXJ9mFx0mr Pmpr/TKqDMRoBA5XJvEhbemK5Qq15LwcZA+lEm4lFyLyqMKlna3WgaoIx Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105497" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105497" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877511" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877511" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:38 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 28/34] platform/x86/toshiba_haps: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:18 +0200 Message-Id: <20230517075724.153992-29-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/x86/toshiba_haps.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86/toshiba_haps.c index 8c9f76286b08..39e4c49847a8 100644 --- a/drivers/platform/x86/toshiba_haps.c +++ b/drivers/platform/x86/toshiba_haps.c @@ -129,8 +129,10 @@ static const struct attribute_group haps_attr_group = { /* * ACPI stuff */ -static void toshiba_haps_notify(struct acpi_device *device, u32 event) +static void toshiba_haps_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; + pr_debug("Received event: 0x%x\n", event); acpi_bus_generate_netlink_event(device->pnp.device_class, @@ -140,6 +142,7 @@ static void toshiba_haps_notify(struct acpi_device *device, u32 event) static void toshiba_haps_remove(struct acpi_device *device) { + acpi_device_remove_event_handler(device, ACPI_ALL_NOTIFY, toshiba_haps_notify); sysfs_remove_group(&device->dev.kobj, &haps_attr_group); if (toshiba_haps) @@ -203,7 +206,7 @@ static int toshiba_haps_add(struct acpi_device *acpi_dev) toshiba_haps = haps; - return 0; + return acpi_device_install_event_handler(acpi_dev, ACPI_ALL_NOTIFY, toshiba_haps_notify); } #ifdef CONFIG_PM_SLEEP @@ -253,11 +256,9 @@ static struct acpi_driver toshiba_haps_driver = { .name = "Toshiba HAPS", .owner = THIS_MODULE, .ids = haps_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = toshiba_haps_add, .remove = toshiba_haps_remove, - .notify = toshiba_haps_notify, }, .drv.pm = &toshiba_haps_pm, }; From patchwork Wed May 17 07:57:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0483C77B7F for ; Wed, 17 May 2023 07:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230201AbjEQH7q (ORCPT ); Wed, 17 May 2023 03:59:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230173AbjEQH6n (ORCPT ); Wed, 17 May 2023 03:58:43 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5DC0DA for ; Wed, 17 May 2023 00:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310322; x=1715846322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y0VBERQ5PR3nyeSq+O7hX0oeQ5wwm1bOcmrLZAB/n3I=; b=VwLv3sDRmRJndKJJl74fBhJOctNbjiDE/gVljblQEroeimYjAqAePHuc wKWWN/tIO65FG90Kp/gqcxxUL6YDW1S94zqWU3wMIJWKVAKaTc+AKAlGA pmc2O5lForxgDY62Lhv2owSclEUsiIq3j5HNC5L77j6342gnCM+21H/sF xLkEEt4hC/TgxQ1g1gugB2fpJzpjT2sYBjc5GIUUuQ3wb88f1yUgiu4Wi F6x+sbK8jQywq4/CA28qUWzI8dmNvFgy/mQoAu8mP1Uyckss2m7p/Q45w inJXVgRp/r5SSmIozBZVBQSn7cp3Revd3fgSySGcQaD3UsIJ4Qm/N7QFn g==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105501" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105501" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877532" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877532" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:41 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 30/34] platform/x86/xo15-ebook: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:20 +0200 Message-Id: <20230517075724.153992-31-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/x86/xo15-ebook.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/xo15-ebook.c b/drivers/platform/x86/xo15-ebook.c index 391f7ea4431e..8b5b05429889 100644 --- a/drivers/platform/x86/xo15-ebook.c +++ b/drivers/platform/x86/xo15-ebook.c @@ -56,8 +56,9 @@ static int ebook_send_state(struct acpi_device *device) return 0; } -static void ebook_switch_notify(struct acpi_device *device, u32 event) +static void ebook_switch_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; switch (event) { case ACPI_FIXED_HARDWARE_EVENT: case XO15_EBOOK_NOTIFY_STATUS: @@ -134,7 +135,11 @@ static int ebook_switch_add(struct acpi_device *device) device_set_wakeup_enable(&device->dev, true); } - return 0; + error = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, ebook_switch_notify); + if (error) + goto err_free_input; + + return error; err_free_input: input_free_device(input); @@ -147,6 +152,7 @@ static void ebook_switch_remove(struct acpi_device *device) { struct ebook_switch *button = acpi_driver_data(device); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, ebook_switch_notify); input_unregister_device(button->input); kfree(button); } @@ -158,7 +164,6 @@ static struct acpi_driver xo15_ebook_driver = { .ops = { .add = ebook_switch_add, .remove = ebook_switch_remove, - .notify = ebook_switch_notify, }, .drv.pm = &ebook_switch_pm, }; From patchwork Wed May 17 07:57:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13A8CC7EE23 for ; Wed, 17 May 2023 07:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230173AbjEQH7r (ORCPT ); Wed, 17 May 2023 03:59:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230203AbjEQH6p (ORCPT ); Wed, 17 May 2023 03:58:45 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D76BCE56 for ; Wed, 17 May 2023 00:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310324; x=1715846324; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+ts6C5JUZkQiwH7gJ6stxKKdR9KfqEVngICJLmKLlXY=; b=NaHrA3eAZzVvt1btTOnYuKkGP8TwKNTkM22UGM0jLapBTwHyI/YyTho9 gitDrGJsarQkJiZsEbqNH6S7G/RlE0TPb/bJeTdwMyF8Mr8aPnzNVujSD UG80tF4lkQRSPdDOkdreEyEr1vHb2Ce5y+W8yIlQrAcphnXQQle9u94Fi VAWzKggFfEve6zQu8Pwu5QniuYTfc6ii+wFNVDsP2mgrYuaFpV069gqfM Pvm0eRlUvIbjBsNpto3zOeY86m7kcJsQIIUtzxW+GDAffcc8eKoPW4gnS 2WzblC+R9NUFBDDnvC5Ke6Bx3Hg4iuZ0FKbGXrZrYGAwkhjmEuvC0j5Ps g==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105505" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105505" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877538" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877538" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:42 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 31/34] virt/vmgenid: Move handler installing logic to driver Date: Wed, 17 May 2023 09:57:21 +0200 Message-Id: <20230517075724.153992-32-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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/virt/vmgenid.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/virt/vmgenid.c b/drivers/virt/vmgenid.c index a1c467a0e9f7..50e7f4a82f99 100644 --- a/drivers/virt/vmgenid.c +++ b/drivers/virt/vmgenid.c @@ -21,6 +21,21 @@ struct vmgenid_state { u8 this_id[VMGENID_SIZE]; }; +static void vmgenid_notify(acpi_handle handle, u32 event, void *data) +{ + struct acpi_device *device = data; + struct vmgenid_state *state; + u8 old_id[VMGENID_SIZE]; + + state = acpi_driver_data(device); + + memcpy(old_id, state->this_id, sizeof(old_id)); + memcpy(state->this_id, state->next_id, sizeof(state->this_id)); + if (!memcmp(old_id, state->this_id, sizeof(old_id))) + return; + add_vmfork_randomness(state->this_id, sizeof(state->this_id)); +} + static int vmgenid_add(struct acpi_device *device) { struct acpi_buffer parsed = { ACPI_ALLOCATE_BUFFER }; @@ -60,21 +75,16 @@ static int vmgenid_add(struct acpi_device *device) device->driver_data = state; + ret = acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, vmgenid_notify); + out: ACPI_FREE(parsed.pointer); return ret; } -static void vmgenid_notify(struct acpi_device *device, u32 event) +static void vmgenid_remove(struct acpi_device *device) { - struct vmgenid_state *state = acpi_driver_data(device); - u8 old_id[VMGENID_SIZE]; - - memcpy(old_id, state->this_id, sizeof(old_id)); - memcpy(state->this_id, state->next_id, sizeof(state->this_id)); - if (!memcmp(old_id, state->this_id, sizeof(old_id))) - return; - add_vmfork_randomness(state->this_id, sizeof(state->this_id)); + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, vmgenid_notify); } static const struct acpi_device_id vmgenid_ids[] = { @@ -89,7 +99,7 @@ static struct acpi_driver vmgenid_driver = { .owner = THIS_MODULE, .ops = { .add = vmgenid_add, - .notify = vmgenid_notify + .remove = vmgenid_remove, } }; From patchwork Wed May 17 07:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 682937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8D05C77B7A for ; Wed, 17 May 2023 08:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbjEQH7t (ORCPT ); Wed, 17 May 2023 03:59:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230270AbjEQH6t (ORCPT ); Wed, 17 May 2023 03:58:49 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED7C8272D for ; Wed, 17 May 2023 00:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684310327; x=1715846327; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=znjg1HTj5xvxahu+0hAY1ilrkW02Q96e/dE6fQc+3t4=; b=FVpqrWwKcGJf1iUl+ibXFmc19FGmTbT00C+ADJmFkOm15jo36Deo44dY 5yPXSYkJR97mMd8mD6IVIvW4uaqNvcQZ2i1rwFcDQtUcj7Z0hwUfU00v0 6JGskGNGbZtguI4l3IqjhGHcM03rGrUo7bIZYCUn9MWwfF2PnbTJq3X81 wb+tj/qyytXMjEBYeKW9t25WatTMfODocqfJMb4XseU+NmDFPbRWht7Qq CFGB6fY3tJhNfKMyeNg/7McvGi+rO0EmA2geJ0BZ+TDiAz28PvJ7vmEbO +yA2ZQO/VYz2cMvw38BXexl0vQL0mmk12f1PRgLq3jKZ2yLpfdyiuilDM w==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="415105520" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="415105520" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="825877564" X-IronPort-AV: E=Sophos;i="5.99,281,1677571200"; d="scan'208";a="825877564" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 00:58:45 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, srinivas.pandruvada@linux.intel.com, Michal Wilczynski Subject: [PATCH v3 33/34] acpi/bus: Remove redundant functions Date: Wed, 17 May 2023 09:57:23 +0200 Message-Id: <20230517075724.153992-34-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230517075724.153992-1-michal.wilczynski@intel.com> References: <20230517075724.153992-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 3eeeec70e70b..bf0704bf8e04 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*))