From nobody Sun Nov 24 12:54:06 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.63]) (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 543DA126C03; Tue, 5 Nov 2024 15:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820818; cv=fail; b=ueEJL53d7aYXVThGWSneNc/KoJ6JNCZTBxv/kq2fHtSFKbG0BLMakcE3bL72JqWEk56Q3qBB6kyLIhB0BcDaU0ywMEKJMBs4eBPwMYRlDsmw7bVtqy+JezFLESXE6e1+lT3oYXkoKZTvC+Wl3edQ3R8tu8T06kcIfo5a2NotdBo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820818; c=relaxed/simple; bh=7AooLGyysGXoohZPXELnGeYztEfM8k/ZcIos1h3C2wg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FwaztROY6FxIjsXCo2tvnj5GnCOfvYZEWu/EmHDEEUKqCislgxVcB0hRcx4S5e38+LJMWFueb9swYsPolY8sWiD3JsJLExhF9dP/wgtAkKNtUhvADj0u7bMPfvCjHj7yYyrgGsKvYgdeSc11SzT0CZAUU5WcJYWj8vkVolKWMgQ= 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=lCx5F5P0; arc=fail smtp.client-ip=40.107.244.63 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="lCx5F5P0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=w7tTD0CG3LdBv2pVlsI5hqDLRWY1inwV30s5fsYib9hgDRSAXtch8NDbsAem/Q1ruYSrm3Q9o4v4m1E0QBF+XwUe+57wq9QEnjvWJjXO+RpTK3gIH2nhiEq6IpbNR6RygmN8ojwLPEPMvI4G2hTmAQF4gXc9deWWPUzQ2jz7CoAM2mdr8nrbf36Pan8w3m/a2lGbkyBel+XNnLnvD9jK6gvXR7W7ccV7nIr2FRtELBgq7jnBeE+s4Hog2vsu5A6E5ZdTSEd3G/2IMu7GzcqiG9Jm8olG0fMl2TLFfTZERCEX93rG/HnZbcEBz3E26wa+cllUf+M4GJ6yE0wtXOFQzA== 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=ZDdDjN4psyY/0raDk4s+w7ZhQvmNm24C4BYgq9B0YJY=; b=f5ehrSeGCvxTlKZEX2YH//oFXOymgYYztM7pJTuwqrNiSLB0HrcaIj3MDi/0eEmKHGWScnXE8Bchn5G6375NW5BQOmsLv8KKFygjPrhK2slfHBuwqX7uUM+6W71WwJRpuv6+K72OE0+1cXfs2AaH+VlIUqXbAu0uT4i3yFCgXQwO7uozIt9aLk+ZyKDxOrhj6JoHsqV+dpe91pdZaLngyNjEUpditecL72KU+xGlTkVsAg0kAoDI0StwXzps7Jy3aYZty8G9FaA/ltwg4ngFARVXVDz9Vof6jD4hyJ+SQFXQXHlencS1SMxVDca3xr5lyMzVoulisXNOM5Vh4RYBPQ== 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=ZDdDjN4psyY/0raDk4s+w7ZhQvmNm24C4BYgq9B0YJY=; b=lCx5F5P0F2+Du/c3/sTHp4CxmWuyzR+gM1BFumEToUbeGX9zQ0f2A8aLvO1mbllIMriMq/tJIaxcSjtLTOIH11x/wHvsVxaiFthupf1ncgZcvCmzKoMMSdlWXXJKH0mWY1b49I0bgROzhP3umDiVv883AZK9gEVmPEssHPDiRuw= Received: from MN0PR04CA0001.namprd04.prod.outlook.com (2603:10b6:208:52d::35) by SJ2PR12MB9189.namprd12.prod.outlook.com (2603:10b6:a03:55b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:33 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::a1) by MN0PR04CA0001.outlook.office365.com (2603:10b6:208:52d::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:29 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 01/20] ACPI: platform-profile: Add a name member to handlers Date: Tue, 5 Nov 2024 09:32:57 -0600 Message-ID: <20241105153316.378-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: BN2PEPF000055DF:EE_|SJ2PR12MB9189:EE_ X-MS-Office365-Filtering-Correlation-Id: 20c99e3f-bb23-45fe-d426-08dcfdaf3425 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: =?utf-8?B?aE8zM1owRjQ0dzRDWFVINkpnT3lNa2JIbmhZdmJOMGNFT2N4QmlXc21SWXRG?= =?utf-8?B?aUZPYUJ3MVdabmFsNDlQNUpIb0NUTi82ZUZpMjFEWWRSSFRIb01OaHJ3V3RV?= =?utf-8?B?ajBWeWtXbHdkbkgrLzc5S2tEYXNDdnQ2eXo5dWc0bTByNHF6bURYN1lpcTcv?= =?utf-8?B?MGdpRThGbG9hVWZUaGJPSFN4Zk9pUERzcGJPNjVwWHc2cStSd04waWNEYzVs?= =?utf-8?B?cWhKUnN2ZDJGU2toOUFTaWhMclFvcWtuUmd5ZUxwT01raHc5cGlmajRkOHg1?= =?utf-8?B?eWlIa1RuR01nWVRkU0s1TDUraDBBVCtJbmlxYy9OaHExRzhXQTgrUTJ0TG1k?= =?utf-8?B?aFd3NXhlSGRUajRMZUE3VGlqOWVQTWdNZGp4RVgrcnNWZHdqUXloM3B1MkVQ?= =?utf-8?B?VWFVb2xWQjJKSGNsTi85cW5vSnBQamJ5Rmt1ZFF1eENjMnpoT0Z6TnpjOE1y?= =?utf-8?B?aWZRZTJKblY1M2FpVW5yNVgrUzBYUVRNd3RxVjhYQVlpS3VFRUtnVzVYVWw5?= =?utf-8?B?VCtHb3NMODhqUDdzMEJWdUhKSzBESDRyMHdTSkh3dlNxUVVSaDcxSUgySVFH?= =?utf-8?B?YzNXeWJvMnpKQ2w5Z3RYbW1lL1lENHRMQStuZ1hkQWJqNTZKaHpkLzFmdXBP?= =?utf-8?B?bkRqVHNmU3kvVnd4bDVHSFZOVGQwWTBvSjY5aVhIOXIzdWJUd3h1d1NCb0I3?= =?utf-8?B?TXZLRVlOWGg3MU5xSW9GRitiMzI0MWtQK1ZQMmdqYjdtV2ZzdVJUc2dXODNG?= =?utf-8?B?M0twcGJTYkswNVlVYWxZYX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elBmeU5KWDNiTkYrWUM5S3ppVnRFSHdPVWUyUEpUbzhm?= =?utf-8?B?VVBodk53cTVpeGQwcnllTnB2RXZxYkxTS3hodjVZYlEvTkR1K0pHTWR5VGkv?= =?utf-8?B?RXYxcFUvY0VNSWVpQm1mV21QRTlCTXdBYnYzQUd4aDRUV25NbkF1SXNBVHVR?= =?utf-8?B?QjcySVFURUNPMG92Tm0rWUhtYWlzZFFwUnRuNDNPUEVaalE9PQ==?= 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: 05 Nov 2024 15:33:31.5141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20c99e3f-bb23-45fe-d426-08dcfdaf3425 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9189 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- v4: * add alienware-wmi too --- 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_d= evice *sdev) =20 tpd->sdev =3D sdev; =20 + tpd->handler.name =3D "Surface Platform Profile"; tpd->handler.profile_get =3D ssam_platform_profile_get; tpd->handler.profile_set =3D ssam_platform_profile_set; =20 diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wm= i.c index 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; =20 + platform_profile_handler.name =3D "acer-wmi"; platform_profile_handler.profile_get =3D acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set =3D diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/= pmf/sps.c index 92f7fb22277dc..e2d0cc92c4396 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) amd_pmf_set_sps_power_limits(dev); } =20 + dev->pprof.name =3D "amd-pmf"; dev->pprof.profile_get =3D amd_pmf_profile_get; dev->pprof.profile_set =3D amd_pmf_profile_set; =20 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 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 *as= us) =20 dev_info(dev, "Using throttle_thermal_policy for platform_profile support= \n"); =20 + asus->platform_profile_handler.name =3D "asus-wmi"; asus->platform_profile_handler.profile_get =3D asus_wmi_platform_profile_= get; asus->platform_profile_handler.profile_set =3D asus_wmi_platform_profile_= set; =20 diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x= 86/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) =20 pp_handler.profile_get =3D thermal_profile_get; pp_handler.profile_set =3D thermal_profile_set; + pp_handler.name =3D "alienware-wmi"; =20 return platform_profile_register(&pp_handler); } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index 972385ca1990b..3cf79e55e3129 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -247,6 +247,7 @@ static int thermal_init(void) thermal_handler =3D kzalloc(sizeof(*thermal_handler), GFP_KERNEL); if (!thermal_handler) return -ENOMEM; + thermal_handler->name =3D "dell-pc"; thermal_handler->profile_get =3D thermal_platform_profile_get; thermal_handler->profile_set =3D thermal_platform_profile_set; =20 diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 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); } =20 + platform_profile_handler.name =3D "hp-wmi"; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); =20 diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/i= deapad-laptop.c index 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_p= rivate *priv) =20 mutex_init(&priv->dytc->mutex); =20 + priv->dytc->pprof.name =3D "ideapad-laptop"; priv->dytc->priv =3D priv; priv->dytc->pprof.profile_get =3D dytc_profile_get; priv->dytc->pprof.profile_set =3D dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platf= orm/x86/inspur_platform_profile.c index 8440defa67886..03da2c8cf6789 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, co= nst void *context) priv->wdev =3D wdev; dev_set_drvdata(&wdev->dev, priv); =20 + priv->handler.name =3D "inspur-wmi"; priv->handler.profile_get =3D inspur_platform_profile_get; priv->handler.profile_set =3D inspur_platform_profile_set; =20 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_acpi.c index 4c1b0553f8720..c8c316b8507a5 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10549,6 +10549,7 @@ static void dytc_profile_refresh(void) } =20 static struct platform_profile_handler dytc_profile =3D { + .name =3D "thinkpad-acpi", .profile_get =3D dytc_profile_get, .profile_set =3D dytc_profile_set, }; diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index f5492ed413f36..6fa988e417428 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -27,6 +27,7 @@ enum platform_profile_option { }; =20 struct platform_profile_handler { + const char *name; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2 --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.50]) (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 CD98E13D52E; Tue, 5 Nov 2024 15:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; cv=fail; b=rEyV/DJnAQLGjEhJiLk7KMm+rBVfKenofMG6M8q1deA1aXK47fnxrS7ZMw47KZOR6s/evrzdQ+Hc4b6jc81z4mUv2OKW+iisTCjQBCqtM92A8KnCD2KVdRKhkvypII9MvQPOWuox+EJOJZO/sw7CaniOSjQVtssqOmOH51mIyss= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; c=relaxed/simple; bh=Hf4w1lZfBgnE3Sq+P9ER52v4RFaq4g6HvEIEXOsuI1w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lkzRPoCxLH32ZssqVJG11BhwQyS59AA4/uyab99vDx0KnXAwRcCKuTaB1AentV56+i/qgsBopQnNgjWEmXObmlqg8mh7a94Eb/hD0YxLCwfl5iX9gfc5kcS735ThXeOblLEAXWWvh50DFcTRlxrSJ4PBAtgisBCefSJ1SdI57BU= 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=lSzG5P+A; arc=fail smtp.client-ip=40.107.237.50 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="lSzG5P+A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AnZ97z9toftLSjMzFRhRic8jbOV3xPW+D3YkRqZxplf5TRph3HvSGXrMsDK5tJupubVt7mGiUMQqOfy5bh29XeyNarF1tEdEYpNyfxuvkiuS4tgmxi8LnT2rBpHYQ4d2bi2dkQUHPIu4t9T6njJ6+pU0X1KqLjTC8amHYjXBmO0DTKdsji7of4hHYErP9qB/WxFWe9taWSXbhWshyrmC0/UcfR0c8Axc3+zIX4icy/UvzO4t+qQRYA9y1evZjYzkOgUXWQGr7FNso8KDeIndqWdA3w10kVmoM7V+uH3fBpt2v6ZX6qqkT7FX4JmWGvxmPPDhaK6hsCLXoScWGTs0Rw== 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=3oVr6vEiyIil7hu0Gy4FhGVYc4++Na2Ht5xVbuuI/U8=; b=pKXJk9+d2YYRLtZtEhd4AZPvnPOwmM9CWsBxMdR3Ti9Pchs2/PezzkaraZ24SAmrDdeMUByJOAGtnleF+PES60Cos5pfUN6VbK1Zh9UADKaUM+aX8UTQw19pDczFjp5QwCWxDZiS7kwAX9FkjPYxkmkpnYm7MUDiVTstS0kYEftilDZx71UfV8ZrsGvKofN4Y1h7qvuEEE/lUzfc+UPwvVOD0ji3cl4TFt9QtG3u9lnFBxCLh41PyQGBmR/YhvvDrxv+5432K0GBjDC7S2eIHzpDW4Iu57d4znUJV46/ag42bRjhIac7lSf7+3SOEHWJEFpaf9BmHoC7JqmRmaVWdQ== 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=3oVr6vEiyIil7hu0Gy4FhGVYc4++Na2Ht5xVbuuI/U8=; b=lSzG5P+AwfGLUsXNFvo0VeAgma+URK7QpslxSfxQni3cmMAVuyTnKK50944i770lj0P1s6/AcwkJb6x5aTEgyqpoJxnP+vMCq+OiQaJh6FTFBI1lq0FCKNxVxKLeozBxxps13uByNSsmmTst1NlRo2VMw38ZT/OmDSEtda6F3T4= Received: from MN0PR04CA0018.namprd04.prod.outlook.com (2603:10b6:208:52d::11) by SA1PR12MB8723.namprd12.prod.outlook.com (2603:10b6:806:385::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Tue, 5 Nov 2024 15:33:34 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::1b) by MN0PR04CA0018.outlook.office365.com (2603:10b6:208:52d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:30 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 02/20] platform/x86/dell: dell-pc: Create platform device Date: Tue, 5 Nov 2024 09:32:58 -0600 Message-ID: <20241105153316.378-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: BN2PEPF000055DF:EE_|SA1PR12MB8723:EE_ X-MS-Office365-Filtering-Correlation-Id: dd4a8b8a-9d99-47b2-3b15-08dcfdaf3571 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: =?utf-8?B?Q0U1S2tFUGZab1RSZnVzandPb3VRTHBRcThyb0ZwQ2QwOWpSblF5T2RuM3V6?= =?utf-8?B?MGxzeURubnRCN2JPTXg1OUIxU1ZYWTMwNmRhWWJmSHZZZU5TVUg1T3E5dVhB?= =?utf-8?B?L3h0YjN6WFJycVNMcTVVaDJZSi9xVFNVWTIvTzAvSzcrYzlQZk5sWmJRd0NK?= =?utf-8?B?cGdIcUZxV29Fc21YMDA1eE1jZVltckprTFFwcTNDdHZTbUNYOFJuK2prbDg5?= =?utf-8?B?M1B6TXlKNStFNlZ2RHBZdWlnVTVkWkZ6c1F0dXlyRlhvejJYTW5IMGZoZVBn?= =?utf-8?B?UGFqY3p5SWYwTWQ2WmpNdndZanVjZGErUnp5bzQxVTRueVBJcGc0Ky94NVY3?= =?utf-8?B?eml5Qi9FbHVSbk1KTzVjL1AxZXZQVjRSbUI4NU9HWFBmWGtPTndRK1hWdHVH?= =?utf-8?B?VGJYaFF0SG5saXEyclE0dzhQeGpnRnRBbDhYMnRKK3l2Qm5PNk5UZlB6bDBB?= =?utf-8?B?UmxsdGIza2JvRUdBb1hUOXlyRDNwc0s1VHgzck1NSkJ6TXQ5RmhpMWV5U2F1?= =?utf-8?B?cmVZMVFpaW9yaVhkVmZXMkRKMWpQR1Y5dWN0T0JCZnJzTzZ2UVhPRkJ5RDBk?= =?utf-8?B?MXkrWFp6dEViVGs5OVpJNHdCZzJmTXlYN1Q0eFB0TS9jS1FNTDBvQ0lRa2N3?= =?utf-8?B?Y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XaG5RTkxJ?= =?utf-8?B?TWpCVm1TWDh1MityT0g1enQ3UXp3UUNyZCtmRm1KaytOQzNFeFBlcXNvWHYw?= =?utf-8?B?eDBTd2RSTWFlQnNXYlpjTldJQkd6dE9MS0lvbXJBVFhhSVpIZ0NGSUN6NFJO?= =?utf-8?B?bWZTMm04d0djdjhXUk84ckQwOHNxZCtOTEpxN1E0QmVySFFUSkh5SkZPdkw5?= =?utf-8?B?Q1EvRkhtN09aZ3VJQ2ZvS2szOUhweGNnV0NyZ1lVTXlkb1lmdUZqMUZKcHJx?= =?utf-8?B?UzJXckRGZTNxaVFEczZnUXB5RzVrTDZ0Ym1QdEYvaUNuSWxFbHpqMVlIS2RH?= =?utf-8?B?RWNsMGYrd1RTZ2F3c1NQUk1USWJEbUZiamRJOWRDZnNtOWc9PQ==?= 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: 05 Nov 2024 15:33:33.6703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dd4a8b8a-9d99-47b2-3b15-08dcfdaf3571 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8723 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: Ilpo J=C3=A4rvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- drivers/platform/x86/dell/dell-pc.c | 35 +++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index 3cf79e55e3129..b145fedb6b710 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -18,10 +18,13 @@ #include #include #include +#include #include =20 #include "dell-smbios.h" =20 +static struct platform_device *platform_device; + static const struct dmi_system_id dell_device_table[] __initconst =3D { { .ident =3D "Dell Inc.", @@ -244,9 +247,18 @@ static int thermal_init(void) if (!supported_modes) return 0; =20 - thermal_handler =3D kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) + platform_device =3D platform_device_alloc("dell-pc", PLATFORM_DEVID_NONE); + if (!platform_device) return -ENOMEM; + ret =3D platform_device_add(platform_device); + if (ret) + goto cleanup_platform_device; + + thermal_handler =3D devm_kzalloc(&platform_device->dev, sizeof(*thermal_h= andler), GFP_KERNEL); + if (!thermal_handler) { + ret =3D -ENOMEM; + goto cleanup_platform_device; + } thermal_handler->name =3D "dell-pc"; thermal_handler->profile_get =3D thermal_platform_profile_get; thermal_handler->profile_set =3D thermal_platform_profile_set; @@ -262,20 +274,25 @@ static int thermal_init(void) =20 /* Clean up if failed */ ret =3D platform_profile_register(thermal_handler); - if (ret) { - kfree(thermal_handler); - thermal_handler =3D NULL; - } + if (ret) + goto cleanup_thermal_handler; + + return 0; + +cleanup_thermal_handler: + thermal_handler =3D NULL; + +cleanup_platform_device: + platform_device_del(platform_device); =20 return ret; } =20 static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } =20 static int __init dell_init(void) --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2075.outbound.protection.outlook.com [40.107.93.75]) (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 4BDE113CFA8; Tue, 5 Nov 2024 15:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; cv=fail; b=qTjl38XTnLOGRaLQhcBU+9whaoFTTC4xdNMOWM9EiSG9+8qdNLUKL2BPv4DNI8Hjs69i7+WIjb2xnguPhgEvLf3ytRpATwRFiMc4WvsvOibfQUSKVg4emm2ynVJUjy1uYI9TMVyqWWKyP6u0fF5R7zDTewPNLrFXDBLfTQIlX7o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820821; c=relaxed/simple; bh=BmMR1Enibk1nJMvtTQUaBjCmHf+VJwF7HpJDuAA3Jlw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZEPrmFwcL9BVH1PJVWCErTejLBwr/1Uo4BhB4yb5+0/4z7HlJH7fTaEG1Zpkx1XOO6QxW9sQqoB4hYQcmBx2GEq7HLMPyp34Dt/ITjk6CYycF9lVC3xLSnzgBXY4QiPyxUpp3pmzVoQyJ2HkZzeeOdA6HemSZwdf/iy9WBVroWY= 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=M5ei7LHA; arc=fail smtp.client-ip=40.107.93.75 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="M5ei7LHA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YqI+pM5pn1PG/rhAAFr6E/IqIfGui+kVaJMbsAzOGOETYw+LcolTOXHwSwTPOuiWomNFQk+O17zBZcrBqXnmHwUeNjPvjMYYipWOXik950k3HUrOlNLGhWs7TO2wXFZ4n3ar1Co5ec5OMRwFRu6C2lu0iG3vWCJk1nscWpfe/gQkVt7buTiyKTXZFPYc7B1aOVm6kb4VGeaJDAn9Qkh20M2q+iG1hn43cQ/g1Iw2bIJ5Z1VbVZK0Ra0g44N92zF3AXakxTH8CDM/e2K3FwN8SJ3OvQbBp3yMrAWNBoGTH2Cj1X4lHsE/m4NDN8JTEdQN3IMgQacd39JmqqW3o93piA== 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=akdffAgsWFY5qLva447baJQ/DW+tvIatLdlKwEunKCY=; b=y81DnYwytWgjirJ6RpCycPOrjp+BBvT38hRhMg0qZ8splRdcRTq4xsz3vb4i97HiKzruvTbIvb4LPpmGO0Zxo8Sr9A1xtLSjvhtTmR00TSaveII7qqNIsjFuOWNPc7+UZVJjqULRQ+PCY4yWQ1mjekHSp7kwsw4F9TJV4DTKDzrA9RbSY1Zap77vwEe7Usg/KHk6H93WHjnAiHko2IC0kWNnnC0Q6CADkLzGGORUO943ajuWiviyMYHvAOaZnwFd0+I0qhySVs06Ml8ZIcfyMWqlmOUD4LuFmY5kDvbmHwqQ2OKYIsuQdTghX6gyYoV4iZnCw0y8IaKpIEhXRxrBTQ== 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=akdffAgsWFY5qLva447baJQ/DW+tvIatLdlKwEunKCY=; b=M5ei7LHA7hvRIiAPedggKuKO8ZKaTTX7pVAaPrub78BN9n566tlDAr6tR2jaA9chWup6lrErzJG+r2uOVbFlJEx9lHCBN/bqvVsfARVyn5buKysRjr1bjZuLcK1gGggXbWFH2SCDaHUPHqO0IoWbVJ7As5L9bJGd2csOOzoFFK4= Received: from MN0PR04CA0007.namprd04.prod.outlook.com (2603:10b6:208:52d::12) by SJ2PR12MB8928.namprd12.prod.outlook.com (2603:10b6:a03:53e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:36 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::7c) by MN0PR04CA0007.outlook.office365.com (2603:10b6:208:52d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:35 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:35 +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; Tue, 5 Nov 2024 09:33:31 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 03/20] ACPI: platform_profile: Add device pointer into platform profile handler Date: Tue, 5 Nov 2024 09:32:59 -0600 Message-ID: <20241105153316.378-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: BN2PEPF000055DF:EE_|SJ2PR12MB8928:EE_ X-MS-Office365-Filtering-Correlation-Id: 6fc0725a-8d2b-466e-53b2-08dcfdaf36ae 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: =?utf-8?B?L3MzRmVmNFhSbTl4YzZBMTZ2bWJxc0U4RzJjSkhRWmloc09rMFptQURJbE9h?= =?utf-8?B?SXZHdlVBeWMrdHZCWHIzUU9BdEU0TWRyR3dGSDZOdHhNMFU5ckZKK0kzREVR?= =?utf-8?B?bUxVRHYzNm9MbS9Qem1jUEU2MWJFaHd5THZCeXFDS2d2dSt6NDdZKzRyKytD?= =?utf-8?B?aE9vS2UzSm9zVCtTVFRKdWFKNGpPT1lub0p3c2EyVGFqSzFUdEJPVWNtVjRS?= =?utf-8?B?aFBqR3dqKzNEZlIxSXJCT3pGbENuWldkTGJnUEpvTWNjL3JzS0kwSTJwemRx?= =?utf-8?B?L2poaVlsSWFQbEo1WFV1UjdvTDVhUldsOGJIemY5Y2cvaHI5TWNuTUZtM3NF?= =?utf-8?B?MXRESTMvVkh4RktsR0xsSzBWdW54ejhYdXZHY3ZQSlpmbkFCK01VdGp4ZHRX?= =?utf-8?B?WkNObExsR012UWpDOURDWU0xdkhMcXFuMEgzL1VDa2VBRERjdkxSN0NUQk45?= =?utf-8?B?dkk5aThMOWkzSk5pSzRGdE5SNWdSOGRYZ2EyVVlEWGkyaTgvMGk4RGlyNjd6?= =?utf-8?B?RXRBMXoyc0hwNGVWVzEycVFCSkhSUDIyMXR6dXJFNXdFV2t3ZTNRbkNHZE5E?= =?utf-8?B?U3o1WkJ6djdZVG1jRFZSTjlscHBGN1pMWkp3RjNLQzM5Z0sxUXlMUVNFZmV6?= =?utf-8?B?dnZ1bERGRjdaWmRsQVE0ZXAzbUxpMU9yVlloY1FnbTRjMVdnT1l3YW42ajN0?= =?utf-8?B?dU0xVVF3L0NjbWVmUzJtTWtacmc0eDRqYittQUxDN1lZUnRrRjA1M0lVVlRT?= =?utf-8?B?UU9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ZGEvK1d5?= =?utf-8?B?K2ZVQm5JZ2JqQWJMT1huSDhxOU5mdStYNm1WZ0xtOTlubzdYMFdJNzVVYldz?= =?utf-8?B?YlNHUDc0WkxEQlcwZlRWYW9nbE5DTU5LZ1I1OC9LMldDeU9OWXVmTitoalVE?= =?utf-8?B?WUdDazhibGhFUkxnTitMZTF3a0UvejBBMCtKcWhpV2NMbDIycXdDYUhCRFVW?= =?utf-8?B?UktOQmxDeHlHU1NNdlJwZEF6WEc3dEcxclhMc0xwU2FLa1E9PQ==?= 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: 05 Nov 2024 15:33:35.7641 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fc0725a-8d2b-466e-53b2-08dcfdaf36ae 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8928 In order to let platform profile handlers manage platform profile for their driver the core code will need a pointer to the device. Add this to the structure and use it in the trivial driver cases. Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Maximilian Luz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Tested-by: Mark Pearson --- v4: * add alienware-wmi too --- drivers/acpi/platform_profile.c | 5 +++++ drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 5 +++-- drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 5 +++-- drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 5 +++-- drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 12 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index d2f7fd7743a13..5d9f3f7ba71c5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,11 @@ int platform_profile_register(struct platform_profile_= handler *pprof) { int err; =20 + if (!pprof->dev) { + pr_err("platform_profile: handler device is not set\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/= platform/surface/surface_platform_profile.c index 61aa488a80eb5..5f45f8e8cd69b 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -212,6 +212,7 @@ static int surface_platform_profile_probe(struct ssam_d= evice *sdev) tpd->sdev =3D sdev; =20 tpd->handler.name =3D "Surface Platform Profile"; + tpd->handler.dev =3D &sdev->dev; tpd->handler.profile_get =3D ssam_platform_profile_get; tpd->handler.profile_set =3D ssam_platform_profile_set; =20 diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wm= i.c index 53fbc9b4d3df7..aca4a5746bee1 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1873,12 +1873,13 @@ acer_predator_v4_platform_profile_set(struct platfo= rm_profile_handler *pprof, return 0; } =20 -static int acer_platform_profile_setup(void) +static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { int err; =20 platform_profile_handler.name =3D "acer-wmi"; + platform_profile_handler.dev =3D &device->dev; platform_profile_handler.profile_get =3D acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set =3D @@ -2531,7 +2532,7 @@ static int acer_platform_probe(struct platform_device= *device) goto error_rfkill; =20 if (has_cap(ACER_CAP_PLATFORM_PROFILE)) { - err =3D acer_platform_profile_setup(); + err =3D acer_platform_profile_setup(device); if (err) goto error_platform_profile; } diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/= pmf/sps.c index e2d0cc92c4396..1b94af7c0e0c4 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -406,6 +406,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) } =20 dev->pprof.name =3D "amd-pmf"; + dev->pprof.dev =3D dev->dev; dev->pprof.profile_get =3D amd_pmf_profile_get; dev->pprof.profile_set =3D amd_pmf_profile_set; =20 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index c7c104c65a85a..78621b2af0ddb 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3911,6 +3911,7 @@ static int platform_profile_setup(struct asus_wmi *as= us) dev_info(dev, "Using throttle_thermal_policy for platform_profile support= \n"); =20 asus->platform_profile_handler.name =3D "asus-wmi"; + asus->platform_profile_handler.dev =3D dev; asus->platform_profile_handler.profile_get =3D asus_wmi_platform_profile_= get; asus->platform_profile_handler.profile_set =3D asus_wmi_platform_profile_= set; =20 diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x= 86/dell/alienware-wmi.c index ac0038afd98fa..c03b1aa7dfb5f 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1017,7 +1017,7 @@ static int thermal_profile_set(struct platform_profil= e_handler *pprof, return wmax_thermal_control(supported_thermal_profiles[profile]); } =20 -static int create_thermal_profile(void) +static int create_thermal_profile(struct platform_device *platform_device) { u32 out_data; enum wmax_thermal_mode mode; @@ -1057,6 +1057,7 @@ static int create_thermal_profile(void) pp_handler.profile_get =3D thermal_profile_get; pp_handler.profile_set =3D thermal_profile_set; pp_handler.name =3D "alienware-wmi"; + pp_handler.dev =3D &platform_device->dev; =20 return platform_profile_register(&pp_handler); } @@ -1125,7 +1126,7 @@ static int __init alienware_wmi_init(void) } =20 if (quirks->thermal) { - ret =3D create_thermal_profile(); + ret =3D create_thermal_profile(platform_device); if (ret) goto fail_prep_thermal_profile; } diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index b145fedb6b710..730f97aab70cd 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -260,6 +260,7 @@ static int thermal_init(void) goto cleanup_platform_device; } thermal_handler->name =3D "dell-pc"; + thermal_handler->dev =3D &platform_device->dev; thermal_handler->profile_get =3D thermal_platform_profile_get; thermal_handler->profile_set =3D thermal_platform_profile_set; =20 diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 26cac73caf2b9..ffb09799142bc 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1565,7 +1565,7 @@ static inline void omen_unregister_powersource_event_= handler(void) unregister_acpi_notifier(&platform_power_source_nb); } =20 -static int thermal_profile_setup(void) +static int thermal_profile_setup(struct platform_device *device) { int err, tp; =20 @@ -1625,6 +1625,7 @@ static int thermal_profile_setup(void) } =20 platform_profile_handler.name =3D "hp-wmi"; + platform_profile_handler.dev =3D &device->dev; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); =20 @@ -1664,7 +1665,7 @@ static int __init hp_wmi_bios_setup(struct platform_d= evice *device) if (err < 0) return err; =20 - thermal_profile_setup(); + thermal_profile_setup(device); =20 return 0; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/i= deapad-laptop.c index 1f94c14c3b832..24367c3590c99 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1103,6 +1103,7 @@ static int ideapad_dytc_profile_init(struct ideapad_p= rivate *priv) mutex_init(&priv->dytc->mutex); =20 priv->dytc->pprof.name =3D "ideapad-laptop"; + priv->dytc->pprof.dev =3D &priv->platform_device->dev; priv->dytc->priv =3D priv; priv->dytc->pprof.profile_get =3D dytc_profile_get; priv->dytc->pprof.profile_set =3D dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platf= orm/x86/inspur_platform_profile.c index 03da2c8cf6789..5a53949bbbf5f 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -178,6 +178,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, co= nst void *context) dev_set_drvdata(&wdev->dev, priv); =20 priv->handler.name =3D "inspur-wmi"; + priv->handler.dev =3D &wdev->dev; priv->handler.profile_get =3D inspur_platform_profile_get; priv->handler.profile_set =3D inspur_platform_profile_set; =20 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_acpi.c index c8c316b8507a5..222fba97d79a7 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10616,6 +10616,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init= _struct *iibm) dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); =20 + dytc_profile.dev =3D &tpacpi_pdev->dev; /* Create platform_profile structure and register */ err =3D platform_profile_register(&dytc_profile); /* diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index 6fa988e417428..daec6b9bad81f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,7 @@ enum platform_profile_option { =20 struct platform_profile_handler { const char *name; + struct device *dev; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2075.outbound.protection.outlook.com [40.107.100.75]) (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 5C7DA7346D; Tue, 5 Nov 2024 15:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820824; cv=fail; b=udpt4MiDg50q9RylHAYyufo6jfW1sbNK8NSjGs8NbTs348ejwn6M22I1ZMNZdYAlJuk2JL1KtMI4vtaXaq5iQyAX2JFeyBy4YKafGzZJky0LbX0AdXyOi+jUyopUnjkGGCWfHIKSpiozBhlLaub7gBcjXWM5IfLnKo4stJFQpKk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820824; c=relaxed/simple; bh=xE8tgTFhgfeuOgCsUZhC1WiaGITJjtf48n9pdqNlCns=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qb3iL9FaPXPfQ4jC8eg7XwhlVFrloXq8XXLeicc05kB/8MR36nicKflcXoT7HN97oCmR039rgDkIZbinBznHViYxyHxsjUCP/c4Iod11JRWXqrJ//S/Ave8obAOt5hElyJZpvRXPp+DaBewVJPo5cM2TqlN87ARrCC/KmZvaJS4= 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=I3BSPjCc; arc=fail smtp.client-ip=40.107.100.75 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="I3BSPjCc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LbJ/Oj84acB7SjgYeFKlO8rWu/DAGuxvfJ1GUdBf9A1G+xpbyWFhiFAvCrIGA3DYWglb8O3v14zLTo0jRrQEXcO4/y+CHW72I3sKCfLk0aOxtltZT93r+tsx5UXQNL2Px04R/0qkdwkDG8nbXDWqo8tA4m3wy+Eeo+TCW8ApzeSe4Unu3NiRQfDXmsVm+kjDRPsi649sGTbOnWANgbKw16sEJ8vIPUv835S20+Uz7QRA8vADhBKz8yzwVKx+M5ITW1jeiCQX6K/afk6Y2QJr9ZkRn7Bo/6Y/nQ3x1VpTafBSL4nwG5KESvVqxL1fqXmV45VJnqmcW9sUtArgOC/BSg== 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=CpP+8+J+86qUK9POCB3KSfm3Zjzt6p92edc6CL2tMVE=; b=N4c7Gu4Nfu2ReE1kIpJehcy3HMgIMRwb6ThlgLsy3YRhhUVdOqTR1Rw5eJMTlY5szf162KXq/CGC23zq3/+xDjgeQa5y1/nUhYksJ9jyZrmfXUEzZwerouhLAb2TVPtgbyMB+jie1M+nrXJysUEbs6qPdLOZA3TYWMIF6++dCQNYu3+R5cF6KhHQqKlAtkBfuzBC+scYxU9QiAHuj+bWDM2NYfRxb8mKUJ22h3bngM2Sma6OImZ1gx2XOusjaidUi0HrVySCv5VNZWEF8lU0BVOl3jkRWM8h8bxjmvUW498DlygGIiiU5N+ybJ92E5FuZJkFktVikYh8gS5Bt8zYSQ== 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=CpP+8+J+86qUK9POCB3KSfm3Zjzt6p92edc6CL2tMVE=; b=I3BSPjCcjAcZc+eSXYPJkARwTfGuFLEtIBx6QdbzzWdTc4jjZWgqfQEPrS5zyJStcPcEU2x4Ex1PMSxkNZjs6IjvDwev/dAIk/EqZjlVQrKawi3e7PkOrR4YsxQs1HJFmDO0mR8LNItiztdmq2lWMkg233akDb3TLR61393GOo0= Received: from MN0PR04CA0008.namprd04.prod.outlook.com (2603:10b6:208:52d::22) by DM4PR12MB6448.namprd12.prod.outlook.com (2603:10b6:8:8a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.29; Tue, 5 Nov 2024 15:33:36 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::40) by MN0PR04CA0008.outlook.office365.com (2603:10b6:208:52d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:32 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 04/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Tue, 5 Nov 2024 09:33:00 -0600 Message-ID: <20241105153316.378-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: BN2PEPF000055DF:EE_|DM4PR12MB6448:EE_ X-MS-Office365-Filtering-Correlation-Id: cce979da-cd70-45f5-c49c-08dcfdaf3720 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?RnhtY3R6RTF0ODhZNEdkcEdaZzNpNmlZUXAwT2FaNWZ1czMrWU1pY0FZMmpo?= =?utf-8?B?bmVoeUN6dW5HMHFoYWs5bDV5NFhvOFVNYzFzSEtYZUJ1R1NRaEQvWEFBMUxh?= =?utf-8?B?cjFMY09TU1FkZW4yYS9OUmhXS3AxOGhjbmxYdXl6WjZLVnhqZndWT2tXNGtm?= =?utf-8?B?ZCtCeEVpWGhGWTFmVktXSytCYm5Td21PWndaMXlJSW5EMncwN1RGb1VVKzhj?= =?utf-8?B?Vi92ZlRHTW4zQjRPWkJMYVFLZWs4ZTFxTzR5cCtwZm9CM2RMR0dWOXJQQkdm?= =?utf-8?B?NG53bnNMa1h1WUZMUE9DRDB1MkVjRjRiRG1lclBmWmVzZE56NTBYMlhSd2xS?= =?utf-8?B?VmtUc1JYcGp5ZTJMUmdQQ1F3NDRUU3ZSOW43b2RwSlV5em02a1dEdnBvSFJZ?= =?utf-8?B?bW83S0VudjJDN29KZ3kvVGdkVkUzeWdEYjU0UWJuSnh2SXkyc0ZRYnFybWVY?= =?utf-8?B?dWNEeWVFcjAvK09RbXlQQkU1V0hndTM5VWxBci9TWE1HTUlvZ29Tb2lieElS?= =?utf-8?B?d0Irc202UlJsUGtjNFBwU21IYnFIWUIyUzJPYXJ0dno4R1lUUVZ0aXRwQVJn?= =?utf-8?B?QmFVR3h6WkRhUjQxOURqam5KeGQ2YWJkdWhOZXA2eFBHUVlaNzA5cjJ3WUZ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kdxdkk5TUlKUUpJ?= =?utf-8?B?QUJSYXB6Rmp6VCtFbGoyczZZRXhTZklsb3RiVXpuc1kycDhiMFdqSnFaTHMx?= =?utf-8?B?OEYrWDdnUlRzeFgwOTdGOXlaSUlXeUVOcnZGU2xjQXhPaS96bFQzbmxlVDhO?= =?utf-8?B?c2hjeDdJTkp6c0xlSk9DQzVXTE9BZ0pIejF0dkFWSWFta1JzYnBlMVpRcWUy?= =?utf-8?B?NEJEall1VDYzV3NkMDVVWUZwQ0g5MThReFEvYmlFNEZhSHJ4M083ejh0VmJM?= =?utf-8?B?MWtiMzBDZFJhOXIwRTAwbmY2ZDJMRjB2aDRCUTNJQ0VXRSt0MFpKKzBiUUp6?= =?utf-8?B?dXc0OFI5MjE2bFJZUWw2dHNZaGNMZDlHLytBaFByRmJDbWc9PQ==?= 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)(1800799024)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:36.5141 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cce979da-cd70-45f5-c49c-08dcfdaf3720 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6448 To allow registering and unregistering multiple platform handlers calls to platform_profile_remove() will need to know which handler is to be removed. Add an argument for this. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- 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_profil= e.c index 5d9f3f7ba71c5..c76b8e3fdcde6 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -210,7 +210,7 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) } EXPORT_SYMBOL_GPL(platform_profile_register); =20 -int platform_profile_remove(void) +int platform_profile_remove(struct platform_profile_handler *pprof) { sysfs_remove_group(acpi_kobj, &platform_profile_group); =20 diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/= platform/surface/surface_platform_profile.c index 5f45f8e8cd69b..b449c4c8b883c 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_d= evice *sdev) return -ENOMEM; =20 tpd->sdev =3D sdev; + ssam_device_set_drvdata(sdev, tpd); =20 tpd->handler.name =3D "Surface Platform Profile"; tpd->handler.dev =3D &sdev->dev; @@ -228,7 +229,10 @@ static int surface_platform_profile_probe(struct ssam_= device *sdev) =20 static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_platform_profile_device *tpd; + + tpd =3D ssam_device_get_drvdata(sdev); + platform_profile_remove(&tpd->handler); } =20 static const struct ssam_device_id ssam_platform_profile_match[] =3D { diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wm= i.c index aca4a5746bee1..b12965d9fcdb7 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2547,7 +2547,7 @@ static int acer_platform_probe(struct platform_device= *device) =20 error_hwmon: if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); error_platform_profile: acer_rfkill_exit(); error_rfkill: @@ -2570,7 +2570,7 @@ static void acer_platform_remove(struct platform_devi= ce *device) acer_rfkill_exit(); =20 if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } =20 #ifdef CONFIG_PM_SLEEP diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/= pmf/sps.c index 1b94af7c0e0c4..bd2bd6cfc39a0 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -426,5 +426,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) =20 void amd_pmf_deinit_sps(struct amd_pmf_dev *dev) { - platform_profile_remove(); + platform_profile_remove(&dev->pprof); } diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 78621b2af0ddb..0750e2fe65325 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4886,7 +4886,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); @@ -4913,7 +4913,7 @@ static void asus_wmi_remove(struct platform_device *d= evice) asus_wmi_battery_exit(asus); =20 if (asus->platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&asus->platform_profile_handler); =20 kfree(asus); } diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x= 86/dell/alienware-wmi.c index c03b1aa7dfb5f..3cf6c371d4220 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1065,7 +1065,7 @@ static int create_thermal_profile(struct platform_dev= ice *platform_device) static void remove_thermal_profile(void) { if (quirks->thermal) - platform_profile_remove(); + platform_profile_remove(&pp_handler); } =20 static int __init alienware_wmi_init(void) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index 730f97aab70cd..65989af2e4196 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -292,7 +292,7 @@ static int thermal_init(void) static void thermal_cleanup(void) { if (thermal_handler) - platform_profile_remove(); + platform_profile_remove(thermal_handler); platform_device_unregister(platform_device); } =20 diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index ffb09799142bc..6d6e13a0c6e2d 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1693,7 +1693,7 @@ static void __exit hp_wmi_bios_remove(struct platform= _device *device) } =20 if (platform_profile_support) - platform_profile_remove(); + platform_profile_remove(&platform_profile_handler); } =20 static int hp_wmi_resume_handler(struct device *device) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/i= deapad-laptop.c index 24367c3590c99..80797c6ae8b0b 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1136,7 +1136,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_= private *priv) if (!priv->dytc) return; =20 - platform_profile_remove(); + platform_profile_remove(&priv->dytc->pprof); mutex_destroy(&priv->dytc->mutex); kfree(priv->dytc); =20 diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platf= orm/x86/inspur_platform_profile.c index 5a53949bbbf5f..53af73a7fbf7b 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -191,7 +191,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, c= onst void *context) =20 static void inspur_wmi_remove(struct wmi_device *wdev) { - platform_profile_remove(); + struct inspur_wmi_priv *priv; + + priv =3D dev_get_drvdata(&wdev->dev); + platform_profile_remove(&priv->handler); } =20 static const struct wmi_device_id inspur_wmi_id_table[] =3D { diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_acpi.c index 222fba97d79a7..13798c6d5fcf3 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10638,7 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init= _struct *iibm) =20 static void dytc_profile_exit(void) { - platform_profile_remove(); + platform_profile_remove(&dytc_profile); } =20 static struct ibm_struct dytc_profile_driver_data =3D { diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index daec6b9bad81f..bcaf3aa39160f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -37,7 +37,7 @@ struct platform_profile_handler { }; =20 int platform_profile_register(struct platform_profile_handler *pprof); -int platform_profile_remove(void); +int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); void platform_profile_notify(void); =20 --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2043.outbound.protection.outlook.com [40.107.94.43]) (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 62FF0146013; Tue, 5 Nov 2024 15:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; cv=fail; b=roODfQo6V/LBWMWGviPV5yIYAZcLa7x9D/4Da9Q4dRiNgM+UR4zZPejR0xrYPfmeIpnznKWTappgezQK11i5++WBEXwyN1XeKDYChlm9jxXa7S8KHDalmocK6muiyejM4XmPbyHCJdPlPAazCk16PjMpfHV8p6tDDFHDEFhFC+M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; c=relaxed/simple; bh=coqx1ADwMrtXqO17eBAIJiGtY0S3w4Hi1a9kzpKViqo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZIbnnMysoFNQrP8xktuYpy58m7elMZde3iLYqnhR6YXHottRhwhxUERKgWogzZ/BrcK7zsKprb58zNIzNw89SSxy91TiGqDaBiNt7ijJbTNaDhwJrT7bMZdrZ/zYpNEkL1TGSa11nyg5XuGRMCbHyDCWZav9m7AeLIYk6UK1oIs= 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=uxuHjSst; arc=fail smtp.client-ip=40.107.94.43 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="uxuHjSst" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tUV+yMW+v50dewUWpC6Z7HviLSDYEMVy64xTuOkqXfPM3gWbI8Eb4Hy/61hA7jbvZflYfGwEM93nK6ffUpZ3vbTxSjqWVv/AOufSqjIYynosOUzrdQsR6vcRWbknjmq3gNOuzNZO2JAXRoIzrxzCGozAzlGcl52FeXD7xdjxlg9cbhF3FN0vWfNzWmAsOLvv4i55UdzbKcX17pNBRRg2Fu97bvdl4kCoOXlJawDncFejtTJwoDoVjUaFkNlaqZo92L/SMkFQs0Qmcugs6yNOJ5DIwUqDqIS5FW8nXj0byRpbsKoaEpqNhuOd2O3VZKORxe88DPMDnT1wEw5EqjryiQ== 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=NgdRMEm5b7ecUIgJRgBzczX2TCGPfumhFWdIRNlizFc=; b=zW6zxLHRPaEowdqX1idz2imKqkiKr2lwpAT/0KjYQNy+RAFJVUv2UODqnMdNetFzURkHlJegfoafHUmUb892kgoALUTqKR4lzTUl5UKZTn4esie7ETYRcbYgnO4xD7Y1ANaBo5QGIeXklvuOHzTj65Xbyv/O9106MzF0NOs8O2lUkM4OtNV+3Ha8RwAL6+GqjMc+FLj6lMaVo+t1tXw92BiITnCcr7W+kbRmfJ3G4j3jS2su7L05UZyel/w+NVLnF9xcL3eFHPQxY4u7ix2sEmn3EsEOmp7XZNg08ZL/rBC60pqFKxwxRqIIZmkrLQKPBKUKBGlY80781aUDAL5vSg== 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=NgdRMEm5b7ecUIgJRgBzczX2TCGPfumhFWdIRNlizFc=; b=uxuHjSst+FHZRO9Y7cwG21Xjy4+2FvmHpWdeUx7zwEwH3D0RdtHVo55JpIKvtXZVhlPhBNyFND8wCXOUXHyYeXw/91z4DdP0UIfizSalySnQHeZ9gsxxG7cMhnbJPhg+aTV+HPOG92ZFhaqti+A/UiICT8MTTw1yQy7oBaitS7U= Received: from MN0PR04CA0028.namprd04.prod.outlook.com (2603:10b6:208:52d::27) by PH8PR12MB6795.namprd12.prod.outlook.com (2603:10b6:510:1c6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:37 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::cc) by MN0PR04CA0028.outlook.office365.com (2603:10b6:208:52d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:34 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 05/20] ACPI: platform_profile: Move sanity check out of the mutex Date: Tue, 5 Nov 2024 09:33:01 -0600 Message-ID: <20241105153316.378-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: BN2PEPF000055DF:EE_|PH8PR12MB6795:EE_ X-MS-Office365-Filtering-Correlation-Id: c50279a0-0a90-4a09-8509-08dcfdaf3782 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?UnY1MG8vUG8yU1VEL0p0bVVldVlaN0NBZkk1YTczcEorNkJFOGRpOE1ZelRv?= =?utf-8?B?WGVZY2pWbG01cWZYQzhadlBEV1hoUncyMVdPUW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aGw5?= =?utf-8?B?TUxsa0Erb3dOcHFNM2s4NnlDR01iU2k1bjZwRllqaE9Lcmc9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:37.1547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c50279a0-0a90-4a09-8509-08dcfdaf3782 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6795 The sanity check that the platform handler had choices set doesn't need the mutex taken. Move it to earlier in the registration. Tested-by: Matthew Schwartz Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index c76b8e3fdcde6..4e8a155589c21 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,12 @@ int platform_profile_register(struct platform_profile_= handler *pprof) { int err; =20 + /* Sanity check the profile handler */ + if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || + !pprof->profile_set || !pprof->profile_get) { + pr_err("platform_profile: handler is invalid\n"); + return -EINVAL; + } if (!pprof->dev) { pr_err("platform_profile: handler device is not set\n"); return -EINVAL; @@ -191,13 +197,6 @@ int platform_profile_register(struct platform_profile_= handler *pprof) return -EEXIST; } =20 - /* Sanity check the profile handler field are set */ - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) || - !pprof->profile_set || !pprof->profile_get) { - mutex_unlock(&profile_lock); - return -EINVAL; - } - err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); if (err) { mutex_unlock(&profile_lock); --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2066.outbound.protection.outlook.com [40.107.93.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 1360414E2D6; Tue, 5 Nov 2024 15:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; cv=fail; b=mtmHqqgc3mEb/h41C8DV4qYq0MkS1lzX9+8Ltsq83y7tGuqTF2pvtS6KulOOldNX6Fzlq4EaGuXfmhIg0VFY/VPx6FQ98RfTkmq3zABGpXRUOoXaB8I0MIVtoWw/g3WM/wN7Mk9mKNLo9xLcxN4XmlYWTEYUI1s+DD+mhG/cYDQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820823; c=relaxed/simple; bh=vmH80ZPsQiWyuhHi93KG5eLUcVTYH8g9LsY0szntTDQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GspamskvqSgEpbKW2bIvVxqqElwOnagDNXltboiFGqWSaVLah3ET8V4dQVT9hHOkpKEihOujF3oBH94YqGYyYZgMLRB0ew2DuGd1uUYMxi8cc5P8Sy1fmK7vp4BZRAWawE4m4xzYqpjsgDJoDObmkoSZhun/RuwCIBNG+JUANZ8= 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=P+6+0jFa; arc=fail smtp.client-ip=40.107.93.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="P+6+0jFa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f/I2I5od0xbUO9lQpo2oyy55IrvGoL6O7auBP3A4ptK1B+OEyQ1/DDEW3JHWhD5jXWJGm6coj/XRin5bCBqlDXxMk10pJyA7Ykmr0fqapI5MmHHYvag0fFysOKhHiBdTlUrEfZbJQTpTy8QX5YBVQ/DfgD1qYJ24HzSMwvXd6mqqHTIrVa3pK/cke023CrCGrIEhtrwTHfvHD2SAr5vbzXsRda32FfgU2zPc5jE5Pj8LNXW1hEW/tBRv+tRz5z7bUTmi2Ohl3lqhpTPuIQb+5hesg3E2H4X/YyJpomg50GqFLVaFxtQJep90Gsn6xvd30vbPVUmHoFSQhCBZafvLwQ== 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=BpOOny12FmSUBq/F94SaWglUWvl7NYuCERlhr18ZrG0=; b=CeDhq06BaDxq90sdH/ST6ZRB73E32ASydCT5Msg9D8OKN9Rc17YInXtKuh08w/q1TcMyAHSPAdiYW3+HbsNpJdYVNUwZ0ELejVB8tN21j7bCF0Ic3DNuWBY0CgF9Ip1tZ42aQskENIAhbEins3VZdODNL+USOXnwT+0Id/D+JIBqhkR/04srjE3svzxq+o0XBDZReFEU9zWBjrqbPwBz1OkJuU5rAHXYY/SSn0GWqI8DnAooO6m+y+pdJpRFJwoWamfJ92nNQCj0UdGEeCqPnd3plujKNqUeyO6xbrqTOxBnpHLHX3occlZtvNWrgcbE9pRb9G0EGrK0jW2S0u1/rA== 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=BpOOny12FmSUBq/F94SaWglUWvl7NYuCERlhr18ZrG0=; b=P+6+0jFaiml2Cm1kD5edUDgd1x2kzJiYA2JuwCMTwF3OU81PWc0k3TlVueJhmco+Ehkp/cqPmhlnj8M+j1VwtUSndhzRuvUsR8s66XKAdKwgU1/p+U7kjZnTdEhW7sy0/LeJuue4u/I5TO3ZdeUZ9C/QxGLcVpUtPyATU4OWvGA= Received: from MN0PR04CA0021.namprd04.prod.outlook.com (2603:10b6:208:52d::32) by PH0PR12MB7982.namprd12.prod.outlook.com (2603:10b6:510:28d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:38 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::8f) by MN0PR04CA0021.outlook.office365.com (2603:10b6:208:52d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:35 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Tue, 5 Nov 2024 09:33:02 -0600 Message-ID: <20241105153316.378-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|PH0PR12MB7982:EE_ X-MS-Office365-Filtering-Correlation-Id: 93fdb62f-4ecc-4fbd-e19b-08dcfdaf3800 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dJyRmJYGBY2BUPla5l3t5xXPk6pTXX/RaiQcLhD+aTMyzbebAdVBVuKsP+eY?= =?us-ascii?Q?3X2Yn4dlZ8AE3wlqjliuQ7MM6Nz3z8n0SmX1BENPzgr0Bu4fagT9rvR+zZay?= =?us-ascii?Q?aO00XrFp2f2ZCC0tufWKbu7sRTZ4HgpyJQb0hveWpmAvmJb4QTvznAsvyd6Y?= =?us-ascii?Q?+mPu4zo8bry7C9Ao745nWLTQjx78VOcqrCfVik0WMnThjESQY5mc9FgZxK3Q?= =?us-ascii?Q?fDvO+YtFRXyd8LiJS2wukIKeEtbFvvuak7H8uGUgK+sPiBHXncW0DQnLCdOC?= =?us-ascii?Q?PDsrlunjqBzo3x/zS8w2nZInC/RgkS5PWvk+9v5F6+IC5rwpSHJR03PGS86p?= =?us-ascii?Q?b4X3zaw7GPM6IA0SnHfgKTwJrLdJvoaaS7dATaxC2AvTvA1Xw58bD37m+UhJ?= =?us-ascii?Q?u2+FYm2qD91PjFYcl1BfWH+Q0uHXSZ000o2HCnFoKjVtggSJfcFdwT+K3n88?= =?us-ascii?Q?BhlbKOEolCnJvvAWVW8UWFAJ+vrtaHugO3X7REjsr2A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bxGd8poy3BUnzfJ1TXu46XM4+eqBqFCVLdoG+LotA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:37.9828 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93fdb62f-4ecc-4fbd-e19b-08dcfdaf3800 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7982 Content-Type: text/plain; charset="utf-8" Holding the mutex is not necessary while scanning the string passed into platform_profile_store(). Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Reviewed-by: Ilpo J=C3=A4rvinen Tested-by: Mark Pearson --- 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_profil= e.c index 4e8a155589c21..70e7f1ba68676 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; =20 + /* Scan for a matching profile */ + i =3D sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + err =3D mutex_lock_interruptible(&profile_lock); if (err) return err; @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev, return -ENODEV; } =20 - /* Scan for a matching profile */ - i =3D 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); --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) (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 3D6B2145B14; Tue, 5 Nov 2024 15:34:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820849; cv=fail; b=Jc1K51sUmiDeHekFgn1FX5rNmkEHIdLEmY7D7l6fzyQVa/IcbyF0QCZOwY7fW7LgPqTsNzmL8U4txvF1tTAc5U0d1giCAU6hm8SK94ukwE81G5sCCNblA4Kh24iL5RBeNuYf7oi5bND4ni4UpTqsi3pCrl2mXrE51IqBNNa0Yeo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820849; c=relaxed/simple; bh=CC88Q+zb9x+qJyFWT0r7BsGTISAdvYfUNOCDT0p7LSI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QvTQ6RbyUqf883WXlDUbLhth7HSq3dLp0dLY8Amaw/PYwP8mvGTVUBYlO+oLHgjwspLtAKw61XVUDIKaIhIXjrB2gYmULMgfwWCObOm3yidgV1IEqHxYgn2YelC79ZjhSykFMZvzLNCUCn+4HAo1V+O3aMWF+eq9Rdpz6oBvdhg= 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=Ib+hAAz3; arc=fail smtp.client-ip=40.107.244.57 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="Ib+hAAz3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lI6wIUIBDQdabPZ3W3tjs/3OxPk2PQpKgUHHIY6N0LpHMnk23EIxC6j9ZDZYcnSMzLGCPbWvVOYR6txmcwq7Ta+fbn+CtietX3mFu2ZR8ms5Ew7DXyKfTnXKratcIHAHKoc5HbC3iOdGg3G2E2AjVnHjLQxybx+tV7PCy4rHmAfTd6LrDm0NBeqJLxCT2O7wcNXcrKVMn00sAhid5LHwRJwjP6onTBziYzKIGjcomIsxggMm/P/ZNiiXBqo7UY580mp3Xr2KmiuITb5r0oN0j2bmEg4xNxiJ2+1XqWhjoDphHAu/aA7oPYxGEifWIX25iE1OjtRzPTgx+KbZNF/pFw== 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=DWrFpOP8j0p7ioctz6BKIQzkCfCwrDMVuzyTi8lgzZo=; b=PoCjjbvAaX9/qAC3/pBHkxLUfVijfw0fnXpTPTLnI9frIyngru/IxHbDRGjABPJlfVkYLtV3NawPABoZE/WbuKFxrynTrI3PzE54yvJdl2+LjYMEBIOd+599IRPpgUR4A+TaUv8ecCNT5oIEYQy8ooCrveWPCGHztJM/8Tj6jbbf28pqmS+ZL4p6EpzFuHId38TuoWJrwghunruggnEVlxPdFnlKNuwV+plsfDzDEqct2aRa3RStPVcGjYBkDMeRwZGIHmoKzQxe1S1K08aeoei6kVVS/0Qi0fq8NGLF4g+Q0tNaom23Fg5WRFc0ATVtKe+ZKIu+qVOZ1lArIE8Ozg== 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=DWrFpOP8j0p7ioctz6BKIQzkCfCwrDMVuzyTi8lgzZo=; b=Ib+hAAz32cTi4es0BxJlPOqXCD6OR9HNnwkcTFr5MenQAbczsOz6Lyo5cpVz/xGHk3AOH0N3ls0fM6m/6/IXFMAlquWfd7O/Yq1vPQZ/RdUCDl92HpMcKt+Pb+n5sNbMCsjJ4ZlrsUnvyv3D7kxhKX3wFSSFpWV/aN3Z3y0dnFA= Received: from MN0PR04CA0029.namprd04.prod.outlook.com (2603:10b6:208:52d::34) by DM4PR12MB6542.namprd12.prod.outlook.com (2603:10b6:8:89::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:39 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::70) by MN0PR04CA0029.outlook.office365.com (2603:10b6:208:52d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:39 +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; Tue, 5 Nov 2024 09:33:36 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 07/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Tue, 5 Nov 2024 09:33:03 -0600 Message-ID: <20241105153316.378-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: BN2PEPF000055DF:EE_|DM4PR12MB6542:EE_ X-MS-Office365-Filtering-Correlation-Id: 62af7fc0-497e-478f-c653-08dcfdaf38a7 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: =?utf-8?B?TFVCTm9WeHZRU0lzNzJlUmtGS2cycVhSWU1XekJMNHVlUHNscGdJNklMUWly?= =?utf-8?B?Tzc3Q09qTFNXZnRReVRXWWY3N1N1Q3ZSaVVXNE5IMFFKYk50K0hLRnh1ZFRi?= =?utf-8?B?Nk9tY2szdWpYV2FIYnlsWnZ4WGNyUEZXZ2ZCZzBJZ3pqbWd3N0h5LzVoSUFx?= =?utf-8?B?WTB2cjFGTk9sVE5tekthLzBiUXRxT3NhSE1yQ2VPbXBEYW9zZFhZdWRWcml2?= =?utf-8?B?R1NDMnI0NkpBRHJXaEpDb0FpN1g3cVp5b0J6Rm92ZGs4OWdsdi9UVFhKMWJM?= =?utf-8?B?NWpML1hrY1hHSllTSGJhMlI1U001N2JVUTV5MXRwL1llSTFYM1dTYTRVV3o4?= =?utf-8?B?dVBadXdXRGNlUEZWRHh1UWkrdEFIMzNNNjFvN3VWWko5aVZHa1BiQk93RElC?= =?utf-8?B?b2dKb0NOclM4ckFOaDg5RHd1SkdIVy9MS3lFMWlvNW1xV2VINEE0M1BVeGZK?= =?utf-8?B?Tm9vTVFZTjBuVDhPci9kSmFQMCtEQkdwRjU2am4zYTYvcGNwS3Z0U21Dei80?= =?utf-8?B?SjE4YlFMaFFVV2dBbFhPRjhwcWFtK3loemJ3MDRMSnlibnVXYldER2VwOVhj?= =?utf-8?B?Z2h5SmY5SG9XQ3pUZkczSU1Cc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FpGWlU5NDlFV2phNXpQdFpFU0diZXlVRUZmYUV5?= =?utf-8?B?b1FzSjNXVS90OUFtMHljWnFPOXNodW8xMTVvODN3dTRCNDZUUkkxRFI1dFBV?= =?utf-8?B?VmNyQjZKVjNnSjZOcDRJb2h1Uis2dHZQQk9Cc0xFYTRZcFlUOEZ3a0xMMG1O?= =?utf-8?B?NjNZRjhCVVIyeTVJRkFoYW1yWTVWcGQyNE4yUmo2Vm8zWFFVU1pvc0pXRGda?= =?utf-8?B?VU9JYUJ3S2hKbXhaTmU1NVdLcjBLZGlpZmk4OVV0MVc3RnBsbU5sT2I2Ukxn?= =?utf-8?B?ZCtVSC9ReWh1Wm9YRW1sczViOXZER3F2WXlBLytqR3AvUXhzemoreGc1b0d0?= =?utf-8?B?aDliSUM3Ri9KUm03UGljeVMyMklPYlQ2SU1YNzN1aUUzVUE9PQ==?= 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: 05 Nov 2024 15:33:39.0766 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62af7fc0-497e-478f-c653-08dcfdaf38a7 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6542 guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- 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_profil= e.c index 70e7f1ba68676..4454c4a903c8f 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -188,32 +188,26 @@ int platform_profile_register(struct platform_profile= _handler *pprof) return -EINVAL; } =20 - mutex_lock(&profile_lock); + guard(mutex)(&profile_lock); /* We can only have one active profile */ - if (cur_profile) { - mutex_unlock(&profile_lock); + if (cur_profile) return -EEXIST; - } =20 err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) { - mutex_unlock(&profile_lock); + if (err) return err; - } =20 cur_profile =3D pprof; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_register); =20 int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + guard(mutex)(&profile_lock); =20 - mutex_lock(&profile_lock); + sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile =3D NULL; - mutex_unlock(&profile_lock); return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) (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 ABEB315573F; Tue, 5 Nov 2024 15:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820825; cv=fail; b=H25CZO07u9zLBO6WBUuTtyvzCi/clzQFHrGycxaP9xqd67H6n7GigqN3P1IG3s5Q7P8RtLgbfHe4eiGO95Q7z4QkbxHV2VR36btb0zu75rq3UyYuNaSqyyesEpvexgwDp2cLpCMhSQdt4TK1kKI5Dd2Uhg71D70g/1Pjb7YFKSU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820825; c=relaxed/simple; bh=w2Dm3SR0v5D689dffnqkc4HrQRF/FCuKE23LW6i3O04=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V2q+wIAaBazRuQaheOywnIYAnKV96vM+6HNyV0rrK7BZnRWoPEZhO27KbCxW6dWhAcnye4yBKkvLUx/1tFE2RF1KI8pSYxrZNzhLXJSQRYDnRLnqRogtDJ9haiDC0MQvE/t/Ng0A8y6YsE4LMY1df7CmlvkW3Ee6n4BfH0NuqK8= 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=bDMfZBLi; arc=fail smtp.client-ip=40.107.223.46 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="bDMfZBLi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EUeQHpR1ziwlKXfVEE3MYm1haWRzlMqONuBCrMOg09Vi439aGHGugsV8wkWy+QQxrXmK5/t6YoiMFegjN7PdDeiyLjQ76rjNjT9O+MbAsGuh8n2fPgMjKHfEKnZbIJP5ThXfzpTO1AcF+djBlDqdwWe/dhcVIZ4V2n9VJYr0wGM0LEndJfSuo5rO8Y4w8dL13Hg8SVauPyeNyF2QnCFZCFQw4cVoIIB9vQXaASdab0hMNpt5A9dVRGz71ok83haCf4yUAB7Q1bPMLdHWdgdNv/JmwaZSdmG6yyB4QNsPOMy99tADmB6TuiQhpSpTYYMXUlnkCDONdd2U4EY3FEuFQQ== 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=3Ad1/6TojCvY4jp/TB6IgLBEzjel4m/AXx+akqf9shs=; b=NOkWcD3N1pulZDRa/AqiSRkqwOVN05S7MLr687g0FNuLrX030Oj8R6adha6YicpZgwyQTJ2r5Is3lCNSfWmLqTIgPFplfzK7r7JuW96dOZK6XSuduG0n7uMe+bOUQV5ymuiFDlgYY12hqq4luxIA+mZl6MO8jM+73+ATILnLxf/5B71XBrMy6ywmLvu61clEe9vDHBunUvSmJ6U6/DOEbbfIdo5Vlv0ZvE+T+//TwT0v9szk5HZP2EXT9ce6Kq34EUUD+epB3rEhc3HpSoNuCfpli1iTEsY0st7w7OocUydkWKPLNxKT44jalP+ZeKEQLsEcL7MXRxcntsv0gyI4wA== 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=3Ad1/6TojCvY4jp/TB6IgLBEzjel4m/AXx+akqf9shs=; b=bDMfZBLiYS4CYIfQWvSYnt4+tP+21oXw+3VoHSzEvsaOCsAyKNRk+Gvy+F6mESLcpnIZgNdKI3A2naUiyy6sjvVwcBedV8fGNbVVjUzWPJYLt2d4mTjShAELbvqGzClI1KeFGP9O8UUwj3G9IS6Re28LiZ+Nwc0UTAmu9tP8VmA= Received: from MN0PR04CA0026.namprd04.prod.outlook.com (2603:10b6:208:52d::17) by BY5PR12MB4145.namprd12.prod.outlook.com (2603:10b6:a03:212::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Tue, 5 Nov 2024 15:33:39 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::27) by MN0PR04CA0026.outlook.office365.com (2603:10b6:208:52d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:39 +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; Tue, 5 Nov 2024 09:33:37 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 08/20] ACPI: platform_profile: Use `scoped_cond_guard` Date: Tue, 5 Nov 2024 09:33:04 -0600 Message-ID: <20241105153316.378-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|BY5PR12MB4145:EE_ X-MS-Office365-Filtering-Correlation-Id: 12232ade-a9f1-4667-d670-08dcfdaf38f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ga8nTEjOykxLOu6UuVPBln9lt/vJJOnhuDZuxtUOHL+4Th+r6fED2GDztF2i?= =?us-ascii?Q?34YrC7Dt73S+3ZweiZuSTWCUWZhKwid7x+BS1Qi5SOrAYcROrSI19Ouq8DSB?= =?us-ascii?Q?2XGyB5hwvNNe/WX2FW97Zw8KROeTnnPl1O/U+864GGJA+TixNRqhccmyKjtm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PuQmsgIiRejmcjOBGwKZg0th?= =?us-ascii?Q?2PzHVdW7mxE23YRCIl6cUdhy/CyMAf5mYHSs2vkk8J9gLhyWmqAthbUOb0AH?= =?us-ascii?Q?hxtlY4pcpcD8p4sqfxuFe8Wk1vA3Ou6DJWc7FuhzFG1nnSYoCYE6X6B5szuN?= =?us-ascii?Q?lUlkzptX+fAzEkh9gt/jUROy28mRCjqJO1GpqGPZKYmEQXdRurd3H1eT8AcJ?= =?us-ascii?Q?PpLQ4B8AjwkoSotzXLKjgs8NKy9PPWN6JktaUMXJ6CGkRfLNk46jRoSXLvdW?= =?us-ascii?Q?p3MD1qizifwjnPDtbJwUO+IExdI4EZwVOVdQjXGJEZFpoxiyI6OzCPsITUv9?= =?us-ascii?Q?ALaYzjgM/YCJ4n3ysm6B5mL7FLDCxiz26qbM4rW+TRu+a0Evkw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:39.6078 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12232ade-a9f1-4667-d670-08dcfdaf38f8 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4145 Content-Type: text/plain; charset="utf-8" Migrate away from using an interruptible mutex to scoped_cond_guard in all functions. Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Ilpo J=C3=A4rvinen Tested-by: Mark Pearson --- 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_profil= e.c index 4454c4a903c8f..fd1c4e9dccf0a 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 dev= ice *dev, char *buf) { int len =3D 0; - int err, i; - - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; - - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } - - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len =3D=3D 0) - len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); + int i; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; + + for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { + if (len =3D=3D 0) + len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); + } } len +=3D sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } =20 @@ -56,20 +52,15 @@ static ssize_t platform_profile_show(struct device *dev, enum platform_profile_option profile =3D PLATFORM_PROFILE_BALANCED; int err; =20 - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; =20 - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; + err =3D cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; } =20 - err =3D cur_profile->profile_get(cur_profile, &profile); - mutex_unlock(&profile_lock); - if (err) - return err; - /* Check that profile is valid index */ if (WARN_ON((profile < 0) || (profile >=3D ARRAY_SIZE(profile_names)))) return -EIO; @@ -88,28 +79,20 @@ static ssize_t platform_profile_store(struct device *de= v, if (i < 0) return -EINVAL; =20 - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; =20 - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + /* Check that platform supports this profile choice */ + if (!test_bit(i, cur_profile->choices)) + return -EOPNOTSUPP; =20 - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) { - mutex_unlock(&profile_lock); - return -EOPNOTSUPP; + err =3D cur_profile->profile_set(cur_profile, i); + if (err) + return err; } =20 - err =3D 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; } =20 @@ -140,36 +123,27 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; =20 - err =3D mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; =20 - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + err =3D cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; =20 - err =3D cur_profile->profile_get(cur_profile, &profile); - if (err) { - mutex_unlock(&profile_lock); - return err; - } + next =3D find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + profile + 1); =20 - next =3D find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + if (WARN_ON(next =3D=3D PLATFORM_PROFILE_LAST)) + return -EINVAL; =20 - if (WARN_ON(next =3D=3D PLATFORM_PROFILE_LAST)) { - mutex_unlock(&profile_lock); - return -EINVAL; + err =3D cur_profile->profile_set(cur_profile, next); + if (err) + return err; } =20 - err =3D cur_profile->profile_set(cur_profile, next); - mutex_unlock(&profile_lock); - - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); - - return err; + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); =20 --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2083.outbound.protection.outlook.com [40.107.236.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 667861714D0; Tue, 5 Nov 2024 15:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820828; cv=fail; b=poyGSQE2hkOl64x+KxG58pjN+02/Cm0znwZ0tALC/j7WN2MfRBLOgAdZNJPAtly/s9TfL//k77VqeUamVBNT1igPo8XW7totg7g65UiycuyZ9tMFNlFE2qeCJRqiwR+kYszTL49wKGyA36loF6in2CzitLUDG8dxd5VF/uygf78= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820828; c=relaxed/simple; bh=IKVHLpA4A5Emcm9TiMSim8CDvCbkac0/6uf5InyDifQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GRQHgTGsOdhpQvl3qwgOBAtPnbvwZXnx2cKMqObThePm8jKInxudtT5AFZxxMeeQPmwleNBzEnNDyNb7zAoTWnJH+NPmzOwoWar+34sPzEKvNmjFn4gFfEdMppWeYRI7yhKhlHtbQVmEvpxKGc7e+Ls+SRERzgQFNWoPX+eCMss= 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=nYMXHmvF; arc=fail smtp.client-ip=40.107.236.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="nYMXHmvF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EKiwQecVnO0QVaUP5okXS3wGH/4rnXPE6JcXGrsdRUszAMhTgOhwn5Q26x4UUXzCx4813qMWM294W/4wFf/cw5FBLuuMeO2Rj6IRniw4Ntr4sMC38JNz7wRxvh+ECggOty8maqyznIxfI14DTziAx1BK+9bM2VjW5Mu28//tL/0RQGlnYkOHwKzRT2lJYiXraGfA8HuE0aPohTSdbWClCwfJGMvIUGiOFWuFfb+MtxsNrT1AzeUx0U0G5QDvv9Zt/8SOCRTwiRzwZJuj/hcMi1uzSh28IdO7YfzC/fxTNGdyorKz0JIpAnb44jixnguvpcJfMPCjlggdtcdJ0yJTcQ== 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=AeHUBXnx2/eWL3xINfk4aXphOjzqTzP4FAaeqbocuiQ=; b=L56VMsehWaFYidwTSswLVKE43HMErmkWw/IuZ9X6O0RrLAGW34WdISarDiA3nGQsT6OiM/P3dS3jRjJTYv979392igwgk41gfrVP5aAdYpVTrjuryOC2CFN1+KJhsdTGf4CR8L5Ln+bOuJ5GKgAsUnP2gGk7l/NNYWm7P1Avm/7+MCtpkriB11AEW8uO7tG/RXyBjaOJefrDvT/g6t615um3roTUYPzwheCkEIVAMm7yVHh3ni4ux0JuTVzLSmDNoQVc4w4UcqHcRV2GNATdPkNXp3IOdr7MbvD1zoEBfNXvG+iTg/4FLFX/9pWcVAo8UBkk4Rl+IJ8ajDTdir74dg== 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=AeHUBXnx2/eWL3xINfk4aXphOjzqTzP4FAaeqbocuiQ=; b=nYMXHmvFzXoEiEnJP+hUE1WmpygaKNDn8wuwLzza/3IlyXSfRkCcOLAsUc04FQkE7W/LxVnKnOqRt8e0TwKgXVjqkUA0qD7G3yYzpT4nECBtTVnLyxvIQowXiBi0qvA3jlzurNn8ub+U6QM2JCI3Kh8NvDycCJo2yFVX1qzJSwU= Received: from MN0PR04CA0026.namprd04.prod.outlook.com (2603:10b6:208:52d::17) by MW4PR12MB5626.namprd12.prod.outlook.com (2603:10b6:303:169::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.22; Tue, 5 Nov 2024 15:33:41 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::56) by MN0PR04CA0026.outlook.office365.com (2603:10b6:208:52d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:38 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 09/20] ACPI: platform_profile: Create class for ACPI platform profile Date: Tue, 5 Nov 2024 09:33:05 -0600 Message-ID: <20241105153316.378-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|MW4PR12MB5626:EE_ X-MS-Office365-Filtering-Correlation-Id: 8faca741-fcf3-442d-e51b-08dcfdaf3968 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?/rHMM46gVePch5+zbyXVVluFhFThHNYOYhpaY4nql6jfwuHJbYA355CIfM/i?= =?us-ascii?Q?e0U9eEE0aOyoBpf3uV77UGO0vZCK2UCbBZ5YXdBq+2dtOJ6M+kXvuyoRppCT?= =?us-ascii?Q?V3aD6U8LJ02/8b2yFNsBbO2LDhUDFaTTi0lb3QJiXoSVzBN0ITPwrAYJon9Q?= =?us-ascii?Q?UqkpYKKGJGeZBudtnG0CbpE9G3huY/nZ2wYJbricGXvPVsFfhoG6rB2XroKA?= =?us-ascii?Q?TibKCYRdnHJjts1soS4I3RQI9dFiwiEvb3VlfK/DVkLXCiiUqVM81HI5HSWc?= =?us-ascii?Q?gAQ5NR0oBDyDnBdAgMKo80Oq8jYvXFzs5mM0kxMahblnctNKyhw8T6qZ4qCw?= =?us-ascii?Q?1CDbuKN5/bksBkmHl67LVSNv1rRxL5boFvNv832FkGw8zkmSpOYw3pkX7j5Y?= =?us-ascii?Q?W1xREnCzAsYDP29PPGcSuYIbuo0caVnKJbPW+NSxbqOQi8vYrD/ASZ1UJr2g?= =?us-ascii?Q?BhDH/OTxtXJwS2t5zTeLQmlD2GMOi6jS1VhGWK8R2KeUz0ixwF3OeDONsQFa?= =?us-ascii?Q?3ejkbWwU3BF/wHCiZckkrtn4tvZJyrjyl8ph0jk0EeGZbed7zASfXv2gDpqy?= =?us-ascii?Q?WM3lfNRRSoKon7MUdcCqLU3+tfQwOWeopctnnamnKWeK3/c/byAyjpY9Hrgh?= =?us-ascii?Q?DF5p47X7wiuPnAFagUmscwnDVHPYEVFFe5bzHp7uwU0wUDQg6xOI8QxD8UHG?= =?us-ascii?Q?Jy6c5Vv/JuvNl/pHY4bwOzQ/xrH0I036IfKpF7TxdVzLMkEIqwuYPRl3MiPW?= =?us-ascii?Q?+Y7mpY8bb2awaAypi0R5KecwZetBMp3S43vnZNj408mTdZMygCunt3QmNW0U?= =?us-ascii?Q?SZ6FyOSr5CX1M+eL1HFQR76tuYNeUpZKd3QDcWf6m3gFU8DG96HKizabnbCU?= =?us-ascii?Q?vMYhPEuJrpTdioMWYo5UAVrB9/1NcGUStkToMcmbodQMRnnYyCUV/gwNus+h?= =?us-ascii?Q?fbq+pBZTNBUfpSYaTokba2RW1P/h+b2ZyHy6+u7R9cXOSGWS67ZkPGwbTtaA?= =?us-ascii?Q?9qbbZ+cf5oI1Fc/DuaG0qIZaCKrDkC4blLxUbJiLRjZ0BUtWZ+pGJoOacuzJ?= =?us-ascii?Q?LMTZl8p4AaA3b8bOsVCaeXR8oQ3QHijvPuL8rgB11gExXVsl65K3PD6M8TSt?= =?us-ascii?Q?v9SGDWv6iPTaf48Mh/oszBqZjQ3OfuMzVXhevjZJzjEkEubrVCeMaNQ5As05?= =?us-ascii?Q?YL6nD6DCjWfY8nNgJBtI5GZj37+Iunl8Wg68FF9/c7Wle2QkAi6eu0aXU0RC?= =?us-ascii?Q?9kLYlWxurEogjC4bh/zu/7x2614kpLPC0uNJdDlZGCOEDVSvf7anq3lrUB9v?= =?us-ascii?Q?ikCSx7omB2ppHX40bpfFjGqhg0vPKBhlI01Mgty6YUG57+9rmpd3t7mwenyn?= =?us-ascii?Q?NamtsxDxNRw68FtrHW9IAwh/oXNCnoWdnZxmqKlWEWrZdibofw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:40.3422 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8faca741-fcf3-442d-e51b-08dcfdaf3968 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5626 Content-Type: text/plain; charset="utf-8" When registering a platform profile handler create a class device that will allow changing a single platform profile handler. Signed-off-by: Mario Limonciello Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 42 +++++++++++++++++++++++++++++--- include/linux/platform_profile.h | 2 ++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index fd1c4e9dccf0a..f8e9dc9a10d54 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[] =3D { }; static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_PROFILE_LAST); =20 +static DEFINE_IDR(platform_profile_minor_idr); + +static const struct class platform_profile_class =3D { + .name =3D "platform-profile", +}; + static 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; =20 + if (!class_is_registered(&platform_profile_class)) + return -ENODEV; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { if (!cur_profile) return -ENODEV; @@ -167,12 +179,33 @@ int platform_profile_register(struct platform_profile= _handler *pprof) if (cur_profile) return -EEXIST; =20 - err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); - if (err) - return err; + if (!class_is_registered(&platform_profile_class)) { + /* class for individual handlers */ + err =3D class_register(&platform_profile_class); + if (err) + return err; + /* legacy sysfs files */ + err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_class; + } + + /* create class interface for individual handler */ + pprof->minor =3D idr_alloc(&platform_profile_minor_idr, pprof, 0, 0, GFP_= KERNEL); + pprof->class_dev =3D device_create(&platform_profile_class, pprof->dev, + MKDEV(0, pprof->minor), NULL, "platform-profile-%d", + pprof->minor); + if (IS_ERR(pprof->class_dev)) + return PTR_ERR(pprof->class_dev); + dev_set_drvdata(pprof->class_dev, pprof); =20 cur_profile =3D pprof; return 0; + +cleanup_class: + class_unregister(&platform_profile_class); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); =20 @@ -181,6 +214,9 @@ int platform_profile_remove(struct platform_profile_han= dler *pprof) guard(mutex)(&profile_lock); =20 sysfs_remove_group(acpi_kobj, &platform_profile_group); + + device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); + cur_profile =3D NULL; return 0; } diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index bcaf3aa39160f..f81c3afcb7575 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -29,6 +29,8 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; struct device *dev; + struct device *class_dev; + int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2049.outbound.protection.outlook.com [40.107.96.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 16A87178CDE; Tue, 5 Nov 2024 15:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820827; cv=fail; b=CLLar5M2qLz0JT4LP4ScXTyzx8IixLOM9w3wlxIXQJ0w6Ix41hylYvFtIDuHe1hQ0KN89T56uf7zKZRn1nhhRIRH+9D/5mumlGT0zn09RsqlEe+p+wxJqveSrGILqdqlLAHkV46fA1ts4BBoGtmj733vEsFO9lHtt1tp0VW/J+8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820827; c=relaxed/simple; bh=A80apRvzFpvKnp/iSfY+2i4P14vmr3rdL7/mm8Jq4kk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sXEhbFtRXugT10ShEoADdUOzpoopUIDNsP9AGddVsRi9kaYziX/BBFT1MxPYjAbMz9AvWheGomYoH0Wo+GbxvehSlmwLOgXubEYcPic/O31sy6X+sKgce6pwKijZnrRTVfKDdDo7X/fXgBcO54x0tTEmWv9v3vU/+b8Dbq5/S8Y= 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=K2vZAg8i; arc=fail smtp.client-ip=40.107.96.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="K2vZAg8i" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IKzn9IBZGrpiyrb4SB8zJOPPzooQUQBMcwZoL49nEX+flZaMTa5htMNa7io3gTomeRUKlTn69tLNJPiBhU5+9FC5EspblYlNQ9i0+hjxRAQpm4PSluK2b0YcxV2CwUCjpvXl+axca8Ug2ykDSWpgO+OCLPsm+ULxlbU8LjZz0zgeZSjXBMdyJpdgHP+yP/yZo4BaLoxfnC6IylTMwv/n5rgGuJdtQqH8ksRzOLoAfDWSNbGSPw4OKHZrnAJvGhDH7TZLH++6Pt7U1MZOrrr+VQXx1HZG8MpwkjV8bVLx7aA4q1HRx9dUiSa60ouK6PSeQ1jusnme8jKarjRgj2XIYg== 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=Z53q0LzTArxcJwMP/NfJsibGypRNuBSVtaP407naVoQ=; b=pkY2ANH+umVRrU4COLEqE4ApNsC4rWbNeiUNllRTTKULQtJRxq/apoKD6SjdvZ74h1djVjdcJwgD8I1RXewIrWczzRQ3iyHywOWn2Y2fnFPpPqDpCPj81jvEKsKPhC0QlQ2TDNDWGwXcIEHOs5IY651loFgrDccFQVB4xX3ONEzztZJKbMI7ZKkGK3k/NC6V5GnteLLzb6cuBQMt6d93RjRgX3eL7hEmYZKYbzjIb41ATi045Xv3g7XAbyD+cdVxcoqFA0oMY3S+1HHgm5hc09ugMnKMAT6szaxh7OgGyhe9Mbns9U9N+vnQo7uI/sOBryrXfYoGUmkVpcdQYD4kxA== 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=Z53q0LzTArxcJwMP/NfJsibGypRNuBSVtaP407naVoQ=; b=K2vZAg8ioOrCg7kkD2FabKnHZY1tIXfWftct5nUUG/PSTysXIcluoWALLCmrHSuQwPD3/CIOtXFNiAyvb+c2so12nkckyVzSkfR3nE/kQy5SsyucYGNsuXpNRwgvcAd5GmlcTgzQfu9R6ZRp9AAM+7qa2e6JNiSs8kbeaZrYAQg= Received: from MN0PR04CA0021.namprd04.prod.outlook.com (2603:10b6:208:52d::32) by IA1PR12MB8192.namprd12.prod.outlook.com (2603:10b6:208:3f9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:41 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::aa) by MN0PR04CA0021.outlook.office365.com (2603:10b6:208:52d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:39 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 10/20] ACPI: platform_profile: Add name attribute to class interface Date: Tue, 5 Nov 2024 09:33:06 -0600 Message-ID: <20241105153316.378-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|IA1PR12MB8192:EE_ X-MS-Office365-Filtering-Correlation-Id: b2eb7893-57bc-4535-2a90-08dcfdaf3a31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dUBVuAHDaGHkLeqa1ZMVDPbCaFCr15IyyBxk+eXesbPbi7S/MweDun2pjKOP?= =?us-ascii?Q?p/SQJqgkCPm/WLsjyF8JRSxYSxAigoHpm0b0hHOivfXdEi3Fe8M1z0hRWRHH?= =?us-ascii?Q?osCCMW9gLutHSnXwI+ia+HFsH2gq0TLrag8ENuOSczA2FIFanA2adkK27Boh?= =?us-ascii?Q?lepQZTZLYLH7YAz1PzkN1XW/W+PcP651AO1oodQi1SyJvqyFCzKj+MqCXXuQ?= =?us-ascii?Q?L1KhQX6cZe47WACMxR1ZetNITquXpfqQFF6ZK1KAK8p0vhSnezOnzqGfQYe7?= =?us-ascii?Q?uPIAPBCierMAkveD23VG92zvGxoooM+L+9sYH5QfVcfzafic2fYhKxS2THjL?= =?us-ascii?Q?2LDmN0iXlCZU0lFwWZerKKvQuVV+NQiT0hAvagrNmjwd5D1rP7sKOlsWoG4k?= =?us-ascii?Q?OhBobzOg7HvfUwUu0sPIh4znBE2m1zmVW5vcRffmiU1YPKiALLzRIKM46OMA?= =?us-ascii?Q?kFMfKLl/rsHtpkcHAA7z/s6GnzkhMDE7uiFwQ/NFy4mDTJae5VVORSlCjvLg?= =?us-ascii?Q?4b9Mqu5nHncX0wgX7djLO44MCUPAh4G2c3Ey3dBAXYDVivpIaDF+uS9yY+R4?= =?us-ascii?Q?CkTmCicfBuGhMDOGlBnul3oEBYU+VwBrAmHZ5X1WsepNu7ny+z3kEaAg07TX?= =?us-ascii?Q?JBHJBw9CQb0Ck+qTdyJ7zB4Z87+1HYQzJCHvSQGfL6bdEtihp0TO62PKYzwD?= =?us-ascii?Q?i2ABnc/mdBNyfyzaB9cqSfhiI/cxIHBZlwJqfcQx5njH17eApqA/LhqhiCkm?= =?us-ascii?Q?Afj9g+oMx+3dSodiJZD0xU/qD6KGMBh156NPZkPNAXXCK3BUX3qrqfQ9Jg6v?= =?us-ascii?Q?gDR2WOurZKbj03pKr7GqTzQkI65iB1Ugd5U4HPZEUbeF+Xloh06Qs36jZ62M?= =?us-ascii?Q?2lMC/Tg+ckWRDlz24Xi2yDhpJcIIYs6VTUYO4Y3zcq7Nx1oYvomzTn11gYFS?= =?us-ascii?Q?DjFLwt5kBnYr92DI97iWfPy0O92gOH4WIf+zoSEbzTWDNs1ooqbUarY7kaPO?= =?us-ascii?Q?PrEPwO7nmlpkfCoKJqgBhvPJf9BdJQ8sKGdF/bchYWFub5Z/lwevDC+BJpFE?= =?us-ascii?Q?AKIkf0aOBNmsZjqnGp3nAo4VyGBK94Dx8j/9wE6qHQ4OoA2QdMlMhr/gbT3L?= =?us-ascii?Q?ilLEj3EwPPv7eUH0CrcLHb7GyS+6JikIAu0n9Jh15Lv4zB/Vho9oeTuZ3gK7?= =?us-ascii?Q?BdrrEJQ/Tn2FpB1v+BCbPKRrOZvqSKf54wfHQs9drBAwx+bBa+7+ANsja8Nn?= =?us-ascii?Q?exkU+parKwpvoAZUYvagQ1E/iFe86Aa3K1tIcAPNddUfByAVwR5rqv+rK2RT?= =?us-ascii?Q?fe2+cX8sGpIaBYQpdzZBkcrTZAf1vuS9zxWLNHi3RSPwNnKPlb3qDP9dSw/b?= =?us-ascii?Q?8w+L2CE8qBWWQQp+YuJbOhmLh01pEOphqf22Kjl1V3sZZTrWkg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:41.6547 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2eb7893-57bc-4535-2a90-08dcfdaf3a31 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8192 Content-Type: text/plain; charset="utf-8" The name attribute shows the name of the associated platform profile handler. Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index f8e9dc9a10d54..986bd636be226 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,8 +25,33 @@ static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_= PROFILE_LAST); =20 static DEFINE_IDR(platform_profile_minor_idr); =20 +/** + * 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) +{ + struct platform_profile_handler *handler =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%s\n", handler->name); +} + + +static DEVICE_ATTR_RO(name); +static struct attribute *profile_attrs[] =3D { + &dev_attr_name.attr, + NULL +}; +ATTRIBUTE_GROUPS(profile); + static const struct class platform_profile_class =3D { .name =3D "platform-profile", + .dev_groups =3D profile_groups, }; =20 static ssize_t platform_profile_choices_show(struct device *dev, --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2058.outbound.protection.outlook.com [40.107.243.58]) (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 EA12A16DC01; Tue, 5 Nov 2024 15:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820826; cv=fail; b=i+W4YS/b1phE7U23Y1bxK7Z2EzeGkknr3/vJOC6y5WJW+gPntGtSN82I2culM9csqR5Ew2r4oyifsg69lLBWbPYNXibKtKvGMLuEKIyp0cUyPM1tN16Gl2fE5bSVCaxeflYsxXbqf5NgwApm3km+7+i8t6rofnv7J3fC15cJPdE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820826; c=relaxed/simple; bh=ZiSnrAZqpknDKmRTcVtO5k6/JrorA98CRKWnE2qaNnQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cActgx1FIutYG1mokfajtrkdXFKp/6aRxIbY3EpbN6DPeDMuGoeY77NzOLbmNAnmV2y1d2/R1KXv596y6tCJdICGVy6OxvZm0iqKeo2P9gR8INMta1+nnZOoGlbB1IbXC9/aJLpRIm5VX33vhS4lLdGmR1H/jN3dPJ6rRPd6OU0= 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=ji/DC1ib; arc=fail smtp.client-ip=40.107.243.58 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="ji/DC1ib" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jZyLT1bkgoff+yg7tGTBSum72kEhWbNi75wjsthMNKwasDPFCAVFnIeSH0eZKEPZzRAJ1dwRimsmbQWFWw/5j1iRt9GBf8R+bPeDnyD2oVAjJRSf5Y9nqbTpnbR4ZpU7e+6OUUz2pR+GTyG8WkobYH26PpTL/CrwvFAtbvlZ9ScFvwVRMwUB8F6OGKA7LRAqTCvEGXvk7ScNAwzLPcJ7k4E+zIAayJrrO+OTn8AjStR/c61vex4QoppINrJEmcaaouD+iDZekPLwk97RRn27tu9hVt8CoBRlOb9dZ8hVwNauCHXR1M1/CIaaCHbrULcLLR+pEAMVwqbVSQ/20MXzhQ== 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=naMIE5K+E2Bm+Lw6C/PWo8a1NL6TcZTaCbH9D8/5SRQ=; b=VPrH6UcZ8X5Vj7Fkyj+xJHOZkPBRn1TrgMj6ZQ6KWGaN21HM2XgtZeBzQMiSQMQelUl4uL6UQdmwMl1qBtD0Q7HoQLxpis3ITIdR9aGgcdO2r4G3oV3jP9SACG3tiDsXhW8T4PIv4p1cR/DfF9TWo/H8GBaRugC9GB5FYqIvga9VmenBhjteDvVNCbkWqosqEajj7fmVG2q7tSgxYhfybKxb8TcK4/98bhxFOnKjC8FnF74qJ3mmBpQSK9pceZ0Tz86STLqFPPrHSe/LiLdHMt/2u5C909yi9ZmNBnDagSxHsWopokcDa84uVrgcmu+ufCrT9cUKr4RCB0Weru1r2A== 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=naMIE5K+E2Bm+Lw6C/PWo8a1NL6TcZTaCbH9D8/5SRQ=; b=ji/DC1ibGhcNgIp/8VRnSsGsSASuwZoY4ir5xSn38ZWTPovotAaCwg7wC8q5RucCOX5uo2UgbsGgLgVIZCCiPVbycGI6pQatm29MTNyisrvOUEb34Ywkx1FdVBx7rnbYUEQ6JEjVmyU5QEZ3LAJyK5PHd1jBQRoR05kWMfljGvM= Received: from MN0PR04CA0023.namprd04.prod.outlook.com (2603:10b6:208:52d::28) by DM4PR12MB5723.namprd12.prod.outlook.com (2603:10b6:8:5e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:42 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::a4) by MN0PR04CA0023.outlook.office365.com (2603:10b6:208:52d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:42 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33:40 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for class interface Date: Tue, 5 Nov 2024 09:33:07 -0600 Message-ID: <20241105153316.378-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|DM4PR12MB5723:EE_ X-MS-Office365-Filtering-Correlation-Id: 41e95df9-60b1-4209-9cc5-08dcfdaf3a84 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?pfe6BQYxa98EN7ZFNRNWOjzMoTai5ByULv4sy9YIBnS+Z1rSf4zbQNKud5hS?= =?us-ascii?Q?60qmLE9GIbViXu1KSLxLd1xjf/ATg4beOroYiaE6ondH/s57RLIAWYWayvZj?= =?us-ascii?Q?wyNeX572zY4mOvaxeuvUsEdJKky8oPI3y19dbb1gKL6jC+aQMmQLbc6K2/cj?= =?us-ascii?Q?vX5fZD+EkGVAaiVVeKlB9nv9+UYJ7XkC405oScb40pXQEWwNE1Lv1VnWWY6X?= =?us-ascii?Q?nNytoQHH6yspkZs0wUCjrqVAAoFOCs3j7m25lA5WQ8DxLWHdr0hkMpEnWib5?= =?us-ascii?Q?AUU+SIZW6/llqx8KLffZ2BZxzlcWi+jqQJVPdRUwXP0hZk1xpiNc1ZrzauM8?= =?us-ascii?Q?aXkUjYVFV4MEyEy3TDJ7JtZ9HmxreBtJe4FX9ijCeD488ym5jlEijIPsJso1?= =?us-ascii?Q?1DU8q9urv+rO8fCT8MnKsLNqZvE6OCv5cuLx/VbIUIZY6DeGJFDe/W18daLH?= =?us-ascii?Q?4lM54FceKYLKTIohvRBtGxmAJBNdcWvzEvoMzEgCkcwIVhVXKsTeA+EoEaiu?= =?us-ascii?Q?o1TLaTYe1PKwPgI6ZR4vOqbsS0BWrmXM7trwNDUlwcN/w/hwa5R2ws59h510?= =?us-ascii?Q?wYc/pu5ffxoBy3O6MMvl8+f8Gur/5jJBzCui5DpJDJHCl9Sgecl72qT/XdaV?= =?us-ascii?Q?90VFGcoghj9p7vpxwI32n/sGhWxDEJAaiupHl7o/XQmY2Y89yUHytlThtBIx?= =?us-ascii?Q?Mtxl4uOIOl2RXRiqBA4NhAwZjGH/kBL6mihZ1vA+53U4Et24kPyBJYMRkE8e?= =?us-ascii?Q?GEKtCdAeuhxoIC2Pi5dtlbGxpgMFIYAiYISX9F0bCd12ieB3i+svQcASSdGa?= =?us-ascii?Q?icWex3cy2CCY752pVvsXmX6YYp8lNi3wZAeQ1/o8ey0K6QkOxZuCAqVTSN1C?= =?us-ascii?Q?OF2hDnIW4S8IkNviSII3NWlMsNOv59HTtqvcLgmDy93g0aGHmcI+d0SEZ/4n?= =?us-ascii?Q?/xYDbm7JrBaPlnp2fLo4/LcHfyDfWwtMG5iILmy3P19Xah8qGU3wqu4BSf62?= =?us-ascii?Q?npXlxz/1E3rbz2L8d0k3C6oHTkHmIzxQBdpEYR1YTY6IoD/fTHKevtoOZiXp?= =?us-ascii?Q?olhd+HW1FfmmYhMUousbmjQ/nbHb96DyDGUZ/+hmYjsVZ5YaEvaBiodT6WvY?= =?us-ascii?Q?HW7BBHIqpMUJCq3ntBga1K6R3qEAk7g4RCarKhL+6md4rVvbuaaOfOU561/e?= =?us-ascii?Q?Jlpr2vVc6qJUKD8YaprQVCzxM/2fGLH5TChGGnNJlR+LZFlhPd8oNxugBg9a?= =?us-ascii?Q?9A2Heo0K82dIuJLq9HRPF2ydzwWIF2nGQehPBWhDTH4cf0ozmKlywzTEezGQ?= =?us-ascii?Q?xfHncDiiYgqF6UqT7V8MIJdtu2CpeCP8eYOGULTnZY/2tKJYzR9gpjxbGtI0?= =?us-ascii?Q?BVUEy6V0f5cqWMB/FZvE+0H5Yp+xVwCb3f954HXwWz2maDurFA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:42.2016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41e95df9-60b1-4209-9cc5-08dcfdaf3a84 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5723 Content-Type: text/plain; charset="utf-8" The `choices` file will show all possible choices that a given platform profile handler can support. Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 986bd636be226..e1b6569c4ee70 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,47 @@ static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_= PROFILE_LAST); =20 static DEFINE_IDR(platform_profile_minor_idr); =20 +/** + * _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 =3D 0; + + for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) { + if (len =3D=3D 0) + len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); + } + len +=3D sysfs_emit_at(buf, len, "\n"); + + return len; +} + +/** + * _get_class_choices - Get the available profile choices for a class devi= ce + * @dev: The class device + * Return: The available profile choices + */ +static int _get_class_choices(struct device *dev, unsigned long *choices) +{ + struct platform_profile_handler *handler; + int i; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + handler =3D dev_get_drvdata(dev); + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST) + *choices |=3D BIT(i); + } + + return 0; +} + + /** * name_show - Show the name of the profile handler * @dev: The device @@ -41,10 +82,32 @@ static ssize_t name_show(struct device *dev, return sysfs_emit(buf, "%s\n", handler->name); } =20 +/** + * 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 =3D 0; + int err; + + err =3D _get_class_choices(dev, &choices); + if (err) + return err; + + return _commmon_choices_show(choices, buf); +} + =20 static DEVICE_ATTR_RO(name); +static DEVICE_ATTR_RO(choices); static struct attribute *profile_attrs[] =3D { &dev_attr_name.attr, + &dev_attr_choices.attr, NULL }; ATTRIBUTE_GROUPS(profile); --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2053.outbound.protection.outlook.com [40.107.95.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 D517917C9F8; Tue, 5 Nov 2024 15:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820829; cv=fail; b=FmXXFPtuQshWwY+hmtrSPavtnG5M9Ru8lfMlHegM+67OyKq+6lIOL0go6AKJXY2EqPpVvzBScTE1itpKzCgQOVi+PmJG2mCek+M9LOYixrcUT/uJ1zbEX2wH4H370AOpElROc6iyTiJi4xj74MvG2p2C47lHv8halz0Nn/ZVVWA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820829; c=relaxed/simple; bh=TKrfIx/ehNBqFKp6HxS0kQpPp2ZLQ7nnOD0u69SIGUc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KWtdw11Od/Us4AWZEkWniOZ2BXL4Grm8HBmuLZTEGdwwQb09whLr9CmFjZeBdd1lcEN7t9o2fOZIQaHxdQ5SkasOvq2KcAowEc3PsJi82Ho8gzKTnG5wJEqCk6XPWO5OtNOBCwxWNWjBmLxdSZQUAEqsspfpRiqiA44mFplc4mU= 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=DAwQB/l9; arc=fail smtp.client-ip=40.107.95.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="DAwQB/l9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q2WVmSn6+UAkxJvj2F4MS1zSzTllDnbP/Gz8saFycGyiVFxtojU9JnA2Xu1x6Gy3wziV8nSOKDcP6G/HtzFHhKK5ABGmEbjKEh+WEQ8PROEku8gqcSt26JC2hr1sbdiRP2xXNalV1IBMNYnFWkIHLkdGqwnmA/YjcyGPv3LYD6CIGEOzFcB8SgF1wkLKN9EcV+NS0ZnK1JZS4vpA7PQ5DzHllXMpnpbYc1nhQYKzcMCcYNi5hoFjk1LxcEZNAcUL6VIvYh8e4pwFt/Ob7tl9HPnNV5oPTgi5Kkx9lN5zwbdjmdieVtK57l7fI0r+5tdXV/5V8sFo+KmIPlkSvdvXfw== 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=xJpLiFAFUIKpH4h3eLZ/owU1Hf+GXYfHSQ/QgRftZXE=; b=kgUiK5kHEfHcI9GU/+tzuk5KhEag4fv5x79azlTU9C3wP35pKg2LTUZZtRzgaRYOIH9O0MsRPvXBgcYGJE8zv6aNTY9+8iZ38GT4xQpeTc1UCef8Gdl9WaPpFjg+DjngphsbAcIdRLfqAbsbadZxj0Y4/CP8Mc1CA0ZKE5HtllUlWB0O/XitKL6Bj7hOdO/eiUBBTM7LZEuYsUk0FwhOwIJKMd7xKiwsSXhrWGUBbPmDgNiov2CwqwDn65bwqQXQDj76tyRySmz4UuPIH15IUOfCcDhOSbYmkkgKXzOIFgNurx9SFuN2bmauY7b6np2k+oz4/dItAtIKcrB5JSZfBQ== 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=xJpLiFAFUIKpH4h3eLZ/owU1Hf+GXYfHSQ/QgRftZXE=; b=DAwQB/l9JEp1zPCdt6HOP8bKUW38NwE6fiHRJUQOdpQqyLoQAeqKOzG7f1EFISLBpPCMtpzW7K94soHjOiLiImqDjyIGIyHBXdWX/f17iwAuCOmmbR24SHVfpGMpdwyabvMlR18CAcVRkP70Ubj2jI9mqXKQf4PmWJVD1k+2M0E= Received: from MN0PR04CA0007.namprd04.prod.outlook.com (2603:10b6:208:52d::12) by CH3PR12MB9455.namprd12.prod.outlook.com (2603:10b6:610:1c1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:42 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::93) by MN0PR04CA0007.outlook.office365.com (2603:10b6:208:52d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:42 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 5 Nov 2024 09:33:40 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 12/20] ACPI: platform_profile: Add profile attribute for class interface Date: Tue, 5 Nov 2024 09:33:08 -0600 Message-ID: <20241105153316.378-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|CH3PR12MB9455:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b06ef5d-1755-4d4d-e812-08dcfdaf3ad0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?CvuLkxShw9THo/Uw3u4Jf9VNLdZXQ7RQsvIFIdoSu/ZiJ9TTKIT2hTgyuy9R?= =?us-ascii?Q?6YNJmL+uRQr1AkXqAbX6pW2MWk2tgGTaxSRrWbuPqDDusrdRD0Z6esW/4q97?= =?us-ascii?Q?a7/P0NrNxwoA6JqFcPgI7NGbUQyvArvSyuvvAhRjwW96Lth50AOfds8qdlpF?= =?us-ascii?Q?GGvTc2SE0CRqzrxfU2xYabsmJd3heT1mZL5USmrRz702Tlj9Rc/9RwpsEV8q?= =?us-ascii?Q?Mm1r9hBdpUHZg/TOv3hDWa9ZFKP75CAFfJ4mpjvhh0mLaELX/zaeJ2a0NCHW?= =?us-ascii?Q?yLb/gRbi3cqEprdwz9I36/ctzqQQ2SkZdPXV+5HFXFsewI51I2ckxfambir2?= =?us-ascii?Q?drp7eOkrMPZ8ynoSa6GURc6eLQCRL2LaTgjO352tH6TCgvWjzlaU9KmL1kxL?= =?us-ascii?Q?XPDMqhQ8WhcvEBRPw4XlqZUbOB0f233Dr5MmlaZ3J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kLrwgCPuGkvfunee6CovI+7Hglmy3kmh6Je5cKBWhrnINN?= =?us-ascii?Q?qAqU6Gdnx8LfOyLaLOQLaBcmrctoXddV2hNGevx5o64JcViZHg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:42.7016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b06ef5d-1755-4d4d-e812-08dcfdaf3ad0 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9455 Content-Type: text/plain; charset="utf-8" Reading and writing the `profile` sysfs file will use the callbacks for the platform profile handler to read or set the given profile. Signed-off-by: Mario Limonciello Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 118 ++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index e1b6569c4ee70..79083d0bb22e3 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -65,6 +65,78 @@ static int _get_class_choices(struct device *dev, unsign= ed long *choices) return 0; } =20 +/** + * _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) +{ + enum platform_profile_option profile; + unsigned long choices; + int *i =3D (int *)data; + int err; + + err =3D _get_class_choices(dev, &choices); + if (err) + return err; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + struct platform_profile_handler *handler; + + if (!test_bit(*i, &choices)) + return -EOPNOTSUPP; + + handler =3D dev_get_drvdata(dev); + err =3D handler->profile_get(handler, &profile); + if (err) + return err; + + err =3D handler->profile_set(handler, *i); + if (err) { + int recover_err; + + dev_err(dev, "Failed to set profile: %d\n", err); + recover_err =3D handler->profile_set(handler, profile); + if (recover_err) + dev_err(dev, "Failed to reset profile: %d\n", recover_err); + } + sysfs_notify(&handler->class_dev->kobj, NULL, "platform_profile"); + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE); + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + 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; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + handler =3D dev_get_drvdata(dev); + err =3D handler->profile_get(handler, &val); + if (err) { + pr_err("Failed to get profile for handler %s\n", handler->name); + return err; + } + } + + if (WARN_ON(val >=3D PLATFORM_PROFILE_LAST)) + return -EINVAL; + *profile =3D val; + + return 0; +} =20 /** * name_show - Show the name of the profile handler @@ -102,12 +174,58 @@ static ssize_t choices_show(struct device *dev, return _commmon_choices_show(choices, buf); } =20 +/** + * 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 =3D PLATFORM_PROFILE_LAST; + int err; + + err =3D 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 =3D sysfs_match_string(profile_names, buf); + if (i < 0) + return -EINVAL; + + ret =3D _store_class_profile(dev, (void *)(long)&i); + + return ret ? ret : count; +} =20 static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(choices); +static DEVICE_ATTR_RW(profile); + static struct attribute *profile_attrs[] =3D { &dev_attr_name.attr, &dev_attr_choices.attr, + &dev_attr_profile.attr, NULL }; ATTRIBUTE_GROUPS(profile); --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2085.outbound.protection.outlook.com [40.107.223.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74ECC17A5A4; Tue, 5 Nov 2024 15:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820828; cv=fail; b=diC7JnCDVYNx0dbgvY0sBIetB3E8mVKgB/9Ai96gNmq/sLWYx8mwWpNF2cBUV7TJWTlaiWHcQen/tVcHwps9RVFgzp8RV0JlxuR5tliEdciEGLOSLWpzjWPbPwo3m/hC/LFb7R19q3UxeYJLEsngpfz5Vhr8eF/xolrmugIY/Zs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820828; c=relaxed/simple; bh=ma6d5NxwyV3xz0uFiVwWHAoPzdOxFIKFXHz9yd0C6P4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A5Zk7k/HBLpUOlUY9nXZXkFh2G7k6NCnJQ6fupaR4IJey840SgFfvSosTFr0B5lzyW+xNQpCxn6DIR2mhTy830fJk5qT/sHMLlZN7q3p/XuuZJQBqnCTy4n0ZhcVpeLyTJxlWiaIOPiJbfkVaxqfIZgmF9O+rrWLyLoXbUT3WM8= 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=mOD2Edm4; arc=fail smtp.client-ip=40.107.223.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="mOD2Edm4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Qv2nBvxEYkPKB71wMpYDe87JHVmB85c/rYW2ygm+DftL25PMk15XxDJ76KwQdWnWrJHrr10I9mO0F8/K2+6veiGdj/zqHlDEYNPk892+68q2S5l8va7VXWpu77esBRBZZ/thfN3fsOcX3bQysYTK1VijrLU8ltWXwXHXurm3TQVH74YyFPePEJiwK2uZVhFUnl3kUCM7wNS0q7oEajOhUpcvXLe1NjYtatvUxry+k1boC2ylTMTsdpXRzg5R1S9SNlAhXsyR1cjAPyVJ2hZBT6CAzUDaJH/MLSzG9KZx4ajJvyc2ZqoQv7Lzh1kJQIsg2dexzb9dmw2xL6a8WMiRVg== 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=7LMnJlDVc5gGEZL8b37BBEZ+USZkmvhj/BqsNTn8yQE=; b=g+w0CJAFm4HTXCtX22QE4lLvMRM584J7kolRTUwa7JwH5DRMOLd+732dWYxkpf6yM3s8E4QLdF+JgRNmSSsIoOvuEfiO1blyFAaNb9EKrBnMYRBVyX79tpOT5EMlBeLtk6BOp64ZOmLn+v5WnvKEplPmRrM8WoUIDnEMm+V9fCKuilrEGHofJbXoYEflcIvOACxG7khouAGyrkmg1V+if3mGzviecFxlPNg3wBrqZDL2iZ7OpYOOKkNNIxTpAbidZEt8gP2B9IfxGZKKTvieM4Mgafjl98mKHE0MYl1QFJwdHLk9wHezdSzsTPFaz3HxKbjwqdqjIdXWOvy8+4hO7w== 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=7LMnJlDVc5gGEZL8b37BBEZ+USZkmvhj/BqsNTn8yQE=; b=mOD2Edm4yWz0/WJ7Q/D/TLj4emUZK3XE0fXRIjaXGH+KkOmA+oB1HEG8SoACnA4lt2GUPaIhDfUcTwSRfRKhBchFWJfsybZ+EHpZMLWQ404axOQz03h7U3CA7F02dZZivSj4xXq7Wdm81fXp3PIl4/u4UtFrqs1taNMBLs7qBy4= Received: from MN0PR04CA0006.namprd04.prod.outlook.com (2603:10b6:208:52d::23) by CH2PR12MB4248.namprd12.prod.outlook.com (2603:10b6:610:7a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:43 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d::4) by MN0PR04CA0006.outlook.office365.com (2603:10b6:208:52d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:41 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister Date: Tue, 5 Nov 2024 09:33:09 -0600 Message-ID: <20241105153316.378-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|CH2PR12MB4248:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bb73ce3-1014-4a32-3352-08dcfdaf3b1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?8T/ysVAj+sKZB55JIzIGENyoNceC/AYqU6XDmZusZLBEFMpJFrzkxK1bOIzH?= =?us-ascii?Q?Jcf9Hq7If5nrUYfWUneTnQDp2s4w+/v/3IUybO/z1OWd6S/PgPu1+od6jwq9?= =?us-ascii?Q?Fv5YHCimdpKV6sQfPCtbYQQkrDpTJgCQuLC+1XHxNfysCsooNwr7KVsSO0OB?= =?us-ascii?Q?QrkRx1FCzz+hKfMMMBFRCiHRheQbXG2/FqRTtm9oAMYtWb4AJLQzv+w/R/8q?= =?us-ascii?Q?1kAGIxoCNxqYJFKMUpRyL0NrKOg6y1xeYfzRLFHNicsorOa0GMe4S4jsIvYJ?= =?us-ascii?Q?K8/8Wqhr5XUvQmWMw9I/6OrjJcBXcdeeXvJsaMw12LiO/rcPYIAtubjFIzNn?= =?us-ascii?Q?FMceu7Bv+SVA4nlEKOaDvH4Q11t/ORKyWIgwNrl58EhNnwBBl56L0OTq2+9L?= =?us-ascii?Q?AgRWMqSBbu63ItZq9NumFaJbU86b8ybaBVbx94N6YByq84+zNG5X73AZ/p9m?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peRqivJypDwz8DLAq7O43Jql7j9uita4rv9WmhVd?= =?us-ascii?Q?lCeb1HCGOeAXwSQUptllXHQCY3rDQCEGNCaLVPVfiYJDsp3FVA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:43.2016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bb73ce3-1014-4a32-3352-08dcfdaf3b1d 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4248 Content-Type: text/plain; charset="utf-8" As multiple platform profile handlers may come and go, send a notification to userspace each time that a platform profile handler is registered or unregistered. Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 79083d0bb22e3..c9917daf683cb 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -404,6 +404,7 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) if (IS_ERR(pprof->class_dev)) return PTR_ERR(pprof->class_dev); dev_set_drvdata(pprof->class_dev, pprof); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 cur_profile =3D pprof; return 0; @@ -419,7 +420,9 @@ int platform_profile_remove(struct platform_profile_han= dler *pprof) { guard(mutex)(&profile_lock); =20 - sysfs_remove_group(acpi_kobj, &platform_profile_group); + cur_profile =3D NULL; + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); =20 --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) (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 2EAF41D90A4; Tue, 5 Nov 2024 15:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820831; cv=fail; b=V91ZQuSbBgqK+4I9nNj36b/PMyELS2NjP07ogmHM5iGm9DjTIgiilrdwUrNPkbi4+vY+UHKeG2gT/vgk2QpANblesZsruBAIaoJkopG5sMELXD81xS8ShnfH2yEM0aeYNhRXhTYHqMBeq8payTHh8kbP5S+LaKMDHfBWnJE8J5E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820831; c=relaxed/simple; bh=bea7+oj/yKdwscoVFM7DQQ3Vx8PXYMWZ5pqVEEdBUNY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YjG0lymvBtU8TJSQMxBMYTwiXNOZcBjAWkm+1BEetMwzkbELROmG7vlN70dzgX18ChPHWJ5slWCKoHnQXz95NQcCOe79xayjlRoXszryOTsbimJkYLtsz+xIFfr/TEGEsOge1jYAjOhtYYcEqTdS7xZ9wLBcPj0Xl+AKNB7z22I= 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=O5cMdkN6; arc=fail smtp.client-ip=40.107.237.87 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="O5cMdkN6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=flMH1Acp1dYzHKW8Vdc0xZ6IbZRc9vhv8l0Qk9oPpcpYerESmhszSteAxGnsfPZ2iq7gsFLlZzmOaoVSL5T88hAM6018ISMD3xCbKffMk3Ttj5TKJn9GBlSo0FkTlKYHfOFi2wwr4zhhWLhI6A0ug3aPONUeAPKm69m6Dc33XpYOck4gWdHcSeoglWF7RG0lOj2y29WUQrGOi36G12wZHF+HkhzANe1tUDvVebfIc/Q0rjnOa8GGEPRSYPut4pHD0J7vzQFBuf/UBeIxWmwRT6lydVX+2tm+wBSFV4AO83RDFQNKxWoJdPdhnXgCIRfSlS9rxqZ+vOQF4gUBFDp9rg== 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=QC/7QRb8PV1yuawMDK+R6YepIHiT9JZOu655rTlMd5w=; b=onqXbYxhDJjIY9jrWcMru4/4z93pjpmgOjbUv+J5pYR5JdXtAsS8/G1m7DuboMuKdNn/8me9X3Hik1qAgHm9YfiMiNNnzaZxBs83+xulxZI16fOV9hCecLKliYkQvOz30rM9w8TtDz4VAOXqa5ZM7QH3boPVMFaTJTMMfh6duABaV98hNaTSEVHpffCoTrsyuQf1hOvN0bPJvFZPd+f22+ijg3yWTyjiljMawPVG6LvhTyDJ9Oo4wz3KFhOK2GmJiOuy5nUR5jYNy7asiV3t0h/nK46oOtfKqza10tQFqaZa+/T+5FgYqVaWLig5p7GV4OmVxq7aYse9L2/SQfJNLg== 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=QC/7QRb8PV1yuawMDK+R6YepIHiT9JZOu655rTlMd5w=; b=O5cMdkN6XTNsMfUybN68MfsQlJq4rM7G/7zURyDF5VgWtGVy4v02O5deXqqOthowgw6TPJWTlU0wFkEJXbrjolRn5V4SZ4xiarzhrrMAF0o0x9DsnZuGHfcPNPdvyHWkanVF2SES13z6rVaRow6Vdeu/hhQ1gZIr8C3KHLe4d0I= Received: from MN0PR04CA0014.namprd04.prod.outlook.com (2603:10b6:208:52d::20) by DM4PR12MB5724.namprd12.prod.outlook.com (2603:10b6:8:5f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:44 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::cd) by MN0PR04CA0014.outlook.office365.com (2603:10b6:208:52d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:44 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:44 +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; Tue, 5 Nov 2024 09:33:42 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 14/20] ACPI: platform_profile: Only show profiles common for all handlers Date: Tue, 5 Nov 2024 09:33:10 -0600 Message-ID: <20241105153316.378-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|DM4PR12MB5724:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d9754ca-d5e5-452b-7ba7-08dcfdaf3ba7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?At4D5pdUM0KpNDuiG9tHBJK2K6wPe1hBfTi1qQf4Kc9BDQnU1e2a2VHNLOxM?= =?us-ascii?Q?h6BqwgI3LMQgb85pjrjHLft8tfl+B4v+R1fHDGINqovjVpGaS02896E2NN/x?= =?us-ascii?Q?Ca8txDbO7Q7btIIMBbsKag7WW+zAaExT5SFPxR/JV6Nk4OX62vrrTJkNAZOV?= =?us-ascii?Q?auxsWRMLaQdEYygLy6omn0fpPBx/sf8vQXmZ0tSRXCnjAtXzXfStt79FBrl1?= =?us-ascii?Q?blyBajHgw7aCKssHyvHfYPOgIxHASBAqPCks738p+pcdKR7st/7BeQqbtzyP?= =?us-ascii?Q?EkE5sSUb41uuH8svilsNHq0U3mYyt7vvU0+Dqm+OF4Mgy25j0VwM7E6E1bdS?= =?us-ascii?Q?WZvKTMu+dVijcMtNK66UWj/WbsjFJzDdRjm6jIptZc3I+b27ejMrstUW0kqf?= =?us-ascii?Q?ggb5ycmYDiuEaQ+xaLfV9ORTnQHK03yryRHseGDJMtdekBh938NG3fvOP9zS?= =?us-ascii?Q?JlhEclM8xgbBCmJjtNjevB+1mZeYVSVgPsHHsgaCQhpwZfQBLX1KS5blq6EY?= =?us-ascii?Q?K4soe7q0+VRVcXOgOVK0FBTZ086b9MUMOheajzNytiiJQavLJjkLKBq9jRLI?= =?us-ascii?Q?ChJjeIQNOSktYXseJhFc39s64391kUl6NaRlDQByRQWDDj3mJPwTRBa7q/Oi?= =?us-ascii?Q?RUu6ipuocGtmr1GJMonr6lAi5c6vHTqhB4ZDpQHE6XD7rJGYl8k6KthlcAuQ?= =?us-ascii?Q?+ICF0c4wzAdueMIARWRztBtp9xLklsUiPlTNIyh+/C33ENAc+LNWM7zpEpc1?= =?us-ascii?Q?jBySUkMqX687ZmIbxIfyiSQIUbI6H2Q06+/sxZoeKDyFjm8VtO4amypuPvqb?= =?us-ascii?Q?8YMUOo17JolxGmPRDGpAzF9nzq+Q19cQ8YrpJiMxWy/cHA2Rg9dn5oiOGd7T?= =?us-ascii?Q?LqeqL0tl2hAofAm25We+qMrOo2nxKlhuUQM1gqBWTtbvUVRC5BL5WfcP3heq?= =?us-ascii?Q?JjGcZ8UFelWtpI9V7FQM3WxmZ/5GECJsBx7cjF51bMEX6g4wAZyaFNNUY6Dz?= =?us-ascii?Q?SPkthAErTvUrLab5dvkHB38eGjTKlkNSXxo5AcamqoseM4BAgZQLT1Kkr32+?= =?us-ascii?Q?UDJzEB+R0BhAXvDSUD3F8JH8HvdDjmi9MIWSRF3F4KRol80gpawXDx9qx+Yf?= =?us-ascii?Q?uHoWoeHbUFh3hav3+InOCnuxE0sfhOT0LIIYEhe9w72O94PtyJPYytotnHEa?= =?us-ascii?Q?qL5zkQuY5qYqMr++spyMe60tdseLS1innR0W80EiX7mM4BKjl+ZSPyktMDvD?= =?us-ascii?Q?Pksi+cmeAQxjxcHlZHBg11IzMtrmdHXOjvYoNyH0lQkcdl4jqOpeAfLZg3Qg?= =?us-ascii?Q?mFqg7LXeeyScfjWfdM9iAsopKN1OjUZ6iksG93oPpGMJnVn14ND5P/ikURiM?= =?us-ascii?Q?KgLJ6SXnPp7TsD3npVQFPY8ZTpMpjrBfmAlncjTrHRMqMUbR6Q=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)(376014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:44.1078 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d9754ca-d5e5-452b-7ba7-08dcfdaf3ba7 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5724 Content-Type: text/plain; charset="utf-8" If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 55 +++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index c9917daf683cb..8de7c8352673e 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -235,27 +235,48 @@ static const struct class platform_profile_class =3D { .dev_groups =3D profile_groups, }; =20 -static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, - char *buf) +/** + * _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) { - int len =3D 0; - int i; + unsigned long *aggregate =3D data; + unsigned long choices =3D 0; + int err; =20 - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err =3D _get_class_choices(dev, &choices); + if (err) + return err; =20 - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len =3D=3D 0) - len +=3D sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len +=3D sysfs_emit_at(buf, len, " %s", profile_names[i]); - } - } - len +=3D sysfs_emit_at(buf, len, "\n"); + if (!*aggregate) + *aggregate =3D choices; + else + *aggregate &=3D choices; =20 - return len; + 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) +{ + unsigned long aggregate =3D 0; + int err; + + err =3D class_for_each_device(&platform_profile_class, NULL, + &aggregate, _aggregate_choices); + + return _commmon_choices_show(aggregate, buf); } =20 static ssize_t platform_profile_show(struct device *dev, --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2043.outbound.protection.outlook.com [40.107.243.43]) (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 2A370126C0F; Tue, 5 Nov 2024 15:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820829; cv=fail; b=NqElhn8s+ryCpDmiY/b1A17T/Ty+GrdUb93d3BN3C8oNgQRhKuMRCfUBBdsauqKpN+/27l6C7fNiafaJdVKO92dnBnX7onNvbUyEJhFPQV1dx6d0I6M0xKzLblXGu13YZ37kTvNRLZm84bUmKRmDl1H7bmTNAFEx9U+93yTExcs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820829; c=relaxed/simple; bh=Cd0g23FeVtwAj5O4/KHsSeyaSM6F5ZMiE2xkf8UVSBE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OpTvkEvCA5Cc9o5lmYZrUwqdY/VKPUynO3JWDM+zWOvi/wqqDQIf3SYInoh9mPS5pcOUOZhn5YiatIrjRlpH6kQn4MwT60P8dyEPMWLXliv1gRRnUk+fdqUVcMWNPGoHoP7tbZaqpAQoXT7AYx6xPkurSnSG8/tu8oBDOFajqRA= 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=VdBfmK6f; arc=fail smtp.client-ip=40.107.243.43 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="VdBfmK6f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LpGMVVYC3XDxEfrW1vSwvh7NPyfQz5t7gsWSnTcTDI3+7o8/AQCSya28v7dGwUTqhD0MznQ2NJpjMyokCCM3uoTo11mEhBf3QCgzOL4gHMFAl7/j3wAO4RBNVVemuO9EZYme44GGr5rh0CmLd2Fydih8f1jLi1jK7c2FUMmiuEIfiT+ScgQeOZjD+QaNVJl0++glk0WYMkOoDWiHZGA7Kn/wcLteV7RF0TmR8NTopMwCK3MsQhf1wFUz+08tDuy1kRZ1rwFemCbDuYIw+kM1gdjSwDPb6yOIYkpRSSXXBHsq+9Ku5BBnBWmykTR0hvLLFCaUpOmXVX9WtkCmql0Ppg== 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=S3aTvu3Ec310NAKYMzm+n8TYQ55+AteNFEeMXomJjW4=; b=ffMWKetZYU7zJh+3lwUPHpknBsffrErqStljvswWjDNHu3DN9g37RQi7sudaHy8pXQEsMUIyBMiOrf1gYx9O4I3N86zQOnDad7ATrH8xjfCj3PJS6b/YbAPKiZCaPmzdkdNOPBkkd78Bqb4vAvCj8mi2ryRgfdAZf1UU9HB+w/2H+KNZO4wQh2anNLzdHLwwDQN5gM9qZKPmyQt+XZ/gIlku9FHp+HBxntoZJPMN0HPPdOMKkGpOqxh8iorRofMCnT/4xyIs93dOO06tHEE8xDo5Q3rpTH99Zz3mLIz1Flj5JBOkgUVQceK+16LNlNDG30ujZqwcbfaDl9cYvBJE/A== 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=S3aTvu3Ec310NAKYMzm+n8TYQ55+AteNFEeMXomJjW4=; b=VdBfmK6fNT4WgnjPBZawflVDShzb+f2UyvWNdFaIwolXvxkH5CW0pNicfOEfKetiFPY8VuvvJ8C/U5SnDOrxNBhYy8OP6xR/vpwGJYIFmJXk6nn01W/5sHJ/3ofEv2nNKHDtkihvG3AT6MSN+EO51U+licDSP2cukhvbB+C792o= Received: from BN9PR03CA0544.namprd03.prod.outlook.com (2603:10b6:408:138::9) by BY5PR12MB4275.namprd12.prod.outlook.com (2603:10b6:a03:20a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.19; Tue, 5 Nov 2024 15:33:45 +0000 Received: from BN2PEPF000055DB.namprd21.prod.outlook.com (2603:10b6:408:138:cafe::ee) by BN9PR03CA0544.outlook.office365.com (2603:10b6:408:138::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DB.mail.protection.outlook.com (10.167.245.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:43 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 15/20] ACPI: platform_profile: Add concept of a "custom" profile Date: Tue, 5 Nov 2024 09:33:11 -0600 Message-ID: <20241105153316.378-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DB:EE_|BY5PR12MB4275:EE_ X-MS-Office365-Filtering-Correlation-Id: 2590f222-c1e0-4e68-4cfd-08dcfdaf3c3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qDhSwBkIGzo01cErq1GPEi4Cr6B/8wDFLiYmawQX8EZIMb6+E4TUgNFbIEvU?= =?us-ascii?Q?64qlY26PhsUMZjotWT76v7x14BbydcLXF/nuABtVYRbatqqE8n7wmwLWyFAA?= =?us-ascii?Q?FjYMLyW8dkAk3xgY2Sce1n0U7DgTz6yQAQ7UvsFV2XtBeotQE5nnqihZQd/u?= =?us-ascii?Q?+tc7GmbV7kkyb7oRHQrldQlys+MsHuFW2EaJG3tYKWmL1SGIApinYVIEV4pw?= =?us-ascii?Q?yQkEIuDQc2G5F1FMnmknDKaps760V8IKICpocqyYwHfpD1pcsYm6TUGdDOqf?= =?us-ascii?Q?1ZUXjHvwpnCJ1lMlDGoKi0/O9FU4eVDBvx61TFtLe19SaoYeN9Vhh9Bwobur?= =?us-ascii?Q?qYpsy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XihbiVTWff3cQsfXnBbPv?= =?us-ascii?Q?JJsq2SIRlLjiFz9WZAsT8foy18ChJQfJgj76wVxh/SbJnEv9msEt0xOC2JxO?= =?us-ascii?Q?NBlTtmXsdwKHjt7j0BTX45xbO2CLsUC6fz/BYfTBqOrGOIMaBZ3RqE2PtMCW?= =?us-ascii?Q?XtLqMvZKuOqNWrtUt/M3MDENhwCKE7FlOZlnEdSA5fc6Hy6SFw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:45.0962 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2590f222-c1e0-4e68-4cfd-08dcfdaf3c3e 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: BN2PEPF000055DB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4275 Content-Type: text/plain; charset="utf-8" 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: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 1 + include/linux/platform_profile.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 8de7c8352673e..d8c2d195106c2 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -20,6 +20,7 @@ static const char * const profile_names[] =3D { [PLATFORM_PROFILE_BALANCED] =3D "balanced", [PLATFORM_PROFILE_BALANCED_PERFORMANCE] =3D "balanced-performance", [PLATFORM_PROFILE_PERFORMANCE] =3D "performance", + [PLATFORM_PROFILE_CUSTOM] =3D "custom", }; static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_PROFILE_LAST); =20 diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index f81c3afcb7575..d2a2ab4c6cee9 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -23,6 +23,7 @@ enum platform_profile_option { PLATFORM_PROFILE_BALANCED, PLATFORM_PROFILE_BALANCED_PERFORMANCE, PLATFORM_PROFILE_PERFORMANCE, + PLATFORM_PROFILE_CUSTOM, PLATFORM_PROFILE_LAST, /*must always be last */ }; =20 --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2041.outbound.protection.outlook.com [40.107.94.41]) (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 491931D9669; Tue, 5 Nov 2024 15:33:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820831; cv=fail; b=RJugFZlVpkik+IWyyCPvVKLYi3ZHgbThH/JWqUYkkFpXP1w8DwE7rVptYzeVL5spnNepaVxzwRKsVY7dpFcWmmKJVk3Ig5AWBgOPLtHhaD0iXLB1RpX5acO2W44IzKr/nCtXb+Q2jKxAjAB+nRPl+3AbHxib/tVyL8S4ir352Lk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820831; c=relaxed/simple; bh=7EKQRIUFbmHdiD7bG+5mSsPZ+0rhm2SGPEQdCXLXBT0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hB5cQ3hVwoh490LEulHsVMcWjRMjHsXGusHmh/LT39HSAi93Ek/s2O2wt4Lf4x0KlkQdGARudzZ2/TB/hiIJ3vlPpQtUAm7mDpndY40Qaam2c7Mbj0ujKdsK8rtMDajgEzoTl1nSfzRKLSxd9POizk3ADa6b6O09I65HyBxmLVw= 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=D5K7I3H2; arc=fail smtp.client-ip=40.107.94.41 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="D5K7I3H2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZG00jN3UAU17rdrHhLUxzjeF7/L8U/zole5GQM29CwCXbLqsZBdJqwoW/sAaFmKvO6l71relvfqNdd3j0p/vpixb7fpfNh3kWKGnZo3Nzpo3/DxpP8Xj+Dg0Mne45oziuzDaAWn+k7K6LRoIJFRM3UUA3O1jX4K3Q5UENfwoytUBbZZ+yOYWfAix4XqyZ7nycTDoRgLEuR08YA6DFJ2QBxtp76d7lEdqnvSSm9h54pWBsrjFPSpU+ggYFReeXOGEg6LlRjPZvQE37Po6kMECluyQm0M0VykCVDOeKMxvvIrx/a/PZnZ6a1TEVxPpu89gzBRdenygRflZ6FYXC8lGwQ== 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=VGwvhOXSQqEMg3VRy0cWLQm0Ref24Xtdqg/sVQL/t6s=; b=NR9/zA69+u25JM/OskPGagowcEGefXeZom782+iK1Ee3kS+y/Z/+CTePDc9qziVMThkbAEA17SHGSW7xa5jaVIw95XseMZo8wCUfoelFEKmokBrA03kYb/QA2dktrVRPK6c/0uLrFJWn0ZO800G07O2ZtRenXQYNeTSsiG8NHLXPiMCKYwqJcIlqFEgMIvXYCsyKRpsrU7iG4B3WXGpAyuRkpHeKSpq9pku45D7PQytmPPRY2EcL/ihjz6BMZZW3FNB1RX2s/iloX+prY+fi/AsCbMZmkItivdJVEuD2girbPSsiwgICTk5MEJUUwAdRRxEDcw84VjjEJqdYuLHPdQ== 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=VGwvhOXSQqEMg3VRy0cWLQm0Ref24Xtdqg/sVQL/t6s=; b=D5K7I3H2sfQNGnBPlFANtKmoHhzql504PK+HG4AhQLj2LNmcPVArWiEmfrDxbpv894wGm6NteFu1PbmYjRYetPrnjsrjd1SAgu0dDZjWYPX0IWAXTOfy4WZlyCAgs5GLG98Q59FTGYcMh2mVI79CxdDGSR0xIlIxiNJIqoUnUgw= Received: from MN0PR04CA0003.namprd04.prod.outlook.com (2603:10b6:208:52d::15) by SN7PR12MB7179.namprd12.prod.outlook.com (2603:10b6:806:2a7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:46 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::f5) by MN0PR04CA0003.outlook.office365.com (2603:10b6:208:52d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33:46 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:44 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Tue, 5 Nov 2024 09:33:12 -0600 Message-ID: <20241105153316.378-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|SN7PR12MB7179:EE_ X-MS-Office365-Filtering-Correlation-Id: 25c1324b-6a97-437f-bcf6-08dcfdaf3ccc 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: =?us-ascii?Q?k1V2uhwFq2v9YDFmC9P0CI6S+hETFP0WqdjM+muYchc2XHr1FypmCkXelHp1?= =?us-ascii?Q?vZacdzp6NwjFT57KT/gLE8fmBH622z/OiDsG5qEcCGIoHuiuK/OAHPIcSijy?= =?us-ascii?Q?Udwncnz5nQkHIfiTOh/JaqP34SDj27KLF+Da/OJ5er52d3h3c6kFraN1+Bfb?= =?us-ascii?Q?otNcTVjaZ7t4pyupoGY48/4VeD3WSxbw4u+YGzrZ7dViqBEQOQvWTxFbMQzD?= =?us-ascii?Q?U/KqVt0OnIkxc2f3Fp6TQxyxMMmESvrgfLsJSjGPVXGqis8qWJjVavgMtBZ+?= =?us-ascii?Q?hnQBfuk2OXb63FKaZb/NPg4lN6T82dHP2d8x6tXVMJkus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FeQlLl3+wLTSgCPo5oWcXEK/MnjD+EyU8ci0D2URl29gRZDk9GU?= =?us-ascii?Q?wJYBZXNSuMygCBe1JNE5gY5aDWAKmkdYkIN9WvR72ANEeEwUqP+gr+STDeDq?= =?us-ascii?Q?zaLZziH6959mYCtJn8MPHmXioQme6ZaV1g/51xiCjMK7SudqRa1WnP1FuUO3?= =?us-ascii?Q?Ugf3s9chPLzkLjNJ1f+FvQfqFJSkSgb5lIej/gGjRY1Pz/9wQA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:46.0297 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25c1324b-6a97-437f-bcf6-08dcfdaf3ccc 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7179 Content-Type: text/plain; charset="utf-8" If for any reason multiple profile handlers don't agree on the profile return the custom profile. Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 84 +++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index d8c2d195106c2..7861fccc2e58c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -280,55 +280,77 @@ static ssize_t platform_profile_choices_show(struct d= evice *dev, return _commmon_choices_show(aggregate, buf); } =20 -static ssize_t platform_profile_show(struct device *dev, - struct device_attribute *attr, - char *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 =3D PLATFORM_PROFILE_BALANCED; + enum platform_profile_option *profile =3D data; + enum platform_profile_option val; int err; =20 - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err =3D get_class_profile(dev, &val); + if (err) + return err; =20 - err =3D cur_profile->profile_get(cur_profile, &profile); - if (err) - return err; - } + if (*profile !=3D PLATFORM_PROFILE_LAST && *profile !=3D val) + *profile =3D PLATFORM_PROFILE_CUSTOM; + else + *profile =3D val; =20 - /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >=3D ARRAY_SIZE(profile_names)))) - return -EIO; + return 0; +} + +/** + * platform_profile_show - Show the current profile for legacy sysfs inter= face + * @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) +{ + enum platform_profile_option profile =3D PLATFORM_PROFILE_LAST; + int err; + + err =3D class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); =20 return sysfs_emit(buf, "%s\n", profile_names[profile]); } =20 +/** + * 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; =20 /* Scan for a matching profile */ i =3D sysfs_match_string(profile_names, buf); if (i < 0) 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 =3D cur_profile->profile_set(cur_profile, i); - if (err) - return err; + if (i =3D=3D PLATFORM_PROFILE_CUSTOM) { + pr_warn("Custom profile not supported for legacy sysfs interface\n"); + return -EINVAL; } =20 - sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return count; + ret =3D class_for_each_device(&platform_profile_class, NULL, &i, _store_c= lass_profile); + + return ret ? ret : count; } =20 static DEVICE_ATTR_RO(platform_profile_choices); --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2044.outbound.protection.outlook.com [40.107.212.44]) (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 B8BC81DF731; Tue, 5 Nov 2024 15:33:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820833; cv=fail; b=KXSwkvNrVQvam/Svvl2JNn9mlLe99sEkwZuVAwf4hD69E0Y5gWVv+vrS8OGu7FiR4ii+MlrOkoPCdjDfrj/HOj47IJIeh5uhVF2FHdc0SFv44iga0usd9ux23bbSWgyXiRU10n2tV7KO5g2kdyx5kWbHLaHfMPPaP6HjbYnQwD8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820833; c=relaxed/simple; bh=ny3iW6DOlZU8HQaxcPXox+hKvSEiG1vFhL5CaxmL63Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A3t68pFirN/MQsW2SZK65J3NWPnagbnn85y+P03v0n+RJ5exxktZWmtVK4rYNcCldvsaU/rOV2sjhuN78t6xQDZiyqivrJHwj0lh0F5xmB/aBkuYxkIkkwbMuU0xZkoJ5Jfqt88k32x0ZHN+jDdhHD6UMWapB8MeALtj8gA4jqM= 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=HUphLA1A; arc=fail smtp.client-ip=40.107.212.44 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="HUphLA1A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B7CBsAGkO0bA/5Yvamgt9AKvl2tWA+gtQq6ai5K8fHg9lrHd5fNoC0W0l0T9j0Ov/ErySck3cMmoulKIjJRACQkFPEzMnsXP0QeiE6Q2hdD0rQvCV9InLiNH8GKsQY8Qnn9rXi4AJyqUMJUrPoSdqwezruCgrZrFrHBqAA+Xuyig7TcXEPsf0btxy74rhENm11BoLWYtGcyqhNYjrWffnC+wQ0mUm7IBPb7I3Vwl0aNs7hYLLfkcpAtXXf2ZgK96v6AnGivIXSoL8vw2AJshSOCYeiXDwrmEqrZKISW2ynO2bE8HuOvX0dY60lNtPvptYQ26+3OPNhgk8HNdgxMpTQ== 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=1JP3To4xH/AA3ZnPv9aOvigXqmgNlgcBHoMsbj8A2T4=; b=QUm15SZg63Do0HkbgHzEQl0zZR1kQfE9zMC+2X+sLYVFkZJKIoIwZlmiJtIutFkIkl7N7xLZGYrsh0FWtN2Jt0HPQtKicp+7kNLsczjN7ErIQY+LhJyenaDZ9p5i8IFkLhEA2h/WzbBq8q2S+S47oq/NCbuAk7QO4jntcU9qQnaeFLHoGV7j5vznnGGSoivQ1GGAEJWOV40+EoyQ+f5oP1B9BO6oSdN7qheI0Sel9+8hyL+/xMYJ9CQ4h6XTZ1XCJ+6lnJelbNqmvIaAPAUEyvbpMaKcC6GsLvGbgDxB8draRReqWX6xo/Rl9RwXkWh2uGN0Fdmu8201EHgZkaHXgw== 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=1JP3To4xH/AA3ZnPv9aOvigXqmgNlgcBHoMsbj8A2T4=; b=HUphLA1AekvuGJlXYFpjqVdnk/nYD+Clj8p5dhq0usHPLbpwY8tZk2fujDdL8q08fEVEi2sXbn8egM5FLktR+5sBZCdmUzBSfHzj/ol070p7tU7xUOi3ektNeAiwhHrNVdnoUxXVDOJqC4cidNTk1WPGvbYxtnXM4NSypmerEGY= Received: from MN0PR04CA0011.namprd04.prod.outlook.com (2603:10b6:208:52d::7) by DM4PR12MB7717.namprd12.prod.outlook.com (2603:10b6:8:103::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:47 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::28) by MN0PR04CA0011.outlook.office365.com (2603:10b6:208:52d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:47 +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; Tue, 5 Nov 2024 09:33:45 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 17/20] ACPI: platform_profile: Check all profile handler to calculate next Date: Tue, 5 Nov 2024 09:33:13 -0600 Message-ID: <20241105153316.378-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|DM4PR12MB7717:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d838e77-fb61-45c8-183d-08dcfdaf3d6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?afNngmcMqPrxtZGW04jW/zY9r1V/Z3xEoArP7M6BizyqWQ0QCaVo/1DbRYAD?= =?us-ascii?Q?59fdd6fNCVv3eJdEtyycGeJgX6myfwpDMMuc5hsG8sEQiMmt9q7qqMWqW4PF?= =?us-ascii?Q?pyDtmbY6O/Oe1rasOk53fHpGe9Nf2PcRaKBlXR5Nu/lDy8gao+17OpOqq0sb?= =?us-ascii?Q?TEO/AEVGRTv36bRFDMrgAKHbpbZpGCFKbLJyLcEUROJ7FoqHXQrf+yPIOBnP?= =?us-ascii?Q?rob1qthXffu1IhnVGzWafj1gSsvNADSTOmrAULFUN3FO5cRLsOL8+wePQkyJ?= =?us-ascii?Q?nmxoP5buDJ83Q/iKBoZfgpz9IzwS8vYpeglsGJACu6Snx4dxmTnWRliF69eT?= =?us-ascii?Q?aHar3XXLfson0xq5oyGYqEg3yiYwsoLEXsGnouwsSh2huo3RnCQsOTiQ4VqA?= =?us-ascii?Q?mGIhnucdlOisZpg8HffmMwSL+2iGE/o1kPGs/KHlC6cw3s+WDMg9QVCq1qZ5?= =?us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Y0pi8zIpxBBjNKxaLgtPOnBv0c?= =?us-ascii?Q?h5qldGPR6gIg+BQmBljUshOPaCRdIg2AsNjloFFVDsAGTu31aQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:47.0610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d838e77-fb61-45c8-183d-08dcfdaf3d6a 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7717 Content-Type: text/plain; charset="utf-8" As multiple platform profile handlers might not all support the same profile, cycling to the next profile could have a different result depending on what handler are registered. Check what is active and supported by all handlers to decide what to do. Signed-off-by: Mario Limonciello Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 35 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 7861fccc2e58c..568485e285061 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -378,34 +378,37 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); =20 int platform_profile_cycle(void) { + enum platform_profile_option next =3D PLATFORM_PROFILE_LAST; enum platform_profile_option profile; - enum platform_profile_option next; + unsigned long choices; int err; =20 if (!class_is_registered(&platform_profile_class)) return -ENODEV; =20 - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + err =3D class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); + if (err) + return err; =20 - err =3D cur_profile->profile_get(cur_profile, &profile); - if (err) - return err; + err =3D class_for_each_device(&platform_profile_class, NULL, + &choices, _aggregate_choices); + if (err) + return err; =20 - next =3D find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + next =3D find_next_bit_wrap(&choices, + PLATFORM_PROFILE_LAST, + profile + 1); =20 - if (WARN_ON(next =3D=3D PLATFORM_PROFILE_LAST)) - return -EINVAL; + err =3D class_for_each_device(&platform_profile_class, NULL, &next, + _store_class_profile); =20 - err =3D cur_profile->profile_set(cur_profile, next); - if (err) - return err; - } + if (err) + return err; =20 sysfs_notify(acpi_kobj, NULL, "platform_profile"); - return 0; + + return err; } EXPORT_SYMBOL_GPL(platform_profile_cycle); =20 --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2042.outbound.protection.outlook.com [40.107.102.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50F831E3761; Tue, 5 Nov 2024 15:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820836; cv=fail; b=ijpVAuPHX+VJf2WjkTctqxAvcqlgylDpefLuGH9RcMKDc3RUPv13g20nViiCu9frCzw3DqjYj/1FRnMy6okoAQ4xU7h46LQOZnhOW1g/xBHvPOGGH/WZ5xUza8J8GFGhqR5ly3l7KedLoE3Be3dk674CgkEkhjsOoFLWEKtbFH8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820836; c=relaxed/simple; bh=8265ZWL5VAjazKoIuoLkcoqO6KX5LFi0MhGnolPFVNg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aDgnVz/2jMaM0raakvUcSOhzs0e96ejFsyZj6h0aAApslvgGMTPsYuTiO0rXfpO+qRuYeDTv72Uyy30yzkP8QqWREeJitpr1hUBUC0UHcWruE4F9HK8zGR2JUPrnL5qFzD6qTQbq88z1y0uK9yzpsPCPxzP4DgOrRF7c6Hx+WPA= 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=cMoYQs8Y; arc=fail smtp.client-ip=40.107.102.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="cMoYQs8Y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ohFpJbRJ7Ua+OSgIc2WtuYqHPL4c2syfKBM+cZCwj6CCw2/Vl0pVD1jXru8Tb/F/3NLjuvv52QZGWMtZsMHS0LT5inCR5wRIN7b1eb9o0O2e6N7KSePb0dBp0yT4JCiWGa7vA+0rKMrmZNN2q49ZV2DgjbKjaq90o4nIGO5M6fdBS3QTHYZqK+vXxA72IJciP0ge+OFtvZ0dKhltmvRvqIqHt0Xg7PpchZDlp2OUZCYnOSq58NyZw+w+L5SaswrwQW7psdnqYx4hGcP+jIFjLxrkxCH9FAhXdvWn3nIEE5IK9RozILRUBduzqTQ0Tx5PbSqDiYa/F+a9ElBZ0AB/ig== 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=2d2T7e6xMXa8Ho9y5c8HKcJjgMwsLu6CwC9jhZqoEl8=; b=c+F1J7WV4gf+MVMIsJCuZEa3gu9wxtE6otv6tT3CDoyrvPvWxCCytqFkq8e8wOYzihSi+Paj+ONR5eJpqqkrKtNUivtXIVww8pp07YJDdpA0Eew9LKRahqqA2pPAZKQRsajuU6HXWF5hA+TtNw/gfk5iuQbOXvFtIEc6YvZE2FY3wg4nGepu3HuC3bMQbd7AV3Eh3nM3JJsOee8b2DwleIxOSUPClpIGsq4XRXsdDCYUu3r6PrwoOHl+V8SR8oAUo/ae/qOs9IDN+nnVy9Y8guQXkTqkiJmoSFaSwOZa5YvFdNngV5xbkIYS9xhWIofiFWybKTFTSjU6aZ1pa+QzhQ== 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=2d2T7e6xMXa8Ho9y5c8HKcJjgMwsLu6CwC9jhZqoEl8=; b=cMoYQs8Y008AY7BoGlRTg++Pcn9pgWj5t2FzUZJin2QyiL9riITekcn1kc5QZNx9tOmlqkRJyp8CRyDqwOQTpS5Q/HLYrGcVskNxYq8ks/zBRvQ90HlEg8hiTIfA9U054KqStqfjA4AmMmTMqyhLMCelrCdEy4bko0em6QuEMGQ= Received: from MN0PR04CA0014.namprd04.prod.outlook.com (2603:10b6:208:52d::20) by SA1PR12MB8699.namprd12.prod.outlook.com (2603:10b6:806:389::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.32; Tue, 5 Nov 2024 15:33:48 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::c3) by MN0PR04CA0014.outlook.office365.com (2603:10b6:208:52d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:48 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:48 +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; Tue, 5 Nov 2024 09:33:46 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers Date: Tue, 5 Nov 2024 09:33:14 -0600 Message-ID: <20241105153316.378-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|SA1PR12MB8699:EE_ X-MS-Office365-Filtering-Correlation-Id: 02e81b3e-6041-4849-9618-08dcfdaf3e6b 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: =?us-ascii?Q?BB6OCEhVkEaAd04PrS1uDCvV6AnRZrcSq/zpzO3ips49Re7eahYEUoKVi6Qu?= =?us-ascii?Q?KfA8VgpGo9g/bZNhHK0LpnQwjS4+Yzn+9IEu94fk73jK9PerAe5/kzURS3EN?= =?us-ascii?Q?FZuBlHW2EuyXlJ5FTtsbfjy6ilnt3xfJD/NztfxRl99XB/BSb1A7f9knzt3A?= =?us-ascii?Q?0KZN8uNB++qxWdOIGkArH5K9wT9VS1uf3QiZuXYWHlWVjzTU4d13grogj3Y6?= =?us-ascii?Q?9mr2wx+ZDLT0A51BpT+eCcDQEvzrnfBxVUPc2GxI/+jIS6gtFxCBLmVQfzVe?= =?us-ascii?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DFnRIxipH+?= =?us-ascii?Q?S7fw8ZWzDHU/T8yMBpx/dKW9TCTtzgQzyUAmztDNngoiH3ZIbntpqm8QrDLS?= =?us-ascii?Q?dxtFmKsvn1fHp0kz8mgnR3OwfNqtOPjBV4j3UH2y+5qRTyx9IDZsuJnUvsSc?= =?us-ascii?Q?r9JfMMWt+5BkM2AyJ8SyQnWHdoDor+ddnPekTvgqoiST35qdUqrs8Ar94q5C?= =?us-ascii?Q?Hfz4lY68Ox3D5+1rAKSB7jyS7Quzd+r12behd8nz/APXXzEhkg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:48.7485 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02e81b3e-6041-4849-9618-08dcfdaf3e6b 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8699 Content-Type: text/plain; charset="utf-8" Multiple drivers may attempt to register platform profile handlers, but only one may be registered and the behavior is non-deterministic for which one wins. It's mostly controlled by probing order. This can be problematic if one driver changes CPU settings and another driver notifies the EC for changing fan curves. Modify the ACPI platform profile handler to let multiple drivers register platform profile handlers and abstract this detail from userspace. To avoid undefined behaviors only offer profiles that are commonly advertised across multiple handlers. If any problems occur when changing profiles for any driver, then revert back to the balanced profile, which is now required. Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- drivers/acpi/platform_profile.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 568485e285061..b9eb25f58a2a2 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,7 +10,6 @@ #include #include =20 -static struct platform_profile_handler *cur_profile; static DEFINE_MUTEX(profile_lock); =20 static const char * const profile_names[] =3D { @@ -368,8 +367,7 @@ static const struct attribute_group platform_profile_gr= oup =3D { =20 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"); @@ -428,9 +426,6 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) } =20 guard(mutex)(&profile_lock); - /* We can only have one active profile */ - if (cur_profile) - return -EEXIST; =20 if (!class_is_registered(&platform_profile_class)) { /* class for individual handlers */ @@ -451,9 +446,9 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) if (IS_ERR(pprof->class_dev)) return PTR_ERR(pprof->class_dev); dev_set_drvdata(pprof->class_dev, pprof); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 - cur_profile =3D pprof; return 0; =20 cleanup_class: @@ -467,13 +462,10 @@ int platform_profile_remove(struct platform_profile_h= andler *pprof) { guard(mutex)(&profile_lock); =20 - cur_profile =3D NULL; - sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); =20 - cur_profile =3D NULL; return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2080.outbound.protection.outlook.com [40.107.94.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 1CEE11E412A; Tue, 5 Nov 2024 15:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820837; cv=fail; b=tWaxZD6kWfjdlX45qV9e3+7cULMJxREGo+nap8vEvd9yYnKgLi2yUxom4xPcbuB/iDgdNUMtV109m39HJFcUrmoqOH/Kq0MGqmhm9fhToYkF3bxmQGw2zdsPxEo8+rzwk0baGlQYubfINBnwimpl3HppXYTfWXluz7tdpAzth2M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820837; c=relaxed/simple; bh=Yr2DwGP3stibvV5kDEhUIRooOkkRhrchVHVPrM0URJ0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WDPFIwj3uPrjkbPwAYxGsofnVxJTe7Tj5jremf8iezLAHPT9OG4sc6ySYyydJqSSBbjsY4oiowE5hg6S3kaEwATOBwNVSlRBMGrPlHgJmHZHym3Rsv3BgYY5s4Kv9hkpvGIA2Mq/bDIp0mT/fZvVJyVVDF0/V29883VKd6FnNLA= 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=mD9TRaqV; arc=fail smtp.client-ip=40.107.94.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="mD9TRaqV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hqWM5SehKn9BYuhbGHfHJ9HbmJ+vhqIx4qZWM1AZYGCbnfAOY0JsrnD1JLQA8DylnIDhc7WeO6MQhtzUrQx6AM0uwUOeETeDh4g10P4Rjlz2fwG5YrO/Q0BDSoFf7uIrUQXjVInGsEnCx7yRUnSAG5r1YPFJ74WEUY8eZ28ZynhZ0posbK47/dQW9+RgY1RxhiHDW51A1b4TvpFFcnW7aQRH5r3IwZcw9cLx80NIHbAWaeKXyhggsPuwhmIrTV5ucQMYFdHH/uL4JlpzlKS6x3Lo8jO1C8Gn9y0Pgk0nko4Z7lAsHJVIDeZ0yIgzJHRFsxgmQOsj2IsdU+kE/oDYxg== 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=t/3tLlKeu+mu2+ZvcCVORU2kQj6qVksAflAgnmkPtrU=; b=p67nPGg+QEpjki7Up/ozdBk0U3WdjoYQt80Ti/0bQJTInEmj8aES8tTK7RYhETc2LS23rTjDhUsWMNoTgkpgjDK1ppH07L491x1WRotGYVMgai9Kaf3NMh134c5IV+uzQhIGDtYnMlnn80FRhCvBecI6B4cCoCbsTEvqV6rpMMTZYcHY1MAbuXxa2XqCYm6G+5maVDZBONZVQdX28ImvcruWPTkGp9qA2DOu9VgOLQPQ5JekvERONa1pvPMq8ZJSPZigsfWkkh4vNuFyEViYAaOEToTNUfYn3wj/ZogTjLedh6iiXDVOqwhi+Se9kloViHkXOdP7Xajpglzqb90SsA== 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=t/3tLlKeu+mu2+ZvcCVORU2kQj6qVksAflAgnmkPtrU=; b=mD9TRaqVdrQIUBcC5i3L5S+NzJQK/vD+TvKdfOjycYIh2MbUOiD61Kg/xWPxgPOui16H5/+9ghFzgKAj/L/N/cIItMbXI0WhY6MABSyyYlA8ktks7QVPX8hcjDi5rCb2JgtLNlDdv8PD3OmUS5BWe8vmy1532fNe7D9uFdb3AEY= Received: from MN0PR04CA0028.namprd04.prod.outlook.com (2603:10b6:208:52d::27) by DS0PR12MB7900.namprd12.prod.outlook.com (2603:10b6:8:14e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 15:33:49 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::e2) by MN0PR04CA0028.outlook.office365.com (2603:10b6:208:52d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33: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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33: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; Tue, 5 Nov 2024 09:33:47 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 19/20] platform/x86/amd: pmf: Drop all quirks Date: Tue, 5 Nov 2024 09:33:15 -0600 Message-ID: <20241105153316.378-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|DS0PR12MB7900:EE_ X-MS-Office365-Filtering-Correlation-Id: 91a9210b-7e9a-4e52-6ad3-08dcfdaf3ec1 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: =?us-ascii?Q?RmLjdV+zvhXv2OFox4hPVs7phVw34ieHAWFNfPk8Le6rI7cbu7zK/ov158k8?= =?us-ascii?Q?CnCRGqxb45m2c/o/NII/EmDAkg275JJJe8tUsx+6XkUxupvt69ZDVAJZPfQj?= =?us-ascii?Q?c7E4xxRRvCIMQIh2cLmEuxoTms2fE05vSFeuKjJlEsC2ts+gyNoXXPyfuJS2?= =?us-ascii?Q?Xa0GBmHiiRsEfclbY+9AHhN9cUa/gpPie5a1FQng1T1lpkwwnr2OECx3W203?= =?us-ascii?Q?6HUG68eh6tw4d8rJzrSrrNnMNsNOBYILcqnLWiEuSy7YJxYY4lW6/TShPre8?= =?us-ascii?Q?ToS8aG5Qa6Yn3gjprD2nEhH9J5JPI/lOB9gFEhDKhTUI7BmhrgzUehhhioLX?= =?us-ascii?Q?mPZaLoWjPIeMoWmEsAzhTl+GJxRdLRV62nmDtVGf6CciW9Ez5/bDLtXkFOII?= =?us-ascii?Q?pH/OZD73xirjlMigMX4z4ARPAugQzv7cB52dN915hToBEOQumYrhjuwFKVOC?= =?us-ascii?Q?1YaJGwSCqWpgoWq46zi6Ni4X4psl5/j3ZzRJ+t4rm2YJhI70PMt/kaWafDkz?= =?us-ascii?Q?8sWH+PLFmgBTvKup3OoAb6tX4V8BaAiRlovJ9Kv/UWuKNgPRtbn+5Yc92ybR?= =?us-ascii?Q?cMuKNkysScqV8jwx4vHUjs7+H6DO/po+g5fJUwLLiSedQ1dCucJg8Rx3X/Dd?= =?us-ascii?Q?2QW410PIlO3CGEpYJgcZGpBxLN52Vfqp6Oc2DgoIbOSVfByG2zG1MjD7J5dF?= =?us-ascii?Q?9nkSndKchGs71oGVrgq6l9vX/RbJQjm1sdUg6c70db2tAC5G6VhGXBU6ishd?= =?us-ascii?Q?IratUJ40jkHYX1IcVHLNuJcnJ29J+AZStcu3QlrFgFoshb0Z2romOFU6kfW+?= =?us-ascii?Q?Pu/hzLYN7oQNh4j+V75glMr96fQbQWrIASEB4DHH8WRTesr+RSWVd0SAsLOO?= =?us-ascii?Q?PwCvgpTkx+I6Ci0U6+Rr2FR8dA5rLEDd8lZExhkuMZAwUVFYSUIDynW5ySYd?= =?us-ascii?Q?reUcpH6ZXVxc9VeiKMiIgTmspKcYDkvUfDvcj91kwNumpOjFpL3NzWQtkpCn?= =?us-ascii?Q?aaD3Zllk+IWR3G1DBWHI/KLDZiaYCXWBUxYu3dQ2UXrYLcWelxpYiGEK6fPn?= =?us-ascii?Q?Zk+SOS/c1k6YSL/gtZEaZ3B/g4vO7oYbscJjzWABTH38ArLno9IMgpZROwxv?= =?us-ascii?Q?Xo70lBOeKVI4CzG7nPvdOptiE5RQ02tFRt8IVl9hZYbeKrJ6bMDiTg4K2nj5?= =?us-ascii?Q?mcxze2aD1B3Osx1pBAzhEnh4t0iLWClTLpcnmYUB3N/ZghYFdqPn7eHeJp9B?= =?us-ascii?Q?Pm22t4FM6Uk0SLmFl69vaxTpW+lSO8yTFUtokb/bOJM7TT1CvtozDqWhML/z?= =?us-ascii?Q?gqbY7f+aveimxCNE1JkQDmbtYiCVG8U4JIUrrQ9Tivbn5G1I4G9ClMOl2iRE?= =?us-ascii?Q?GJWCKAaXjMcXNh4QnYQDnYQ/twu9o23N1PW/ouzvNQHq66aMzw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:49.3110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91a9210b-7e9a-4e52-6ad3-08dcfdaf3ec1 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7900 Content-Type: text/plain; charset="utf-8" As multiple platform profile handlers can now be registered, the quirks to avoid registering amd-pmf as a handler are no longer necessary. Drop them. Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Tested-by: Mark Pearson --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/core.c | 1 - drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ----------------------- drivers/platform/x86/amd/pmf/pmf.h | 3 -- 4 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/a= md/pmf/Makefile index 7d6079b02589c..6b26e48ce8ad2 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -7,4 +7,4 @@ obj-$(CONFIG_AMD_PMF) +=3D amd-pmf.o amd-pmf-objs :=3D core.o acpi.o sps.o \ auto-mode.o cnqf.o \ - tee-if.o spc.o pmf-quirks.o + tee-if.o spc.o diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd= /pmf/core.c index 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); =20 - amd_pmf_quirks_init(dev); apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_dbgfs_register(dev); diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x= 86/amd/pmf/pmf-quirks.c deleted file mode 100644 index 7cde5733b9cac..0000000000000 --- a/drivers/platform/x86/amd/pmf/pmf-quirks.c +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * AMD Platform Management Framework Driver Quirks - * - * Copyright (c) 2024, Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Author: Mario Limonciello - */ - -#include - -#include "pmf.h" - -struct quirk_entry { - u32 supported_func; -}; - -static struct quirk_entry quirk_no_sps_bug =3D { - .supported_func =3D 0x4003, -}; - -static const struct dmi_system_id fwbug_list[] =3D { - { - .ident =3D "ROG Zephyrus G14", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"), - }, - .driver_data =3D &quirk_no_sps_bug, - }, - { - .ident =3D "ROG Ally X", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"), - }, - .driver_data =3D &quirk_no_sps_bug, - }, - { - .ident =3D "ASUS TUF Gaming A14", - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"), - }, - .driver_data =3D &quirk_no_sps_bug, - }, - {} -}; - -void amd_pmf_quirks_init(struct amd_pmf_dev *dev) -{ - const struct dmi_system_id *dmi_id; - struct quirk_entry *quirks; - - dmi_id =3D dmi_first_match(fwbug_list); - if (!dmi_id) - return; - - quirks =3D dmi_id->driver_data; - if (quirks->supported_func) { - dev->supported_func =3D quirks->supported_func; - pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n= ", - dmi_id->ident); - } -} diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/= pmf/pmf.h index 8ce8816da9c16..b89aa38434faa 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -795,7 +795,4 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_de= v *dev, u32 val, u32 preq void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_ena= ct_table *in); void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_t= able *in); =20 -/* Quirk infrastructure */ -void amd_pmf_quirks_init(struct amd_pmf_dev *dev); - #endif /* PMF_H */ --=20 2.43.0 From nobody Sun Nov 24 12:54:06 2024 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2089.outbound.protection.outlook.com [40.107.96.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D439E13C80E; Tue, 5 Nov 2024 15:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820839; cv=fail; b=cJRXgwcooCVAb+xukJaM+87ETDkIXG0MsKWy7S0mdkzQzeAD5b1aAPjNbvX+bTNvn3yhfSWK33JuKDfZf4fw+lngio/u7XIUfj9HExT1B8B7s4AZPrZAG+0bgZED20F2+A/1xAvPHTo6JI9PYH25+0YLP5qbs8KcGYo/Pm+FCco= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730820839; c=relaxed/simple; bh=h7UuvL7RUVev5uvHZ1pWhoJtMToiKFMIm87x4l/APr0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u9GUdiYSnZrgRuqprXMAh0xuEMEOywm8mObMy5qi/QfW6DaOVOAV2HS0jd4lFDzrR2Bs9PPHNhmv9LIdgDuGEj7g7BtXyYN/VIpWnMOLRTLnTxbD+QKKXXEBbzEXBZyvdx5xjxYM4xiVG58ekQl+Zr3V4+CI6aFCRmSvRLK7rFU= 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=SzZ8RUfy; arc=fail smtp.client-ip=40.107.96.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="SzZ8RUfy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j5ernT2hQbdDpwlairVTdve6Bk17pimXLIRzSvdXbYsJH/m1NFVlu8oNjFrTLgNuyqLsSH0IlIKJpGPO6GlYHjHrcvJK2zpPIs/iwMc7Jalo+UJKOWLgaIfacoKj0sY8IxndKROq1kbrgtCFC3qj+UIJjT8o79VlRhdv0T6ZoUgOhsG7HaOISvAtiE0nMVi8GiY227NjgKdTihqSTQC++yplYGh78Fy2WDNQ1KixZqHoweynlFducbIJ0g1WVxF2Lo1RELanHJ+ITBaV8fUl+nryJR/bhT9Nwg9Cv38Mts7Y5u2MopdFW+Ir84+SNuzDuqbCBJLkPjAnCJnEMEHbDA== 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=gBtBAl+R8h1wq1/q1GN+IGXuNYZqj8oUNSJT/F+/2mo=; b=KcCkkNbv7PJ8R1obLEZonVVoVkNDVIkBZiJDh1l9l8/jZCbq/H+VfCzon6fiNK1nvu+gyFeUJYLJDffIthgD8RJ7NXu/Dm482LjGouQzfYICxp4ZzcF/W/RF3hAY1T3CwKC66ag+k2yiBZCWr72f550/jHT5SexsxK3FnYkBGOsr2SIhqFSroRRYo3SK2h6k2PNUizUPcd40etU+YH6nE2Sa2MJ0sXBzgZyxVXMKbhawWBc0jq2qM3Sj0J3XmlNsN5h0GEId3CQC5Jo4T8OuM9m6DSqzy0c8lTDOlkt3mPErlwuXfs9KTgoXgPPIySS7t/RB4JMP3bQFokh07C0qcQ== 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=gBtBAl+R8h1wq1/q1GN+IGXuNYZqj8oUNSJT/F+/2mo=; b=SzZ8RUfyhfewU6Z7l/kehJWdTG5KbgzRZ5ziIBcAU+VxLh5tXiwbZGj5YTtP7RTDO1TdpQCYbEgYAq+4R9JCfu3HPyYhF1o5GMWflRXM01eGV+/vjGPxE4F7KtWGUb2AEWD3NGLD9MHTSEMy98Bb7HevNLyJhOfXWP/sQBEqXe0= Received: from MN0PR04CA0007.namprd04.prod.outlook.com (2603:10b6:208:52d::12) by DM4PR12MB7504.namprd12.prod.outlook.com (2603:10b6:8:110::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31; Tue, 5 Nov 2024 15:33:50 +0000 Received: from BN2PEPF000055DF.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::a1) by MN0PR04CA0007.outlook.office365.com (2603:10b6:208:52d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.31 via Frontend Transport; Tue, 5 Nov 2024 15:33:50 +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 BN2PEPF000055DF.mail.protection.outlook.com (10.167.245.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.0 via Frontend Transport; Tue, 5 Nov 2024 15:33:50 +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; Tue, 5 Nov 2024 09:33:48 -0600 From: Mario Limonciello To: Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v4 20/20] Documentation: Add documentation about class interface for platform profiles Date: Tue, 5 Nov 2024 09:33:16 -0600 Message-ID: <20241105153316.378-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241105153316.378-1-mario.limonciello@amd.com> References: <20241105153316.378-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: 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: BN2PEPF000055DF:EE_|DM4PR12MB7504:EE_ X-MS-Office365-Filtering-Correlation-Id: 0990ddf7-7dab-47e6-a076-08dcfdaf3f38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wagLuZn1eNsKJwQz06Tn86jKXML0XK7wQOljQiiGeP8Ix/qul8kt7oR1dGU8?= =?us-ascii?Q?Nhuc8MQB6ZnskbzU0gRPn/reDzr77XDzRM3XTNTMZ1hvmmd0+e3rui/NB74x?= =?us-ascii?Q?REZVTir8PLjxHIlW89l0+BPnhxWcbWtbash65mwV2GOJG7BUUGvW9nMEN06y?= =?us-ascii?Q?AxZ4M5hqGrAVUbrTIZNqmJ0vd/NsiAd/mrGdaKSmEodu2aZjg8hFnwq0ReSi?= =?us-ascii?Q?1bVNAsiAj1AEubdE3aO27P1jToBmQCdwx5FsZH8D9VAocZtQmeSUWjxSb8/X?= =?us-ascii?Q?rHoZqXhNq7stgGyeHcvHMKe/LgSeOiNOO3TwKC56kQbpqEMP1EGwvl92ZJuu?= =?us-ascii?Q?OdbuVYwLbjltZQNwsY2JQ2pQ8l6DFpol0JccBUCpeyi/ODuj9vDb+3EFZe44?= =?us-ascii?Q?RaylsupCgmCAgPnaa6mOH9drX7aAFLoOZwGlnFgoW6p64NGvBELX1Z+QzNL9?= =?us-ascii?Q?sOz0/sHbkucV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ascii?Q?uQGdjPOgEM1w3PX/MXsSrbOQAiR3BDYTAegjxDvNjmiyfYQ8Iw=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)(1800799024)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 15:33:50.0922 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0990ddf7-7dab-47e6-a076-08dcfdaf3f38 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: BN2PEPF000055DF.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7504 Content-Type: text/plain; charset="utf-8" The class interface allows changing multiple platform profiles on a system to different values. The semantics of it are similar to the legacy interface. Signed-off-by: Mario Limonciello Tested-by: Mark Pearson --- .../userspace-api/sysfs-platform_profile.rst | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Docum= entation/userspace-api/sysfs-platform_profile.rst index 4fccde2e45639..418c61b096304 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 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +When multiple drivers on a system advertise a platform profile handler, the +platform profile handler core will only advertise the profiles that are +commong 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 t= he +same system. If the selected profile by individual drivers differes 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. --=20 2.43.0