From patchwork Thu Nov 7 06:02:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865825 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 D937E192D8F; Thu, 7 Nov 2024 06:03:32 +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=1730959414; cv=fail; b=iN6xYYw6jhmwmTc8gylRlV0z5TKCsntMVIE7+wi90ebxVfukiIUCyuAQ5e3bnBFE3xkEjTqtE0xThK+EUPrBkspm/w99q4FyT3tiVzc29l67jqJNw2LeIF5M/C78DI3+ONndCWPQJ6JL16Ki5CYzbkhPsY24W0xpnbczkcDLbWI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959414; c=relaxed/simple; bh=tgk8RY+Xh2BX2mN66fKFdmqhl/F4m7qqrrEeV1tpv8Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Goh1SFBilukoTWHrAfUUVLlwB/NMS2FU9tnmKMsHjjJ+iuZ4I0XJSTgzlFWlKZ6GGYlr3pE/6jVxt2FyJWKjP7dVX5PbZSL8eW1GCBv+lczzv9iUWyvp3eypxk8wrFNLhOrUb3O6rsIR58EEcVrnLDBs6Jv875hkDMdTSYrl07k= 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=eO0i+Qqg; 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="eO0i+Qqg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aGgFRa/yO62l1j11ZvtSA977fsurE+67qPAG7zGCpx3PKAQQPu2vH9MDhUz5dMB7wfdQh6bw3x1VJOpmVIpvLGHPdGBVJkEm6EbGIzZTGE+x+vJ+axQTNypECEculAwQSJ08AVBltzR+2xcUJ7OnVwIT55zZrYf3l5SCL1yolymIMNGsCsIVVYUMIwzUloCXKyE8t8J6CUw1egWMRq3U4Ca4i8zAqZB8Bsw2/7gUsVvFFagCiflzJ6GYDzX3BCdUn8KP7DmdMM+A/CvvlEcQJWqKJv2ygKFykzPu1d3sNFVCt/Uwoz/acZ4A8rRYvl1KpcHHL+SgM3ZYRRxtWApsWA== 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=YZpVGhxUqKsw5ae2nfZGIdmBElV9ZiVBff5oYJnU5X4=; b=O3woC8eNmTq252fDx7SMeeIKSuSY/XHlsacNWspbxkRAzpY5AIZ+LtKkV80k01z8Wtn4kmN4ikvv9XmBkhFy9ajIxPWGpMCWb660kBe3BNKfvJnSaulUs8cFBgT3yXf3U+3NoRbWjFeRMrHcvRIT4d0363014Zg17iBV6yKdTOYn48mRfkzqeRdlY3EEvAgqRSrsA9Hsni6oRas0JLJ9wdX6/ElObZEEZDCSIBmoflOvjMZ/Z7vZpHV3HpPJFMG1lqRyU4zmwL7U8n69Xzn8LtUG/0fB6MsT1CopSDrV3CE1XxidyJh+nB4bojjImSHsSYHTKr+20N5uKMMYd9POIA== 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=YZpVGhxUqKsw5ae2nfZGIdmBElV9ZiVBff5oYJnU5X4=; b=eO0i+Qqgx7MjeI6KkslYeImdvhfqRORanMfBfuvsGEnGDr5xiWPMmiVEp0IHq9++clcEooZUH/DH2qBqOOE35/2im2j1CCgXx9I2JwxObpWHgxImxRevNbJ+MPjrNKzGClbM87LH7LWFB1luGBDeTWpRfukKRUbHwh0AX6f1jUk= Received: from CH0PR03CA0292.namprd03.prod.outlook.com (2603:10b6:610:e6::27) by LV2PR12MB5776.namprd12.prod.outlook.com (2603:10b6:408:178::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Thu, 7 Nov 2024 06:03:27 +0000 Received: from CH2PEPF00000147.namprd02.prod.outlook.com (2603:10b6:610:e6:cafe::d3) by CH0PR03CA0292.outlook.office365.com (2603:10b6:610:e6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000147.mail.protection.outlook.com (10.167.244.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:25 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 , Armin Wolf Subject: [PATCH v5 01/20] ACPI: platform-profile: Add a name member to handlers Date: Thu, 7 Nov 2024 00:02:35 -0600 Message-ID: <20241107060254.17615-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000147:EE_|LV2PR12MB5776:EE_ X-MS-Office365-Filtering-Correlation-Id: a431c8ed-32b5-4e98-7495-08dcfef1e5c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|7416014|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?xZSs9HK/KQuwcCdGyqw/286f+5Ioxhh?= =?utf-8?q?qgJ4PeRaAqJvWXa4TmkwCS+SO/TOolXCdaJwavoaycmxjVZ5QwT5n/kso5qssMjuw?= =?utf-8?q?uVOH2wmVix4qXfANP/J4x5Zk9GNQeH9MtszMeNsMvAGDUtpKSPyhuK75icmisY5jz?= =?utf-8?q?nOptduObSAIGO6tNsd5gSmtVtUHJfvFnpAEvexbnxlt7xFeHwkhGnwtGJHnPdqZqn?= =?utf-8?q?9otF4Kjjh7L99hfqOV7X30Ws2t745gBrytpw9tDTDJd/cwe3S/raUy+QYTe6xXdIq?= =?utf-8?q?LN0QQrI2klNx2GYcBo4vqPPUclaooLdMTnQvH3G+QeRfkdt0eKMPeYDzFxh17f+cf?= =?utf-8?q?KlGkbBcfVsIGBIOPeO9inPGHAmw+cGedn/sE33XtDONvYO6oprbAgfa0ORp7ABCCG?= =?utf-8?q?M+mcmTk57bGeLEGlwteg/gNRKOsiKAW7X6x01pqVNpi++edH9fmP5hPX0Bb9iAOaX?= =?utf-8?q?TYBoYNTjzbzy5PHfghAwIGRpLS7MKPe/EtD7FU5x1ReNF4ZOOJkTQg1ssEWWfi3NS?= =?utf-8?q?V7ABsKHkSDrF3xe7Qlfruq8tDJejp2VNn2F/05UzvFiGnRFWXqnv9BbSyQf5Dy1DD?= =?utf-8?q?firbut3JtoLhukqKDANzue7K1rCwTxT3Lg+3820DVR5aUBFFJohusxgmIklgc/lh5?= =?utf-8?q?sUM45G+u6kTymVPXbfsDOyfsw9c3Vvm+yA7Tglx+mfyPqxthVxUB0POcYDv8vSj99?= =?utf-8?q?4WtsDZ8d4hDPKiohoztlpo9855xiUD4wXCtrLPtnfHjD8TGqGXGoAYGSMta6sTLHE?= =?utf-8?q?AckxX6tV94udASO1DIauGqU2JMPixSU/+9GBY33u828ZjUZCOI5QJs0AFAyhe0wWt?= =?utf-8?q?RkqO+tbULefkvGmN5D6pqDOsWn+pvJAKPcwl2DVcumGubHRMnaiV+fzOLr6KK2hNR?= =?utf-8?q?36C56PElhFt435rdtd7sMeefpeorzT8AOi4RBQrq0yHpWcV0aOflOqJAn3XrVzh/M?= =?utf-8?q?jc/UMcByCX/IqANaDCYYhA/uNwZ9dfXRcNVlQ2BKMzxUUwNmjxwivdMcac9owU4mH?= =?utf-8?q?LHfMFPNRMn90ZLc3zvzR/VCtPjsrENsMfIk3kDBeXV1DjUGBH8rjR7FmKFnbFGuSR?= =?utf-8?q?JQgZefc8zPdch9ZxdU+RUH0Gn5+JHSwOsXMWH/ti8u7xoM1k1WgMmVMJGjUsA8q+Z?= =?utf-8?q?yv6FfPXqaHfpv1NpAwOh+pDJSGXol3EjqQlD4lb2lFQZ8wtdc4ksrDyMB53KElka4?= =?utf-8?q?JOAhe2gOa48THj51BjYlDpmQrLdkI/JWTSlqyQTxhGPJw9SMVsMy6Zv9M+2+aVFuH?= =?utf-8?q?l8Go43P/5Hctex58x0VjrdvI1T2EoMpxN3ku/5mS6fxKnafoCVRu/Htlrz2nIhT6Y?= =?utf-8?q?2L1sxPzhQn+z8tuZVBrSSXV+DYYdeP9dbg=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)(82310400026)(7416014)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:27.4417 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a431c8ed-32b5-4e98-7495-08dcfef1e5c4 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: CH2PEPF00000147.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5776 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * pick up tag --- 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/alienware-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 + 11 files changed, 11 insertions(+) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 3de864bc66108..61aa488a80eb5 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_device *sdev) tpd->sdev = sdev; + tpd->handler.name = "Surface Platform Profile"; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index d09baa3d3d902..53fbc9b4d3df7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1878,6 +1878,7 @@ static int acer_platform_profile_setup(void) if (quirks->predator_v4) { int err; + platform_profile_handler.name = "acer-wmi"; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = 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); } + dev->pprof.name = "amd-pmf"; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 2ccc23b259d3e..c7c104c65a85a 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3910,6 +3910,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); + asus->platform_profile_handler.name = "asus-wmi"; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index a800c28bb4d51..ac0038afd98fa 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1056,6 +1056,7 @@ static int create_thermal_profile(void) pp_handler.profile_get = thermal_profile_get; pp_handler.profile_set = thermal_profile_set; + pp_handler.name = "alienware-wmi"; return platform_profile_register(&pp_handler); } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/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 = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); if (!thermal_handler) return -ENOMEM; + thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 81ccc96ffe40a..26cac73caf2b9 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); } + platform_profile_handler.name = "hp-wmi"; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 9d8c3f064050e..1f94c14c3b832 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_private *priv) mutex_init(&priv->dytc->mutex); + priv->dytc->pprof.name = "ideapad-laptop"; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/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, const void *context) priv->wdev = wdev; dev_set_drvdata(&wdev->dev, priv); + priv->handler.name = "inspur-wmi"; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_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) } static struct platform_profile_handler dytc_profile = { + .name = "thinkpad-acpi", .profile_get = dytc_profile_get, .profile_set = dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.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 { }; 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); From patchwork Thu Nov 7 06:02:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865824 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2076.outbound.protection.outlook.com [40.107.93.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 B1170192D7E; Thu, 7 Nov 2024 06:03:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959414; cv=fail; b=cUfGM3KdpL2efT2AhRh36I23YH/1WcHy8C/c8ERcGONy5IVKrh+CkQQZtV6bUR9A4jSGEYHGjr2zwcn+UC3Z9TsJ3bhenzZV2s3MpG8VIkVZaNqJFrTmLMzJDqguftiF1BpkXLyjxRHgDnhuFHhUk3gkG5nYngSOvQVg/Mf7whI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959414; c=relaxed/simple; bh=YrvhKUBrmKASOjRrsD4+2FutuCJZ/+C9KrTb2y2zj1E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=okvfKpP0lgY/RtalaGXMNPjMb99wYywAJ1OWPLF9EwTnnYr7l5T0/xpsKnL152ljIbvfaSK1msu2xp/vEDVjEL2r+vE/ZWrqWgWD3xMcWg2NP0LDt9yevto9YY0Ehi13SoID8HVNmOqjqbPgx2bEYX2IEWeEYH8WQShm6XlAwxA= 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=uwAepv1V; arc=fail smtp.client-ip=40.107.93.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="uwAepv1V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kVnaV0d72dPj5RqWaJapTngmFB9LRPPDAaqePNNNIYGK6PbS/YZs+dtwWGF4zQv6Rw5RwIR3Sfe9Cnma9iNeJvblOpb7RMkkuJadm8T3TN1koO7m1Qi+oWv/JrSGKeNhNSFonpP6wDxLK8CAhnLVBFBaFbtJd0nSC8XbzW44y71MKZdIhnfzOIb73ZQ50NVo0pFNDBf3HM4+3K54lumu2ilP5z9sOrG0mjALKfXVAKynP9d1c9yOqzj2+etCXIdRhbsv18+XggjteDiGruye4P1LngrAU6rCTkOhC0ipYDWYcBq7i1tmE56uEQ91QkGLff6dlIxpQA6hcarVLplxJw== 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=4JnTbbFF5wE4ooCniMJuEfRSre9huJa0rS/D8f+fLP0=; b=CRXNEEBhuTZFyWtOcvYVdXbPpZ1BrzKCKufJWxexwB4PEaREyTDVf+cx6V9V8TZf4WFZ4GAxSofotWDCsRDVCg1tGN/FCAVuo9dy/Z0ozCCANwPlkREPrX3r76CI4v23n+yTPVHgZbBPTv3E4gSOa0uwTt/ACb/zWgDzVWtkmFNLMZGIOukrcL3MgMSAD4KXSVSYMVMwCREj7nTd3vNupm67DhL9JdVrYScCJV4GpBgTGkq/clFFBkzgqHtu6InWC9bWRXZmr38hvvrmuvp3OWTDY0OxP/6cfy4ofkOZhgW2+tqIl7zmEuu2PMpt/A6GEKW00fKpXVIX/Cj3M6bdSQ== 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=4JnTbbFF5wE4ooCniMJuEfRSre9huJa0rS/D8f+fLP0=; b=uwAepv1VceZcCqqZ/Cfufy8RHoU/8dDuk7PVEAjoBLTh/tKHQ9Jt57AORFTIqjGGLLu8gQlZh949Al7QLZJlf64VXfnCNnSPFXVXR9hCtxNLEObcJKVr/D8IJ8dpmnI8XF968owDHALIGHMl1QwN34VmuHcklwFPTWDPWtXLxx8= Received: from CH2PR07CA0007.namprd07.prod.outlook.com (2603:10b6:610:20::20) by PH7PR12MB7331.namprd12.prod.outlook.com (2603:10b6:510:20e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Thu, 7 Nov 2024 06:03:29 +0000 Received: from CH2PEPF00000148.namprd02.prod.outlook.com (2603:10b6:610:20:cafe::8) by CH2PR07CA0007.outlook.office365.com (2603:10b6:610:20::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000148.mail.protection.outlook.com (10.167.244.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:27 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 , Armin Wolf Subject: [PATCH v5 02/20] platform/x86/dell: dell-pc: Create platform device Date: Thu, 7 Nov 2024 00:02:36 -0600 Message-ID: <20241107060254.17615-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000148:EE_|PH7PR12MB7331:EE_ X-MS-Office365-Filtering-Correlation-Id: 5805d461-7537-4b58-ee5c-08dcfef1e70a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?HOvRLpZaWuKZ+eHXHt6IWHHnX3JxmUr?= =?utf-8?q?7esxLgHB1giDQz8B3n1zebWQnq4Y/vW9vSshWnyIyqdmGLV1nI5jXaslvpCKazvqC?= =?utf-8?q?GyeGxEi7bYT6kxcz4c0geXaIiiEwg2iitk8PfuOJtd3s83x2owcPLeDAK9ghoz+gD?= =?utf-8?q?1YBeH2JjdEiY331Rw3ONpgYy56vzJfx5bKcvVqhviMjcBQQ67/OyxT27X8kLcT2GU?= =?utf-8?q?sy4oj/2P+c53mGQbYeZYnJuD6zmwG9rJQ3rrkP2SEHWDILW9cKIWIhjnAZvdSxWvu?= =?utf-8?q?z20+o21AlHPUbcnvtgpO7OF1Iq/wixqLg/d4KNm+63okczapi+f+BGku4ULW7Huek?= =?utf-8?q?8g6NFmytR1u2eTq4NP1UmsXBPO3UitNJosSdc5n5NtLUeXJnVLHxbWlJlf9q46T+9?= =?utf-8?q?m0KNP3FIKxMs+x8M0ElhANnVenbzj2TTTrke6svEhGLdAK5iIb5VMblgs0mWys/JI?= =?utf-8?q?dW2m1tX1+PFxEwn7Cn2bsivniL40WGX0orGubXu7klYlvwu7RYNdtvkycNIv6EpM0?= =?utf-8?q?NZnQdIPICOWnDU27RGBwGwjRE90IW0nLTziLGshnk0/MSBFFCk8fTHo9rMss2icCn?= =?utf-8?q?fAbm1lFj0Xrno623w+2c67mBjEN+tepW/mRons2W2ZmyvHd6lP8zWjOqgOYQnWFiO?= =?utf-8?q?OVgNd1n964aSvAGFzEB2d+2X6/N68n/9GkbwzUg3nMoXiZnVNjipkDTEO+vuowCbI?= =?utf-8?q?p5bu1A2XC2x3o0Bme/b+ZqhGdDjxbGypHpvdR7sfv/A+/1vtTWZtQ4vecDZlvdkpk?= =?utf-8?q?O7mq6j5rrEpZm2niWO1y1KW/h3+mITiig16w7wzVMD+j0Zt/7hTCEXRuXoy2Uacfm?= =?utf-8?q?LlmL4PN1ue3IoYDxr0Zt6K6S2cAKFyja9TW36eOySjHmAe5Octl6BghFTScbko427?= =?utf-8?q?SpDjAqdjuOl9Np9/W3UZIIu58d9sk3KcQ/JdR/pA+t+ElGTQdHhqw+Xfn/KPWfYI4?= =?utf-8?q?ML+jReDE04ldiKvp0O8BWrchfuvdSvZ32kg/R6yVi2hPkHtkovds/P8R66CAcKyFN?= =?utf-8?q?Mu45//igx0sfMLtf0lP3RQFmeDe4xzCH47zlFUTab3Yl8jY0SC118ViaCY8o97lRO?= =?utf-8?q?RQDhVzFvanZ9V7QrZgaByvRe2/B82PkelKt3qprqSEnj88Mp0gGsn9fFjBFMTOENh?= =?utf-8?q?DH1WehsLQ3UWQ2E0j47jR/Ts+aUZdOlC5OoYpAnYjvd1gFTTluq6xpZmYO9smStNJ?= =?utf-8?q?p1A0R0SucBJ4V9ZUpk2DNzwQNFgPn1/ZgwoKYrco5KHAKd4uqWuFp7QjiPi5ntjnp?= =?utf-8?q?O98lXDrHdzJnr+D2CLQxC3IeltUUwf3SKPKfmKHBDBU3qqHFA7+GCh6uKyuLArGG9?= =?utf-8?q?HkPKri20DaCo4zCV/RIKlf2Itpy3GDtA1w=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)(7416014)(1800799024)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:29.4563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5805d461-7537-4b58-ee5c-08dcfef1e70a 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: CH2PEPF00000148.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7331 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- v5: * use platform_device_register_simple() --- drivers/platform/x86/dell/dell-pc.c | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..0cd9b26572b61 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 #include "dell-smbios.h" +static struct platform_device *platform_device; + static const struct dmi_system_id dell_device_table[] __initconst = { { .ident = "Dell Inc.", @@ -244,9 +247,15 @@ static int thermal_init(void) if (!supported_modes) return 0; - thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) + platform_device = platform_device_register_simple("dell-pc", -1, NULL, 0); + if (!platform_device) return -ENOMEM; + + thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL); + if (!thermal_handler) { + ret = -ENOMEM; + goto cleanup_platform_device; + } thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; @@ -262,20 +271,25 @@ static int thermal_init(void) /* Clean up if failed */ ret = platform_profile_register(thermal_handler); - if (ret) { - kfree(thermal_handler); - thermal_handler = NULL; - } + if (ret) + goto cleanup_thermal_handler; + + return 0; + +cleanup_thermal_handler: + thermal_handler = NULL; + +cleanup_platform_device: + platform_device_unregister(platform_device); return ret; } static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } static int __init dell_init(void) From patchwork Thu Nov 7 06:02:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865827 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2047.outbound.protection.outlook.com [40.107.236.47]) (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 86E39194C6E; Thu, 7 Nov 2024 06:03:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959418; cv=fail; b=JVgRQsTzWcWdJaKMeu0MkOBP+RCur9uyhIJh0AAlUBSt7ZkZSQhj5FICT4KDhQ2Ok5lOBclLk5G2m8TROmuzuc8QgrIHVOQmSjAwT0i8W32V2SWXcuKIfv7CfOFE7EInSRo2KTHKIYeu4ayXzX33URaNGNQaOw9fBLHH6zSFmII= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959418; c=relaxed/simple; bh=IZ1HlMQ/Xt3xeFZFd0KcV+Z8RNZRAWxNsipJcv2/foM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mzqUU+wZ1zGXoKEINSvT4Ba4aQV+lS3Z2xzXZ1/x9MMh8J3Zxfw4xezjtJ3P8UXChlZfUChcxXb7jG/hKzpfDLa03X/E/hztk2mMaxQQw2gVYcTwQvqAVBZz8Z+cxsrD4ZDMGXFfT5oojvihvueazZcJ94TsWObs57NVYFrdXAo= 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=DJYKoq05; arc=fail smtp.client-ip=40.107.236.47 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="DJYKoq05" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gWM1g+kWSAbRsaDnOI6XJu4IlLZJF1hv4xUeooTJGK+4+i+c/LOklyeHyjwbu53ZXf3RGlhqv7sXmmmmdOOHBWmalWK6G9XWzsJlWp5fCtdFqDSIIqGGOW1yO9LcaYEr+5BEio5vU36c8SZpDquOonYnApWV8HPoZS1tk6LGs4BAeCB7XsAr8p7glt6/HQU8BWSHpxwPPsH+6ZquJaSCo0Ki921QM8O6WmxZhZ6D8FC9fn6KkmFbj3liX0sPbAUAZoklGWHQlbU+GSghGlKlSuF54mZ0jBWrxpezUc7OogVI7VMxrjt9JaclnVXSNDVaWcgEgHyaN+Q/RRLpQ5nYQg== 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=9rcEA9VFt43X5+VIMws0c2U3e7AuxufNdvwsPe43s08=; b=JHFCffAFUJ+NT2nwUCs31+yLCc2fVV+dje6TTM2phPkcg5Ao9IZTikIjlfwWfTEx32v7e/XIPJbeIOiW9pJU8YVrubnKk5OjtArNw2IJbzD63u4QGD5TnCPwe/R1t+cy/Dy6ATJdfs37Lp+ukBqTHuz0dardXrxQpnyNRpYAL6vmvk5C71xV4VSUfrR1aonnXU3duZbbZ5F7nASNS4oaVzGc304TqjbL37LAJt3LnA8FaiHZKubvZfm9VRKQdZe9OqQ9ghn4oIjLDkyJI1sgpr1vxmh/tpir33Wz9sVXsHnoCFek1fp7jQOb6yK4ZxnkP8oPsvgnh+iVmz2zojqVWw== 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=9rcEA9VFt43X5+VIMws0c2U3e7AuxufNdvwsPe43s08=; b=DJYKoq0560kHVNJzThHFhIFqVuR8PWxLZfWDLGUAa/XZ5jTZUSktqkiDA52r96mnHw1FLGoGJCWtzAPyvYBuOo/KBRAMrqo9E+VolfQpG66sLVyMDbVuicTriQpqh27NtWF4qBpivj2k6SRawAmH9/nGRrF+Z88rW0MlO+d0Owk= Received: from CH5P222CA0019.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::20) by SJ0PR12MB6686.namprd12.prod.outlook.com (2603:10b6:a03:479::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:31 +0000 Received: from CH2PEPF0000014A.namprd02.prod.outlook.com (2603:10b6:610:1ee:cafe::e6) by CH5P222CA0019.outlook.office365.com (2603:10b6:610:1ee::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF0000014A.mail.protection.outlook.com (10.167.244.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:31 +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; Thu, 7 Nov 2024 00:03:28 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 , Armin Wolf Subject: [PATCH v5 03/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Thu, 7 Nov 2024 00:02:37 -0600 Message-ID: <20241107060254.17615-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000014A:EE_|SJ0PR12MB6686:EE_ X-MS-Office365-Filtering-Correlation-Id: d619c148-b22b-43df-8481-08dcfef1e823 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: =?utf-8?q?cPbLKnt4aJDsnipdbp+1URUIf9ihvbv?= =?utf-8?q?F5RmLKr+QYJUHLHX5GfIU17L4Cha6Hk9FPYTmRt2+6INDYXAE13o3lSApS3eO4OW5?= =?utf-8?q?Wj91yFjjatpI+qn7YPnm2ivBsTXjd40H5V/gt10WvEwYy106JgiqSkjUC9jf5cehx?= =?utf-8?q?hlvafofNQDiXDDsXg6UT3B3VVVVlo4gkNJYO6pBIKKwKp+7ymRh0ejQYWWs1B14EJ?= =?utf-8?q?JtHTTOf5h9GWArKrebjGfW5mKvTTvCGV4vLa3yyH2ASWnn7qb+fYpAfda5XyZq1aB?= =?utf-8?q?egoS3VpWZyB6OpIxhZM5Smx1/GwGkqPq6RURcj6h1wv6Aivo4nBEQP8PbtlKzXgwo?= =?utf-8?q?6PJdLH9iva20KLhjqXV1My6LZTOoVa7zWNxKDF3HD/ss3hw856IfLn/1XL6DHU89H?= =?utf-8?q?+thpRDXSY9EUuGGrE2qcd4p4DlADGA0i9RjwPoHepJHPw2z7+yXlZRQhUm+P/ZFqr?= =?utf-8?q?dVEXqdEkzlImPbNn7c0e5qw2aG7LDZ6P/yNIt7m8QZ/KNg5Nycb6JV6M3xVSvO9jM?= =?utf-8?q?UB45reEGttpmGENA53BcvZ8hzVdmu5Ionw6IEkb8ZoYPojPyuyOg+odueN7s9kpcT?= =?utf-8?q?2qqJgTFgzTju/tMiII2pu7l9RmM47DCp272YoUwLQ9KqTShs3KQRKQUks+VI0Q0cg?= =?utf-8?q?WGAdXrWKlIriP1pRMS/B6rv8uGzz4eVdCmG9nTIQs8rhxSrpqhSGs+1U5tymMfVK8?= =?utf-8?q?KfP7ftVsrTP95M5aLIa21GUak5dbO5T+VlGdSoD55QAoIfPtFDP5NzQS8RRnWwfLo?= =?utf-8?q?5tz+EDnKana+cd/dpY36uHGd9E63hGn3kdZ7m7xcXj/zHmwfwrVA6mtKMvIwfi7Lo?= =?utf-8?q?spRgZLxHIkhEqYZcxihgoVZoiJ0yRuUG5zM4pkeiVzv9yFfnxrS1wXbmsmrRIdr0a?= =?utf-8?q?/Kk6IfPeWltQSWBXBk3XsdX7kt7AUdKeSr2lfJWDSxMiA7JbBZ52+o3Qj6mXjTKfE?= =?utf-8?q?QLc8+eA+pgJNYsfETBs1VxLTWjCWmg90rA+nc/VhFVZXkaCMwVk8v4Btpg3BC++bI?= =?utf-8?q?Hlzeu51S+Q+vGAW9vGnFft+iB9ep/g8OWF1FZOR+S/SQi/+s6OvgYAs9WWcF9igTQ?= =?utf-8?q?0J3vlTrJBTvv58EtcTXL4vSFeNRJMbjEpJbh5emgaU1qi8Lqc7+JFxHeXUUBSu1gF?= =?utf-8?q?9HYCAsU3SJFUp9CtX2kYhCK5l8vYkaoDiwV17mrlYxgMA57DrgXnMu3wXb0qowpH6?= =?utf-8?q?HAc3PqwE+kXJVd/T7Pn1zNoxow4z63pOfAfZI/AksxXD0Lbz8gUCbUW9ocaOg5+DJ?= =?utf-8?q?iV4k2drb0r3T9GvcwJbfGMwzgrsILqxuEF3wgj4QVpXQtrt4HP75IQ1C0o7geEx/K?= =?utf-8?q?I4OBIL5nmlTtr8xiTME02rVzvWC1TU5hyw=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: 07 Nov 2024 06:03:31.3108 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d619c148-b22b-43df-8481-08dcfef1e823 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: CH2PEPF0000014A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6686 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: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag v4: * Add alienware-wmi too --- 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/alienware-wmi.c | 2 +- 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 +- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d2f7fd7743a13..c24744da20916 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -205,7 +205,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_register); -int platform_profile_remove(void) +int platform_profile_remove(struct platform_profile_handler *pprof) { sysfs_remove_group(acpi_kobj, &platform_profile_group); diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 61aa488a80eb5..1c9e37b1f4761 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_device *sdev) return -ENOMEM; tpd->sdev = sdev; + ssam_device_set_drvdata(sdev, tpd); tpd->handler.name = "Surface Platform Profile"; tpd->handler.profile_get = ssam_platform_profile_get; @@ -227,7 +228,10 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_platform_profile_device *tpd; + + tpd = ssam_device_get_drvdata(sdev); + platform_profile_remove(&tpd->handler); } static const struct ssam_device_id ssam_platform_profile_match[] = { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 53fbc9b4d3df7..71761d4220c26 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2546,7 +2546,7 @@ static int acer_platform_probe(struct platform_device *device) error_hwmon: if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2569,7 +2569,7 @@ static void acer_platform_remove(struct platform_device *device) acer_rfkill_exit(); if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } #ifdef CONFIG_PM_SLEEP diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index e2d0cc92c4396..cfa88c0c9e594 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -425,5 +425,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) 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-wmi.c index c7c104c65a85a..f5f8cda7fd19c 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4885,7 +4885,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); @@ -4912,7 +4912,7 @@ static void asus_wmi_remove(struct platform_device *device) asus_wmi_battery_exit(asus); if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); kfree(asus); } diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index ac0038afd98fa..e7f97eb24a014 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1064,7 +1064,7 @@ static int create_thermal_profile(void) static void remove_thermal_profile(void) { if (quirks->thermal) - platform_profile_remove(); + platform_profile_remove(&pp_handler); } static int __init alienware_wmi_init(void) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 0cd9b26572b61..b1ada199e7978 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -288,7 +288,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); } diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 26cac73caf2b9..bb8771d8b5cd8 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1692,7 +1692,7 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device) } if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } static int hp_wmi_resume_handler(struct device *device) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 1f94c14c3b832..50819ac919e87 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1135,7 +1135,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv) if (!priv->dytc) return; - platform_profile_remove(); + platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 03da2c8cf6789..d8fd59b826f3a 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -190,7 +190,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) static void inspur_wmi_remove(struct wmi_device *wdev) { - platform_profile_remove(); + struct inspur_wmi_priv *priv; + + priv = dev_get_drvdata(&wdev->dev); + platform_profile_remove(&priv->handler); } static const struct wmi_device_id inspur_wmi_id_table[] = { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index c8c316b8507a5..619a4db74e5f3 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10637,7 +10637,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) static void dytc_profile_exit(void) { - platform_profile_remove(); + platform_profile_remove(&dytc_profile); } static struct ibm_struct dytc_profile_driver_data = { diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 6fa988e417428..58279b76d740e 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -36,7 +36,7 @@ struct platform_profile_handler { }; 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); From patchwork Thu Nov 7 06:02:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865826 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2047.outbound.protection.outlook.com [40.107.223.47]) (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 EB66B194ACA; Thu, 7 Nov 2024 06:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959417; cv=fail; b=NgjLj1OQ+QGBAdt/NPaiELcEgAq/wSreszASZK/A13tHLyG6JmhPMXt1oFMrS2vOKEBttH56+pEZnzhIfC0Kj17DfWgsjCbh8g3K9BNlQT+r39uGT3Orw9lpoVcOCwi4E6whrlT8bdsJumM9wFPGVYha45tLvz3QMjvFh96r9yY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959417; c=relaxed/simple; bh=qRMkcNUifXAtXpphjU+checUJ1PxliYj1y1hj/6MSRU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ChXBMTmthbxzRUK43LphI0kvK26iEoaZEM5S3nc6zEpCPmRN4A30zSLK6sc/GGKiVgfcpSgiYwt4XBUIfR6wOfzEOsHgbYrHiMXQAu/h05z79/WQX8WYjgwnve7tpe9TGhMnMXDoYOdNVY5Rehf2QZahPboYItIH9WfDJlK/xnU= 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=qlpJPxdm; arc=fail smtp.client-ip=40.107.223.47 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="qlpJPxdm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FSK1urzYDmKgs/r5nGXyd7HdcdpEyEx0X6gCF5L+nuaIpXjg14FIVmWaQYoBX+pwntEqubvKuX+k0/5oQDeuLrAnNweOgd5yHpU1EEEb6SS3emQhJNUxFl5ytgOuuTXuHQuxwBbalEJ3Y8sEdIfj6llLwqrPQkyLh4Yne5SaquxOYMuxfG4naknJ7j3sYzRqai6ayIbIzP2+XgyCUXBj+HrSP6JwHvaURGDJ9ONtN4txL59MYjpmTT3A14m+8lJI1ANDC8s2M1DjejWowZkbWdY4NZB6wQjz9hTPJw++HrxOdxg2o7vgevZ3bJs9a+ZrWb3T6NXjlPaq2IdruD/XHw== 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=cT2khbTtZ2PklkeQ8e6PL1V7vzlpvNCYOcZuzpHGU/Y=; b=Ol99oQuH9K9Fe7xpe1y+lYhBoIT/q9k8ll+nzK1BCOGqfAqvtG2Kx21WC513CZGDLxN96/4VzlaVNZFTOj5Lp4dTS/8gkQs7jHlPKO+rA1+DPG+HzcVyvCnMKTBqZnevwkjbGgidNXTQC8jg2xH4879ePQLSm5pteK4PMHQktJUV41wyNJO1PEK01J2GWW65lYN8d2rzZZ5SV/JjVSo7/CpG/5750EcDz/Oka1u2Y+eCT/GS6Op+U4gYKK3I/kmTjnzoJZg0ZyrAB3CpohJJ7k50UxFWxhEYTz3soqrcsnvJWq8huJhF+Ach0Wwp0jXmJImWx9jbShYFVLvk4D+0sA== 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=cT2khbTtZ2PklkeQ8e6PL1V7vzlpvNCYOcZuzpHGU/Y=; b=qlpJPxdmBUtzsThAkjfbpDODw/hrTZoe7elO7vSaiwCTeweMQUmEDsPleyOP7kdL4a2IQo34asn7RMIi9EcIhFL9PCDS3SfGnFJ69lVIdiWsXgUkXRqAhP0I+50kyRSSUWHRvz+MR9tqw9EoSwqoDqmla+s6rbU8FEh21+LBWms= Received: from CH2PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:59::19) by CY5PR12MB6480.namprd12.prod.outlook.com (2603:10b6:930:33::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:03:33 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::ce) by CH2PR03CA0009.outlook.office365.com (2603:10b6:610:59::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:30 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 , Armin Wolf Subject: [PATCH v5 04/20] ACPI: platform_profile: Move sanity check out of the mutex Date: Thu, 7 Nov 2024 00:02:38 -0600 Message-ID: <20241107060254.17615-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000146:EE_|CY5PR12MB6480:EE_ X-MS-Office365-Filtering-Correlation-Id: 32e1fc26-143f-43cf-89c4-08dcfef1e930 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|82310400026|36860700013|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OIAebvcnASHgbq5P507j1lAknP2tW3B?= =?utf-8?q?Q2/Jkz/vTFVjEIQf6/+GYGs87gDwezIJfd2GfZe68TgO2DJK0D9V5FZ5TlzjUUkE8?= =?utf-8?q?nkeLQ25jJkL22Gg+DS/6Q9SEMBz6YErBl51ujCt4acy8tlsm2YOHIed5m9n2xf1HS?= =?utf-8?q?wSOmcoS5ZWue1UZBD7KMlILM/wBbz4japhBDr04UhlaaMzeFzMxxnQ0xld2KrotP+?= =?utf-8?q?uM1ZxRqklldIZlnXXdm1L2zegM75vtQdw43PKWstAJQ0f2OmmVTcj6rWpxtyloJjK?= =?utf-8?q?aLnlir7l2RaXJVKlhXehmlITRA+BKDKyNQ773pkHG7Zn7Cu+5aEP9CAhZ6DJBzgkB?= =?utf-8?q?mPrp9TDYBPZaN/o9l2UIrPNq/SA7EM2Iq3jN6hsycXNLIH5gsnJOwo6A+OhDLUvFl?= =?utf-8?q?srjNj0PVMP+Y+C+CBSR33MTcfZaF+DYOZ3vdoAQcH6iwfxGRPo0AiYHRSbXFpVniy?= =?utf-8?q?KZfatS23b+TTnHT/lJj/xyU3ZPrmzwV31g4E/wsMZuk2zeTMqppAdvpsb0eLRfn4U?= =?utf-8?q?0nKpH7o0sjPqkE2JyFCtQ5/A/h4Dm/RI0jmjYmlNRpNyMEFvqwatAYrPr0NVhtDeP?= =?utf-8?q?z8J3L86rJX1xSeY6tEOb1DGTaxp55ibRRfybqmHlDW4hzqu5akbKuRhB6EqD3eDNf?= =?utf-8?q?//gmhQX1ynmS2pYWWV6Si6RgvMoZTMgVrYXrrAUaj8Ro7IAHnFm0M+oyIM6SkQzDJ?= =?utf-8?q?5S9lNVdt3fpeBGNM5tChwyxAX8ofdFHnLM57hXr4Xdw1dToI5gj3X66zqZWBufTvc?= =?utf-8?q?ZViiLILMotdVuwdLa0DgZtbjK3zAD5CkWdkfLZ4CFbzV8NO4z6jNVNeHmj9MvABB4?= =?utf-8?q?o0m4jUIaXOr/0zpVZfCRaF3KNYQFMU6K5VMAoprIXB1omExYnhQZMr7DdrQRAk+Bv?= =?utf-8?q?gpiUVRSX43a1wpoJkK0ttvdfdh98yJAKWzWVE7pYNKkt+C5lY90sJ63f13Uxlb/fd?= =?utf-8?q?9EtvUTn6hrl40qjlbEpAyw8rO7f7PMnHxXAs6is4SWT5xcEI9N2Ue6xGKp55jxNov?= =?utf-8?q?Ly+JW+BVbn/DCf5IXevubs9X7NA6LquGoaRl6jeEQuQzAyKybCXeT3x8ABKDPX76H?= =?utf-8?q?XVXLVrzNKrFU/UntFOFAY3O6TO0iYXDYT6uvNGGrsbU+OZHzes4QJcByXAmbzHlTX?= =?utf-8?q?pcV82EdS3YH0hzBHruGdFq0Dd8vPwwdMz1SyjlsekEV8uvvFWemOEPo4X4sQj8ScR?= =?utf-8?q?4pRUhNsfwRBIWB0o6bGs6KUV1uMwu/gg2tJ9NNnD5uY4BmYsgsqKQ73nuwidWjhBL?= =?utf-8?q?he5pSENzMgMwuvOGllTgDQM/jGDT2n5TsWX5jxBfsFImM1YT9KuN4AiFB/5iLbl4E?= =?utf-8?q?F2xTbgMe7xhmTiZ1gbPQAqReLhqwBCGDcA=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)(82310400026)(36860700013)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:33.0894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 32e1fc26-143f-43cf-89c4-08dcfef1e930 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6480 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: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag --- drivers/acpi/platform_profile.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c24744da20916..ce3aa1361721e 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,13 @@ int platform_profile_register(struct platform_profile_handler *pprof) { int err; + /* 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; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { @@ -186,13 +193,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EEXIST; } - /* 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 = sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock); From patchwork Thu Nov 7 06:02:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865828 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2048.outbound.protection.outlook.com [40.107.220.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 552D719750B; Thu, 7 Nov 2024 06:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959420; cv=fail; b=fsA8nF7sDUsZocwW55S7UyxTASwtBACvNUp1mL4lamLBuemRgSbn0qv1UIvvVLhd6SO7jMuwRBuHpYWNhmew1u2Lnr86SPB+rev01HdlmNX77NSjdvQtrVTRdZ6HbnZFbZStOhhfY0CSAx6LFk50IpmrbSCNbRuJQZm2enePxAM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959420; c=relaxed/simple; bh=DDkbAG6s/28zVI9+vavafl2eH/ICGR+F1er0g86Vvb4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=d0kE31KlTpWMXrH5VMgq1U6V8WEaeAmNuMpYn/BQtofcS1yzyJ4ipFL+mucHgXdVNJGQWpf57cd1jrhJ/Do7T4/12Zd4tPn79smncUjtn1l0e/3+kA7ClNtewh2b/eilyxgR3+IGkahOdkM65yD4uyUmgNZVw/9Y6i5QI9pxpcs= 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=BINiz304; arc=fail smtp.client-ip=40.107.220.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="BINiz304" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=csQlib47aALnd/QbBRSA5QZ7tni8LaSWVaFY7fkuUO1QQfibBvVvRtijvkQxa1Pe3jZOrWXn8FGhCbM0CxFMlfbciXQ+3YoMfDJnyV7tyu9ntAJgeCgjQkjuguB1oA4DCLa+IZVPVav+c/KgNEEjEBCUULUHxXaPAmO8mFM1GHYXx9h5XFF3f6Aq5jALbyZaiU9cZEsf3D9zI/FYu/Ce6evCW9RIjE+zGDGaioBVbVqrnXj/4kFjTmrfu6g+jeUuZFS7jnY3ftEyuWd4iMnWD1dDh6nyuz1fp5UjRpzn1Qxebd22niZyGQx0dJgwrGKOovN/jgxSMn673fAuM13ppQ== 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=DJwrJ761+yqKmHSkFl44f4+2ZO6F8u0PriKiwW84Lds=; b=kHZIKTXawryPczyJr9nvOHYFTmWVHeVu9SzvVVxRBk7NCxv4JsipnHayxDLOen2y0D+g3+kin+ZXjJlv49cXtDlLl8ZKhPIKX7CC2DfprHZhWdhC8jrBZpSTc4sKOyDtT7wK0trgAhwlGJqMcdr9bwCwcwZNWxO2PLR0qBQFCbdkni2j8cx2RWm49I0O9BnG/Mbp1c/V42SC6tOSpal+xkqBo40e0aFNWE8lSOx5oMY4wQZRCXfuao98E234Anok8sV+zos2PVsYTHiq5Atj7jvHR9EvsDuKSZXG0e5kuhZ2p8uslTfCQbsKoOnsgjTG9IBKxMtChJkqyEtNjEW84w== 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=DJwrJ761+yqKmHSkFl44f4+2ZO6F8u0PriKiwW84Lds=; b=BINiz304ZcTjPON1TUJIaZX99S7CTVTCdQuTDZLivDMtCLBY33btb6I9FMw/qVAGmdNciBDFTSvPLv1XaUjbuCKRVrKRpxC8o83oKpcUqHAFGFFICFlqZlOo6Hnxr9wvyZ/4/6H5S3HG3Ur7ODW+UaRcR3T+nOBZjmTK2hLHiO0= Received: from CH5P222CA0021.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::10) by SA1PR12MB8094.namprd12.prod.outlook.com (2603:10b6:806:336::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:36 +0000 Received: from CH2PEPF0000014A.namprd02.prod.outlook.com (2603:10b6:610:1ee:cafe::24) by CH5P222CA0021.outlook.office365.com (2603:10b6:610:1ee::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF0000014A.mail.protection.outlook.com (10.167.244.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:32 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 , Armin Wolf Subject: [PATCH v5 05/20] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Thu, 7 Nov 2024 00:02:39 -0600 Message-ID: <20241107060254.17615-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000014A:EE_|SA1PR12MB8094:EE_ X-MS-Office365-Filtering-Correlation-Id: bd5a763e-c87e-4efc-76cb-08dcfef1eb3d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hB1wNHh2BtYb3oBduofphQumKai1Ko5?= =?utf-8?q?CCM2dnT1NT9eMxL0kSr9BDspjRTRFwtVDa5OCPGnPOf4K8EL4+cd5+JEO530ZWsBm?= =?utf-8?q?CMLhfHZZtnyOWWPj2gexZuQDFv8+Y1PWKpfsOGYJ7PDgGBMOIOtJghKXEAKQPaNZb?= =?utf-8?q?+Lq7GBZmYU0Wa9C6ZLmlwd8CZLasAnNu9PJ4tNQiCigBohbv4WyQlyNZSH3+AxJgA?= =?utf-8?q?cWVFBF74wiEkJfmo6VV1T1JRmjoXI7GkYiFFxsTbhY+16H6ok9A5tlvbpFTIBfZi+?= =?utf-8?q?4UwqSA/Qec2fQHTMj/jzUy/KAY+37iIwVvu4QgyN40f04zH+FDX7JzjbP9B5+V2vL?= =?utf-8?q?kVoEeedE4ar0h9xV9MV/ivOAULGDpb/7VsxRWwQO+EIisHzbgu8AOY6RhOJtIP2Z1?= =?utf-8?q?7XY1o/oxII8tKA36uvARFpELl1UAjXpTl2bpvXJFfpjZU8hHBhHiFbPA4uXgNW5Qt?= =?utf-8?q?rSFONonlu9LR7FsTU/WSrPce4OeLINea8xwAlp3A0y/Kqhk14inflx6nFkNOho7rg?= =?utf-8?q?Fryw/pGoAc6f3HJ+xbsLPHNk+usMVhd9xm86cL72Yndgz/O1Y4QJFWVSnBWHHezZ1?= =?utf-8?q?SKsTw60Z2END/UPeydtfRoey+fLGwnwcJeWKGcYBzWatOF09Rrp7ZdJRb5Ixh+1Tn?= =?utf-8?q?JUNpwoujbnBPWCWaN+yPuqzFRzGGaZcBTOS6TuVA4wYkxM3LziJBZv6a76jkRTCo9?= =?utf-8?q?mOWz4SQfQVJ/Qjp5LxvUp9iUDOCSpgGePqc2HK9bvUCxFiIzz0DRRL+Dj/opflNB5?= =?utf-8?q?2hd3Ew52cz1Zv/IqqP9u8ssoX5XmFXLHMPO15jH4WJd7j3pt+5RkiImsGkmw9aM88?= =?utf-8?q?y23AaNjxZrv8sGRJarkXt2AVOahQODYgpGyr1zTcldRq1Bk6gcW3GFA0HiQyKtzG9?= =?utf-8?q?qIGJy/csiafdd3DU5DFgjp9hBVkTLwyKkbFKYXEIzqTHZGhn6IrhLl2nJhUqPh5Hr?= =?utf-8?q?neA6JZ/a/YtvKvhf0IAtH/Wp8ic5e9LPlz4wjf8XV6Jp74dIYtVTrvTSKzQ648ynU?= =?utf-8?q?ZgcbVpKprKng2x1mK2hNo8vWlbTKW9MW/hhnM6mS9P1eU0TCcOUxov5Ep7OZ9Umf+?= =?utf-8?q?nO9f6Ac/xoR5C+vnowDJIcEzSEWzYiL2cjg/WzmXc6qRrV5zcZx1fVLXJ02bCCjo3?= =?utf-8?q?w3CEtGi0K9WwBp7Qsc631KNcS13LfrpPoSbyZdI0ja7ySTPcoyt66AXTgNpyNuhEP?= =?utf-8?q?Fe/Itbo0ktfP7fwlFBwgMWwL+Js35WEbL6wpU7WIZm/HB/cTZ6CISOGCNk7b2g4Oc?= =?utf-8?q?qR8fd2nMtlSMAJEuY4VsPoqQMdHwU2t7iPyrU+mKbfMAJHiLIDuzK4erTrjhuEdt0?= =?utf-8?q?zuTJ9JFY9S82CB4a8D1Wk9LQgIbbP34ONw=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)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:36.4983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd5a763e-c87e-4efc-76cb-08dcfef1eb3d 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: CH2PEPF0000014A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8094 Holding the mutex is not necessary while scanning the string passed into platform_profile_store(). Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index ce3aa1361721e..fbdf3cdf1141d 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev, { int err, i; + /* Scan for a matching profile */ + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + err = mutex_lock_interruptible(&profile_lock); if (err) return err; @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev, return -ENODEV; } - /* Scan for a matching profile */ - i = sysfs_match_string(profile_names, buf); - if (i < 0) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - /* Check that platform supports this profile choice */ if (!test_bit(i, cur_profile->choices)) { mutex_unlock(&profile_lock); From patchwork Thu Nov 7 06:02:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865829 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.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 E3D28197A7E; Thu, 7 Nov 2024 06:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959421; cv=fail; b=oilVhqzBSdS9Tdhsgksd9GxIeiUS9kmJoX0mm6JktV98lha0/0D/SYtx7sXYFx/9Aa99qLu5BssNO13TJBfdiIuUVJTrlmacPvNqCkrq9scs0hhqQ4ooU1M+iCWknnZ0zDz9dS9y/PZFHFc100Izyd6kYNj+erbKz3ORxesKvbE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959421; c=relaxed/simple; bh=M8a3jlvXTMdc/FFBVebMJsQ8wdXj4ZIXAyA82jD0/18=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RSl9IxJYTBT8iURUy9L1+YLsfnV6k10KAtvnFWNPzgoyCRIvCkqpSPGFQ26NKh1HT+8QVhhpt8XT7QtNpiFeb9klCqSb7fd7bgkNC0z8ZjZSarZuIW0Y1Thye71ZGF9+KU2V4dF45960fC9kKrfTdQb0QiNgnQqLUw5RIwFx/Fk= 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=238mT48P; arc=fail smtp.client-ip=40.107.94.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="238mT48P" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HeRZw1Wkad5JcdLYb/sm1BCmjkf5mk4KvQbNkm621xCcY8bgTlAoddXoD8umq5NpIQPxUNw8I04Q/EPPCVMZp3LuxxKgXvDDxDLh+457sWOIHQ0vxoP1xgAXt/fO44Gy9gqVmaMSy7tZqBiI/HnC4/3JDdIRTFPA51NS0KlEHQfYZ+CGge0iNgwEUcM0d4oohmgw2UdmfV9nB4Cp+yxtdrulJfqfwuaFLx+OBN3jaQBp2fVRURe1sXajDKN8I1AE9sYGROWd5STl6f8yQ1NkgMQ9tOzcfSf/XVtUGSbvccRZnkAcL5riEm9+yicdNfvRs413gNHW7dvQqHfvOxKGGQ== 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=wnfyT3tMCL5FCDOuR+WuRHGXHAYbYss7SLrNrf80Y7w=; b=oRG10fke0HdSeqABf1E7OnkTJIVm/6XWHE1wke04MKIaFVqfXtA5oWXssWls+fFtALUXED+AXtN6QCEeTHUnAUEBfPlGfVtoEb07DE1hO/61kAZrxQ/vmSq1+pBxMkPCSXTXGXEcKH6oG6xkx2XfJYHmwg2Tald8a81vfOC831t1QZ6Fp3hGoMdqbE6xZmOJrPvJ241Zywd5ukryM75Mlu1XiN7PrZ+m5AR0dWjCaBao3r9TcZNNvWUGwpeRVXVyfRdXXw1Vf5EPeOM0YoEWcK8RQzF4+8+Na7bEbBiVYgGlMq3T2Q+fO7eg/4INmZvsONaDLC9KS+ggu23lzlePpQ== 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=wnfyT3tMCL5FCDOuR+WuRHGXHAYbYss7SLrNrf80Y7w=; b=238mT48PuHuV111jTjNXMa0+Ba9qdw8j5a9JRiSQhxNXvHgyogPSM5CL4VQCNCzDPfuw82EtJ50dtGc2orHHGMZniFgEG1NemOhgMJ3o9N0FbSMIRChCmPwkZRSXtvvd+rMJZ1ZDb2hwYgz/ZtQsowm8gaQ1BBoTR5+BT6uPhyY= Received: from CH5P222CA0013.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::14) by CH2PR12MB9519.namprd12.prod.outlook.com (2603:10b6:610:27c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:37 +0000 Received: from CH2PEPF0000014A.namprd02.prod.outlook.com (2603:10b6:610:1ee:cafe::4e) by CH5P222CA0013.outlook.office365.com (2603:10b6:610:1ee::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF0000014A.mail.protection.outlook.com (10.167.244.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:34 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 , Armin Wolf Subject: [PATCH v5 06/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Thu, 7 Nov 2024 00:02:40 -0600 Message-ID: <20241107060254.17615-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000014A:EE_|CH2PR12MB9519:EE_ X-MS-Office365-Filtering-Correlation-Id: d38d4228-dc94-45ed-99e1-08dcfef1eba1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?jZHpcrzlmebX8ZAyWPJ0nZtjCUcNtTx?= =?utf-8?q?HeJ642OlUW5vbBveJE+4rNlKPeGJUnyXNtZeQUaYI2TljDwwtO2zLUHebUFw9IRLh?= =?utf-8?q?QHr46a7fZdsziPAhOreKSmBifWTMQb2YFTGyuJE2+qNnAvs7ZjvEfM/f2fiZBgS7n?= =?utf-8?q?U6sU8FWfq0HXR3LMsHS4tAU6NFUtmhINHVg9iFGDuuN3p7K9r5+tOHC2CG8z3/1lz?= =?utf-8?q?SxzZUsvoDvJ0KHLeq4M0QlBfaZnbFsh+HOLbvzcs/P6vNURnGZtwsunabfvhmxlWb?= =?utf-8?q?jIyBzqZwJEvrXUXK4RPknm1eLT7yteuUNDi4R+oU4AnDR7F9apUUqwD+ZNQWIwC8V?= =?utf-8?q?ELvjz2fB+ZSG8KlmldFytI66YulKuFixxKO8vUu2DoQqFLRG2oktISS2kMmatzUnc?= =?utf-8?q?Ivdhsfz7WO2mflZNHcUf8w4dXTPaU7DzFlyNGNncziMfVseG51FS1xrcqo5zalbBN?= =?utf-8?q?gdVX4sxEr39bIoCaq+JBjTN/WLEWYWbGbcBG1RoaYLsO8x8/WJ1uSxfH8BNrIH1DU?= =?utf-8?q?7JYDZlRAiY/N/VvbmCnxrJxR3KQYfzAE+s4RBtTk4P3OArcKXzCz951vGZt+M7OAR?= =?utf-8?q?I0ckyaB1bK11EW1cHGOUu99mFfjjfr1RlS2z5WHgZt/6VrDVA4liw9kdVsm9nStpw?= =?utf-8?q?hsTQvhVXOHYG4OKlZf41qnqyrTvHxFb68vWx2nLx67xMsxURkLbyhGkZYopfk9EZt?= =?utf-8?q?lcY+4ZRwFMV1+2v0Y9mg6E27PEv7TtALvfhWu4MhlAo/dau8inCavuyy3ZGdPUoAf?= =?utf-8?q?eZHXy02ps5QOGFy9WF73rdpMMutufSIUl8TMTIhjNFQiDQqWkruNmH1IPh/ZYtyrS?= =?utf-8?q?vCEmcGsntfnNYds0SoWRTS6agspEebe7L/27X3PAFVvnDlpiRf3Qo7aZbqq1JZUAS?= =?utf-8?q?/1QdmiCXWffzFXauAq/57A6PjCPntMf8X4+JWPSF3SP5cLcyGaUQzxD9UVf2HbIRd?= =?utf-8?q?V8PxaFEaglfJsu8i7oklUs3HArm66UoAYbN6yLvT+1YthfqXtkPU6kVYMHJ+oRwZa?= =?utf-8?q?XS5Y7qbZLvj18bt1rzMabm85qhZt+KaAjnuKwZseKw9NsIa4PC1gzdTPQUxG3kgH/?= =?utf-8?q?6qfR/wE/7r0slpdSopzN5cyfB+YMERQTrgBNeXREdlQq79IrfW+Ztaig4Fl9qF6bt?= =?utf-8?q?HX+gpH+SP4Y0yVaItY36gTAJFA/wp0VMxuHZ/o6EB/71HNm9feNj5Kvva/pluvMHs?= =?utf-8?q?dD/U4q2UbDnVtYluo0qh3mGcxe0SLSBtjacREOtaI9HS79UnIX5mXqRn6D5yemjhj?= =?utf-8?q?Olx8JQc0uxtcvbHriT9RE3IFMW81EuooSJsNc605XVnfQOdg10vZ0XWYmp9I2vqDd?= =?utf-8?q?Dn+T/9W8rj58n+OaL1FytKDOWNRP9LZT/w=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)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:37.2015 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d38d4228-dc94-45ed-99e1-08dcfef1eba1 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: CH2PEPF0000014A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB9519 guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index fbdf3cdf1141d..548eb99253958 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -184,32 +184,26 @@ int platform_profile_register(struct platform_profile_handler *pprof) return -EINVAL; } - 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; - } err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) { - mutex_unlock(&profile_lock); + if (err) return err; - } cur_profile = pprof; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + guard(mutex)(&profile_lock); - mutex_lock(&profile_lock); + sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile = NULL; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); From patchwork Thu Nov 7 06:02:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865830 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2049.outbound.protection.outlook.com [40.107.223.49]) (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 89182199951; Thu, 7 Nov 2024 06:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959424; cv=fail; b=s+BDBWPSxqu1QJpZZHyMx8HcB9hPi0ow6Fb0qs+nVIzqh7+EUNkcJxczZm7ciz6hkfR2j+sC1w2mzBOQOGQq8QffSN244xUDQbUVwftu28mgkRM1+0xim3nkM6gsrtY2IxbZkwT+Ne0S0BzVYgl5TLAuc+z45c4V1Ifug04zHXQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959424; c=relaxed/simple; bh=Eh7GbAEhOApPgwe7sJ19hDwugoPdNvuFgJKEBageevo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JJluHLAa3ISo5iznx6e/QLWBZxuqqohfDWzMnpzL9RiKKNfGQVuOxgZG2eMvDM4zaD8ZT0uq4xedOc4PbTRbAve9t/e4bSYc3IopZxAjG+bTg11zDkWdEMxY0bhfakZQOcJqt1WHUagDEwtn3Lg4Fik6MGdX6RJJbA3zHRKgMq4= 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=pPsp9J2C; arc=fail smtp.client-ip=40.107.223.49 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="pPsp9J2C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jp6yA3uyIHUbiNA2u3UPhPt45ry2qCNqqvumWw7q5BTi3Srs79BbK27UwodCrPAQCDz+4stZrJX6+7yBWWFqUlRGXQxZJnvkk5TZ82EoAlRLNNJshuZItGUt5vRBIEZzgJthQXlDVhPNVS2Jul2NB7ZmFnmG5ClFUSb6u7pJNhAqmcl2vn2eUz5NthfAtctUrSmOhFmMZMiIoigJqP+rU2H8PgG2MBqxCDgEmmYUMJG7w96BcluFUbrNvJJEj1XVZ6mdVOvzob6yTJqdDbluLUJFSwpv3XqVAX9fMDtq05AAp3dd5XsTWglrlupVMXSDEHs7Z2ZPKE2vM3Rue9ohdQ== 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=o78hvHLjyjWYhzj1ketM61l/Z9Bnrn7JPtZ4EHIBTBE=; b=yVlfBSqG1vY07IuDrRzMzF7/F2dNxbtGXDw1ZsBaMD/DvVzCYDhSEZs6Usch01igGTKBMAmJe4YERRcq/8T1sM6KoQZozGyLnPRtQrA107wSitqanzTrWeFGiJ1AcarvqWjpFn2fRVqmfTYsz/a6hXQr8vR6hDJx5o1PeD0n15C7qx2/3gfDAeF64u4eZ/yd0CqahK7E6DekLPV65JAWA+rCUpD+8TpQVwXDsGaW2JPyB2UHj59VbOgr042y3vLzCmQuHGetn6iz3KIa261lBQHBliv1TKmLfdFPKI55dKBrPpR2BdMdYwyIo8f6dzKVYZAAZ1S0PLnbct7wACQUSA== 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=o78hvHLjyjWYhzj1ketM61l/Z9Bnrn7JPtZ4EHIBTBE=; b=pPsp9J2CEdSAOVr5c/iRyGfdAu91HjHewI2mrOpwcLAX/F88ghju8eOcrAF4KRFibVdmnq7zd9xb9qFh3M+xoHNe5Jn4ZtRDZw4WrCTWApe9fGx0dgonAkWos/SMHq298EG4JZB68KN9EmZfrKRFweAZzsUqTpUHxAHp41jSqUg= Received: from CH0PR03CA0271.namprd03.prod.outlook.com (2603:10b6:610:e6::6) by DS0PR12MB7653.namprd12.prod.outlook.com (2603:10b6:8:13e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.33; Thu, 7 Nov 2024 06:03:38 +0000 Received: from CH2PEPF00000147.namprd02.prod.outlook.com (2603:10b6:610:e6:cafe::1c) by CH0PR03CA0271.outlook.office365.com (2603:10b6:610:e6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:38 +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 CH2PEPF00000147.mail.protection.outlook.com (10.167.244.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:36 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 07/20] ACPI: platform_profile: Use `scoped_cond_guard` Date: Thu, 7 Nov 2024 00:02:41 -0600 Message-ID: <20241107060254.17615-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000147:EE_|DS0PR12MB7653:EE_ X-MS-Office365-Filtering-Correlation-Id: a8809ab8-8428-4f4b-7896-08dcfef1ec3d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|7416014|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?PKWCB+hAFejG+vXOk4ndjDF83WyPNiK?= =?utf-8?q?QMqnAjgLJ7yUq89rgVI/0sqnPtQ8k9u1am+RSR2CO2+YfDYjWOnfVzNcPfJn3E9Zn?= =?utf-8?q?5gb+r01PlGlwXioWD3O2ZsydaDE7evzZHTMG2jlcF+pDh9t3drC7K+T9aF25c/C9N?= =?utf-8?q?qzAIzpawR/gqlW7Iis0MSU1aXkEQkGFa6q+Bau4PWgaiGoRCGhfQJ6Gu1p+V2IiOo?= =?utf-8?q?96tc7/3NbDmqYhPkDTSEUSBuK8h/xvSBlUzVyhfrADfWjyIMZdNUUVAdBn0Cw5EVe?= =?utf-8?q?5jseBlGQv40+7xsA38DNipp1X18pfDq7yFJhrePuxDnBlH/OQFXEgEaeIvjWp61p7?= =?utf-8?q?6RxAN9cA6kDnYdLjZcqtK0Y1Z4VQxkhIgidYPUkBrkUO5ielRA9+dnMAU/aPPxs2D?= =?utf-8?q?pXhM6z5fNP+4y4Q6UCZ23eM2S1GFh7/blmSlDY8zWUzNE4fZhGtLuHLApkvoHR+gL?= =?utf-8?q?cs0Az3EEK5smbb9omAzV9AUDOOTiwy7fEWAdl9NuQ86dcUBQrQwhjAX27RcOxWEb6?= =?utf-8?q?40OvXwy82tsw7B5IVDFC0FpisNtt5y+9Re0OPuGQ6AUQQtB8VeVYH9JJb+kkb4XjD?= =?utf-8?q?ubV5wBdCJz0/MCzuxKbTvIXmW80VVlStizkZJ9+/QaGI/1OD0T0pCHmB7QEiRsIry?= =?utf-8?q?C2PzN2gedPSmKEMIi9/1fM1JKVrSkw1VX/de0j9wH5Q/KM/W+nrLjC8xQvQulFYeF?= =?utf-8?q?wQ4SyXjc9ke0z+t38HPcBqP3fOyQSrCb+teAh4pKUN1uhYpQXxkeSEsbGcUBLt/0N?= =?utf-8?q?sgKEnopKzK78Tp3U44/B/jjDVlTFeuKvh9Kg/38nXnqs8G8zUurxaXnzgLjradsh5?= =?utf-8?q?6D/jBtHrPBg8YUtpGW49z8+EmBJyTdRoJK1G6RM3dV1HanFyUUtC8ApACjAo+S7E+?= =?utf-8?q?0HTNaxfMno/B/dgT2EgRmUd8Q4snvmklZowlnX1xPL5LaGg9p8ZjU5CIbKwnqopp0?= =?utf-8?q?4ggnG/qCYbgADu679m87mcj2BDPuRgLmsZk1nQ81lm+keJha5PIH3iBdEhXuGRNhB?= =?utf-8?q?ToNAPUuXKw4vJzMjTJpriCk4lufxnRNYgQgBeY286Li9PUxPf8+8urY5DNmG0EUE1?= =?utf-8?q?oLGmc1/QVl+8UgZjH3n9Db9wkKwxcmgA60/LJnftBDHKfoTH41sk/yQ6z4p7v1+MX?= =?utf-8?q?FWm/L8RUNLJToAc/CAWanmKuaDM/ug2Qbtnm3dvVwFt3xNyssYrTdL5FuNgMRIyhr?= =?utf-8?q?h5hNbamJFbBSIA8SF0RKd7gzLVdnFJ22FoZBLqmrDUUnONh+gdo8YmUGLZwSG9Mcs?= =?utf-8?q?X5bu6faSvwnoAGldlgsV2ijkE6UaG5xX26pspHEbqS/RjvnbnrdH8cjequvS9gyE5?= =?utf-8?q?GzhR4WZGs8gT8tTsFWgemHH2gEgM2Z8SFA=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)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:38.1761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8809ab8-8428-4f4b-7896-08dcfef1ec3d 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: CH2PEPF00000147.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7653 Migrate away from using an interruptible mutex to scoped_cond_guard in all functions. While changing, move the sysfs notification used in platform_profile_store() outside of mutex scope. Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Ilpo Järvinen Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 114 ++++++++++++-------------------- 1 file changed, 44 insertions(+), 70 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 548eb99253958..0450bdae7c88b 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -27,25 +27,21 @@ static ssize_t platform_profile_choices_show(struct device *dev, char *buf) { int len = 0; - int err, i; - - err = 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 == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += 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 == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } } len += sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } @@ -56,20 +52,15 @@ static ssize_t platform_profile_show(struct device *dev, enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; } - err = 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 >= ARRAY_SIZE(profile_names)))) return -EIO; @@ -88,28 +79,20 @@ static ssize_t platform_profile_store(struct device *dev, if (i < 0) return -EINVAL; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + /* Check that platform supports this profile choice */ + if (!test_bit(i, cur_profile->choices)) + return -EOPNOTSUPP; - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) { - mutex_unlock(&profile_lock); - return -EOPNOTSUPP; + err = cur_profile->profile_set(cur_profile, i); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, i); - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); - - mutex_unlock(&profile_lock); - if (err) - return err; + sysfs_notify(acpi_kobj, NULL, "platform_profile"); return count; } @@ -140,36 +123,27 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); - if (err) { - mutex_unlock(&profile_lock); - return err; - } + next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + profile + 1); - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + if (WARN_ON(next == PLATFORM_PROFILE_LAST)) + return -EINVAL; - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) { - mutex_unlock(&profile_lock); - return -EINVAL; + err = cur_profile->profile_set(cur_profile, next); + if (err) + return err; } - err = 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); From patchwork Thu Nov 7 06:02:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865831 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060.outbound.protection.outlook.com [40.107.237.60]) (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 D5B38193425; Thu, 7 Nov 2024 06:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959424; cv=fail; b=TkGvmDavkMjgeM55GHIHVl9BKeNP90MgBbFAyzcIt35PgpuvnSViKj33ECFVt/eTGS4twOan1hsn06ctmbnHMGwvPiJ+6NCK9lXXoOAMtPLcLykAE6bbLBs7HNehD7aa9SQSTcoR5P/bzFqerg1Ye/ipfxt4v5mLwTFunnwwlHs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959424; c=relaxed/simple; bh=q9GZvBlwrd92oTt1mnV2lyNEoxYbU4zV1u2AvfyM0ow=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pcFfgm1UT1O5/vjl0qyfBncoZFSYF6kQt6+CpvuURjNW4tnVfX5EIMsLRwwvWJMNLnM4CnGOeZeUZGSMUN8fePJsDK4pIJruT9DLScO4nJplwg4B+ePWuYN51rq0eTYemNlTWkTe5jxHEKeZdhj7Pd3fD6EKF0AgjmXrxduyU0k= 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=khQYl9cK; arc=fail smtp.client-ip=40.107.237.60 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="khQYl9cK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t9EW6nvHB/+V6wRjSlBo15Oid0gL5ZjILbQG98OW78Up4VXM5CuJX6P67kvqyc2C+JXG6BhYxiumbo+3KAdbbi3vl+9j7c1Sya3OIW/u12DfWFVfzzSaYufWkH/yuha3ZpSUFIt5gSGwhq6b7yyMyDv5nMeb75zWkgmq4RWgOJJGO56S6Xt23CKLLIcHq9BR6Qn5p1w+9Dbe7gp339G/RMeaZVqxGkRIY9I3f4v0RGTJcZ2yb4sX5Zie8MvXzi5Fv08N/N/5GKouura+4NjBtI+afoDUseqwWSPgeL9pa0uwCyZlXq0IU7FEEeVjvoFYAocfOMnjyWuR3II6txeI+A== 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=OninPEMgDexlVeaKcBObF+G4EqFFKv7D7USsC0HuLoI=; b=leQexynj7/7qj5y2gyUVffZw8s9dIvfzUd+fOHAUljnov+aZySnkV/J6nfYWtgfdgCsPjlZ+dxqmWvaTJGDznc3/hM+sDk1HPxL5ZVGw/Q9ttwt/dWDTFA7+XeSrS10S/PaI3Wst7L7qEtBOYHEtGIMQRB8vN5T9KyUGlnGYyvznOA9ee7/CrjqD5cYSips6HYYTX28Lan3qSeMXnynycyyI42+l1kjCe4UbO5Mvh9kb4aktDsKZcJKCrTxw6riv58SQla3ZbcKmLVbKWbLxTjlu0GgfUS4dJZrRpY95XQM8KFFXTm9T+sCabh0pKF9P25tLO9P48DHDsPB+qdmTvQ== 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=OninPEMgDexlVeaKcBObF+G4EqFFKv7D7USsC0HuLoI=; b=khQYl9cKsDgAcIydNFuPusSXYYkL8MuxGzrDre4r+dKTPfswW8cZ14DaM//vryEMbpcwWn9VYdnFge/8WcKMHbSM87j/NJEvwd3DdCI1zxSxTwWuPkDDb+906EdwW8VPYcG5KCbgIeT7UXCK2oEG++R5KqtB4J837zOfP5hnOJY= Received: from CH2PR03CA0016.namprd03.prod.outlook.com (2603:10b6:610:59::26) by CH3PR12MB8403.namprd12.prod.outlook.com (2603:10b6:610:133::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:40 +0000 Received: from CH2PEPF00000146.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::cb) by CH2PR03CA0016.outlook.office365.com (2603:10b6:610:59::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:40 +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 CH2PEPF00000146.mail.protection.outlook.com (10.167.244.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:40 +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; Thu, 7 Nov 2024 00:03:37 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile Date: Thu, 7 Nov 2024 00:02:42 -0600 Message-ID: <20241107060254.17615-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000146:EE_|CH3PR12MB8403:EE_ X-MS-Office365-Filtering-Correlation-Id: 1978dc77-2b8f-4baa-a9ec-08dcfef1ed5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: k39CNQK0MeX/GsszhAkeC9H2/rdHmkHTe1/Md37YtRh5M2kP+UeaKKJesGTpv2GTl0Abk453BX09Iw0aZ1e/EIauZjh91IcbiIk5IER7ztMpZ5BGOjyHeTP1/ymygaNbOAiq+uyrgXTTr8DaDxgCjOy26NbKMVNKWjBSMDalGaTSbGyBnuh2qodDl70ooAxynxl+Gpot3MmYGoZ/oi6dYpusd1UoRcuK5/prGD2M2mfhABce7JjRNKK2gstuHimJBNKLaV9N0D1ibNsKlT1JD21eecCK7YvrBnrjkDHYg5ZrCP1VyB43gQOfxoAd80VFzjilZWWZEKxV/1o1XENQjOxeQQua6o0kJ+0A23PDHJAs9zetspFSUWSye3WLWZ3YBWm4kAPg15YHzFwKWC+AgNltZK2fIwgF7RvT72ZskZ7WYViYTaPuF/OlRmuJgngGBj+L8R3ZhhSq4+vZ5AuvBMJtT+RwqID+3LGirytgweWmvFDJbUz4WDuzUdlubhTaTeTqJSvgkvnqxMo1L/iYid/Kmdy67RamsoJ1sXsDeMIwhc6+Fro/2vYqO2TiIjXBihB5oZ7sBqMyOi8gGjlPClGaUjYJpem8Flt5Y2h9nftlHsAdHcKC4PVXrFB3trMI70CKPhQrf0ritLQ3hD9hPRgTBQgKrQmKoswf6Ucc+pM+2fg0QctHqvE9ZHHOQ7Tl9QXhlQEY6rQpyYwdoLfuW7z9Bn1XEWEd4nhSGlEID2XGOLHjsyWq1s2Zf9zl5IKsEFMKjf5SVCcTJslOY7tRaMJqu19ZfARRXJXWoJ6jLFcc6id9oHWp44n/GXb/fdUhxFzKU7dh8FruipFwpBXTnagemFaHERq2F7TZng+pn1Rjtb9MqmbjawFt8sJM2MVP6Jw6sBvj24KdLNCic8bHzBUyjXfWeDqoh4ZNh945GgHjWP1+yRJxnEe/ux/1yTxT5O2SO3p8wbJxtLAi7H3M6J/VQt/f65xNXTH0WhBcHbm64qtf03Hz81L/T+RVkHtuh3uh6dLH3NVuzzz+pzb+ZLmvxFRdDBkorIwXm2UpBKLEpvZRJchFE/5i+Ki5HtdZ2+uu71tVoVDKL3UpB0YAc+1bMtXoSehAfP4XMGnJIyfjgwyD3XU2kZKG8Xs1ls31rI6UvWImj1ER1ItTsDsRgaM9eaMbpufS+Za54puxVJphangLo3JE7bFP9KtecXy0+/JVJAjoDR2TCydBIRpc1GGhuLhJ8a2/WkA3ALp5qQbVDXXF6CMt81XqBrbdmRCqLtpgGfgaWDraZWSiYptKCmI7Us28pfb070dadxQ8TOi5AMUP1rx8hQ4Cr4gHzGK9tiGeswY+fn3rj4Sgd5gJ5dJTKduJJWu2iyt29782yWqkawU3lBz4nbpACV8YGlN0jZX5chhxiiwKCGo7n1DTtA== 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)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:40.1051 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1978dc77-2b8f-4baa-a9ec-08dcfef1ed5c 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: CH2PEPF00000146.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8403 When registering a platform profile handler create a class device that will allow changing a single platform profile handler. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Use ida instead of idr * Use device_unregister instead of device_destroy() * MKDEV (0, 0) --- drivers/acpi/platform_profile.c | 50 +++++++++++++++++++++++++++++--- include/linux/platform_profile.h | 2 ++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 0450bdae7c88b..652034b71ee9b 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,12 @@ static const char * const profile_names[] = { }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static DEFINE_IDA(platform_profile_ida); + +static const struct class platform_profile_class = { + .name = "platform-profile", +}; + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -113,6 +120,8 @@ void platform_profile_notify(void) { if (!cur_profile) return; + if (!class_is_registered(&platform_profile_class)) + return; sysfs_notify(acpi_kobj, NULL, "platform_profile"); } EXPORT_SYMBOL_GPL(platform_profile_notify); @@ -123,6 +132,9 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; + if (!class_is_registered(&platform_profile_class)) + return -ENODEV; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { if (!cur_profile) return -ENODEV; @@ -163,20 +175,50 @@ int platform_profile_register(struct platform_profile_handler *pprof) if (cur_profile) return -EEXIST; - err = sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) - return err; + if (!class_is_registered(&platform_profile_class)) { + /* class for individual handlers */ + err = class_register(&platform_profile_class); + if (err) + return err; + /* legacy sysfs files */ + err = sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_class; + } + + /* create class interface for individual handler */ + pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL); + pprof->class_dev = device_create(&platform_profile_class, NULL, + MKDEV(0, 0), NULL, "platform-profile-%d", + pprof->minor); + if (IS_ERR(pprof->class_dev)) { + err = PTR_ERR(pprof->class_dev); + goto cleanup_ida; + } + dev_set_drvdata(pprof->class_dev, pprof); cur_profile = pprof; return 0; + +cleanup_ida: + ida_free(&platform_profile_ida, pprof->minor); + +cleanup_class: + class_unregister(&platform_profile_class); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { + int id; guard(mutex)(&profile_lock); - sysfs_remove_group(acpi_kobj, &platform_profile_group); + id = pprof->minor; + device_unregister(pprof->class_dev); + ida_free(&platform_profile_ida, id); + cur_profile = NULL; return 0; } diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 58279b76d740e..d92a035e6ba6a 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,8 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; + struct device *class_dev; + int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Thu Nov 7 06:02:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865832 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2066.outbound.protection.outlook.com [40.107.92.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 406AE1D88A6; Thu, 7 Nov 2024 06:03:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959428; cv=fail; b=o9fkBBbkupI4gU2ettFl5vhSEmpiKl0tOM7BiQIhd0PHHFHZRpD5SncjSSY98/N/H8qX3hJg3LWMPNYsMx0oXtnVoxTN0mR/BCZyH8JgPrpfq6IqDo974KlA8FTfHJ9NvGhVAXpYRl6EoZOHVtdmd62oVdsP+UJYeGpgCub/Js8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959428; c=relaxed/simple; bh=OQXVw6u+M7syhHbLbRezlPZA30ypVFVMtBz8NgxSXIk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sf7bldaxDvheeYHsNpPqEgekPvE/gA+SaAVm0b1tcTuiukjiwKhGEY+w1ymNFeCclz1KfUYmW8rwC4i733cTZ8eVdD10JP8ZEC+numxaA1XR6DK77ZdGkONiX3v9/wwKpHJPZPEGb2/AQnxK/GXE4cc/ZDJ387qb9aF3VnNr61w= 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=LtWUhb4O; arc=fail smtp.client-ip=40.107.92.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="LtWUhb4O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dELxqkpltC3sUqSYSutrZqAmdnXVadWVMGhJGaDIufbl//HuxytVf0pMnj9LoaPQjKxCFSLvlf13ywbuP68DaSmzCMbL3H4TmxqHINA0D1Qo3557FqJ183COVsZ4C3MIo0CUnGKi035T/L2Z4U7xaE/vhaG8Bkyv7dydIzbB1CmQsIdixpvOiP2ctzV8bGIgLXAB76w87UIxRaXOR+WWw3RcZWwyZWaXVpyZLbYkyKbx0PcyspHeqqGTCJWcD/YcXkEdtns+8bU2wVXXHcd7izcJ7UiPSgYl2/KwR5C+vpBybfuynFYcN/euE7AffgnumhenwczQBL1OV1S+tqYwpg== 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=LqKSai3N+X4lQ2c3ALLtn0M4GqhAaiwrFQCWs3AImhM=; b=ySL2CPiFT9KbxFAIlMdtCmfwqMROyOV8NtQwlKWY2evn1/VBeCqb08KpydddMJrfkE7WiNoi+4I1vewgyrzZHV3xtIZNQE/lRMc5rb6gHMCY7IUo3hgxM/FwnahxZI1ZqtwdmGRBlGjpY5oFoDU0J02BeGRac5rHHYTPjbsP9G51bM5DjwTnaxxxzrILwsoKw2708aPp7VQkRzZ1enmUUIWLT641Kh+Ju0hrW1ogXa0z25nXfh5jxL3k8toiRRKiim2jj5t8WnCD7vykisDRxihyVqdgW+28Ikv9Vs7IniltPj3M31N0++h3vkao0p6OA8NbXLPkCBMV1n1DysdE5w== 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=LqKSai3N+X4lQ2c3ALLtn0M4GqhAaiwrFQCWs3AImhM=; b=LtWUhb4ODckhbqdD6P1cxX0fs21ztDZpnx01yndOw3zbKWScIylny5hTgl/g5kYbMs2JUjwTKVGynYSXu4YAgyhtep3nkzJ+ZfjUpOKzg8P4UTCCocXUqO/2jCnkhohxbzCq7Z9xHXZWwZQj5SWJJq8ww4iJKk8EflmXShUBzTI= Received: from CH0PR03CA0292.namprd03.prod.outlook.com (2603:10b6:610:e6::27) by CY8PR12MB7313.namprd12.prod.outlook.com (2603:10b6:930:53::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Thu, 7 Nov 2024 06:03:42 +0000 Received: from CH2PEPF00000147.namprd02.prod.outlook.com (2603:10b6:610:e6:cafe::97) by CH0PR03CA0292.outlook.office365.com (2603:10b6:610:e6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03: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 CH2PEPF00000147.mail.protection.outlook.com (10.167.244.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03: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; Thu, 7 Nov 2024 00:03:39 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 09/20] ACPI: platform_profile: Unregister class and sysfs group on module unload Date: Thu, 7 Nov 2024 00:02:43 -0600 Message-ID: <20241107060254.17615-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000147:EE_|CY8PR12MB7313:EE_ X-MS-Office365-Filtering-Correlation-Id: 79b08a48-9931-4637-9aaa-08dcfef1ee66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: zi44XaYeXA0Q/xlwwKJFktFrcXMuuhlWzczoywW2uL+odWoRqXo90Rr51NUBWfKfMm6/ZQRSMrTeL1AcWhydXE95QLBLON3uxcs3SrqKrJ6hcb+48obW3tZUd8uXcT6ksRAEVY1/fuFHXUOcjOHOglju3nvrWHJknWf55gw2OyIhvF7d/jjgcC7gHbWyVP2lkGgmG7V8XebIauCI/ixpVwi3ntcFhMQZx9KxC0BgdYbvUymxx+Z0AwMMJs4wemhpz49BmwYH2XuGF1p+HwfHJtfOI3Uxr3aHahtidC3c9/tK4EC2BwcYmmd2JaacjhRIOq2US/NEZDa1eHTGd/NED4Q/4kpliZwKItnkR528Ge7hs6BNmRG9DGNADkYBJ9AmZF3Kq0BwuCbUdAcnZ+svtEgWB9J1qNzvZr4Xte7/4AWXypUvTFgzwJg8IfmlMC7gBoPr2IL13vwavBCWHgF2XRtSib9ugog5R2po0FAna3LCIadSaCVXeWlrgJ+i2WQLIW9Tmx0Kr4A5oz8w3qsuZ+2omtLzuGfD9/4CbUeh04amtB0ZJmFVooVc6Jo54ViUtYcoCI4LiQEV1XdGuWEyt352Pz9ccxafxy5ikBNcGIK9Wz0NbPV4MDb6FRTDRHuENLVk4W1BXK8CZoNY6PJys+rQZ/1kq2lf9jOEBPvzhB30ulfdVCDmg/SliIHVx+KzBc32u66QdGiyj8iq7+eofj3jyfDYL+PUSGRL3VpzjZCeQYirnBwxUX0oUAvjxqKHBaeaBPIHZF4pwnVsE0CZJjPe24Wf43d4I+Cu0UgqEe2vptRf+F8JZbe/c9xTgzPQSsn4L6Ign9gnY4L/43h/Uwcg8D8qaPFL+D89HUsqNv/4XDM+nHZA90P7LFH0UUdhA4klhgPeufxBZ9bKaL+Od48jw0L/QNiBC96GZ2pqU8Fu7zk5EN+1iltoDXZmYC5VUVJotGRHpOWzU+tsIm6NFVAnIFcvZSf4ODRtOHU6j2DAuDEmtWTmK0zVns04vyjfVaHUDh4h+6y6+VWBAYDwCNnHIS+uEd0A6q6e/3RlJ+TfL8MXTmrvgTN1jUtd9b3pNhxAU3mxNUrUsWpIKRHcoOfVShYI4cSENTc+PLNaL/0pCR0eiSTu0QcD5hf4kJv8coINs2H7YyjGK8xLkbrm9kjwYD4aGrp2RjsGRICG8sRc5SXWG9/3xF80OzHhwVU0+PhHuWIxk8V1PqhcTbo+I64CDERR90whSqBrnrAUZzv6F0blLjBS9pA9P3+vjvDXEf7wEmD4bAPhxynhxep+FAo+fZ5tUDoxg2p6vbh4MO5yxQf7DBonKCZ5zIfz+jZpeO7HsVwD10PKYK2Y8pSERnHAZh6qAgR2r1ueJIei+r2vCOYasiIhxuVQcJ5S2CWE667rhZS2m6tmeLJ+CrDuyQ== 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)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:41.8167 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79b08a48-9931-4637-9aaa-08dcfef1ee66 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: CH2PEPF00000147.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7313 The class and sysfs group are no longer needed when the platform profile core is a module and unloaded. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 652034b71ee9b..9caf070f77f6a 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -224,6 +224,13 @@ int platform_profile_remove(struct platform_profile_handler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_remove); +static void __exit platform_profile_exit(void) +{ + class_unregister(&platform_profile_class); + sysfs_remove_group(acpi_kobj, &platform_profile_group); +} +module_exit(platform_profile_exit); + MODULE_AUTHOR("Mark Pearson "); MODULE_DESCRIPTION("ACPI platform profile sysfs interface"); MODULE_LICENSE("GPL"); From patchwork Thu Nov 7 06:02:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865833 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2066.outbound.protection.outlook.com [40.107.244.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 78337197A7E; Thu, 7 Nov 2024 06:03:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959429; cv=fail; b=e0kCdkgHFm2Decpq2mDzcgbixBVeakTIl4dEFp1pxqn1Oooa0Vi0Ov4iqTTRYtNDEoGIY1ynV1Hs2HnXq2RRBP+hQC+1LOvik/V6NF5rnE2i/gVOPCQvRgJs/cOgaf+kpHMQhyyjhZA7ePN0eOreleexi3tqQZ6AHLXiRgKo5k8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959429; c=relaxed/simple; bh=QsAXOgS6tiGey7CpnUZrLRQVOLxqlxqGQKPNtyXWShM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h4sbd+YOATcAppuZTXP8TuMyz5esmNQ3gE5ija3G43KNWdvcyD1sdEIf1aqSGx4WykUHfaUCjwiTLr2SqXnNQAaEKGiFgxFkHcwN/am4oSMB6lbhvW+mBw2F00EkCSDQW2VhpxmOXkrIxqlKl7JC7kQ9325hLdjHGMODRgIvDmU= 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=tTPxi6y9; arc=fail smtp.client-ip=40.107.244.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="tTPxi6y9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WxgYpNE6fDFh4Tur2mCNxdDSYsox2v2wglHEbEIOtOrCMQ0BlHVB9X10ct+j+tZiQSplcTyVNLZOfK48FgweKx3vlS8BwIMoLcUHhRuuBIp+yGX7zshJfrPqQrauSpaC6XtYpOmymfDgJu8yMwkzqgMf3aBx5IWCUy+qHbkWXuunP/KH7SAD1aFQDG0/ZdAY5rP79mXA0splivmdu8L7e3oWfnlup2REMvytGKjmfaSEmN+f3obhoOJStZrs3tDbRSPhp2ZzVmV6WWNMThlEz0P5WuKWA4y7e+whY8v7lg93jjzULJAjrNRw8VzfRzaPpOO1oruv9Ontml+ZTulbmA== 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=+458Bkc3jM9LeqcDeTMlbe5a/JNm3coZ7L9HhdhC4ko=; b=Nbb/ATORou7SS1R+7B59LBiB+y27GgOglyRbXO4/ySxZr0hQW4moJyjeP09+XpwDvAD/Swb5mY37gao/Yv/nS6vZpmrX9YwrtC2JfODnohdAIxcapvWIFq8/rVZlGV8+hxRQyjkZTMcg5KHu5ef8rrBBuY3XxRBA6hpFFQwRG0exE8c0D/fQ1KfSYxf4//+53CuLaBP6wSIcjb4TRNT+9cGyqjfKDOELw0Iwlk4By4yONwK7T94Oj76G96uC43rbtQMKbHgy3SAxvD8HZdR0HTwLunB0gDofzeQWMtBlWVY2P5NjOvo4D/7PDdRhXHqbUWk1fB6x7kXusy6MEYK6Wg== 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=+458Bkc3jM9LeqcDeTMlbe5a/JNm3coZ7L9HhdhC4ko=; b=tTPxi6y9zCgbwbNHtftWzP2bvyqsylAMaMDbTwcPcJRzHW0c5ELK6+02quMyh4wHYqR9ZcYe2RTcHXo0Yq3D+8xj51z7uRCrV5tqUZs1K2bRzKv0DdlZgCd4Af34b18XdkrV0AP44Qg47TPN/AoxSgK2iO044aEz4sNBalKNtkA= Received: from CH5P222CA0007.NAMP222.PROD.OUTLOOK.COM (2603:10b6:610:1ee::19) by IA1PR12MB6460.namprd12.prod.outlook.com (2603:10b6:208:3a8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:43 +0000 Received: from CH2PEPF0000014A.namprd02.prod.outlook.com (2603:10b6:610:1ee:cafe::4d) by CH5P222CA0007.outlook.office365.com (2603:10b6:610:1ee::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03:43 +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 CH2PEPF0000014A.mail.protection.outlook.com (10.167.244.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:43 +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; Thu, 7 Nov 2024 00:03:41 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 10/20] ACPI: platform_profile: Add name attribute to class interface Date: Thu, 7 Nov 2024 00:02:44 -0600 Message-ID: <20241107060254.17615-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF0000014A:EE_|IA1PR12MB6460:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d43da61-ea95-441d-e807-08dcfef1ef58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: 1FsL5X7vfE1teHQYcy4i2BkLeFd+3KD+zg0ocyRpsy3mr+r0fhADn9hXUkXJTFk11yLKWCyd7ru+ZYumKu1UDW8BzO+XrrOt9zm77POC1fPhWGCVTtzMs5GO/eKFCwdIFazABA4xKNZWqdG8x/g/2DsigOrIuUNtRWP9VtwGtsI6c6HWYiHnUeemWMrS13xaogxmJq48+GFu1OHhTgNdx2jeEDexsa8unMMmhoFXgEmbuHfMb86PDqjrWPbOB8TejOKpURvDmh4NxXOPXXex9NzihvsbH9Av8gCYRZXaSrIRfFxaaDbmV7utuom5rS138IhT2a1KLR5rJVDPv5HdZdffOKU2TJFdvFLOde1sf5cD+yO3t0xlSSlQeJJfbMe9T4Riu/uE7nYKO9xhwWUuwNsMdG4RXc+C2hfYTlJW5cZB3yvDVfSCZDcAbfoFSB0X+kz/kvwRm9UuyZA9Kimp+ncbXd8Gsxiw3CZSUFPJXX9NgbbMml+9bMqbfCHr8hL3dWI2djFuYoCGLKVfjegLelbcPNFnY5uY5gaAjdILLmM2PJghixtPMW2KiN/1ERMEoG6QJouf06OC9A+BiC21/QY1S2X7Y4+t52QY4vqGTfag4tSQopEJIj46LqWSnAkvEKOzgXtdvVkyZFkp4bmCuhqtvcZtX7iGpgvC+WtIyHklyE3HPNeVJxo/GVlEHbTKz6sI+GKyDN7K9h4jGfkDnaPScW+ip1JfAMss0vSKbYl2r51Ki0tOqaSxDX3HH4B3if04lmvMmjic3F7Xpe4Poq0ww8f63D+16P4xCi5G+uH9iXOYAnUU/LXCmxwcU4tND2WkqIjFxFKEFF4xfdjhT86l0MdUlCxZEAGaLlWYUWDw40kL6SKPSHdxcT7YZ++PlwrNLv+KFhrYClmRE17pxqUiJM+mPeim3VAP7p60CFa+3Li1RlRqWtaaumni5fHOAK9w9S0loxn4gNTwCaw/qCgr4QfI+5gKvoW0SvWGHrRuSOhYD5wSnMCjcGUOu0CMMyW1XB3td8DXLa9LeYVYah+qNVSYh5PH3D8xE+PCE7TIsyvaAXl9N/0BVLmE7gf1MRWSAv1W+OAntDEJbqaXIV7xntAF8Ibb50RJcqv61UckrvpWwmv0KafjoaUlHa0KyqiUYieD/wVl3qt/1J1SR2pnWPenuPCeCvUuEh8o9iPhCI7dYZnKox2zCzW73vQ6Yqje3iT3SriHDZ1gWxXGhS3JvX6nNcvLiQzvni1rId7VDBB2r4Lam4REBZq5uDUTJAH5PfpdUOSP5mYOiGF1/Xi2JqCImkjCp272VT7nB7KnPACcsMQdCbCbSfgq0JksMxc+34yaOmSc4TLrblSMHq0R6CRTI9fVNuUWakyBIhhgvITb/A4a4///qtrWmhQ09kuVUfCEzGZptXIIZEo+Cg== 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)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:43.4359 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d43da61-ea95-441d-e807-08dcfef1ef58 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: CH2PEPF0000014A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6460 The name attribute shows the name of the associated platform profile handler. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Drop newline * Add mutex for sysfs access --- drivers/acpi/platform_profile.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 9caf070f77f6a..f605c2bd35c68 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,8 +25,35 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * name_show - Show the name of the profile handler + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t name_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%s\n", handler->name); + } + return -ERESTARTSYS; +} + +static DEVICE_ATTR_RO(name); +static struct attribute *profile_attrs[] = { + &dev_attr_name.attr, + NULL +}; +ATTRIBUTE_GROUPS(profile); + static const struct class platform_profile_class = { .name = "platform-profile", + .dev_groups = profile_groups, }; static ssize_t platform_profile_choices_show(struct device *dev, From patchwork Thu Nov 7 06:02:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865835 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2047.outbound.protection.outlook.com [40.107.243.47]) (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 B21981DCB2D; Thu, 7 Nov 2024 06:03:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959435; cv=fail; b=TT7QzAWHD1/DjsSrOnhWfZowekbM7JGtIGzOHrvEP8LDJAQVX8meC/wJe1YatHBmca9cHc03qRBcPS7ywqJw/jA4xDVA0hLlLH6wZvNFN+BAK25FTTtt4DIRLljra3TCJXwUkCkrD3VRMclcN7ahNBHfL6a5kKIt4/1Oh3y9CbI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959435; c=relaxed/simple; bh=f0l893LI4FVlohn2BPDpkgTKzCKlgVj83c0H0mShSkg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PRSPYj8yExjr11mvKj2MsW2ntR6zAP5gvwKbeK7wencWoVMgAV6IJi6A/Xodx9NIbY1uF/IVHPg2fAB0LfuPHK8jrCzpuLqoO5fJxtBrKEBOPi7mncYVPgu/P5Mhmoh3FU/M3XEmOnWHgUTgRgpXVUmUaDlZfmubIAmqMJVnn0s= 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=E4p/+3fn; arc=fail smtp.client-ip=40.107.243.47 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="E4p/+3fn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EtUhRo0weFmkugPGTsY2jNbMY+SqPf7+c1c9Y4xMaF8wwZqe5SW5UxwY7/RZ03gKEwcsQTbFtJ1NiYfIesgsKCZAE7G3nHSyYajxiMTS4BF2La//lm14xDv3sDzU/nmZEWkMY4djM5ms8JiMeZIZCBsW5/iRv6oDwiaQfdtigkQ1UTXElgr2ZvbD2+GuoIOlQQj2jwEIjt1wID7b9NjTVj3epv9QjAAixWZ7OUDRvlhNLjQ7YIi8WEZV/PgnOv5SqQPTDTjqt73HgBmdCr4HCCAHh/gV3Ttn5dV00ZBucQyWvYsN7yaY3K+E1lv4GxoFmJg+UL6Ds41DTO8xqIkkhA== 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=QKO6ignEE16gTq7imld5NyURl13XVX5rOoT2wTuRBDw=; b=mRE4N4b6NaQJDJdeoM7pM3gtsB1jJQo+LeltGY3fodLFgychmbiKbE1m62/b9y/ke4a5vLrDRRmY/h0jGyY2pAMXN3YXAGqDdQ979/uZtoJyxwA0UUz/7RUa1wbUOmEVcLZDSwqybnMDm502uEfWwJ0xW7rO2SmgMVMOhYsmDi0V5oHF5Ezg4pZCdoxk2CMCMB6V8pfWl8HGi5E7wdDsEJl3H+VhCQVCBfEqnUS/ApWzBxhQPjMhstguJIJXkHm91GXdxY1r716FUXvm48oFnBIeQH+HTPgRXjW8s92rLmPGPeYiRPXLAsW3s88EzReVqAT9CCEakINGtYULDdyuiA== 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=QKO6ignEE16gTq7imld5NyURl13XVX5rOoT2wTuRBDw=; b=E4p/+3fntAzw1IXQzi+JJGYMvEAL9+TKcPGQAkryQ2BhI2HEx8Kcloz8txLB7WO2+QVgxIyq7lvfVGbs5POeJRrhFL2R5hbTdXTHQHBxJM1juw5oA4hRJEQPmzfVU0H/1dsWN7ClDuFz7UOlmkxvEX5fsQ9gl9LZKsDP2tjsYAw= Received: from CH5P220CA0019.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::17) by DM3PR12MB9413.namprd12.prod.outlook.com (2603:10b6:8:1af::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:45 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:1ef:cafe::33) by CH5P220CA0019.outlook.office365.com (2603:10b6:610:1ef::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20 via Frontend Transport; Thu, 7 Nov 2024 06:03:45 +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 CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:45 +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; Thu, 7 Nov 2024 00:03:43 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 11/20] ACPI: platform_profile: Add choices attribute for class interface Date: Thu, 7 Nov 2024 00:02:45 -0600 Message-ID: <20241107060254.17615-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|DM3PR12MB9413:EE_ X-MS-Office365-Filtering-Correlation-Id: 3165bf55-0f15-4754-ebce-08dcfef1f085 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: on4eKRnvJEooSDZCAUkhJ0KEGkE16Ne3EbraH9ZWAp5Oc2QRMGxBiELoC9x34Rg2KzXGSRE5PLtAfKVQsg3tBVdxkpMHNvB+nIFXtix+npNEIo5H3jyO4GDLHpldablw9lJQpjk2FUyvWs2wYYPrDr8KbtyvcMkTXrk5izJd38oxIpc54vHtBqZNvYqJKzU13mJrFAUDiNmw19n743S+YBrlyLpAF4QukT0gvj30dm/Cl3RU83UZFgaUil6bpWfL++Etm8NyolgZwCtgQKQc9jRnUPaN5/7PCnaxAJHg/50Ha27XjyrRu2bmSoeErWvFx7nFjjT5br9oKYkGwCOFOzPU/xhgghpVGjFEwrPwqD4Lrz5644BDHS4NTs/7fWBLiR6DX4koZe6QbgaKD26pwzwOgY9rT271ZplM0fSr2sYRzO3II8b/5zmoz3dBKsuHoro5ySbIc60iheE0arszqTPVTs+tDfvzlIyS4rz7JQe8v+9hXGtm9o16NvXStLZOzVG+QXVR/jCl8NzqiBU/lfJT7EdBAIQbFgwc/Tkuo0/xCRdhB/UvVxFqy5jfRPPhrFjERa4/X42lw5LcPoNk8I77m8rDKIz80jGpXocAEE0UIE9bQenEe02zjno89451GNtjle/6Ffay6jCUHO+U3IPctUzvl2zk7jDvMwClWNS89IjplY8f+Uw/V5n8phIrusZf4bHJRps/RgYCS2UZmk5pl/vIQEsekAZ9aE6W/htAuN6oVEVPzSncicIQGMC4Qe3ziO75ALb4NSuGT6At/nPbkW0fW42I+3v3+mD2Ub5hx4OAdGl0n6FywPTgDBtzy52Vlr/4rX7agvU8/ZHfvIAFEf+o3+9u/bOw94xUGVOG78cXR3jJsaUpfVeRwffSzYqfSBbCaKQMvVrhi1kV8FK8cfLMkGWsrY/ui7ZwVoC2c1ypnqvCQ8TroCpis4soPkBfQCYPEJ2twacYtvqAyM/mTdQmYC4uFgMJCK0H2fQn0aKUnMBpMmZozg0G7zF4e2j09d4GRFPfM5ZZnIKgcTy1NHpgFyEL7u/qJcCYTOBWDaSm7nfhNxh6+bHv4stc1O5YA+7QfisCaK9OZ7M4PxPy98cLhzoGhTHizibL8qNQ+CGd6Ew0WKZWEcpqHQmwTTUYM4WuFpWdjYIpGwpVwVpHXmg4mEfwBwjs/rpMQsrgTHdkeu7LO7XV+2cl11EpKbG7lS9RHuIGwE5wPdIqrntZ68ayQhxT0ImBbpZj+nvcjkSIQ6rOQe9bv7IVfkCOPGt/yxi1npPMb0XI7OWnFD2vKHz5ymxzK/stwRXEzBfZJP54CKG44NEEV2aih6NrTCibUUdWW9xeR9TWaUyMdww3STLIcXo9uOxfFclEUAMOjiK6rKk/9v6H03rgdVG32610L8juu0ErOtCywl836g== 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)(376014)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:45.3305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3165bf55-0f15-4754-ebce-08dcfef1f085 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: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9413 The `choices` file will show all possible choices that a given platform profile handler can support. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Fix kdoc * Add tag * Fix whitespace * Adjust mutex use --- drivers/acpi/platform_profile.c | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index f605c2bd35c68..5e0bb91c5f451 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,46 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * _commmon_choices_show - Show the available profile choices + * @choices: The available profile choices + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t _commmon_choices_show(unsigned long choices, char *buf) +{ + int i, len = 0; + + for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } + len += sysfs_emit_at(buf, len, "\n"); + + return len; +} + +/** + * _get_class_choices - Get the available profile choices for a class device + * @dev: The class device + * @choices: Pointer to return the available profile choices + * Return: The available profile choices + */ +static int _get_class_choices(struct device *dev, unsigned long *choices) +{ + struct platform_profile_handler *handler; + int i; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST) + *choices |= BIT(i); + + return 0; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -44,9 +84,34 @@ static ssize_t name_show(struct device *dev, return -ERESTARTSYS; } +/** + * choices_show - Show the available profile choices + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + */ +static ssize_t choices_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + unsigned long choices = 0; + int err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + err = _get_class_choices(dev, &choices); + if (err) + return err; + } + + return _commmon_choices_show(choices, buf); +} + static DEVICE_ATTR_RO(name); +static DEVICE_ATTR_RO(choices); + static struct attribute *profile_attrs[] = { &dev_attr_name.attr, + &dev_attr_choices.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Thu Nov 7 06:02:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865834 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2080.outbound.protection.outlook.com [40.107.102.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 C3DD9194A44; Thu, 7 Nov 2024 06:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959433; cv=fail; b=C7ZOaE09y2M5DSuoAjjxFS6v9nMMWZXhYh+tRjhDCrtr4Eh3+bHC5TJdEzt+418RGrzhAUQ4IYGIRdPVX51YxDgU6IH3Ybhy+ao8ZUE04YndgWVnKxPVNBlvtp4hzuGZfmVOT6EWiK9ayuwJ7wvl77HGcHfAaRwNZranz+O9Gnk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959433; c=relaxed/simple; bh=/J035DqGcKwrpg7UOyQsQjC7qLIPU4AKT/W+VfqOGHY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kMQM8Kegj2ypMcJVys6t9eb4NXl/L+JP0HNoBKve+DKr2t24BNTiu2GHGfKX6WgQ5VJIXzi+bIXrrggZ8XY0zoq+GjE1ECMb4cCEXwPHZ5cVLWmWn74W4Tddw4I0l1iqwqcSUcLJ1dgWhNvYpXzcVjpY4xb8/+Hwf9lBfgJsYG4= 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=czPmi3XN; arc=fail smtp.client-ip=40.107.102.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="czPmi3XN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dFG6mHH4cdIO0naquAZhil7EqDfFb0Sc5xUXe4wbKFFBA1XIRgi8c4H9bpwulfW6AolClrvcdeFYM19e9vXokjkUnlHTWasFbmkEZCL93ghko/LDQxzwYxVstbZuPZjfsKSbe3+XSu8qvtLqiAF7qkYlCK+o790qqKaJva2u9OhHCDsLwjIRz4od2eeHeXWPsNb2si8Nr0wRxa/YBCaIjz9LBX1qu9ciz5bouwrI19WN2YjOzOiTQx+MpMVDxYr+6MEN9elZCgmpY750eodm9Mwpz0Ibt3wV6hFs0sWWibl4ai39e/iX0jB+6oiR/Gn9TJfrPTQC4dcCiH4tZFjkZQ== 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=0XqfiSKg39ndSnN6DpO8ObLRygWns2SrPtfou36eZxM=; b=Nt3MlfqUsjQQ6KvsfztxheXUmRYV1XQc/Gv0ghOvRNbZzn+iYA2Y+c1xTrlWZfzVJ1kXODd7BpiyHMM7pZ7kTGecEmJqs+y1lLM6bMLebqtTt38R47Y2b2+kACOLmgn3rttHnRhT1PWJChqMjx0OJzWQ7EISbxMnix6qS/pAfcIz7N97Itzfa9MQ6qKzB+SEp0mwC4ad2ScCcoDAO75AGStWpitwpXFItkxvpM+PEP9yCjoDegDy8kjdN9qZ7NPJWYT+qbi6UHOsbQE46hOjaLkCfuGfmLkAnLIMMnX+O4s/KahWNtzS8xvNG+bxW4kO3z0+3Ue9fNTJBhvGT1c3AA== 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=0XqfiSKg39ndSnN6DpO8ObLRygWns2SrPtfou36eZxM=; b=czPmi3XNuD/XXZR/cyQb7PPwtYJG9Z5zsnJ1T//gbJjdS9BKeMmGBLoyNZCtc4/WWLhDPuHbX2dXLrPOBhWCJ7wZbj2s85GZ5/CDB3VRgGQb6z3ihq5lSJS0Id1hLCPDtR5003Ft1oZkLym0C8ZMIkN34wAhR+Wsja87fI/fmYA= Received: from CH2PR07CA0008.namprd07.prod.outlook.com (2603:10b6:610:20::21) by SA1PR12MB6677.namprd12.prod.outlook.com (2603:10b6:806:250::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:03:47 +0000 Received: from CH2PEPF00000148.namprd02.prod.outlook.com (2603:10b6:610:20:cafe::41) by CH2PR07CA0008.outlook.office365.com (2603:10b6:610:20::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:47 +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 CH2PEPF00000148.mail.protection.outlook.com (10.167.244.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:46 +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; Thu, 7 Nov 2024 00:03:44 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 12/20] ACPI: platform_profile: Add profile attribute for class interface Date: Thu, 7 Nov 2024 00:02:46 -0600 Message-ID: <20241107060254.17615-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000148:EE_|SA1PR12MB6677:EE_ X-MS-Office365-Filtering-Correlation-Id: 104e5c5b-4d52-4539-d8fd-08dcfef1f176 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: H04FeNJN/hxjT5+xuSQE1Oxv9/DhQGnS9bNYNuFQ4mzksSjMcbTW9TRT48W4po0Km9VJdMNulqmOgbJsGLnMkOBknQmxVsiDBOq4N3x1oCgyfSlIELKCNYHpKCIM4ZNSZP8xdGrwdhC09/EvhsEpc0XbUP6gt7vUx+tSPvvbHAoYYoroZBNSTdsw8Hj4O5mbWJghs62Ifpho0pz5QU670HwjDuwm3dIFoFQ2XFE+Tcn4CPEpAD9prGmdEiJd32mFr2dWUeTFDtkjT/dDGGmdkpMSIC0vJAJIarJORPnYjo9k8bbukk4gZuEuKeVLHW4jDEfx51inzax66QjoTEZ/k45pSuyAQOOzp9UVslIA8xc2hVpo+NDydnUumUtPaT1GDKNndB9TBvoKHg2Llh8SvlXgFLldtfwBfaGili7+/KzrnJaRsBR/XFuK5h/GpRP9/Er0FYq/BpSiX3vL1B+lPDKjUVZv2qVocxtDdDyL06sCE0JOXG3dknL1TAUqN32n2StZkEWL1UG8Rx3HbGp/XdL19A7ZX6tqDckJANse0R58yGWRiXVWfGROp32QbAb+HuDoVJt8/WzLVa51LTxSUVIuQtEiBKtmj3C7Fzbs5GwtQPoHSxh8sw45xdBGp8iEoUebmxu/Zm453yHn7h7GjwmhTM1aUKMXdlINSfAPCIstYCNFnf7UdkWBJp4pm4XzkFyGsdheS1LRizwWCp8tjEP5FH7Vpe3PUtsC3lfoSc23UoDTnpbikZCrjCUdgeA9xe8xhtVsLr2OdKTgHt0cWBxajDj/dYQyZwAUGcC1VGwCNpu42nPFJjPMUmdaacDX+rGPkYefdIxWQoF0yRyCRYSpgIP9/X2EMueeD4YuVkEyr0cbfQKvQVK9GiEj4bM6kruCQcrvpjZPjYfkOONJ7cVgA9vZ26w6zMdDweCoCRIgxQBZJGLOYK1Viz6/s0dEuSo5Z8v+GGn7PPWdFF58VhHvJgmbd5/m99iXcgVyGIA3TNE0ocEjryFl1dXZ2yz6bqKIXdPtDpyPFnMeu69DLUVQAC4Zq+NMkfYmCjhgqP8n/2Hxzj4TVT5p2DvRagHsirvKAGXsOHTqdIvw7l9l0E1YA4JgV4c04xlflNpi0EHaayCylMuVfQKLirtoI/D/bEnxEgbpYYjBx3iBDOYpVSZ9aRGGOOiZIUjTrwZ/IQiMPjIPlJ2gStg66BArf/2e+isdvY+RptC2LKiolz1NLFvu3lfthEUWSswd4sXYJzpKqEtryT3jFy1ewAMFyp57Pr0lJhJaShjpiGng26tFdp/HdNNI9zDZJeUOIDpfaPkU23HRTAqRA22wkz8Hw28LZvCmrHRKcN3qjrlXQVjmkWTch3KZ03/F7fZo/fZN06y3dui8z7vzDQbUldtTy79AsfpdpqApRcMbJhwWDcQyqg== 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)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:46.9253 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 104e5c5b-4d52-4539-d8fd-08dcfef1f176 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: CH2PEPF00000148.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6677 Reading and writing the `profile` sysfs file will use the callbacks for the platform profile handler to read or set the given profile. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Drop recovery flow * Don't get profile before setting (not needed) * Simplify casting for call to _store_class_profile() * Only notify legacy interface of changes * Adjust mutex use --- drivers/acpi/platform_profile.c | 110 ++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 5e0bb91c5f451..35e0e8f666072 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -65,6 +65,62 @@ static int _get_class_choices(struct device *dev, unsigned long *choices) return 0; } +/** + * _store_class_profile - Set the profile for a class device + * @dev: The class device + * @data: The profile to set + */ +static int _store_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler; + unsigned long choices; + int *i = (int *)data; + int err; + + err = _get_class_choices(dev, &choices); + if (err) + return err; + + lockdep_assert_held(&profile_lock); + if (!test_bit(*i, &choices)) + return -EOPNOTSUPP; + + handler = dev_get_drvdata(dev); + err = handler->profile_set(handler, *i); + if (err) + return err; + + return err ? err : 0; +} + +/** + * get_class_profile - Show the current profile for a class device + * @dev: The class device + * @profile: The profile to return + * Return: 0 on success, -errno on failure + */ +static int get_class_profile(struct device *dev, + enum platform_profile_option *profile) +{ + struct platform_profile_handler *handler; + enum platform_profile_option val; + int err; + + lockdep_assert_held(&profile_lock); + handler = dev_get_drvdata(dev); + err = 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 >= PLATFORM_PROFILE_LAST)) + return -EINVAL; + *profile = val; + + return 0; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -106,12 +162,66 @@ static ssize_t choices_show(struct device *dev, return _commmon_choices_show(choices, buf); } +/** + * profile_show - Show the current profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ +static ssize_t profile_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; + int err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + err = get_class_profile(dev, &profile); + if (err) + return err; + } + + return sysfs_emit(buf, "%s\n", profile_names[profile]); +} + +/** + * profile_store - Set the profile for a class device + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * Return: The number of bytes read + */ +static ssize_t profile_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int i, ret; + + i = sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + ret = _store_class_profile(dev, &i); + if (ret) + return ret; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + return count; +} + static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(choices); +static DEVICE_ATTR_RW(profile); static struct attribute *profile_attrs[] = { &dev_attr_name.attr, &dev_attr_choices.attr, + &dev_attr_profile.attr, NULL }; ATTRIBUTE_GROUPS(profile); From patchwork Thu Nov 7 06:02:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865836 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.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 99C8B1DD0CD; Thu, 7 Nov 2024 06:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959436; cv=fail; b=CjzorEdpzb5e8JG/Ayctd8S1lzoG/BP+UA6jUbYE16lvMeH5rOs8TQMT5Q4c5CppUTOOJlgXXtTgX97ujkWPA1Kk8ftjIIxFbl0naqxnHVGqOq8tGMdXnEhqmBnJCE3wTuT/jpLN8g2zY84d06aJVnwLTnvwr8aKQNDWzjzT1qo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959436; c=relaxed/simple; bh=ygdLyhxsL1E6CrOOFkf3Wil/fb1df9UANwK8eafvuvY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Et5QoEMX5xj5Cu2essp4MKAlx5GzjE/Am6L7q5vCxshzRSZgjuxpOsaa4XPQqiGA4FBDGYFn584Pd2sCnI9SuuTZ1oJIzQuPC/cMKNpwcx/OgXETATMiLMev4DPwSZ6HX3sOImOSsrv7Tw5S32XzWxolRKX2uuazid7+eoVQhD4= 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=DTzrAPBZ; arc=fail smtp.client-ip=40.107.223.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="DTzrAPBZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KXL1gWWOVhTnceKCf+EzUDom2145JrWiXq3dabjVFi0zdREDhXk0qrSzrXWXF/qYGKni3Ggh+Zupt9RVuEjAspLFVxLpxD0xy0iCy4vX49cG0nW9qOTe016ElC7hhB8HWjG8xerfoqeFwV4UAqL9USsOEEtT684ur3qI3ngoOrXN9rNy/an4oFaB6pp87Aq6TcsxLMu/DjN7fBMlsVt3XGwsCUiZ/2VjjF78udnA9o5iNi/gqVbdX+G9IXtvVr5HR+nwK4cQfuL+RTVB1ebpJ5Zibee0qoIvsF1I1Tg2zkiM2hkHlwoljSQwam9qDsI8lVGcXH1FK3sYOl1AoNRTIg== 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=pnoVOYlNJzRgfMoBu5KuIPp1sDfmHYMmm89hNzr+CpM=; b=fe8f55Ib2pPr6wKONaaujDp2k/clK7UU/44krhJdBoaIheZa2MJ0KvARjjLHDfMxuc7AG3R52KY/twfpz1cXD+z4nS2U6K81NYM/ay1kHVMIiCOz1xaFVgpx+K/F/vNhS6PVjbyTq3MoiEMMLKJSK3hp2mmfdvIJxRbsrWdnkqA+oGlBCs4lpbU4ItvLqb212VIV8PTdcnaSqtvEmufjNcFertWupXlXzNBKiFFfGjXtxtpa0mmxDJRa/uZu1Bn/8z7ULwlLV92zRGEfbXNaco0Psevbbz2dnCVbt73F8a/aRQbQV/qqYpj3PZ0SrUtXoV2aCWSl9HdJv0TTJQ24eQ== 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=pnoVOYlNJzRgfMoBu5KuIPp1sDfmHYMmm89hNzr+CpM=; b=DTzrAPBZ+ULPzxDBxZsYnbrXJ4qgNW/VTuQm/mVhI1PShL+grkFwce1Zuy0sDrYkCKvF2ozvza20MYOFsUUXXuAcotQnSGTJo2LGDC+tZiaDnNckqI5nd9YKw18BjYIAABf9nOY94CRWHTcCAfvWKJ7tVfH+yWVZbOOnuEDtqOw= Received: from CH5P221CA0011.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::21) by MW3PR12MB4428.namprd12.prod.outlook.com (2603:10b6:303:57::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:49 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::4f) by CH5P221CA0011.outlook.office365.com (2603:10b6:610:1f2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:49 +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 CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:49 +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; Thu, 7 Nov 2024 00:03:46 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 13/20] ACPI: platform_profile: Notify change events on register and unregister Date: Thu, 7 Nov 2024 00:02:47 -0600 Message-ID: <20241107060254.17615-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000143:EE_|MW3PR12MB4428:EE_ X-MS-Office365-Filtering-Correlation-Id: 5fbc2ddb-161e-441b-2df4-08dcfef1f2b4 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: +sp6/TA46r8xwq6cFouHZxXimImlWxYlIUWC7WFkVcKa9F5y13h1/kUVg1suI/cQ3m9KsYS/4VnjRh8MrBgcpXMNjW/ZQvL3BVd4CSPP/suzvA8WgP4DjNtSCYtk43lg3L7K5vL3PPDEj7kuDpYvnvvyhrxIK9rFFhblmQKLEokAIjEn9Dl8w3GcfmDvxwEJiuV9osWL88yLllzoAjlBl1oKmaVmqCZ+AGdiFo2nfnLZ8PrXich3Yv+kVS9e0Jwph9Pdndu05xgKAg+HFq5WOWPuQ18y4lXQ4+UZFQhmFCinkap4AhM3gCtZ+jpB0VBfW5UQEBAfoaP2k35LnjDwHPb0oqUOuKpp7rt+7KcwvAOPVQSv0iIKh/urvphL8H1xVX6oaT44Efr2rahcBQmkHTgsCv34791RLXeKpdQXblKKq7kwiy5Sk0cWyube9cloKXBYZciJMP38pZ/SAmjC5MAJGuKVBJAyau9mMQMDp5s1JJwcnEIsq7nyJemQOpVZa8x1Ha4J1PR4wHUNFIJ2g7Ahr88DqonUEzxioP7tiwBJLEctfaBf3YbBHuE4VgCH057otCSuhVSAd+HpZrUdyAPMfY2DX4nzK4VrxntDSx0bYMcecIGQ6CRdHk+dpuX3z9SDBtI28p2X9xRaoIdEmb7y9TDkQ09nC/FKhBjDyiXowmzKJX/dUCVsQdAwcZpbkGPghioLDkVLUJe5k3j8RfKPN5nfIY5hm17Ka7mpb3CbzP5NDu/SR5wlqqSriML1XkuE+95NqLB15o0stDTjghpWDak+tIWI152Nf0esPivRvPV3pMe58hTWUO26ZXMky7aK1m8+n41IH3/7bZb41aPHdTbchP9VbcxdZMzGXtnVau8KbikLrwq31bIHEP2A3oCMgIoHcjMzPJTNnS9rV41Hn02VCiAm0AYbkp7TuYl74v4ofjwm4MqGi+7CZHAHAIlxp//3Ahm0y0lQMmV8QOIR1He3JOzJsvr6+PllSo8ctF/a1dSLNI/6Ecx3fbH3eCxa/pCfd8zw7uruv8/PZ4glJcU7Pb0BRuUlRuL/kiEBkIHfk7zgQNx3kjQiYl7m9XnlZkZwUpETRSBMUuQiSLbEI9KxsuvRkXX165LEibF7yfpQbCk5Ch1v9hwBTcEwfpaaXVzB6WaQo1ssZ0xEoFEAXUEuhMRiHUa5UBPhEKTW0meo6B8JmxkOPS2wU7J+2A5ES54sMt5Bd7jxaYyM6OvMS+blqEdZlnVzJksms0PBhY4cpO5Z47dEINTMEfd1lQMZB5zVbNYLZecSVVWuetvzGT8CDgrDKgohxHJzzPghx997HqE5IRnyur95vVzUdKZieYqE8LLMJ9mFENffYhZnhC40K8NQpyClgGjgWjZuHbl0rQGozMpIzhKrpQwlvVH5cSm0DPXte2/IPt6Jmw== 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: 07 Nov 2024 06:03:49.0360 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5fbc2ddb-161e-441b-2df4-08dcfef1f2b4 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: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4428 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: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson 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_profile.c index 35e0e8f666072..510e1435d3980 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -399,6 +399,8 @@ int platform_profile_register(struct platform_profile_handler *pprof) } dev_set_drvdata(pprof->class_dev, pprof); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + cur_profile = pprof; return 0; @@ -421,6 +423,8 @@ int platform_profile_remove(struct platform_profile_handler *pprof) device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + cur_profile = NULL; return 0; } From patchwork Thu Nov 7 06:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865837 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2072.outbound.protection.outlook.com [40.107.237.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 0C27A1DD525; Thu, 7 Nov 2024 06:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959436; cv=fail; b=XpMOKZ+C4KWcs+emPaMnLilWVItYevmyOB1bac2ngQShm4rahy9i13uKNc8dFBpdmz8/S/feyN0li+zn+mSb/XhrANTElruJRf+CILj14yOqBF0UTCfUL60c8C23cTnXtzZmm121mllGVV64VJgmJ92ZBpyF8mLVIMFdZ2Sbqd8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959436; c=relaxed/simple; bh=CTLNKCXi/cTsX4LriEwKBmAvKy6FoN1XxY8tEauqe5c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BCe3Y6hleGsWHiiMkZlFB81jS6DlFffOwN9+wnMtRh+N/vvpX0+Q9m1Ln7fuQcwLNwTOoR5kKujJwOKPVF0C+qlFCtsFYcKORPTlj7YL9i9giYNSIFOQMFetqNDSHTzZ0pJozHSaGStj9SGV3QnXLxRa/xxX2CHxWflx8cI0rC8= 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=D8WKsheZ; arc=fail smtp.client-ip=40.107.237.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="D8WKsheZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OdL1Knf0UGpiuc7UzbfzFYNboJw3VQxlEUjAqaKS1VLEl6KDnriNgGna/gJkxbFhFZLQceBRXFSmIO+2B9PKY+aZmOJYXVrixupINlJpWRkBx8uDZ+SK0uOD0ueWUUrN7cWARzoL271fc32Ewwv7jtQ0cEZILja6yeq5XVrQzHyTSUrHmU0bJSMmcnASF/D9Ppi9fPw13Zct+/bwPn4CRr6IR6o6hPb/0mGX1RsKkPXGZvXobw85thc4MDkRmpidMyqIkmxb4I9h7J0ZlHxVh7MfRicZJ2ZlKlRtLQ8OcA0W7gMH4bL/6skJ8MZTO3CPXa6/fyLdxTchCqOO7u0JjQ== 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=Ef2WNmNYKfJfZZJpNE5oKPFeLWiXbAbe7aodPN6BEec=; b=EBJTBXOC/dBeGCmTrN+0aphuym1RfnwrHyTXg346BKknl3CyTRKaHiKVCZVjhyrXnCelYQ/AnG9nPicQOCUDEPDTAEjIMsAkr3DdKv05eJG3J0Dd4tsqyKIPsk3oFID0rCMdhWZza/FuDxXn3Zp5ZC5JEg4wuuQdB2bwAo1WDPxoQEIe0ZBWoZwQtyXbq2ayqafry2+Adf+duRhmOBfU2fqn7AoexpyOD6Nby1zx+iSZXOZzsoISadklZvUtYZLr3U+ym8c+gRQrAoF1nkz4+jA/uqzROOu/d+JjLW2yKXqJd8V/YRIyMQZwp38UFfGT2OvRwfCW+jcbOsXuvKjwsA== 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=Ef2WNmNYKfJfZZJpNE5oKPFeLWiXbAbe7aodPN6BEec=; b=D8WKsheZNSMTu7ntmhdrQCJcXWBy2ZlHiwxRNSPIh8rgGmMp4mCBXw1PMa8dT5qd1WUgB9HnNIk2brU6BjbquUON5nNRpV4HP9wOP1fgKZWL9oHo0QJ5fBBIAFQb0+2L3cU3mM9aFUABu4D9D/DNHn+eJTnC2/T4ZIX6ql8Qr9Q= Received: from CH5P221CA0024.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::18) by SN7PR12MB8130.namprd12.prod.outlook.com (2603:10b6:806:32e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Thu, 7 Nov 2024 06:03:52 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::17) by CH5P221CA0024.outlook.office365.com (2603:10b6:610:1f2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:52 +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 CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:52 +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; Thu, 7 Nov 2024 00:03:48 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 14/20] ACPI: platform_profile: Only show profiles common for all handlers Date: Thu, 7 Nov 2024 00:02:48 -0600 Message-ID: <20241107060254.17615-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000143:EE_|SN7PR12MB8130:EE_ X-MS-Office365-Filtering-Correlation-Id: 40b61abe-03ec-4110-c9d8-08dcfef1f476 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: 53lHTZo8s/T29HjqZxqr2mzb11uv4fTAjocPEKBfpnZWnICJ3ADG+krNYcw20d6Sq3BIw807iIMH1UFleTjijEMPwjBJOML8qtGzWEV5Tux1wMJcwTCBUeYsigSfMv0UgOy6cyVLRDB9yh3/zVvcA/A1pSzZ7GsLvGVrttLXYgykJNeTAbdi3m/bK6VLlLcIS1IQ13R1NInBzWEEFPcoYnpnXm7hIuRG+H/A7fqb1CPwkh0CZR9/EICVARjRxR4dJOmtzQgfJK1WAkGShjYJiFBn9stCXV+9xG8uKz41c53SjlwJf2/VWL/GlvA6guxUPMjFsyx//8KObX11jrr1iXfibZyzI8oUqL1rsGIUoECJRi6XSLe0ZBJQpQE8I77RolpQ/OOxP3jbQKwg9yskn/km4pYyGqVtq+g7pTk0csfz4AZkZRQ6OLOAJHOlpC3ppJb5R8rFZGWAzJjM7UDqkt2D8WDuaSJ98JmdwcBDPJUHiGgULL7oQTo3I1zgFQVbpQ9VYtH+R4bVk45kQTlqxSWSI8qZP65Q1fA2hXLOn1kcWavxjLr+iW+aZRX3Ten6YWDu2GDpcPAhH9kLkryyrtu0glFc/Q9BwMUNelmWfklyQdMdMRRL/c61zBCHkxAmjda6OybE8MLl6qjTNmUniojGgcHu3W1+HbdGnEeMgK2EKvudf2NrQzHbdpVY64tU4FGTHTb7f8Hkqc7jmDg3VIskZX4+aoVHbkGrEsJr7wzM8aeZDCe1/xyi31ugTBKOilWAXyZjRsiEWssGpblMkL0njoW3xZXwoAy2TQoblBF3NXsmmBq0+jcaM1QRPn2NVQzLmLDV23zbuFKn0+uY7hQ1vv1OwpHtX3PGfmKTfz5MP+6OBhZeRuRjAneg6CXOEMSImALJwTgGE9VE+DvyrTwhyvM6ot3/iZCgQhPlktf+Q15RDdEkqLunDo8qywod4AvoZ8sr41tLUo7uyGKIs6XpgmDnaTHm7p7AK+39g1pA7N1+pkn/4FNYYJORx+3YiugB1E4QIu0ptJ1XycoLbfcazT7ItUM3Q0Pp1NukmcK6QSn5UOd3UEULuUmrO0Le7mhkBA8ruR7Z0GhI4jrC3dAsxmCFrsCDOWPTzuq/yo0yNiSQC/NBQJALYQ957UaoRqSfy/AB1F1zLbDFjac+stivSpy/vVq3ckfzDb3ou+hcNfVRgIVyKaTIt3NKPGk3b2XxvkBR1Xsis82dqBhcZHgYyKn7/gTkHD88XdO5pAz/9klHuSaNY9b0kA9+/WFjKxF7731W99cZfwrihRt1UTVz9+GxTubazBVB56BRqnMZIk31z0CK4Lic10csQT2VIPhLX/TtoteaQQZvRvcuC4tL6ErIqSRs59TFL1ZKtAQwqSql/372KF3JJMRP2Tt/CNtIe9uWfElK6ZFMmeXUkg== 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)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:52.0360 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40b61abe-03ec-4110-c9d8-08dcfef1f476 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: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8130 If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- v5: * adjust mutex use --- drivers/acpi/platform_profile.c | 59 ++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 510e1435d3980..2ae0437623abb 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -231,27 +231,56 @@ static const struct class platform_profile_class = { .dev_groups = profile_groups, }; +/** + * _aggregate_choices - Aggregate the available profile choices + * @dev: The device + * @data: The available profile choices + * Return: 0 on success, -errno on failure + */ +static int _aggregate_choices(struct device *dev, void *data) +{ + unsigned long *aggregate = data; + unsigned long choices = 0; + int err; + + err = _get_class_choices(dev, &choices); + if (err) + return err; + + if (!*aggregate) + *aggregate = choices; + else + *aggregate &= choices; + + return 0; +} + +/** + * platform_profile_choices_show - Show the available profile choices for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - int len = 0; - int i; + unsigned long aggregate = 0; + int err; 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 == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += sysfs_emit_at(buf, len, " %s", profile_names[i]); - } + err = class_for_each_device(&platform_profile_class, NULL, + &aggregate, _aggregate_choices); + if (err) + return err; } - len += sysfs_emit_at(buf, len, "\n"); - return len; + /* no profile handler registered any more */ + if (!aggregate) + return -EINVAL; + + return _commmon_choices_show(aggregate, buf); } static ssize_t platform_profile_show(struct device *dev, From patchwork Thu Nov 7 06:02:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865838 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2064.outbound.protection.outlook.com [40.107.223.64]) (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 451A01DDC06; Thu, 7 Nov 2024 06:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959437; cv=fail; b=HclJE0ASD7ccp8d232wIMpnrXvVvetko73xXYAXDCtpqNN9UC+eUy0QSc9DykIVfpPrm191lU4oYJBWCkeSTxd0NZyT1CmP4oFBG1K/MlsBRMmswT2n4DpkBqeBaig8H2V+FJXKZH4W4e2WLAi+IFz/zlcT07TkLdHzItgo9BQw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959437; c=relaxed/simple; bh=0CE18Owe0jR089hDMR68XR0Uui1Chr7ms5oQtc9in54=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ePsKmVw4MAx//7ZohNZ7CftLjwYNugXoV89g7yPUUDzIc75JZ5jQs+Zq6/TgbMhpOSiwx8alb5plB10HbTc06Piazed2KGOYRp+OIog3Vl6pnu9VAb6tiWAA2/IU4drmTkxrYrixEVKI/mTJvMovk7Ih0oNcBdltY48kJN2w1C0= 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=3bvoru3X; arc=fail smtp.client-ip=40.107.223.64 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="3bvoru3X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ikyobXq+DJSagPh6JbiR5TesvaisuOAtXnlCMlo+wYAkZ6d1zKgVzZ+wBZmu78FnUfR/6MRE6O+ZS5Aurm/M85HtSEM/XAPwXdv1KiQsGl1DadFzYfPEtxNcKHYyghHrt2+IyyM1ERN+x1XPyXGFnP4b+kCz2pHZSjjHlGJpmnNrD1zRtRQVnA71l9MafdOq8N3gFMnY8NFQUhhC+B7hhsSvYNS3+vqI5RZAsfkW+SqAUNxh4z5sDvvjFS6Hf8Zg227+WipjECYDh42dYJxd3TWMgA969oBdQbX8RLPckvYeb64pYuunIF7GyaZihNoB0P5HRY4MdByVdMkN5a2kZA== 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=sNjdOm1VjUvCTcCTPQGwwS/qIN8336LW0MbHgOASTXU=; b=zOA+nqbslJRzTxau9GIc341ruMDRUmWl7fvGcyziRoIRFc5gewg3Exg3PEJsWGcI6Qql+fnKgPrAwZG2hsvpVv7k3ZJR9NTPM4mRBv3utaBCUAv61LU6B5fTtUzbQDYx5HZYqWF7u5hC1egVrlB12af5Fz++81UPQo/S45bRcz3G8l4D9na4poEGzCItknKBVQCeD7QSOzJPEUj58LOtg1MC3DXBaGWqdgcxct2mETGWPdtK1AS3yeOtsTofnBbI3dlx97SuUrMZHRBjGIXG3/oRa06Eaqyal0Jdrax5BXj+JYISJEBpyITaDc6fgWAiQFQDndaOPM8pLzbHca7uVg== 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=sNjdOm1VjUvCTcCTPQGwwS/qIN8336LW0MbHgOASTXU=; b=3bvoru3XLelmXIqgaZaScQ7uN0KV+JEhVDUB5wxbccJg3k7BUsX+yAC3zJVpnriZmwRQ7pnXYQKXQPUWhoDhHBNSz7NOWwA9Ul871TIpo9jDXYWDgls4DPmZfoCl5+ILYM5e4UErzaEpsiaIEFD62ZMIM8f6F22UN2XYesp9JAw= Received: from CH5P221CA0009.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::14) by DS0PR12MB8218.namprd12.prod.outlook.com (2603:10b6:8:f2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:52 +0000 Received: from CH2PEPF00000143.namprd02.prod.outlook.com (2603:10b6:610:1f2:cafe::63) by CH5P221CA0009.outlook.office365.com (2603:10b6:610:1f2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:52 +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 CH2PEPF00000143.mail.protection.outlook.com (10.167.244.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:52 +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; Thu, 7 Nov 2024 00:03:50 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 , Armin Wolf Subject: [PATCH v5 15/20] ACPI: platform_profile: Add concept of a "custom" profile Date: Thu, 7 Nov 2024 00:02:49 -0600 Message-ID: <20241107060254.17615-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000143:EE_|DS0PR12MB8218:EE_ X-MS-Office365-Filtering-Correlation-Id: 0cdce361-5eb2-4b54-b141-08dcfef1f4df 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: mymcLN+Jn6sTmUkjoyPP+z6RZjPKOgzl5IWjtE3XPwWXnfDHb12Bw9+zREEoLwn87StmWfEyCEHHZM6l3+lskVDTFfi/V/0rs60BzTU1PcLRSwUztJ44d0isFmHAwNfxK+bMSkKWJarLFg9EIHVMasDHSNCfuaeBXvYWy6JiSBUSmyiiB3KrtCl3X1lWhfY+OO0F0+x0GlS3k4WTRHCwGnPXxlO7ARwbxY8rTRNQ6w70opJWDeMy02SM8Q5WBEi9aK6sWq+UVfgciW5nZpjf7AVaiCLXl51vbWd4ooO4MATA5on2SDEYP5BaRe3Yw8eaYQBI747pX30u/voYaNsXwkboboXglbN42xO7kGSJQpDkaNiwRr7FrQD7KPf4at0+0OZN4Gvf0O9JUHzbdyubu/aIe48eLPp5Qw5shBukPAU/rOTc+6hL1z5TI01x9dQGDpqZUklnMi1xUomtACpSVSwzW2gXK6p6G+qZPnEitkPk/JpcB8nddcttPnb8WfQB21vt1nZgzyB5o3+xP6OQSz0DJdIstFqXe7JP6R1xLgaMU5FokaYGA4cc30ZrX2ltX6H5PJOb7l6IWzYnZAKITaoAW1rr/1I/Z7uSHvU2JCZxhsJATN2Tsf8H5zOdPf4wlyJuMUocKWL0IMCK44qEFBfqK1xdMm5fWXrR1O7hzPpnhrN6ePuo0cMsday8dgQkqZRbNuA6V9d8mWcyqfEFB+fSdCBUG/cD6UkqOs3qn5jeBAdCsjrir2o4mMJxxJ/gq4wlMjW7W1EpRhsSVmjVD8Q7X0Zh8hvVJPtrAzSieCqMDbEgTph4lbL06z0UsAoMAi1C1pyPBZfKsk5mVmrAeL+Zb/FRpCNG9BTGC9Iw1nVzkXIH3BFK4l+3mGBM+lKtAvmgpsJ7aFT+nKcawWvqEILUhn4sjEBx36KbWF5sx2yn0wdtWnP/RkSbSBZ4zVghb8eCCvFEp7dGf0Uvzdzf5btJjjfs3Zce7rmJxfPw+urreE4u2YHIjdVC+i0PVQsWfMUjed2d+jDEMVhBwc/Qtyil1WOHxOCtfAe3PmeqEZvsW5mgfotFNViNypFa0WZ8UF+Hfqww18A1jM345xOoetPp8IaAxyt3IfQiUcQkNd8SknKpF1OHNFDMSD2KdWXkkwly3c67kmIIUvXcJyryFYdyqJGgp+PBVIE3IQcmKde1EbQTgg7qSCFuT2BVDgucpITVdTJSoiTygn8GuGX5vvmW7G0ie8NTirpiGw2z1XStncX2aZvbfQnemjSAKTBqdLf7vILTQe0wBCWSx8smN3E0TlvYRa6IYg3JDyNRfcP9ZLtfoG6SE3BbeK4TtjRhA5UtIwpe6TmxZw5wmlnbBqH5sN5TzUXl2rYmr/JzDglyIkw0t1jw+zuNgE8m84rYRjzxEyuEvmeuG/Q5eXTIqg== 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: 07 Nov 2024 06:03:52.6766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0cdce361-5eb2-4b54-b141-08dcfef1f4df 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: CH2PEPF00000143.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8218 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- 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_profile.c index 2ae0437623abb..b6f3388b4eef9 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -20,6 +20,7 @@ static const char * const profile_names[] = { [PLATFORM_PROFILE_BALANCED] = "balanced", [PLATFORM_PROFILE_BALANCED_PERFORMANCE] = "balanced-performance", [PLATFORM_PROFILE_PERFORMANCE] = "performance", + [PLATFORM_PROFILE_CUSTOM] = "custom", }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index d92a035e6ba6a..07807c93fde74 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 */ }; From patchwork Thu Nov 7 06:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865839 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.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 5978E1DE88E; Thu, 7 Nov 2024 06:03:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959439; cv=fail; b=bX8E2QYUc5cQg+oiQ3QvtqKo4o+dhEA+lXG220g26f9j1mWQwTEJdmQUpq+loKJP9I4MwOw4nQAcnGpxfMmUHRlBgSj+KOcoPVJSGy+7ujaIwdMzhFps2FTliI4VYm0Ac9pBNS5T/Pkm2OaYSDjUCCVODTrGxXNhRDpZNfJDGqo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959439; c=relaxed/simple; bh=K4AoFKCAu4P4SG3vzBedERFkMX9Pcihfe2eS1/CifE4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AzI+4PMW1I5FvQsTo3j2Tb/2jPaP6Y6K0AThDScbDU9S5Sx3U6VQWx2j8iIL/oCfQ8cURFpVi7K56c4yhePbRfHt8B10xdJTe0rT6EtPTbXOmEmBHSbiKZS3SJ7XUZpPuYWcY/uiN6AFRy+Kr7rtInuwMESmwvnUwX+HnBLVQrs= 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=j1wP7RA0; arc=fail smtp.client-ip=40.107.243.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="j1wP7RA0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PI5lWuG5KV2y2nYMEUyLFKh9QwtM02IEiDlrF2ovyS4ZUxUuYngtd7mR7IXJ55Tdd4h4XnkhsIbaVed3Z7rT1SBCT3r5n4jG9S2NGASt/7Tk/gy6k44IXdL+GbPjBv/9vLp6Q1ZPGDQbya1uREJrJ5K9EHWXDsLBBREva/oW2AdbavbpwH5iywi56mZII1E31Z3IbTA6eTREEZuL6HutAUidyr1bKiSDvEQVMrEM9CJtV893tjEPi/El0ttWTGey9HmTrXkjqmnoch0r+EVusK0Hem768voj7NrERi+51MOlmGoEyI1l6ixdwB5J6kb33d6bnu/0xkiPTgtTZfbRrA== 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=TyKpeqW3CvjjNWY5ZB9puuXGNn8a3q2KFzVzT6du1aE=; b=uVyEvqw8RtD9/bXxmxHsW/Ci/aHbeLv83wUqU4aLHX8szZUa3LYi/Wb/yvoDdPvau+SUfzE0zvgbcdwbFKDSRqrQl4GRyIpzgnPOMBOI6+t28IAiwbVLeYjAfkd0ySn67reFWA8dD3YRp0xCEgaOtOlkzDz/M28AykWGM7LGpa3rDw77S04vbnpsZ0fwXm8NgHbSC6IuYuxSrmrnYPTDRoO/8IgIs27EBw/OXK8BYYbkIEQymRpbdqhv0xiEfkvrSRZJtZas+NxA5ZAqSB9SGPAliIHYCEntayyV5JH/FcaYZdgEVASvCDQLq5cYpr2o9SuXuOTsji6cYQDDqP/9LQ== 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=TyKpeqW3CvjjNWY5ZB9puuXGNn8a3q2KFzVzT6du1aE=; b=j1wP7RA0+MhvNDlL7jO1GwSUUMSAks3TneVzzIbexVS+MQi/KkKO27/Q1115OA3Kpy1IBlaNUGktxCZCIs5WWlPCSIZsZe9BtC6p/Mihx684AN9mX8p9yoUuTZBAF9xTxNABYmZQROi2epwPKwRfinZExnILWprydhasl1uUidE= Received: from CH5P220CA0013.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:1ef::27) by IA1PR12MB7760.namprd12.prod.outlook.com (2603:10b6:208:418::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.20; Thu, 7 Nov 2024 06:03:54 +0000 Received: from CH2PEPF00000145.namprd02.prod.outlook.com (2603:10b6:610:1ef:cafe::de) by CH5P220CA0013.outlook.office365.com (2603:10b6:610:1ef::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:54 +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 CH2PEPF00000145.mail.protection.outlook.com (10.167.244.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:54 +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; Thu, 7 Nov 2024 00:03:51 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Thu, 7 Nov 2024 00:02:50 -0600 Message-ID: <20241107060254.17615-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000145:EE_|IA1PR12MB7760:EE_ X-MS-Office365-Filtering-Correlation-Id: 331b0c0d-ddf3-4026-3e92-08dcfef1f5a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: s+t+UQnKNiQldBB0elpVKLmAbQzCO2NJE9j8BOAUEbV83bTCUT/eoxvh+w+Gdv5F8e3V96egCw0+xsRXTrNDyXhzEn5e7ofTSSt3asx0bKcjHHDv0Vz3Y8bKlpSjuongm9d14swE4pRHGKaqCG7iPpAgIXvNgPfEZJ1NDDHSUoDJQV45i9VYnRu+pdJTsDxW7lPnHzwIzF08CcC8+1vt5dvM6DWadOb6j/kOQ9KwCJhGi8ipS6uPL56vjRfQKoB0Fmpvj/Tjdwc/VY98oYLQH4HKk2vfzTVb1pdDUHlSJAJVf6J8/lx7yW0mHRzFl7xD2f2pq2xPONByfIusBR6kLvtULbhHxFVxHfmxlsQVaNj+dQiysIZySIGurBf53Akm/JeyJ/kEJkDLmEfCfG4OYJQXZT07CJN+4ZUtgWLoc6VfEGlum7q11V5i7byyYoeFWd1qREjNf7wOBgKfq1hEOMJgg5ECDWTdn815xRLCVROKRJMahbVk4ryTtRvnzRsNVwJUZ0WihpQNREEEWHW9uHTXBzhJ9Cp0jWgu/eMJEVsHVQeA3IsqHbhIS04aBorJ9WzpU1lGrE2C0DMguB8baZOB8TRjLzTDdbdvNklA03qvweYD4Xv22fff+X0MyVDbrz5mM+SngLJcYk3hJjOFGjrY6nfYBVQ6ZpugU2Vva1YYVO/iRexdW/Z7XUjxfd/8Js+uLap0gNm79yki1hQDhvNklAOHJOwReajoM5+XBJAMpIuW9easmmYCosKD7NP3XJGanZoPQOV5Hc1Qqaz+bmWtd94GcI4GoE7uRAQOWxIuMFIba5u/Upy7nq4Zvzp1O6VTaNVxFzR12lv5Xui3RhlXJAlvKHdAXIJv3sbKStUcvhmDrSNzSQ4wMig1nujKoWrolMvpD9BgjO+OcuX7C4SXRsRbh6PBEOsbwB/XRnJFlHM7KYFSBJgvLxv6du86mIvSJLSvmroRFL48M4kqBfO/8qak4MRwO2hSz5KYAHd0EzJcR6Bwm+kS6h9byjv9yfPezaexeSomNKfLC8+o5EsGBm60wy8XCjZF4u1nAruc18rxlQoGtNJWydJZ3ItFWzpQFedAvJc1nZmezMWGCQWxG/FkbbmA4FuVmKCDhA0+lqZYF+KmIuwgQljvLCZ+Ar92gD+hLEZir0ozlecVSJe63OoOy7wGd96hvlirXHUETMcBsLqwd6LjxkLNRwuI6zO1Xi0HXGgbDxS+wi5kaQJaxROuXlehDGA6Y3eSocMv7jU/KdpXo92lXhjsUvJsQZ8GB+ZrLhAIPEpu2YIjXuGM2cxYDRs3jGy4ErGbJhqps7kclKzsGCjcsrFKyN1cmPb1Nq09Ascw+1LTOWd0fPm5JzDXJOgaTeB1zrYU8+ANXZCNn4Ruliv74CFi+QyCYVhYX2a7n/n9UBCe09l8RQ== 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)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:54.0182 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 331b0c0d-ddf3-4026-3e92-08dcfef1f5a5 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: CH2PEPF00000145.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7760 If for any reason multiple profile handlers don't agree on the profile return the custom profile. Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Notify class profile of change to legacy interface * Don't show warning when writing custom string, document in last patch instead. * Adjust mutex use --- drivers/acpi/platform_profile.c | 101 ++++++++++++++++++++++++-------- 1 file changed, 76 insertions(+), 25 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index b6f3388b4eef9..7f302ac4d3779 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -94,6 +94,22 @@ static int _store_class_profile(struct device *dev, void *data) return err ? err : 0; } +/** + * _notify_class_profile - Notify the class device of a profile change + * @dev: The class device + * @data: Unused + */ +static int _notify_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + lockdep_assert_held(&profile_lock); + sysfs_notify(&handler->class_dev->kobj, NULL, "platform_profile"); + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE); + + return 0; +} + /** * get_class_profile - Show the current profile for a class device * @dev: The class device @@ -284,54 +300,89 @@ static ssize_t platform_profile_choices_show(struct device *dev, return _commmon_choices_show(aggregate, buf); } +/** + * _aggregate_profiles - Aggregate the profiles for legacy sysfs interface + * @dev: The device + * @data: The profile to return + * Return: 0 on success, -errno on failure + */ +static int _aggregate_profiles(struct device *dev, void *data) +{ + enum platform_profile_option *profile = data; + enum platform_profile_option val; + int err; + + err = get_class_profile(dev, &val); + if (err) + return err; + + if (*profile != PLATFORM_PROFILE_LAST && *profile != val) + *profile = PLATFORM_PROFILE_CUSTOM; + else + *profile = val; + + return 0; +} + +/** + * platform_profile_show - Show the current profile for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; + enum platform_profile_option profile = PLATFORM_PROFILE_LAST; int err; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - err = cur_profile->profile_get(cur_profile, &profile); + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); if (err) return err; } - /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) - return -EIO; + /* no profile handler registered any more */ + if (profile == PLATFORM_PROFILE_LAST) + return -EINVAL; return sysfs_emit(buf, "%s\n", profile_names[profile]); } +/** + * platform_profile_store - Set the profile for legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to read from + * @count: The number of bytes to read + * Return: The number of bytes read + */ static ssize_t platform_profile_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { - int err, i; + int ret; + int i; /* Scan for a matching profile */ i = sysfs_match_string(profile_names, buf); - if (i < 0) + if (i < 0 || PLATFORM_PROFILE_CUSTOM) return -EINVAL; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) - return -EOPNOTSUPP; - - err = cur_profile->profile_set(cur_profile, i); - if (err) - return err; + ret = class_for_each_device(&platform_profile_class, NULL, &i, + _store_class_profile); + if (ret) + return ret; + ret = class_for_each_device(&platform_profile_class, NULL, NULL, + _notify_class_profile); + if (ret) + return ret; } - sysfs_notify(acpi_kobj, NULL, "platform_profile"); return count; } From patchwork Thu Nov 7 06:02:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865840 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2066.outbound.protection.outlook.com [40.107.244.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 00CE81DF26E; Thu, 7 Nov 2024 06:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959440; cv=fail; b=DZMpMP7YW1rVueQ1z3diNFLlZ465v3RL/tXt5BtpjX4LdkTZH0t4x54deJkhN7nVczvDFZW2n5wXUifKSOEb/PeZUB16D3oa/5hB/tGkX+I0bbAYN6VT645tElr42SOcuFT4Amnawq84eupPbS5J9c7yzNdGG63/CX+MuRSvVbI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959440; c=relaxed/simple; bh=hGdIbfS/+jpLYOwWMj/K6zfSfnaWUEf30H2z688aza0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FWFqSkS2JXOd7bJ2wLHCxlEbRFpvWvlgm/3pN77UIdgg5OiJKz+2ZAJg+IQKZCU6vu401k/w9seOXCtIdCM1GE2GWONvHZiQWbHS1K2ByDVsg830+GcoLYjadRcq3iak75GT3SPC1m2qnkHxCicye6kZuGpnLLDPhQjg6Bh9Rfc= 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=0zrZ9x+i; arc=fail smtp.client-ip=40.107.244.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="0zrZ9x+i" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mYH2wlSho/dC8s+Q/jB+qHaq+G4F/LGs+XFekCSuk620xKzDQOfMjzZEfJMEOSqmcDAhN6a4+n21olc6Svo5RcjFDlo6YcUHUOty7IkTNSIz3psak62x3Ou1aImTOsnWC6ak5Rn2bgdtPIf4IIwKLwf8YUlRen/B/+GQob9EpoaSBAFpLZiZVJo77AVN4BdDzngLrfs5xzLfeuUKvQ7XaETelnl6mfpDKEoMxS2+kpKNUNfddvmkxV2rsloUHXxzKrOJ6m/HPqbTxqkxVeg3JUw19ELmpgl5J5jIGo2x95cMZpHVvtp+OZjYffoNzg5YjV20kiv5PrJeAi8vvvT+TQ== 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=mDo+HrkIo28732Z0/g/cJF5z1/K/WaqMVyyvI+DMEr4=; b=LA2Cb6nLcqVElifeBjjtBd3auMIr67nx6mWogxJ8/FEIroc9jOq0MOUC5VX/oA+Y2LDqw5Ni5kJphgDXgBo0M7eky9eIouNJmXVpXGVo62Pkl2XFtDhRrIvtuWwwFkGCBGCnybSA9VPqAzp+ed0Ijnm+xCMeiXK9kvGyS+Gm9Hlt0iK+rfEqi7W5vlcU/OQttpfuNKDITnOGjccBReWg4e2hxLMK9Tz3/bMZFfVZIgy3HyhLMfbJbMHGlj6xGkFN4SUBBBKRsGF4gIadpB4fzYrL1GoBUcFTumoEOYUbZDizOrC0w49+4xSv2MTO66er+6b/IrMmlX5CBfFTI7+ZoQ== 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=mDo+HrkIo28732Z0/g/cJF5z1/K/WaqMVyyvI+DMEr4=; b=0zrZ9x+iitDiM4oilagIPM8pA8kDEak80jreioEG/yboL0ILCQyL1swwmbQHxPMXCilHI+emMNCd3x/RGbBjz4VKKEaSBndlZzbSVHkHI137MrholcHLGWCsrVZq13qKdHuG0/YPXN+TavkZpbAOnsC9x06Otl2qcOvx2tuv58I= Received: from CH0PR04CA0081.namprd04.prod.outlook.com (2603:10b6:610:74::26) by PH8PR12MB7184.namprd12.prod.outlook.com (2603:10b6:510:227::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:03:56 +0000 Received: from CH2PEPF00000149.namprd02.prod.outlook.com (2603:10b6:610:74:cafe::2a) by CH0PR04CA0081.outlook.office365.com (2603:10b6:610:74::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:55 +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 CH2PEPF00000149.mail.protection.outlook.com (10.167.244.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:55 +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; Thu, 7 Nov 2024 00:03:53 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next Date: Thu, 7 Nov 2024 00:02:51 -0600 Message-ID: <20241107060254.17615-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000149:EE_|PH8PR12MB7184:EE_ X-MS-Office365-Filtering-Correlation-Id: 90db55b4-00d5-4e26-86a0-08dcfef1f6aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: 9X+vzBhmZHnq08DAjsIJw0ncFzDtwNXLR6+Z0Z6xnl2d6zZ4xqIuZrBgvTmps6zmnK5c/dArvNPstuHdLhBnmOGeFj+L45JoMSwHAQKtFwDcQs469DYC1YJnQNGa3Y2ToopfXaOJRzW5RQB+/+C5xY6ZeZ7MBN+uaIApc0tSdsjbG0K957G6K9spb4FSJ5gzgStwvp8vVS7aNF2KZA7Gqn3IuXgYNim8LAvfnesbPxKQ44CZdZhOOpukuRhVr0Bnhxu1f9VFq8VVnMZ8dpoXMS+6YNtwrlws0eIrv+sBEUROU0nqK77zOcArOhr3VXsx1mhZq+0qhFov8obgPettwPKQhrwqYQnxAtj1Msi6yJNPxCEQ4FmNdtLSMjEag0GeS3nP06a5k/pornUuDmRw5pCcff2kOqEKpvTbJHE04S42PSGZm0Qh1BTXJCEUJv5dkNPChUXqlsL3SojxTvVSRhWg6j3K5Wgyi8mvUy/Zbg2dL8jqi0+Jdqe4AVbnsp6/CI8oA5dLvYW631+uFzSUcaFxhzkniI03Ne+ItvS08gcLaxEV8SBbrlg/rNW1uDok9KQm/erB+d9pRz8EJo9lk2Agj7XIFTqd4lBLEmFOW11Bi0ri4Z+tyTax69Md7bo04TucDgZr6viIE2Fdm0qWVWpRe40d2oJJlRYhUMHCEslfMZrmCrApUwMcenCHB+3oZTzq+R6GZY79WMgthsWq7Kjlz4BrZ6J3XYM5GBYLmIDfUmbau62OJmbZjs2jaCjfT4WRy4mw+DEavgW3Om55cUstckiLOstfQ7KYE+T4BZI2Rysf0LlUkYXICFxHos1GmD5f0V0mPKHWGUW4DPPVvA59fH13hx8J1W78JS/u6V46ISKFcoKOIPzIptMxa5yUgZiwdifvMcb48ctGCQIM5LQx077w8+MijVscI89AVi4ZyqZmKgT8+519VOFt3IN/6ShObnyHXi9HI0UFkGpX2DwCWW1s12/Cjt6o9fKoAZVv9Wx55Evb+V/Pmz0cb9eKt0pcNDgUoY+QCCpzFr4tZ+Etr1X3t1HAw8gzI/U7u1yR5yszXHt+nT1WpUqrRVXNDqj72rzwA7NDj2S1bv3KJNabHnakfH/abvTpPfji7kw9o7ok2Y7tjZwfur7tE/NPDx3I4YBotzZXGDSL0DicBiFxZL2jA4ARU82J6dSbe8ywM7vTHj03SWjQgGWkIRqnJtEk4WvKGmM5qOHkFMVyglIpHup9jyP5+EpiInebNdDZHGkAik57DB93jLCZc9NcujmGAKeBpRxxa6lrdEvHtOsRTgpq7Hju1UwU0+QzSkRFUadkcB2WQXdFroN4jtJu0IEulfq6+gLXAYe2ogGezP+9XZ446ZDut4sJ6oU9dXVq4SYdzEkUYOLda29HZV5qSp70rBmg+ny7jUdjMrseUw== 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)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:55.6836 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90db55b4-00d5-4e26-86a0-08dcfef1f6aa 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: CH2PEPF00000149.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7184 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. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Adjust mutex use --- drivers/acpi/platform_profile.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 7f302ac4d3779..2c466f2d16b42 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -411,34 +411,39 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); int platform_profile_cycle(void) { + enum platform_profile_option next = PLATFORM_PROFILE_LAST; enum platform_profile_option profile; - enum platform_profile_option next; + unsigned long choices; int err; if (!class_is_registered(&platform_profile_class)) return -ENODEV; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err = class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); + err = class_for_each_device(&platform_profile_class, NULL, + &choices, _aggregate_choices); if (err) return err; - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + next = find_next_bit_wrap(&choices, + PLATFORM_PROFILE_LAST, profile + 1); - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) - return -EINVAL; + err = class_for_each_device(&platform_profile_class, NULL, &next, + _store_class_profile); - err = cur_profile->profile_set(cur_profile, next); if (err) return err; } sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return 0; + + return err; } EXPORT_SYMBOL_GPL(platform_profile_cycle); From patchwork Thu Nov 7 06:02:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865841 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2077.outbound.protection.outlook.com [40.107.92.77]) (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 566F81DCB2D; Thu, 7 Nov 2024 06:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959442; cv=fail; b=Tc3fk+MAxpRpesoRdsJiVIz47znMctaHpuebMOTG5REjJulD3WzvpctDV7ehkPfPiXRgTOCqrxgq9QLnMfpGJ+Z7taLRZ2YzKXP5t60FvDOQd+2kurndsdVWlb+8woY02dGU/QNZ6JbSO8W5ub1ziXvewd1A7udH8OIRvZMS2jY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959442; c=relaxed/simple; bh=cC4TbPX/VQOnAUsgBwm00InxYmXfz2kAuwh50Eqi8Ow=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MzCjRE/VGTpE/ZwYEqYWnyS8z22yfMTa4d2ZmCBLkmU0eA5bHfK5ohNdukWLZT8A8f954XsIi/fy0Xyejq0G+rWn8xAVl3qk+vR0MkpT6n/a5eIGnFfa6pa98D9jWPTu/95kAku1+EMaGezSRaBcyYtEZULm3TslxuRcseE04ik= 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=Y2iv2TAY; arc=fail smtp.client-ip=40.107.92.77 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="Y2iv2TAY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aSzlxci7NaDZKPujspxo8B4HZsYFtzPx3F8rsV6aKbfeS4BfKy4bMaR0U4KFw8EkkH/0yb/kJtnFz2SRqe6BzQqF82FQux2xpwkUaax6fzSZe9H1yWK1MkSRR5iws7Qoey1vYY0rpfLAhCkNbWHAFq9t3g3qqknDOWXj7xGGPSU4vKoDv6qp+0z1qPRrB986h7ofKXlMbRd3y+b0gixymxVQSA6U4EHEPMANccRvF3CFWNNSTiG24AU5GXkON6FvDhoxsaI4M8KvHulBIPaOZqNLkMCmeb0Fi2CZ0rIG87xr7Mn7ubSoMTGcBCgWHiv1o7237GoBuNWavGrUqvHY1w== 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=m1d0S4zb/ctgwx9iRMLS7vElenRqrsErndD/UwbSOy4=; b=gm5MN3uDW9AvfoOYQlizmiujTepLkI8w1kHYJCylWTJ/D9JkcoRCdoz23yvVUlgpCDhQJfGcUiOcdtGWuyjcVk4JxkRobXcNut+hJtQE0lnbvokshdUXo5BfeJiljtAJz9czAGRAdRs+AFMwK9w1MlUplFJvs62dICukyDab2lq7bBbGfaubnRrREsvZwbQgq/d5zvDB/RtGQgukC97Q6KltUexE4AW5kZnoyasPXchhhBU4rFc7B7QZbT/7YOujAm8nZryx/AWqjkReJnAeWvR3UcEsFsMIANjrhpAw2L7PXKKmElCf7ErATQjVLDI3KuACK/CBHwOaeh5mBw/Gmw== 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=m1d0S4zb/ctgwx9iRMLS7vElenRqrsErndD/UwbSOy4=; b=Y2iv2TAYbyLyF+DH1GB+MA8XhLaSB3yTsZej2sYV9VS2RgfInlMu7VFb7dFGoZB0OlbQDXRV3DT8x5W/xHnZlZIVDNLnGtJU8gqR5BUobsc8QC0AwhU3/ZlN4bAycY6gsVc+VTSE0AwOh86djHABM8tKze77QL7nytpP0efhpXI= Received: from CH0PR03CA0295.namprd03.prod.outlook.com (2603:10b6:610:e6::30) by SN7PR12MB7251.namprd12.prod.outlook.com (2603:10b6:806:2ab::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:03:57 +0000 Received: from CH2PEPF00000147.namprd02.prod.outlook.com (2603:10b6:610:e6:cafe::b6) by CH0PR03CA0295.outlook.office365.com (2603:10b6:610:e6::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:57 +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 CH2PEPF00000147.mail.protection.outlook.com (10.167.244.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:57 +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; Thu, 7 Nov 2024 00:03:55 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 , Armin Wolf Subject: [PATCH v5 18/20] ACPI: platform_profile: Allow multiple handlers Date: Thu, 7 Nov 2024 00:02:52 -0600 Message-ID: <20241107060254.17615-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000147:EE_|SN7PR12MB7251:EE_ X-MS-Office365-Filtering-Correlation-Id: 51eb5401-3ca2-46f9-924f-08dcfef1f79c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: 9Yl8zHtshcz2a1Exvwyp4li08VjBVFoODLBUtw+oY1ND1CbSIbgFiOeMasCEV+cQHZfUzuh6HxCisJLukZfw9FEtuJ6BPiBppCS/BtL8/aCjewPM5KODI8AZJyGiEiZCn2Ay1r1Q680jEEuqpKMD46/fNMGywrLaRvsy8XiDmEO1rmkF6ZC6N0cEfI5K9BYYykFG91l8f9OxQWi941eCE4qKw0k3ZS3UHJnld0llK8eqHFPDVm9VU8noN9EMV7z0sPK3wwhFeDbKvQda7Tyma4yrlt07ycolU6dzCswpKNaR0IRJIQhC3rk0rGNYjJVSGdh/wxCzpOdEf8/Djid0hXe5cJPO1gXA/dt0IE3fxOg7ju4uRCHnUXtq1BZSTh2DzM3C7TugCOB9olXc9tUo/uxIJ6JBx0rlqkhWOrB/QJeSPQo9QGcUrtlre0qb4MRWIdd1IiDmEqj+M7OH4Dl7l3+ax50lxCG2zU1/ODpb6ITIr4rHqJ8UUjl8EWSJTpHrx51Jbq4YNf8NQ9W49UAwvtmWZsySegQ54kOR9T4rushCGBufRBq5nplAMz/DAcViUOZ4iWvWYRMJaKxCcKzukqSHPJwSORQ0GcU6qhtqAsMmw79xXKIotQJQxyvuR/IJ1qLOO6R7lRRRcrp9UMyWC/w6lMdqI/O8ADQlrf+vHL7ZXw7DXK3d5ZUdU1gBR7F2jIpHRxQrCcjlvtgnCkWAvMK9zqjGB0wnAm7JujjxMe6T5vJmbI1n8/3H7eZ4URuG4q09LLF4T1PqMcS/8CCxlKP+RdC1zX7dOmhSLcN/6oQg5qTdWvrAB5f1004gOqymY1Te0TGNnwGwhbvQNQ8G3zAfbJ47cLx0F8faNrmq/rIXjF7cudc2hWQUyUbDWE8v7W61gZYY7Krk7Z/YDaQbszCLTcPrjm691nKR2Aam/aHxZulUCSgP0X86PArVDGoXR+AhqdGFWV492R/3Zf1cJhces/Di+3crgggg5ikNhD/7LGXFLWh/v1Ly/aDo4li4D713KXukplMvab5t3AxpMHxgKnlQEKIeBwRTCxhjPdq070miBBMVF/c2P+n5GfD33YjunNcVrvSOXccKNZAq7v4KR31p/wlBPI5//rsXlOH6Hl3WUhoeT4mRh34cgtZwTplo+lIr7qGhhl8AKTZOAgzcGxDctu7WLku1cxzjSkpTz2Sy6sEdKOO4m/lhPIIxZ/vmzuElWXsCOHryF+WvF0tei5UEYBmcnODFANCkcMpDqXEFW/zd2lyc0uKpQtCYtfS9MCP0WmWeiTSb2766mWOfyUNZ2uBm4rKK/Nv0ZKoz6g/RMbrdl3UCl7V6N80C4wo1ADFZnSlU8MwcbOpXRHHc6uf4ikebimlflm9lV8rC0FF1aqWlSNmPtciffZkcmuegCkPBxG3euiacqsJ8kw== 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)(7416014)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:57.3012 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51eb5401-3ca2-46f9-924f-08dcfef1f79c 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: CH2PEPF00000147.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7251 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 the drivers that were already changed remain changed and the legacy sysfs handler will report 'custom'. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * reword commit message --- drivers/acpi/platform_profile.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 2c466f2d16b42..63ef192f1a07c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,7 +10,6 @@ #include #include -static struct platform_profile_handler *cur_profile; static DEFINE_MUTEX(profile_lock); static const char * const profile_names[] = { @@ -401,8 +400,7 @@ static const struct attribute_group platform_profile_group = { void platform_profile_notify(void) { - if (!cur_profile) - return; + guard(mutex)(&profile_lock); if (!class_is_registered(&platform_profile_class)) return; sysfs_notify(acpi_kobj, NULL, "platform_profile"); @@ -459,9 +457,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) } guard(mutex)(&profile_lock); - /* We can only have one active profile */ - if (cur_profile) - return -EEXIST; if (!class_is_registered(&platform_profile_class)) { /* class for individual handlers */ @@ -487,7 +482,6 @@ int platform_profile_register(struct platform_profile_handler *pprof) sysfs_notify(acpi_kobj, NULL, "platform_profile"); - cur_profile = pprof; return 0; cleanup_ida: @@ -511,7 +505,6 @@ int platform_profile_remove(struct platform_profile_handler *pprof) sysfs_notify(acpi_kobj, NULL, "platform_profile"); - cur_profile = NULL; return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); From patchwork Thu Nov 7 06:02:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865842 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) (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 5D3F51E0DDF; Thu, 7 Nov 2024 06:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959445; cv=fail; b=lB1pTFrmAo+HKRH2/lir7ZINrMLzbYbuy49bnF1l63kD0nFSUFzSrqivMCq4mESoWm7ku8Cern28gXU7sg6YjMw7wBdCHAEJgBPwt5ECKCeMjmKrrlNk/5j00DPYHntJULsoUHPweRDc4ZzFV/MFCvOj+CUNtmYMgfkM7TT4wA0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959445; c=relaxed/simple; bh=wydFZq9b9U47n3suMunKX8B3Vmy1X7R/gKQy89bbhQ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T/CyCRbZBu5C09Q+edu5wzZ41DloNZbfkKEdQynVQWnRNkbAgZm/VvAp3/rkH4eMi5k547ENliXs9TEUDbv2Q1thpUlrwSk9Cus6iZqLZUAQ/7hdWXLNK+MBAKM1GAmkVDa9AUq4TnZG26vQ8mRwrCblr0v544FVcHQ15SBmZOw= 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=ImkGRgb6; arc=fail smtp.client-ip=40.107.92.67 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="ImkGRgb6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J4Zk3lZFS2Q2Z7vyCLeZhy2z8abmu9tZZ059nl+bZRrVmhaUh/+GDFQ2ZEc5HXWoQcK9U3+OeqNbPJOztpxz0LleWvaPVjaTd5N+9YuPIg59X/l3+R8uwEQ7n3Ch+hnEBDfUYMnqb6Gml52ZAVTeoXezLHu+61fdsxYi01ARtTVUHGNEftqwIr0asahj0ap8pX/lfyb9OaK3nILOEqkeMp3c2s1oaGykpCkPRVNy3AW6x1BOfLIDEy11dOM8R16ZYW9RXkSAAEY1zn9W+eyHZx3Qe8ZRta32G7eEthuijgJcJBiFJdOpInsKRNh/dcgswlXud7fl95N15y7MYdA3rA== 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=tGd4uyuf3IiVcajgihcX5MqVnqZNO56nHUgYLRj4468=; b=R2lo35xBl5BqoiiziYDkCeQf3KHOMGfYvyKwrmoQH7RU8wx5R0H1VOtj1jrn8SlZzlUSxGpbNOaWOOcDrQsYZA6OE1YJK+35dgSXVhfRPM8k/mlwqNz4L9Lhgyk8jwAXprnv0+lXr/+JtmFC7FVxVgoMH9xkcVYTqqM0Bv/5+bUzgJhRZe24RX26t58V5BdN02FJDkHSzDHKlnEMjdJMGmKh2Ke1ztLNlDRbBXBKRfSlEIR/1VQmRJmruibDPrkh0Ms+ExWPnP2kdXhcqxBE8I4nutRRRLqmrmTPxjnzwOfhzuQDzvMXGqra5xsiaU432IUyO0MUwdaenu4gkakK0Q== 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=tGd4uyuf3IiVcajgihcX5MqVnqZNO56nHUgYLRj4468=; b=ImkGRgb6KNtHLm9KD0kKr9eDLwib3YmOtAqJvzCZHjtvKYqFPkBDmUcOqsz23Yw/JxeSmd9ZLialayxUVGvAYykj9I0bV9zWPOYsie595M/vQC1ulypm1mYRjlXZo6LPkzBinkcSF1BcR/EJpAA2F18fN7oPPqZcCvmsuyo2J8Y= Received: from CH0PR03CA0245.namprd03.prod.outlook.com (2603:10b6:610:e5::10) by PH0PR12MB7930.namprd12.prod.outlook.com (2603:10b6:510:283::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Thu, 7 Nov 2024 06:04:00 +0000 Received: from CH2PEPF00000144.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::51) by CH0PR03CA0245.outlook.office365.com (2603:10b6:610:e5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:03:59 +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 CH2PEPF00000144.mail.protection.outlook.com (10.167.244.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:03:59 +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; Thu, 7 Nov 2024 00:03:57 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 , Armin Wolf Subject: [PATCH v5 19/20] platform/x86/amd: pmf: Drop all quirks Date: Thu, 7 Nov 2024 00:02:53 -0600 Message-ID: <20241107060254.17615-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000144:EE_|PH0PR12MB7930:EE_ X-MS-Office365-Filtering-Correlation-Id: fbdc959c-eb9c-45d5-8049-08dcfef1f8d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: JLbd9yiqNmOW+v9PMuIwCZd5ybjqmlSTMbaKDVDkgUoyAHMXc01sxS8JyU5qo8zk9x+JAH/5A295syI1sunBjKocDI21n80HA5tio/4o/RDiQyCQoEpIfrIGkPPeGCAIVFTHk+6lCZTJdqZLNqg8LVrDAjBXnwxlxLdJ/f6T43ZJ4YEA/SZvTEyILWT9lhCFXWp65amPOqlJnun3PYnWTQvfANYgvqTACcUhV8XzFi8p5NjQuM/kY6mznsGqYrwDFCt61WUxYlrVK4mjn0+DQmpRmowwYCagW28fHULSmjw5mUWL0wMJ3Td7gFLIfcg/EClUtjqmHF2kBOHrLdQYOaAudwghBv461BbjCnj+RDTtuFnrk1Izan9qCAP1BGvTqS6+vhgW2VTVoBlIpf03i/ouDB7np5E3tNJUyapstRD2giBgbuzTdo2HcECz0s8BOqXVQqcB+J11EmGB6WnroGHUI8DKdoKorx5RuJytFlbZKI0HfwTYKkF3+it5oY9daTp6Bg3rbpu+1ENCdqNzoU7yzu2u7TTyHCMR86yli2ZFLqO2UagI6eWRsRXTgRFnZkfY/4/hXJKraBz+X6gumPHLIkRMBR0mPG46Tg1e37q8idLeJLkOgeQuP/fwJreAW8GvnPDjJEB2ESL/TZrVBg4fid3vjF6vZ7foOD2alTQqTEwxZoJddhxeLlhpOXLq8I8rHf1UPFjqLyZXDOcc5JjVCVwx60galdNdkCjWknAxb7619DgRYcUik2kGbnF/cNMSpmCHL4HzTeiYYq6fRyzVWIoE5vk71BQAsM80fzNw/FxcDcj0ps+Q6nkIo/y8M7vGQoASc+xgPCuPwAxThgH+GKht6vUr9r+X0DXSZsgPiXi0bcXhT3qgnrB2FAg/zS+tjHTx/3/Wjc2qhDd18hC4YcPH2l94/eQBe0071+hiAwR+QR5ZW7ZB4NT5660sqtnB8KbbEXVELwwTRvPvWDOoYw/yd4vOPoat21F+V8VJnyzNlWdbZzWWEqreid2zkTsSF5LpBeJyVsgnD2yA7LR0/EhiwBjv9RuCJ7EpN8/NeucliLEcY1/+efph/7pWZ2e2secgSX/V0QU7kJ4a6Xbi0CIxMCFy3WxTGaVB6ah0lcyrxd/BCFqoUebJKuTOO8aJrGhdul3jVS02+sGLU6r3abeHssGUVSTrh/8cY7lSQm+rV207IlEvC5CXlt0ov+x6FI8MoBaSF4JIE16cJc0cDOP343hOAFTLFkKW+u/t89OlmQFtMp3r+Ewdnt2rigOiLC9DgcO6iJs4t8vsrkApj1VDsA40GxsrGLePnylN/X9A2G80dJzDTh3XdSQxN4lHTCsDchNqA9tJPHf9SlVEdcCP62BEEQs1Tk4HhR0N1SM8eL0fi9ZSXCLWSW3DHMt9qD9vWXcnMZJxUa1llg== 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)(82310400026)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:03:59.3495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbdc959c-eb9c-45d5-8049-08dcfef1f8d7 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: CH2PEPF00000144.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7930 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson 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/amd/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) += amd-pmf.o amd-pmf-objs := 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 47126abd13ca0..6ad00b3d472fe 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); - 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/x86/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 = { - .supported_func = 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] = { - { - .ident = "ROG Zephyrus G14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ROG Ally X", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data = &quirk_no_sps_bug, - }, - { - .ident = "ASUS TUF Gaming A14", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data = &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 = dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks = dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func = 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_dev *dev, u32 val, u32 preq void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in); -/* Quirk infrastructure */ -void amd_pmf_quirks_init(struct amd_pmf_dev *dev); - #endif /* PMF_H */ From patchwork Thu Nov 7 06:02:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13865843 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2053.outbound.protection.outlook.com [40.107.236.53]) (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 AA8831E1021; Thu, 7 Nov 2024 06:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959446; cv=fail; b=lr83RO1eQH1IE0/PxJ0hjl+pIF8c8rF72UzJWLAucgy/J9P2284PU/bYPBBpGe85wDgipADBpKAZ+YJ1kAOAAC5xr32wofah/lZxfv2WFAvGWvtXIH8HF5HwQ8smz3hC+Z7P+Vs4pPJEP2qbAwE0k6wcC1DptX6mUsZXxbovI2g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730959446; c=relaxed/simple; bh=/+/ROlHIruuC8Ptk3wbPDnl/Q1PdBpPyHTOE4QQFJzE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FboL7XL+78UDbOf8qVRZA/W7wOb72IkBKYooJtrKy0kel0haPcbHdb/i9ZK0uatF9JmWHjY1RvHFaZ80b8J2bNHCOB3dAFXY1aArUCjfNDAQBPJDOkgTcSajCxuMxH5q45gcAXgumrmFt0SHNHPest5j8C7sfWFWtxovQ57cAHs= 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=cQfzosWV; arc=fail smtp.client-ip=40.107.236.53 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="cQfzosWV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Fs2kiiFqYTzWSVsEpx6+0JLjuX+G+Wb+3xF/o9EHKF2p8LzBzbGUdsExu39sCNO1tQglbPyvZjNnqISiGckvka3ajgj2CUW7tw6KJNUqpTuKAxbYsn8hSMyccq3dWapvDH2Y+/RWbGjQDwKUNSW5/4yQ5xStrj/vAv1T0POATBkDCnujS56Zwx5k8CHc52KQI9mUG171yRn3C728dhKmfGaCg/dglvIGcB7bSCWwDV7PPZ2SlXQMAnR8jfpMiC6TVYmLj6EotWalgrJBAd0phF5VtelC/JR4B/eGLzI9jX4JzHCvgl6GA979tHMJdDIjuWeaFcCXoirX81IYexurQg== 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=xMYzj0HO6grQuskdeKK/x04e7ys9n7Ov1LkG/6DM3OQ=; b=BByhBn7UwfU28KDeFiy4sQSKny/4sOgx89bAnXrrThgSgJDjoiAPnC1iXOYaBYeA56rTpzDqVEpZ42SqVp2SC05bNJ+h7+pM4iw9W42KtpBn3QtT/WJLjgWmbCPpF5HAKnJ2r5E/Ye8SOw4kE3SkWgv/7Q6y+TOKiR4Y/mKL+uCefIqIWFeZysYXKw+k4cOVjXWZHdvQtImRLU/MxeQiF0JDYzxkqdTeGxTyKmNnPRqTpJ7Ps7EW/pJo2OE2MgBu4AkmMSozb5Q+WH+ij1RUb7tCMYWtAWSstxTZUPGGpE6vkvc4WPCowjETibqJkylaAN79A/sXsHfbmZID224AqQ== 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=xMYzj0HO6grQuskdeKK/x04e7ys9n7Ov1LkG/6DM3OQ=; b=cQfzosWVzhMaIL+FoTpVCKLdC+agqHJ6UKhK0fxpJqHPlK5lhbmfaSXefQ1YAWZ/8reIo4Xk1TyDCQkmBdf1UPtW0mn+i7W0oKQOM/oKMcAfglf7NG2nnXYJTr9F6LTy/jR5vqqVpJUdaljIRYjuJxS6/bw9YcyWrKqQo4aGjD0= Received: from CH0PR03CA0267.namprd03.prod.outlook.com (2603:10b6:610:e5::32) by CH3PR12MB7521.namprd12.prod.outlook.com (2603:10b6:610:143::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Thu, 7 Nov 2024 06:04:01 +0000 Received: from CH2PEPF00000144.namprd02.prod.outlook.com (2603:10b6:610:e5:cafe::ad) by CH0PR03CA0267.outlook.office365.com (2603:10b6:610:e5::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19 via Frontend Transport; Thu, 7 Nov 2024 06:04:01 +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 CH2PEPF00000144.mail.protection.outlook.com (10.167.244.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8137.17 via Frontend Transport; Thu, 7 Nov 2024 06:04:01 +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; Thu, 7 Nov 2024 00:03:58 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=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_Kleine-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 v5 20/20] Documentation: Add documentation about class interface for platform profiles Date: Thu, 7 Nov 2024 00:02:54 -0600 Message-ID: <20241107060254.17615-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107060254.17615-1-mario.limonciello@amd.com> References: <20241107060254.17615-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF00000144:EE_|CH3PR12MB7521:EE_ X-MS-Office365-Filtering-Correlation-Id: 0bf4ad12-8653-4c40-d710-08dcfef1f9d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: zKNmSVcQE/bzmy+yP4SkyMUCC2qTqalsNxjc02NkUBA70jcMLGFkC0m92RGC7TAsrYvvw1hOLCC7pGQqdO6tAIJeuCKU38shLpc88uvzO/vEL7VU8eK4Vlx/4PsgJqEDpbmifr0cMollG+bNZFSMsoNARRebkU5MaSGkyk9TJsBVIiLTR8Jww3gHjaFRwUT0LASiZ3aneP82wQLQitg/LCpiab2dTO+BqrOCwePapr9KTz459kd6iAjpMGAV75TExS6zuD1v+gNL0y/Y7KZNsdG/3EibG+QhBPAMfgJAVPCf/3+KZDllokPolqvmdtA0ESjHtK4dLSmwfkEauG7MNveal+Y8HCMZRl8VVYTK3kCsa1wlHCpmEkeZLHXdy4UGbPoz74HTj8bIDOl2pjL90S2nLa/4aTodPETULl771+sl6DegYmrig4ycYaVs2xDqk2ZDponSx2ABhXK3EU7vLJejI8b9YSZ5+c5kLgyCX1bOQMujgohggrd4FB6FCjG0+maDreQP/g3s8p8GD9tdClc6a/hyG2FlXd6497Kz/0sVgQyosAg58J7OzhH3TiXdYECB9taKCwZJsiy2WIZsaiVZag3Yr5xSjnAz4H0kgx9k7QfmpvzKcWnJboOCwvpWa3XNYF+1hSN5jAbmvvMQMtmIa8BEfSHVOOk0kkpqucCdw4Xw/5nCdwPrx+iqWHnR56rH6nNKV1AyT/K07ZKa91KLoz1ItF64IkC0LPs0DMoEChOomY+ZnrbPaT8PN2p0qa/G4QXRLpZMCjLGzWeJSdZ/Wdg9HV1iAk6po+yHqnSlK65X4wZjBcUY0sYfDaBVth32QYYaGojLtFMrngo5GGSMRUD/SaASLuh0PNcNO+pcy5VAPhPZk6qLWF0l+bxOnCMFBtBe93EdsRj/LDUd4+RHgVhiLgfWbdmv3cvx6rwo6zT4bBydibEoUBepo9TIArIFXC7YcKHnWugYIfVtMDwf3mUEQsYVkJspmqNxUA/Tyv4xmckckNAOAOb89yTXfia6zck74D2fFXuaaMlXeYLK50ApiY/DlvsSimVxgDii9Oge55WiBPOoJ3srM1NS2Y+qHVnxq/w+p+vBxBupNspV3vRhhyToDOZ3zXkKavnW4vYyIJPsfBuC9P+A7c1Od3eiI9p/EzNyA7rXbgAcWHo3+m9dvOIq3vCCCvrcb5a+1AH+y280LDdYZ/xVrC+IXHTq5dLI9uQmDlNFEoAHXAVcGsAHdTz0sObAl2RUMB0gLAV2BVDKW8DI5E0NIedeE37AjxzUFxFRQEpjAsHDE58/f/iAd6vpQdFeqcRLmNShQ9HV1FIBkTr7YAxF8F7zZbZ4Ju2qj8cFbA2lwboXeKdsGvuCHalzXIrrnHAfp5Pp9sM7vlcKa8fw6LeM7vxCtjgyusWGBpeya0UQ4vkYpA== 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)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 06:04:01.0370 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0bf4ad12-8653-4c40-d710-08dcfef1f9d1 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: CH2PEPF00000144.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7521 The class interface allows changing multiple platform profiles on a system to different values. The semantics of it are similar to the legacy interface. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello --- v5: * Fix some typos --- .../ABI/testing/sysfs-platform_profile | 5 ++++ .../userspace-api/sysfs-platform_profile.rst | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform_profile b/Documentation/ABI/testing/sysfs-platform_profile index baf1d125f9f83..125324ab53a96 100644 --- a/Documentation/ABI/testing/sysfs-platform_profile +++ b/Documentation/ABI/testing/sysfs-platform_profile @@ -33,3 +33,8 @@ Description: Reading this file gives the current selected profile for this source such as e.g. a hotkey triggered profile change handled either directly by the embedded-controller or fully handled inside the kernel. + + This file may also emit the string 'custom' to indicate + that multiple platform profiles drivers are in use but + have different values. This string can not be written to + this interface and is solely for informational purposes. diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Documentation/userspace-api/sysfs-platform_profile.rst index 4fccde2e45639..b746c30432753 100644 --- a/Documentation/userspace-api/sysfs-platform_profile.rst +++ b/Documentation/userspace-api/sysfs-platform_profile.rst @@ -40,3 +40,31 @@ added. Drivers which wish to introduce new profile names must: 1. Explain why the existing profile names cannot be used. 2. Add the new profile name, along with a clear description of the expected behaviour, to the sysfs-platform_profile ABI documentation. + +Multiple driver support +======================= +When multiple drivers on a system advertise a platform profile handler, the +platform profile handler core will only advertise the profiles that are +common between all drivers to the ``/sys/firmware/acpi`` interfaces. + +This is to ensure there is no ambiguity on what the profile names mean when +all handlers don't support a profile. + +Individual drivers will register a 'platform_profile' class device that has +similar semantics as the ``/sys/firmware/acpi/platform_profile`` interface. + +To discover available profiles from the class interface the user can read the +``choices`` attribute. + +If a user wants to select a profile for a specific driver, they can do so +by writing to the ``profile`` attribute of the driver's class device. + +This will allow users to set different profiles for different drivers on the +same system. If the selected profile by individual drivers differs the +platform profile handler core will display the profile 'custom' to indicate +that the profiles are not the same. + +While the ``platform_profile`` attribute has the value ``custom``, writing a +common profile from ``platform_profile_choices`` to the platform_profile +attribute of the platform profile handler core will set the profile for all +drivers.