From patchwork Fri Jun 30 18:33:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilczynski, Michal" X-Patchwork-Id: 114854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10587513vqr; Fri, 30 Jun 2023 11:51:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlHAu2cuomo70TC1U6X3ogUwh2AOkiSL0RzEbC2RmHuP5ngJLEOL83G09JquAAhD9mxGozHV X-Received: by 2002:a17:902:a416:b0:1b8:1e05:ed09 with SMTP id p22-20020a170902a41600b001b81e05ed09mr2367870plq.36.1688151070831; Fri, 30 Jun 2023 11:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688151070; cv=none; d=google.com; s=arc-20160816; b=ga/1ef/WNRUlugZ7ANFZOY0e2AO/lMYoLpTzA/WMKIx0vk5TQ95+YG2NhqjqJuViRe 9IFf41S1IK4EMA6WT5lD313nKDjoh+2Zg0MBC8W1jAqfpcFESoYtb9OgAqfBhO3pkcp0 98ZFL8m+kK2VzhkFzJrKN8VDcAQZfCTQ0bIWDKCicKCFsZ9+ClzguZrCW/vv5sFHTetq 13fSlWOxjixCb+itQEV2r8MF5RAMpMJShpVISrwDP93g8qjCZDuYFuNgQBq+lFcY0JLT 5eYP0xmZbbqpkgrJTe9BKtdvsIk1nTyAlnV5Gm0AoU32SXAPdbuJLdfVoByRoh4+Fmdd CFjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YtqX0z7lVg0NQoWLr6qcxLBuwehj+IGXyTiEO/p2LOo=; fh=BmoNGikZ0c0jFVvZ2YLzmoZUwDhNTkpAEx4ktuFUIgk=; b=QFJbJOdPKNPLCmb+WkaKU3mueOCA6lXTLacE0owYW2ebQgF7BbNFnrgLecDvOrgEAd 26+3q71m58qTRMWw6Q0Ar+TD1MU7OUvwaqLp/0dTMSfMtdtGsPefI3uWr9U29lsFipDM X9zlxFq2Ay7MZDWPVeqVLzOs1okNd22FixFZdsjtYp0UPOeh0AcFyO/KByBE59xkHGAs POItIuYzsjn1ITFatrKZzzQLboj7eK6g9XkH5zXukxDaaF3zv2DqOouOackiYv6XTp2w yYoOGk0pU+jjdKiuMF5T9Xf/CvW4q5svWkoqU/Yq3Pv+C1FVw4w118k02PpHJ3idFUSZ cwIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PlNt9rTU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020a170902e5d100b001b87b17cfb4si829878plf.392.2023.06.30.11.50.56; Fri, 30 Jun 2023 11:51:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PlNt9rTU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233203AbjF3Sfm (ORCPT + 99 others); Fri, 30 Jun 2023 14:35:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233206AbjF3Se6 (ORCPT ); Fri, 30 Jun 2023 14:34:58 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74A39468B; Fri, 30 Jun 2023 11:34: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=1688150072; x=1719686072; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/R3I4v94b+OqCb+YA+/zIsoRAWwSbNvd1KKpPX6mkEU=; b=PlNt9rTUD22dV4rWwMBhWsE/fASN7KPCohXZBDDXxANTo4Azm0I9hSmt nZsbN6HfcBxIfT33RfRuKlhd+7vBLZAgxK/viIrOuhBFMy96yyTJd8DQn X38zCbJmTdg4nCfmvRUzH+TuobQhA0bxK2/wA4PWJJHWQ0RWwZKJJ6W23 WYkb3meQ7hHzO/KCqxHRdj//NQq4t5dOKFxyS7Bf5bpwXAZIXRWtCC985 4QtfCfRQoGZIjjmaR6RZ8mO8lupTXLRm+X3MoPuP5wqZgv7P7Iutiucb5 Gv8mFmW+cSVLrI9ARygmSFKdyhPtXCDJidIPwb6ogzIqbj13J2AmjcrQf w==; X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="365949997" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="365949997" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2023 11:34:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="717896464" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="717896464" Received: from powerlab.fi.intel.com ([10.237.71.25]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2023 11:34:28 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski , "Rafael J . Wysocki" Subject: [PATCH v6 7/9] acpi/nfit: Move handler installing logic to driver Date: Fri, 30 Jun 2023 21:33:42 +0300 Message-ID: <20230630183344.891077-8-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230630183344.891077-1-michal.wilczynski@intel.com> References: <20230630183344.891077-1-michal.wilczynski@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770154697454615425?= X-GMAIL-MSGID: =?utf-8?q?1770154697454615425?= Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of acpi_nfit_shutdown(). Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver. Introduce a new devm action acpi_nfit_remove_notify_handler. Move acpi_nfit_notify() upwards in the file, so it can be used inside acpi_nfit_add() and acpi_nfit_remove_notify_handler(). Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/nfit/core.c | 41 +++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 07204d482968..ee2365a80aa1 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -3282,6 +3282,24 @@ static void acpi_nfit_put_table(void *table) acpi_put_table(table); } +static void acpi_nfit_notify(acpi_handle handle, u32 event, void *data) +{ + struct acpi_device *adev = data; + + device_lock(&adev->dev); + __acpi_nfit_notify(&adev->dev, handle, event); + device_unlock(&adev->dev); +} + +void acpi_nfit_remove_notify_handler(void *data) +{ + struct acpi_device *adev = data; + + acpi_dev_remove_notify_handler(adev, + ACPI_DEVICE_NOTIFY, + acpi_nfit_notify); +} + void acpi_nfit_shutdown(void *data) { struct acpi_nfit_desc *acpi_desc = data; @@ -3368,7 +3386,20 @@ static int acpi_nfit_add(struct acpi_device *adev) if (rc) return rc; - return devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc); + + rc = devm_add_action_or_reset(dev, acpi_nfit_shutdown, acpi_desc); + if (rc) + return rc; + + rc = acpi_dev_install_notify_handler(adev, + ACPI_DEVICE_NOTIFY, + acpi_nfit_notify); + if (rc) + return rc; + + return devm_add_action_or_reset(dev, + acpi_nfit_remove_notify_handler, + adev); } static void acpi_nfit_remove(struct acpi_device *adev) @@ -3446,13 +3477,6 @@ void __acpi_nfit_notify(struct device *dev, acpi_handle handle, u32 event) } EXPORT_SYMBOL_GPL(__acpi_nfit_notify); -static void acpi_nfit_notify(struct acpi_device *adev, u32 event) -{ - device_lock(&adev->dev); - __acpi_nfit_notify(&adev->dev, adev->handle, event); - device_unlock(&adev->dev); -} - static const struct acpi_device_id acpi_nfit_ids[] = { { "ACPI0012", 0 }, { "", 0 }, @@ -3465,7 +3489,6 @@ static struct acpi_driver acpi_nfit_driver = { .ops = { .add = acpi_nfit_add, .remove = acpi_nfit_remove, - .notify = acpi_nfit_notify, }, };