From nobody Mon Nov 25 00:49:16 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EA3C26AD0; Thu, 31 Oct 2024 04:10:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347830; cv=fail; b=g5qlJfXmzgktqmCeOkZFD+TKGcuvO78sXBPDFDMJynfn77Ll2qdtj8Uv+5m6Sx4mutJP6fIoW7/1VJmNbsQ0PN82Xd1pB8GkOWwoEU8O+q4xexUVlJZLt8BaF7k3hD1baKu39JTtVuxB04tY3q5H/n+5LBqTi8A7uHvQJXDSL9s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347830; c=relaxed/simple; bh=LT207b0D2cujNgfZlGy/3GMB9YtgAVWVYuGVhHvtPc4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Zcpb4NxF8qhqXj0ByNzSC0UU2lIiwdrEHqZTqqVSYcPDtQ1fPdgW1wE0+Vd5cmStTM+ymLsE2M1UwdeMEhhb8tZ5T909bOrjNBQB6I0rMVM52YX502r/YoMn9J9izRmswtDDoKQI88h6x85yzd9MXHoi/AhQDLhmoct1oAL2pAY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=e5XdRNFL; arc=fail smtp.client-ip=40.107.223.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="e5XdRNFL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K4IZ2MBh9LVA5nzB33kTQr11Er2vp4pbB9BmYCIVaTyUgH7hOW5g3yr+vNuZq9K+T11ttTIXF3c5f7/1AgehXLusL5Ddo9XRMO1iSKBoB8Nnf2hV3ltjpBCmBSMCw4Oo+A71mgKHw0G+nZ0hEq9D7Sr/4a0cP/N+vAHqZ3E55Z2Mqfr+rJIHOGwMTJehggGQ+FzZjTKgDV/67oq5uONSjpbseeleWZGCrHChY4ZlXGiqrOGIZBTZ6Dm3RbW6ccvoaZL9jNsd5U5+zAvA+Ewc63XAXlD3s+fE23OkxaOv+7GkgN87Nu+Eb4TxKXudMrXioQck59MQ+LuLQhPrP7ts0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wEaqHAtFNbzbSffeGrvACYzTZMNrQiHOw2ZiVs6GbLU=; b=JcnBpfZNCHiixlS2I+w39oqTt3RWkX8s0LNQ4EzDWvvBHFt94XVXCDdkKKZzmezB22yT0n4Tme9B7tDeYhMG2LWQboDKLaWVUxGzwc6EsOBnpH/Va7OnAWHJ2cGOH3bT/AnlQgcesqbD/wu3gb8XqWlhhgUvdI9yU9tfSYsJTTCbV4CquEhCquJTlRXYzR3n79LYbxl5vsY8zuwjudtEzBpUXrgAZFBl2+3Jf9mkTosTqGEcAC+sc0r8l/b2n00SWEENlJgmpPCWOFgcHjRc4XNyvNj1YqUFnqP/W89EPlHDvsLXqyyh1phM+akld4kQz3Z6snfMOhd6BO0WlpZ6UQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wEaqHAtFNbzbSffeGrvACYzTZMNrQiHOw2ZiVs6GbLU=; b=e5XdRNFLrKm5laqngo8YqCwR9VDvO9rIP9m8mlq1+wUcNL6J1t+Ln5lXbsF3+fIpTiNIl8Pu+ty8WMTv4bSzLY2hGyuCcQPhXMMCV57oXMJ2ykDbFc48L2hG/sqDIMSIz4+xz61NC6j9wjReAKoXFlr6zS0yA2Qn0oouJM8zAXA= Received: from DM5PR07CA0117.namprd07.prod.outlook.com (2603:10b6:4:ae::46) by BL3PR12MB6428.namprd12.prod.outlook.com (2603:10b6:208:3b7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:10:22 +0000 Received: from CY4PEPF0000FCC0.namprd03.prod.outlook.com (2603:10b6:4:ae:cafe::5d) by DM5PR07CA0117.outlook.office365.com (2603:10b6:4:ae::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC0.mail.protection.outlook.com (10.167.242.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:22 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:20 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Lyndon Sanche Subject: [PATCH v3 01/22] ACPI: platform-profile: Add a name member to handlers Date: Wed, 30 Oct 2024 23:09:31 -0500 Message-ID: <20241031040952.109057-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC0:EE_|BL3PR12MB6428:EE_ X-MS-Office365-Filtering-Correlation-Id: d010ef96-e0cb-49eb-03c8-08dcf961f0b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?swqYY3a1kIz4LR0qWlgP3g6/2VtiDGC1edqwCMkxuIunI7iIHOs/JAQFkulP?= =?us-ascii?Q?C7F/rjYb3tXXtb/lbVguRB3ANGNgliN9o+WqJczCXe3+Mv+CSX/LYAagCQJ+?= =?us-ascii?Q?bxZ+qB9lCXMMxfDpeA2O44HPP7OjhGWKTaFzl5vNzkkwMkrhWxVFG2mwcJAs?= =?us-ascii?Q?v5jUUQk7gewv+7f9jwqcjBKHn3TBHUUGozJDoCXOh1saPeHLjEaDcznAZ6jh?= =?us-ascii?Q?SUcmZOVJjlU+E16ZQoKAroXKpq0mBFelbUbHdUZp2CFBR4BylmrZruVA6aoT?= =?us-ascii?Q?f+yKhcuqaT/Zjld/V2PmpS7CxeWaJetJX1Jb6h+lkF0tBko5xii01/xAWaHV?= =?us-ascii?Q?JAUv5v4hu5CZ/1dB/tNs5pb32QRuN9aI8g0TSqtjWgr333Y9l1EYGmecDMVR?= =?us-ascii?Q?SQMqUvD+5GjdjuTgLmj2bylem43VzrkXOTcpkpBKCf/7JATXveTBim3kR0+b?= =?us-ascii?Q?k9ZjkthWJTiaGKea15/5NZaXohQ4ljwPKwOxg33aDir157+qzX72+RnHDa2h?= =?us-ascii?Q?D1xwJoS1L0u27+4q4YRMbeIvZ2z9+mRweRizTFRTo2hQROpAyd4Podu+2itR?= =?us-ascii?Q?eBIGvcLIKiN8MPZqdizf2J6ySPqIjsyzB3ATZSLPq4grjES6Hhdif1+qx80M?= =?us-ascii?Q?omBBoFEDByy+OLaPz8XKFPPn8uD4itoNkr47uizT5EaRXpegk1y5F2HzM/s0?= =?us-ascii?Q?DCJVafZmlKO+so/hdrMws484GR5tluE+d38VJ2/Jags1KHHJouMLZZwD/uB5?= =?us-ascii?Q?VKo+7e7c3NtI8BvRck98u0ufqyBKKGMc9dIJV/ADidArsaNFdlzczFjMFfSM?= =?us-ascii?Q?U/ico4ytLIyLFL3wyG504AMAwk4ZYWmcQYLV2aWz5t8+spYAcUeLrn1Rb7u/?= =?us-ascii?Q?WMk7gOniCsU2nmzYqhO0CwM9agY5VyHMJ5WHGF3I3iMF/BSN6nj9tC7JaL2P?= =?us-ascii?Q?0xc4g8Fcj8OkqAGFHeCBwbh9Viq9dtjwRdcDqOmLyC5SptqF2r0TztrOkoUV?= =?us-ascii?Q?f6I4uR5V5yTTaLOQszecUdYYyuImRjtlQZY3eLYMHVT+jGXavvepKp4TDqDA?= =?us-ascii?Q?JFljmFX+TZr1kZPqEH1TaK+jzIXpVeyTKfoc5K3FiGQDVsWaC955kbivBkfu?= =?us-ascii?Q?/gIUjFQ3HUpioKA4Nu3t+jR3rIbWg6KmcNMAi8owIoFStc2E0ykMLfL/Hcp7?= =?us-ascii?Q?qMnyYK7Yx9l/GtiKwPp2I1pIr/Cf3teJu1pxN0m1x1hJ9ZU7+POT89OIk7y6?= =?us-ascii?Q?nw6rljSkO1TIpu2zmaUQ9E5cYNyjYGui9gWWzh1bfeJIX+yFY9KtnszYXfMO?= =?us-ascii?Q?oTE+/BVR6N8xV+fsnvAGa3BoxgLffDrF/EqPX9o4/i0kdPo+vJdBKqIWCiuG?= =?us-ascii?Q?bZSoMdB+41/ltMdMNkLHEowTpGj1TYcHrwQyahBUJdR1Fvm20w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:22.2871 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d010ef96-e0cb-49eb-03c8-08dcf961f0b6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6428 Content-Type: text/plain; charset="utf-8" In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Lyndon Sanche Signed-off-by: Mario Limonciello --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 1 + drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 1 + drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 10 files changed, 10 insertions(+) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/= platform/surface/surface_platform_profile.c index 08db878f1d7d4..9d3e3f9458186 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_d= evice *sdev) =20 tpd->sdev =3D sdev; =20 + tpd->handler.name =3D "Surface Platform Profile"; tpd->handler.profile_get =3D ssam_platform_profile_get; tpd->handler.profile_set =3D ssam_platform_profile_set; =20 diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wm= i.c index 7169b84ccdb6e..13a97afe0112d 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1883,6 +1883,7 @@ static int acer_platform_profile_setup(void) if (quirks->predator_v4) { int err; =20 + platform_profile_handler.name =3D "acer-wmi"; platform_profile_handler.profile_get =3D acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set =3D diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/= pmf/sps.c index 92f7fb22277dc..e2d0cc92c4396 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } =20 + dev->pprof.name =3D "amd-pmf"; dev->pprof.profile_get =3D amd_pmf_profile_get; dev->pprof.profile_set =3D amd_pmf_profile_set; =20 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index abdca3f05c5c1..6177fbee60573 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3920,6 +3920,7 @@ static int platform_profile_setup(struct asus_wmi *as= us) =20 dev_info(dev, "Using throttle_thermal_policy for platform_profile support= \n"); =20 + asus->platform_profile_handler.name =3D "asus-wmi"; asus->platform_profile_handler.profile_get =3D asus_wmi_platform_profile_= get; asus->platform_profile_handler.profile_set =3D asus_wmi_platform_profile_= set; =20 diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index 972385ca1990b..3cf79e55e3129 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -247,6 +247,7 @@ static int thermal_init(void) thermal_handler =3D kzalloc(sizeof(*thermal_handler), GFP_KERNEL); if (!thermal_handler) return -ENOMEM; + thermal_handler->name =3D "dell-pc"; thermal_handler->profile_get =3D thermal_platform_profile_get; thermal_handler->profile_set =3D thermal_platform_profile_set; =20 diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 8c05e0dd2a218..10a853b6b0514 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1624,6 +1624,7 @@ static int thermal_profile_setup(void) set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); } =20 + platform_profile_handler.name =3D "hp-wmi"; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); =20 diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/i= deapad-laptop.c index c64dfc56651d3..6c72d1b6a2aff 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1102,6 +1102,7 @@ static int ideapad_dytc_profile_init(struct ideapad_p= rivate *priv) =20 mutex_init(&priv->dytc->mutex); =20 + priv->dytc->pprof.name =3D "ideapad-laptop"; priv->dytc->priv =3D priv; priv->dytc->pprof.profile_get =3D dytc_profile_get; priv->dytc->pprof.profile_set =3D dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platf= orm/x86/inspur_platform_profile.c index 8440defa67886..03da2c8cf6789 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, co= nst void *context) priv->wdev =3D wdev; dev_set_drvdata(&wdev->dev, priv); =20 + priv->handler.name =3D "inspur-wmi"; priv->handler.profile_get =3D inspur_platform_profile_get; priv->handler.profile_set =3D inspur_platform_profile_set; =20 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_acpi.c index 4c1b0553f8720..c8c316b8507a5 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10549,6 +10549,7 @@ static void dytc_profile_refresh(void) } =20 static struct platform_profile_handler dytc_profile =3D { + .name =3D "thinkpad-acpi", .profile_get =3D dytc_profile_get, .profile_set =3D dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index f5492ed413f36..6fa988e417428 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -27,6 +27,7 @@ enum platform_profile_option { }; =20 struct platform_profile_handler { + const char *name; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2072.outbound.protection.outlook.com [40.107.95.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 059EB126BF2; Thu, 31 Oct 2024 04:10:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347831; cv=fail; b=LYNFi9VkKP9iELRy6xjLzR5oHPghcVpQmpd2K7DKfmUrIyLg5wdD160cGP+YrXIvZa/Fx4uCn9YlNNjnJ6Vif3+wTtfDMAbv/B31uUXo5AOtByyGWuVTvqLE0PrxPwbzXtp5fuoHaeDTVKC/iu7wXCOQ6tcpXGgzqtYNfSKk5CM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347831; c=relaxed/simple; bh=7Y1ye+dojnd83/ekD+XzCxFvj3T3Qdw+9hKUx108gN8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HAQu89wqgvAU5HNpYiDSXqDmSgt44ohUE2Rgxc/KIUhDIjYMYNWcq8bdBcTdsH4NyxZoHTe5Zr6bjEMw873/wIQFLosI0lZZH98oGg4PULdPIetmAFx+d9hsg/LW14XcjGUGSOiLHdLBSh22UfHqxYk4oC4PMkYJFnZh87UbuvI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2KpgXbyk; arc=fail smtp.client-ip=40.107.95.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2KpgXbyk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dt4m3UGcNWsA9MCcZNvNmoecQwK2wvwOE+19L6WC/wi0Jl9IoZaXy7T2RzqBpSV1m+k7s1jLqSm91vjvKTcJdtxXxiNYFZ64jaMZir82A+9N1JG/4upDqERv6T+tCBtyz+8Z8NeIfi4VmJv3rlu3rZZYQT5ko0YjAU6C9f940yppRssqhlVFXtELlrO1xVKBMDNiL+iQ2k5Dic2mSbFQ4+DUkIL/ZK1XWfS2nQk8tOJZip7B+/7YZwYYrAEMesEMexVWwY2xcBDzjvbZVaBc3HieRCCqVUBiMl3uzLN9Lum5nxgbiSm6KSWmLZei8KalXga0lYfr9ekh/QHkpTs7EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1mUyzhBT4vy03YoPp8fHD/o7qorvv1zgUumIXEtGe6k=; b=IhcSaG3SUgZDjQmnZ1H/8/gVIgpoOkCHKGX013AHy9Gt3bLIrL5jMZ4MoU0UAxWw3bCk/5dsfKRWgzff7kn3zv1a1Vb4DlbRFmoIK0r0ZehSHlJPZ4sLmo8Ws1gyfDGLM2AW4ZAEBs7dYMO3wiisz5zbg+kZERqfwxc7rpc8TMusj2PvM9C5PoK9pLaKvzW/Jp5tTchHFIX47ZA21xmZH9cOr7eyfYBrTLoRACavZ8xU+x3a/3SZQUXMzYhwQcB7I1negewnINUvyhDNlcLUmMdhKK7XYtcSucNNLq7770xTn4lLiiqZAb0pHbKLnGAjWGHSDyHgdD3Z9j6N3J/sGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1mUyzhBT4vy03YoPp8fHD/o7qorvv1zgUumIXEtGe6k=; b=2KpgXbykLWalcayZD6Cz8RCvQbwm5S4/H0qrkoXHbk/q5Gorr/STgFclU2ZqpdyeyT+elbTWvYKqJfLUJc9jDUOoKgVPN5Ct372I55zBzSmzpN42v5qO3TnTNRXI3a42/hLt5YS+cRPxts9j67Eypl7HdG8MpgyMWBIKU11t7p4= Received: from PH7P222CA0020.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:33a::8) by BY5PR12MB4066.namprd12.prod.outlook.com (2603:10b6:a03:207::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22; Thu, 31 Oct 2024 04:10:25 +0000 Received: from CY4PEPF0000FCC5.namprd03.prod.outlook.com (2603:10b6:510:33a:cafe::e) by PH7P222CA0020.outlook.office365.com (2603:10b6:510:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC5.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:24 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:22 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 02/22] platform/x86/dell: dell-pc: Create platform device Date: Wed, 30 Oct 2024 23:09:32 -0500 Message-ID: <20241031040952.109057-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC5:EE_|BY5PR12MB4066:EE_ X-MS-Office365-Filtering-Correlation-Id: df2096cc-1754-445b-ccbf-08dcf961f21d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?zjd8H5bjiA8ZaMseRZvunorrLZd/UuAHQaf0FxsNdNfx9IuhqdgKNn4sj7P5?= =?us-ascii?Q?bTTlpaDFNKQfbA2kf1Ruchy8NgDlWbOX26NkYHkYq9s/YtWHCvc7ji09AG2L?= =?us-ascii?Q?X6ccK73oJz9g4Iw+E/NatdMb+Y62840YRSwvQBe6C5NMP9rhOJOd7ip24zyc?= =?us-ascii?Q?Rcn9PS3Kxn0Fg6SsQp48ZEptJ5jTepKUb540XlRhPV/AA5t/+j7CzKFQvteY?= =?us-ascii?Q?MIImOS3eZ9U0oFA89E7LHs2ybnWXDdQXZj1o+AKGPR7j7MHs3QE/k9LZsrqb?= =?us-ascii?Q?KUQXgqdQ+7FeGK+PfgC/7f2kL9RdEjnGpUfY2epjqvyahEKF5+p0Vf5U6Jy8?= =?us-ascii?Q?oBZNajBrvYAgapf/P+1V4FlufMv6YrUG7QX42VF3XuEpZp3CYv5Dmp2Sgl+U?= =?us-ascii?Q?9jnIq0JHnrhukw4300lrgoOvT6jpm4SW8MViBcCUqw+ug5HgliGwYFk7oJfu?= =?us-ascii?Q?R6vVv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pgj?= =?us-ascii?Q?aI9RKMjI6ZrjXJYKQBg5Z0l7BUNgxh6WB452mM1QxA7wqnuIYQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:24.7232 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df2096cc-1754-445b-ccbf-08dcf961f21d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4066 Content-Type: text/plain; charset="utf-8" In order to have a device for the platform profile core to reference create a platform device for dell-pc. While doing this change the memory allocation for the thermal handler to be device managed to follow the lifecycle of that device. Signed-off-by: Mario Limonciello --- drivers/platform/x86/dell/dell-pc.c | 35 +++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index 3cf79e55e3129..b145fedb6b710 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -18,10 +18,13 @@ #include #include #include +#include #include =20 #include "dell-smbios.h" =20 +static struct platform_device *platform_device; + static const struct dmi_system_id dell_device_table[] __initconst =3D { { .ident =3D "Dell Inc.", @@ -244,9 +247,18 @@ static int thermal_init(void) if (!supported_modes) return 0; =20 - thermal_handler =3D kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) + platform_device =3D platform_device_alloc("dell-pc", PLATFORM_DEVID_NONE); + if (!platform_device) return -ENOMEM; + ret =3D platform_device_add(platform_device); + if (ret) + goto cleanup_platform_device; + + thermal_handler =3D devm_kzalloc(&platform_device->dev, sizeof(*thermal_h= andler), GFP_KERNEL); + if (!thermal_handler) { + ret =3D -ENOMEM; + goto cleanup_platform_device; + } thermal_handler->name =3D "dell-pc"; thermal_handler->profile_get =3D thermal_platform_profile_get; thermal_handler->profile_set =3D thermal_platform_profile_set; @@ -262,20 +274,25 @@ static int thermal_init(void) =20 /* Clean up if failed */ ret =3D platform_profile_register(thermal_handler); - if (ret) { - kfree(thermal_handler); - thermal_handler =3D NULL; - } + if (ret) + goto cleanup_thermal_handler; + + return 0; + +cleanup_thermal_handler: + thermal_handler =3D NULL; + +cleanup_platform_device: + platform_device_del(platform_device); =20 return ret; } =20 static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } =20 static int __init dell_init(void) --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2056.outbound.protection.outlook.com [40.107.95.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC54D13D502; Thu, 31 Oct 2024 04:10:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347835; cv=fail; b=m820QSpFtvYCSrKNMMHLY6ylDkBtAt4OvT0AxfTBi3LKtMqpBki/OugZpuIHIH85KGwTK66bt30pynT9n7tNAMeuoP5oK3NNJ+YoiDdhQf5GHjOcCPy7zdy90qRCjHEZDVSICs51hcskKVl7jf+7/Nj8/2AXC4Xam4Y8j5WAYa8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347835; c=relaxed/simple; bh=Pi8a/vJuw+WnaI/I+TEEffa4Bpy42bLAbqsc9USwYpM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xkslp7+acPP/HPyX2ulp+DOLKrH3uYVoC+p7/8k2jLLOzkLeJ5mjddEjUAiTUGLaXOrecMdmUd4Wl1DZ7ZNR/NDQiChxYvrxFh5P0lZ6X4N074sLIk3tiltC/hK5K2EJdzlFt2w9MS+KZk3EsnpL90kWYGqtTmGwWTKC7sOB4sg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=LyEc4zuN; arc=fail smtp.client-ip=40.107.95.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="LyEc4zuN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YjA5xnGCkBg5Aegp1EmcgyHnk8qTorhXGMAhtxmimaornVk/67huZMi//44N27376qImjehd1YXsXiYz9mQnMYzcn4MK971Ea9WG2o4q2YNhqhAmr9K1kM1CoVG2TpFPZLxy9jCF7i8OinKpGySKGlETS1p4BwdrCS+yydc67q3KfAFyOZX4jHawfpHZhzck4mNTNPTtNhV60SXLYUWwBx6BdjN7BhNBa7Ad+3POuXlGxdzQh5I9U7z0pCWIyZAHjcdIP0qyrkqAlqeSutY25ihTkUP+ZBvYHJpL5Y9t4YzSAKboFm9bumGOlhb1J268hRMMcsIYeXqUYM0vs2folw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OhvVpL5s8sr72BvRS6yZGodBn0fZHl5FV/9LqwVd0aE=; b=TMaDn27h66jtrBcGSrJZ203XbzChT/DGC7xxILB7Toya9ZdIWZFjVrTw5nDqMcaB+qe9L7LFRqJ2CEaIZ9FEhFhvZ3xjTSO/0rjX9gNJeIDCbu8R+BkhWhGwg28aTRmSLcg+O8qfWO8xQX2+PiMk/Pleuyx1Zc40HOBsezATUn1HhpjfKoDBjQrfk/f02m/bYB+KAbynQcWZ5ArCQEcHvSpsklwQIRfLs3urdHcxnNl4jzAe5s00RcrcFhT/sYBPvO3F4N3iKFzjWHqneaREGLx2HO+H+5FugqFd1aPubHcghclmtF9wdXySnA39m45KvQQKi3ROsYRhvy5ucCugSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OhvVpL5s8sr72BvRS6yZGodBn0fZHl5FV/9LqwVd0aE=; b=LyEc4zuN1CBUjIgu0efoOOMJApxvFcp3nbmJTE4j8Hs5AJnG0L+VuGkIGCRHxmLRu5+nyATEuxMCRQk1nffvVk9w/jCcllzVeodrspcFVgwLeLG9mU3FvMqhvwhqPNiki0CBr/p5rzdqwRMWWi7D79y6hZ7wY0/4BYEDYGdT+bk= Received: from PH7P220CA0083.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::19) by DM4PR12MB7765.namprd12.prod.outlook.com (2603:10b6:8:113::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:10:27 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::e4) by PH7P220CA0083.outlook.office365.com (2603:10b6:510:32c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Thu, 31 Oct 2024 04:10:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:26 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:24 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 03/22] ACPI: platform_profile: Add device pointer into platform profile handler Date: Wed, 30 Oct 2024 23:09:33 -0500 Message-ID: <20241031040952.109057-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|DM4PR12MB7765:EE_ X-MS-Office365-Filtering-Correlation-Id: 06dc93f0-af49-4773-8fce-08dcf961f395 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DkCMAQL/9VT6TMqvWCpjL4QFYFcch7YJ/4o2s1du+cs3R8U11UonKaJsCphw?= =?us-ascii?Q?evIuS9njMjRJJ/BgXPVRFhM25ya+eq79sz+pMwptsDwYI+TPhpqRCYSnVQoD?= =?us-ascii?Q?a6afGE9ocQ2143G1XmlXe9OFtuVgUGUXbzDR8bcH+aRhDUQwKJFbxqyv4KG+?= =?us-ascii?Q?/N4ujO7Wb6bgA/A/z4zRFDOahOc4PFLF+ug4kSo6WQhixi20k6jEIFsr1v1e?= =?us-ascii?Q?0429lBI1196/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VNfU?= =?us-ascii?Q?TUxoScW8Sq9HoxdJQorFq/XJelZ1k/+FdhsPkBnGqmqwLG8RaUJ8aU8fpOk6?= =?us-ascii?Q?fW1Uic1sznFTYaHIIgEJI0T+AqArqLaZlN8foAOot7da7cTuDqpl9Gd3D9ZB?= =?us-ascii?Q?l2GAysK2T1bHi2+orLRa8ruZwjD15yn9rfb0AJmDBVyqJDx6qUfkQ1g/6JW9?= =?us-ascii?Q?cGmAaEaqgPLXLXKHW4w4KKqx9Y7HVSOdpqpI6BsZdQ3cGWJLOGQHyruy7tWT?= =?us-ascii?Q?cdAiKeS56SJezhhfA1brEOtppIHmammRV3jEMC8w1yRv3Lj5VA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:26.6545 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06dc93f0-af49-4773-8fce-08dcf961f395 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7765 Content-Type: text/plain; charset="utf-8" In order to let platform profile handlers manage platform profile for their driver the core code will need a pointer to the device. Add this to the structure and use it in the trivial driver cases. Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz --- drivers/acpi/platform_profile.c | 5 +++++ drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 5 +++-- drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 5 +++-- drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index d2f7fd7743a13..5d9f3f7ba71c5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,11 @@ int platform_profile_register(struct platform_profile_= handler *pprof) { int err; =20 + if (!pprof->dev) { + pr_err("platform_profile: handler device is not set\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/= platform/surface/surface_platform_profile.c index 9d3e3f9458186..b73cfdd920c66 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -212,6 +212,7 @@ static int surface_platform_profile_probe(struct ssam_d= evice *sdev) tpd->sdev =3D sdev; =20 tpd->handler.name =3D "Surface Platform Profile"; + tpd->handler.dev =3D &sdev->dev; tpd->handler.profile_get =3D ssam_platform_profile_get; tpd->handler.profile_set =3D ssam_platform_profile_set; =20 diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wm= i.c index 13a97afe0112d..a5caa529351ea 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1878,12 +1878,13 @@ acer_predator_v4_platform_profile_set(struct platfo= rm_profile_handler *pprof, return 0; } =20 -static int acer_platform_profile_setup(void) +static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { int err; =20 platform_profile_handler.name =3D "acer-wmi"; + platform_profile_handler.dev =3D &device->dev; platform_profile_handler.profile_get =3D acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set =3D @@ -2536,7 +2537,7 @@ static int acer_platform_probe(struct platform_device= *device) goto error_rfkill; =20 if (has_cap(ACER_CAP_PLATFORM_PROFILE)) { - err =3D acer_platform_profile_setup(); + err =3D acer_platform_profile_setup(device); if (err) goto error_platform_profile; } diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/= pmf/sps.c index e2d0cc92c4396..1b94af7c0e0c4 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -406,6 +406,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) } =20 dev->pprof.name =3D "amd-pmf"; + dev->pprof.dev =3D dev->dev; dev->pprof.profile_get =3D amd_pmf_profile_get; dev->pprof.profile_set =3D amd_pmf_profile_set; =20 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 6177fbee60573..1a8c29aafe892 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3921,6 +3921,7 @@ static int platform_profile_setup(struct asus_wmi *as= us) dev_info(dev, "Using throttle_thermal_policy for platform_profile support= \n"); =20 asus->platform_profile_handler.name =3D "asus-wmi"; + asus->platform_profile_handler.dev =3D dev; asus->platform_profile_handler.profile_get =3D asus_wmi_platform_profile_= get; asus->platform_profile_handler.profile_set =3D asus_wmi_platform_profile_= set; =20 diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index b145fedb6b710..730f97aab70cd 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -260,6 +260,7 @@ static int thermal_init(void) goto cleanup_platform_device; } thermal_handler->name =3D "dell-pc"; + thermal_handler->dev =3D &platform_device->dev; thermal_handler->profile_get =3D thermal_platform_profile_get; thermal_handler->profile_set =3D thermal_platform_profile_set; =20 diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 10a853b6b0514..1b6677e176769 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1565,7 +1565,7 @@ static inline void omen_unregister_powersource_event_= handler(void) unregister_acpi_notifier(&platform_power_source_nb); } =20 -static int thermal_profile_setup(void) +static int thermal_profile_setup(struct platform_device *device) { int err, tp; =20 @@ -1625,6 +1625,7 @@ static int thermal_profile_setup(void) } =20 platform_profile_handler.name =3D "hp-wmi"; + platform_profile_handler.dev =3D &device->dev; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); =20 @@ -1664,7 +1665,7 @@ static int __init hp_wmi_bios_setup(struct platform_d= evice *device) if (err < 0) return err; =20 - thermal_profile_setup(); + thermal_profile_setup(device); =20 return 0; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/i= deapad-laptop.c index 6c72d1b6a2aff..feaf98819dc82 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1103,6 +1103,7 @@ static int ideapad_dytc_profile_init(struct ideapad_p= rivate *priv) mutex_init(&priv->dytc->mutex); =20 priv->dytc->pprof.name =3D "ideapad-laptop"; + priv->dytc->pprof.dev =3D &priv->platform_device->dev; priv->dytc->priv =3D priv; priv->dytc->pprof.profile_get =3D dytc_profile_get; priv->dytc->pprof.profile_set =3D dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platf= orm/x86/inspur_platform_profile.c index 03da2c8cf6789..5a53949bbbf5f 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -178,6 +178,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, co= nst void *context) dev_set_drvdata(&wdev->dev, priv); =20 priv->handler.name =3D "inspur-wmi"; + priv->handler.dev =3D &wdev->dev; priv->handler.profile_get =3D inspur_platform_profile_get; priv->handler.profile_set =3D inspur_platform_profile_set; =20 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_acpi.c index c8c316b8507a5..222fba97d79a7 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10616,6 +10616,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init= _struct *iibm) dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); =20 + dytc_profile.dev =3D &tpacpi_pdev->dev; /* Create platform_profile structure and register */ err =3D platform_profile_register(&dytc_profile); /* diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index 6fa988e417428..daec6b9bad81f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,7 @@ enum platform_profile_option { =20 struct platform_profile_handler { const char *name; + struct device *dev; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2086.outbound.protection.outlook.com [40.107.92.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1F2D1422A2; Thu, 31 Oct 2024 04:10:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347837; cv=fail; b=VQRFvKQEiF0RTiE6XeYUyXG+5GCB7Ymti0+5sqTpM2KJEbC+77cwDyAbCUwS2n9oc3XRaAVernHkw1D3J8M5I3xW2YoZlJoX/z4rcdcVRib7w8cX+j+74qT0PC+oZ8jFyDihgc3KQ1buK9y0W9zMCpv8QfowS/VMbsdpWey1hsY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347837; c=relaxed/simple; bh=dB/p5is31qIeG25xbZm/v3EQsv85jK4gOHnlTJJd0WU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F9vUkzC+sHQHvqHFk6Ci4CvLTStp3xXQfHJgrhq/0URFtAmjUJpgKExIw44U9rn2P4XrXWX9bwO61K87qlgNIP0d1H5f+ZsdKxiz4wm7+zEnWA/XRc78+KaLQoVY6ITOgeHevSYQSFLBnInkCBVzS4lcMkZLcYvdyzabt2YXAjU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=iqYU643J; arc=fail smtp.client-ip=40.107.92.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="iqYU643J" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gbc/aYnJUrexWB7TDvDwNTqputAw0iDn8eJ/x7G0AHF1D9nfV4JFZocqrbrBpptg0YkU4eGUsSVeLACOnZaTyckKqRNBbLVazB7qRD8oq64PburHgNu3ZI48fPwKcdwCDUtEILXrd7LyU02yE85Ih+hmuDXQ1KrdMDEg/mnS8mVY/etJXJk6ulbI/FiUkugaCk28neQHN/FKZEEkSQn/fZwCjoMv3zdQYq4rz5S/gFHRJBflAxl7nqWBZFtAGHO6+R3p5QLT3n8W/baW0zlzZUZ+x94mMMj8HGTgq9s1zPEm5Phwd8eGISxzM3+bxJ0cCOuTS6lE329SBsUBqCP4/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KQav9+5aq1tZTigIRlc0h8HY9zHbD6WOzLNTqDVgPhU=; b=p3we7sFpFJe+MUR7i4Ijp+NMw4p0VC+8DezQMMU90SH5/SJ1IvOm7tADVKMmBW+IVQCss+ZCHuUiGIgoPCKVYDzirwFIF2mHk0ajFQGE2ONHl/nMjcmgoskHdMZysj4ZibENcvnxCm4Pka1G7G6RGf3Y5TWeccH2oKtlw4kTbQAtEL8aqLl1vhTPiA5h532H+FNoPkhkcbz34sNHNakg8EVOjkTp/Uh2GdyAKh32dp9oEO5anZYKEeKJlYvy53GzMOPYnQBSz3iEPxwQG0mrLZIsZCLXrOA//gAtxJwhIz5SR+I8y+PnD8ibFOXU8EVO/fPfSWCUXOD/zXCbmlPOoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KQav9+5aq1tZTigIRlc0h8HY9zHbD6WOzLNTqDVgPhU=; b=iqYU643J5fqXrvyrT73vvJ8o0P7m48Q8vacfu7/L64xzGAXMnHMXifXFC+o4Fg/QBauqVxJEiGHKBL1X+TUSd04xXw6VVmOvJSLVJtTymlMAX2bY1PVn4QN6OOamDcPz8jF8Ca82/ojCmFXsaaRA26hbtxwFFNrRBHyeF9v4mMc= Received: from PH7P220CA0075.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::11) by DS0PR12MB8415.namprd12.prod.outlook.com (2603:10b6:8:fc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.34; Thu, 31 Oct 2024 04:10:30 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::6b) by PH7P220CA0075.outlook.office365.com (2603:10b6:510:32c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Thu, 31 Oct 2024 04:10:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:29 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:25 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 04/22] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Wed, 30 Oct 2024 23:09:34 -0500 Message-ID: <20241031040952.109057-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|DS0PR12MB8415:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c5e63ad-8741-4106-55af-08dcf961f521 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xg+Fc5mTssk/06s/An3xrkZgsl8v6ksDhg1qC05ZloZv/7blD1kpDUF0Drsb?= =?us-ascii?Q?X/O+K0sd+kqG13DBh/dxcxLCIILltu4n0wJl4bOawdjti0ZyWONDORUOPJ8s?= =?us-ascii?Q?uvDHSr37ahDuAwZDEKBuGRoHsauYEHlNeI1Y4YreLikKMWKpoMymXWGXcpoy?= =?us-ascii?Q?X1ih63mmFy+ZO6z9jc2OmIAINqOd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w7avkFQ?= =?us-ascii?Q?2VfwDWhVgupSFFrpmtFNpwmejc8Mxmz1aL57WdjDxlIYasWdDTUPTaTn0Ns2?= =?us-ascii?Q?B5o3AUTDtZmjvoA/uM5Bv3YSaa+VR6p4CQWAgsBIp2krHTHMPDUlhjWx+1cV?= =?us-ascii?Q?o8unfG+wmdU9nclqrWQXhCtTk3YPFyoo6zd9LKHcNU8Aukb6tV4wT5hKiEVI?= =?us-ascii?Q?DPzGszPNrX/X76ZBvXHF089DCw+j35E4waEVFd72w7iSbl2I6jzrBgHaVKaU?= =?us-ascii?Q?xB73MzEJ0pbTyKChMv7w+HMP93R8TKqdeYz+vWZRn6NKBFFryVlkYxLKJPKl?= =?us-ascii?Q?TAZTKxE/Cc+yScddK1SIyr9eWZEo3bl+EgkTZvnHp1ZdAnMQMQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:29.7014 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c5e63ad-8741-4106-55af-08dcf961f521 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8415 Content-Type: text/plain; charset="utf-8" To allow registering and unregistering multiple platform handlers calls to platform_profile_remove() will need to know which handler is to be removed. Add an argument for this. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/surface/surface_platform_profile.c | 6 +++++- drivers/platform/x86/acer-wmi.c | 4 ++-- drivers/platform/x86/amd/pmf/sps.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/inspur_platform_profile.c | 5 ++++- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 2 +- 11 files changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 5d9f3f7ba71c5..c76b8e3fdcde6 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -210,7 +210,7 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_register); =20 -int platform_profile_remove(void) +int platform_profile_remove(struct platform_profile_handler *pprof) { sysfs_remove_group(acpi_kobj, &platform_profile_group); =20 diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/= platform/surface/surface_platform_profile.c index b73cfdd920c66..6c87e982bfc8f 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_d= evice *sdev) return -ENOMEM; =20 tpd->sdev =3D sdev; + ssam_device_set_drvdata(sdev, tpd); =20 tpd->handler.name =3D "Surface Platform Profile"; tpd->handler.dev =3D &sdev->dev; @@ -228,7 +229,10 @@ static int surface_platform_profile_probe(struct ssam_= device *sdev) =20 static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_platform_profile_device *tpd; + + tpd =3D ssam_device_get_drvdata(sdev); + platform_profile_remove(&tpd->handler); } =20 static const struct ssam_device_id ssam_platform_profile_match[] =3D { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wm= i.c index a5caa529351ea..44992d5da4768 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2552,7 +2552,7 @@ static int acer_platform_probe(struct platform_device= *device) =20 error_hwmon: if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2575,7 +2575,7 @@ static void acer_platform_remove(struct platform_devi= ce *device) acer_rfkill_exit(); =20 if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } =20 #ifdef CONFIG_PM_SLEEP diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/= pmf/sps.c index 1b94af7c0e0c4..bd2bd6cfc39a0 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -426,5 +426,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) =20 void amd_pmf_deinit_sps(struct amd_pmf_dev *dev) { - platform_profile_remove(); + platform_profile_remove(&dev->pprof); } diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 1a8c29aafe892..90c20d02e1638 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4896,7 +4896,7 @@ static int asus_wmi_add(struct platform_device *pdev) fail_custom_fan_curve: fail_platform_profile_setup: if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); fail_fan_boost_mode: fail_platform: kfree(asus); @@ -4923,7 +4923,7 @@ static void asus_wmi_remove(struct platform_device *d= evice) asus_wmi_battery_exit(asus); =20 if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); =20 kfree(asus); } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index 730f97aab70cd..65989af2e4196 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -292,7 +292,7 @@ static int thermal_init(void) static void thermal_cleanup(void) { if (thermal_handler) - platform_profile_remove(); + platform_profile_remove(thermal_handler); platform_device_unregister(platform_device); } =20 diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 1b6677e176769..22a7fc64d230a 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1693,7 +1693,7 @@ static void __exit hp_wmi_bios_remove(struct platform= _device *device) } =20 if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } =20 static int hp_wmi_resume_handler(struct device *device) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/i= deapad-laptop.c index feaf98819dc82..73030dc6b579b 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1136,7 +1136,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_= private *priv) if (!priv->dytc) return; =20 - platform_profile_remove(); + platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); =20 diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platf= orm/x86/inspur_platform_profile.c index 5a53949bbbf5f..53af73a7fbf7b 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -191,7 +191,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, c= onst void *context) =20 static void inspur_wmi_remove(struct wmi_device *wdev) { - platform_profile_remove(); + struct inspur_wmi_priv *priv; + + priv =3D dev_get_drvdata(&wdev->dev); + platform_profile_remove(&priv->handler); } =20 static const struct wmi_device_id inspur_wmi_id_table[] =3D { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_acpi.c index 222fba97d79a7..13798c6d5fcf3 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10638,7 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init= _struct *iibm) =20 static void dytc_profile_exit(void) { - platform_profile_remove(); + platform_profile_remove(&dytc_profile); } =20 static struct ibm_struct dytc_profile_driver_data =3D { diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index daec6b9bad81f..bcaf3aa39160f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -37,7 +37,7 @@ struct platform_profile_handler { }; =20 int platform_profile_register(struct platform_profile_handler *pprof); -int platform_profile_remove(void); +int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); void platform_profile_notify(void); =20 --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E9081448E4; Thu, 31 Oct 2024 04:10:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347837; cv=fail; b=IMsuWruGYmpsus9uYgnPAenzNJ1ALGvcQAXIk0rO2QVag4UF/Ef76ndoYIaMDOpNYD/7gffU9c13/PCOg8URy0F4xtJtTGD8f7gpWwzyvxbz/k4D7pBogjSL/K1Kce9vzVnIeRZs5+eHxxM2uDLOhuSsZ8WWbB0EZEsgfhsalUY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347837; c=relaxed/simple; bh=3+yolz3CqVaVknInHwF6eh5BNFawW6KdLcAksK32EyM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MB+wFJOGoeNgDCvhiNLiUus97mtr4R1YSg4yWZezBsSsIFD5OYCW77kd224hF1YYJBH27ZvIZ3PtnPAHduRwfavWINkvqiAO9uzKtgldv9ukULFX7zBNPZG5tbEYZAB1ta/1Nh0jaQRheuOE0Bwg3LyFyvFu25+JnEBlYBTcV30= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=pJZF0HYK; arc=fail smtp.client-ip=40.107.92.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="pJZF0HYK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B/yIbt3uN4O9Sq6UyrwEvLH+OBoN7w66Qj7coOfPGrmO6x2cvz/85cnx1ftqgA5h48kTd7n1tH6/wkByZFmWjC4iiXULTt+3mbPFjvx/UYxvu23pPcS9w+SJKBfZ9x5RfhsRy09hw8+mnpx5d2nscUv8Itxu6GzREeu5939l0Q7tUe0w8ikrpBOPY9Un+C82aM10ch7mR+sWhC7Jau00PCxF4NABWfqvn1ei8E/V7x8DzVsUtYeKmmDwPMSeWn17d2xMvL9QXRemR9HBPX4hXnwpoWyfI7WFV0b7UKDK/M8pnNlwvJvaRnk/KCvp4DvZbyiLchjfxMe9bz74X9N+Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YEt3L4xHA0kK5K+bkOWuGumS5UXZV2HyiCh2P6m2MgM=; b=XSaTwDUeOjCk5qQzKLvQijCRI0nELpenAxi4uHLkgAOpwKB5g8T6hFy6wrxguhNaHBNnHkXXaken3kF4FUK2rvXPwPu57C52TGSYWjqxYNj3uNIfpbX9oL4CVObiAozLvMGmH0OX5B8hW7t1P0e+nBAItWXfs1UNDKRFzbD866nnO3hlQlZUnITu4o6SEHZc8d2duasfBs+x1zLgmui/eYPlPHdzSzEqOU4PcYJEhhjZzeLwfySEJ+nC7bQD7Vd9yWqzPNBwViSOgiGCpr53BsbIJFt7RGjKo+EEMd4rZDolrv8WF4HvAB14+w78imlC0PAUBJt1cJtycn0RlYj1wQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YEt3L4xHA0kK5K+bkOWuGumS5UXZV2HyiCh2P6m2MgM=; b=pJZF0HYKQs4C+HdJYoZSTIqrY5aDClZjTcJtUcsEhEyxvsfAxM0ARkjBoas0GKciwa5lmFcMHEOnXhRgLhhaKmA08NTtAQibWWY/u1UVylPzhVJT0asF/v7+fiapituddz/ekoFzx1Q2e05Tcn2lmd8gG2s1hLL9T356iA6S2z8= Received: from PH7P220CA0072.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::31) by CH3PR12MB8851.namprd12.prod.outlook.com (2603:10b6:610:180::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:10:31 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::1f) by PH7P220CA0072.outlook.office365.com (2603:10b6:510:32c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:30 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:27 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 05/22] ACPI: platform_profile: Add a list to platform profile handler Date: Wed, 30 Oct 2024 23:09:35 -0500 Message-ID: <20241031040952.109057-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|CH3PR12MB8851:EE_ X-MS-Office365-Filtering-Correlation-Id: 698754d6-39ac-4433-4d0e-08dcf961f5db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?hrkKcBUMQRtT6outp0szF9AL2iETAW7gYE2eN66HOzrbjym3qMr5flKVYLLT?= =?us-ascii?Q?Ld5U7h73LjWGH7PLb1caLTYVlAuib3mMIk2hc+XU21jJ4WgpcVoFqfep7sCs?= =?us-ascii?Q?hgMniL2SEBXEZHGXgTTXgAj+Er+dDX5H2YW0QcbvBMF7PK1C0MdqRO1Fv8iy?= =?us-ascii?Q?AhwbJkiyelFk32iC6nJrVSj8GwqZc12a/R0VqVlrqtGEomidUihMNBHIe3vp?= =?us-ascii?Q?YvjTWduBp+JQ9zLvLTAb24991NTBLN8zp74E1ZOUOcri0oIjwHnvOQlMkKW0?= =?us-ascii?Q?0rqjJnGhTLPl8z3nddO6NCzyViESYF6njmxqdGOlH92ZnxoZ9CvwHnkffqOw?= =?us-ascii?Q?vdc6ILZfnF5JXOtKGVcukb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q?WNvsdRmN1MbznDDR9NkbiZwFl0mHss/6GhGOCkXLdcdSaVmDJJeydnKnn6Za?= =?us-ascii?Q?9uMnsCxqeIUNDAgABABEBBldCF3bqrwuXvBOCU+jqfgw9JWtYVV7LKas/BN6?= =?us-ascii?Q?BPt6hxs2qsxXmz37k5c91kw8kfttUggXJxbu4Jewc38L4bDcgQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:30.9983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 698754d6-39ac-4433-4d0e-08dcf961f5db X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8851 Content-Type: text/plain; charset="utf-8" In order to prepare for having support for multiple platform handlers a list will be needed to iterate over them for various platform profile handler calls. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 5 ++++- include/linux/platform_profile.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index c76b8e3fdcde6..d0198d2ccb551 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,6 +10,7 @@ #include =20 static struct platform_profile_handler *cur_profile; +static LIST_HEAD(platform_profile_handler_list); static DEFINE_MUTEX(profile_lock); =20 static const char * const profile_names[] =3D { @@ -203,6 +204,7 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) mutex_unlock(&profile_lock); return err; } + list_add_tail(&pprof->list, &platform_profile_handler_list); =20 cur_profile =3D pprof; mutex_unlock(&profile_lock); @@ -212,8 +214,9 @@ EXPORT_SYMBOL_GPL(platform_profile_register); =20 int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + list_del(&pprof->list); =20 + sysfs_remove_group(acpi_kobj, &platform_profile_group); mutex_lock(&profile_lock); cur_profile =3D NULL; mutex_unlock(&profile_lock); diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index bcaf3aa39160f..6aad98f4abaf4 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -30,6 +30,7 @@ struct platform_profile_handler { const char *name; struct device *dev; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + struct list_head list; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); int (*profile_set)(struct platform_profile_handler *pprof, --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2045.outbound.protection.outlook.com [40.107.244.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0FE3145A07; Thu, 31 Oct 2024 04:10:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347837; cv=fail; b=YX+WRON+t+LhMahN7axoT2uJ8Gb/Q9/ijUEgG3q3adKcozRPv6qF1RMviy87kvnBWeAmMkdcrYGXj9u9UbqAsQdsiY4EXSz1775aYoarixw+H/Nma/bj0m+59wnwbtdMCF+41U/C1539w3mtTM8TR1+4kzrfhcq4jMjbGEj/ARY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347837; c=relaxed/simple; bh=lITivSxWn7ZJIFuNDUnBiffU95HVkMnsOulfhflcTWo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E6XAdYAXUaiqPUsNjzChrGNNuPy6WhMJeQufKT16tmy4REf48n4Gfo+lXIcmn0DumnRZ73+3hh8DIgLg6Y7GR6UYXwIRBjqQ9j3ngEm+8unT1bDBuMsB2SdcN2qFMwj2VLiwdySOoK7cq2zGvcu76P1YmaHoX3OeLxPONYqqKHE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=PIpjrCoI; arc=fail smtp.client-ip=40.107.244.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="PIpjrCoI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WS3ShhxLyPD9w9da3mfGmLzNIwXfNw7d5pE7p6mtY25ue6oucefNpEJ/ZL7y0+HEISbfxcBFt2CAVU3CJRlHuD3wXvBBhUZw8EMHSqEDk/BYZiR/04o9XCN5lgv8H8Cim9KwACV/zLeeqGUlNLMeEHWGucVDVHQew/ytbHMPGEMgu/A4TERP+cPVfFBHv5rnTfFcr9f+UmMxCPUEQWYhEvn5oz9BpSjeScSCb3Syk6GDyKvzuhc35ahk+jSTmyAiS+d7xigFFqbhc5qM2FMb2lpp9mxUGk3niyP/nIjaqkHpsllVCFqWrzt6E5dXr/Q5GHkxQNz/fQvrshD8GKPkNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vhE5ZoBZMfpPu5FgwOwo7akoVYoJAzzRoSOpdj2fwyc=; b=avxHlnf7o7bFCuv6qwfqvgBnzrn4kwgbrJRmOLHXKA2UWAmmH6c2KesLb5eeUT8fDMG63yQTci7eri3Qs7/wwXuhveuEujdwVFWHs3e+wRJygSNSdK9Zt7+BO8cXDIVLi4z8QgKWI1has0jDA1pfPnllIZmef1oKRalb+lm28wjxwMyWsT93L8PjN4xoke5AyIAst6s1HnuUaSvTx1LNqlcmqMYyD0jUqrjEz2W+35RWB2fFdWzucSSE3fepn3UfBS2tq0ITEMYijqai/00GWG7Z1W6pBQintHDMkiI7fq4wmK/rk++r45HL9F4tb4bZTstXUo/J7EBRXTLGQfhetw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vhE5ZoBZMfpPu5FgwOwo7akoVYoJAzzRoSOpdj2fwyc=; b=PIpjrCoITtWN8KQj2TVgQWuBU3ppydIB7UrxonPyUTx+eSpVVDmDuPUVT3nQHSWIN7T3BwHiTLruxTfsZEw43r5964ohefDlE+EsUcJSItVeIg3V7nlEZM50aE2Q/+y7aZanusS9pA1ddgRFzLlJ3agAMxUtjpNHkWeqRGvSMA4= Received: from PH7P220CA0072.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::31) by BY5PR12MB4275.namprd12.prod.outlook.com (2603:10b6:a03:20a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:10:32 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::1d) by PH7P220CA0072.outlook.office365.com (2603:10b6:510:32c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:32 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:29 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 06/22] ACPI: platform_profile: Move sanity check out of the mutex Date: Wed, 30 Oct 2024 23:09:36 -0500 Message-ID: <20241031040952.109057-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|BY5PR12MB4275:EE_ X-MS-Office365-Filtering-Correlation-Id: 1fad3cc9-6d33-4798-305c-08dcf961f6a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?f+vPwNnOU0BeVwvUil2u2doryU/luHtN6PAFO5+GUcX5P4qWpTuI41izdn/t?= =?us-ascii?Q?7oHj5+jV6azQXILWbJVpqY6LNFOhwOjlUHqtsMDIMFGzHu2mTYaToAm/L0Ak?= =?us-ascii?Q?nNhOxg7d/tgX3jcC4egoFT/qZVWRPtMhyvd072ghPNgqunrRD084buc4SoHB?= =?us-ascii?Q?7Ers5G/abT2qRPQjbTRT+DsbGm67c3MOwKKsdmkPoR0oLqg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ImPswoX1BbMkBvP/jGQC7ROSe6oKoe4LTtX7fbvo61+cLUJT4vy/M?= =?us-ascii?Q?XvjL8C1dSRufw8aUnGRUoSksH0X4EKldtk43GvZnuPIwhvXcRFLPdHj0BOXp?= =?us-ascii?Q?3yNclYrttiOxEc5Z0B1cKA5P90T6khW6rPe9+/6vJd6WgJ8C+dmsiCkANLhJ?= =?us-ascii?Q?DXNkxnm2vyT6YXgVMWcoHvSGUG89ryQ6ockrakr7++AuxEaEVV4JAmSgiGZm?= =?us-ascii?Q?bCARJ2l5zuKIUWgug84XN9mu+WcdkhpHmQWK7cHtW6DalGHdaQ0aZrNsobWR?= =?us-ascii?Q?3fKlQyCWT7eYY9HD68sGd87AONStAc3JhJy3MWKmGXncnVB4Vg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:32.2951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fad3cc9-6d33-4798-305c-08dcf961f6a1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4275 Content-Type: text/plain; charset="utf-8" The sanity check that the platform handler had choices set doesn't need the mutex taken. Move it to earlier in the registration. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- drivers/acpi/platform_profile.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index d0198d2ccb551..f2f2274e4d83e 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -180,6 +180,12 @@ int platform_profile_register(struct platform_profile_= handler *pprof) { int err; =20 + /* Sanity check the profile handler */ + if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || + !pprof->profile_set || !pprof->profile_get) { + pr_err("platform_profile: handler is invalid\n"); + return -EINVAL; + } if (!pprof->dev) { pr_err("platform_profile: handler device is not set\n"); return -EINVAL; @@ -192,13 +198,6 @@ int platform_profile_register(struct platform_profile_= handler *pprof) return -EEXIST; } =20 - /* Sanity check the profile handler field are set */ - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->profile_set || !pprof->profile_get) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock); --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2085.outbound.protection.outlook.com [40.107.223.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA9081474A2; Thu, 31 Oct 2024 04:10:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347841; cv=fail; b=H02vKRFy9ySN+SrQKoraKLSnwj6APTn5AZkZ7/wAGwJOJ4JQUKgw18cBA0k+8NjONx/E2ee4DNCOcBZ7jjqh1rJm7LRNQYq1/XI2iVsOdVbc0AIldqkG8w5Ef3m+V6F8FTv76t77yWchSSzBZK/PMXZN+CCKC09/Vz/xLcvKcF4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347841; c=relaxed/simple; bh=E+hQchgdGdaS267kdYfzGBDNAUhOSX4W0c+LvWbVk64=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gFAOAkE+HbcUoUCX0NenBQUTJ9XaRdIsNMOF2oEZSBwWYF5sjI+Jd7bk/GtmQL/prulmDvUoiw25jLaxXtntQae0Vkst+llCJWcRH52WcVDeCQVm+4pw9SCRd8sEJVMurE1WHcMX1gSdLYJilKFnWkLoAicByWU29B1x9rHNBo0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=siY8e2xG; arc=fail smtp.client-ip=40.107.223.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="siY8e2xG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S9Jan57oOa/AYpr1J9NUyhLQTD+5WExy7Rpi5ehfA2TzIhfZFZzfvhtgKBEVzdEtbyYl8IHt0T/kwfyr8dWqu/PPpbv96zkEI6OoUzYu3lJj8V1/pw7Xj9e9j3/eUX4dxeM9Uue0ZgK4hqGDyBen5XXxAoquzO2i6h/2c4ag1KWJUK24OF2tdvymianLma2R3j5tTUofhrbCWS5Ja5YVM/gIydUamSInFQF9lvZJhT7gPAd3ddhwiGDNDzofFLtuJEJUrVFOAICEeH36kc9+n2dk/EmpFVD23neACnXCV3DYMMfQ6NgawA3jZsfeE0IDy0eARVZHpj6e3Zc4xoiY8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ru2E8mvU6PKJs63/fPnxqlo1YPE/bzu17chK5A3+i1Q=; b=VDfxg8c8POZHrp790t1jxufHcnhxQiWdT1MSDIG+UudzDavdbx93PtiXrKZA2tYkdIg9FPvYg4fpMEt+yhJR7kj0Oi16uYc2XasQVH+3r7wjT7O2tgGBYJpM0SKWakbIycp+PnwiBWAvZUjl2hhhIWEmdc2mnJYF1S3fRDjTCS5mLAyh65ZSQp3YhVrmfaiNN8pe+rJvIw6ejEGujEf7gPFj22t+2cea12pNTQFI/cDcJTcPtuH7fjC/8p0WMEUR0qq9Z5/95OgDrd2m5oD5gb7mjcQce5zkfw9iTBErSSOljKIwgOA5FcrmLrmebsPUANbyrvodVlsfMoBxDjOBlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ru2E8mvU6PKJs63/fPnxqlo1YPE/bzu17chK5A3+i1Q=; b=siY8e2xGLfwnFpsVb7BURVu5p+KXr2IMrJjqbMb5R5r6S2iYekj/+fHQUDfVkHBe1ywG47PgcsYevoq1RLu8Bw7ZkhfE1OiKlxJ+uaxg3sZkuYuf9cufpDTh9WtwVbNeSeltxzbe/l4arqiMLU7SjrrrupXfNVu5sdkTvhmNjqE= Received: from PH7P220CA0068.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::24) by SN7PR12MB8104.namprd12.prod.outlook.com (2603:10b6:806:35a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:10:34 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::3b) by PH7P220CA0068.outlook.office365.com (2603:10b6:510:32c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:33 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:30 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 07/22] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Wed, 30 Oct 2024 23:09:37 -0500 Message-ID: <20241031040952.109057-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|SN7PR12MB8104:EE_ X-MS-Office365-Filtering-Correlation-Id: 484dd568-93f5-4507-ec33-08dcf961f75f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?e71TkawE/VVJhavUe2bn/BnDqzDmCLHHFVGbLw/cW3NYKLMqpAZVzEt4pyzY?= =?us-ascii?Q?Eeoc1+QMqMBfZBCyQsCI3uOLVzLq/wYHq92MaFfU41AfTiaUMp6v69E5/JyE?= =?us-ascii?Q?E/lsnRVd0VAej4BUato2tE3aMAKI2ga+ioRP7dUozvjbiEcWvc2NKUUk/i/s?= =?us-ascii?Q?REl6jxpGSPD3gwhLIp0BObYHrxjxhMJsTp7HMqdgg0rEPRfNmMwL+8DYBWZT?= =?us-ascii?Q?gS5cNQy2MEoAibEwczyl6t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9Kxsmi?= =?us-ascii?Q?xR3fbctD1sAKyG8Fd4K+/ehxd9OpWmvl8z6CovoWnouC9eUKJ4HsxaijH2Nc?= =?us-ascii?Q?+z07TG+xtPkWqFwMHUGLKK5UtA6/CIeVzz/BF7lOUCFVCT0EDqec11NU8Eoa?= =?us-ascii?Q?mBVajcL03nQwzFQsHuHl090A0fdQzD2nA01/R0Zr4Kmufpp7roxChJnLzQZZ?= =?us-ascii?Q?W+SOroZm5zTU+bYKFKKQvnWLTJptVL4PS/gSC9B4qNdyUhdcv7jlYkiSRPzv?= =?us-ascii?Q?LmwzDeg760tcXKrU0Ud/kfMpG+2qcLAG/t14scfoocaT0Nvakw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(1800799024)(7416014)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:33.4670 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 484dd568-93f5-4507-ec33-08dcf961f75f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8104 Content-Type: text/plain; charset="utf-8" guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Ilpo J=C3=A4rvinen --- drivers/acpi/platform_profile.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index f2f2274e4d83e..cc2037147c0fd 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -191,34 +191,29 @@ int platform_profile_register(struct platform_profile= _handler *pprof) return -EINVAL; } =20 - mutex_lock(&profile_lock); + guard(mutex)(&profile_lock); /* We can only have one active profile */ - if (cur_profile) { - mutex_unlock(&profile_lock); + if (cur_profile) return -EEXIST; - } =20 err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) { - mutex_unlock(&profile_lock); + if (err) return err; - } list_add_tail(&pprof->list, &platform_profile_handler_list); =20 cur_profile =3D pprof; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_register); =20 int platform_profile_remove(struct platform_profile_handler *pprof) { + guard(mutex)(&profile_lock); + list_del(&pprof->list); =20 sysfs_remove_group(acpi_kobj, &platform_profile_group); - mutex_lock(&profile_lock); cur_profile =3D NULL; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBA821474A9; Thu, 31 Oct 2024 04:10:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347840; cv=fail; b=PVzxD2/AfyQRpWrcoKNHfJ033RQu/fvI/MQeHKKsabrVg3I1lCgLBy5pC6RUfljqqnTeGJvNTRg0woypnarHhGip2xY8TRpKFhxL4VovFPZX98bQXLrCmE9PEij0SpGuWFtFRc6k29luZuZkV8S0kFXCAhJnBFIzuSupQbWCmDU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347840; c=relaxed/simple; bh=kHSWXmoYwTA7lWKf20voObXAqnC26/Pqba/tidTV9C4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dDXQs1DTz5qDLjkPY7jt0k89ykdgoU/jdd9geaLYwn64CvVtJJnr2z8k/EkG3/Yfff0iVN+jzc/Gy+jBMJRDmwU7vy/nPMvKqtEcUSSmMfNX/8oh8a3li6A1/A3+to0UMfD77xoI/KGZnLKs5lcynl/KT9B/vYDlwvSBXtWClgA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=00HJhEU8; arc=fail smtp.client-ip=40.107.237.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="00HJhEU8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KmIrnJuG0HYA8slndJMHB18BE4SBDvBK0VDPtiXf6ru2QdDdQu7kVSPJZ7+N5+5qglcb0ut7vkRzVDbOyqOY4/Fc1eOI7BUDD6OgrMHGxxRkWL0mlesjpBymgDlwxptgof19o9BxsBZUGz9QeY2B/cIT7kQKeu2ElF9NIWcPP21/Vi9HaFiA8wfvIhOZRWdvVh0697Spk0El45fnMwhWgGXwJ9TlmpnKXizusBA7vGlVvLjxdYO4OBni1Tc8iN14WpRhunLPra9K2sb4JLMyv9AO7caFITph00nTsX+XSQw9JDZS7o0P3FznI9kuxnG4OPri8lcQ1gGq3Asb6iwesg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i9RBHR3gyJfqRzIdQq8UYU5tcO1bw9e9KrBG5YRN3FU=; b=SHnFKv6E4X5gOXXLGooC1YaSPwNsiGFYDvIs5RMI4x/AcnVJU8OAnYk6JrV6MfESWrlaf3cscjQPlzND1GN+g6CEDMkqYTiC6SMvm6AWlggBlYsau9G3VLRDFs5Rt2/8m8ATcMsTvvf8teeO87RWLQ9zGAxmrZido5AbM5Dx3FW2zu5dt4PvkFoc/XTSgc4Pak2s0Py4SerNLyWpbVucwVJ9VratD8B9a3LcJK4Fr9bHnUWk9PdG5gb9lYp7qOj9naF6W/Nb1508jqTS0ojDFySYbVK8EyStHdrINB+WEo2MqfK2OLQIxSDcX1CbkwgfVtS825NeXkEs8udwHdwFeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i9RBHR3gyJfqRzIdQq8UYU5tcO1bw9e9KrBG5YRN3FU=; b=00HJhEU8KrklNo54gQ14vGxKNYa4eKppr42J1I6YRjy1GFCHhP1aaW2299vBf5T4FDsYLn8/mq0PPdkPbdJEOxKMT8CKQ7cLzSRhQYvbjd+gowBtVmHpfdsF76dzKE90l8gLYBjT3NxSuUTny6rBoZbmg0bAemms1wLZEN/IsbI= Received: from PH7P220CA0089.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::14) by CYXPR12MB9337.namprd12.prod.outlook.com (2603:10b6:930:d8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:10:35 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::10) by PH7P220CA0089.outlook.office365.com (2603:10b6:510:32c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:34 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:32 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 08/22] ACPI: platform_profile: Use `scoped_cond_guard` for platform_profile_choices_show() Date: Wed, 30 Oct 2024 23:09:38 -0500 Message-ID: <20241031040952.109057-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|CYXPR12MB9337:EE_ X-MS-Office365-Filtering-Correlation-Id: c15bb5b4-4b8f-4709-34b2-08dcf961f7ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ummZYh2LH5vJN3GrknABRToIXN67YQVin4AivSSbPTKuVx+rwVB3EiceRyon?= =?us-ascii?Q?pZWCW0kJZnroRTYAF2fcJXPQRwWOBHrIdNSN1hdNSGGZsrz94tQWC4puPANO?= =?us-ascii?Q?SBoWyvo3otR/FumO/4XETZikZ199JAsR/8PM6U4pMp3NM29LVfV9Hx4gu3Rm?= =?us-ascii?Q?I5ZBtPXZKIkZBdcKAmxA/HpeEpTTgg1jmycho26dEaZH06ZVZUQV91ym8N4J?= =?us-ascii?Q?p7kQCe1rYx16Iwa/X+ubrPDM3ncfkqUoC6LPrKd+7hAClUl5VF9edbMIVRTi?= =?us-ascii?Q?gvZNv52s6YTME5cQii9Ph4O54dxndVUeecUMW0qxoYNowPxxonYKpboRadBN?= =?us-ascii?Q?66WFoZVySr5CsLNyO88YJnjXXDBnvG/AGt6UW31rq7lQW7MR3HQSsbWz0918?= =?us-ascii?Q?iGAFUiZgoD2axmoD6mDWXm9o5LMWcn9A5goZf2hGUKt64WbYh6mMvAkhfh/F?= =?us-ascii?Q?aT6WeZyrVGjL9jW2GFx1wi51juFIgbgEgbt3ACItGhWEgk4QPUpuOkWU8Pab?= =?us-ascii?Q?/ry47nxQfrMvJzL5FxenA2viW5njN6kfH3t55rrCtRUQkw0CTteAN3OpO8nW?= =?us-ascii?Q?MazPi5n8tKAO8XnqQ+zGTs+QPSWq80XOoiQi7GJZ2f9m7vDNKV1FbxlMzBon?= =?us-ascii?Q?2+mXHQQFT56I7GjFmJavMivVg1E88GiY5XvAHTAoJyyIkgAnazn3DbQVkCqS?= =?us-ascii?Q?ApWkN2lBRkEcxtsvcDeC8Iy8wrTOVUrIzdFoMQA2k+lm39p4nUnk7/ILwQpW?= =?us-ascii?Q?9XcVpsCR7D5XwzQrs+65TbLYYIUcdsJBIXLBQGZ1TCRNKVHo+5oiJyUojLo+?= =?us-ascii?Q?8SgEUlLLLrSSOHVfA5CEnMgEeV8scge4BQDdnJcIeeRhR6gEcb/na+J7cktQ?= =?us-ascii?Q?dW1eFFdU80ktGs3vg002ms8y8k1yheFxzYi+LvTa7wzYTv/SyOa1frQ9klcu?= =?us-ascii?Q?q38Kl5ZIKAMXMZFewcNdayQVWk7mGgfIntW9LAxAD340IF3h5ys3kOGQGP9h?= =?us-ascii?Q?bOcNlyz9S4Iedq+HGceON0svx00sUye5xocoGsW0vG08qdvgAjZbZ1ni785s?= =?us-ascii?Q?TCp7/yktEeq9DwB4zx6quXbNNLii+yhmNudN46nQx9UHWKZ/jelah0rIBMzR?= =?us-ascii?Q?u57LtnmIqPBHsSeeBqGG/jCHoWt8ecXUx1W7/TNyBnvANqiAJX1ijkZV8Xpx?= =?us-ascii?Q?AHyKT+brF49rccF+zzEHzWAYaujgVZ8Tf5pg6igqrLAnf1zYBxipNzo3qEp7?= =?us-ascii?Q?IbpYsvoL1GhqIOmc51fblIQhEmNd0XFTu6G0xyjaiB4//Gm0yr/zDwBhz9iG?= =?us-ascii?Q?7E3VziBvusEN5FWbdoGbH3XxObSaDK+toLBW+k/STtdQPRZthnqoe45Hwa/e?= =?us-ascii?Q?ZWnxyuZe4vVbBqGUmIV+TqFAl89FzlFiUXZA8wlMNBOdcopD5w=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:34.4514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c15bb5b4-4b8f-4709-34b2-08dcf961f7ea X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9337 Content-Type: text/plain; charset="utf-8" Migrate away from using an interruptible mutex to scoped_cond_guard. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index cc2037147c0fd..79feb273c1def 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -28,25 +28,21 @@ static ssize_t platform_profile_choices_show(struct dev= ice *dev, char *buf) { int len =3D 0; - int err, i; - - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; - - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } - - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len =3D=3D 0) - len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); + int i; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; + + for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { + if (len =3D=3D 0) + len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); + } } len +=3D sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } =20 --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2055.outbound.protection.outlook.com [40.107.95.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECF941487C0; Thu, 31 Oct 2024 04:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347841; cv=fail; b=BmfIP0v3SFeMPrvpaH5wCGplyIqYBoe8s5QtjQhA8vE5TJehlHUc0Gg+EYD+S6lySC5HBRSXCnJoil9hcAbc8pEligHyAlPbw+9wDpN4y5/KMz98ij4qRPgmG1doH64vx2p7jvV3ylii4B+ejWK7jIqqgVsbQOTomtwBKTgmlTA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347841; c=relaxed/simple; bh=kZbx+5plx1y9L5bCopHfGpx/A+YaI2ZaYuLZ1EpbbYc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oYqk8npnMmB8+iUr7Y4+MYvs1hN0eedJZMyatScxvXJEgO5HQ8ScEZOEAfxqnp/JHdB69OzwfTtq+2wOUQWTgGy+PAInA39IivIHHuL51K9ocfuMdTDrwSR7BF8sQ30hQ5IjCmYBa4S3gflc2LXwELAvI2UE1sTnqTIslt7+qdI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=hX63oKhE; arc=fail smtp.client-ip=40.107.95.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="hX63oKhE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jEpfcGklEbmCl0hZT52wTOUPlOpjVkYbebwQ/PwBDuL3I/A++IPmRCFElNxGKuSunv0N9GNbKJdG55PX+2ZvEqjaK1C1vmiAbIMejraLVfKF4gzu5G86GB++rRoAwFyCNYjTc6REbkY4UO7fk76dbnbKfJQ1J7avKetvucEGr1jK3owNZBnvTnzghf/CzYP6CtP90iGpo+QtZZ5OmqYtWjyldCvMAoBSEQn4JUR2aLUdOIAbFpb3Xz4mqDH8PUp3uQ2w5r7MNA0O4NWRAfUiowsnvS5EgzMjuP7bx3nkPNf5rlSobG6lNISZCNxelmJZc/uA3iWwrzECyqZxGpYvBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZsZ5aFimorcU3PbFA/8AHd8NCIp4H4npWyPb1dAAxI0=; b=GZZBBysaeoXbdb6yqHzqXvfM9l/C6JT9q9mqBC0TFDKUnYj2tFS2p3+U2wHkO7LfmSpy5WwqL9A4zNqMCXXpAXUtwxiD+5sKGfxEkOi2h8FBzftVdnZWCpYzL35bOXkkKDhDgFLtZllYHbUplDZstGDF/ooszsuMFQ82iTMfkjn1/TPU3SQcJnpfhC1wdzQs29K0RppYhN1HkQWott9+ljS2WlE3gb9IOXC6ifB34y8MH+sYojv0f1CXYTqLZlje4+TwUP+SwL9cL9uAyfW9xE8+xBVF2rnx1leYcJyyffimjYP6DUHbZO8pDcXBaeh7H4VqfHqLErMx2nRhLPeVpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZsZ5aFimorcU3PbFA/8AHd8NCIp4H4npWyPb1dAAxI0=; b=hX63oKhEeCGkzTCAXJZb3CYMxw6S350DtUIMR3cgDhT3mSJeZohM9JjP33OkQTRSiEM1XV4ZDMadNeGLo4fBccqLQrx+pvnzMWWUOdnV+V0Ar6+By0AyFYQXhAV475l2aLgrIbeCeyRR7Cpwjt3j1m9ojggzHC/rdpOYkt0MANg= Received: from PH7P220CA0080.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::23) by MW4PR12MB6778.namprd12.prod.outlook.com (2603:10b6:303:1e8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:10:37 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::7a) by PH7P220CA0080.outlook.office365.com (2603:10b6:510:32c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:36 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:33 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 09/22] ACPI: platform_profile: Use `scoped_cond_guard` for platform_profile_show() Date: Wed, 30 Oct 2024 23:09:39 -0500 Message-ID: <20241031040952.109057-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|MW4PR12MB6778:EE_ X-MS-Office365-Filtering-Correlation-Id: ffaf378b-a87c-452e-4bdc-08dcf961f946 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?hSiAMMF/HABaf6wLDcC3SI6gjdH37W61RhFmk8U76xTmc8prJLEDOBD9UD98?= =?us-ascii?Q?3APkkm+C2ix7weHmj/jDB8qrICX/TL8KKxu1NPQVau6z/X1SsRCOFP/7sszw?= =?us-ascii?Q?rht91ug2NE8Ist/39hBhtMfpWatIe5I76ZH7ffsCaezWoNKIu1M8CQpNzdh6?= =?us-ascii?Q?LkUKdDU24t+ieTrSOkk9sCEJXyyJjY4PUK79yhZR6ADaCyS1OltgzbVJ5SR0?= =?us-ascii?Q?LH6/9/qBd0Kq+lX4OQBF/i0vy0nONlGI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us-ascii?Q?05Ugpm3f+i4KW+mXYiTCuCOO/pVkUBZK5h85Ktn9BkFgycEMrFIH4Y3/cWg6?= =?us-ascii?Q?c7PxWEcFt79MIP7Iwt+VpHvGrC+hE0hbro1MJ1NAzPtHIHZxTYL/m/w41KhL?= =?us-ascii?Q?QgF4D8ZMXAV9TLmOEZ6ylFTC4AobF/uU38q2XSiuGlkVhSbOOf7jOezA+3br?= =?us-ascii?Q?EN+Cpc8AxDNz2spK3YilhBwh/JKENYPMQ3+IEwLQb9FoLGM3AhtQRSbi9fIt?= =?us-ascii?Q?ls0gjx9FnRb0oJ4Uq5YtIwDtyeDvaN3WM/RKecL0PAwzCYgZyg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:36.7326 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ffaf378b-a87c-452e-4bdc-08dcf961f946 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6778 Content-Type: text/plain; charset="utf-8" Use scoped_cond_guard for the interruptible mutex in platform_profile_show(). Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 79feb273c1def..b48dd34301f13 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -53,20 +53,15 @@ static ssize_t platform_profile_show(struct device *dev, enum platform_profile_option profile =3D PLATFORM_PROFILE_BALANCED; int err; =20 - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; =20 - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; + err =3D cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; } =20 - err =3D cur_profile->profile_get(cur_profile, &profile); - mutex_unlock(&profile_lock); - if (err) - return err; - /* Check that profile is valid index */ if (WARN_ON((profile < 0) || (profile >=3D ARRAY_SIZE(profile_names)))) return -EIO; --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2076.outbound.protection.outlook.com [40.107.244.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 943AC1494CE; Thu, 31 Oct 2024 04:10:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347843; cv=fail; b=UVbU8Jsj72TmY0+Py3VlBP7ivpUEqgJbqEk1VVtw8Ho3rtkBRTp8mIjuq1Y9iQcm4bC3Oo90I1co4luQeRZhXfssrOPG4NuM2tj4h6xpda640MhsilH1jAdf6uPYX2/T9/Ym/gS6GXWUZ/3H0utFuKAcA20Ze8l+23c99xyqDu8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347843; c=relaxed/simple; bh=kssn2NDK6gU3O/WAz7m7+hTS3LctO64s30kaUthU5Nk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YAVeUiv1SmBv54v6pAHfHEV3fMMLXXwudhMk2d2votbgprUu1QfCMWzRB/6+QfwXgfzvPZzxXuZs5V3S0bFNV/oR09bZvdbSrZmC5fuaU3LvV4aVikbvz8yvQqjHLOC4NfUrgXgMPTLOs/hIMZeTrdrXwl/GB6+r3R4Tr32FIWk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=gawAFDzX; arc=fail smtp.client-ip=40.107.244.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="gawAFDzX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qLq9iZ1ztTiyz9ZAhnQMtS1Ba97VJNVPfTEq5PKP8OCMmCg+Hnk9hEj194w99hGrW2lSWAtAixxc6GC/osQkuzzuwp56mLwd8oNFZ5jFJg3i7shqAzsNzerBXoRzbuu2Grbzw5Vp2nQOubfOmrkhiLEuGDWEsUXLpip9/uO1ywaQsFA91FmO9jZE65Ehxjhsln3emXzy3dFd90WxQO7ISeBh7N2yuN4FiFbdoISrP2OBPk7shSYullOlEJB3smmdjvd3Jt9G7HxpIJKrCnHF/uN8kc4A4QeArCiQ9y1I7nJY2TUKAvRyimw/i125mNdnRs3Axq1o+aGIWCqLN10/mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wMe5H6/SASpOQUoahDlnuWpv0h9KbKCpZ1FiZ5ixcT8=; b=H1cZUaHDeI5MV4fA+rkE0qRDoZbuk+7YptYLLLFYpojeCb/Xcqr4757HfnqIYnN3OD1b67zEtQZqXF7eHK7BHobTocSEyQ5ucYfCCNaJ6zO+4up060xhsEdR94bvCZ59jppoMWy76SLzK3XlpdrLeThpITG7t6NHcuj3VBXQsgnC/yL2WCrFEY3TLJS7/G0TApSOgRvoNvNOwUvwvvoIe+e8xZNMxE20rMCIJ4ZeDR+lV9r7kML4TuJIzJlvi3Q9Vgyf1jM8FEHUFNXx958oDRU+lVK60l7O+MwPT2pUZCO0fy4/iWKFxkg7QdMrXbcRMCymZqP/lUrNIunu/CWC4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wMe5H6/SASpOQUoahDlnuWpv0h9KbKCpZ1FiZ5ixcT8=; b=gawAFDzXoMTVngq6fcndr6WUhekB3/sfgKEb+ZJsHJQNUIBWuHcp9FVRyHqI09EhZOuj0il6AGL5j5iTD4SID+I5rBfhy+XpgksDfwBXn6C6refqjKdhzW4evFFD2Q/jByyDPQkteAQ37NxgBfXegODQfc4RwHzQCKQUeWBKBVE= Received: from PH7P220CA0079.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::27) by CH0PR12MB8579.namprd12.prod.outlook.com (2603:10b6:610:182::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.24; Thu, 31 Oct 2024 04:10:38 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::d1) by PH7P220CA0079.outlook.office365.com (2603:10b6:510:32c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Thu, 31 Oct 2024 04:10:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:37 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:35 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 10/22] ACPI: platform_profile: Use `scoped_cond_guard` for platform_profile_show() Date: Wed, 30 Oct 2024 23:09:40 -0500 Message-ID: <20241031040952.109057-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|CH0PR12MB8579:EE_ X-MS-Office365-Filtering-Correlation-Id: 004dbde6-2708-4b27-cf8e-08dcf961f9cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?fuavviVrhzqIQovrKVQV/SOynpX0D09vdwiR3QQOY8wwqskQO5/sJoDrivB/?= =?us-ascii?Q?ocor47GjYaCHGeNH2FfEq7CkluT7xU1y7JMZqurZ5rhwe4+R6KKRv4paJjng?= =?us-ascii?Q?U/3rJDs5NxllMUNBMW3pgWhvp3fC0V+KQFlj+B5Gzu6EIqmzYDLOEHTDINyC?= =?us-ascii?Q?R2YX+/87t2aSx7OhL/UV1nmtQHlslIx3ietjO2g49ENBxXOjd0VfzEdbDTHp?= =?us-ascii?Q?BnGRD2rtTtFK+ootitQxnlzy+o9MkOiSxjUnaNixwpvtguDFKDIh/rhuLqhw?= =?us-ascii?Q?w1ZddRTz72MEUu/Y6mpSh1158GK5CapfQrEy021/AU9HRoFxG8YvgiiZAt3r?= =?us-ascii?Q?db6kIY9M3pDYRl0x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?= =?us-ascii?Q?xVT4wWD4hIbqK/tHQxtGT8mYW+rH3sRIGBYB+vrq2ZuyzE3xvwrYEXRLvCzV?= =?us-ascii?Q?Qop/x4FR7imLsUd0E9DOY7OKc7l5xa0xC7p7NEKi9HTtkYwaurhIwAN1OpVD?= =?us-ascii?Q?r6nmlifdwrbqWltiDFzf0M/zhg9RjatC94UklZoXGK2cTs+m3A=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:37.6076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 004dbde6-2708-4b27-cf8e-08dcf961f9cb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8579 Content-Type: text/plain; charset="utf-8" Migrate away from using an interruptible mutex to scoped_cond_guard. Also move the sysfs string match out of the mutex as it's not needed. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 36 ++++++++++++--------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index b48dd34301f13..63a5f5ac33898 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -75,35 +75,25 @@ static ssize_t platform_profile_store(struct device *de= v, { int err, i; =20 - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; - - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } - /* Scan for a matching profile */ i =3D sysfs_match_string(profile_names, buf); - if (i < 0) { - mutex_unlock(&profile_lock); + if (i < 0) return -EINVAL; - } =20 - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) { - mutex_unlock(&profile_lock); - return -EOPNOTSUPP; - } + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; =20 - err =3D cur_profile->profile_set(cur_profile, i); - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + /* Check that platform supports this profile choice */ + if (!test_bit(i, cur_profile->choices)) + return -EOPNOTSUPP; =20 - mutex_unlock(&profile_lock); - if (err) - return err; + err =3D cur_profile->profile_set(cur_profile, i); + if (err) + return err; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); return count; } =20 --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2066.outbound.protection.outlook.com [40.107.94.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF5EF14EC46; Thu, 31 Oct 2024 04:10:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347845; cv=fail; b=DGUUrb/v/Ei1PhIXuSu38mGKTaIPQOrCIRZTvzcOMJiCasVqpjpsaRr4Jub5u/1l3Rex/5TOz4vpRzaYRgAyjM/xG0dLzAdxEEsorwM1UKqQEQsujiH0Otd9WOmgaByhtKDLig1cPMc4OozKKgKatk4d4u9hpHwMgvvU2YESXO8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347845; c=relaxed/simple; bh=NA85YAzU5HGhnAyOn7Slgl06+COemEDtnALxY7uCu9E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kvSs545s75YOUAKIeJ/l/JTmwsiYYHT4r8tXRuPA24TaUIblkuQPUY2MycZU8Ilwrjfxg6Iqyq1a43G3fEgYIC6Kkh9lh0sAF06+S4nzMrRebd9C3Y4nHpU8MY+R1JsotkYb9nqT7RiyhO+cNqjEuEzShs7ouKOGproT+F0vFA4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=h04SUTy+; arc=fail smtp.client-ip=40.107.94.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="h04SUTy+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TXbbxQGsiFbf37vWu09V0+GYjZzRfr+5DvfTough3JXEVdogudM3dXjDE/HZwKVGz9Dyz29kqMZ1faYs3PY4lKQxYzU0IC3WkFzCk/acJmUHcft4d0BTLlaAfUuZx8dOHJJNXXvQeJGJPdyoboXjsZ7wkwHkaDYJlZeC011FNX5UKDhbdZDUBoL2X6R0k/S3TWB4GV2pY97HtTwB6cpI2weVoCt5ao+++zQipcCM+Ey0yi51U8oDtFJMBub6jkf7QyRFODeZXo2E+HRu1hYOcsr398edJvkJGkBIPelLHV6BratRq0XNgD9WowOB+RTDKmJ0rc4WnYOdQAyVHUyvkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3XyZCGQydisWB0aecSxy6A4iPT3N6k+B+VWHygPISz0=; b=fOf1O5sSaRHoPQ4nCqgVzwC+SgIPrhjuYDaCp/YKO42uKl0Pt9HhSaClC+74SqKWREXxwk+BozD4629iX/Oct0jdItOLlvAgtfw9Txk+z92GyMk1Lmp9ZcQvJ5kRpFldJmS/rWXWOoAnUcneoNgxQxfuHCqhmDshR/oY2U62SBgacZjovwmNcj5t3/jDImK+BirIcdu33fgF8bjyrJIsmbq6V2DuwPM8xNnArXScshZghvi+C+d5EqHg3+X5V/O92PihK0giwWrBQtgkPo2d11J0vMTrAXOWTnMJgJMN5latqa2ype5IUF1hbIVt6oNquJaJoFYGjnFc2qpSwivpVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3XyZCGQydisWB0aecSxy6A4iPT3N6k+B+VWHygPISz0=; b=h04SUTy+VT/blGEvKhtD/cF5tBCBesHMuI4UHd0i0lOgKky8vROuvYm/N12Qec6OklKVLy+VK1C6Uz+FdmY+l6HsZio1uP6Cg3tchbFNI/3RmafE/qkUy6uP628kcipuifFW4PAzYNKEV2BwT3tty9Q4I+pLe22atv4Sv9tt3ik= Received: from PH7P220CA0065.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::22) by LV2PR12MB5728.namprd12.prod.outlook.com (2603:10b6:408:17c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:10:39 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::d0) by PH7P220CA0065.outlook.office365.com (2603:10b6:510:32c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.23 via Frontend Transport; Thu, 31 Oct 2024 04:10:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:38 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:36 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 11/22] ACPI: platform_profile: Use `scoped_cond_guard` for platform_profile_cycle() Date: Wed, 30 Oct 2024 23:09:41 -0500 Message-ID: <20241031040952.109057-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|LV2PR12MB5728:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c031ac0-a45d-4e1c-03c1-08dcf961fa62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?a3u0qQ6d5K0TEI5xulIlGRPm7Lpl7h15YvVYAALDjygJXDnP5Q7bW6zEIGM6?= =?us-ascii?Q?zt9I9qMB3uUhjrp43PKQHuG6mturH7yNHLW05oKHLX0d0xySMAD6qKSEPZrd?= =?us-ascii?Q?oVZI64rT2ELKhXwP50DwqAVgj63N9XBFlt1h5QZ1UUtkkEi8Z/kmA82vzmJW?= =?us-ascii?Q?+AVC7RKAqggRAusmXsct9NdoZku+e99Ssq/nda+dGw58Gn77/2VI5pfhWb5w?= =?us-ascii?Q?lQaPLmGDe8DFHhcwQkmjXpaxs1VAi2FutlTt6x2Z07x3CxdqMUF8KgQRsYSm?= =?us-ascii?Q?jFCI5vYiAWUjeiAxF+kAv5sMc9rStU6oC6Jy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q?HagStAN1UzTad1TJJUoYa3B+XvwhnPsV5CPffj1mIJILKMb9BlSQbIDqywDq?= =?us-ascii?Q?uMsirfwCIP8lVplG9o0MuYGIXeg2bti0hEU0eZtLFLU1JpT6/ObGbpiMrXz0?= =?us-ascii?Q?RYnGeILhHbtuIhhYoAONgH4qWMz3yaIRH3r+S6f+/27CPbdfMFywNDsGW+n5?= =?us-ascii?Q?qb8Cb+5Yzy8XTb9I3S7AlUrAUvMQd51/AeLZSYRQGu0fPuonXw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:38.5920 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c031ac0-a45d-4e1c-03c1-08dcf961fa62 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5728 Content-Type: text/plain; charset="utf-8" Migrate away from using an interruptible mutex to scoped_cond_guard. Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- drivers/acpi/platform_profile.c | 39 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 63a5f5ac33898..2d971dba2d917 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -124,36 +124,27 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; =20 - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; =20 - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + err =3D cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; =20 - err =3D cur_profile->profile_get(cur_profile, &profile); - if (err) { - mutex_unlock(&profile_lock); - return err; - } + next =3D find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + profile + 1); =20 - next =3D find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + if (WARN_ON(next =3D=3D PLATFORM_PROFILE_LAST)) + return -EINVAL; =20 - if (WARN_ON(next =3D=3D PLATFORM_PROFILE_LAST)) { - mutex_unlock(&profile_lock); - return -EINVAL; + err =3D cur_profile->profile_set(cur_profile, next); + if (err) + return err; } =20 - err =3D cur_profile->profile_set(cur_profile, next); - mutex_unlock(&profile_lock); - - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); - - return err; + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); =20 --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2074.outbound.protection.outlook.com [40.107.100.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D528155A53; Thu, 31 Oct 2024 04:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347850; cv=fail; b=tbbHbqc9jyActBBRdxfXHtGa0gRxeX69dMEITNcVghxnb3Sz1hNELuvp7p+ndKehsImFnrcNzlcVUl5gbn4McyTP1q8l/XGLJUhrzoWTVE97v2Y+pYA/K8q0J/aSZckn7vELH2WfM+1QkCiDM2PB4p8aTWip7C99UOnCQQASzdw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347850; c=relaxed/simple; bh=mWOy5GM5UEJggDyZTxNZzpYHTp+vSago3fuXq6E9D30=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HttnirmKDozYR6HIoOgnc1tvwp+Y6gqo9+8CjLcKPwGzPXxKY+irWlVO6phKPtQ0W1jqXkgVr1ALSJDNauwrm8yIzuiCzbtO/d68p3qeQ2oST9qlchhsHcETEByxigssZwcrGC5wWwem21mUer7A+Yv9qnUgWGe1RN1yDOEF9zU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=MzIuSfe5; arc=fail smtp.client-ip=40.107.100.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MzIuSfe5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d6X0UqIj8h7mGae1pK0C79dIxGYt/gyLyFiWDjN8KxjeTkGil2j/UTPgB5aPMUwqZSl+x0FufkwlFeLfpZpWNFmGDnz062gwbvDV6Gw2KwXv3Mk8pqbsjaSjIKMqbk57qftyis2vUvvudj7cFEpWsHpvGwCu8UInbdds/mZCLlQlI/PLEV2KdyyKUtG3a38091UeFVYRrPLv+/rbv10KDFTFmABz+Vt/ON6SDwI1yXMzlVYixLsAHB4YijqQdGaeQsQSaU7SNBMtTgeDUej3qIR4oEFSlQ7BI9myo9jPAbyWvjcHBP+HBH/fyn6SPOPsF8Dxzxtc/FQGbSlyvq997Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kJzYNeaKYSJpkQy8diwOKNYtzHPdojNbidqIUCme8uI=; b=qcj7DGmwTNHB5mmEsihFShcdIaTyIzhz2D8sQ7xxgST7SOcqwiZqJ1LEAVFNOBYHRTzXmf3xBJZBz7UHO7jhs/vekP9ZA8ysmPNOoemj/9DWpdmIZCxB3wImYpFTvPAIgxzLAb09L79rcr3EYIOfjiChnvGDP/ivNXOOHl3hVvHtejDOvNx37WQM1/m8HNYHE5MQPqX/HyH5NyFL4s0XbvT7k/xwI65E/HvtdwjHtOJcKp+7Z9+p2S36K3rl7JG2Qlxj/T3olk5Yn4ffslBtS753FTHTuKmEsnX9MmMaiuB0vzlPc/YBB8B26slR4QnMu7e+1ycBEgVDOPoFwF+S4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kJzYNeaKYSJpkQy8diwOKNYtzHPdojNbidqIUCme8uI=; b=MzIuSfe5+l+6GY3pdpdQE5iPxX4a8ABjm7H0Bs3iEOPN8MHl44izFtB2k1Erw6XmLmGTLLsQdd7sCVzwGL/k2agHfGwEZpuVQ03bbbrkTTrlmYsotT8ShzW1pNc5ki+w2bkoyV2IlyXl5CIO4t8zj3bI//ceeGJXUoFlxIXN45c= Received: from DS7PR03CA0345.namprd03.prod.outlook.com (2603:10b6:8:55::29) by MN2PR12MB4047.namprd12.prod.outlook.com (2603:10b6:208:1de::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:10:42 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:8:55:cafe::c5) by DS7PR03CA0345.outlook.office365.com (2603:10b6:8:55::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Thu, 31 Oct 2024 04:10:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:41 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:38 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 12/22] ACPI: platform_profile: Only remove group when no more handler registered Date: Wed, 30 Oct 2024 23:09:42 -0500 Message-ID: <20241031040952.109057-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC4:EE_|MN2PR12MB4047:EE_ X-MS-Office365-Filtering-Correlation-Id: de47a983-6d2e-42da-ec9b-08dcf961fc22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WzsDlELE6f7TinTUQ7C+SHBpAAs8EPw8dwACqIadmSgWoWhKpuKKi4bpyuiC?= =?us-ascii?Q?Pzl/8x7UA2HeM7fSRbQdCMfoog8H5B2m/aHe7HrOGPO6o+a9SJadNT3HNsxo?= =?us-ascii?Q?DEjMyo/drKvZM4RQkZtNDDInGD+WGnYQxUbMVXvP053eW9J5zlEi6XDH/Jqk?= =?us-ascii?Q?naGGtmx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P+078vZvrGt8qoBCw5g+LtF?= =?us-ascii?Q?LgeB82OpltgXFEYb7IeH9z34mOIx9U8VXbzzJssFMR13r+Tq288tJy/Djeqw?= =?us-ascii?Q?lvKHtYfPDWu4Bi/VSZrJDD4qw7H+tG+pTux2w8ILanUExTcwL7+TFfZ2qM22?= =?us-ascii?Q?EfwXTXgV61DbeqiQDk1awYcI9wq9IieFkRdApYTxf0TywBQudZUutQWSX8JA?= =?us-ascii?Q?SL4ttaswy/a7pwFLzC/uVkOUt3NQLDyH/HKsZIT1gn2kX660JguMo+bpt9Fd?= =?us-ascii?Q?Jp9SOqZvxSwO4ED/32nzgEJcq1DeKOw7o/qhFWiwG7W8OoO3FuGRvrJ7ubw9?= =?us-ascii?Q?UZ8kwtYhJj+C/W8yS4ig+Mb2/WdN8Fr1UfuMVNO8u5XiDQmyAw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:41.5340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de47a983-6d2e-42da-ec9b-08dcf961fc22 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4047 Content-Type: text/plain; charset="utf-8" As multiple handlers may register for ACPI platform profile handler, only remove the sysfs group when the last one unregisters. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 2d971dba2d917..b70ceb11947d0 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -23,6 +23,12 @@ static const char * const profile_names[] =3D { }; static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_PROFILE_LAST); =20 +static bool platform_profile_is_registered(void) +{ + lockdep_assert_held(&profile_lock); + return !list_empty(&platform_profile_handler_list); +} + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -184,8 +190,10 @@ int platform_profile_remove(struct platform_profile_ha= ndler *pprof) =20 list_del(&pprof->list); =20 - sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile =3D NULL; + if (!platform_profile_is_registered()) + sysfs_remove_group(acpi_kobj, &platform_profile_group); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2089.outbound.protection.outlook.com [40.107.244.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6458715443D; Thu, 31 Oct 2024 04:10:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347847; cv=fail; b=N0LGCXAkTF1xSUJyrKJ5sr4IQivk37vrvUb4xDd5Uqp3x+9n4RXApDvx/8nHewy+IU0Mz4eHi4L0cnAeSa1NpKbnkiEyyVMBkHHLhzgSOYe/a5qK3T3Hi810kPM8vuiQMpSbfvIAOeDTJXWfHnU58PydNomEVMiw06DxVTW8IVc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347847; c=relaxed/simple; bh=iKLFe9FucDIr15NkiaQmVgbAANocew65IHkqIEp0gNc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MpHDeuTrrEIbJlOufDflHZyyDzc5c5kq+u+YLP8jLNdOTukcOjBfOx3v/ikuQH7AIYtqJH2zd09zR7rmB6l9yURbmCyb+DcOJulFT8UMSZ8fmqScmhQg6UU7TUFgsO0QhSpopZu13oq9pw8htAJfXVIVw0Ip/zMqxAzMvBezhcM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=AvfRTWAn; arc=fail smtp.client-ip=40.107.244.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AvfRTWAn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KM7siR+jjimwybxdDbq1M5WCs5JVI8APEukNHmWofnUHplnVMPDjfhyFQ5CaklonGUUxxjphd+QUAB7c+jvB5B4LRal0Y30/SxfJq0RkvkqBfkfmI8wFYerBoNKIss/prOwj6+SlAVex3w/du9fZ33v7FQ2AyuDKFBzg8ZbmJtU7UdJNm48QqFsWDNXzb7Xp4YL+qERZsTAtNxtNu0P5FmrdOaIU3z0Gm9buIJJYNoztGScmLzX3OPbiJUGmcQA/6gFiBN+MkIsRqOUWBHHpwcxa4bdns/GcBI3A8NVqBdbx9KGxi7WxRyXS/+LI2sb+3GFI7xen8+O0Ctn8ngrPkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ISN2oysPyjxrEnFD4DuN9L23LJ7f9XkdxpR95o7X1xM=; b=whLmSnGcyYwVogbZLpLbN/MyP7JP/ghhLfTi0QuuUZBzLqWbLbJlyF/dT58AQk6l+ZjxzBBGyi2xL+L9XwC0YO6Hdfy5YE4yxgbibrPgl5qYsZB2gCydpeJwEn+RN7vN2Hrro33Nbvfg3ubHyZ9G8unMKytLgTtPkKQXcaWSPYAcQC1+wLQta6pjn8sHB/YpEuQZTX1ClnbdGLXnWo0It0yybhIgrJ+AcO4M5JwvEH1L1zr/R+kwJ9tYKYRIq4CsLxafEXMEaEz7rt6J2inc0WnpGgP+ZX8xTrjEVDbKgidkh9NmFdPA+4GrydwM8WORWGrgfh3pVJFRahgvqHJDKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ISN2oysPyjxrEnFD4DuN9L23LJ7f9XkdxpR95o7X1xM=; b=AvfRTWAnt7H6VTfMsrBMBJtjXG/LpNLBGOG1XWDbkJRdOJsX2QfQeN1O6+76xBbfr84LK6/DBH1ErZ30Y8wu1OuEWjhZSPXiNiwpebUe4UvKhE9stdBp1cefdUinWxJwFBI1+vCW/VEY4947fFSW2yLQ3KG8sCqfpSKllY/zzcw= Received: from DS7PR03CA0344.namprd03.prod.outlook.com (2603:10b6:8:55::28) by PH7PR12MB9253.namprd12.prod.outlook.com (2603:10b6:510:30d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:10:43 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:8:55:cafe::b1) by DS7PR03CA0344.outlook.office365.com (2603:10b6:8:55::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Thu, 31 Oct 2024 04:10:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:42 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:39 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 13/22] ACPI: platform_profile: Require handlers to support balanced profile Date: Wed, 30 Oct 2024 23:09:43 -0500 Message-ID: <20241031040952.109057-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC4:EE_|PH7PR12MB9253:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d3b3f41-0eb3-47de-d1ea-08dcf961fcc9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?A/1TFd2NHflb2IxWb7X6eZb5HT1hH6TFLCNKhZcme83fy7SxZins6bKuM4iX?= =?us-ascii?Q?h4UGQr9atsp7bi5CSQ2IKSD/fkN4QqWVFaru1Cu+JOleQd727nSCvYK6zH/C?= =?us-ascii?Q?ONEo41AVWPqlhDKgnJXHqZzhCthBUa1VvsvGOR8xXChImwUDcPEj8Jw49Q00?= =?us-ascii?Q?XpXAvTgbckTv/8qEgGGRVm60vK8iRBBlJH0UbYi21HMUUbmpSxT9sS/fMfOP?= =?us-ascii?Q?im97VvE+ShN5ur7FG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ii?Q?TnvMD3BIXAPQOkj/REXH8uEm4gMWtawuy0Hbc5QNY4T5HuepW0+4W5NSy7Zt?= =?us-ascii?Q?pnl7RJ9fAxEBno8WlSitchhpNDDpTwPvv9sHRUwpYFmMgkmmt9IbFTuEIhjE?= =?us-ascii?Q?HBHqb3e60guFyM2787+XgmBEWlYKTsN7ob3Ua+iHJ4YbqXyngVXSf7EpViji?= =?us-ascii?Q?B5JLHxqjxsSvzakzYiiVloMq/Egb1NwVWWxWkloKEa0pWM622yDPwyO/9tDZ?= =?us-ascii?Q?OA0ngqQvl48mvaor48z66wMDIJLxTj4nFUkOfcKleatpz/4+lQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:42.6434 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d3b3f41-0eb3-47de-d1ea-08dcf961fcc9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9253 Content-Type: text/plain; charset="utf-8" As support for multiple simultaneous platform handers is introduced it's important they have at least the balanced profile in common. This will be used as a fallback in case setting the profile across one of t= he handlers happens to fail. Tested-by: Matthew Schwartz Suggested-by: Hans de Goede Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index b70ceb11947d0..57c66d7dbf827 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -164,6 +164,10 @@ int platform_profile_register(struct platform_profile_= handler *pprof) pr_err("platform_profile: handler is invalid\n"); return -EINVAL; } + if (!test_bit(PLATFORM_PROFILE_BALANCED, pprof->choices)) { + pr_err("platform_profile: handler does not support balanced profile\n"); + return -EINVAL; + } if (!pprof->dev) { pr_err("platform_profile: handler device is not set\n"); return -EINVAL; --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2A3413D600; Thu, 31 Oct 2024 04:11:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347878; cv=fail; b=eureNWxfAEFzTxbI8e/7aNBemzV5pAZsyrNnMj6JZwQJPVCVAERdn9224G9aAVL1KrPT6OlQcQGuVzmgA1s2Th7AKKWu0G3vy2vqke9Y7Wda/J+NbwvsoaNlk5/2aEnmgn3uQcGVMtpWwThei5AU7PqZ9OrYq+22EKOkveF8U/M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347878; c=relaxed/simple; bh=aUECkS8rU1nY3fzqvmb1sAn3nx5yAPU6ohrRg++j6KE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RxDp4d7poL7WV69Xu75+rED2CFNkJvD/KQX6kBlAkXsy2Tjauvw3iNvyG4KhjbK+ffTaUVoqFnBo4YV3UUH/NudT+2nZB4JPK1PGxzKr1MzLOr8ZaHfbvqQ7+Ft6McVXqw1Qm3Spi3C5FyZ3RzyT9q+lpKhRihk1QjHiadU6YvA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=IVObesI1; arc=fail smtp.client-ip=40.107.94.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="IVObesI1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qAwqsGxft0ZMVznLkxaW87PcGfi0ZrGfzqZvBpfzn6XgULyfLCm1eZl2FWP0+KITjz0qMwqUF4Jucg3uXg3YxLweSacpY41e+rCEviBU8UTjrJy1M6UU6NefjKqxJE2vA0Q5aghBrU1IsDR+FjM+DhfBVhici0lXRDalpmsFfURY3XAaBV22sFtT7jVbZdi4kGT7rzgg+y2JPoC+KDkWMRkYfeTdD6x/CUhod404fC1g39exwOIAm1tJ3Vtw6DbF74I60sgvtS+zkHpsmKG0AGukuYi7KCJMYH70UybutHHXNVxGgEW2D6UaRslZlMzsNB3mqlqRDhaYUAmmdJy57A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8EzwS4FBEC6WJMYqrXUBj/Gnio3mHsXYP9NCxxfe/YI=; b=nSVYXGaQokQrbBWJQPZPbBouZ2ZhuiYgTqyF40MDBFHs8cuBNEjGiMfzzKwhvkU5Yrd/B11b5nylkBwUm6T5qRKw3EjEVeHtCceGmhP2GfBt/RKldEb4wXM89fMFGOruDeZqAo6oeeLTZGWGgmzlH2TEY/+BV6LBAryo+5JHScW+mTWyRo+ohjOrsMFjXc6NuiUx7h3kwYfE0Sm1Aa19MOOnNA+b3B2RtBayc7e+ZB+dOojUia5nDZ3C7O/9PsH0DQb8GZtQ/dImUmbgZtRitYnPcHvfkAXKSrW0Jp3sxSfBChxYF9w2fgVmJRi4IYRLchzQTVWgLej4IZVqRiL7Yg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8EzwS4FBEC6WJMYqrXUBj/Gnio3mHsXYP9NCxxfe/YI=; b=IVObesI1Gn5zTR1/e+ixQGRb03JyCU37J4bfYlychm0pKGPIU1H18ReD4xaBBKcN+6sXELKdBByixtN2+Trg9iRVRVziXXhyTT9KY44VkybskVCBDGCNZAWAxc8cC6599kBsI2HYOVLFv5D8DL4ECt8kYyeL2PBt5V3/gp2L8Lo= Received: from PH7PR10CA0005.namprd10.prod.outlook.com (2603:10b6:510:23d::11) by SJ2PR12MB9115.namprd12.prod.outlook.com (2603:10b6:a03:55c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.34; Thu, 31 Oct 2024 04:11:14 +0000 Received: from CY4PEPF0000FCC5.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::13) by PH7PR10CA0005.outlook.office365.com (2603:10b6:510:23d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.23 via Frontend Transport; Thu, 31 Oct 2024 04:11:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC5.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:13 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:41 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 14/22] ACPI: platform_profile: Notify change events on register and unregister Date: Wed, 30 Oct 2024 23:09:44 -0500 Message-ID: <20241031040952.109057-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC5:EE_|SJ2PR12MB9115:EE_ X-MS-Office365-Filtering-Correlation-Id: 1acfafae-5512-442e-538d-08dcf9620f76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7iW/Zc6JwduaJx1C+t4CzYq+Qj78edATH94x7irk2Wwr2wG/Ob3rWTUW991W?= =?us-ascii?Q?e4uGHaPx7FSwk49hiEFXtKPZ2F/9a02/FCRwf7pVZk1yMJTwKuJW8I4bywtZ?= =?us-ascii?Q?ZrFf7xW0vJgqBbGoxK2Rd/jQO/GLid7WD3aM41vB5cZmZ1iUxyE+yL3TFRar?= =?us-ascii?Q?Dupk2/ANaGFWF1y/m8nr3QedqZDhnMWzVorRi602SqRszYMTqi7gO5YqizwT?= =?us-ascii?Q?ZgbHc/UHEvXZUjZeYhER24wihhIJw+aTQpRkmBn/39qkuAGvFXhahKLGL6cf?= =?us-ascii?Q?o+5GZR1XzKH7zOxi+nrQCPe0i7eG9WAjpDLI/ktGwXvyDWh9smNPI6q8sggJ?= =?us-ascii?Q?Ky6gqenlmRjGhJXwoG5hpVqafP2wYN6i8Ym0jpMasBiOKg9Q8u/f8o69IVfo?= =?us-ascii?Q?3HT24oTks/SD9+ckcT2goukOZca5VsqJToS58YKnUEzmtKd851nAoIinwtg9?= =?us-ascii?Q?MGDhvod5JXlWlJEwewY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pA?= =?us-ascii?Q?npC5MC4ifdcMkT7qkYKJelIWyeBMlRtPoy4pCnr9AxYZPv/0vw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:13.9573 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1acfafae-5512-442e-538d-08dcf9620f76 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9115 Content-Type: text/plain; charset="utf-8" As multiple platform profile handlers may come and go, send a notification to userspace each time that a platform profile handler is registered or unregistered. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- drivers/acpi/platform_profile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 57c66d7dbf827..7bd32f1e8d834 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -182,6 +182,7 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) if (err) return err; list_add_tail(&pprof->list, &platform_profile_handler_list); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 cur_profile =3D pprof; return 0; @@ -195,6 +196,8 @@ int platform_profile_remove(struct platform_profile_han= dler *pprof) list_del(&pprof->list); =20 cur_profile =3D NULL; + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); if (!platform_profile_is_registered()) sysfs_remove_group(acpi_kobj, &platform_profile_group); =20 --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2052.outbound.protection.outlook.com [40.107.92.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4626126BF2; Thu, 31 Oct 2024 04:11:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347880; cv=fail; b=Lj5C4NUy7WHItLsBfoMmztxZ2NXke5Kz81wUJPNPG1R2jAFNms1w2HVwKoPKGZvIDDsds57B/3Ump+ahF1jvAOeb1Y8uU8hNayk8xsPT8AIu9SDvDacCmI8uZ4Uej3jayBBhOFQchTZg8jQuZ/Gmd1eGSg8NXSvaJntfeJGr4Pg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347880; c=relaxed/simple; bh=OtCtHlpL5bk4vLAegdwWm3/Ky92bzSLwgrPBZOPM1rA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E/o0Yh62SB7uZfzZHYOGPOM40pPDzNDRYjEXOvPjBwpxx+g08Kl56+QIdGFiAnY58N8rWnhrM2qySmVNskhHaHtAF64uk5bFy0bfohoaP51ZxrClsbxmvLOa8yaFqEfqzAeMPSBXRaf4OqWEqYuDILIQi0wcI4vGXIpAEGWjC4I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=5KLz9Udy; arc=fail smtp.client-ip=40.107.92.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="5KLz9Udy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xrN0/Oz5XSxP0sR21Bp8KQAf6vKol6rXibbowHQ/mjHg+2M7dqCdR6Py0denpYSuYQQB5pz6yEG9YUm5D7/YSl7VUY1/pwQo6bJJ7Eju5VvQfDC26KVVZ5cAvgCSdRQZJgK0xUiSZx7AyMGzaQ3rHBTiMY5X6DSG5jleknxih3Aq1HlKToJuxsz9VtW3Ken6UGCuVFSv0AOhXuTR3u7mbEXzeeyBtFi7pn3BX7g41dEiWSx+zZ31WbRwlsZ9Wqit834aiYzGzIodg6R59/0kWfOP5tiXEBTIohH0UiEQjDFzHCkuCKqkk+YGr/+CjW2mz3Ez58Nf+fHuNdAsvrDGKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GTMgLG4xbIsY9gFb29ycOBwD5iLmIPptvlydkm4UJuM=; b=KWiAQGtVj2s1lxGN/r2e6w8Ch9o01W8ZHV23kLGFcXpe3YWGE69D08XuiIULSfV1TL0ZVMxD/nNXALqOKUBF2pUSficjSH2KNTS5NogfTD6EPl709AEaIShTa7SOj77Bu6x5ZN8QSaBbOiHLvrt5iiCBnTM64KAJbGys/D23PaRV+mwtOLXOcz7srTVIa+yZqB3R1LSy8hiPpQD/xXtB8D2kl33Wt2QQXnXMK7xg2Ri+n5C544oDlRtIdoXGjgHwSYKkf+i9miFuzI434JohfPG6IAp5ya1IxfaFcEIuL84kywXSVbWwxN/ZwaFbJ32EsRrfe+opg82kY7/Qf6t1zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GTMgLG4xbIsY9gFb29ycOBwD5iLmIPptvlydkm4UJuM=; b=5KLz9UdyVZH8KcqD4FMIea1rR1advafVoeDMWD5V5CsFKJmCXN4InDiYgHrGBQ6+/9BR4QF731jejIJJ7iBs+dhsy71p9pnFhBoRV2w16HcHELirkZzWMLqFTfyYpD3dQfSJNEMos4/4X27J5iHfBbFoHPriNIiH3xy32wZJW48= Received: from PH7PR10CA0007.namprd10.prod.outlook.com (2603:10b6:510:23d::7) by SN7PR12MB7854.namprd12.prod.outlook.com (2603:10b6:806:32b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Thu, 31 Oct 2024 04:11:15 +0000 Received: from CY4PEPF0000FCC5.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::ff) by PH7PR10CA0007.outlook.office365.com (2603:10b6:510:23d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:11:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC5.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:14 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:13 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 15/22] ACPI: platform_profile: Only show profiles common for all handlers Date: Wed, 30 Oct 2024 23:09:45 -0500 Message-ID: <20241031040952.109057-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC5:EE_|SN7PR12MB7854:EE_ X-MS-Office365-Filtering-Correlation-Id: bad308c9-efbb-4e67-c297-08dcf9621007 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|376014|36860700013|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0htAXIwqA//U5U8PKOmOfACotYNVuT/ckP7MsWqy/e3f3fkCCmApYlFpqtHP?= =?us-ascii?Q?vvjfTEa2GIhafbp1Oq7mA5aRJj7br+hqtPJZKT9ZIomFDKWNnEugDOPWEbEN?= =?us-ascii?Q?KzJjt9+D03rQyhNzZ1JzfxvYxbtcX4bP6aVrm0dU50TaJQNnZAbOA5SD9SNn?= =?us-ascii?Q?NJWmMqja/yp1sItJyHghqa+a73ytXy39ZMIcobB9/EF9v0Z3s1uh1KeMHR23?= =?us-ascii?Q?jliEGmUKcYfLyycvVR+UBsJGR1qy2ptciY3+sDNa44g2MQOchkYRNtXOjHPr?= =?us-ascii?Q?Tj8cpoNB2vgrUxxlfqhw2QneMy29SM3sBzLAqHuYxhA/2ldJQBZxZHr5tfls?= =?us-ascii?Q?Y/AdHmI9IFQ9RC79OqOd6IEDr9ewOLPFx9yvApL8PAZUvH4pm8ADpxrNL9Mo?= =?us-ascii?Q?Ybu7FCzfrHq1bdVU/Gjg3k9aKUuHZu8RQLyqUpM228hWQJRArwEHPQaoMUw7?= =?us-ascii?Q?gSG18pGBZZ9ZNWU/iM2aFHiH3KxUnbw2danbMSba+wahMTd0AZNawmtqQw3y?= =?us-ascii?Q?NDUVxIPfbvDaesB4CyhtNy1IFtiAotBjVxV91ohLW83xsZERXIO02fZSdnvs?= =?us-ascii?Q?5NesWf2aQrHj9XoC9z3QiJXVrKAm+r7wg8BAZIl8NZlk2KFscS+3gseeh1ez?= =?us-ascii?Q?zNLTx1QVw1lVDTEOkFbpf6KEPxGApwE9g3zvAKcKeil6U71EVru/G1SgLD4e?= =?us-ascii?Q?yP25J1nZnCBSnEjogCudNgSImbgTprHlJBFW/ceNA+IDYqjM2H7F7K1Tpj3m?= =?us-ascii?Q?+l3zRQP/5JLNRtHhmDOO7LcEldESk7McCU4Q7mznvAeI/j//fLwx17auEAT3?= =?us-ascii?Q?VJx3vMnTduRuBiQ53PLNaSgPoEPol7UJU28NUyOGBrbQuMlIM7pIDThRmSNo?= =?us-ascii?Q?V15rgehSNUM8iiO4VMq2vr3HFqarmlNCDB43KSQ5sE9ovYj6Q8xAqodngN9Q?= =?us-ascii?Q?Cu2PT0PA8/mWbGMbeMZg0ktjo1Ztq8i3aUy/s0+wzeZsmqR6G2VNEf8CewBp?= =?us-ascii?Q?J/n72TpHL4Uh/xmnnvfwRu70ouqG1dIXs6FCo+h4Ar8EdAABV4QmrmdAbtra?= =?us-ascii?Q?2AbKfKHZVuSovDg0cNYt9rJcSFxM3NYAUEYapERmLs+bM7Zx2u8ElxpSW8vo?= =?us-ascii?Q?3zeag06qaehqW3F/dOAyXRSMBCTzo6Hee9kLGo7s4ioiwtPtHsP/quEg+xik?= =?us-ascii?Q?l15JoYLdg6OqC+R3Dam38u3EFpWcwncIBlh+paL5ak73BiSG+oC8Auj+F8un?= =?us-ascii?Q?K8IJCtEi39k8zT+PePowUuzP6r1YT+uCsr5jt/uZbJ9v82Rzp4szH6AiO5V0?= =?us-ascii?Q?gRBbzxi7on8guQdxcYA/huSum3Vhd4mc4oWJh7yoN4PO+dIor820az3mWX5+?= =?us-ascii?Q?0m1V6LehwYOh4lzKk5hycRoCLVrR+hIWw7sEOZjBh8n2qs7VBQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:14.9104 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bad308c9-efbb-4e67-c297-08dcf9621007 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7854 Content-Type: text/plain; charset="utf-8" If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 38 +++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 7bd32f1e8d834..90cbc0de4d5bc 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -29,23 +29,43 @@ static bool platform_profile_is_registered(void) return !list_empty(&platform_profile_handler_list); } =20 +static unsigned long platform_profile_get_choices(void) +{ + struct platform_profile_handler *handler; + unsigned long aggregate =3D 0; + int i; + + lockdep_assert_held(&profile_lock); + list_for_each_entry(handler, &platform_profile_handler_list, list) { + unsigned long individual =3D 0; + + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST) + individual |=3D BIT(i); + if (!aggregate) + aggregate =3D individual; + else + aggregate &=3D individual; + } + + return aggregate; +} + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) { + unsigned long choices; int len =3D 0; int i; =20 - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) + choices =3D platform_profile_get_choices(); =20 - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len =3D=3D 0) - len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); - } + for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) { + if (len =3D=3D 0) + len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); } len +=3D sysfs_emit_at(buf, len, "\n"); =20 --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2048.outbound.protection.outlook.com [40.107.96.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DD191428E3; Thu, 31 Oct 2024 04:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347883; cv=fail; b=CAIPn84+oBa1qgXU3J5R7o8cDEmtjF7RxdnvOJezbzsyIEy/BJXlGdJ0yrH5C5qFIZcyp0sHVzx5Nsx4mQaMNF13r33Fhy5lX25DukkC4tFeVfzXu6g6rvO9dV4Ni6IHlx6xXpN5jMf/XxQ7ammD8I8feYf6Y0Jr7LQr6WYycTU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347883; c=relaxed/simple; bh=qrb4y8DNgSCrDBbHhO0W2f8rcPdti6swkaWXkEoVYR8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VwNVIQr9MyVd2/+YYY5x8RUuVQHx6imDVJbwogS6DFyaitM7GydHs8gJfpn5T6SG+AoG+roURJzbKnz9CL406pr9jrX6w9x2x64tl/UTNTvZHnxnZTJ5EfNRgcLzBvsqDjLHZLx9XxSbUga78k8GScQO6okyMK4F1d81dlbZ/A0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Wt4Hl+5S; arc=fail smtp.client-ip=40.107.96.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Wt4Hl+5S" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xfQUiQcrQwbEFddmke7tX/PYCu4uSo7pQq0YTqJmY6MqKWDeFLIhSLa5oWirBzz2htB5nrnXoeK9JVkFQyGcQX4beJG0d/Yru2H0HnIYvJ12Ydisy9I72koXeDylQ8paJwZywOiyyhik6KJxz2nXxFsAS0UCJisFCzzfc+R7fxfyPU5NfzXG8pGSGGO+23fYqvHsRzdoAzBNl2I0r4UIcbIpMvgrbadQ/q6ARsBnHkZXpQvCj68jpWgR6Dh8bUOdndSPhnE5dSQ4A3vwZ+YG0IDjZCIhbUsUBz9CAMq7wC1H4lryB7i/XjKGXD2uzjLn1gD8Tqc+V7Zi3xIt3RVYrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xZRw0PnuGSquX6w1fAZagDnZwh1ox+3Ian7/NRON/FU=; b=BQZzFcKIwo9fU0jgbKL/yHtPkAtop+lBbf5wi8OPPU7UlKqh3JPtape0yjZV0T8Ul+y/qb7f3W/QlRYQO+GrlvGEWtn1PZV0QT6xSuCHJQArwg/+FeyBhWG/SaPlON49Uhalg2uX7fDDJnVPS5uQRqWSFvKlTJh8iNy3QcvlAt3UthV//or5sD77dxsv7xN+mMqM4EZZJSU6/1b1370Y+FVTQ8PZ11nlYGa9I4spckruNfrs4fWeMn+WpZhio+94xWPEdKknYJaZp1HAidalcD/YeNznumSvTqHLpMZMeTt+J1o+M2JwZw/7JvTcKxvjRLpwmKjRnYRWuYw2TMczpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xZRw0PnuGSquX6w1fAZagDnZwh1ox+3Ian7/NRON/FU=; b=Wt4Hl+5SEQUqrz2fQb4kj7usagNfB9AdefWIInI4w017FuX3p2//ZVgf2IaJSqc1Xr2i/B+9l0Wz6k+k0sRQAC5XSYoW3HfWpGNbb25BRbBDV6JCqZXTP9ugl/3sCnfnCNYWKMlsVS7sypVzUP+0JFWY4BcuaPjf8w/INd8lLQg= Received: from DS7PR03CA0354.namprd03.prod.outlook.com (2603:10b6:8:55::12) by SJ1PR12MB6147.namprd12.prod.outlook.com (2603:10b6:a03:45a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:11:17 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:8:55:cafe::c9) by DS7PR03CA0354.outlook.office365.com (2603:10b6:8:55::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Thu, 31 Oct 2024 04:11:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:17 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:14 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 16/22] ACPI: platform_profile: Set profile for all registered handlers Date: Wed, 30 Oct 2024 23:09:46 -0500 Message-ID: <20241031040952.109057-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC4:EE_|SJ1PR12MB6147:EE_ X-MS-Office365-Filtering-Correlation-Id: 057f5614-3275-4f45-3ce5-08dcf962114e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5liTDJdmhzzYsbqhI+MUeBuYt2ZVHrk3wB2+yGRmZNJ7SdQ3bsvDRBzodW9i?= =?us-ascii?Q?0oC+1UuKH9+Vr6QIIHXK3xlat+2HDzHHmALi9lRT/d8zzpHaBqvXETI6ZIzf?= =?us-ascii?Q?S64alTDHr5yd0oLftcgaZWb0ETksorSWtinvoj2F5mJmfaUSFQC//BPRGhlZ?= =?us-ascii?Q?YAdrgdONnXxkjCnAfuEH3jCSfjxy24YRdpqPky7tBA7WRVhliJRL8z1y7nTP?= =?us-ascii?Q?RjBbKf03rn4+UJXdT5UIt+fnqY9k2RALvzIAzxaF0cbn8xQgaPcTcQZ4pa3y?= =?us-ascii?Q?foIL4jf9eu45v3oQYjPiRgCUdw4cLbxJJSArmWvX9cjxvJjzImQXBEc27FSd?= =?us-ascii?Q?XyX9tugFYUppEwd5p8KMBdYuUDIVuFwNP1yteMUvbeCiu/FmD5E3kZXiL/wk?= =?us-ascii?Q?k0zNvTq3ES752kEGwXI4QrOzup7vzBlUO1o9iTVxUFmf+YReh2ZKT8QCHQEX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LSdazAX5eWCJNX/fDoSrs1cvgk?= =?us-ascii?Q?kEGCz49LJb0CK7ZRb8vUXOI3m7IY1HXzeA5EO/yF33lOIGHK8A=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(1800799024)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:17.0656 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 057f5614-3275-4f45-3ce5-08dcf962114e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6147 Content-Type: text/plain; charset="utf-8" If multiple platform profile handlers have been registered then when setting a profile verify that all profile handlers support the requested profile and set it to each handler. If this fails for any given handler, revert all profile handlers back to balanced and log an error into the kernel ring buffer. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 90cbc0de4d5bc..c2bb325ba531c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -99,6 +99,8 @@ static ssize_t platform_profile_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct platform_profile_handler *handler; + unsigned long choices; int err, i; =20 /* Scan for a matching profile */ @@ -107,16 +109,29 @@ static ssize_t platform_profile_store(struct device *= dev, return -EINVAL; =20 scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) + if (!platform_profile_is_registered()) return -ENODEV; =20 - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) + /* Check that all handlers support this profile choice */ + choices =3D platform_profile_get_choices(); + if (!test_bit(i, &choices)) return -EOPNOTSUPP; =20 - err =3D cur_profile->profile_set(cur_profile, i); - if (err) + list_for_each_entry(handler, &platform_profile_handler_list, list) { + err =3D handler->profile_set(handler, i); + if (err) { + pr_err("Failed to set profile for handler %s\n", handler->name); + break; + } + } + if (err) { + list_for_each_entry_continue_reverse(handler, &platform_profile_handler= _list, list) { + if (handler->profile_set(handler, PLATFORM_PROFILE_BALANCED)) + pr_err("Failed to revert profile for handler %s\n", + handler->name); + } return err; + } } =20 sysfs_notify(acpi_kobj, NULL, "platform_profile"); --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2086.outbound.protection.outlook.com [40.107.243.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FDD413E03A; Thu, 31 Oct 2024 04:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347882; cv=fail; b=HixHh113DsFrptCPOU3zZb4BsMbN6yu9FRYWZUraer/sDYFXtCMx/4fufGF67DQ9UjIkxzwmbKUK5jss9bRswGrWrLreYt7uURUNT656emPq9hZJKTxh6Cc/2MHlAvSWYWiiktOrywKmTGp3HvwqMtouS3bHWxEFFfurXlNAotM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347882; c=relaxed/simple; bh=FGMZ2R/7poj/mINnOz6nbRH87uy6ciuIa8LOGQcLobs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bn672iiOd4LY6BoS35UvkkfU3/hwoaAf8fu2CT4VpUgjKQ0YERGZftGLLW9SjFoThqb2Aw3th5AD+MkIr/+lBQvEZ0mrhsn0lEahLGuxblVxsMe5VhSMncTZdlO/04pZ7hye+sRAQN5jWpttQWXABpq65xIOaqxE/n4l8tt2AAA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=ev1oKIih; arc=fail smtp.client-ip=40.107.243.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="ev1oKIih" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T2cAkzE7VP7OwFCw8cUBLDx1LqCqMqxvq9q69yq/7deHpHaaLYSmXGB4NA36rprkBXDeYVxtgkdlMRRkbKXgxpuuUYnlb8KKxhxdSq+rA2R7dj64MTouwxNVH1dRMOiHOgfdZ+N6MS6k9pfpRQQkpQe80Q86GIAg8zwdP1A6BqG1/5LTX45OnPG+5Ao0r1OlHiMDYbIH+otbafXxybHKUOPG/ZhBADYA1d2mmJAMpPduuHBRtEcZrBMCa0zCA6XWXrxq6pnEqwELix05F/ldDYsv7wZtbl9zaO5Kuw2R3gLaVPfIBzCX2n2l735oGph6MMPPPxEiorYpWRAcUFO0Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KqhdUL5T+XIdKvYZ5ARQFgfkK5iJmpT73Z6Z8A1LXxY=; b=rmCkR+z9hy56W96XOla2GrGU77KCGahX3pyeAnLMv92fp89UgUYzPOkh5I/ZpDZM3Vd19i+WkfQYs3tbBst4vjh+dvd1yqT6IckFDINIeic5ldyVdQ6YT1YGXuGu4JgoRaVagKS/FnPN1M5yH9CgFIRvPa2m2LRYBte3SrhY8U5sH/6Bzno0LP+TuDDnLA/mOadnQ59k+fj2skId8f6Eu3098v1n9Q539GZG/qCv3fG/p+4JFDoPmrRrvntEAiJS09mrzkrTBa1zogc4S8+IC8L5Ap0iqfNwQqIA1hB/Lu+YzHMPX6gnMnI4CzZT+geYOScq5S65u+weE8OXNx814w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KqhdUL5T+XIdKvYZ5ARQFgfkK5iJmpT73Z6Z8A1LXxY=; b=ev1oKIihS+4hFOkSw4f1ccWjxXD2E8uHpB6vgSaGTTtLG0IAOv7Y+Fe+tGWy8/QSTq3ChkVdawHifVsOn+aPXZyDNisG8t2WJO0g7RtdL6QWta6Q5r6werG7es8P+8Ncv5emufoRZfYX1MpF/Il0Vmv0q3B+TYMvpaL9TSbl/Jk= Received: from DS7PR03CA0344.namprd03.prod.outlook.com (2603:10b6:8:55::28) by DM4PR12MB5938.namprd12.prod.outlook.com (2603:10b6:8:69::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:11:18 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:8:55:cafe::ff) by DS7PR03CA0344.outlook.office365.com (2603:10b6:8:55::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Thu, 31 Oct 2024 04:11:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:18 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:16 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 17/22] ACPI: platform_profile: Add concept of a "custom" profile Date: Wed, 30 Oct 2024 23:09:47 -0500 Message-ID: <20241031040952.109057-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC4:EE_|DM4PR12MB5938:EE_ X-MS-Office365-Filtering-Correlation-Id: 197942c1-f4c6-43a7-5d60-08dcf96211f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?SIWPB7jZfpQ1t874sjVzkzvDIRr5A3PDvrRxZnx2rwhdExWCxmH/iSxnJg1O?= =?us-ascii?Q?t01CKPtDUVAKeqdpc/Rx/X4ZIDjLTDh2ZDMBpHmun2fAYKhKb5xhUZrRcErC?= =?us-ascii?Q?VlspuPc/VEghEQlHPgdbX631fI7I4rINhJCfPHp5L6/jejobRwfAdHb9IeuS?= =?us-ascii?Q?nqEoMjKLi4//yrXhxzE6Od5iR/3kZqTJho67ZWQKK9lj6128n6JBzRjie9x9?= =?us-ascii?Q?aDmQaDdSGmc/mUlefeEQZ7G5VmteZBuDKU/7y3gyg7bOEGDHU2czuKIr06cp?= =?us-ascii?Q?wVyaynWkyfXowV3jDtLzXK7G0tFwgf7vtsLHsuw0vQEl8jZyFHCll47U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5MffOker6Sa5LYyBRx+TmfBROleCOp6q/AFu?= =?us-ascii?Q?VItvc985zOO0Gp47q4qOBRsxXDCPZPm+gIwxz502GXbtHCYEGgccUk7iaMMy?= =?us-ascii?Q?GDBLS12JiEiK5+vdu7a3BPnrUKGpvHvPqAwkfAU6wZro4B3qMUAW+5O9CufK?= =?us-ascii?Q?zR+D0LvmrWok24kDn9zgFxK1urUmGEcfPGeQ+LlbI8EIQRpdaQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:18.1125 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 197942c1-f4c6-43a7-5d60-08dcf96211f0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5938 Content-Type: text/plain; charset="utf-8" When two profile handlers don't agree on the current profile it's ambiguous what to show to the legacy sysfs interface. Add a "custom" profile string that userspace will be able to distinguish this situation when using the legacy sysfs interface. Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- drivers/acpi/platform_profile.c | 1 + include/linux/platform_profile.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index c2bb325ba531c..3128bd16615b6 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -20,6 +20,7 @@ static const char * const profile_names[] =3D { [PLATFORM_PROFILE_BALANCED] =3D "balanced", [PLATFORM_PROFILE_BALANCED_PERFORMANCE] =3D "balanced-performance", [PLATFORM_PROFILE_PERFORMANCE] =3D "performance", + [PLATFORM_PROFILE_CUSTOM] =3D "custom", }; static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_PROFILE_LAST); =20 diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index 6aad98f4abaf4..da009c8a402c9 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -23,6 +23,7 @@ enum platform_profile_option { PLATFORM_PROFILE_BALANCED, PLATFORM_PROFILE_BALANCED_PERFORMANCE, PLATFORM_PROFILE_PERFORMANCE, + PLATFORM_PROFILE_CUSTOM, PLATFORM_PROFILE_LAST, /*must always be last */ }; =20 --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2074.outbound.protection.outlook.com [40.107.237.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 155891465B4; Thu, 31 Oct 2024 04:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347891; cv=fail; b=RKDtR71MRKWj9vdoid5lKtUC5RCG3WiVzK6aTbfXn02JeTDq3ol89FMNQf79Epj0QmDjBkx6HXA1WmtA2lcIMJftmSaU5/FEQ6ZAixG9/FgBDMI8CjGLbl1qEKNIaxTPgSbJP8kNfjizWSeXikJBVjMEexNOx+HmXLKUFiPRoac= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347891; c=relaxed/simple; bh=6UK4KPOkTBXgHgJ757at4Kltmdl+cBgVmhDqbaSTfAA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kbsCvE15b/8mzr8NIl6mOHYhmBGXaiPRIe1QdKKuls0IU6o595YiCq6fopxGtDZgX/ivUk5YoE6b12YTpDQfVhS+fGC+gLm+tZAO9rIz7Rk7HfO6aLRoXw5UTNDK68BjvFRxNYj5IKUDSfiujc5mN+QSIPz5UoMeSTu9/str2SI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=VJw4xBId; arc=fail smtp.client-ip=40.107.237.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="VJw4xBId" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SIXEVH5xQ7CSs0V5Du2JP4uhbWWEuOEZaWEAOYEG4/+qhb0GKoEsfpOJlFSvQ8OTE14JZH+aEM3FMxdZmUnHzMJ4t5ojAXKJ/BjpDzzdpOK3K141/TXV2155DdGTpMs/IDuUb21qPYxcDCpWAXphlwGAO8+zeXaDpABLm27AKYd1QRBscgVv9NR46kNHAlL1Q8Al9EEaTzJ8cCI/NPFEpaiHTXRODBiNfCLT2V2Q5belW6xcR+hTTq/57Ng1rrsgGCNe/uThu4YvYRH7gfG04maauyppEl1czxsJdWVV8dZH87xgXMhzCWT/aEPXrxvyqpMxkmveLd7GYaknemxffg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tym0pi3XMzZvhS+YgNcghEe1i0+BdOuSCGVmlPuXgk4=; b=VLexYoeq50g6vU3QhgcNSifhvuSIJGIjXfcFfS2SE17714BqzUKD+6bbeYO7dZNeKeSXFundm5Yo1vJB8fA9MclZebqN0OVQb1gtfUt5waZpComDsfIKcMXzN4+ud358/DKrOCcuzi0mTy2lmrJFC0CdXlgdlkI9P7eoLu3Oi2EiWQlN81YwQTBBbbw8/+ulUPMhGOFrlPK4doLbbK1KV5CjmsL2EJjr612FG6NjF5Dv8PU+g+X8Fg66i0g7GthfUtxqCCr+fNh3rVNwVx8ql0Xj6otZE9Rgdu3lZmKFbhfUiVzQerNURGHgr+ADe9uEScNcT02DhhPOcnI0eXEhyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tym0pi3XMzZvhS+YgNcghEe1i0+BdOuSCGVmlPuXgk4=; b=VJw4xBIdpdZ4H61SJ64dpUAkNaejERKl5NskEEzo5WbGhI2FdMkuOm4+Fgyes5svRG/KCLUuBI610gGgjwmkRPyQJ47QgK1HTkeFNpSnSFsI4g2M9YsONFAA2xb1o0KzI1yds2cgqVIQT2gs5eK/ExzFwWXcSTRn7fLEQZa9Pw0= Received: from PH0PR07CA0047.namprd07.prod.outlook.com (2603:10b6:510:e::22) by MW4PR12MB6826.namprd12.prod.outlook.com (2603:10b6:303:20c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.27; Thu, 31 Oct 2024 04:11:24 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::3b) by PH0PR07CA0047.outlook.office365.com (2603:10b6:510:e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:11:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:23 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:17 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 18/22] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Wed, 30 Oct 2024 23:09:48 -0500 Message-ID: <20241031040952.109057-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBE:EE_|MW4PR12MB6826:EE_ X-MS-Office365-Filtering-Correlation-Id: 05034412-6068-40d1-f1cb-08dcf962154e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lhQ9T9EzHilgkvtcFne34U90eEKTfK8DAI280sPo+ARnFFMRFTOdoRqAyo5F?= =?us-ascii?Q?JRmNXzOn72qS/8m7oUtIl1VOWqcFfiferIhIKBNxHxPwnaNy+TR1ttDtfrNx?= =?us-ascii?Q?ALqpogz31PEGUSBNZ9fpMrUlAWdJdBenL9AwkuD+4QM22p3v3EYjAh/lDXHr?= =?us-ascii?Q?Ez5oykXN04IeVjCBPbPE2jBdUUlybFRdmFeXE55QNBdLR8IryVw7YbArrIKs?= =?us-ascii?Q?7BA5FqvboTXeAKb3pd3rf4xXJWfxzEVL7p1vlKVlFPCFKiy1NJfebh59n3/r?= =?us-ascii?Q?kDqtuadDS/6ovTN0a1ptDy0KHi7BXz0GHyXeJajUnh5lME8BAplcrM2CEiVz?= =?us-ascii?Q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2hX3kXyiMD6EKD?= =?us-ascii?Q?0yPoPsmC9fzF8YsDMl2EU5HehAkKSBvv5gYcYzmv+gDz0t+8CSIbCsYBJ5VJ?= =?us-ascii?Q?ZjFO6coq/zzIUgzIo/JAgUnCxVc918wixGPLdEYnBII7n0B9cpUMwD15kDx7?= =?us-ascii?Q?jwufmJhWby/PP5JLfnS4q+wp6gXkeRIMm6ho2MRNCL1Z/Q8TXA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:23.3124 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05034412-6068-40d1-f1cb-08dcf962154e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6826 Content-Type: text/plain; charset="utf-8" If for any reason multiple profile handlers don't agree on the profile report the custom profile to userspace. Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- drivers/acpi/platform_profile.c | 39 +++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 3128bd16615b6..5baac1f9a9c0e 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -51,6 +51,36 @@ static unsigned long platform_profile_get_choices(void) return aggregate; } =20 +static int platform_profile_get_active(enum platform_profile_option *profi= le) +{ + struct platform_profile_handler *handler; + enum platform_profile_option active =3D PLATFORM_PROFILE_LAST; + enum platform_profile_option val; + int err; + + lockdep_assert_held(&profile_lock); + list_for_each_entry(handler, &platform_profile_handler_list, list) { + err =3D handler->profile_get(handler, &val); + if (err) { + pr_err("Failed to get profile for handler %s\n", handler->name); + return err; + } + + if (WARN_ON(val >=3D PLATFORM_PROFILE_LAST)) + return -EINVAL; + + if (active !=3D val && active !=3D PLATFORM_PROFILE_LAST) { + *profile =3D PLATFORM_PROFILE_CUSTOM; + return 0; + } + active =3D val; + } + + *profile =3D active; + + return 0; +} + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -81,18 +111,13 @@ static ssize_t platform_profile_show(struct device *de= v, int err; =20 scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) + if (!platform_profile_is_registered()) return -ENODEV; - - err =3D cur_profile->profile_get(cur_profile, &profile); + err =3D platform_profile_get_active(&profile); if (err) return err; } =20 - /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >=3D ARRAY_SIZE(profile_names)))) - return -EIO; - return sysfs_emit(buf, "%s\n", profile_names[profile]); } =20 --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2059.outbound.protection.outlook.com [40.107.212.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C223513B2B4; Thu, 31 Oct 2024 04:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347891; cv=fail; b=ffjS2nycfOg4wwmeZ/zG4ifmJT19KGM+q+3lvsn/rkBMAab0RFS5li2UTa2DflWmcDGj0g/gJ5XQ7EE1ANGKO0YsLPsAj6b+W/LCGYs5Fr0bILh71Qr7eYWiWJfKDcBo2If1zQjJbdNW2k0OIXnVMS3P+jSvsKG9ylMopHz1W7A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347891; c=relaxed/simple; bh=OYjck0t5lChXtVOi739FYh2KJY2cGMLR7AjODyNcx9U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QnvWLrpdqH/DtUUulIKvOGugftTt8bG9J04Pu+/zOAzMZGTGwwBkA76qg8Rc+alxYnj6+6YkOXVHhuF1RHPUHz4quZcWEje6FGfnTpQcKuG2fhrfVaDrGljI6UMt0g65I/ikcboGwfXLChy9cTqZQc+jCf9e7mhQGEqBB0WXH1E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=fXNUWLTG; arc=fail smtp.client-ip=40.107.212.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="fXNUWLTG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x4TJ7N+H5Db0SZQnQ7Un9YMq1rARJtv299QC3+sbN6oQWI7hovboKbqXjaGKM6g/eKMFDr2qMx+X/BBVI37W5tNf+nMgrYa+/5k6KzsWXgikrCRAJs57QO2m4j/2N4SCKDxrIl4McY9g2r0uQDJ4NLbhqxkjXNtEn2vvb3WkMGbe2KpX9GJlhSI7p1kV2Opso2Gp2verXtjP8MtT3PMbFsSq201ef3OQjrewS5uaqyZ66pGONGBT7/IgJbyx1njlEnkX5ERzgCY0jYrEu6FZKkIaHExumycrXjjjoTRxi56n9vp8hqfJywXPGZfCRtYim8d6cI2pkloCfaouhslYrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1BHOmBpCMLd2UWhz8UzPz+xuXGm5140wW5a7FSkKKrk=; b=QMvCMgnxxsSPZ/51IUsp+xWtJjrgbaVXKIZ/StQJvVva2hHn7tcsRHK7BUFNWC73JGqVbZvmn4QqZiLKWf8UHyOm2EuS+jFcp+vz1bRvpUIVii8iw2Hc1nGQM00NoNFAscM9NlcPvEYeuYI+zI/02+hbiFYCwTzvKyiH+EsSHM4a8m793GSHCY/VDKtFhg1peiqbB3H/vhjDmTNE4nlN/ucGhM/yYR9y1iEMNNpYn5hIX8Lgxrqn7psZl0qUsyga/eZiq/iPzEC83dFhRePQ0Vcs6b/j4HiwpF1HzY6xB8STs41glbwxedKPUrNnXKgSw7ftrTRonlf7d4igR74eqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1BHOmBpCMLd2UWhz8UzPz+xuXGm5140wW5a7FSkKKrk=; b=fXNUWLTGYpHTXAz1bs6gnYa3h+OBwuuUUiNTwewmoxPOBspDXvfeaEGcMcG7CeOY7j8yIpagWXegnRJxWhGrj5dYIKgWBZeakDvimTyYqdrNp8LNkNVAjT855J3Y465ZLdCXAzbDLzWWa0Zz95trpixuTwj7+rknhaid6slxOx0= Received: from PH0PR07CA0058.namprd07.prod.outlook.com (2603:10b6:510:e::33) by DS7PR12MB6069.namprd12.prod.outlook.com (2603:10b6:8:9f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:11:25 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::fd) by PH0PR07CA0058.outlook.office365.com (2603:10b6:510:e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.31 via Frontend Transport; Thu, 31 Oct 2024 04:11:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:24 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:19 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 19/22] ACPI: platform_profile: Check all profile handler to calculate next Date: Wed, 30 Oct 2024 23:09:49 -0500 Message-ID: <20241031040952.109057-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBE:EE_|DS7PR12MB6069:EE_ X-MS-Office365-Filtering-Correlation-Id: 692e7e49-a65d-4145-83ed-08dcf9621644 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?anXxWTWYt72qvS/TR24MBR1AC+R5j/ILRfuCty15EAXxU3wUBrJfkaW7osTk?= =?us-ascii?Q?GJAU85bNMp6zIfheS8hI1IFm5FWbd/4pYsmYLlUX30QyLCHCWHVVLPNVRgZ5?= =?us-ascii?Q?BlCqQPTTxWd919+PgQFElSRuDK2U3nuGeuJq01jsqMdmedLrFjPXsJoqdh8X?= =?us-ascii?Q?MU4s+UHxpqxjfWmPViR6U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ZTUF6?= =?us-ascii?Q?WDEolyjNxnKbGztpiLi2gecfBUTp2NmJNFP4FJ/271m+raJhi7BwsAm5zqWO?= =?us-ascii?Q?c7BALKANdENJCWSSww2Xi7eurzG4y8C1a48jWIptYDkSSPoTY8gJtgCBU9uO?= =?us-ascii?Q?TWhpYPfrOYCep87fUvf642+XfkEB+8Scnce+Yj54jbQQIo2E8urtemkv9Txl?= =?us-ascii?Q?NmABJ472fBzThmp0scOIBlOTGU/6TOOtgLI8/i8PKs+r8WhUmlvHxk8el+0I?= =?us-ascii?Q?Ousu6EuIEy7RR09wJAiL7VL0QkCfK7hc+jXs4hhgsMELRf8JUK3zZgIrzmNm?= =?us-ascii?Q?jfphkU7zgx4zZ/PVz+mRv+GcUq465HyfpsOUF24KG81a8JMUsA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:24.8592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 692e7e49-a65d-4145-83ed-08dcf9621644 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6069 Content-Type: text/plain; charset="utf-8" As multiple platform profile handlers might not all support the same profile, cycling to the next profile could have a different result depending on what handler are registered. Check what is active and supported by all handlers to decide what to do. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 35 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 5baac1f9a9c0e..9b681884ae324 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -187,30 +187,41 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); =20 int platform_profile_cycle(void) { + enum platform_profile_option next =3D PLATFORM_PROFILE_LAST; + struct platform_profile_handler *handler; enum platform_profile_option profile; - enum platform_profile_option next; + unsigned long choices; int err; =20 scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - err =3D cur_profile->profile_get(cur_profile, &profile); + err =3D platform_profile_get_active(&profile); if (err) return err; =20 - next =3D find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + choices =3D platform_profile_get_choices(); =20 - if (WARN_ON(next =3D=3D PLATFORM_PROFILE_LAST)) - return -EINVAL; + next =3D find_next_bit_wrap(&choices, + PLATFORM_PROFILE_LAST, + profile + 1); =20 - err =3D cur_profile->profile_set(cur_profile, next); - if (err) - return err; + list_for_each_entry(handler, &platform_profile_handler_list, list) { + err =3D handler->profile_set(handler, next); + if (err) { + pr_err("Failed to set profile for handler %s\n", handler->name); + break; + } + } + if (err) { + list_for_each_entry_continue_reverse(handler, &platform_profile_handler= _list, list) { + err =3D handler->profile_set(handler, PLATFORM_PROFILE_BALANCED); + if (err) + pr_err("Failed to revert profile for handler %s\n", handler->name); + } + } } =20 sysfs_notify(acpi_kobj, NULL, "platform_profile"); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2080.outbound.protection.outlook.com [40.107.236.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33278146A6C; Thu, 31 Oct 2024 04:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347892; cv=fail; b=uwKHwpKi8ZtOb9yRBZlZe02ru+fqdsWdPdMiENsKUvyegfTaRg4gs9zzcc1lnbXpxI8WS7VramgOqpopeYxHd5wmAokLWli1jcXgDtBkZCPlIbk9lP7Na4qUOA5LZl04yDiGaUWlyq0nB5imD748e2OGXqwQg6K+l5ouVgHF4M8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347892; c=relaxed/simple; bh=ASgI2mf+wn+56shboFohC1GXeGNgqkK7PrRqtaLk6a8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kO4UT5TdM9By14SW2oyy3ZYqumARW5X05OcrZHCtpXPGAjJPDvuhAFfn77dMQ58cbduQILP+lyTL9fNNMWlC0ldF4nlUEZbmaOXNr0tpPjOEtHy6T030p+ZHaGIrgl/tSyAlr4FsS84UJaRch3w7Mlp7FeNCWds/UANXrtGTNUo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=spXwOoiJ; arc=fail smtp.client-ip=40.107.236.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="spXwOoiJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nUkwvJUVqtRbuGKookuuab3C5xfW0Ouefnp4/GnDQy0gNMLEEJDBfqcxekhJpVNlygYuulSUu6tErUPFQX2RT2g34Ps4XP5kGyjvaneWg6S5tWnq33NOVq4qN7lR5uEKCodfClgBM6D/eQ265KD86DNBUnn9YFOpguW7Hx1lWMNVEZxj9/yQZ2iKEtkSC1tKZLgjmXVC7HmvN6nzD+XgQmnLW1e/L0orEOFimKF7NWOAYIs9cO0taAqdro8n5HlCbiATy8cZ/pjP5cTvOm/pd1+9tSYIdDkwdSrJYJB3Uds1NDdMrz5SFj2ihtLtczZ3EhbUrz8WkEb+7O0rAnMSrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hQFE8Inguc1AFWBccMNoWw32J5ynjV70yDTo8C2otig=; b=TDcJuzWWzixnbVcxGkSmIz/BZfJ/hS/2tBLbU4JT4EQFWtuJsklUXBU+ZLd9LSOO0JsMbGRMoaokUusekl/B53siJI3wQUXQ3Rf+NcIdNCpGcAmdWChnfx7ufX4c2rUvmNQtD67zQjXh6sIuQKSE7TWYRzWx0YctE/4DVfWd42e1aKfiKtUDPF3mDQG3U0gTpnjVtHgYqbxrN6TvLR+gmHCtb6tlqx84HwOKl/8eZuCO41Nc1JZBa3EVGhefaCE7wlB4AZUG973iQVOjchCfaYiQf3P6aDtB3xvZMbAFVl03p68wXrukoqvEBbJJ42gUmxT4Y/jB2v9wll7YefeHPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hQFE8Inguc1AFWBccMNoWw32J5ynjV70yDTo8C2otig=; b=spXwOoiJ2OHl/khhlODrsK82E+NhhFkce8Fp+qqv9Pl3lix2OFjZmU0gMwmh6XTEQCHQ46z9tpWQD4o5w49YQYWqegnc7yPDZXza+e4+tM1PVbfY+SqxYtcjO3Mn7ZK3afAQPAIVFdhyk3UzlNcAltz9zZRJUv1X3Tp30ipYozQ= Received: from PH0PR07CA0039.namprd07.prod.outlook.com (2603:10b6:510:e::14) by IA0PR12MB9012.namprd12.prod.outlook.com (2603:10b6:208:485::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.18; Thu, 31 Oct 2024 04:11:26 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::b3) by PH0PR07CA0039.outlook.office365.com (2603:10b6:510:e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:11:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:26 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:21 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 20/22] ACPI: platform_profile: Register class device for platform profile handlers Date: Wed, 30 Oct 2024 23:09:50 -0500 Message-ID: <20241031040952.109057-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBE:EE_|IA0PR12MB9012:EE_ X-MS-Office365-Filtering-Correlation-Id: bd320fb9-b846-4778-4169-08dcf96216e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?eo+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RBvBkHgQt4hEVts1e/dctVvpwK?= =?us-ascii?Q?GjOAtgwqFecACS/MSZWyRNumVDu7toLMWkzbuslV8VrsJ4KajTJM1iHpZc0x?= =?us-ascii?Q?xAd6F9Gsj/UqDZlOMh0L2QON25PUP9lYwKGnZyB9FlAoQx+wsci18ocEehpV?= =?us-ascii?Q?ljxb2oeKpvuJd/Xzo4yt+D/eF6pP8blmTqJQ4Y97Iwp1K56gGpm9q05k9LIC?= =?us-ascii?Q?pO0xlvcfU7hUK5eSIlvG7LfkitcXXq4T/AnOqV5U2Hao6gYutc9OyThgqyTO?= =?us-ascii?Q?dl9CMFqie6jpeAvRaTnCGd51MhxTCaCQWdDLFa9k4HZkchvosNWJcZFxrtXk?= =?us-ascii?Q?4T2ZI9zJTim5ehYxslOl0nx5UsyuY4nxKXITMScQKRPm0jRuMSbMqcpxe/dq?= =?us-ascii?Q?W7Kh3aNJzDJFJjsAgGZDVhzeBdnQUPNhSBsNHfWdcqt9YiWlGQIDdUWhjn2+?= =?us-ascii?Q?939Whb1LBry1GrtzYJM/gNaqWXdwhtpAmmPHf1qu+K7qamI6PEt9gkLAAdLR?= =?us-ascii?Q?/hLSzhmSTNCKSUJEifAf9UgGFacU5faEotejGuAvWzgpcz9NGw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:26.2655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd320fb9-b846-4778-4169-08dcf96216e4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB9012 Content-Type: text/plain; charset="utf-8" The "platform_profile" class device has the exact same semantics as the platform profile files in /sys/firmware/acpi/ but it reflects values only present for a single platform profile handler. The expectation is that legacy userspace can change the profile for all handlers in /sys/firmware/acpi/platform_profile and can change it for individual handlers by /sys/class/platform_profile/*. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 93 ++++++++++++++++++++++++++++---- include/linux/platform_profile.h | 2 + 2 files changed, 85 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 9b681884ae324..1cc8182930dde 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -24,13 +24,24 @@ static const char * const profile_names[] =3D { }; static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_PROFILE_LAST); =20 +static DEFINE_IDR(platform_profile_minor_idr); + +static const struct class platform_profile_class =3D { + .name =3D "platform-profile", +}; + static bool platform_profile_is_registered(void) { lockdep_assert_held(&profile_lock); return !list_empty(&platform_profile_handler_list); } =20 -static unsigned long platform_profile_get_choices(void) +static bool platform_profile_is_class_device(struct device *dev) +{ + return dev && dev->class =3D=3D &platform_profile_class; +} + +static unsigned long platform_profile_get_choices(struct device *dev) { struct platform_profile_handler *handler; unsigned long aggregate =3D 0; @@ -40,6 +51,9 @@ static unsigned long platform_profile_get_choices(void) list_for_each_entry(handler, &platform_profile_handler_list, list) { unsigned long individual =3D 0; =20 + /* if called from a class attribute then only match that one */ + if (platform_profile_is_class_device(dev) && handler->dev !=3D dev->pare= nt) + continue; for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST) individual |=3D BIT(i); if (!aggregate) @@ -51,7 +65,7 @@ static unsigned long platform_profile_get_choices(void) return aggregate; } =20 -static int platform_profile_get_active(enum platform_profile_option *profi= le) +static int platform_profile_get_active(struct device *dev, enum platform_p= rofile_option *profile) { struct platform_profile_handler *handler; enum platform_profile_option active =3D PLATFORM_PROFILE_LAST; @@ -60,6 +74,8 @@ static int platform_profile_get_active(enum platform_prof= ile_option *profile) =20 lockdep_assert_held(&profile_lock); list_for_each_entry(handler, &platform_profile_handler_list, list) { + if (platform_profile_is_class_device(dev) && handler->dev !=3D dev->pare= nt) + continue; err =3D handler->profile_get(handler, &val); if (err) { pr_err("Failed to get profile for handler %s\n", handler->name); @@ -69,6 +85,10 @@ static int platform_profile_get_active(enum platform_pro= file_option *profile) if (WARN_ON(val >=3D PLATFORM_PROFILE_LAST)) return -EINVAL; =20 + /* + * If the profiles are different for class devices then this must + * show "custom" to legacy sysfs interface + */ if (active !=3D val && active !=3D PLATFORM_PROFILE_LAST) { *profile =3D PLATFORM_PROFILE_CUSTOM; return 0; @@ -90,7 +110,7 @@ static ssize_t platform_profile_choices_show(struct devi= ce *dev, int i; =20 scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) - choices =3D platform_profile_get_choices(); + choices =3D platform_profile_get_choices(dev); =20 for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) { if (len =3D=3D 0) @@ -113,7 +133,7 @@ static ssize_t platform_profile_show(struct device *dev, scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { if (!platform_profile_is_registered()) return -ENODEV; - err =3D platform_profile_get_active(&profile); + err =3D platform_profile_get_active(dev, &profile); if (err) return err; } @@ -138,12 +158,22 @@ static ssize_t platform_profile_store(struct device *= dev, if (!platform_profile_is_registered()) return -ENODEV; =20 - /* Check that all handlers support this profile choice */ - choices =3D platform_profile_get_choices(); + /* don't allow setting custom to legacy sysfs interface */ + if (!platform_profile_is_class_device(dev) && + i =3D=3D PLATFORM_PROFILE_CUSTOM) { + pr_warn("Custom profile not supported for legacy sysfs interface\n"); + return -EINVAL; + } + + /* Check that applicable handlers support this profile choice */ + choices =3D platform_profile_get_choices(dev); if (!test_bit(i, &choices)) return -EOPNOTSUPP; =20 list_for_each_entry(handler, &platform_profile_handler_list, list) { + if (platform_profile_is_class_device(dev) && + handler->dev !=3D dev->parent) + continue; err =3D handler->profile_set(handler, i); if (err) { pr_err("Failed to set profile for handler %s\n", handler->name); @@ -152,6 +182,9 @@ static ssize_t platform_profile_store(struct device *de= v, } if (err) { list_for_each_entry_continue_reverse(handler, &platform_profile_handler= _list, list) { + if (platform_profile_is_class_device(dev) && + handler->dev !=3D dev->parent) + continue; if (handler->profile_set(handler, PLATFORM_PROFILE_BALANCED)) pr_err("Failed to revert profile for handler %s\n", handler->name); @@ -194,11 +227,11 @@ int platform_profile_cycle(void) int err; =20 scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - err =3D platform_profile_get_active(&profile); + err =3D platform_profile_get_active(NULL, &profile); if (err) return err; =20 - choices =3D platform_profile_get_choices(); + choices =3D platform_profile_get_choices(NULL); =20 next =3D find_next_bit_wrap(&choices, PLATFORM_PROFILE_LAST, @@ -228,6 +261,7 @@ EXPORT_SYMBOL_GPL(platform_profile_cycle); =20 int platform_profile_register(struct platform_profile_handler *pprof) { + bool registered; int err; =20 /* Sanity check the profile handler */ @@ -250,14 +284,49 @@ int platform_profile_register(struct platform_profile= _handler *pprof) if (cur_profile) return -EEXIST; =20 - err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); + registered =3D platform_profile_is_registered(); + if (!registered) { + /* class for individual handlers */ + err =3D class_register(&platform_profile_class); + if (err) + return err; + /* legacy sysfs files */ + err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_class; + + } + + /* create class interface for individual handler */ + pprof->minor =3D idr_alloc(&platform_profile_minor_idr, pprof, 0, 0, GFP_= KERNEL); + pprof->class_dev =3D device_create(&platform_profile_class, pprof->dev, + MKDEV(0, pprof->minor), NULL, "platform-profile-%s", + pprof->name); + if (IS_ERR(pprof->class_dev)) { + err =3D PTR_ERR(pprof->class_dev); + goto cleanup_legacy; + } + err =3D sysfs_create_group(&pprof->class_dev->kobj, &platform_profile_gro= up); if (err) - return err; + goto cleanup_device; + list_add_tail(&pprof->list, &platform_profile_handler_list); sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 cur_profile =3D pprof; return 0; + +cleanup_device: + device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); + +cleanup_legacy: + if (!registered) + sysfs_remove_group(acpi_kobj, &platform_profile_group); +cleanup_class: + if (!registered) + class_unregister(&platform_profile_class); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); =20 @@ -270,6 +339,10 @@ int platform_profile_remove(struct platform_profile_ha= ndler *pprof) cur_profile =3D NULL; =20 sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + sysfs_remove_group(&pprof->class_dev->kobj, &platform_profile_group); + device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); + if (!platform_profile_is_registered()) sysfs_remove_group(acpi_kobj, &platform_profile_group); =20 diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index da009c8a402c9..764c4812ef759 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -30,6 +30,8 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; struct device *dev; + struct device *class_dev; + int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; struct list_head list; int (*profile_get)(struct platform_profile_handler *pprof, --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2042.outbound.protection.outlook.com [40.107.220.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AE4B146A87; Thu, 31 Oct 2024 04:11:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347892; cv=fail; b=pZ8N74wKwLSPL6CgCZZJxoIfRwCQUoti12xWmwtFZzvPRlpwvLFVvjFRYWlmUdI0qsrn5epox2WzyMHuKoiVJ1oQrp5rZy9npXv9PpQ+KL0U56oPFVW6UY/DX5HlkFVvNfrT2/xedX6eG5gUqeNwmmtV7qqGt6ue1eQHAGLHueA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347892; c=relaxed/simple; bh=2bgiz07RWtlQAlUkySyB1AoW7uwWWD3IthivNQhZaUE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t3JwtrLgzGPxNMA6PRxB87rlAE3zWH4Aodb0Sc6gvJbRwtCrzMXRonRGuP9FxaWd1B0+0ceKxH+RsbE3tsMEKEfUIo9txNVSNM8vJ0Qx5RnRAWnJSXIS7znBjccVNsIfgbZVmsbUJjE2bTwVk011Aei6HlSNyPf3w6lODfaOcJo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=EaTJi/JA; arc=fail smtp.client-ip=40.107.220.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="EaTJi/JA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QqKJhwgS4UnQPKgAaLZnxNVuH1U7uxrSmXwvFMmLbDiLtKJY6t3i/eJP+BZc20oO/avu7fPLONKSYyBU4nX1ybk4iKRDbIbHzV5LXfWwPRxQg8/+UOtdPFDBOpUOl+GSj0hW32MWLXGvDUDPDZZVcEa51waa8BtS7tOZtH8BHf4L0sihE8K1e3Ok9DBm48Ad26BqrLDbH49uSvDduHgCnZCiAIBNVLrc7HpreBIfY3SKUtytJMmidM06Z6JBVCqmR2v/S5Q9RXAnK5emAvcrgMZaIHPK/yNO7eaGDW69IbOKcLTZgGlyHKAErAzOVLyEKhucojWmYBxBC+7j6McEDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HrgXA5/hjgAqL0HSOmHsTShil3KJAlJa4+pswu/z1fk=; b=jYbhwvk1ydQMJql4cXGsuBzo+FKrh99SGC2w4bjxZCAbYV1ZOWRFj+Td8xq+rx2DFcIB7zaQmQrdEV+xnHFgyX2PbqZf8efY58aqq7e1GFJk1LOHLFBg2bPXgY1ObGjrhiv6UFGpWWylvaUcewe0NrJIQ7tFvADyVksu8HOjdVwRv4a6b1nixZaFpDt8L1NbJhflx7S3x5LiFY4f47yxifS5kVwdzgZ+wsSYKQ5WrZQtYE8g5l27RT/mD3PxgO6aMP1zjDa3jfSMg31IW6UtI9+b8Wa+PrMw3ZXVwI7xrWcDPUvy1yawLD3q78dMwoIiB/jd2or4sdLL7e1PvH25+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HrgXA5/hjgAqL0HSOmHsTShil3KJAlJa4+pswu/z1fk=; b=EaTJi/JAddHUMkHyrrLTK4Uwz/aShNPTX5WQj1EmxuBRnVk6hgADb92msmGPwYp94UNHXLUTb4lbrxlp/kQuZH8CRk2cHGFInaLSJKuVV1n6ycYv1Cf37NLRX0N5ym+E7Cut5+eGqpsQPXMsko5qCR9QuTGowW+bYjjsFEa2tpk= Received: from PH0PR07CA0043.namprd07.prod.outlook.com (2603:10b6:510:e::18) by DM6PR12MB4202.namprd12.prod.outlook.com (2603:10b6:5:219::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25; Thu, 31 Oct 2024 04:11:28 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::73) by PH0PR07CA0043.outlook.office365.com (2603:10b6:510:e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.33 via Frontend Transport; Thu, 31 Oct 2024 04:11:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:27 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:22 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 21/22] ACPI: platform_profile: Allow multiple handlers Date: Wed, 30 Oct 2024 23:09:51 -0500 Message-ID: <20241031040952.109057-22-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBE:EE_|DM6PR12MB4202:EE_ X-MS-Office365-Filtering-Correlation-Id: 34c7a095-1f87-4885-b0d8-08dcf9621775 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wzwOsD/Uhi10+N2MtYI3oMNUcYU9Vh5GXoUrE9gRjZ41aTs8EzL0MWw1RCV1?= =?us-ascii?Q?PZvSQlBMUFmM+sJivmA9Wfb8kzhWaflJHx5GcpJ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aIhyNJDMT7BLHXYGqLco9XGkf/fX/Da1Z49mYKBF+?= =?us-ascii?Q?a4acGEZse3VN5vctF8479z5uCR5ujsCo5nK4zxaEATfvyA00Gd4xWwM+XPlw?= =?us-ascii?Q?5zLUv0gQxzb1JBARghaO5exY8MZG6GEGvMSaHr/VMD16RRhLRVbpzaSPjbaY?= =?us-ascii?Q?KYxoc4mLfTkA341R4GU6cm55Sy9SXWGdyo+Xwi7cdJDgK3OEio2RPUjy0Ro9?= =?us-ascii?Q?WEVil3TYPOcWPEFcYV4qiu06gnyhcrtqTtzmB1ZRzb/Kh+bB+ey0Xe/lOvAv?= =?us-ascii?Q?eW8fL5MWAqkf9udr6RKmQp6iYRpWIJ9hKnCTQPuOsxV6n2ib6TqAoIa4fLR8?= =?us-ascii?Q?+JFAnwMmUxgSph03sciRFZTYm8RUoTsq22uEA4eOEzL6E1KuOFC5TDrlqI7v?= =?us-ascii?Q?VkERxvaGpbQmRlSGXncONIiMfzDcumGNxuL5ij5e0Ay/b3JkbA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:27.3749 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34c7a095-1f87-4885-b0d8-08dcf9621775 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4202 Content-Type: text/plain; charset="utf-8" Multiple drivers may attempt to register platform profile handlers, but only one may be registered and the behavior is non-deterministic for which one wins. It's mostly controlled by probing order. This can be problematic if one driver changes CPU settings and another driver notifies the EC for changing fan curves. Modify the ACPI platform profile handler to let multiple drivers register platform profile handlers and abstract this detail from userspace. To avoid undefined behaviors only offer profiles that are commonly advertised across multiple handlers. If any problems occur when changing profiles for any driver, then revert back to the balanced profile, which is now required. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- drivers/acpi/platform_profile.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 1cc8182930dde..a845524a248b9 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -9,7 +9,6 @@ #include #include =20 -static struct platform_profile_handler *cur_profile; static LIST_HEAD(platform_profile_handler_list); static DEFINE_MUTEX(profile_lock); =20 @@ -212,7 +211,8 @@ static const struct attribute_group platform_profile_gr= oup =3D { =20 void platform_profile_notify(void) { - if (!cur_profile) + guard(mutex)(&profile_lock); + if (!platform_profile_is_registered()) return; sysfs_notify(acpi_kobj, NULL, "platform_profile"); } @@ -280,9 +280,6 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) } =20 guard(mutex)(&profile_lock); - /* We can only have one active profile */ - if (cur_profile) - return -EEXIST; =20 registered =3D platform_profile_is_registered(); if (!registered) { @@ -313,7 +310,6 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) list_add_tail(&pprof->list, &platform_profile_handler_list); sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 - cur_profile =3D pprof; return 0; =20 cleanup_device: @@ -336,8 +332,6 @@ int platform_profile_remove(struct platform_profile_han= dler *pprof) =20 list_del(&pprof->list); =20 - cur_profile =3D NULL; - sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 sysfs_remove_group(&pprof->class_dev->kobj, &platform_profile_group); --=20 2.43.0 From nobody Mon Nov 25 00:49:16 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2051.outbound.protection.outlook.com [40.107.94.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7852D18FC7F; Thu, 31 Oct 2024 04:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347894; cv=fail; b=UuU++dQK2UzfM1RC3xm5a2e5GNdE3bLN96a/Bo2jqSpITJm0PKMAq15Q9D4p1QL8cRkbfssundCelv/7bb+FHjt1Vt180s6APWbnDAKC3VDbeecMU4WCiMxcllb87uY5hYPXh7+0MxVESGphxCw0jlvAXkYKqDjGqaAtjltqFIY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347894; c=relaxed/simple; bh=5itRs+0Zj3QFTkypBZE0+Iy97f2zvJHrmQw71ikXEVM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aqm6ckY5GzMiw1IPpSxhTusmUSF1PGvdCz/ocUCYHmYCFXCzPEuIT6NNsEe6L39fP1sTUcqiSqt1le7ICqjRxdxgIefzjKXQJ4GYcOByJ97VTaoGzrr7YRMQvpX9GSTnK1Uz/rqK/pqjuzpkfc+TBkaC8ZMN4uq01d3EYTOEmu0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=v/+k21if; arc=fail smtp.client-ip=40.107.94.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="v/+k21if" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sX8WZr8dM5/OE8jDKkJTh7f1/SsFA85M6zLAiTJBQosQfMaXFpT9/KC88ORaX+q2tlFrRxNQBrdCI3Pxv22Eikbc8lkG3/H2rI1Olv85nrZZQ/CiXbdSdG5tThLjBsFkerQcqn0xbZ4qnUvVhF3aRq79y65I5adH4qgs9iH62ovSu0Io0LxbOXGLpPomXVMG24T1D8ZNZUzR7fm8bNwtDNLiZOPAlWYayZeNtipbsUZf0FhYXNWvc1La0gRrK6N+p74qj2j0sZMDuFfSr6NAByAJGD5mtMvevTeuO6I8FzXm03HxVq6D9k3JCDF/lFLry1db2+iLwp/XOcLbZ9gEwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZQ6Mds4UNrPu1FSi+YcGzN/5YmiE7gSWMRjCumN+XkY=; b=pXKUx5FJZg8PQYLJcRHk6v49hbtWyerFqbJZQ/DPOjCprc8oU9u81OAhewpw/3LFW0Qx2RbX+yo23GSJUDSLYJktzIINhjwdK1n0ZAppleGYfMHEC5ulusTPYR2J7lr1NnyyAGpJMoTx2wQFTtdk6g14siZ5f64vlqGGMOiaiPQkKJ6pFn4VBp0cxyGGiN5AntvcBQ9rHzsoaz7BH+/qh24yMpFknAIFHHnxwRe+gxfqS9pZinvplDvMjPTYeRn8Bv4nz0sryAxVdxbf6u3kvHRssUXchMt4voNWHFQb9kTyxdPmCPKGnP7twdr6r+vTEnFDTWnVnepdxZqW3ahi2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZQ6Mds4UNrPu1FSi+YcGzN/5YmiE7gSWMRjCumN+XkY=; b=v/+k21ifIz/7bglHcqY3nihUX1pI4H2Ow604AZXGmaNAxxlhM+blP8pURZ5TAqHhsxZetPUlaIXFDmusSs0ym0StvDanjsvg+Z7+jSLBuIVerkTSJUJ3U1+nRLFCrGmApyE77CdMZWMczT78wVAmwBQBHuVJf7Cwnbff+wBZQUQ= Received: from PH0PR07CA0036.namprd07.prod.outlook.com (2603:10b6:510:e::11) by SN7PR12MB8025.namprd12.prod.outlook.com (2603:10b6:806:340::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:11:29 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::d3) by PH0PR07CA0036.outlook.office365.com (2603:10b6:510:e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.17 via Frontend Transport; Thu, 31 Oct 2024 04:11:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:28 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:24 -0500 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 22/22] platform/x86/amd: pmf: Drop all quirks Date: Wed, 30 Oct 2024 23:09:52 -0500 Message-ID: <20241031040952.109057-23-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBE:EE_|SN7PR12MB8025:EE_ X-MS-Office365-Filtering-Correlation-Id: 7dc927cd-9d00-458e-6b9b-08dcf9621853 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0h93YJ2duLOsdai70cEdSt3bKVy0U8PysPcc407u8fAsYGi3NmHpTHUhCzRR?= =?us-ascii?Q?0I4wtXCeo0UuWn9bJQ5dYhlqmTr+s7fq6EmNVzabcMBwX4XqxXSFHNJghqCK?= =?us-ascii?Q?sU/Xs577ivsJD770VjruYMlsWYkQXBe8DZ02ClTU1sjLFiK5o69P9W+JMSEQ?= =?us-ascii?Q?qbDXQslq8uw7n/Fp9Pm2X4V7Q3tOhWhSFHv772DogsXt5FA5dkReOXYYodVp?= =?us-ascii?Q?GIS8ANCpuGnBrwsOvFGvGFSqmgCWscKU7oUqaYtBMism3DfgiuCi6cfQR57i?= =?us-ascii?Q?JudzCQsELQypty6hYry7z1PfHc3Q0V6dKt7S4jMhosqUnHW2b5g3bBLAgM+3?= =?us-ascii?Q?eFmGxb67FNEa0PNKxu6xCBGZBZhvC7HbBQqrK8Q4VMoZi9P93buT2mx5Y+6W?= =?us-ascii?Q?llI9jQPK5xJiPLo3QB29pcDt4nwzH0sKpKWUSd6AzpnqHflzNugNB/wKEKww?= =?us-ascii?Q?E4Lx2kk6oP+N8lwZMsn9Dn5Wq3soFuB7ak/Pl95niQ06w+OeCl8cUEl4MhLm?= =?us-ascii?Q?akDmKvBJQzLk4RAk7fcucS7v5hL6P9y0VymAEjpecJzYhLeT4YbYi52ZXOVU?= =?us-ascii?Q?eP9P9TioShaisDFLDswoCwFplwxy4KuSB8LyMXhnmQymoivtiIBnYd99jqat?= =?us-ascii?Q?wExPwyETTc5QCutjX6y1o66ekmzslmyjgN6WfshsBYwkJqvdmrAGC5AC6Okd?= =?us-ascii?Q?97/nvP2FfZSpgFG4N7nyYvzOd3RzkiPS6rs2zY8cNmjg1+6z1hUlG1sj3oGd?= =?us-ascii?Q?sOWh81zI7LDajUVziJCLFqDC641QXJh+bINjcQRQaqQPr5RsjFN+CHxPuZ36?= =?us-ascii?Q?0EOdsJ2BrHFso0W9yntVXbmNaCVaDMQeZGJlBRRoRcVqsOdbURaPXRAVU+5U?= =?us-ascii?Q?QY0NL1COTQ4SUyw/RhloWMIuVVEVoh6YK2TxzhzUj46r4BCjkb+tubZ+qIf0?= =?us-ascii?Q?5FzqaCDfNl+GJ/yHmdxrsMGX7b0J7KuY1f1sHYovnm8A68XM+pKq4xTsdmTU?= =?us-ascii?Q?KeB7P0SJIFSWTU+B9PJVMc4Q7YYg8uHnQ9i1kDzHP5aluIGaoFaviTkeCVDy?= =?us-ascii?Q?2pArL2V4JT1JhPpo0SSNK7hi58VaJ8Upr0XbFcRSLAESNgXGcUv9Ut17mRWD?= =?us-ascii?Q?L1gN8V+y07cpGvrkocyCF6XFKby3pUP+n5/uQ9i8T6Jp8KhK+NSLbfUEwl6f?= =?us-ascii?Q?DudngaqgofvPhQWO8KE5gtOOyoUSMAh9mLkwhutGZnLDCGKykR33JwSb8UF9?= =?us-ascii?Q?YBPkSUv68XHHlyxf4f0MSNMOwSoPS/pChb12hJO3U2EvphdtQI2Du7ABu2eC?= =?us-ascii?Q?1rzDB5ERBJDmrOEyoOPWOu4PUjiPkFWwWRRk0heJpY/CMHXxSzRb1yDMkRnx?= =?us-ascii?Q?2bmcOKCR7MIiNawmHXVdkAnZEwMSwOjPvz/iXZzOz/n6l7GnTw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:28.4530 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7dc927cd-9d00-458e-6b9b-08dcf9621853 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8025 Content-Type: text/plain; charset="utf-8" As multiple platform profile handlers can now be registered, the quirks to avoid registering amd-pmf as a handler are no longer necessary. Drop them. Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/core.c | 1 - drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ----------------------- drivers/platform/x86/amd/pmf/pmf.h | 3 -- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/a= md/pmf/Makefile index 7d6079b02589c..6b26e48ce8ad2 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_AMD_PMF) +=3D amd-pmf.o amd-pmf-objs :=3D core.o acpi.o sps.o \ auto-mode.o cnqf.o \ - tee-if.o spc.o pmf-quirks.o + tee-if.o spc.o diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd= /pmf/core.c index d6af0ca036f17..ffec0a64a82e9 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -455,7 +455,6 @@ static int amd_pmf_probe(struct platform_device *pdev) mutex_init(&dev->lock); mutex_init(&dev->update_mutex); =20 - amd_pmf_quirks_init(dev); apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_dbgfs_register(dev); diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x= 86/amd/pmf/pmf-quirks.c deleted file mode 100644 index 7cde5733b9cac..0000000000000 --- a/drivers/platform/x86/amd/pmf/pmf-quirks.c +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * AMD Platform Management Framework Driver Quirks - * - * Copyright (c) 2024, Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Author: Mario Limonciello - */ - -#include - -#include "pmf.h" - -struct quirk_entry { - u32 supported_func; -}; - -static struct quirk_entry quirk_no_sps_bug =3D { - .supported_func =3D 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] =3D { - { - .ident =3D "ROG Zephyrus G14", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data =3D &quirk_no_sps_bug, - }, - { - .ident =3D "ROG Ally X", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data =3D &quirk_no_sps_bug, - }, - { - .ident =3D "ASUS TUF Gaming A14", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data =3D &quirk_no_sps_bug, - }, - {} -}; - -void amd_pmf_quirks_init(struct amd_pmf_dev *dev) -{ - const struct dmi_system_id *dmi_id; - struct quirk_entry *quirks; - - dmi_id =3D dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks =3D dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func =3D quirks->supported_func; - pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n= ", - dmi_id->ident); - } -} diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/= pmf/pmf.h index 8ce8816da9c16..b89aa38434faa 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -795,7 +795,4 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_de= v *dev, u32 val, u32 preq void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_ena= ct_table *in); void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_t= able *in); =20 -/* Quirk infrastructure */ -void amd_pmf_quirks_init(struct amd_pmf_dev *dev); - #endif /* PMF_H */ --=20 2.43.0