From nobody Sat Nov 23 22:48:04 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060.outbound.protection.outlook.com [40.107.92.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 190661CF295; Tue, 19 Nov 2024 17:21:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036867; cv=fail; b=YTXoqfJe7Qmn9Hnijr4lXDuibKqKdmxw3wSfjZvJaT46S6IJbRmzVDxUZlUb354EBZ3K3Dt9eYJdc+qn57PiZyzuGsl967YT/Q3XfLLUvgYZhDiusHrCLKER7e2wxVqz/DhuPIHmKCnEDfS9ghuNbs4YO/7ADBNXne30kRouHIQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036867; c=relaxed/simple; bh=4acWOBTgKXkQXKJ2F6QknLiWxVdZF5ne9UoVI1gHNM4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qg5PFMIJ8x5oqLoqilsTKnKKq/DLTZeYUYyN2H7Vm7TBQDqeqrlnf3+7H20vc3q/4AscP8nQQg3ewvUfHxYUJsKlS76/Cny4Md3ZhvJmBDD5f1y2ZQvwd39XIAlrwigBtkY2Dnq9CmdZb66ZL5IX3v7A5nrur3h6LSCtMEds6T8= 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=Pej4slrF; arc=fail smtp.client-ip=40.107.92.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Pej4slrF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Mww5h4w90RZwvp9TiMEuLq9dg7pQ5B/iXG4C+mtp80/KZ2/sPC4XXDce09g63fWLJ6j/y9266jIsgUaDMkALjwlfjzLbDJ9dR41tVl92gp8t5r5m0fV6fMo8dgBXdlltpDEJZgSsIkmakTsnK+FCexszKQkIZsTNA2vk2+qOcEAS2MtbgisjgTkBafh5vIBIXReshJJEjTqtLgsf4y4EHF0BL8adBJCizCYbcfhQ1JVKrYVrtTYSGdmIOEfaHBADQCZRQu4moaH42K08oQgX7YeQn+ZL2By8NmB8tlDKNEJjwGI7wxu896erX5XeErUSL2HDxYzjQo5BaNoaGHPNbA== 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=Su0YGzELm9tFqAipf3MGeeTvz0dxYZurd0guxOY8Ulo=; b=nI2zXOCoZSVrGWT95k14GuEnjJt9VaOK2MdAKOrvteoekdeOSbcnssy8wD/1brsF3+TqHazbBL8o1L9J1hzv2zpIfIpSvpVOs1FyxuXCnIdDwYrXqcq1tRtF/lNGTV7ONCtIFZgP6ElVH7HGXpMDl/CkVdwy/ejAH8gSiUVPacg/bg6aIqiQy9m6fQdi3J1fWZIzDrkFMKf/HbWZVT5qFJjygd0SWiTTEZfB6b6dPe3XbvdjUzJ1Tze51xtNWFooqIO7z2l5qJ25VWMdVrIftdtG0fyXl9LjVopNRfGj8iNuf01/HCddtPZFGWu9ODIzTJTzVHTATt41a0MMJg2rxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=Su0YGzELm9tFqAipf3MGeeTvz0dxYZurd0guxOY8Ulo=; b=Pej4slrF05r2B3F3ePkzy7uhyBsS5dPTlmJSijtSUlczlfcjTvd4xS0lL7vBIo+5XJkOThTZzOuygsRfiZK06pBuo2wOIm1jAJmJrPRFnt70CSqNISyF3uoInG9SXC5MEDIDq7okUJ4/FIQOiuuEp4Jp1itmNw5TcOolYAXVdCo= Received: from CY5PR15CA0257.namprd15.prod.outlook.com (2603:10b6:930:66::21) by MW4PR12MB6874.namprd12.prod.outlook.com (2603:10b6:303:20b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:00 +0000 Received: from CY4PEPF0000EDD1.namprd03.prod.outlook.com (2603:10b6:930:66:cafe::9c) by CY5PR15CA0257.outlook.office365.com (2603:10b6:930:66::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD1.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:00 +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, 19 Nov 2024 11:20:57 -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 , Armin Wolf Subject: [PATCH v7 01/22] ACPI: platform-profile: Add a name member to handlers Date: Tue, 19 Nov 2024 11:17:18 -0600 Message-ID: <20241119171739.77028-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD1:EE_|MW4PR12MB6874:EE_ X-MS-Office365-Filtering-Correlation-Id: 358bc359-8a5d-451e-d154-08dd08be89a9 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: =?utf-8?B?SlJpNDM5bE5kdDMxMEt6RlljbjZUakpENTlZcnVvWlF2R1haU2dxeS9SbDVV?= =?utf-8?B?bXYxdVY2NFFzdTk3Y2RacEVBZ2d0NEdMSG9CMjNSTEduSHBHcXkySTQ5N2Uz?= =?utf-8?B?NnU5SS9oZWt2SDYwNDJVR2wxNERRQkpjUDhWQWRLV0xVR1krYk5NNjdzQkVm?= =?utf-8?B?Y1FybkdERkhpSncyUnBRKys2V3NqWE5SblVJdkE3SU5vS2VLYjh4NTR3NFZj?= =?utf-8?B?Wk01L3lOYW05N3ZxNjJEc3JyOUU1MU1JNEduWEIzaUdhdWxYK1duRVNFQXZ3?= =?utf-8?B?VUpHRnBPVUZIUmpqamsrNFBiL1A3ckdZakgvdEVZTlpaZi9nM0ZOcmhOQ2NS?= =?utf-8?B?STRhMFhTQlZ0Um1IZnYwU2JGbTdFdzl2dHlDUERYZU81enBKdnlGby93KzJP?= =?utf-8?B?cFU0WURuaVZnQlE0KzhuS0k1ZjNWK25GdW5tRis0akRGTnhxRURLcFl5YlR4?= =?utf-8?B?MkRlc3d3TnZjZTc5KzRBWExIM0Z2djdZeHp4M1JvMURKV2xaa2x1bjFZdDJW?= =?utf-8?B?SnBPcndIcFkxa0h6cTB1eFBvcDRTMWhkTmwrNTRaVkMxbkp4a09vT1JzRnR1?= =?utf-8?B?TkhEK1luSmRCWkhZbkFyWUhLTHJVRDZHRTdJcHd0YWZRaGJpRG9FWkZsZzBz?= =?utf-8?B?YU1EVElaMEx2eCtlUVV2SmRGUGtyUGV3TzV6YWpZYklGbkY2dW9BdjNkT25m?= =?utf-8?B?aWtpMTlvOWJieWcyYVNiWExxZ2wwSHBVbFhjNWhjenVIRzJveUdRVVQ5OGk1?= =?utf-8?B?SVBUbWlQOHZuTFFTZkJKczlyMEJQ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3QwbFczTVJKcEt1eEQxQ3ZGWUI1WjlvTFUv?= =?utf-8?B?K29kZG1GcW1HZnViVEpzQ3RwSFA0Zlpzdnk3RFEzdXQ2ZDhIbVNVbWwxQXF3?= =?utf-8?B?UGlwWnJnRFRWb2dkUTZtT0Z0aDUyemhzV3BId3hxcERoMUZwdStwNURCcWZR?= =?utf-8?B?UkQ4WElxZDRKbXJSeTd5Y3BZQTc1Ry9aK1M4dGsrYW01TEE9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:00.1175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 358bc359-8a5d-451e-d154-08dd08be89a9 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6874 In order to prepare for allowing multiple handlers, introduce a name field that can be used to distinguish between different handlers. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * pick up tag --- drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 1 + drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/alienware-wmi.c | 1 + drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 1 + drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 11 insertions(+) diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/= platform/surface/surface_platform_profile.c index 3de864bc66108..61aa488a80eb5 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_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 f15c7ce37b256..c0ed9ffc3913b 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3866,6 +3866,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 77465ed9b449b..f88d898447511 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1156,6 +1156,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); --=20 2.43.0 From nobody Sat Nov 23 22:48:04 2024 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.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 CEA7C1D1E79; Tue, 19 Nov 2024 17:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036870; cv=fail; b=RCF4FGeFQxwgj+wUM0j0vPLxbZpDoH+2qhllsl3fhEILY8O4v58PwJ8wTyHBqUOUriiS0AuC4/1kzC4ppor/+mdClBsMFGcsZ1wrAgWwDNHnRK2VFmXUSrtfQdbOzJFq2fMvk1KcbxyyHDKe+u+Q8RQ4oKdfyRz0A1UkvNLGWAc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036870; c=relaxed/simple; bh=gVOFZQ1NkY8btPf86/D8ZFqsha0+GCMWANbhEBwFGl4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fL3RYe3DJUVxoC2fSDUtyWru39jqZgVc+RS4XGXY8bsrQrArPTLNigCEnNqcbcHhiFdMeZ6WRvHUyFmfm3pI5zbJt6GkjRucy3vCm7JXFYUxN96NLIC8w/N4h/tC5l7V8lS7jzM3vrWbFTc3WeodsZ7DRV+qSoOsZZxL+ObIDXo= 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=E59xm3d6; arc=fail smtp.client-ip=40.107.243.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="E59xm3d6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fRaE5fEaI5G8Uf4IOPcJP33HFq6+6Mtt1RkK5UWLfiOA3nNO80SAYKjEdwBqu71IQjF9tqc1gjE9TekpcE1Jb12Ybz6Gbq3W9bVM4AeqBg18hty3XAPhK9ElGqNjyMWgNg70i92CXmqLK+TjHBfCBkcXRusnbacWFIZ0fNVg8qGNQcu+OUowfNSkBAInwH1uiQ294LmuKy9FJp4pSCluNJbfVIKi+mZ1L366u7dX+r0vXG18o5nCsncBD77qW7BBZ8uTE54sXwkkFs4wVMNo9v8dmDXi9OJjEDgvtM7iM6N13lwCJ2IeAOP7ev8DBQjIBLUOJ+0je5u96e+mtsRcHw== 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=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=kkqipRyXGiCgLdcAQTvutvs2K5Wb52weCnsGqsOektUs6B7d4DWyhfohQHTZUppz0uQnppd890gJzdJP6eWTmq1/3UU264BeLZROhO8wI5OjIgsFxyXps8VZLA4zcyvnGOClKjLYIwCAreLcuuvz0E8TnIHJAu4EB/QOPZGTeWIhcBdTOq3N5xLPqu9QOF/iKie98Q7ACgdHZRDNj00O/+OmjwXPPEsPGi2+B556hINgZQPWUZw5F+btomsuOvFc99qukIsgGbmjEvki+bvt/KXfT1kI2tK84aGRfo+qnycPcDgB/TpRCAVgJQl492bPkfcA9vmB026607een5oIcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=Rcake+aW7InzlrriCA9veWw0Iv9E+pdMZvM9w0hzudg=; b=E59xm3d6xDoyojZQCFMUfz8/heJvf1H26odjeB4IwT6zq4LQy5uzQuVNGm7ul9AA+ujDjDdUW5LvbkRBoj9j6sv1749yV+nhRKC2i8h9ZqlyRHy5UasIuKt4cTlO7cKTt8d4RrbeakUHN8iOnnCK12YqNGkmS7XzdD/j6GIS/Kg= Received: from SJ2PR07CA0008.namprd07.prod.outlook.com (2603:10b6:a03:505::8) by DS7PR12MB6239.namprd12.prod.outlook.com (2603:10b6:8:95::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:02 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::69) by SJ2PR07CA0008.outlook.office365.com (2603:10b6:a03:505::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.25 via Frontend Transport; Tue, 19 Nov 2024 17:21:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:02 +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, 19 Nov 2024 11:20:59 -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 , Armin Wolf Subject: [PATCH v7 02/22] platform/x86/dell: dell-pc: Create platform device Date: Tue, 19 Nov 2024 11:17:19 -0600 Message-ID: <20241119171739.77028-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|DS7PR12MB6239:EE_ X-MS-Office365-Filtering-Correlation-Id: fafd6b68-d250-4506-3513-08dd08be8af9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YmhQYmIwZVN1Ym1sR05NeW40dis3WlFQMHp5WEozWW1VTko2RU1UWkhWeDdX?= =?utf-8?B?VEVGWjI3dEJTQTR3MmU0RVdZWEdwWkU0eUpqRXhxOS9Od1Y1QW9QazdMUmdq?= =?utf-8?B?bWRkZk02SUJxdms2dUp6bmM4TVVQeVNnNk1oRFhhV2JLVUNoMHB0SjN4MHdE?= =?utf-8?B?SnZrVWd2S2t3V0xuOGRpZFpwOW4xMG1RRHQ2UUsyVmJEYXE3NE5DSWYrZ3pY?= =?utf-8?B?TU9UV0o1TWx5UFJqUWJWZG82ZmRac052bmVMUjQ1NWViRWdYbXdOWWlvZ0NG?= =?utf-8?B?eVp3clBBd1pFeWNKMlo2UFVYY0lrWWhPaVQwWHNzUnAyY1pUelQzOWlwUzlY?= =?utf-8?B?VkU4eTBiaGR6VmhsUE9ESnp3cHhiYlgzK1VZcHZ6dG1YZWdjV2hMdFlPRGlE?= =?utf-8?B?eGh3L0pqK3hkSWdmd1hVZmJMZjJrODdSZ0RwWXA3WFRRS3FCR0I4VHl6bGVk?= =?utf-8?B?M2FCcXFQUnk5czB4VTlFbnZRMDY5djBwOXI2UjFOWW9hNFVuL3RDTjA0QXdN?= =?utf-8?B?djU0VFFySGJGYkNyZG90cUJjQ1ZhRkY2NzBGd2FZdnNrOGFMelpVdTl4eTNx?= =?utf-8?B?QThqWFVtcHZwSXBCOUVyZXYwSTBNdlREK1NwY1ZTMWlrdGYzdkthZ211bHk4?= =?utf-8?B?dGNGSnlhaE1VazRLb2hYUlI3djVFbStIT1R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SEpOM1k5TXUvNXZRYXNyREVBNWFkb1BEaXNQQUlZdEQxeExDOEdWdEZp?= =?utf-8?B?MEk2cnJsM00zdW9hR3hDWFlJeUs4bkdLaU9KU1Yxek5RSU16eEU2ekNLNHFG?= =?utf-8?B?V1ozZWRxMGx5NDU2dFNESDlRSWttdEs4b21VVlRRRkQ1NnRQYVFFVGZ1OUFi?= =?utf-8?B?WjdTUGc4Sm8xaTN0R3A2T2tsMUdLMEo0eFByTHZGd2ZYVElBWDdYOFFJWlMw?= =?utf-8?B?c2tJVnZ0MUtUam95L0J2SWNpTVdOTXBMaVpQQ0Z5bUdkUjA2cUJ3ekppeTNX?= =?utf-8?B?VDZvMHhDVlRNdkhxeXN6QldXekxWQ3ZBaG1ZeXVGWTN2L3c9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:02.3156 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fafd6b68-d250-4506-3513-08dd08be8af9 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6239 In order to have a device for the platform profile core to reference create a platform device for dell-pc. While doing this change the memory allocation for the thermal handler to be device managed to follow the lifecycle of that device. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- v6: * Use PLATFORM_DEVID_NONE (Armin) v5: * use platform_device_register_simple() --- drivers/platform/x86/dell/dell-pc.c | 32 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/del= l/dell-pc.c index 3cf79e55e3129..805497e44b3a5 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,15 @@ 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_register_simple("dell-pc", PLATFORM_D= EVID_NONE, NULL, 0); + if (!platform_device) return -ENOMEM; + + 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 +271,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_unregister(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 Sat Nov 23 22:48:04 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2088.outbound.protection.outlook.com [40.107.223.88]) (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 817571D26F9; Tue, 19 Nov 2024 17:21:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036873; cv=fail; b=EpnLgkhfCSAZtCBCrf4n2zDBqgF0ri5hX10ildfXW3q5kmmeadiqXJp/EPcLCTGyEsIn2eqk0h3whCEDYRIZXVR/I8Li8zXfw+oa5SOljGZCqUTD9Ab6jNvI7pps2YV/vXDiHKFcit7UGlkyMvIz7h/WDoYngREtfjVh2b/1sQU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036873; c=relaxed/simple; bh=tJ4DVdV7cYXpMcLZGQ2X1sYu4uUhOwjck0xtfjKy1Tw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H72K2V7Z21gha7nv1i97xumt2hPHIj6x72Q4Ei2F12x/yYE+vjzWvhSjh3PH4GDNXS6ASHOMeOxgANMmYjO2kw2nrGXOTmvlc4jvfOqXI4oeSEEWZtv5DFbAZwFMKqERO6EYshpF0tvnZAyYufDJ5NQUnBE3ftg7H6jv7JqRlW4= 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=VojsyqSA; arc=fail smtp.client-ip=40.107.223.88 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="VojsyqSA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eDlmVAt0lzqGj4HtHEo0+BlJGPvh5Bm/Ga0gqkwolZw0+hH7LWhcJ3n+QwFvpGlkR/DHk0pYbqzBvzF2RgGtbAaf7wAv3Lg6GLJMA1W0RZRtRXYZQVoaMsg1aI9eLLZGHtifEeniHFL2ZC1kgWwT/5f3Y9m/aPpOOoFakRW2YNtFlNSNvch4+T2VMWjZqP1M/+zeT4hiGUwGIWLEx319WkIo3n8HStnPgpWykUI16kmny2PGmOCk65Qe85/OuClECt7jEu/9vYmF+iw9m0c64X9RBg5mIhFNCNcmkesh1ov6OtKwHragUCU3TB4wKPwXOjOUwphkbUJi+1Gd3L7VYQ== 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=DxHNLh8X+PGIiA3w7kI8/pf3Usx2TD2JwkiwHrhZM6g=; b=kmgRT8O0vgVQ3zYYpVYjdRYrP2rYJVts49C1a2y17aun702W6G9ffDLTERR08p00YxLgHhxGmZcDCuHnbAyDf/Unu/uEwQ8MwSiiX+yvy0ipMfglhQWVQenEFdnmHR0E091H2P5byZ50mGMECUYhBC0aCWPwP2oWDtN2N7EQx3iv+IQfg+y3otzdIpas3I5RGVYvF56QLt3TJdYWxq052fIWvV9badTvsc2xSgW9jZsf9hNnnT3ZKD7zIg8xOub2TClWTntywEALbpnFdNA9c5lFuXB11MvYwNyp82EWFfW416hdVxxybO8aQqjruBtQrS50xhZrxbMLWKjVebE0Hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=DxHNLh8X+PGIiA3w7kI8/pf3Usx2TD2JwkiwHrhZM6g=; b=VojsyqSAqUj+KnzjrHxxwsWnKoHCzVVJOxaHi99SIoOFMS8TObLNUxZ7rFyt9Bh5fSw0Eo38vgZ1aXPrLhHw/FbjvMhgFSXC7XfIlrfbryXf5wEu28zTEuEFjZ2bNeuMNWrCQPX3/C25kO/8CvG18eSwDLyM8Ydn2tsSMQnr7D4= Received: from SJ2PR07CA0023.namprd07.prod.outlook.com (2603:10b6:a03:505::9) by MN0PR12MB6128.namprd12.prod.outlook.com (2603:10b6:208:3c4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:05 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::64) by SJ2PR07CA0023.outlook.office365.com (2603:10b6:a03:505::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:04 +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, 19 Nov 2024 11:21:01 -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 , Armin Wolf Subject: [PATCH v7 03/22] ACPI: platform_profile: Add device pointer into platform profile handler Date: Tue, 19 Nov 2024 11:17:20 -0600 Message-ID: <20241119171739.77028-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|MN0PR12MB6128:EE_ X-MS-Office365-Filtering-Correlation-Id: e5c52dd9-1a41-497a-114e-08dd08be8c5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NHpnc01mVGZqRVNNRGtDeGwrSXBESE1uRTkwVnYxa3ppM1hYNEw3ODQ0RFZG?= =?utf-8?B?WURqOWtrZHVMRmZ0RjBINnkrM3ZPMCtOYzFiZXNVZWR6Tis5ZWlkbHFWMHhR?= =?utf-8?B?Uko2UGlZK1ZlOWdLUVZtb2kvRjNBdVl3Y3p3bVl0NytzTVY3SnpvTEtHY0F1?= =?utf-8?B?Z3VhbGcrdUhKRWVpYWFaVWJLQWtvQW4xSWtwQSs0T1VVbkJWMHdXKzk5RHM0?= =?utf-8?B?bGxJbzBNWU9SMDNha1g2WU5LSWdoTE1PcWFZOVhuZ0NoaS9IMjZpMDhCbWZs?= =?utf-8?B?R0U3V0JyeDdZUk5yRmwvOXRpcmtHT1JqOHUxRU5GZndheUg1cVNOMW43c1RS?= =?utf-8?B?ZWUyRUJiTmRWSnVJb1BibzgvbnZ2WlhOZ0Q2bUJkSnBLSkNoN0MzWDlWU25G?= =?utf-8?B?QkthcHFQa0tNN0xCaFJMM2RuWVF6R24zS0I2SW55UE5mb1pVQU8xVjY4VHh4?= =?utf-8?B?NU9hb2FaK2diaVl0ejBaYzljNXlTVjEzc0RhNUowQmtoYnNQUVJ5eEMxUElu?= =?utf-8?B?bTR3T3JWWHFrVDZOeHBCWWlNQk5qUHlzK2J1ZzR1Y2lWUm00aXFhc0Q2RGlC?= =?utf-8?B?dXdJUHVPNVk3aXMrL3MwZk5ROEU4L213Nkg0ZEV2K0QzbEc1TUFUQVpEalJm?= =?utf-8?B?NytaUXk4ekJoanIxc3R6MW5WRm5lRkFEYzRSelAyY2Fta1FTQXg4WG5yOC9P?= =?utf-8?B?ekdSL0dOd0VTcjRNaytrVThvcGFCdmhOc0lWNUlu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lhSanpSUXB3Q2RsVVJKeFc1Q3R2VGkvVXlX?= =?utf-8?B?ekFtVS92ZzVtZmtYTTF1S29YZVNUTy9qdzdVKzZOY0s0R2hCdW14Q3ZPbExI?= =?utf-8?B?MFBGUzFadjFkWVBCUkRTRjh5eGxTb0dWT3h6di94MzdWdUVldlNERUF4cDJB?= =?utf-8?B?U1Q4VTlQWGlEdWdTTkNHbDBtRW5SSFFjVHRmOVRSRi9PVmR1WkIvTm1LaFMy?= =?utf-8?B?cTlxdnhvVnkzVFBBL0REOWJVL1RYNTlvT1cza3NjNTFDNGc9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:04.6124 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5c52dd9-1a41-497a-114e-08dd08be8c5a 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6128 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: Armin Wolf Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Maximilian Luz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v7: * Add Armin's tag v6: * Don't require to be set v4: * add alienware-wmi too --- 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 + 11 files changed, 17 insertions(+), 6 deletions(-) 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 c0ed9ffc3913b..c15fccf5131af 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3867,6 +3867,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 f88d898447511..78aac76132788 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1108,7 +1108,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; u8 sys_desc[4]; @@ -1157,6 +1157,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); } @@ -1225,7 +1226,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 805497e44b3a5..e5724e76a2082 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -257,6 +257,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 Sat Nov 23 22:48:04 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2055.outbound.protection.outlook.com [40.107.93.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 203941CF7C1; Tue, 19 Nov 2024 17:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; cv=fail; b=p57k7rWzxMjSURn5PRcCLTBwma3g0dNqYb/+OZVpXXWmvMVZM815KxNFKolLSwaJ1P4AO1HY4qgfILsFliONXP6miWh4QWdILThdHTVadYWhFflGgKLTIdgEaC3EAzfQFe4ut3nWwah11RzP7poCslhgsoQXNUUcv5ncnH5+He0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; c=relaxed/simple; bh=vwvkuCF6TUIm5sAd8pAAU03EmVf6teWL+lnPU/6KHg4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K+uiwIyuYzDaNMaWGDos1xTEQ2isuP10/pKo9+1JjQQXx2fuoEkqTFYCodalFW0+P75/n336ADnsXxZjsHq+Ch9k1do92iJOpHlacjB5IeD2pOdkUnuhWdeENeHA6kwNtdecizyNVkEe0yViUOOdOAaKV1oRv4VVYZ2qljZXgc0= 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=nkpUuvU3; arc=fail smtp.client-ip=40.107.93.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="nkpUuvU3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=srrFMrOqPaeVWp5glqZ8kBNr+VFg2UhF/XvvxacZlERVySrJuUSzegr439rREJbUOy0bqtznGb3qBc8e/DUdScarEjqQ+NHvAp+jCu30foPNUHa2Muccuf4PXnWMd8hPXVHl4xUihsLxetQQTnk3UokF4ajy+G1QDSccn0cxOWOpC/pO5Tuq0Rksodcv5QMWNEWz7qaHGMO+AdSi09Jmm4+NfEU/yATN1wLLAiyPleiRdLAVkgPmO4KrrzyiMPcWSObym0lfZk1bZ8v02r8rXpKVhQOuExkzM4DyViC7mhwU4QKx5Pfl3yMy/7G3QLijQIR5cC//sUmyNOEGGggnWA== 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=OehAyRoZjLR3a5hc5eWpv7UNPEKV6B1j4xI56uoKf0c=; b=X5zHp3W7IpzCuse6CP165r99P81n9YtFn60+3oQ5WNDg3E/Taoq9jT25FrpluXPN31fLt1Xa/8uefHdabzpxdpccaStSKbEogOxEVS3BSj03T0jzu//Fu1dPrBMHpuuji/OkjnZ+s+FEZuDvt+tlQGivowJg24Ilz8l/9Hbh++ZEySlitLZr54hOaApVDM5gCVZiT6j+fAbothLprSWV7SztvBH6lcei7NK1kjvh/5X3tXDK5h6tF0JaLkL1TC5sGZrqgOIbkhRtT6TFKAJ9AVX+PkJJ1Juy+cRDv33FqO0z+MIYjH2fKAU2dpCBwskCgKlMqk8MpJSdEJFYZratzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=OehAyRoZjLR3a5hc5eWpv7UNPEKV6B1j4xI56uoKf0c=; b=nkpUuvU3seWwlgItY85QqU7dZrwI8yixAUI5flcm4zLKYUOP8//nacz7Xgv8R6z/GNGJ530OOn7IRv0EE9vKEGVhorYRkbOIh6LeGIk7V8J7/eZu71aaFN4JGt1j4Xoidq8VJ1pgj0I7sqfQhkmw2B9CxxfUWQa1em0lRoXFTi4= Received: from SJ2PR07CA0022.namprd07.prod.outlook.com (2603:10b6:a03:505::24) by DS7PR12MB5719.namprd12.prod.outlook.com (2603:10b6:8:72::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:08 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::40) by SJ2PR07CA0022.outlook.office365.com (2603:10b6:a03:505::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:07 +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, 19 Nov 2024 11:21:03 -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 , Armin Wolf Subject: [PATCH v7 04/22] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Date: Tue, 19 Nov 2024 11:17:21 -0600 Message-ID: <20241119171739.77028-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|DS7PR12MB5719:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c2ba382-6e14-4de4-2329-08dd08be8e32 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: =?utf-8?B?NGRBcWxBMEE0U21QOW9IbkZ5V09takREb1IvcVJHSE5mZnIyS1VNa2tJL2ww?= =?utf-8?B?Mi9UL2VETmRuc01kT0oyTnlpYmU5RmpOaHVyR0pnWmpyd3lKSklaa0lmRkxy?= =?utf-8?B?NXZac3oxZ1IwVlZ1dmc2eDlMWVdrMlZrc0pVSFByRjBHNy8vc2lXU3RybkpT?= =?utf-8?B?ZHI0Ymd0b09MT3VaMS9hWFJycjREejFmRklaOFF4bEEzV3BCYzh4YUU0L1pF?= =?utf-8?B?bXRCekRSaThvTCt4Y2xuNFlzcDZ2czkrSkErYWhDS0tERXlHY21kRncxSVUz?= =?utf-8?B?TEd5VjdyZ001YjhWWmlkbGtUQlg3aCs4NnJFRHF0V2ttZU92M2RJUjdTSlJD?= =?utf-8?B?R085NTVHcjFLSEdFMnhMTGZKaTFybWJJcEpOamgraGtFZUNPN2V3ZmlEd0lP?= =?utf-8?B?bHNkZkVhaUc1azFXS2h1ckMyYi90NkpiaDBDcnRBS3JxZzQwaDlxbmtxU29E?= =?utf-8?B?TlNhZVh4WUdYaThxRmFJdmFXOUdJYnByTkZIU0xwS1g4OUZGeWFpY1JDMThi?= =?utf-8?B?N0xaQVNPOVVhbk9YbjErYm1hT3MydWFBNjl2K1ZzSGk2WVk2d1pQckZzU1lD?= =?utf-8?B?ZjJXam03bGxzTnFDNDgxNEpZTHc0RUNjVDVTZEd2TjVNYm9YRVZNejZjOHFq?= =?utf-8?B?L1R3ajlYZEhLL2pkYUJVbHlWb2VTWlJUYVZabHpZWGU3QWQ5NFJUc1I2ZmlD?= =?utf-8?B?bjM1U2E4S0pBNnFmMjlNM3d3ejlFSmZyRlRlMUZsZGFGUU5vNWtEOWlielJQ?= =?utf-8?B?aWsvcUFwYlg0cyt4d1JQTWZjRlpCU05KRFFEWU9pblpNVWxQK2R1OTIyc3dG?= =?utf-8?B?Q3ZJKzVDbjM0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8?B?VlBOWngzUzhldWJaTHJuanhYb04ydW5sNUZwU3RwZmwvaWFlbEVNY09ia3Ns?= =?utf-8?B?a2tTUXRMM1dpc09WdXRjWURIY0tvSjFySUhGTTBiZGlSMklYdVBTcDc1VWFV?= =?utf-8?B?a20ydk9zTDRxQ3ZoY0RUaGQzeFp0ZS83N3lXRE5EYlAwdHc9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:07.7062 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c2ba382-6e14-4de4-2329-08dd08be8e32 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5719 To allow registering and unregistering multiple platform handlers calls to platform_profile_remove() will need to know which handler is to be removed. Add an argument for this. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Maximilian Luz Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag v4: * Add alienware-wmi too --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/surface/surface_platform_profile.c | 6 +++++- drivers/platform/x86/acer-wmi.c | 4 ++-- drivers/platform/x86/amd/pmf/sps.c | 2 +- drivers/platform/x86/asus-wmi.c | 4 ++-- drivers/platform/x86/dell/alienware-wmi.c | 2 +- drivers/platform/x86/dell/dell-pc.c | 2 +- drivers/platform/x86/hp/hp-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/inspur_platform_profile.c | 5 ++++- drivers/platform/x86/thinkpad_acpi.c | 2 +- include/linux/platform_profile.h | 2 +- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index d2f7fd7743a13..c24744da20916 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -205,7 +205,7 @@ int platform_profile_register(struct platform_profile_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 c15fccf5131af..9105b456eab1f 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4842,7 +4842,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); @@ -4869,7 +4869,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 78aac76132788..e95d22c7b60cd 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -1165,7 +1165,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 e5724e76a2082..5c4d48e4b667a 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -289,7 +289,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 Sat Nov 23 22:48:04 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2067.outbound.protection.outlook.com [40.107.92.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 350BC1CF295; Tue, 19 Nov 2024 17:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036875; cv=fail; b=opOtR5tAjI3bL5t88Rg3y47Tq2ivLPNITctEFTIhX49BusppU7E7Atbrd5PmMuJgUvPpYTkur5Nva5+ZTB+XL56kwkLzOPy6MJVDMDGi9nETVgDYOfIph2jLhr8lW52rhLEXD5ko2lR6fvtEXuyHX/CDxVueTGUYg5ixw9MzpT8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036875; c=relaxed/simple; bh=JPe2DJsTvwK+BxZZsMEmNji+XZXD4uKA1ctPwvtUOf0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ya/winkQa577nSVTeMhGlLEoy32xi2nrXkLBYZw4o6aEyX5355c6qSd8UviXml88aJPXaLYGFbG4q0JtLnu7spvtI9PbS9nzL/tkdV2scfQTJzduWqt4w2yiFcxrQ0TVF6stKvx2EmRNqR1NE1BCUsxd+1nOyBZF/Ihp5NYx614= 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=khN3K3JO; arc=fail smtp.client-ip=40.107.92.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="khN3K3JO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ocUyvG9b/mDzGCwEU1WnX5OnEO0UgknzSXw9QEKpkLV+MpagNytxa6C9QaxYKqm5GQpwCi4v0MEpm2xl5dS1hRkKtJZo6k9qcpq/P7KSlHDoBKGMasuUchxboaD5zNOHIGsHqaIJEMd+R67kA3DRcDzeZYtmCgDJ/0XryP2JcvMyyWVt6TW3WqS63MAWHaiwGsecCKosXS8cOqyYkjcfSyBfQ+xPTren64EyWvSjsVRzHTG74BYPS8IKQrB542aKXo4F9Z+0VxLfK8zYuz2MKR7jHeHIGzgRq4KwFSivfefxrQ5reeB7jV904hMm1lT9sz/VtszVC+9gwVTxlhhhwA== 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=zzCFVbPZgYxPcQ1+GhB7cobM6gVHm22OUaAGLwiiReU=; b=BkDAYvRiBY7JyUaIx60tIpmvv73epvM17nESHdmN57kjOqzV8itPO61ssRsCj+8Fiuqa1U6yfPrR64BcoZWpBFSIjL0i1DTdFmJuuHsJPsserp+0iexMIgUMoOzbQjo5k8eROL1QFLs470KX8mPRxPLJ2q4ipI+ima5JqaSFeFuXLQw7b17ZBZjMzju79Ww6HQp3Xap64+T3BEg5EBWVcSDAMXLLr38xkcvDBQ9zBdExxA7dCjAVDgdkcb1ktSLCvj/Jc9yOf8Bwd60OMtmPCR7o4Kshuf/thm+tHhy4T5yIHhrCCurXGveJTAZON1nw+pCScWRy4IoO06VmDer2fQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=zzCFVbPZgYxPcQ1+GhB7cobM6gVHm22OUaAGLwiiReU=; b=khN3K3JOkcDQMw58erNZm0NgzHVxfbIvtfp/q/3cRnPG4n5umGgUBf1BTMOrxZbmdpqaEBjv0ep8fhF6Ggkdu+oABGU3RzmW5QYwW1Ha0JgdKXUd0Q3OafckV6/Xzevf+PHmNZXCqk4do3qLPD/f/SUxQxYRDXJ1QigpY6UPIjQ= Received: from PH7PR17CA0047.namprd17.prod.outlook.com (2603:10b6:510:323::29) by PH8PR12MB7374.namprd12.prod.outlook.com (2603:10b6:510:216::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:10 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::27) by PH7PR17CA0047.outlook.office365.com (2603:10b6:510:323::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:09 +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, 19 Nov 2024 11:21:04 -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 , Armin Wolf Subject: [PATCH v7 05/22] ACPI: platform_profile: Pass the profile handler into platform_profile_notify() Date: Tue, 19 Nov 2024 11:17:22 -0600 Message-ID: <20241119171739.77028-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|PH8PR12MB7374:EE_ X-MS-Office365-Filtering-Correlation-Id: a5410d8f-e214-4d78-ea3f-08dd08be8f47 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?K1psSYPGuzdJ4PrkKJ70Ax5O5+o0HYtVVv7F1kuIsdm6C+vBAY/8FaVV/U0c?= =?us-ascii?Q?0wRGeAMNINJvuVSLIhHU/wDmrdktUa1TlN8a7Ij367tl0XIg9R/oBUPbH1HD?= =?us-ascii?Q?f9iVp2GOFxH2CqKzo/QvfkwbkyPMBDBPGA/hbvdQWWHamrSwQq1QXzLuX1qB?= =?us-ascii?Q?a/WxlZNBEHcsQn7jhiiW6UqJuoGP4LPDXh6dZPgBKKS99WsVXzvVts0m/NFN?= =?us-ascii?Q?3WMjFHFVidkpdYtu7qqnwIov//dCpSjHZD27IbjcTwM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HvuJ5u6/p+rgrab6nANhA8muFC5xhAQjuYCZFV43Ea0FklEfV?= =?us-ascii?Q?4ZOSIBwZt3nsd5ASZeyIpTjQep0mGQO9UjvGF0fjXOI8dOwCQF1pQDPWCt1Q?= =?us-ascii?Q?effkN9faoxwNeSiEJR+JeLguWbXa3BncPC6bEhwo09xrcs1ksvqIxo2Nk+SH?= =?us-ascii?Q?sS94SENw+aC763etxnvAxBz2G+p+DNcNKho45DhGyuZ9hf4HVI0J2SU9gnwJ?= =?us-ascii?Q?2YKFwT8Q4nWoi23cC/Q3KNWhnvBYUZY+hL0xwYdUyS5kyAn33A=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:09.3548 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5410d8f-e214-4d78-ea3f-08dd08be8f47 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7374 Content-Type: text/plain; charset="utf-8" The profile handler will be used to notify the appropriate class devices. Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- v7: * Rebase on pdx86/for-next for asus-wmi change * Add Armin's tag --- drivers/acpi/platform_profile.c | 2 +- drivers/platform/x86/acer-wmi.c | 2 +- drivers/platform/x86/asus-wmi.c | 2 +- drivers/platform/x86/ideapad-laptop.c | 2 +- drivers/platform/x86/thinkpad_acpi.c | 14 +++++++------- include/linux/platform_profile.h | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index c24744da20916..927a2f7456c9a 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -128,7 +128,7 @@ static const struct attribute_group platform_profile_gr= oup =3D { .attrs =3D platform_profile_attrs }; =20 -void platform_profile_notify(void) +void platform_profile_notify(struct platform_profile_handler *pprof) { if (!cur_profile) return; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wm= i.c index b12965d9fcdb7..0018818258070 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1988,7 +1988,7 @@ static int acer_thermal_profile_change(void) if (tp !=3D ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI) last_non_turbo_profile =3D tp; =20 - platform_profile_notify(); + platform_profile_notify(&platform_profile_handler); } =20 return 0; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 9105b456eab1f..dcda7420ca26c 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3789,7 +3789,7 @@ static ssize_t throttle_thermal_policy_store(struct d= evice *dev, * Ensure that platform_profile updates userspace with the change to ensu= re * that platform_profile and throttle_thermal_policy_mode are in sync. */ - platform_profile_notify(); + platform_profile_notify(&asus->platform_profile_handler); =20 return count; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/i= deapad-laptop.c index 80797c6ae8b0b..79c65c24b433a 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1041,7 +1041,7 @@ static void dytc_profile_refresh(struct ideapad_priva= te *priv) =20 if (profile !=3D priv->dytc->current_profile) { priv->dytc->current_profile =3D profile; - platform_profile_notify(); + platform_profile_notify(&priv->dytc->pprof); } } =20 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/th= inkpad_acpi.c index 13798c6d5fcf3..8539cac042be8 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10516,6 +10516,12 @@ static int dytc_profile_set(struct platform_profil= e_handler *pprof, return err; } =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, +}; + static void dytc_profile_refresh(void) { enum platform_profile_option profile; @@ -10544,16 +10550,10 @@ static void dytc_profile_refresh(void) err =3D convert_dytc_to_profile(funcmode, perfmode, &profile); if (!err && profile !=3D dytc_current_profile) { dytc_current_profile =3D profile; - platform_profile_notify(); + platform_profile_notify(&dytc_profile); } } =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, -}; - static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) { int err, output; diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index bcaf3aa39160f..8ec0b8da56db5 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -39,6 +39,6 @@ struct platform_profile_handler { int platform_profile_register(struct platform_profile_handler *pprof); int platform_profile_remove(struct platform_profile_handler *pprof); int platform_profile_cycle(void); -void platform_profile_notify(void); +void platform_profile_notify(struct platform_profile_handler *pprof); =20 #endif /*_PLATFORM_PROFILE_H_*/ --=20 2.43.0 From nobody Sat Nov 23 22:48:04 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 255131D2708; Tue, 19 Nov 2024 17:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; cv=fail; b=I2CS7hlXA2XadWmrHo1+2Frdxh1qlX3CZlQvhvamr7qnms53q8FkWcqRf6X0gW3S/LzNDcT6192tvMBCkC8nuIaeOKTyXzGNc05vyxnEQU30/NRXOwovtoBBXZzrWuvwtUltwiPMGSPGhBiGpRHc3WUP9j+xJoNRuqQ6olK+zHc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036877; c=relaxed/simple; bh=qxZR0ioXhz7I9mrAT8p2DAj4zP/orxCZ1guCEIlDwcY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Jt56qRUEAnl63xsOCzh+HUWQHopDCNtNsDNZQit93AMD7iZMnhPyK9VsVI6KCiC8u8H0C0XH7NEXHmfD4ZECUh7lzw+rpfQKZtAy8+FulRSZa+iAY6fZAKx22v7zBjzAJXi5nug8ftIXjvIci8n7f3zckDOgyAULc8vLiqk1ASo= 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=uE4qgv67; arc=fail smtp.client-ip=40.107.93.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="uE4qgv67" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W2wylO5jr9tjnFaHHZHHl2IhJHMKm1fO2NG4eJ391VD7qlxQ2W3O6rguP5hHPnPfFy//thiGdYXEPiA+JXz1imW2hMCQefvJQCmpzc8OLrryLFyiTTmCSV8L/vPN8DhV4ELX6I5QDS8LZjFugOoNE46H7aeEwS/a2yst8AdTtBk+rAeYNuvA3eLPMIJ2k9PjO0phnLcaNDaKomZdrwH0b50ulocToP1jsQEX5QO8K8gSMqrn+YXy9YVsHENejC/jbXLrfawJoOM8Tm2VHlpjSrApDbz7zewW2nU/4l1lXT8pDtZ9hpAivVyRnja08qQQhDRk9cIN5wKCMupnzJdPJQ== 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=eb96Rfxdmtyo0JIpdtirBRC/6HMVRjTmHsGHHm4KVnY=; b=EyI3YNO2Z6KchJi9ZGJeNzpv88p44RP6zN41/m9ES4Sbom2gnrweoZbMM72O5cE1pvjdpe9mki90VOZLiVyB1x6bOlo3Po1a2TUjzQByfrHCzUFUBGvOigu1kW6PytIdwkDs//UO1ndjSHq0eT+9CLo1E7puYC2N228HQWnTuHdNvGX7Uocc3saSxgYARrh7LMxLljz28NbAf4LuJeu9mA0EKdjs8U11D3esFvGSECOd/c0mRXHej37mi59JKfY0QJdeRWoAdG9Qx7k5VFmCwRiM2QAGTZUJZDQoGqyQh5SKsPu0l8uuwhO9hWdVbD49RAEI5P6phHLbe6T6iWJYQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=eb96Rfxdmtyo0JIpdtirBRC/6HMVRjTmHsGHHm4KVnY=; b=uE4qgv678V+t+69Pu6mXQnBJ8mG+hyaokDNHf3tSoXVDOQhCd8uukBHt9L1r32/Wbz8CaSX6AAYaKaVdV11RJ6IJpQjqzmyhLMNEoddF5gGrB9ie70boRQ6vnouftuWTrxJu2Xc+uLNl+OYmKIfS19/lJesn6c+j54UgmKlHGuA= Received: from SJ2PR07CA0022.namprd07.prod.outlook.com (2603:10b6:a03:505::24) by BY5PR12MB4065.namprd12.prod.outlook.com (2603:10b6:a03:202::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:11 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::18) by SJ2PR07CA0022.outlook.office365.com (2603:10b6:a03:505::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:10 +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, 19 Nov 2024 11:21:06 -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 , Armin Wolf Subject: [PATCH v7 06/22] ACPI: platform_profile: Move sanity check out of the mutex Date: Tue, 19 Nov 2024 11:17:23 -0600 Message-ID: <20241119171739.77028-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|BY5PR12MB4065:EE_ X-MS-Office365-Filtering-Correlation-Id: 0dd9ec7a-38fa-46a2-fb33-08dd08be8fef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?bVJmT0lUWnAraWllSm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=?utf-8?B?Ny9IV1QwQjVpNmJ0Y05wVjRoaWxhYWtJTEZSc2dDaitFeWEvTGVCeXRSb1ll?= =?utf-8?B?cmtWY2IwQ0MwdWExMCtCdndOYmFiYnEyQWZBZDBPMDlsbXc9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:10.5812 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0dd9ec7a-38fa-46a2-fb33-08dd08be8fef 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4065 The sanity check that the platform handler had choices set doesn't need the mutex taken. Move it to earlier in the registration. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v5: * Add tag --- drivers/acpi/platform_profile.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 927a2f7456c9a..4f5623fc27c09 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,13 @@ int platform_profile_register(struct platform_profile_= handler *pprof) { int err; =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; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { @@ -186,13 +193,6 @@ int platform_profile_register(struct platform_profile_= handler *pprof) return -EEXIST; } =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 Sat Nov 23 22:48:04 2024 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.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 0150A1D2B3C; Tue, 19 Nov 2024 17:21:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036878; cv=fail; b=uERnwgBnXDvkMWXFbWHNxjudG7jzxhkTd906O1/JL8EJ6il7zCXvYOi/Z0DkFUmsGOIiz2xnsW78F0+Aww21O+9WsXRVW2oDZykDXXb+Z4gu/FP1etcOYeqaB5vx+YJ0ICvUnsApYBTgWCmv/lnyUdmIkP90qYnQYznTEYvtG3o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036878; c=relaxed/simple; bh=vmgke1hNgi+9jY2YjBI6Ei/XWu/10vuyZ2DT0pBncCY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=huo83eeQO3AHWkBSCP27DJzAt3/3MOdDD1o7xxjo9JcaBX6ZzLFn0WzzL2OmAzmwEHHcHhPHtwI7g5YrbS1v8KJ6KZM16uveJ6TpcUbbLXoOwmcBFmdmfMmrk8KzPjBAf+nB//D6Ttq9fGHpnjW8V7Eji3MjwHtKUqJtvszGCjM= 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=KUrnSnw5; arc=fail smtp.client-ip=40.107.94.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="KUrnSnw5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qygAIZ7IyCjqHVLXHTp2vHqSrm0dHvMQDwsNBUsh1sr2+UJDrsXSatPZYFhiUM4eXQpgba6tJEEn8eendGBr3kOiKsOcKZcq4hSzZB3YSBLw15ebP9xpBzSMPnXUjuUA4uSejO9IzhQeYCMXNjpSlzkVwi0it4blenIUiNVHR2yZ8Bw623N2/HcBxvQHgzoJ1YLoN/SXoryLONv5p/iOG46FbBLzTM1M84oL1TO3fxCdUnvKt2w2YobLnYCbEY+DcJvI8qwnKPiB4xTFti+24iUIDByPUxZpXBa8u4Ea+a7bzuJuRVuWEViNyRe5cxwrGkL9Z+gmdAEq3ne05ABqTg== 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=2JOepbNXpw+MaowhRv9S0+a5ySr6FY/Rm6BniVYK8xY=; b=ot92jfqwm+3DYOWGD7X2+aazbF4sAnHBdhdrCd1LnyCWzi30jIW/iva3ts3CcoGmt5mugDrK++mX35yabGAGODXvwf9xySNIoSR9ZrKmu5sdhuJ6exYZVJ5Sdssjulm0uknuYQZJArrkzPzmGtoG+ax1qB5rd9PypC22o89MbfFTzRyI8CpXt20zjRjIEe6CxyFrrWD8DBpSpXc7DTmm1mq0cZFPdImBriBFvAv1xSIVvFL9cl3bwY3OcJrUcgQjOg0GRaoMhR7MLAaI0ygmsBO09Pi7sWCA4WiccaTZ02LGeVClz5ZXEt3c+Qt22h3IKnkpqyg36GeoaianF8Er8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=2JOepbNXpw+MaowhRv9S0+a5ySr6FY/Rm6BniVYK8xY=; b=KUrnSnw5SlUZPe7Pzz6Tqvyi7wvFgQUdhtyb4x1IZvcYzKxvhfvpJLzFUwrE/nr9M7GXRjd4JL5+Zg4LJ5NSFA7eSxFueBcAl1w0r3bICW54xcsPUlMjPpVFuarwc/BcysJpqPO8s59Z6NB4F4rQV1fWRiYuzqe4GSOtShzebGg= Received: from PH7PR17CA0048.namprd17.prod.outlook.com (2603:10b6:510:323::11) by PH7PR12MB6908.namprd12.prod.outlook.com (2603:10b6:510:1ba::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:11 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::fd) by PH7PR17CA0048.outlook.office365.com (2603:10b6:510:323::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:11 +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, 19 Nov 2024 11:21:08 -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 , Armin Wolf Subject: [PATCH v7 07/22] ACPI: platform_profile: Move matching string for new profile out of mutex Date: Tue, 19 Nov 2024 11:17:24 -0600 Message-ID: <20241119171739.77028-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|PH7PR12MB6908:EE_ X-MS-Office365-Filtering-Correlation-Id: 69ac4448-5c7f-4907-7cda-08dd08be903d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?bm5RQit3Y3JuVWJZVmYzaUR2SFNJVUlxVFZDNi9LRjJvSTFLbVFtM1JZRThD?= =?utf-8?B?dzNjTW1Xc1dseFpaeE1UZXNVQVB2RzIyNityYXdNcTRzM2E1eHppVzNQM0V4?= =?utf-8?B?bmNSc3VtWDZJWW1vcm9ubzJqWXpUNndCdkFjWGZYUC9sc1N1czczWXE1T2Nk?= =?utf-8?B?TXYzYlFrWkhpZW5HbUhVV1UyYmZJbjllV3B3b1BVZGNWemdvcTdLQWdNdUVR?= =?utf-8?B?UDJNUjltMUE5eTRZYk1iRlozekZQSjduU0RVcVdwMlBzWHZEekpCQ0U2S2E5?= =?utf-8?B?ZEVER1JlODh5bnlQS25wN3VydmlwazlqaXVYSVowZEM3cEhTZlN4WGlPKzUx?= =?utf-8?B?dHhkUUdaSHBJK2dES3BrT2E0NmxEWHRZcmRJVldmVlB2YlZFMkp6TUtlU0ZQ?= =?utf-8?B?NkZVMzJFeW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Y3VHVFFD?= =?utf-8?B?cVBucEdhMUxKWmwyY0U2K2NtYldoV2lpZm9FdzF2NlFlNUJUUmF1ZFp3YUp0?= =?utf-8?B?WDQzMU5FWGFVbmVBU001RWp2ME5kcUFEWHJ5cHpWVUdscjhjYjh1N0Z2UWRN?= =?utf-8?B?NEx2QS9zRkhxVVc1bW5kRmVFQTJ3MzZTTGJMSUU3UVpsRFhza052amtlQVJo?= =?utf-8?B?Z3FycFM1Wk02WW0xdyt4R1VWMmppUGI5eUR4eXdCaWRYS29kNExmbjkraWNz?= =?utf-8?B?WlU0NjJiZzU5T1VpYjlmRG9BZmlRZlNQc0lKKzdtSEZtNnI2QmdEWnRqTnYr?= =?utf-8?B?WTQ0YWZaV0tVcHhtU0NJV3A5dzNGaFBaanBmbm5xckI3N3ZzeWNmYks1bVB5?= =?utf-8?B?K1BIZ3F3SURpOStJMmZzU3J2UWpKK3k4N1Y2TG5wbHZka2oyRGF2bjBQWEZy?= =?utf-8?B?ZzhiRG5aczI4Wk5HUjBpTVFpRWlKSDZXdm9Xait6VmFZWmlqYnpIYklNRGJs?= =?utf-8?B?YzBjVUlOQ25BV1dSS0tMVEkyNDRlRDUrUGZJTmdVSDRkMWNxV1NidzRYbksz?= =?utf-8?B?ZDVtRGFibG1HcjlHS3RrZ0R4d0FzSGZaYVd5Uy92dHJERlE9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:11.1516 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69ac4448-5c7f-4907-7cda-08dd08be903d 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6908 Holding the mutex is not necessary while scanning the string passed into platform_profile_store(). Tested-by: Mark Pearson Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello Reviewed-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 4f5623fc27c09..45ffd85a71dd5 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 Sat Nov 23 22:48:04 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) (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 7DCEE1D27B4; Tue, 19 Nov 2024 17:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036879; cv=fail; b=ZZcJpsHRh8cGXhg0GjsrVFst9q1W8uxU3lizVBkFtNY4rjAg4AD81ux3FfQAte6D2slIVXKN/EwTx9KLJs97tK6oKPfaRTPDDHl4GPuqfx2JK14z18ZpdjJm5gitMb65wuGx1gct1fCSdF0KV/XiG554viUzJqW/Vvx0IH2dHH8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036879; c=relaxed/simple; bh=JewyXTxhFRqy6h34+YKrMpsgMeLgKwlZqckAx0I+7ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tDb6+Xi9ci6KFLohI+lYejQJH7VeZnAhjpuHrkzx8Sdeg04z1QVPf35IwjAq4/x1DnSgXhcp8KLsONaHkdLNsjCW/CfiR1TY8swwQeWh/W29d5BzShC3vBAV5Hs7Ph5LVroj6ve7m3lIWLeasw8tzn9o1fr9uvzLvT5Rc7NmBbU= 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=edfjn6gy; arc=fail smtp.client-ip=40.107.92.62 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="edfjn6gy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hUikfqQSy70sVX+2YpY4GE8ND3kaigEJ0BeUz+SCeY3zLGxy2CyhoIjEnzNrazNYoBsor4Yxmg9/fNV5frWpTmSOnG5wIXbW+E7G7mJsSST2Lh6YgTofO906SCl1GZrUGsqnzJu2uLuadLsqmbvWmW8qGKikY3PLA2xfTf2nSYPRlUOVSQkEksUJPF2+67b5FFkTryESzkdtKJqOmBWYsLEp6hpRY5l7fqn8p7TJLs++Hl7RYjeKXTFCfKXRU06cpSnc6/1G5OZah/Dyv4xuNocOUXwTzuenuUs5o7tEHoeDoehXaEGINF3FFbA3gAzzvRxuW9n3JhcamBQIWiQwhw== 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=se/DRSG0jq4mSe3JIlni8+u15VBvik79rcxTvY6iGeE=; b=qh4oE13lfHnjG5ST/HYAaapJDcq5n8FwrbiUJmSXToddL5a7BhrNPRQMmEA+wDcnpSaURV3XEb/JWtPr04+BLDX0u6pwF1HY7phH3MqNGV+7jzL1igE+Q83DinTiN6nhTKgtGppRnThlB7FandwBYBG5msyyPaFvX13VtKn3BVuV0ygWPJKmi0ftyGajwpr9m7e2jRf4rzki47oppMBXhrK6R9mkl+43Cc9dxpKJSoQxYGoQLRpAgrtiV7PUAxIEX5oc3fVLROpvYnCLUdwxSaRnZJYp0fvmW9NlPLFP8xBLu9g9HOF288inFOFLxinZq0Oazixg2gvFf507xoEHAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=se/DRSG0jq4mSe3JIlni8+u15VBvik79rcxTvY6iGeE=; b=edfjn6gy6/zYuhhLkGa1y+/NRlN79wzmD1ZoBvyOryd7MbwLTRAy8HSo7slqCIZeXU/rR+4pvO0ERK7P9HTyF4TSo6FlBkhNkKJkrkxM91i1plbElgQMCsjTC6E04UAvCeHM6Gix5jMKOVUWQ9DJxkUmikyig+cvehTq2MA3ceA= Received: from PH7PR17CA0041.namprd17.prod.outlook.com (2603:10b6:510:323::24) by DM6PR12MB4219.namprd12.prod.outlook.com (2603:10b6:5:217::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:12 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::32) by PH7PR17CA0041.outlook.office365.com (2603:10b6:510:323::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:11 +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, 19 Nov 2024 11:21:09 -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 , Armin Wolf Subject: [PATCH v7 08/22] ACPI: platform_profile: Use guard(mutex) for register/unregister Date: Tue, 19 Nov 2024 11:17:25 -0600 Message-ID: <20241119171739.77028-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|DM6PR12MB4219:EE_ X-MS-Office365-Filtering-Correlation-Id: 976cc9e1-d22b-4d36-4ffd-08dd08be90b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?VEhVZ1NsR2ZYUUxheWROQVJ3VVNmWVhXbnIvV0pqQzFPTTQyN2FyVEhxVGox?= =?utf-8?B?azAzWkpEVWx2bTdiT2lpUXE5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SMW5jTlNs?= =?utf-8?B?RFZuY2FmdDkwYkZNUW1vTHMrQmo4YlpibEx0QytVNkFBUVE9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:11.9173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 976cc9e1-d22b-4d36-4ffd-08dd08be90b2 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4219 guard(mutex) can be used to automatically release mutexes when going out of scope. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 45ffd85a71dd5..9729543df6333 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -184,32 +184,26 @@ int platform_profile_register(struct platform_profile= _handler *pprof) return -EINVAL; } =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 Sat Nov 23 22:48:04 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2051.outbound.protection.outlook.com [40.107.93.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD7311D2B39; Tue, 19 Nov 2024 17:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036881; cv=fail; b=TQjkCfaZQjx/8K1blWiZuL4/OeeVFz5BO7FJ0wxg7s8MuSGNjuIaCGrawEdbCIA6bXQ0NtB1wMq7t49gp2XbMhq4JvktwXlfDK/cV2Uqd9oM2Ot5EOo3+akwp6RyOBOannlm5S3VVR5i2ku0EWkxY4qYCLdrVzk16drN29oixTg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036881; c=relaxed/simple; bh=PNUcu1E/82BSOFEj+1FIiCzavwo3sGsVB9Qtl0r0bJE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O4MohyV75Qts4gepyzq9C99o4MmC7WN2gqBNapAi9SJhiz7iitLoF/0n2mZV58A6CHg0WPxzX7mVaAS1PA+VPYAHTbzJIMagtHAYUV7olRKjmb+VzxUaapDpf8/ERoBjo1zlmqw010mieTEBOlzB9fmtMd3oPwYynWBsxJPADjI= 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=WjeZsJO7; arc=fail smtp.client-ip=40.107.93.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="WjeZsJO7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vI3zuUMXXupObyBcpAAgDea/pwfX2jmSvXJJq5c8zo993CqnPaz3gOllyHb1KJ96r/UlErkv54zVreB+vSK8FCwJoyhJI686bEvPX9WoQVgJSrOC8ku1GJQXA5ix30ayrbsX6nNQZJF0ld5JDD7uHX22YgMcPkDby0AZzN3oN35wy87QavNznFNi1J1QDESCygnG2XcMk1b+mE4zlrw24YXZZ9FeI6XWbJsdUdv/d9VchvYWgdZBT/EBKYw406jgs/6vY1lMQKaABPGnvVuJVo39k8LiURkNcQPM0BlrIk6owh4UpwefVPOKCOgFicBLOD32HQq0buJN7XtUbuztZQ== 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=G0B2bHKyeeoDyHW0ot5xsOyAVBTpI6KiIUFRqxBndXA=; b=EhpYZHOnXnGpC7WUxgHa2muIpifR7vP2TyUfFz062HYdO6sXSXOIWDBpCDU1K4rWeicWbDY+TM7sJHtx8bwOcsJa8V5ftTLEMN/lSNJzwKp8EuZNcTsvNM5q+XqWL5odqX1zZZfxs4rrD44DAKqYhqgwFS1ZurPKijXBBw/RSKe/OsqogTPmRzr4KzveD5N5pHDuq8krpehWEgEUgXaieFlnq/Ab2NYLqJGOm1kAvsusxKjyNe5I4iPD8IHMmcRehHladURyuJKWAeeMonmFKuPNvtLv74olrXnd66z+Bp9z2NcxT4Mrn97S0U0uPKkAXmVjmjDAvQXrI6LmOMgDzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=G0B2bHKyeeoDyHW0ot5xsOyAVBTpI6KiIUFRqxBndXA=; b=WjeZsJO70YT5SJ8FK1VxgwPLZoUlKU1ElUkQRDE2HfCSBZJ8cAVOuB4gmJ6mK8rcclXOVCthU+ojJdt1zDXsYTfrvXWdKb85AH3sLBIi+iBZixpfsBX1caIgolrh4H7JcwgUv4RiVYTC4LOFOKo6L2dSzTFZzakQlu1zqHhciuQ= Received: from PH7P220CA0043.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::12) by DS0PR12MB7994.namprd12.prod.outlook.com (2603:10b6:8:149::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:15 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::b3) by PH7P220CA0043.outlook.office365.com (2603:10b6:510:32b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:14 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:11 -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 , Armin Wolf Subject: [PATCH v7 09/22] ACPI: platform_profile: Use `scoped_cond_guard` Date: Tue, 19 Nov 2024 11:17:26 -0600 Message-ID: <20241119171739.77028-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-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: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|DS0PR12MB7994:EE_ X-MS-Office365-Filtering-Correlation-Id: 3efde092-5d25-4967-1414-08dd08be91fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?aHZIZHEvR1I0K1ovTzVYdTVrMElMZm9yU1FrNnMxYnRGSnBkanpZcjBkVndM?= =?utf-8?B?TzlYdnh5LzdpalNZVTJDWmlSckdIWFJ3eEJMZlNsa1hwYmlPT0hobms0Z2dW?= =?utf-8?B?RkpoOFBnbmNjS0g5K2dMS2tNamxKd1pIL2FrNE9tR0tDMnBtM0RZK1VGd0JV?= =?utf-8?B?RlFESVRjOUZ0WUxLelNQOXRTSXNhSHBxVE5PekpMMXUzWWU0SE5acXJ1MG85?= =?utf-8?B?bzN2OEtSeEFYWks5dnhvTU1Va1BXbFJtbDJTVjlNa1laNkpydFpXSHdvbzBp?= =?utf-8?B?eXJiTjdTNWNDMXlVSkJHNG5Xd3FEdGdaTHY3MHM2citrN0hSeGRnbWdRY1J2?= =?utf-8?B?eDl4eEQvYU5PM3V0KzBrNFpLUE9KT1oxdWxVbXRKV2xPaUVNdFhkU0RtL0Nn?= =?utf-8?B?azlQQXV6eHY2ci9PcXN6WjVjWkNXVjV0djdNajFmV3p5T3lnWjVWQjhodk16?= =?utf-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sNjZHckxKdXMr?= =?utf-8?B?WGIyUWJpVE5NRmlRR3k1SElMbTBtZHFuR0ZiYXo1ejJMOGRlb0JOWTVuS2tJ?= =?utf-8?B?QytPRC9DSy9oUHpwMTQzR2V4c0JZeVJLU2sxczBLUGFCK2d0R2Ztc0daQWxl?= =?utf-8?B?TWswdmRGTE5XUnRIMWQwWVJ5Sm0wVCtORHpEQWdUWDBSU0xiTDdaenpQbDlV?= =?utf-8?B?aUJSTjBydFhEcldXS2M1MzFNdk9hUmJPSzR2WEJHSWJsMnkrSjVhd0ZZaHdv?= =?utf-8?B?Q2RDSDhpVzE5Y1hzMmtVdk1mK2FRQ2p4QVlhY08wd2I5b2ZNZm4ycXhWZXh1?= =?utf-8?B?aTlZVCtDdVpMQjd5V1Ixc0syc2FlQlZJSStURjhHUjhON05yeXZ1VVlkelpW?= =?utf-8?B?c3FwZFlSVzdCRStyZE83Q3JPRW93c1RJRkJtM0Fvb0J1UkgweFU0clRXVGNF?= =?utf-8?B?STgxbVZLWXhrWHlybVUvaHI3ellDMi8yUjRxQlo3L1NGUnFsN2M1a0xXVEJL?= =?utf-8?B?ZHEwd3F4QTh5TXczSGRaYm9McTNaTmpja0VWUEVaZjN4L3c9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:14.0341 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3efde092-5d25-4967-1414-08dd08be91fa 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7994 Migrate away from using an interruptible mutex to scoped_cond_guard in all functions. While changing, move the sysfs notification used in platform_profile_store() outside of mutex scope. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Mario Limonciello --- v7: * Add Armin's tag --- drivers/acpi/platform_profile.c | 111 +++++++++++++------------------- 1 file changed, 43 insertions(+), 68 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 9729543df6333..32affb75e782d 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -27,25 +27,20 @@ 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 +51,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 +78,21 @@ 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"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 - mutex_unlock(&profile_lock); - if (err) - return err; return count; } =20 @@ -140,36 +123,28 @@ 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"); + sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 - return err; + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); =20 --=20 2.43.0 From nobody Sat Nov 23 22:48:04 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2047.outbound.protection.outlook.com [40.107.244.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A77D1D4333; Tue, 19 Nov 2024 17:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036884; cv=fail; b=b9UgT1LZAmDa8grCv/FW7NnDkFr9Gt7uupKQOE1EpK4QXa1NeOpltd/r89wfEWD/rkc3i2dBObjaFJKsZlndcB/OK1TX45aCCkdnEiYlqQ9iHG277ml0jjDmDP7XkFTceBFh1JVLmtfa597HUTCDBxwpW1j1aUZAw48BeQ89TwU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036884; c=relaxed/simple; bh=wBQDnDbMvL1S6Enbnu3r7J+KMcdaAx15fZAfucZABb4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=umuDAJkoDNPRwDhVRdJO2o8PhrMezLzkzP2IlwKJlNOqAoXN/oXJBgG6JvecDU1epKMFqdfvtWr/1oPHGvnR7I1L8PzRnzwnA+NvhFTJxo1YxIUuBeE730hOoR4PSJjF+WKhP6NRPSAMpEv1Rahd6GwPNvqjrBEByxTozlMGQoM= 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=KqVVD9xL; arc=fail smtp.client-ip=40.107.244.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="KqVVD9xL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bnrcqd9EkW5EWBjMweGi7Byig0ANUSrToCtmYZmMax6xfLx8QcJZJo1RPTk+xJft4+cO0cDWrUnxGYfdS5SFgZhqz1eYNmewQHCpfJZ8EC+nUzwaWPVkOOlygjOqyJr8c2rrzeTyTl9lWyYeHWSFfg/mNOHbm4Y0mcG6xBWLDWBbWXmXnMlidvvdDgtq1R1Ao0r/BH095/+E7jbBbCVrPopStodQ0FSiXoqeWDI78jZnOKQckj4gDjJxSROyyvK629zvUAREA+OZmn79QbXBZswybhoy1eH5haAtETHyrgw1nnlX9/IWY17zWF/JrXHPRmYxfaFfIAKh2Wwf4Mk2yw== 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=K8DYtwULlzPhvvL2ryCL3gCt0hyAcSnLlGYhblzyqNY=; b=Zfk22G2iKsrA/y38+U1j9V8TDGY5ihLXdz/9RTfBgjdQtKxAwLmq38BOAuzIjtjEXI0hhChJs279qOP8ZfQkQSKuZgRohRdgY9qwsf7eWiNrrTe6BDC9HW/uhbSz8v0lcwbG4QEIknQBPfg9OsygoqPQvqSh1a++ynjzYcIdFROBZydf8fxYPNoa7LHGaZEzaMFbmhzQufg2aCUumqO9Nqinpbg+QNy8oVldHMIqTJY86Uj/n/5yiQ0JI68/sKdpCvDlaqjz3Jl1IWOer+w9b8F6aggk1e3Loq9q8GZVhOrOxealF5q5DTs5YqWPx68g+gj99VRLex7V62osv6NHrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=K8DYtwULlzPhvvL2ryCL3gCt0hyAcSnLlGYhblzyqNY=; b=KqVVD9xLQUjWcypc3wAKeu7XLZijtkDj66chsuEM4Iz5gE51kCnr2hF7hXWt0gA6MFpLL5QtvGqVch3QgM8dT1AyYsSSxlwwL9lkKX0QeqzzcHQwEO3GiF3JbmNl/x9vRSbc7HHXijVpYeNngXiPmJEcUoh1s+clvCjxzTAEYtk= Received: from PH7P220CA0051.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::13) by MW6PR12MB9019.namprd12.prod.outlook.com (2603:10b6:303:23f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:18 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::8a) by PH7P220CA0051.outlook.office365.com (2603:10b6:510:32b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:15 +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, 19 Nov 2024 11:21:13 -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 , Armin Wolf Subject: [PATCH v7 10/22] ACPI: platform_profile: Create class for ACPI platform profile Date: Tue, 19 Nov 2024 11:17:27 -0600 Message-ID: <20241119171739.77028-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|MW6PR12MB9019:EE_ X-MS-Office365-Filtering-Correlation-Id: ed8b494f-42ef-47ee-a6cc-08dd08be92ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wlgWGg6OeOf3IA7LIOZ6Q+FzSj1hPmCenMoP1ZpKu3PtGOQGhvGyPDgxuYFn?= =?us-ascii?Q?sk4T57+G0MKRfGmrOx6q+NkbaaREjbxNKYTdadF+hapNm3Po8Woe/dOZlTPi?= =?us-ascii?Q?nWpmenVXVURo9/kjXv7vrUw/U9zwRwnBEk5lRpMS8tUQXDdvF5rlC9p/tlmg?= =?us-ascii?Q?ulogdCpiGR7nW5qg6O8eR0eMrwALhL3YVkjjAylJWG9o5OOWzVVbcK3Y0Q26?= =?us-ascii?Q?dOZZ6iH6RaDQbG5Sn9CA0x5Idp1JS4UPxsJCiaA9jFdsnJ0Br3CYRX9F1iD5?= =?us-ascii?Q?7iRcRznhOnltmNwyCMHQNps6Yrg1++qk34X87/uNV0XZaCAmsj0R/rs9FWJv?= =?us-ascii?Q?c0miCuX0DLGVCtcXv3FhMC+12cT0kPWdiXtGLFjvftk0QrZLzqMZrELTVXn8?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XY5VqvxgxoRwvNAe5SJCc0mq4lHCB4bvYv?= =?us-ascii?Q?YidOwrujKKoQ07ukNmDKGObpQtZpLOYq4RTOOq45qGpzOonzrOEfRL82AKEB?= =?us-ascii?Q?IiFjeXTDW+Jj7SXggeKZxNedji9indnrQuyqZ+HC2BhkX2cKzw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:15.6435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed8b494f-42ef-47ee-a6cc-08dd08be92ef 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB9019 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. The class and sysfs group are no longer needed when the platform profile core is a module and unloaded, so remove them at that time as well. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- v7: * Whitespace * Add tag * Drop class_is_registered() check * Remove legacy sysfs before class v6: * Catch failures in ida_alloc * Use 4th argument of device_create instead of dev_set_drvdata() * Squash unregister patch * Add module init callback * Move class creation to module init * Update visibility based on group presence * Add back parent device v5: * Use ida instead of idr * Use device_unregister instead of device_destroy() * MKDEV (0, 0) --- drivers/acpi/platform_profile.c | 86 ++++++++++++++++++++++++++++++-- include/linux/platform_profile.h | 2 + 2 files changed, 83 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 32affb75e782d..3524a2b4618ed 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_IDA(platform_profile_ida); + +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) @@ -105,8 +112,25 @@ static struct attribute *platform_profile_attrs[] =3D { NULL }; =20 +static int profile_class_registered(struct device *dev, const void *data) +{ + return 1; +} + +static umode_t profile_class_is_visible(struct kobject *kobj, struct attri= bute *attr, int idx) +{ + if (!class_find_device(&platform_profile_class, NULL, NULL, profile_class= _registered)) + return 0; + if (attr =3D=3D &dev_attr_platform_profile_choices.attr) + return 0444; + if (attr =3D=3D &dev_attr_platform_profile.attr) + return 0644; + return 0; +} + static const struct attribute_group platform_profile_group =3D { - .attrs =3D platform_profile_attrs + .attrs =3D platform_profile_attrs, + .is_visible =3D profile_class_is_visible, }; =20 void platform_profile_notify(struct platform_profile_handler *pprof) @@ -164,25 +188,77 @@ 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; + /* create class interface for individual handler */ + pprof->minor =3D ida_alloc(&platform_profile_ida, GFP_KERNEL); + if (pprof->minor < 0) + return pprof->minor; + pprof->class_dev =3D device_create(&platform_profile_class, pprof->dev, + MKDEV(0, 0), pprof, "platform-profile-%d", + pprof->minor); + if (IS_ERR(pprof->class_dev)) { + err =3D PTR_ERR(pprof->class_dev); + goto cleanup_ida; + } =20 cur_profile =3D pprof; + + err =3D sysfs_update_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_cur; + return 0; + +cleanup_cur: + cur_profile =3D NULL; + device_unregister(pprof->class_dev); + +cleanup_ida: + ida_free(&platform_profile_ida, pprof->minor); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); =20 int platform_profile_remove(struct platform_profile_handler *pprof) { + int id; guard(mutex)(&profile_lock); =20 - sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile =3D NULL; + + id =3D pprof->minor; + device_unregister(pprof->class_dev); + ida_free(&platform_profile_ida, id); + + sysfs_update_group(acpi_kobj, &platform_profile_group); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); =20 +static int __init platform_profile_init(void) +{ + int err; + + err =3D class_register(&platform_profile_class); + if (err) + return err; + + err =3D sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + class_unregister(&platform_profile_class); + + return err; +} + +static void __exit platform_profile_exit(void) +{ + sysfs_remove_group(acpi_kobj, &platform_profile_group); + class_unregister(&platform_profile_class); +} +module_init(platform_profile_init); +module_exit(platform_profile_exit); + MODULE_AUTHOR("Mark Pearson "); MODULE_DESCRIPTION("ACPI platform profile sysfs interface"); MODULE_LICENSE("GPL"); diff --git a/include/linux/platform_profile.h b/include/linux/platform_prof= ile.h index 8ec0b8da56db5..a888fd085c513 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 Sat Nov 23 22:48:04 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2059.outbound.protection.outlook.com [40.107.92.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4917F1D5CCD; Tue, 19 Nov 2024 17:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036886; cv=fail; b=fUEd/IEvFVqslOEY0MGppp7ZMCkCW2bFeBeaH1tH8x9scT4rQTvj/unB3ugCpncJwKsdIqsTtth/+0PFtEU9Q7EQ36NmR8FVUwWCjkG57PXYu5fGVnSwGglUtTN4ePoZDlJQoQ7x8PtalBVsQYq963RotJe/HV5eUMovqKq4R7g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036886; c=relaxed/simple; bh=o0zMirAhO4Tp1P1JyMZIkB2N+NyjUc4RA+EWuEMlWKk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HyHZjmGUpG+JD6JMdUm5apDm0Z7kYUyr9E/rBgmmkYius0GYT1RAW4lzN4fW02R4sboPrv6jZONXDZWkbTz+XDUX1PoOPMojL9biqCJu7f40SlaAXyvJrKIj4kNb7ssPW4D0DDIri2XNxNOT4G4dkeX54321xqbRlc5BUqPKw1Q= 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=fF/2LNgx; arc=fail smtp.client-ip=40.107.92.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="fF/2LNgx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WSVmJzIYANTgFmIIxmcZmxZ3rXmBw4cFrwIyii0cFkwQ0E4AG5euSsV3YCzqDnHPPzCGPedk8Ej0aZCKd9/uenQ0tHjag/K77aq6mV0GLQVw3GYyMW/REPg3YYbRyZVAEM8KB/9Zt5OIEyIz9szSZic2Sp6jFSUUU9HqUaugsPCDfWNbbJB+N2nlvvkcvKFT0jjSf1OxHyYP/y0kbsGXGDlrQaUi1qnnb2NeAByFklJPOaxodc50S0qst/NylzWL/ZYRSp06bqUq8xE4pdc6HceapyGFfhvJP6ES5qk03u4gHnidwyXLXrm89qMJ7r4SWYORzZ1+gQEmsoZX3Qyoew== 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=cVfARja3a+pd0OusscE7B/9Ps+rg79WGoSSVHrXd6dI=; b=WO6W6Fm4/gHnT8vlMQEKx7Kj8U0nXQR+pWtzJwHIv9HbY/2mBc6nNvs+mOgw4wcBadIDzjUK5HbTcfwpc8NLtYCB0egxGepe0VFUxRZdhWhzuG2Ay9LKt7wT98ZHc7GL3mxhvcxaPJ2WScAWbakDBMHMYJPRHkCCSj1PFmyKAE8ivkrh5pKe8/SXXrDVLBgCa+YOYpsniExuStHnAkxq+ULu0bWqFZfSe/tngw7G/4H/qnAGIwl0Q1Vvpe5C/uF0ZbFuKFdsZBQ2E7AM5m+y1RgpxAhZ/bUF/D+JA3q9RjFH2F03Ka8Dqwtt0Dyd75L6ONW3DwbEgwOdXC2+FKV4vQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=cVfARja3a+pd0OusscE7B/9Ps+rg79WGoSSVHrXd6dI=; b=fF/2LNgxy8OzmQ2uf7FFmDhheSgHvFvSDwEY1nk8std7HdE+fbve6zaGns5HbXtt4/plpeX0be5HGOwmX1UW59vXKcsOvbRlhrU2IDKgDksaJjROx89bLisf1CP83T7UxOxD45Jx/leHaKxrQJQQPeXfu2b0tnxuEs7Lsa/GJTI= Received: from PH7P220CA0058.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::9) by BY5PR12MB4260.namprd12.prod.outlook.com (2603:10b6:a03:206::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:19 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::95) by PH7P220CA0058.outlook.office365.com (2603:10b6:510:32b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:18 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:15 -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 v7 11/22] ACPI: platform_profile: Add name attribute to class interface Date: Tue, 19 Nov 2024 11:17:28 -0600 Message-ID: <20241119171739.77028-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|BY5PR12MB4260:EE_ X-MS-Office365-Filtering-Correlation-Id: def880eb-132d-4da0-ce66-08dd08be949c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us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l2f7yKNVxjFxnw6hqxT8qSyamJQ6wYKRJjn?= =?us-ascii?Q?5oyJHIQ0mrfuul/dZJqAqbVVET2OdsRJ1+BeFrSQcA+xJuiHUmv9vcHmLXgY?= =?us-ascii?Q?9VDb7t1z/wbPwyYy7mvGi8Cv10rzN8fvtTWmb+fccZ4h2ypGZ2w4/LiUSGvz?= =?us-ascii?Q?0Y+3PlwR+VFLlfslPTj72iT8LiFWpdkc+9sZinXiN5UpZYW/+OjytjkQMIL6?= =?us-ascii?Q?M8t4NGNoEIPQv0DQ/GuYwHxkFudgkv4jpjOvCigEYXEcUti3iiFfHZu3SKE4?= =?us-ascii?Q?nzc/V0s1IrKb0O4e1Dh0pV1Zol27ocZFoSVvXK1b9c2DdaAfEkGIGKfcIrdS?= =?us-ascii?Q?YkSmy9a1+5qhPNKVe+38pEBefxh6mv6sIwganpi9QOfPMSEDfF+JLbEt+WLg?= =?us-ascii?Q?YFu2EYtQjD89RSGzouYMkyKy9R2kOYdqWr6Ac6yQ6NpVjF2/2ckKqjBV83Qq?= =?us-ascii?Q?3yL7Cv9EAANO20z5GtaLCODGdRKt0zgMO9/+CyWZSN6oIAyo8JR0QhfVx5XQ?= =?us-ascii?Q?e/UVAWf7lE7G2smRs6uf9KLwOEB4si5ntGkH9oRAqTrAuqFW+Q=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:18.4872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: def880eb-132d-4da0-ce66-08dd08be949c 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4260 Content-Type: text/plain; charset="utf-8" The name attribute shows the name of the associated platform profile handler. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Mark Pearson --- v7: * Drop locking --- drivers/acpi/platform_profile.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 3524a2b4618ed..a9d7ec3c85844 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,8 +25,32 @@ static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_= PROFILE_LAST); =20 static DEFINE_IDA(platform_profile_ida); =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 Sat Nov 23 22:48:04 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2049.outbound.protection.outlook.com [40.107.92.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 2634E1D5148; Tue, 19 Nov 2024 17:21:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; cv=fail; b=RP7PiWxz3xU8R+4abByMzWU3Va19ejT7UIuiY+c9qn1ZXUJMcURsxcMMUEeQSWMlWJtQcgEGUQ7kf+NwvxNJNjLIiGOcvSQUfZBDWSBxf7bwXZX1bqPUgK9BcTfgUv/bsyeI+PDBswlwhO9d5ocm0q+27ArcCd5Xt/4vdMvgBrc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; c=relaxed/simple; bh=ksb5hm91eMP5xMbwuBZ/g4WF0yYqTIq9mdxdxNxsttk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nNYvQiagiRnDtenGLwv0mcLLqeJu5fMf4K3jtRmhZV30nyXhNuksyZUDhgCjicnY7cis4/YYoaxRGNU72/PovOmkQ7QA447MgAkK3Uga079JtPIWmpH+frIs6YhQ9FviEi8S0ycJ96bzfhFNuUQcjqfrlXdopEpyfvSkh8DofbQ= 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=wwKZUGXd; arc=fail smtp.client-ip=40.107.92.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="wwKZUGXd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x/C65OqjAzI8ak88f8Ufu6PfhzDR7a+VKXz0DPKd8pBA1voo/l+B+29PLDrM9D4m7shKMZTIIcHhBWAcVsgPmYwTswA/wQaJV5s/ocbUP4r36OKK7prVfHhO1FpSa3clDDYM74nCW+9hlicy5JWDbJRyYaYvz7Ne4L6gFfLMraof3eWMOYhJ+hjHRgjfh+SNcbJ76KDWG5HDcT1KzP7NpSKsLGsCBBDY5r7vuCGawk3b3VqHjoX20BjhWSMaWuqzAZX6IbqAjlHQK9hWVAJhFtOcpQjhapMjJDoSzzvk6UZMdx3zheqx9CZI3zuXgqgsoxZV5B81VoyRM4A38Ke3bg== 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=a6CFc0+6d4W6sohcGl253Idmf7tHdDPMClf+D9DQnQ0=; b=vxobHHC1dsjctDFjyiaNHcjZDT20ouYqddpIBcfslvFfqE8ry2mElSkccOhN60SG2nE7T6nZe/S2m0uEXvhRQKr77pKk+gnzonGrezext3YNK4rug1VUm2BmT5oIBmqffBlRqJ5vZ7WqkGcMrCPPS2EmOfXb54/SE+xhVuANLGM8nRnGDuz/pJEm9Z5A8Xi8/Xn8lKWiCVlD9+GRXx+/lvsIM9c9KEyRFkVHjcIe5T4adt3iRVuRaG3CXZUo/XtUo7viDBwPJeV1NiH5GVLvb34FRrN8BG93mbqlIom/iLB4WzudnKQLaasDJbck/PnXnuSp3mHsZoTv9rJv3mj1gQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=a6CFc0+6d4W6sohcGl253Idmf7tHdDPMClf+D9DQnQ0=; b=wwKZUGXd64EFjHOF0QWURh+V7oaUADvz5TQ3Cibbo6AC8ZwzGmeM6Hox3OE39v1665BtVVnk/awP00VEXin/WzaXD5r/MLjBC3+nFbUyqx0cTxUe0GYqpaG2eJ0/+XNRvThofV/yOnEEi06d6RspaQZNB+nAycB0DoZXfFxjuUw= Received: from PH7P220CA0032.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::31) by SA3PR12MB7829.namprd12.prod.outlook.com (2603:10b6:806:316::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:19 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::3b) by PH7P220CA0032.outlook.office365.com (2603:10b6:510:32b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:19 +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, 19 Nov 2024 11:21:16 -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 v7 12/22] ACPI: platform_profile: Add choices attribute for class interface Date: Tue, 19 Nov 2024 11:17:29 -0600 Message-ID: <20241119171739.77028-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|SA3PR12MB7829:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b33ff0b-0f57-4363-7948-08dd08be9529 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|7416014|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5jXSw30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zkhWrBs?= =?us-ascii?Q?gVvYO6+Au+mr9B1r7okIqBoDNDELgJX+sI2kF987ITbImOqkznOeS7GrIXKd?= =?us-ascii?Q?Bk9aeBnPFZg6/IMQHc+EwHGzNsxVEikPUN540aMFPSd60ljkorCBE3deiSGU?= =?us-ascii?Q?vhFBzTiyveOMLG23P7RvDQs+S2PMCxqZexKVqv+faR075NX2mns3duKyQr3t?= =?us-ascii?Q?TViEMHLtktSywFMmQWpRvnQ5w0g/+Nv6vL2iO/ochx7iPirM3usMYZPX7zk+?= =?us-ascii?Q?3EaQpONnoiTPw5cQ0Nf8bAU7tFirsraPWH1EGf9+kVf3G927oeXdoqCTn2rf?= =?us-ascii?Q?OXhz1+i9BAkMZm77S0MtYvgXH57F66Pq8TjVwxFFV6PE7br+mSqsR6pIsBEx?= =?us-ascii?Q?kMRGJfk4p8D1Cgu+qRt1Ugk4hgTiVfAdvSGOU6IDp6i18UDKdc+2Inp9y/Ic?= =?us-ascii?Q?Xk0kF/EbLrssC22+8ZoXVmIcuHqh3VoOfTirGRS6NABmbDIEb18gZYKAM4pw?= =?us-ascii?Q?kplSmVhkNa2txCMIAsdXHNNMlK2jt5B2p5Mi3NVN7Rfk+g/R+A=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(7416014)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:19.3622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8b33ff0b-0f57-4363-7948-08dd08be9529 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7829 Content-Type: text/plain; charset="utf-8" The `choices` file will show all possible choices that a given platform profile handler can support. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Mark Pearson --- v7: * Drop locking v5: * Fix kdoc * Add tag * Fix whitespace * Adjust mutex use --- drivers/acpi/platform_profile.c | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index a9d7ec3c85844..9d6ead043994c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,27 @@ static_assert(ARRAY_SIZE(profile_names) =3D=3D PLATFORM_= PROFILE_LAST); =20 static DEFINE_IDA(platform_profile_ida); =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; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -41,9 +62,27 @@ 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) +{ + struct platform_profile_handler *handler =3D dev_get_drvdata(dev); + + return _commmon_choices_show(handler->choices, buf); +} + 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 Sat Nov 23 22:48:04 2024 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2088.outbound.protection.outlook.com [40.107.244.88]) (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 BC2751D5171; Tue, 19 Nov 2024 17:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; cv=fail; b=PpEcYveasg9/eRpZxZtt/jo5LTVUunfW7mihMiZlg4MbSAfrjcYfnQxDnuzvld7s1dE0JL04aViPxh6Agg4I15sDhFycqbj2S+v1X9wPNeKKcHpz+MH9HjrRg49aSflwukj42V/K7p+jVusGEjbOXHE2cg7wD5icSF3eAnRMwDM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036885; c=relaxed/simple; bh=snLFbEnXBKQVGlUks73lyegCvX770SSCXi1gKbSURZI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pSiMGVkc+BKS6C+WObsErWhNzyGdC6zE+7QZMBDbezd+VShYleZPsyP9vrrcMC5rHQsLPv2n3enz3WqjRH42++jOSDys5VIuQjSLydbk7DOzCn1ZRBac62RmfMMEOqD3A5Si2uirEEfDzqv6XFeASm5N3rnVyNCogbMewo9FWVI= 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=2QP6FQ2J; arc=fail smtp.client-ip=40.107.244.88 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="2QP6FQ2J" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FT1ND2OwNEh8HOPE8dyCM70ZUmqb7OimJCkQM6eWB9cOVxWsw5WwjzjaUjRcchc/0VqN0biuO0U4JTeWcTwitOuej3g0GiWJkaX8EPzG6X7gVooC8+s0bZCwwpECZ5vfCgNk+BCWMdw1964lyYhgUkE6DLCWP9vI5jK5efp0wQBKb7CRnfyZWgoHtUMHUdTQFGARP6/uE0F80lrcYPn6kpQTyPGQLSnQGlHTUdQJqeYC5SEsx44PAWnMOWjWd2qJL2jACvaZ5u0HH+Yoku/pxWlWl/3dpskaH9fMocwcP38rFg7mDu8olRAWOEXbvWw3dosut+vHic4jnx7+nVg7EA== 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=mFeIu1OOy7NmI9v4XrT9b1Rd6G/IHgfIrbo7n8grD+A=; b=UjzmNPl4hgdWmVp+X6PYrS6zCHf7+yhPkKoOcFwmnpd4dhIwkhnDeQBcW7GLxYZ67N3ejyk+qtsHYVBUpf+KsPLRctrvrP1w0K4feFNqqkfwnQ0bHQHBp148sk2drq7WqcBW0CMUL4umWE+OL0Wwce36mkxd8Q6Ef7TK+bdOqwCoJXdSmN2XuEjIo9a279eAhJFtCf7GvaSUmZKkR+ryJ60ZaD8Z0vJA9B+HGYRxm6jHMnhHlEmcB2KC9BADvN0GdyMYNSLJGAkwkBJhgr1Ap7DpF5Uqkuuz3HeegaCQWlWbHVhiX8Rw9Ixu4zzQzyOQ3m/j8jCG8H2odjhty8xldA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=mFeIu1OOy7NmI9v4XrT9b1Rd6G/IHgfIrbo7n8grD+A=; b=2QP6FQ2JWXZVeQR/eUaL9qUENyMi4P0lyXDD6/rgrycdaz2nm0WgjFFX8wpH5si/TH7E+v8wFu6EUP42lr/Jd03EOPIEMj9W+Z2QA39LeSJl2oDU4fpatKxk20x9UNFO/UiukQXD/Xc+lhnrJTq9A2lrAum/ME9S+qn/VYb53k4= Received: from PH7P220CA0040.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32b::24) by SN7PR12MB7450.namprd12.prod.outlook.com (2603:10b6:806:29a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:20 +0000 Received: from CY4PEPF0000EDD0.namprd03.prod.outlook.com (2603:10b6:510:32b:cafe::be) by PH7P220CA0040.outlook.office365.com (2603:10b6:510:32b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD0.mail.protection.outlook.com (10.167.241.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:20 +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, 19 Nov 2024 11:21:18 -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 v7 13/22] ACPI: platform_profile: Add profile attribute for class interface Date: Tue, 19 Nov 2024 11:17:30 -0600 Message-ID: <20241119171739.77028-14-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD0:EE_|SN7PR12MB7450:EE_ X-MS-Office365-Filtering-Correlation-Id: fca57492-3cdb-42e0-155d-08dd08be95a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?1F8i2RiYQdZkgKUe4hlTAKekSF4azYoMAH7PgjH2D44YAFHm1OK5zADlDRSk?= =?us-ascii?Q?wxn3TADopUH5gEpCVzTqPoE9hOOToGjC6dRyKFI1NpqJi+8Jk37B9SUsUlx4?= =?us-ascii?Q?HGeZ0L0bfLFSG/Rrg9bK1BUrC0HHAf4h9Ktu8ICriK/9+tYAN/B4SKHuK6Pj?= =?us-ascii?Q?IxQCKOVgZ2e2IjLmTT2DmeDKae+6AmNkp/orYysqrKuOh5RDE6mZ4xyGrJie?= =?us-ascii?Q?EpFMSR2eZgUQmOG4+aGNMsLsFRfn9HVD4ZnJ/5w4RVgd2HomVlbbxOoxrhQc?= =?us-ascii?Q?b/iOo5+weT39eLhe2W/X2VBN4FXHYhOf2LGi7xov8i1Dr2GxEvwCeXwiAql+?= =?us-ascii?Q?CXmfeSXbxdpi+IHz8jJw/rhdNIJyV6zWyUOM6TZop2U84OR8gxZMRLdtbFvh?= =?us-ascii?Q?sxV9SwaqreNqB7N9zIojirsuTBeYMai52XXRqjCncAvwCJZxgODDhZBAYTws?= =?us-ascii?Q?ZnfQaaRGcKbjc9oB00Q6pv+9KuPZnuznyxtvAPWqHAftC8rTulSwPUtQqqXJ?= =?us-ascii?Q?9xuSVzZ1tVKNBe8Ts8I0Rpt3q/Sk2T+g8pbyJhny7beGTVbNQUErV0Ggwbb6?= =?us-ascii?Q?enF+8Z0EVTKpIUFuNFR7epApk0S7fzM66TDt/JCHrZQTMWs5c3TC73bg/n3u?= =?us-ascii?Q?NPCt17xY9w6DK2T0Y1zH/nxL7YOFtKdgvXrqgRNSobzMFFxOXNpKrwI1rFp2?= =?us-ascii?Q?8nj717cnpQVfV/awNScJgaUmDlVegei0XbQws3ZP+PjX4tvWTTx4iUIbczc8?= =?us-ascii?Q?lWGzjFgptuwNzmTjHVDZlgk4PkvYTGqowm2A7MfwACtCwRIXZ9I8JAJyqeAp?= =?us-ascii?Q?tkMx7PPUDlgzMwMNtQtF1e8BMkLZZmiYCCPg5n8oGKvYX0P2bbhnDyUCE8Xn?= =?us-ascii?Q?JYcqDr6At5X+HmBqv50/FM0xps/zNnQKbn2h85sFuKZ6Mq0QDeCPuxMVX5zz?= =?us-ascii?Q?0GQJ22L/+RCFgrYNMd4NiiZzcf2EKDDWSakOkpQ75FXY7EwSaime4suLsnwH?= =?us-ascii?Q?7uO+nENgsw3YqmtpqRFjTVwaRbJlQ0ocXkuKvti5JqG0bze7stCY73CMn1bQ?= =?us-ascii?Q?nTd5aidrylzPJIznTJSXOzWcTlpdijOX9FcjveBClvOzDbxnf42JVLTftU1S?= =?us-ascii?Q?EkETxz9Mpv4LBsNubccDOnu0dUOb24q3ZPxfO19/8HjaWasJQrwNacYDOU6O?= =?us-ascii?Q?ZiNZczSCCVPEb/S1u80lI5TLxF7G0RB7vsX0DX9by4QcFukwa7/aUUu30M2U?= =?us-ascii?Q?BSmmCiEHt2NYHtquv0EndFzmnn5CjJHW82YNJuPM3ZWeK2CvTr5BjEAvnKsJ?= =?us-ascii?Q?heAyDMLk+SSCouiwmNMgub3dH3HvnU1KtJB9aahekw4Ujn6PDa9Cx0j8ixVI?= =?us-ascii?Q?th9Dind+U09Xbdpddgghyk6ym5GZ40PsbcYtkNtG89h8iuylIg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:20.1903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fca57492-3cdb-42e0-155d-08dd08be95a3 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7450 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. Tested-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- v7: * Remove extra handler set * Remove err variable v6: * Fix return v5: * Drop recovery flow * Don't get profile before setting (not needed) * Simplify casting for call to _store_class_profile() * Only notify legacy interface of changes * Adjust mutex use --- drivers/acpi/platform_profile.c | 100 ++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 9d6ead043994c..1530e6096cd39 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -46,6 +46,52 @@ static ssize_t _commmon_choices_show(unsigned long *choi= ces, char *buf) return len; } =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) +{ + struct platform_profile_handler *handler; + int *i =3D (int *)data; + + lockdep_assert_held(&profile_lock); + handler =3D dev_get_drvdata(dev); + if (!test_bit(*i, handler->choices)) + return -EOPNOTSUPP; + + return handler->profile_set(handler, *i); +} + +/** + * get_class_profile - Show the current profile for a class device + * @dev: The class device + * @profile: The profile to return + * Return: 0 on success, -errno on failure + */ +static int get_class_profile(struct device *dev, + enum platform_profile_option *profile) +{ + struct platform_profile_handler *handler; + enum platform_profile_option val; + int err; + + lockdep_assert_held(&profile_lock); + handler =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; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -77,12 +123,66 @@ static ssize_t choices_show(struct device *dev, return _commmon_choices_show(handler->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; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + 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; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + ret =3D _store_class_profile(dev, &i); + if (ret) + return ret; + } + + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + return count; +} + static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(choices); +static DEVICE_ATTR_RW(profile); =20 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 Sat Nov 23 22:48:04 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.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 4720A1D63EC; Tue, 19 Nov 2024 17:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036887; cv=fail; b=P7KlMuPbRej0bpJkxnUYqZMJRSFtZGr/GnDzkyjc8J61LL2nVU5dCoGRLKdFlw4Tz/3livyDOj0nku382QGindcL8q99xgB5M5crdkozBi0wKIUArxe4JlgMMWd7rdThaQIg/duIBZXFXLvgAbZs/bII287vHdW/LOj2DFZw54Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036887; c=relaxed/simple; bh=31AW3D7L+1fTsGrX8PR1c6Lzz+tYtEk1o1RenZxATmM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M3rItJOlE7XDWjHYfoHPl2a0s4RGEOGTBx++VKD/Lqe7BjR7FmiG6Q6id4Cjc8GllWldy3vbQipGCHpzo5KnZgnT9UdR49jDcb3nOFbBnCrScqHpnz6JEhDKLY/7PQ7Pi0ZI8N9irTsAwh36EihuvkC4XRAbksgX6XKfWpiWxwI= 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=ZvM2T3RL; arc=fail smtp.client-ip=40.107.93.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="ZvM2T3RL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pT1JQqNYKf0s9/nMqtWZZV4zlAuTeVsKE8V01VctW9T0XKAUcUcUmyMyPkoAEmxP9FciqPsbTi3No6dbMZXqx6nKT9Sp67LT6X7R+xN2KFQB/1f/SfsAD8MwleSa77jTUsMDnBi62fxK5l2Zu+f+7lAJoQhU7UJXxL24av53J8voAIkU9/mZIfPbG6mITiMB5a4apttgPpnsXd5cNxtDHrL6clDOTvGV30ZOZd7LKp0GwHGCCoc5W+eCFQHWLL6QR9/iLpC5hHQPLMam4JF7ONm7mkS5IHv6nqKD1ddEWw4+S495D5GrbgGu7+BE9F8UiJWYLzUx+cZLblfoxWRqnw== 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=gCLCYYN6yRq3E/e6+tiqhvpUaO+kwcSxOCVD3v5ilIY=; b=Qqin2O4eLCd45Lc3ZhB5IiFFnLkTRm4Ep5uX41kSkubRN+9JnOqAAfAy9RE7j0K+O+pNgmZNW2dXUJXgiNwA7nUdW0CEjt4rQmTu9873thwX3Q1FNwXMTStkJLYANAXJllUvAENtYqTLj/J66vbD1Hgvsb4ZROM5wDaZ0UoKCiWd0EmqMC776VaJbuD2yW/B+SNKOpPVZsJY4ripM7/T9uPUZS32Vfs5puIcAbXJ0ww0N0eEelpea4vU5xjM39h3aL+iVXan+DtW1tA2MCJ/z/mY3fLVe54IdF38qJTCiLL/C57w014F4NO6rV1FuYwkUCkVnwLqqEwR/VDVkGPKBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=gCLCYYN6yRq3E/e6+tiqhvpUaO+kwcSxOCVD3v5ilIY=; b=ZvM2T3RLV5khqQuXDTgL/G9La0mrU/kB2Tuqv1CfR6XPiVgtQLti6wlXrgDvYjw+RgInQHRGFcyOhe5rN5qgW/7EGB88TmTYAeIUm51romHqPbzthqs5WQUqqYIrlJq0ZkfSeTo6jNOpiQ+N6Bq+30IRPp+FQ9VxXqa0Y8cVwPA= Received: from PH7PR02CA0009.namprd02.prod.outlook.com (2603:10b6:510:33d::11) by CH3PR12MB8994.namprd12.prod.outlook.com (2603:10b6:610:171::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24; Tue, 19 Nov 2024 17:21:22 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:510:33d:cafe::e3) by PH7PR02CA0009.outlook.office365.com (2603:10b6:510:33d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:22 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:19 -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 , Armin Wolf Subject: [PATCH v7 14/22] ACPI: platform_profile: Notify change events on register and unregister Date: Tue, 19 Nov 2024 11:17:31 -0600 Message-ID: <20241119171739.77028-15-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD2:EE_|CH3PR12MB8994:EE_ X-MS-Office365-Filtering-Correlation-Id: 69bef7e0-8f32-4fa3-846d-08dd08be96e3 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?/7i3wFtMUUJH+4lYzO3EOCK0jmgwfrzn2UQtyRQO7qBbRw497R/11O++lIwM?= =?us-ascii?Q?1vqalbXj8U10S0lT2Hpz65gclY3ipEFoH2LQjDIZ5dZUFEJRkLDXVYBMKFK8?= =?us-ascii?Q?xKXjKuNRckqifBlDXntQPCiGp8dEdS6clsiIkwPKOtr0KCZDK82ah90bI0IE?= =?us-ascii?Q?8Z5Y8IRHOMMKlj2UI5egZKQWfYbY7xEsDFWp6ML8Rm71HPhH1w3IDXG53y7z?= =?us-ascii?Q?G7pZSA72uY0XLtmBviIFOUAt2aFsnPE8hEEzJ68rjFwCNXwxkZOtqevn1Gm1?= =?us-ascii?Q?Xtm9dIzf2Os4qgloq/Mg16PTRDgxtdqpcoMQXvK3Rrv1BML6f+8CcxQeK2ru?= =?us-ascii?Q?CmfdpSKNjJ0TL73cGNarl47bNEGVdTmxNL8gn0A5Zu4sowbucpXrkW1Y90Pj?= =?us-ascii?Q?FmGzBRIl8HYd0edP61waESWNyIFBd1Y1zTSywnyjRithj3VJrogbK4EH+ysJ?= =?us-ascii?Q?0quwMkDSE1oRPyIGtylzrlw0Ev07+vYoAh2RNiFyCAmDimu2K6vGmfSi9ZBt?= =?us-ascii?Q?Kg2cWgT4PyvqfuW6OK448425nvxIHhlp8L+dXXg3z2wMfQ1tv43Au4IrvKy0?= =?us-ascii?Q?nORvFNWCRqxqk9/cFuUi681uzS6p9GYcgXuQA3LmqlgPxpRU8+GahqS71Rst?= =?us-ascii?Q?qK54/ojdBhkzDrxrBU6h+KGaSBZolpFk/z+j1qxF62VJe8ISJso740XV7A2/?= =?us-ascii?Q?yhnb+84z/scxY7KGkuSutn62wUGfsQT0x6wKL67iLU7MBS1ODwODa0QJ3Vab?= =?us-ascii?Q?c0J2h4Puupx/61vDXNUaBjNDyEuN4YY13CQwW4CJPsekkTEuXO7XHgkQ3Azm?= =?us-ascii?Q?pNjzy93pAVJNQOl0Q9G3mlTAYDV/C3x2n5iuzA14hh3Vq5TFYglPKI0QXPQM?= =?us-ascii?Q?b1c7ZeXHGWIoqbJW01e6Cg9eoADVi4OtNIdJNSdE/25hPQ53HML4R/rv9Yxy?= =?us-ascii?Q?yB6gdBsrIbRqXY8mv1N4JPMo5H9MlmiovibTMJu5fBO30AmNtfuKMVGzaNV5?= =?us-ascii?Q?e7NqBcmUibRGmYasXpX+FpfGxEMNVB03BYKbQ0ZCA4Gk7kka789B5baTviN5?= =?us-ascii?Q?4w5Y125aGsAIaqc/SrpijYCPLQIQaDdApXwLq/DJd4AztVcsBoQRN2DcPafu?= =?us-ascii?Q?O61fk1BXcdykCE6B7mQSlQP77ajoe6k5h3jojXltJJQtJHK+wMctqBjsH6mR?= =?us-ascii?Q?6LgdXNYqHsgbewHQnVWb5I56Ona6eMETsqAS6wfnsFEifleNIqNtq47QWps1?= =?us-ascii?Q?CSPreT75HCF825rIYhOq2Tk0uu27ZudkCjGVTFBW6RWzvpk21E/i9RK6eDeh?= =?us-ascii?Q?+31pVU0HyF68Re5PrOeZUxcjCE4u3eawLDuBemxkQ/rip9IZc2L3Or/s1ab6?= =?us-ascii?Q?madxJAAKsk1qg5SN7R4+AKMpx0xb+VhMw4+ZODnL4ZNCxtWDLA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:22.3217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69bef7e0-8f32-4fa3-846d-08dd08be96e3 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8994 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v7: * Add Armin's tag --- drivers/acpi/platform_profile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index 1530e6096cd39..de0804305b02c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -363,6 +363,8 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) goto cleanup_ida; } =20 + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + cur_profile =3D pprof; =20 err =3D sysfs_update_group(acpi_kobj, &platform_profile_group); @@ -393,6 +395,8 @@ int platform_profile_remove(struct platform_profile_han= dler *pprof) device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id); =20 + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + sysfs_update_group(acpi_kobj, &platform_profile_group); =20 return 0; --=20 2.43.0 From nobody Sat Nov 23 22:48:04 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2082.outbound.protection.outlook.com [40.107.237.82]) (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 5E8F01D1F76; Tue, 19 Nov 2024 17:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036890; cv=fail; b=pHykVmgG4bA6ZQQQZqowpEGxXg1hOdvAHAcC6uFnHmTMPltfrPpsZruirXBVmygdssOUb0xRNKWGOrgeiuXOvdcHpTqJm8a5dXdyCoUfVL5PIi3QANfRTDw9cOJfGZD3SB+SszRILMRTqJzmrodsO4ii4uxe7NYe+capr1kOwpw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036890; c=relaxed/simple; bh=2rt6Y87tQPRlcT8Df+nkb4/NaZ8Whknr1aC5eHRa6yI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MH130yhA7ZgfCCrL9tMvwcf4Eum/kSVT+h//ak891HU/ZpTt/1bZ4jnVD0njAEYksxNY5TerNQRbc5JZZpuCCzuEvY8cHpOvtdZL3nkQDDiJB8BtbP1Pb00L6UEn4ULjeexI5sAXWXOdew2Hvis27SJs4PGxCsmFrfD+wAud09I= 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=Uio2uQA7; arc=fail smtp.client-ip=40.107.237.82 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="Uio2uQA7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U8KnARZzceNsJKH0B0XiFxo382Tj/n4vdQhf1vqXSr/7tns+i6NJK8CnP90V0S8CZtYyPGvjJxeVnpzWR8JxlwFBkFbgJXsRkNEVHvahE8nd1Ujt+z0j/gHwH5deIKzcKa32qYsrHpzbFDViwbVuSX4+Z+xle4qyaXL7PdKz65wY+gMOUwX42qlqR+l5aafP9wdGSoxw32ne16zXsnTKPfUZXdn75uNL16/3zVFxW12aZLmXG7hSdN9B2Vkl2n3Sac/25/lHljFRHc/6gTCJ+DVirWOMUaF8BzzmtLfgLljQfhVwLjdh+OrXbvEJ9Rbcyu+gvU9kg4dMNNMWAHJ++Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xJyqyRORx3PN3Q7CjJn9UtLhUkcMdMZ1mFaWGk31Er0=; b=P8oo+Ntmk6CfFMKHicLqylx8XZ2t8C5c0aWyeoHEG/Mqi5gpzsITCqt+6OsZw9GXltEg4RN7Lzb04MIA8Q+vluFSj+oyag8eueNgQTa5bFhuFRo58ch5XQTvOIlyS03aVUXLxoMPjNhqA2Lb14ALHXtgrMOR62S7CqU0rKXtHToiQVH3GedF1Zvst8mDtBB3UoYkfGFd//VlTSEPa177MKV7SiUizYTxrfxPzHQFTWzxayMpJ0SRUxFqlNaBQvh36svRCUNMa9yJ4si0RzTy92Xdj3jZ6XuU8cUBMc+QER0NpOn8tzCGpC8+IJsjuzNyU/rv0cSnpiA88MRXlS4OFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=xJyqyRORx3PN3Q7CjJn9UtLhUkcMdMZ1mFaWGk31Er0=; b=Uio2uQA7S2C9gacRfv+zby0M6texHqmWjJsgM8iOj8Ww3gCnb1TbCGjAArArZ4CiiPE4raYI9S4D9tUr65Yrbc8z/fvb24gc6gHqbLWyikc7fzqxQmJppKcr5i6h4Qc+YX4ZUs0mfwTmo7pJZidiPVtUhCZx/l5AFhKHSPTUalc= Received: from SJ2PR07CA0010.namprd07.prod.outlook.com (2603:10b6:a03:505::27) by IA1PR12MB6233.namprd12.prod.outlook.com (2603:10b6:208:3e7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:24 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::20) by SJ2PR07CA0010.outlook.office365.com (2603:10b6:a03:505::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:23 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:21 -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 , Armin Wolf Subject: [PATCH v7 15/22] ACPI: platform_profile: Only show profiles common for all handlers Date: Tue, 19 Nov 2024 11:17:32 -0600 Message-ID: <20241119171739.77028-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|IA1PR12MB6233:EE_ X-MS-Office365-Filtering-Correlation-Id: d45d398b-cfb5-4904-76cc-08dd08be97e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-asc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7qoHLrMYzZECva?= =?us-ascii?Q?HxAa8I9QzZX9YgHlttOg3ovsV4sIOk5WWcPr175ZLbnC9BP0Qm0tJeRteCXd?= =?us-ascii?Q?DrEBMgZvXWb/NAKhUO0gIa+X3XyRaF7zEf3CR8by/6pTgehvmQBC7EN71b2Y?= =?us-ascii?Q?qaJv1fWM9+qdKe6KTnRQEXw26HhUqXP75momhEw59762CIWkCymtR0LYKQNm?= =?us-ascii?Q?6FG/gAB2P4dfqNib9hZrDaLioeWvKf0oxU0gMjy2S3jiRYvukHiL0E3reCEv?= =?us-ascii?Q?CBEk603z8hMbf1hzS5x9ejpQqO3ygXLnYqvn9tPbAs8oyNS8MYZgm3f5Pqir?= =?us-ascii?Q?MG/WtrTv0fGbEKRxeRMeNH6SoqXQ0fQ0YRzVPOajiB//hgV8UMm0m1QbJiRj?= =?us-ascii?Q?tvW+9L6dm0KcTVvdb1zn+x2NQD6yTlgRzLnqot6pr8J6wW3+8tvzw1NV5r5b?= =?us-ascii?Q?t/I4zqY4/Ex6BX5smae8OpAUMYrVsIrjeHHDUKukNCJxToJB9njN0woCRRdg?= =?us-ascii?Q?CtEeXrQczIiA7QTmWs4FiSU4JVdN00lTcC81TRcsTtDTY1RlLQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:23.9562 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d45d398b-cfb5-4904-76cc-08dd08be97e6 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6233 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- v7: * Add Armin's tag v5: * adjust mutex use --- drivers/acpi/platform_profile.c | 56 ++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index de0804305b02c..db2daab5b2a44 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -192,26 +192,54 @@ static const struct class platform_profile_class =3D { .dev_groups =3D profile_groups, }; =20 +/** + * _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) +{ + struct platform_profile_handler *handler; + unsigned long *aggregate =3D data; + + lockdep_assert_held(&profile_lock); + handler =3D dev_get_drvdata(dev); + if (test_bit(PLATFORM_PROFILE_LAST, aggregate)) + bitmap_copy(aggregate, handler->choices, PLATFORM_PROFILE_LAST); + else + bitmap_and(aggregate, handler->choices, aggregate, PLATFORM_PROFILE_LAST= ); + + return 0; +} + +/** + * platform_profile_choices_show - Show the available profile choices for = legacy sysfs interface + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * Return: The number of bytes written + */ static ssize_t platform_profile_choices_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { - int len =3D 0; - int i; + unsigned long aggregate[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + int err; =20 + set_bit(PLATFORM_PROFILE_LAST, aggregate); 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]); - } + err =3D class_for_each_device(&platform_profile_class, NULL, + aggregate, _aggregate_choices); + if (err) + return err; } - len +=3D sysfs_emit_at(buf, len, "\n"); =20 - return len; + /* no profile handler registered any more */ + if (bitmap_empty(aggregate, PLATFORM_PROFILE_LAST)) + return -EINVAL; + + return _commmon_choices_show(aggregate, buf); } =20 static ssize_t platform_profile_show(struct device *dev, --=20 2.43.0 From nobody Sat Nov 23 22:48:04 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2089.outbound.protection.outlook.com [40.107.92.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 BD14E1D9592; Tue, 19 Nov 2024 17:21:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036893; cv=fail; b=MiBLBTG2bB66x+KoEkn+9sY/ha1UBu5LMgbwFhQSlbdii4Ooy17zuhgsT9epTGi0YMgJWbdyqTK1fVTyi3UQaq9WikSNf8CyBNTNc6MibJNoN9DKx8ylrfScleAjWRRZUbLwHOKQZ4W8vXlZI6VF7QPrfqb3Qcm22IR2gUS46aM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036893; c=relaxed/simple; bh=R4FOJvOdpurkjZ6rAItGPYx1C5vNDKL/Ck1Ok8rE8LM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kgVrXtSpyP2GHNRdICpIJVHPJuYEgnXiDSYim3Uqe0R+VhgIUJ/sjgRnQCxKf2nzR4KlUe609lZsbBtRi1YOhLfbAglLGEfT7EyHzM+xsCHlMa3X8PVq3MxyfZVp0elDr8ixbVxQv8UMZtpdyyifXoIucWI6kQ0mHR/nAvhUEWE= 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=CJ5vaEqq; arc=fail smtp.client-ip=40.107.92.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="CJ5vaEqq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OsqFqK7sU/FtG0ZZhPZ5zqAhj1EtSwzdSxBZNHpNgGFZsAKJ2S87ggtlhUTWcmH8ezsZZSta/gSwFRxIOUb+8zxtyCYmA34xdfKzMB5UWkS1/gtNNIYMOS+dyFQTsh1/0Jk+sjv6PApwIYNFNpgad+do8ffKvYtCGELyeYs+/tA6XM9No+gJa1TqIqF83LatuLS52qfh09rPrmMGrEzqmcCsaxmXitbYDp5+O26a5GpXEqNmkL9x7ZslXzHKfr27C8ZneTtIqi4tWPW0DoN0VtsgtbBrqLMm2grg5M+yh+6lYZIv5uwgnauOwxfRZkIrpcosrLy25S6idxVn6FUeXg== 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=gdz8VhuJ822zb+HDdL0/A5HVsWK/jSuxunFPEBpnYJA=; b=Kx+NOY2aQI0m2+kCeUYkQBE6tvnOuH6WO/sLtjcI2k0vXzoXohtshf16Scqf+wAq7dP3LnpMRnBT7QCrz6aexU5gb/Hxuxx9JhjAyypcYKV3tdjGRtCxMA8nrkJK6QbM3Ggfgoss+3kPivMbu6v9fpNtnbxXh0T1uNoJYneVjivGY6HCNHrOuKgtZgrPXRRccFVSzpA1+/L6FCUtheQD64Zyx1maZE7/Ucg0MgWBRGxWG3Ta4azs0a0Pir026HBn3x5162bby9dkkc5g7YWyAHDuGk/QKpAgBtGioRj3tGg1VNG4MumrDNuW1MehhuCVpCHmdFSUOOjS81es9b0GNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=gdz8VhuJ822zb+HDdL0/A5HVsWK/jSuxunFPEBpnYJA=; b=CJ5vaEqqcm+JXTQ99mmFiIUTnqr3uNqaP1rNQ/ANuzt9x/HpduRA98c0obm7Tnk0i0IqT+WHi27jtmuJ7fkZ3dwL9FMGQTMFXevh3CjflilwbJEX7eXRWMOTd3dvn9XEHuPEXtpNP9lLT+fwmTge+6AidQb5pxrMxUkenKaaICM= Received: from PH7PR17CA0046.namprd17.prod.outlook.com (2603:10b6:510:323::6) by SA0PR12MB4368.namprd12.prod.outlook.com (2603:10b6:806:9f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.17; Tue, 19 Nov 2024 17:21:26 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::b) by PH7PR17CA0046.outlook.office365.com (2603:10b6:510:323::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:25 +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, 19 Nov 2024 11:21:23 -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 , Armin Wolf Subject: [PATCH v7 16/22] ACPI: platform_profile: Add concept of a "custom" profile Date: Tue, 19 Nov 2024 11:17:33 -0600 Message-ID: <20241119171739.77028-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|SA0PR12MB4368:EE_ X-MS-Office365-Filtering-Correlation-Id: b1d8a5a7-d0b1-4503-caa6-08dd08be98e6 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?V8VVbOdcfUinJD86ja1k6NIgmwlbLMiZ0+0knu9KFuLnuthzBRzxS+6wSiuI?= =?us-ascii?Q?nBMAl7J4FY6zjh5bu6rC5B4UtkLqRbLQ0qBu9t5a45nHgk/awBESyi1mQHX4?= =?us-ascii?Q?Oa5lJkb+tjxG4IanV7RcWqekeZ16th3KeoTGGr9Q+CI5U/0ojU9p40FJgwG+?= =?us-ascii?Q?7zC7UugfxTyNdxp14ZgGQU+VaROuLkAhy/ocasCwl52qdbj0yrJljzbF9zvM?= =?us-ascii?Q?Wib3tSE68QOGNLaZt6CTf0c/tGWfl8CYz28D3cjHowHaimsHwvtaYEF6BgGM?= =?us-ascii?Q?6Hi4BztwTwbGGWt0pHuwE/WiYyBBGKsn3QVhwhgh1vxelmFW3Uoa+RTiLqYv?= =?us-ascii?Q?yHAVmZkZ7h9DV0foInX779jm87EMSGqw+FOiujNYuCoJHlZ3y1tu578i/ejM?= =?us-ascii?Q?G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8Q2GECoDUmk6Zf+1N9Ikt2?= =?us-ascii?Q?TTTscpA6gtXsMibuLiYbMx5TK3IxchyxAJZ7BuLsNYgK6DCNLSezxblC+SQN?= =?us-ascii?Q?Fs4FZEN7nb9yC+95aGbWX+bcdHYh30AuE/JXsOXLPbOFSZgyjQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:25.6830 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1d8a5a7-d0b1-4503-caa6-08dd08be98e6 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4368 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: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 1 + include/linux/platform_profile.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index db2daab5b2a44..d579de1b31be7 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 a888fd085c513..0682bb4c57e5d 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 Sat Nov 23 22:48:04 2024 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2049.outbound.protection.outlook.com [40.107.102.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 2DE4C1DA11B; Tue, 19 Nov 2024 17:21:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.102.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; cv=fail; b=fTl2d0EMOjvrBoO2AYaVypOa6Ly3ZREIOCsIEfo4q2TMlJ7gzQldXhXi8DkOlbrxqptrMIsiD3JbcPp06PqZuYDoVdUgZdv54rKZIRX/s0vpTjlRkwdNoRK4+0QYC6cS37j8ipoDXCJwfnW1k1t+hOCz/2yC7Rdjg9uM0cI/lyw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; c=relaxed/simple; bh=XdhrySlYFp+OvrJQRA57C4rcdrTgfHNmuwKwtVISUdI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BESgtkXWiZ+qzaqEBGpr+8IFzqjaNS3xXVF3MUXYoblzFsrhN9uwBbER87HB734IaNPY8ntYw4snHWISI7VqZ/SWgDvIT7CUiMjbhTdV2RQpTDdQrsWqEyHeLtfNvxTH6CitX0bgWdWkfVDfvmP+qq28mNK4RFUgiYvfsVBFpxs= 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=KME/kyN4; arc=fail smtp.client-ip=40.107.102.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="KME/kyN4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UX6RqhbvAjSqHD2c8NnKd3oLMzi4HfrXmmzZfMLWa3+4Xoa7yVITosvVJwOwr8IaaS1S2Rdg/kz8j13zwy9TRN4hw9nxLAgqdHWmVAThoezq0rCapaxLj5LTaYDVwv9XX2PBIQtEYgFTbPrg86gXMC/dVEBwH4tGflYFDg0+ljQgay7NxJ+DMVCumV37vKY40eD3s7e3qI0KR7lSzDGupGkmxYx1e7R1DcvDTq8rnOpX3/cZ8kKeeKKROphXC/kQfbkkJkavzG+p0uMNp8CxuqHcl3gZeHD4iSHyOuihdX1eQA4M0NLroufzWXL/enudRFs93wk4SPVyZXWfZIRrBQ== 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=UGPAqd1+1i81/Riyyy4bkGTFIxSQtRIuLq5MJ9N5+Ag=; b=VgS49ZQoHqz9Y+zBkbGY5IyY3+f09X36Psar1kECmRutQNrsstBX6sduadsPiwC6QL6XIyWcppIHlELL/S2/629ZykoSdSlC953J+EiD+m05LP/4b7+MHFAoEbdRz5a9VcPVB56qcv1H/QKUyfIFh3m3iApFJ9Z6TQmjYQRG1cUYc4tNQXCFYEFFSFJeAaaYx84Bi53OYTUsUJetp2zhtfRDjhNNiYcoN8QqoEtSx//J0ABygMIEoJ5JXg38Fc0F3Hh97aGkHko/Jnv6WdRCbcEmF2uibDM1nPCZ4R3R7F4m9FPfLfKsbGMlXTbGXMwjmyJ1dlj1mFEWvPkScZePuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=UGPAqd1+1i81/Riyyy4bkGTFIxSQtRIuLq5MJ9N5+Ag=; b=KME/kyN4mJl6lQuUdFNSnHJWhjjRDXIqTjbsQXqmQuMXooGWIjR+PbU6XcO19d2mWUtd1xuj4AKsQsiFNdKCd/hK6BC6UN7DTO29iWnG/kVGCpgoPzEGZXnwEW0fFwZDYN9tbZGrTUgii/qGYDvv9/I82POtaRenRzyJHsuy3j0= Received: from PH7PR17CA0027.namprd17.prod.outlook.com (2603:10b6:510:323::13) by PH7PR12MB7139.namprd12.prod.outlook.com (2603:10b6:510:1ef::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23; Tue, 19 Nov 2024 17:21:27 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::e1) by PH7PR17CA0027.outlook.office365.com (2603:10b6:510:323::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:27 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:25 -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 , Armin Wolf Subject: [PATCH v7 17/22] ACPI: platform_profile: Make sure all profile handlers agree on profile Date: Tue, 19 Nov 2024 11:17:34 -0600 Message-ID: <20241119171739.77028-18-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|PH7PR12MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: c240cc43-cc18-4e1f-d287-08dd08be99f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?gtk2ysN/8gddDLZNfbcJfmxZcz1E7tksdsvduP3IKP3gTg4hK1NWS5i2xb5k?= =?us-ascii?Q?4eGFwE/LY4861uCOj6dIDQSRP+mmwUNHUIRl/7qSGhWFrVjNHdTRo+dP5p96?= =?us-ascii?Q?TI/Ph5eIwg+Ys5BLjU+kUiLSQWqKVy9fTPhPMCGNn6/FK40Ax7biE+xjgp2Q?= =?us-ascii?Q?e/IOhHPhDvgVEYbAf4JH+Fn6pv08mZaSMBw6P6uAyKbyhwznLseX+yxlovHn?= =?us-ascii?Q?F3k8EsUgD8GW+Pd0JTIs/S6El2Qs2sWpbVpKnQ+U5vGMQhTbHvCOqSUTCkq9?= =?us-ascii?Q?Kvt2gPbb0y4p2JmCFZcV94l57C35Cry4IiPD0LKs1s9AvBy6XPlvbKJmiDUV?= =?us-ascii?Q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= =?us-ascii?Q?gRommHZPdcotCkhLUROFEIHYFdFWhmLOYk8CdcbIr34GBtWSPZRy8Bg1nC00?= =?us-ascii?Q?NTvyF8G46VU933YEQns5YZPnSj3Fz6UB4ULnB6XpPErgBGJC3BDL353p9lJO?= =?us-ascii?Q?fB6JCHszv+jth4+Bqr56Mlz8MHq5lqaWorg88P5AJu6u2BW5/Q=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:27.4330 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c240cc43-cc18-4e1f-d287-08dd08be99f1 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7139 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: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v7: * Whitespace * Add Armin's tag v6: * Fix logic error with PLATFORM_PROFILE_CUSTOM v5: * Notify class profile of change to legacy interface * Don't show warning when writing custom string, document in last patch instead. * Adjust mutex use --- drivers/acpi/platform_profile.c | 119 ++++++++++++++++++++++++++------ 1 file changed, 96 insertions(+), 23 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index d579de1b31be7..a258f2481246f 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -65,6 +65,22 @@ static int _store_class_profile(struct device *dev, void= *data) return handler->profile_set(handler, *i); } =20 +/** + * _notify_class_profile - Notify the class device of a profile change + * @dev: The class device + * @data: Unused + */ +static int _notify_class_profile(struct device *dev, void *data) +{ + struct platform_profile_handler *handler =3D dev_get_drvdata(dev); + + lockdep_assert_held(&profile_lock); + sysfs_notify(&handler->class_dev->kobj, NULL, "profile"); + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE); + + return 0; +} + /** * get_class_profile - Show the current profile for a class device * @dev: The class device @@ -243,51 +259,108 @@ static ssize_t platform_profile_choices_show(struct = device *dev, return _commmon_choices_show(aggregate, buf); } =20 +/** + * _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 data; + enum platform_profile_option val; + int err; + + err =3D get_class_profile(dev, &val); + if (err) + return err; + + if (*profile !=3D PLATFORM_PROFILE_LAST && *profile !=3D val) + *profile =3D PLATFORM_PROFILE_CUSTOM; + else + *profile =3D val; + + return 0; +} + +/** + * _store_and_notify - Atomically store and notify a class from legacy sys= fs interface + * @dev: The device + * @data: The profile to return + * Return: 0 on success, -errno on failure + */ +static int _store_and_notify(struct device *dev, void *data) +{ + enum platform_profile_option *profile =3D data; + int err; + + err =3D _store_class_profile(dev, profile); + if (err) + return err; + return _notify_class_profile(dev, NULL); +} + +/** + * 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) + struct device_attribute *attr, + char *buf) { - enum platform_profile_option profile =3D PLATFORM_PROFILE_BALANCED; + enum platform_profile_option profile =3D PLATFORM_PROFILE_LAST; int err; =20 scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - err =3D cur_profile->profile_get(cur_profile, &profile); + err =3D class_for_each_device(&platform_profile_class, NULL, + &profile, _aggregate_profiles); if (err) return err; } =20 - /* Check that profile is valid index */ - if (WARN_ON((profile < 0) || (profile >=3D ARRAY_SIZE(profile_names)))) - return -EIO; + /* no profile handler registered any more */ + if (profile =3D=3D PLATFORM_PROFILE_LAST) + return -EINVAL; =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; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + int ret; + int i; =20 /* Scan for a matching profile */ i =3D sysfs_match_string(profile_names, buf); - if (i < 0) + if (i < 0 || i =3D=3D PLATFORM_PROFILE_CUSTOM) return -EINVAL; - + set_bit(PLATFORM_PROFILE_LAST, choices); 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)) + ret =3D class_for_each_device(&platform_profile_class, NULL, + choices, _aggregate_choices); + if (ret) + return ret; + if (!test_bit(i, choices)) return -EOPNOTSUPP; =20 - err =3D cur_profile->profile_set(cur_profile, i); - if (err) - return err; + ret =3D class_for_each_device(&platform_profile_class, NULL, &i, + _store_and_notify); + if (ret) + return ret; } =20 sysfs_notify(acpi_kobj, NULL, "platform_profile"); --=20 2.43.0 From nobody Sat Nov 23 22:48:04 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2086.outbound.protection.outlook.com [40.107.93.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 074481DA116; Tue, 19 Nov 2024 17:21:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.86 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; cv=fail; b=pk0Z6Ad3aA/7Y5kiXXHgDoL/uxjjgVbbt+ADjb2G/82eCnyX8yeLsX1iHrrPKukakCmWmFPwjWNPDX3EeETMPMmqjA8Ph91hinJQOwr7Nu0tPxHEaZYnSYJQLdy4jw2rSLZcdhyG+lPGCquI1JnvNZgtIlZV0iOVPYyRZKsmmAI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; c=relaxed/simple; bh=Ef7oQOGf2sOKgbZOMtFN/mM0DbbDnF1zOUyMqKgCTHg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HUbYlCUn5ciPv7PHGs7JjyllBuE7K6B7uopmeJgpG9kJrAbXg8EiZOzMHrroxkXwB//On7gJlU4BGBMSQe8OBuGvcEZQDa1XM0hmZ+MJ8EievkZ/0mVHRgD8kZNHFI343CmQzAXboubI8fh+GNjSDH5X/hcgzRI6oEzDUbGbrEo= 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=hHQALUwZ; arc=fail smtp.client-ip=40.107.93.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="hHQALUwZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EIBDB850AgkTtmftts7wzgjnMvEQ+9i6/5nZwCrVEW1cn6gmzHi3v7Y5LhFRckIUV0kJBcFXVCMMocDgXie4kFPx16m8BLvxr7CSOUjMEgvR3+ew8Q3AuHNj4yQFMJv77wNMTifHSTqgwefQgF/qfIRmzJm6ADcn91Mnl7Ju07YqHfeJsG1N61XC2A2UI8NJpAyHd7SPI+kEVQPHcu4nSfdQIodETlqs09g7MMlKJsg/albOOO+aKOxSl9CPZyAtu2GATAZpUbv352FuZrvfMNEuXv8x8G8mMq9ufrrpZIP4wCQ1m/C+OeQHjsSecJDHZE19dXjyOS1IaF7B1e5y6A== 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=cvogErjJOwcVk46qfAaJGl6aKvOdsby22Z+cYER8yMQ=; b=fGLDQRw7LKwLi+rFapkKVOSZLk56VX8OVK1OaM+dE3faBrkNon3iLyyFew0STzxF84Gzl3MqnZsUa2yg7DueToQGjHIh9AqAxV87AT1GJYhujEg4gvBNGiazLvxFbwWI/tNrVOZb00kcdhcfDountls/LDBH5wHpZMs1N1msWKt4GiD01CEJ3FuGfsY8xWo0qMVK326d/L6NFVLnIRtXG6PxiFOzjrqXedXAGh7gUkzLa83C1gTPGlRAybRjExUca8ziu3xMKfnE+eLPKKGq50vguzl3APEv/lKwW+C3/G0oZlQgKvHO12WOH5SAUcmbzGv6rSXxSRVvYNN9DuwviQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=cvogErjJOwcVk46qfAaJGl6aKvOdsby22Z+cYER8yMQ=; b=hHQALUwZfgpEBnhSyvfXAYlCspPqhvSHM0doWSPsEAXyYsEC2bQBFTvn2OzY9Q84Ux65HidN+Fr/tW3Vaf5WodNN/38HfvCcyfb1w6N+neuo2t59Qonk1ObGrkRYkpw2oPkFf9UdOPua9p/fuBBIPl7xltV/rpmfvmQVjauyZ4Y= Received: from PH7PR17CA0042.namprd17.prod.outlook.com (2603:10b6:510:323::21) by PH0PR12MB7790.namprd12.prod.outlook.com (2603:10b6:510:289::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:30 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::8c) by PH7PR17CA0042.outlook.office365.com (2603:10b6:510:323::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:29 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:26 -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 , Armin Wolf Subject: [PATCH v7 18/22] ACPI: platform_profile: Check all profile handler to calculate next Date: Tue, 19 Nov 2024 11:17:35 -0600 Message-ID: <20241119171739.77028-19-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|PH0PR12MB7790:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f8c3051-13c3-43f7-9c59-08dd08be9b3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?7TzWH9uXUfksOny6Q1afVG/MtUTkiRZaQ60NipLZX/PZRJkgGTiDd08eZ1Ue?= =?us-ascii?Q?dK8dL2KVNpDqwLiANXm/aGtn3ypg337qgYJp6tnGjilW/KoYoBBjoEwjYVrk?= =?us-ascii?Q?oQywNfSIK7zuaJBGYtO1p7wtdDGgJRonOX5mBetawBaV7O66Gg7j15Mx+qUj?= =?us-ascii?Q?9xwack4dg+rHjXJm0emVnla8gV/E4jQtSLvVIrtKWtXEpHB1OOox7TgtaMHb?= =?us-ascii?Q?vNI1zm1ZJH5MnuH7X/5qS87At8msHmcUxa/FrXSywGNBLsJOf0MQ/F7KV2Lj?= =?us-ascii?Q?kg+xwhcG80k/pgKj2xq493SHYXD2roz3DtnvTXo+iHavC1Sz+I91aSPqAe3S?= =?us-ascii?Q?EgyKyjiq3g9Sk9v8P85xGi9v2KQrornw8XQdXw0SrYzJsDDblDwHBar+1+tr?= =?us-ascii?Q?6m1JAhXQxI7nLeacpHIzbDX1ryi4bYFux/4HYeEK8Eb/P6LdpwP07ypPIuCf?= =?us-ascii?Q?d3tusAmmDdzVPoA1Ylz/wJ+nkesobUed3QULCUi0Qk9nkqiutz0C9qNPqGHL?= =?us-ascii?Q?8+PKlGnDTJWN8hH3QPFZ+fWGXXt+SdU7rwsngBo3KWNKK8ZnG8SOlUW3tIhg?= =?us-ascii?Q?lX8YqFyLeqMLOkFEueXf4d2bgvA7K+ZmhGwFYwy5FWTE6tD+yxwcMMzDERKd?= =?us-ascii?Q?seDrZD2gyXee/6XPrJYvVQW+JN21Lx9SjclWYb0zIYEPbIulCnVdBotj7TrN?= =?us-ascii?Q?MP27rdEz7Xk5S+8A6foaUjezH5LcbSYwqrvS8fEreSiSpxtWrOuy+gXKvZa7?= =?us-ascii?Q?KFna2tHpldAeox6JrI2k5qibbQlHgdBBx5xtQE7aUsgDCmKD4MV62betGVJC?= =?us-ascii?Q?qUGzU9nqnCxoHxuzTFsON1hlW9Eu8r8LNq5UzDA8XUISai8+4rAEc0fFouT1?= =?us-ascii?Q?oL/3mvUQNE7bQ++LQkM4xfF+U/6yAh1zPZMma1zTOeX92CSbP017fMPaRT2e?= =?us-ascii?Q?6/ZghPPjrWd1m0bmhM12jw4r65mxXJ7JTPX/002vFf3JDFy559zJmGUaP/uO?= =?us-ascii?Q?aIws24FaVMMxd1lpi6myFri08BZu+EubkJPgYnfRI/fersAWqVrxIY9mAyVT?= =?us-ascii?Q?NH9KlXhJevihPbfl++9JLAcQAUMlueZLXLPSbIQCURm72Vg1z6TLwWtlcDOx?= =?us-ascii?Q?5iPb1gQS71olR40P1AwJ83ImpLhxf+F6juUjqXbF48xd56aJj6jSifD2OTgR?= =?us-ascii?Q?rlIWfhxwLsC2sD5b0xDwhtJAsoBLKkJUd/31hrElrkfIZqAsmrEcu3LvdSpi?= =?us-ascii?Q?I+Gzrfvm+Bny4xdM06ix09e119yLH9c5DGqQQq7kF1Mj5D78BtYQFWC//QvZ?= =?us-ascii?Q?v7eq4s+oAKSYX/nzrcuwkw50sEJ0euYjrh+z6DtpzUehmKWJzIJF6R7UgcLB?= =?us-ascii?Q?pdfdbOUSv1GNjgee9U+n+6ZTKdP1rTMqGjGDM5Vd1bt/wzlByQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:29.6049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f8c3051-13c3-43f7-9c59-08dd08be9b3f 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7790 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- v7: * Add Armin's tag * Use _store_and_notify() instead of _store_class_profile() v6: * Handle cases of inconsistent profiles or all profile handlers supporting custom. v5: * Adjust mutex use --- drivers/acpi/platform_profile.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index a258f2481246f..ca997f4e9a5cb 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -408,25 +408,37 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); =20 int platform_profile_cycle(void) { - enum platform_profile_option profile; - enum platform_profile_option next; + enum platform_profile_option next =3D PLATFORM_PROFILE_LAST; + enum platform_profile_option profile =3D PLATFORM_PROFILE_LAST; + unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int err; =20 + set_bit(PLATFORM_PROFILE_LAST, choices); 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 (profile =3D=3D PLATFORM_PROFILE_CUSTOM || + profile =3D=3D PLATFORM_PROFILE_LAST) + return -EINVAL; + + 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, + /* never iterate into a custom if all drivers supported it */ + clear_bit(PLATFORM_PROFILE_CUSTOM, choices); + + 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_and_notify); =20 - err =3D cur_profile->profile_set(cur_profile, next); if (err) return err; } --=20 2.43.0 From nobody Sat Nov 23 22:48:04 2024 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2044.outbound.protection.outlook.com [40.107.92.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 372681DA0FC; Tue, 19 Nov 2024 17:21:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036896; cv=fail; b=YroDzWn7bX1SeUwqlLJZ6hmhfLgYFkZM7lo2dyrRkhJ7WB9nbWcS1KzCdapFn56M0zGgxxZQKw2i+84Jv8Egpct1S+vKotXF8H5YqN4HkmBOjZcSdp11RDWaVvBTW9ER3bo4IVzIf9BT89plgqRsiiagZWNRE3taias27xEwCqI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036896; c=relaxed/simple; bh=op0V9TbFKl0DZPBs9kLX+o10ntgPOBPf/FzMzaojh48=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RZYeBdGxnBQrXyG+1oem7Xd6cehzgOd6rYq+qJqeICQwblySXtaA5yEyI1bzptYtJORTwCX3175VsYUQobTqtqPd4COaVLyhzSAVxyKOh+SY8+eUTmRgIhhAOqELab6Wdp3E+yo5DXmpm9ZrFHfcvOSylszzMVCQ9aauQ0PLIt8= 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=x6hO2YJp; arc=fail smtp.client-ip=40.107.92.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="x6hO2YJp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A5qWlj2w1k2sTSLe4DRUkJ2B++9FxtAFHexg3IfNAi9nMuTjeUABdniE5fhuFXkk8uiiLTlig94wPjT2WzNTYgew12xdYtOk/9fFnGjoeuycPUrRgQ7XDtEzj2zODEGgaMhlcR1kBtGFE8Humut4Dcjhy8lc1HC4C0iFRZSgnzVZ9lhS0OlSV3zQdwZmco/DPJGl4roTIr1bgJUHVVHUVS60n/S6JQd6N9g+T/i3o52EXlhibNDBr6I1KslBdWbi0Ugv5x4nDeyxV4jwj5Ix0djSyitlKpU3niLIuM975cgqCDLKWqEzaL75V7cP5cdjlNKDzS7Wilp3SP2t3gMQ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/Vn9zVmIz/MhRGI/WHjMYzAQOjJN7vyUN2I6tvttNBs=; b=NQLPFVJU4V96kRA5+iNEIQa+KeDI3dOXajI4ZkRG3TY4llRgE2pwWzYFB8jIU6cda9UnF9fRPVe6x+NaE6eC0wUI3mVHmM9rSlubQwPoGspqAKo8z3zrX91AeB+1nTIZwmdRE+LzMUUr86OR3zmTuI/bWl9KDMGU2FKB1n3IQTmdjCZwOsj5cnDst4IoU8kKanT8iDcLQRb0yHF+19cg6E3OBBCt6kAskkpy8czvLStsvtSCZb1Stv3KT+N6v3RjcJgIbsmLcYnEC13h/G4n1tv1LgiUe+OsX0QDwNjwIrfHAcHB1is3rWnFrx/WzFVHKsMkggZ7+BgGcBk5pl/pWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=/Vn9zVmIz/MhRGI/WHjMYzAQOjJN7vyUN2I6tvttNBs=; b=x6hO2YJpCm8Vgc5CDZWTvP4EC6GlJx2NcHyn/ju2nPJz0hoU1JWvF/lMLglkjTuyxdNg0V09+OQgrugvlc/NB90QCez5po0MGbDriZbUlhlCbuOtQma+6DaVwIy4EfByZyA9HnNmwa+1nnZmYhl+qxYwDQaOLPZXI4Yg4GxBRIM= Received: from PH7PR17CA0026.namprd17.prod.outlook.com (2603:10b6:510:323::19) by MN0PR12MB6294.namprd12.prod.outlook.com (2603:10b6:208:3c1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Tue, 19 Nov 2024 17:21:30 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:323:cafe::3) by PH7PR17CA0026.outlook.office365.com (2603:10b6:510:323::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:30 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21:28 -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 v7 19/22] ACPI: platform_profile: Notify class device from platform_profile_notify() Date: Tue, 19 Nov 2024 11:17:36 -0600 Message-ID: <20241119171739.77028-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|MN0PR12MB6294:EE_ X-MS-Office365-Filtering-Correlation-Id: 696112f5-8a63-4bc9-aad9-08dd08be9baf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?hlkUdCYmENVSgZRLl5B288GbNX5kz8K6KfD/++d2uMCsrZHqyoVfbL/pH9xT?= =?us-ascii?Q?Ah5qglWl6BS/S0z1ap8swGEchLdNmQLgfN+b7QE6PIVWLXqi7doNxwM0rHK0?= =?us-ascii?Q?EExcB67AqJFTzDUr2X68aEZs73BYRXGZVhra6fxueljAAExEucara5cqETgh?= =?us-ascii?Q?v65KOHzw6+rYIymKt4CFgPKDyBA25HVy+tC5FnGgAj1WUq/fjbROAmKannm2?= =?us-ascii?Q?tjI1VPDvUdJu/63BWaUr0jHgoNF63eZom95rS0+WPVQd3CrZVBMWuRpwt0Lw?= =?us-ascii?Q?NO/rjsRhIiEzKf7gpoE1BjSshtJ+zPI6z/PbbJnAD7mg1S2CvObLZ1BmhGRz?= =?us-ascii?Q?HEnhhgAexRLz3LShfzLInv68cIMEOVQ3lK/tL+yFZMz+T71cgpWHO5CgC3LC?= =?us-ascii?Q?JaQRUCk/QrkVg5d0omRExaAKKJLa1aejMFV0OY7g+ilbGkP0tbflwepMAFVp?= =?us-ascii?Q?df3rVX2NsycujktpyWMgDXf37RhNSsmCauodanAFiS170sktWf5UE2c8oC1T?= =?us-ascii?Q?9c9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Ig/9Mg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:30.3549 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 696112f5-8a63-4bc9-aad9-08dd08be9baf 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6294 Content-Type: text/plain; charset="utf-8" When a driver has called platform_profile_notify() both the legacy sysfs interface and the class device should be notified as userspace may listen to either. Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- v7: * Use class_for_each_device --- drivers/acpi/platform_profile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index ca997f4e9a5cb..e88b355a72112 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -402,6 +402,10 @@ void platform_profile_notify(struct platform_profile_h= andler *pprof) { if (!cur_profile) return; + scoped_cond_guard(mutex_intr, return, &profile_lock) { + class_for_each_device(&platform_profile_class, NULL, NULL, + _notify_class_profile); + } sysfs_notify(acpi_kobj, NULL, "platform_profile"); } EXPORT_SYMBOL_GPL(platform_profile_notify); --=20 2.43.0 From nobody Sat Nov 23 22:48:04 2024 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2079.outbound.protection.outlook.com [40.107.93.79]) (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 495AF1DA2F1; Tue, 19 Nov 2024 17:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; cv=fail; b=JIYZP1grE+jedfFiW/ZRtSW/JBV13NdUXuHgF9bHnK0xpKnXzDpCVNssHZuJk9z5ULlJnjD4nWQGsPtMFE5b2C8PxQMCLk/cvzeaEuP5pUDMKVnbORxGDsQoPeZ5GhXrYEI9zpK0Mgvm5fFFG62oFDNt1xicLxvYio61Goc0/ug= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036897; c=relaxed/simple; bh=tPk8iBelMkozwVP4JFH/dleWnueKOlHY6NqDmg11oOs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sWSGv8b7Xue6JIbr0E1PA2mVreqpAAmD2LsSuIC22jqEeTyr8GczayQwVmp+JofOEDEGRTRbg+/2siPRDPbGffOFgDUajtw8wMy7aX28KYGI1KrRq3dA/O7GrYKlYid1l8T/NXBcYxceG/yLdmqLRnItksN4t7B82zhZVva1k6g= 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=0+a4u+3O; arc=fail smtp.client-ip=40.107.93.79 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="0+a4u+3O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sMIxtv5F4lBCpVRzUuD7cMEjYmNPc33gESPv8p52DfkZFPh8tPdIePCL0C+ksbT4/Si1qPNSvEEeekxBP6+O3O7RXRRi6OIUGor4FPjWl7bwPsLtsRuFtsUo9vE84FIGyHhgiS4GU2qcM0byeSdYGegVg9IKR1yeAWt/7D7FtK/6Z6K5mvsR2xPUQuDsEEgCBEOeODEFeE2mU0MXuS/nZ8wR6e3/RbyyiBoXP/79951GcRg9T8hAHYfW4SfLVlcKIujq/XiKrleVKyO5ufDXJ3RCpx7RaKE80ItYWS9C5J2afmGwI751Gf27ZzPZWH2RmzCCmRAYTPrIsFtMjjAKXg== 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=Gdw4LcMjSmWQqzwh5N3XehtHblWWjBa8rpF+/nMuPGw=; b=PVI9GEukSHWDD1AUOAhdzF/Y9JGZH5YcJLpbb3HY+g1O0HeCTndA21vvrWb+/rNC6dzNNsw7opPjQuoIPPHlU/UjzfuwITI7E3bmLZzBODhQN45qRZxzFRmEG9arfwA6M0pwVlj6dgG/NW/D3EFh7Zsj5jx1tM7d0LKgS6CTI68VR1iwRv4RBRiLF2xZBZ6dIA1QgzCKZFxdUJNP+rPpUuiAPQ3NU8hxeSdixoLJobw8UEtEiZp7tgbCTJwLf1gEwIcc2M7+y8dw1FVzidZ3wb70bafIUSovLlu+fIF4vAdoNYfmkbNcwyZ95OysWeRcrGuvCi4/gIUYZLFJkCbZOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=Gdw4LcMjSmWQqzwh5N3XehtHblWWjBa8rpF+/nMuPGw=; b=0+a4u+3OnOgOiBRVFpA41Vd20k1OL6bIsKcIbi5UjpjuaZ1q3nMA2PJi9Xi233wgvdVGcLuEUY3EHuAsNs4UAWx7vK8CZY7kLy9NKwrQY9GBDVf0W+MbW3uXDIFs1zUhk0tzIkQOaFh5ktxFrfbwpgGTovd2ph7TqG15vtU7hRk= Received: from PH7PR02CA0003.namprd02.prod.outlook.com (2603:10b6:510:33d::31) by SA1PR12MB6800.namprd12.prod.outlook.com (2603:10b6:806:25c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:33 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:510:33d:cafe::37) by PH7PR02CA0003.outlook.office365.com (2603:10b6:510:33d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:32 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21: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 , Armin Wolf Subject: [PATCH v7 20/22] ACPI: platform_profile: Allow multiple handlers Date: Tue, 19 Nov 2024 11:17:37 -0600 Message-ID: <20241119171739.77028-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD2:EE_|SA1PR12MB6800:EE_ X-MS-Office365-Filtering-Correlation-Id: f7072b11-5d1b-4295-8829-08dd08be9cff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mAeT9dXHfaSZ9oBHtIGsi473jTnBGCSLDgqIbRPc3CKj/gpKNcuw/ropT06f?= =?us-ascii?Q?hKywW85CG5UWXfpIy9cb0w+kaTy8Z4m0xWaDQrIJBKA1oc2MJaPtWy+8gOvk?= =?us-ascii?Q?31EAF5p0U7+ezOYyuX9DYXGtX1OKWH1gJO7XIapbaTGa85GDBz3qQh0jA7Be?= =?us-ascii?Q?OMErGD/xk0D1iOdLx9LPoPSCfOF44gw8G5gXYw6s5AS4qNlte4+sLKRhLfJm?= =?us-ascii?Q?5iRlCUN7Yr6spX1JjemdMEoU4AcyMK14NRQkjvn/rO7ojapyI/BNjpH5D9Wr?= =?us-ascii?Q?vTSnq+ZcKhvsgPEsMR+59pnA5OvmqQJhHun0l2XYRjYScYSMRDJebGSZHAvN?= =?us-ascii?Q?hPOch6L5pLzBBaKt8E1eixjtW7dcntcQgMWxsYN5Qx7hbWM6hRe+ceNlhsA4?= =?us-ascii?Q?0ze9tLRqr0FU+MLKC83QM+NquVxJHmMo78RNsmVQ8NBLIiS8ADHZhAb2yhOG?= =?us-ascii?Q?6LiMkPeo7BAwQ/Ol67tCdyGQcnklkeM0E6yG6wSceaOmucZ0QdVO15QHCLxE?= =?us-ascii?Q?C0RzTtkeFcKOn4X5ZpuNeeHinQWVofNbvgB6euZHaZpa2jY0W7vjFgtj+48V?= =?us-ascii?Q?2E+SdkzU1ISefeX1Uw4rQLTcdruwog72GqJ3jpoVWUvTJiu6ThGg7plnI11T?= =?us-ascii?Q?8kt6r5kd03XcmrFdpb6IB1ENL/DQ0eagVHsTfkmS+4YHSYWTw8pHQHATy9XQ?= =?us-ascii?Q?2VWj8ar+Cm0AJ3k/KojyUA0mQf1YhOifm6GuVWhWX870mHSwqSeMkbO9wHCT?= =?us-ascii?Q?C4jAp4Ny+kQAXFa3ozBzWBW6sKec2JMQIn5NDLNCpJaymPorQTAY8c5O4xm5?= =?us-ascii?Q?C4OpqThYHeMtO0HLjIC87B0XgaTJJkV4pLZ82k606M5cQ1xKXa0xfTwAaXGW?= =?us-ascii?Q?mVNFGxflDWXgKSZYtrNnkFy2tU78ujrVNXf1fEafT4sLSTKYEUhRm6bAMQX8?= =?us-ascii?Q?OhYMLhu4x6Pnb9rXpUNEfCupPH0KvXKGTd30u0ND7w7q/kvhFyltwglabDge?= =?us-ascii?Q?6sz9Gae0DU/T3xH6vLK0uhLKLP+1saIFppfibPeep2IaIUUnzDT1f8eC11fV?= =?us-ascii?Q?AZm+E1VlnR4PicEaIWo4+DSq1aKxqH+J64Gt+SGueklgTMCcwWev5cSGfQcr?= =?us-ascii?Q?yTjTGhn9K+DshiLUZJnDsCaqFjWImmTkaqJssb+8rVnzoaLJxlxlAqQ3hNc4?= =?us-ascii?Q?O/ox46ZkamKShkHF7jpN3IpmomqlRtLWqJm8cWn0f35406WICuBOds+w0083?= =?us-ascii?Q?/bxUmy+wQvNYuh5fEvjmkXOLQ09HPuJFbC1t7IaGdIyCxIOKBo3q+ozNv2I6?= =?us-ascii?Q?HriXrScRPcblCtwhb5u1ZcIk7fHosL78g7VgnaYIzQ1w4iAs2RvFBLf4RTnB?= =?us-ascii?Q?rl8jqjgxU0eTD3b4YOHJiXHirbJCygsw58/+/4adogcIPHM0UQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:32.5716 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7072b11-5d1b-4295-8829-08dd08be9cff 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6800 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 the drivers that were already changed remain changed and the legacy sysfs handler will report 'custom'. Tested-by: Mark Pearson Tested-by: Matthew Schwartz Reviewed-by: Mark Pearson Reviewed-by: Armin Wolf Signed-off-by: Mario Limonciello --- v7: * rebase v6: * rebase v5: * reword commit message --- drivers/acpi/platform_profile.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profil= e.c index e88b355a72112..7d774c43f4fa7 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 { @@ -400,8 +399,6 @@ static const struct attribute_group platform_profile_gr= oup =3D { =20 void platform_profile_notify(struct platform_profile_handler *pprof) { - if (!cur_profile) - return; scoped_cond_guard(mutex_intr, return, &profile_lock) { class_for_each_device(&platform_profile_class, NULL, NULL, _notify_class_profile); @@ -465,9 +462,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 /* create class interface for individual handler */ pprof->minor =3D ida_alloc(&platform_profile_ida, GFP_KERNEL); @@ -483,8 +477,6 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) =20 sysfs_notify(acpi_kobj, NULL, "platform_profile"); =20 - cur_profile =3D pprof; - err =3D sysfs_update_group(acpi_kobj, &platform_profile_group); if (err) goto cleanup_cur; @@ -492,7 +484,6 @@ int platform_profile_register(struct platform_profile_h= andler *pprof) return 0; =20 cleanup_cur: - cur_profile =3D NULL; device_unregister(pprof->class_dev); =20 cleanup_ida: @@ -507,8 +498,6 @@ int platform_profile_remove(struct platform_profile_han= dler *pprof) int id; guard(mutex)(&profile_lock); =20 - cur_profile =3D NULL; - id =3D pprof->minor; device_unregister(pprof->class_dev); ida_free(&platform_profile_ida, id); --=20 2.43.0 From nobody Sat Nov 23 22:48:04 2024 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2081.outbound.protection.outlook.com [40.107.223.81]) (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 C25F31DD88B; Tue, 19 Nov 2024 17:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.81 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; cv=fail; b=qzB96egYEfCxLn3UM1EqnS3hVYiB5gux0obooEd0ZddEQl5cJJguI4uQoZS1XcXO2nkWJUMb+Hdc5po85aWYvfBrn2XPwdxVllTl/qS6DVK8j/1r8tQqEyQn7l/NWCE9rHo1qJsqbh/A+sxsdXNUNBEoZTiyd83shD2aL4Osqio= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; c=relaxed/simple; bh=+bdiJ1Eyfn9MTcWLW4JH4T1uWT0phudmlVUuiFZMgKQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MoLgyFPP6mHiOKm9OAqBvN2bEKYBSeqakdEJ5rpX7LMZAMGAevmVbwrKVjgRpLKU0ZuGMVXHgO56w8K5C389ADAEScWaTk79+fjOD//qCLxffnqWQjIg2TlRCQISY+57CpAjrrrwLJqnUMtFljN+ZYEl8Gs7gnhyy3pCcN5InLY= 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=1/69Iamr; arc=fail smtp.client-ip=40.107.223.81 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="1/69Iamr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pdq5/xnYLbfbQaI7k+12aoRogOn719rY3OqWAlAxObP5dORDVWF3mY+xK0sqagoyl31DJ6k25MObw5BYutPlcvGA8/3KpIq3zwuGWOlJ3mnshDz6W41E4tmJd/wcOPxeJHJxseN9WgdBksLMUQPTz3iQogUCd3FPMJJRJLyEZo9gUsipQ4EHVY+FpphQkgdf/q7ydQjjbLQFKKK3DLHQ231B4z79tQR0yVDHK0LOUxa5wCkqpAn9eVtSIprErI6DXkqWRLE1wFcU/D8V/gFSkpfKBLW3ZDBbKrzVoN6GeGi8LwsTvCoi9z0w1s42K0s32grC6WNs1KHtYdiHkAWb6w== 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=mE5xib2maNaIrlY03QYSAc2xN6cAxJyeeTXImIzPjlg=; b=quLt7Flxk6aoHRLkqVSSq5oGUL7Q566d6cV6eCwxC84ftcpBSfD8ymodn67J7HglUEhGNuqRc5Hkgs29/bNitWLha+BcmrGH3RK4iQb+oVelJPy7AQS9ACjrTDUKra7bwjwnf3lxWJGl66p1Nx3Itd5ihHLWO9VSRmYu6eO4SnXfsL5WLoVFwqDALNuHmccs7MNb4uGwntSo5h7ODzKxrEfOK+R/rYbmeQwslo9fPDMYd2Us/GjwtMGuV4JR4sDRUBiLjdzu+kCC/RUXnFmR2KEKB0fk2F349ER9xMhoaIHKGMxHUrrTvyBS7Hl/7eLNW64csZFvWbGc4vvxlWluVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=mE5xib2maNaIrlY03QYSAc2xN6cAxJyeeTXImIzPjlg=; b=1/69Iamr5wxi8wf7I7e9tw24EldmH6hHFZ7QWY9y+yEr5YtX+Xlh8ZOJ9v1X0Vp7f2LEGtYUr8I2+12NXizF842eDFCRuCzlia+v2STbkWyrek8dwj/F+Rbe/7arGZsmqkEtR4OIZPen7PpN7zN1Ll/NKrvcTFkZ4ou4E5Xi7tA= Received: from SJ2PR07CA0010.namprd07.prod.outlook.com (2603:10b6:a03:505::27) by SJ2PR12MB8035.namprd12.prod.outlook.com (2603:10b6:a03:4d3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:34 +0000 Received: from CY4PEPF0000EDD4.namprd03.prod.outlook.com (2603:10b6:a03:505:cafe::20) by SJ2PR07CA0010.outlook.office365.com (2603:10b6:a03:505::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.23 via Frontend Transport; Tue, 19 Nov 2024 17:21:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD4.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21:34 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 19 Nov 2024 11:21: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 , Armin Wolf Subject: [PATCH v7 21/22] platform/x86/amd: pmf: Drop all quirks Date: Tue, 19 Nov 2024 11:17:38 -0600 Message-ID: <20241119171739.77028-22-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD4:EE_|SJ2PR12MB8035:EE_ X-MS-Office365-Filtering-Correlation-Id: dec3c9b0-0bac-4afc-0781-08dd08be9e0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?efuexn/vu9BtnldNg8eCRyNn4GMhv8vMjy/6FqgscQn4/nJ5Xgq6/5QNm2CO?= =?us-ascii?Q?QtfqOrnqAGPnyZRHWazMkI3Qimo8AlYIXZduW/DFOI2NQaDkPdloqACd1eYS?= =?us-ascii?Q?FYxtWp4ZMUiyN3P5mBQatJnHxVSZoNrIDl9dWc0O2rpJbOhEHDn3t67966TK?= =?us-ascii?Q?qIDCHx1JVuNcccJeh03bJLKcofKP3M0sJG/pAWGxgU9SK+jP9bEGQEGQPu8J?= =?us-ascii?Q?0uQCQTd4x/jdIEG4umGR/unb+buUt2P69jQtQ3O4s90BfDxNYzSpSfxCPYqa?= =?us-ascii?Q?eTyANja1R/opDGhEMsV+eP2EzGw3cTjvuNs+KuOw/VRz6ciUWWdUHKSNxULO?= =?us-ascii?Q?FQMVpYwHisxWW2kaqhbx17SRfkJJLr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KiRv6eHwiIjMq77KmPoryCzY4nvNWVdRQveDCHOdRHDdxDnSSzumbKP6V+e?= =?us-ascii?Q?iE/qpMiVxXm+o1We4SyzhMPdfA6lZuJGiJqnnT0ixEqO0nJePSEHUMlcnz50?= =?us-ascii?Q?VJjBMrUTWS5DPVa4eO0+aGUscHGXha2bC3VhIyDtrEURGLEL+Q=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:34.3000 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dec3c9b0-0bac-4afc-0781-08dd08be9e0c 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8035 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Tested-by: Matthew Schwartz Acked-by: Shyam Sundar S K Signed-off-by: Mario Limonciello Reviewed-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 745d0e013a330..44461f2f35e82 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 a79808fda1d89..64ab532550ac3 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -797,7 +797,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 Sat Nov 23 22:48:04 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2048.outbound.protection.outlook.com [40.107.236.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8F8B1DD885; Tue, 19 Nov 2024 17:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; cv=fail; b=nxLtkrHJ1Lw756pvacd0/v4xgLZ4eTNDha/GoAvDyk3if+RMDIfWjF5ighCi1apEoXZWvFsJUbpiWQRiQbi7IAPhB9cRlXuNBPCLSIN6QRH33dSC1q423/fvw9EXm4PzVwsj/XuN73y+xNMspa9mTnOgAIPboDownJQwvOrb4TU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732036901; c=relaxed/simple; bh=/ijD+PUIhicssB7moXneLFJ/twRbt+uNOZkim5O1JiU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N6fhI5uzKnseO9/jhgalbbNdh+W36RcTgSHzZ5PHyaCsMdN7qQxKqV3+5WDJUBlZYtEDB2LKgh6U+vqF6yXcf54Kuvf3diKryd2h5VyxacnaBEeRe+n+g/5ThQDQHjFi8C8mn+Zg47avn81E5VXNBXa+2KB59vuAertICdFQyjI= 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=XOrnoCeK; arc=fail smtp.client-ip=40.107.236.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="XOrnoCeK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EiS6MEI+dNMpYjeYKRcxJSuZI9092036lt5KuuHHPffiPJEkV4366uqilz7zReOcPhB4vhkp3sDwIHGGFwKgzp5RaLjKuYX5BbqBNITl0xWD4TlTGi0GqHyYuOQ+OgqCyv8bnx/LT6kfzIKwuKz6zjEsbaEZgqU88IxuKZg0fELw7iRMywtix4kR6pNVRsn1XM17zcv4PgueYCeHRoLXdVshlizFO9Zl1Aga/PFEkKFG381NeuROAxnN6RABteXp9RnOQdq/4aPUQmdujDJKInPzLPWA2OXLaHK4VihPb/LCSAzP42/RYNAOxSmxiFMNgxsP/ksgbh/WwOWLQCY8OQ== 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=4AzDiAVdPZo1X4zMIDEdTxASEFf9b61AT6G4X2TX4TA=; b=m+h0ldZE69dK95mC8oXZo8UEz+ZP5Nq2g9F0qKikUtdzKudkTg9t6LNwVbGLtEUV69APLthzUFMfDMysitAbFfUF6X/PFjGF+fFVdacfniLR2ogrIwZQlm/NEwixDx6gwe8osk01su9lrlslWrHyAzmWrBcNTFGOoVYWPXHhkcE4bLOoICVhJoXDD8CfAGVxM2tZKEigOGKeIBxKVpjL1/t/TZhv5yHoKP4wsR159bdV8WaH8OShabC4ENFn/MB22oJ5coPyUAOjkYWQKj7TWRQvBYfLSIJu4Zut8rHN1LI8tv+9JZn+PPIqnsyHMkjGq6h2e3Z9wfOfcyFcWF0i4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.12) 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=4AzDiAVdPZo1X4zMIDEdTxASEFf9b61AT6G4X2TX4TA=; b=XOrnoCeKMZnh1imad37NdUAs9yCRLNMvy6ypNHk0tRjH15qNiLFVwSfoe7XyWvDifbmJhMfNrzYPmBYZinkqAygPvudnLMLIrLv22zIN3eOWkF2KExCeJ97ivcXAsud3PTzYG1D0SfYZdw37USxuU+9UQ7VJ6GeBlXM1WNp9yW4= Received: from PH3PEPF0000409D.namprd05.prod.outlook.com (2603:10b6:518:1::50) by PH7PR12MB7377.namprd12.prod.outlook.com (2603:10b6:510:20c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.21; Tue, 19 Nov 2024 17:21:36 +0000 Received: from CY4PEPF0000EDD5.namprd03.prod.outlook.com (2a01:111:f403:f912::1) by PH3PEPF0000409D.outlook.office365.com (2603:1036:903:49::3) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.24 via Frontend Transport; Tue, 19 Nov 2024 17:21:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.12) 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.12 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.12; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.12) by CY4PEPF0000EDD5.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8158.14 via Frontend Transport; Tue, 19 Nov 2024 17:21: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, 19 Nov 2024 11:21:33 -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 , Armin Wolf Subject: [PATCH v7 22/22] Documentation: Add documentation about class interface for platform profiles Date: Tue, 19 Nov 2024 11:17:39 -0600 Message-ID: <20241119171739.77028-23-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241119171739.77028-1-mario.limonciello@amd.com> References: <20241119171739.77028-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD5:EE_|PH7PR12MB7377:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c272c68-6453-45b4-46da-08dd08be9f0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?5SPm2S8EHlrzBwDV6HQmAmR21vVjw4TnDSN94dlnya9rhbEM/nkRuCxdAoUM?= =?us-ascii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ovMYJNyVECCL9rxzr?= =?us-ascii?Q?KLr+hmCxtfBbDiW1crSKqSS6YKPijiZc8GQJvpq8d8Ytu83PfrGm3xprBHHI?= =?us-ascii?Q?P3gr95YPjXM9mDyJxPBIyvqu5jmzjKNFTxyGI6QgPCdEThnSOhBpWk4kXae4?= =?us-ascii?Q?bbfhuc9BAAeSUcHr5DzZnJsVok/9/F/4bLn/NGKWMWGBrDOQsVuRlqmuRvC9?= =?us-ascii?Q?G0Owch2dP0MW8OtdS/IxyQesHJkNIBldmQhKlKmYXM3A0EJXgCvxuE5RIuAf?= =?us-ascii?Q?tymhRrYDz2Nht8XNer9BMzWHiJuxRWNgBt4nBB1e3ZVIA/WPeHrBuRwRr1Ha?= =?us-ascii?Q?IaT2Pspb2zZA3Z0BrquO49RjSW0QDzzHZgGmsAskVcgyO6pQZU6KWRhNgLft?= =?us-ascii?Q?fZ7WMxHdFe3w7ltRXGoGKz5DJ1sCNeg8FNFZs2FLMhr8Gk4FRNOS+Gra5PW9?= =?us-ascii?Q?XusFGBKgszOXqHs3gOZHcweWIhszjy5Blr8ZmVfMYsM4L4oLqQ=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.12;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:atlvpn-bp.amd.com;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2024 17:21:35.9728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c272c68-6453-45b4-46da-08dd08be9f0b 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.12];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7377 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Mark Pearson --- v7: * Add tag * Add description for name attribute v5: * Fix some typos --- .../ABI/testing/sysfs-platform_profile | 5 +++ .../userspace-api/sysfs-platform_profile.rst | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform_profile b/Documentati= on/ABI/testing/sysfs-platform_profile index baf1d125f9f83..125324ab53a96 100644 --- a/Documentation/ABI/testing/sysfs-platform_profile +++ b/Documentation/ABI/testing/sysfs-platform_profile @@ -33,3 +33,8 @@ Description: Reading this file gives the current selected= profile for this source such as e.g. a hotkey triggered profile change handled either directly by the embedded-controller or fully handled inside the kernel. + + This file may also emit the string 'custom' to indicate + that multiple platform profiles drivers are in use but + have different values. This string can not be written to + this interface and is solely for informational purposes. diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Docum= entation/userspace-api/sysfs-platform_profile.rst index 4fccde2e45639..0aa384c75095a 100644 --- a/Documentation/userspace-api/sysfs-platform_profile.rst +++ b/Documentation/userspace-api/sysfs-platform_profile.rst @@ -40,3 +40,34 @@ 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 +common between all drivers to the ``/sys/firmware/acpi`` interfaces. + +This is to ensure there is no ambiguity on what the profile names mean when +all handlers don't support a profile. + +Individual drivers will register a 'platform_profile' class device that has +similar semantics as the ``/sys/firmware/acpi/platform_profile`` interface. + +To discover which driver is associated with a platform profile handler the +user can read the ``name`` attribute of the class device. + +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 differs the +platform profile handler core will display the profile 'custom' to indicate +that the profiles are not the same. + +While the ``platform_profile`` attribute has the value ``custom``, writing= a +common profile from ``platform_profile_choices`` to the platform_profile +attribute of the platform profile handler core will set the profile for all +drivers. --=20 2.43.0