From nobody Fri Jul 24 22:59:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 2C4B2307AE3; Wed, 22 Jul 2026 13:16:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784726170; cv=none; b=lfYQtkSL++4j+mFonjWaxfsOKu0v5iGdp0hzMX9WPnAJ70Ft9aeBs2Qsikkw18RUf3ljaSwjZzBkbaz40aCJMmoensp7ZHLX12GUbX58/UT05qyzUh/tv3pDINLYGwoAyEibWGwZSS0ciSJZdFZNOPVMYDEicaZCsoJ/XRFs6Tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784726170; c=relaxed/simple; bh=Kvq8pBUXd3SBMsFtQJvupDCkQGaQzbTYejkgqHTe8cM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XIgXuG74UNT4Sh5IFPvza84XgomlE+imQr4YzybbVy2ZWkhiEEyc8hmF0K6YzNyIx1iPqCmXckVDi4g5iiKvIgthn3WoZ0DwgFhs6GE1V9KMcFwBXbGjp7DhC0K320PbTHcWTg/DnHOToK6Y6Kgx3PISLWjAqNZYj6tdDScFSuA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bFdFfvRN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bFdFfvRN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D4CA1F00A3E; Wed, 22 Jul 2026 13:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784726164; bh=9jYqPRqPWJvx7ZI06P13taAbeaiEKCjE8/dqxPgQSMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bFdFfvRNNd6u3G5CYOcSwlRx50icWAnYzWSUudwmZkD9LgAmJmaZC7eUQMW1GS6Fc 8Ycr0CW2kzh7tnjP+nY6yOGSXYsXHNdDpKEwF1W0SnU0uBkymhA9LNXDJKIpYHtw1o m7/Dxh1uc00KDvYLdA9q9h82mAnhsOrCYeCoywVP5KrOAlly+oI/aMVt+qO8+CW6YE Krt9oe5w139VXsT77EgGSRHWvttB7m4D0jjVhZSJFv/4c0hpvqY+Jt+M1wJ7Lbo8pj B60R9QgcTfx2V6XvMubSKyUShZ43EHUQlSQb2NNlku9HRMfr+f366G9ju8Xm3MRllJ KpF80qIS/VYhA== From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , acpica-devel@lists.linux.dev, "Rafael J . Wysocki" , Saket Dumbre Subject: [PATCH v2 1/4] ACPICA: Fix PCC OperationRegion command offsets Date: Wed, 22 Jul 2026 14:15:50 +0100 Message-ID: <20260722131553.2117835-2-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260722131553.2117835-1-sudeep.holla@kernel.org> References: <20260722131553.2117835-1-sudeep.holla@kernel.org> 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 Content-Type: text/plain; charset="utf-8" ACPI 6.3, section 5.5.2.4.7.3, states that the PCC Operation Region is associated with the region of shared memory that follows the PCC signature. The generic and extended PCC shared memory layouts include the 4-byte signature at offset 0, so their raw shared memory COMMAND fields are at offsets 4 and 12 respectively. Since AML field offsets for the PCC OperationRegion are relative to the region after that signature, ACPICA must look for those COMMAND fields at OperationRegion offsets 0 and 8. Adjust the generic and master subspace command checks to use those OperationRegion-relative offsets. Otherwise writes to the COMMAND field can fail to invoke the PCC address space handler at the offset described by the PCC OperationRegion definition. Fixes: aa6ec56b574d ("ACPICA: ACPI 6.3: add PCC operation region support fo= r AML interpreter") Signed-off-by: Sudeep Holla --- drivers/acpi/acpica/exfield.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c index 9a55524ed8f4..a7fac63938b3 100644 --- a/drivers/acpi/acpica/exfield.c +++ b/drivers/acpi/acpica/exfield.c @@ -45,12 +45,13 @@ static const u8 acpi_protocol_lengths[] =3D { =20 /* * The following macros determine a given offset is a COMD field. - * According to the specification, generic subspaces (types 0-2) contains a - * 2-byte COMD field at offset 4 and master subspaces (type 3) contains a = 4-byte - * COMD field starting at offset 12. + * According to the specification, the PCC OperationRegion begins after + * the PCC signature. The raw shared memory COMD offsets of 4 for generic + * subspaces (types 0-2) and 12 for master subspaces (type 3) therefore + * appear at OperationRegion offsets 0 and 8. */ -#define GENERIC_SUBSPACE_COMMAND(a) (4 =3D=3D a || a =3D=3D 5) -#define MASTER_SUBSPACE_COMMAND(a) (12 <=3D a && a <=3D 15) +#define GENERIC_SUBSPACE_COMMAND(a) ((a) < 2) +#define MASTER_SUBSPACE_COMMAND(a) (((a) - 8) < 4) =20 /*************************************************************************= ****** * --=20 2.43.0 From nobody Fri Jul 24 22:59:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E30B927F017; Wed, 22 Jul 2026 13:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784726173; cv=none; b=Sn8ZdA+G+xQp3oYDm/wh01PWdETn2oX0B/IfdzkSjoWBgx9s0F8OJJt/8AQBq6ANE9ah7XgjuRd2nZ62WNkmIblaQGnOpogbiRBDeyq/dmoFotodpQERaiTKku7L68NXa1Elax8JVj0WdTvVam4bR1P8LZxe2o6UFKDITvHZiqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784726173; c=relaxed/simple; bh=vDGO4jkVYgbdguQucCUIyH2yN1ariNn8DCcJSyEvg3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BBgRdHJFn6WIoMi2+9yOA8W8Q5rJUh21j57qMsHN7yUTMu9FGFXVRRfw32KpYz8hl0HP8ZLxjxN8GP1AXhnBbtHd+o1NBrkFcEsPElWofHp84Ld1BBoTeKnzYz9EzvI9SjfD7PSSUIU/yobXfYM2GIZVH3v7MG8gkLjtDxSgoH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RdDtk8gL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RdDtk8gL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B59E1F00A3A; Wed, 22 Jul 2026 13:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784726166; bh=MKhiqHv4U+5kPiwfByYM3WQ7bJnspf8MaWtepG3bUBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RdDtk8gLSfWP3iYp4f8Cc/shtnPEGHZocvdMzKnm+nt100325Q3s4HELVuEL8lnoJ DRIO6p9hyk76VVJHoScknU3DjeeVYF8TuewwlNAKR3Od4C5iGIpb/cgsViYLxFsLEm g75LpcgiWeErH6pFoyOqjEDDrrHJ4QmawmQNnWp+JH7prIYfelh/iAyk52QrpLKH9K 84fKWczijedZ1tFRH2u+ny9LZrAF9d6CtoCKRbXISBohnfm8GibTaA0A+dLJNGMhdf F7tRIwk60NN85ma23F2XEffPxTZTEuJppt/hxsT27CGgr1OkJ8GCc8VHMu/AQ9vLHB 8H2pbJd6Q5Iuw== From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , acpica-devel@lists.linux.dev, "Rafael J . Wysocki" , Saket Dumbre , Huisong Li Subject: [PATCH v2 2/4] ACPI: PCC: Preserve shared memory signature in OpRegion handler Date: Wed, 22 Jul 2026 14:15:51 +0100 Message-ID: <20260722131553.2117835-3-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260722131553.2117835-1-sudeep.holla@kernel.org> References: <20260722131553.2117835-1-sudeep.holla@kernel.org> 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 Content-Type: text/plain; charset="utf-8" ACPI 6.3 introduced PCC OperationRegions. Section 5.5.2.4.7.3, "Declaring message fields within a PCC OperationRegion", states that, for all PCC subspace types, the PCC Operation Region pertains to the region of PCC subspace that succeeds the PCC signature. Its length therefore excludes the 4-byte signature. The PCC address space handler currently copies the OperationRegion buffer to and from the start of the shared memory. This overwrites or exposes the platform-populated signature and omits the final four bytes of the OperationRegion. Offset the copies by the size of the signature and reject an OperationRegion that does not fit in the remaining shared memory. The example added by commit 77e2a04745ff ("ACPI: PCC: Implement OperationRegion handler for the PCC Type 3 subtype") incorrectly included the signature as an OperationRegion field. A Type 3 OperationRegion containing a 100-byte communication area is declared as follows: OperationRegion (PFRM, PCC, 2, 0x70) Field (PFRM, ByteAcc, NoLock, Preserve) { FLGS, 32, LEN, 32, CMD, 32, DATA, 800 } This contains three 32-bit fields followed by a 100-byte DATA field. The fields correspond to the Type 3 shared memory layout in ACPI 6.3, Table 14-372, after excluding its 4-byte signature. Cc: "Rafael J. Wysocki" Fixes: 77e2a04745ff ("ACPI: PCC: Implement OperationRegion handler for the = PCC Type 3 subtype") Reviewed-by: Huisong Li Signed-off-by: Sudeep Holla --- drivers/acpi/acpi_pcc.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/acpi_pcc.c b/drivers/acpi/acpi_pcc.c index 438c67189511..9881c9ee293d 100644 --- a/drivers/acpi/acpi_pcc.c +++ b/drivers/acpi/acpi_pcc.c @@ -28,6 +28,7 @@ * to PCC commands */ #define PCC_CMD_WAIT_RETRIES_NUM 500ULL +#define PCC_SIGNATURE_SIZE sizeof(u32) =20 struct pcc_data { struct pcc_mbox_chan *pcc_chan; @@ -74,6 +75,14 @@ acpi_pcc_address_space_setup(acpi_handle region_handle, = u32 function, } =20 pcc_chan =3D data->pcc_chan; + if (pcc_chan->shmem_size < PCC_SIGNATURE_SIZE || + ctx->length > pcc_chan->shmem_size - PCC_SIGNATURE_SIZE) { + pr_err("PCC channel-%d shared memory is too small.\n", + ctx->subspace_id); + ret =3D AE_AML_REGION_LIMIT; + goto err_free_channel; + } + if (!pcc_chan->mchan->mbox->txdone_irq) { pr_err("This channel-%d does not support interrupt.\n", ctx->subspace_id); @@ -97,14 +106,17 @@ acpi_pcc_address_space_handler(u32 function, acpi_phys= ical_address addr, u32 bits, acpi_integer *value, void *handler_context, void *region_context) { - int ret; struct pcc_data *data =3D region_context; + void __iomem *pcc_opregion; u64 usecs_lat; + int ret; + + pcc_opregion =3D data->pcc_chan->shmem + PCC_SIGNATURE_SIZE; =20 reinit_completion(&data->done); =20 - /* Write to Shared Memory */ - memcpy_toio(data->pcc_chan->shmem, (void *)value, data->ctx.length); + /* Write to the PCC OperationRegion after the shared memory signature. */ + memcpy_toio(pcc_opregion, (void *)value, data->ctx.length); =20 ret =3D mbox_send_message(data->pcc_chan->mchan, NULL); if (ret < 0) @@ -125,7 +137,7 @@ acpi_pcc_address_space_handler(u32 function, acpi_physi= cal_address addr, =20 mbox_chan_txdone(data->pcc_chan->mchan, ret); =20 - memcpy_fromio(value, data->pcc_chan->shmem, data->ctx.length); + memcpy_fromio(value, pcc_opregion, data->ctx.length); =20 return AE_OK; } --=20 2.43.0 From nobody Fri Jul 24 22:59:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5736F2AD2C; Wed, 22 Jul 2026 13:16:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784726172; cv=none; b=b5dxJVm+iQTx1wR3Lx6/n77OB3HBbqIG9wnxTSYGJ8vbwlqUCP/qJeoGJ62yGJvNCpIkk7cMEQzCqg4HsaxgUBA3ZDcLhnLXQeqYD0mM4WU77EkwxAyF9UACO3mf9l84xmRcracGFEvCCKT20aCCoXB9wYhebOT8uG1j5k52RgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784726172; c=relaxed/simple; bh=93/tmh7jjtpgdkiKYiocCIlJWs4896y6WOrXAHWLNB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dEn+BUX+nXCoyUxf2RmWtyhq2F9FnSpZGjQnTxxgvDOGm65rJaOqDh7CU2y8omxeMsVrKwNobapJTlGgSEDqnpwSkjZs80Yc/5V12rVjPoY7LyYEh+itvM46jrxrILZLILxXBz/we8ofMJ1ZXQUN1OfJVrHdrtS0CJiDf21/950= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I8mFsaj2; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I8mFsaj2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A03E11F00A3D; Wed, 22 Jul 2026 13:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784726167; bh=L7y/zH/SHQn9M6v/cDEuG44N6cqBqTzg/6b4GHAmU+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I8mFsaj2lhrR8UVWoyA6CBvwGsnWiyuCl/8r9dDQGMFrkuZTtEqrEy4g9jIcphLm1 Uyf3iDes7V0DpVxq1u0KXhM0/02Q4Ty9uE5GGgbiI1oI7pAwKb13TtmO4WO9KgPyRu 1Y0RZEt/Vn2/J9kq/GXB1hrbm7tvkZCoFzKEU0sK3ND2h63yWYYUFcW0o5WEJiHfWI Z59lBxUH5jD/cVG96WrQXWuaDs4/lwV1+FLRHx3cchDRVyvWJmA76oDmkeVds0ZPqQ CBJIAWDOwpzZrvP2PI8IBBgUIOwtxxgImAk7CRFlTXs19W8DxQ5oVGarAibGzjWvEK 8km9cZp2l0QDA== From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , acpica-devel@lists.linux.dev, "Rafael J . Wysocki" , Saket Dumbre , Huisong Li Subject: [PATCH v2 3/4] ACPI: PCC: Free channel on OpRegion deactivation Date: Wed, 22 Jul 2026 14:15:52 +0100 Message-ID: <20260722131553.2117835-4-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260722131553.2117835-1-sudeep.holla@kernel.org> References: <20260722131553.2117835-1-sudeep.holla@kernel.org> 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 Content-Type: text/plain; charset="utf-8" ACPICA calls the address space setup callback with ACPI_REGION_DEACTIVATE when a PCC OperationRegion is torn down. The PCC setup callback currently allocates a fresh pcc_data and requests the mailbox channel before looking at the function argument. If ACPICA deactivates a region, this can leave the existing region context and mailbox channel unreleased, and may also request a channel during teardown. Handle ACPI_REGION_DEACTIVATE before allocation. Free the PCC mailbox channel, release the region context and clear the context pointer. Fixes: 77e2a04745ff ("ACPI: PCC: Implement OperationRegion handler for the = PCC Type 3 subtype") Reviewed-by: Huisong Li Signed-off-by: Sudeep Holla --- drivers/acpi/acpi_pcc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/acpi/acpi_pcc.c b/drivers/acpi/acpi_pcc.c index 9881c9ee293d..57d13b25c1d6 100644 --- a/drivers/acpi/acpi_pcc.c +++ b/drivers/acpi/acpi_pcc.c @@ -55,6 +55,19 @@ acpi_pcc_address_space_setup(acpi_handle region_handle, = u32 function, struct pcc_mbox_chan *pcc_chan; acpi_status ret; =20 + if (function =3D=3D ACPI_REGION_DEACTIVATE) { + data =3D *region_context; + if (data) { + pcc_mbox_free_channel(data->pcc_chan); + kfree(data); + *region_context =3D NULL; + } + return AE_OK; + } + + if (function !=3D ACPI_REGION_ACTIVATE) + return AE_BAD_PARAMETER; + data =3D kzalloc_obj(*data); if (!data) return AE_NO_MEMORY; --=20 2.43.0 From nobody Fri Jul 24 22:59:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 20F0D33E37A; Wed, 22 Jul 2026 13:16:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784726172; cv=none; b=a7dgvcuTW+66TyBMkRqxbIm+Y5NO0mkJNdXZhx6LPNiX1sNlIa1swX0uc2TfjHfpsf5osP0EP3scuq9ObrqVRcIb83fPc+D2DcSgnrrTa2tUp8NEpYFukek3VeN4PiNPVgFSt0HIH6FDFBUZCKwTF2PD/xw+kL0k1Q7kt5K229s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784726172; c=relaxed/simple; bh=fULks90RtRceuUJcZ14mCt0FNHR9InBzFoqOp+OXWTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PPr7ZOLYQTHBoQRa8lAJYwMXWp1ws8hOKvLVLysSRlzLLzki+P3xMSBbDfnUr/GUM5iA6jDAkDWLUhV1l637aCmxdTPwG1yq8bkIlrsX9Og2xYqHr/VA/NgGzNHh6ao0EbpVDZ9lwEUKI9gL3pyrw5zSbMt6ERqkUITWV5RBkmU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eVh7H7V9; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eVh7H7V9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 432F81F00AC4; Wed, 22 Jul 2026 13:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784726169; bh=zCyrRMfzhOIUjv0cKHPXUvAY98WsF24GT8xrQP9NKeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eVh7H7V9iPbDfbFGtYjlmm74GXpQO1La4DkB4RaE5O1kw8AreoBCrYcHvdxAryHPM Fw9Ez47HO09ghj73QK9P9ek1isTUeSjTE3u/UuQmaDhckoqofWX2LcUcsQ47pxLSVq MJVTQacgQEQnxnXiMKrjjQT71ISeX89Q5nC5DymSN+IR7hg17N021b5eNnQND0VP9j rQ8UeKyF5i+DyWE0UQcXpP8bu86M7KUV/MvM4KWxU1a8wxQ8DOoeDFoLB2NPYeGNvh gEc+Hbbz+gPd2GA101vDTItJLsK3zPpDWF207a7tzV6QTU4bk4ewGNs51YLE9WPcJ5 LiGbTtyvPRT2g== From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , acpica-devel@lists.linux.dev, "Rafael J . Wysocki" , Saket Dumbre , Huisong Li Subject: [PATCH v2 4/4] ACPI: PCC: Cache OpRegion command timeout Date: Wed, 22 Jul 2026 14:15:53 +0100 Message-ID: <20260722131553.2117835-5-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260722131553.2117835-1-sudeep.holla@kernel.org> References: <20260722131553.2117835-1-sudeep.holla@kernel.org> 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 Content-Type: text/plain; charset="utf-8" The PCC OperationRegion handler computes the same command completion wait timeout each time it sends a command. The timeout is derived from static channel properties, so compute it once when the PCC channel is set up and store the millisecond value in the mailbox client timeout field. Use the cached timeout when waiting for the OperationRegion command to complete. This keeps the timeout calculation in one place and avoids recomputing it for every command. Reviewed-by: Huisong Li Signed-off-by: Sudeep Holla --- drivers/acpi/acpi_pcc.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/acpi_pcc.c b/drivers/acpi/acpi_pcc.c index 57d13b25c1d6..345f233d77cd 100644 --- a/drivers/acpi/acpi_pcc.c +++ b/drivers/acpi/acpi_pcc.c @@ -50,10 +50,11 @@ static acpi_status acpi_pcc_address_space_setup(acpi_handle region_handle, u32 function, void *handler_context, void **region_context) { - struct pcc_data *data; struct acpi_pcc_info *ctx =3D handler_context; struct pcc_mbox_chan *pcc_chan; + struct pcc_data *data; acpi_status ret; + u64 usecs_lat; =20 if (function =3D=3D ACPI_REGION_DEACTIVATE) { data =3D *region_context; @@ -103,6 +104,16 @@ acpi_pcc_address_space_setup(acpi_handle region_handle= , u32 function, goto err_free_channel; } =20 + /* + * pcc_chan->latency is just a Nominal value. In reality the remote + * processor could be much slower to reply. So add an arbitrary + * amount of wait on top of Nominal. + */ + usecs_lat =3D PCC_CMD_WAIT_RETRIES_NUM * pcc_chan->latency; + data->cl.tx_tout =3D DIV_ROUND_UP_ULL(usecs_lat, 1000); + if (!data->cl.tx_tout) + data->cl.tx_tout =3D 1; + *region_context =3D data; return AE_OK; =20 @@ -121,7 +132,6 @@ acpi_pcc_address_space_handler(u32 function, acpi_physi= cal_address addr, { struct pcc_data *data =3D region_context; void __iomem *pcc_opregion; - u64 usecs_lat; int ret; =20 pcc_opregion =3D data->pcc_chan->shmem + PCC_SIGNATURE_SIZE; @@ -135,14 +145,8 @@ acpi_pcc_address_space_handler(u32 function, acpi_phys= ical_address addr, if (ret < 0) return AE_ERROR; =20 - /* - * pcc_chan->latency is just a Nominal value. In reality the remote - * processor could be much slower to reply. So add an arbitrary - * amount of wait on top of Nominal. - */ - usecs_lat =3D PCC_CMD_WAIT_RETRIES_NUM * data->pcc_chan->latency; ret =3D wait_for_completion_timeout(&data->done, - usecs_to_jiffies(usecs_lat)); + msecs_to_jiffies(data->cl.tx_tout)); if (ret =3D=3D 0) { pr_err("PCC command executed timeout!\n"); return AE_TIME; --=20 2.43.0