From patchwork Fri Sep 22 05:45:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 143396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5521259vqi; Fri, 22 Sep 2023 05:13:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEa+XVrHRlhsvAeVQIjhgn4UcKZMjHNcrdlpni5C20CFfnzeC+DjkNFQ1jeac4gTGweOkp0 X-Received: by 2002:a05:6808:1b23:b0:3a1:d457:83b5 with SMTP id bx35-20020a0568081b2300b003a1d45783b5mr8716846oib.3.1695384814601; Fri, 22 Sep 2023 05:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695384814; cv=none; d=google.com; s=arc-20160816; b=hfGTmV96iVGgwM+dpPodhWJwV72m6JQt96dJiquF+NKzfGtKgdOtwq25rVOx/3cXti pKkCW64XpRFV/pzwD8+s1iKC404scVCJDfFjTB1yV8nYwPGBai3U3eyVa3xGzWBh3F3A wZ5R+JNYVEETz2GqAsjxM6uhl8QWL8tBhSeEOFd1PU7ZlIjXQpjAX1Td0CAjuNUh6Mnf 9PeB8zx5WnuLJ2MBJrB1HRbvpLQappCL+geRIW5MfvH7NntNMEjK/k8IW9XzmiqCI/pS OdsMP00RRyaOSBK4zSwgqjNlKu52JF3ksfEKKL46WmbkoUlwuRN+A7W9NCUDUXDs54Y6 Q/kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=VzRDWUyWY/w7RQ5smd3Vz23KHdAxLYnHWvyEJn9VsOI=; fh=d32gQoCPhsH2i1xrFtR6ShoQhZBfQDtF4UZ9iew5CwE=; b=dGmef4PlLfya0V6KXF3Y8dBz7cbbZB44XSWwrt31++sTP3Zth4T6FWvpLEzkiecbvb u86tO5q1lzJX+UapJ9Ufx0SBQWH2IGm5st+QDWS6X7QSqZ9pJT2kAnzd3SqtPkvHUvXz 9AoFqiC91yKAHlvIq56Zdp4WHPhNWah3x71EdzMH9783ecjh0bchZ2kLc4NSYJ/io/yO XRhB2ZqNOo+HN2HxoPXk1lhWyKe/F/E0ifb56135vkG9qCQghuPT1px8CIrfVLSH+9iB 8aogfAiDQhyLEY3TqmCo3vKEfyCx8Ho4wEpbBMiozDcH2osTk+l+/L8kiIZFsRE5BJRM LN+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N5p0MKEw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id q26-20020a62ae1a000000b0068bc0b772d8si3498017pff.194.2023.09.22.05.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 05:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N5p0MKEw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 63B8B8083A99; Thu, 21 Sep 2023 22:47:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229948AbjIVFrQ (ORCPT + 30 others); Fri, 22 Sep 2023 01:47:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjIVFrO (ORCPT ); Fri, 22 Sep 2023 01:47:14 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13718F; Thu, 21 Sep 2023 22:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695361628; x=1726897628; h=from:to:cc:subject:date:message-id; bh=E934W0ha3pK8ajkIFoaGlzg0zJoW8eJf9K2yV/pdMhs=; b=N5p0MKEwtap6HfFcQBJPnPWH0Cd9CpxH4qVAFGCXVO5Qe/sqpkKrsQPg Az8IHHzL9/AFQzTGRgDrVYqn89vdApVHlIkQkgpn5SfF5ItrgQf2hKCuF p0o7sc7Em+KglcXK1wQf7iZRw8LuDw6fowwik1Z8J352x5qVFPKTdAwpt RI7+I3aU+Zc+fJBw09k+pC87N4WMG3++atBEvq0Xtzs2Zt7Fe7gkd+fLi R5dTfAoL/BCaOYOqr/KeE92QxPPkpO678wwbqvK32Fm5MAX8MsLfpbpmZ TCDPb+Sl0xZRPl/ANOySWUaC0rReoMeXvstXuo3E8W7LEKEr3bfiz51kV w==; X-IronPort-AV: E=McAfee;i="6600,9927,10840"; a="411688436" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="411688436" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2023 22:47:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10840"; a="871136956" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="871136956" Received: from inlubt0316.iind.intel.com ([10.191.20.213]) by orsmga004.jf.intel.com with ESMTP; 21 Sep 2023 22:47:04 -0700 From: Raag Jadav To: rafael@kernel.org, len.brown@intel.com, pavel@ucw.cz, Jonathan.Cameron@huawei.com, paul@crapouillou.net, andriy.shevchenko@linux.intel.com, rf@opensource.cirrus.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, bala.senthil@intel.com, Raag Jadav Subject: [PATCH v4] PM: Fix symbol export for _SIMPLE_ variants of _PM_OPS() Date: Fri, 22 Sep 2023 11:15:52 +0530 Message-Id: <20230922054552.3570-1-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 21 Sep 2023 22:47:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777739827105516395 X-GMAIL-MSGID: 1777739827105516395 Currently EXPORT_*_SIMPLE_DEV_PM_OPS() use EXPORT_*_DEV_PM_OPS() set of macros to export dev_pm_ops symbol, which export the symbol in case CONFIG_PM=y but don't take CONFIG_PM_SLEEP into consideration. Since _SIMPLE_ variants of _PM_OPS() do not include runtime PM handles and are only used in case CONFIG_PM_SLEEP=y, we should not be exporting dev_pm_ops symbol for them in case CONFIG_PM_SLEEP=n. This can be fixed by having two distinct set of export macros for both _RUNTIME_ and _SIMPLE_ variants of _PM_OPS(), such that the export of dev_pm_ops symbol used in each variant depends on CONFIG_PM and CONFIG_PM_SLEEP respectively. Introduce _DEV_SLEEP_PM_OPS() set of export macros for _SIMPLE_ variants of _PM_OPS(), which export dev_pm_ops symbol only in case CONFIG_PM_SLEEP=y and discard it otherwise. Fixes: 34e1ed189fab ("PM: Improve EXPORT_*_DEV_PM_OPS macros") Signed-off-by: Raag Jadav Reviewed-by: Paul Cercueil --- PS: This is a standalone fix and works without updating existing drivers. Changes since v3: - Rename _PM_OPS macro to _DISCARD_PM_OPS Changes since v2: - Drop redundant patches Changes since v1: - Update drivers to new set of macros include/linux/pm.h | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/include/linux/pm.h b/include/linux/pm.h index 1400c37b29c7..629c1633bbd0 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -374,24 +374,39 @@ const struct dev_pm_ops name = { \ RUNTIME_PM_OPS(runtime_suspend_fn, runtime_resume_fn, idle_fn) \ } -#ifdef CONFIG_PM -#define _EXPORT_DEV_PM_OPS(name, license, ns) \ +#define _EXPORT_PM_OPS(name, license, ns) \ const struct dev_pm_ops name; \ __EXPORT_SYMBOL(name, license, ns); \ const struct dev_pm_ops name -#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name) -#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns) -#else -#define _EXPORT_DEV_PM_OPS(name, license, ns) \ + +#define _DISCARD_PM_OPS(name, license, ns) \ static __maybe_unused const struct dev_pm_ops __static_##name + +#ifdef CONFIG_PM +#define _EXPORT_DEV_PM_OPS(name, license, ns) _EXPORT_PM_OPS(name, license, ns) +#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name) +#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns) +#else +#define _EXPORT_DEV_PM_OPS(name, license, ns) _DISCARD_PM_OPS(name, license, ns) #define EXPORT_PM_FN_GPL(name) #define EXPORT_PM_FN_NS_GPL(name, ns) #endif -#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "") -#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "GPL", "") -#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns) -#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "GPL", #ns) +#ifdef CONFIG_PM_SLEEP +#define _EXPORT_DEV_SLEEP_PM_OPS(name, license, ns) _EXPORT_PM_OPS(name, license, ns) +#else +#define _EXPORT_DEV_SLEEP_PM_OPS(name, license, ns) _DISCARD_PM_OPS(name, license, ns) +#endif + +#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "") +#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "GPL", "") +#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns) +#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "GPL", #ns) + +#define EXPORT_DEV_SLEEP_PM_OPS(name) _EXPORT_DEV_SLEEP_PM_OPS(name, "", "") +#define EXPORT_GPL_DEV_SLEEP_PM_OPS(name) _EXPORT_DEV_SLEEP_PM_OPS(name, "GPL", "") +#define EXPORT_NS_DEV_SLEEP_PM_OPS(name, ns) _EXPORT_DEV_SLEEP_PM_OPS(name, "", #ns) +#define EXPORT_NS_GPL_DEV_SLEEP_PM_OPS(name, ns) _EXPORT_DEV_SLEEP_PM_OPS(name, "GPL", #ns) /* * Use this if you want to use the same suspend and resume callbacks for suspend @@ -404,19 +419,19 @@ const struct dev_pm_ops name = { \ _DEFINE_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL) #define EXPORT_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ - EXPORT_DEV_PM_OPS(name) = { \ + EXPORT_DEV_SLEEP_PM_OPS(name) = { \ SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ } #define EXPORT_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ - EXPORT_GPL_DEV_PM_OPS(name) = { \ + EXPORT_GPL_DEV_SLEEP_PM_OPS(name) = { \ SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ } #define EXPORT_NS_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, ns) \ - EXPORT_NS_DEV_PM_OPS(name, ns) = { \ + EXPORT_NS_DEV_SLEEP_PM_OPS(name, ns) = { \ SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ } #define EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, ns) \ - EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \ + EXPORT_NS_GPL_DEV_SLEEP_PM_OPS(name, ns) = { \ SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ }