From nobody Sat Jul 25 05:27:23 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 C91BE3DEADC; Fri, 17 Jul 2026 08:10:11 +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=1784275812; cv=none; b=dNb5tx+U5SXiyLDS7T8+TtFtrtXoFr1j2EAMZHd8fOTKMCOwnJuhe1BlI5XvD/rSGW4AWc/YQFXO65z8UEtrV/LJ+4lkdB+fqOS5R6f+vDVFcU4zANh3V7DrcF6IK1iSFLtLnDtBuSH9++8RHKi6Hu76UAhK5muUc4mgcMkvyro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275812; c=relaxed/simple; bh=Kvq8pBUXd3SBMsFtQJvupDCkQGaQzbTYejkgqHTe8cM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qo/zpoErIhN3o5NInKJjCH0J6PrWKvXYv6D3aqXCL6Nwm9BzO8S8plftGghFFOHBKUYC83vDGwdtIJ6+kBuiOEP+EFHd51nyoeotSKwnZmMb1D3RU2DjMFXc7f5vwfaKHeWuslyEHpBgL4XMp9mUlKQNH/kVskXp7s1LRIQdcBk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NN5BFtpt; 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="NN5BFtpt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ACA81F000E9; Fri, 17 Jul 2026 08:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784275811; bh=9jYqPRqPWJvx7ZI06P13taAbeaiEKCjE8/dqxPgQSMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NN5BFtptJtSego9L3E3AqfRMyqvg1pWqjI7MPFFgqORT9AQQtStEj/Suh2dTL9Ffy nGae4C+lgMxROewXejNf8K4dn3iIAALPbWtb6sbC2BS0wM/qvImJXgKQRAQQtyo5jg 9gJGGbV5a2D7DSwyN736S3inYlvvm/ifNI+4P0kRXTHhBx4ZtJNyrS9tj0lEDQlyYl dFD1xUN+aDRBHRoeWPJy3uwYal97SW0RRWVu3JQeFZEYfobJWYTrFUZYGykR5B6y70 lieO09okz3x/4DcjYo2M1L/2NMO02ODob+xn4u9QOeAHXp8AvAIqNn1HQ9ZOxMmKRO L+UeQL8PWhgvA== 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 1/4] ACPICA: Fix PCC OperationRegion command offsets Date: Fri, 17 Jul 2026 09:10:02 +0100 Message-ID: <20260717081005.470013-2-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260717081005.470013-1-sudeep.holla@kernel.org> References: <20260717081005.470013-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 Sat Jul 25 05:27:23 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 7FC8B3E1D0B; Fri, 17 Jul 2026 08:10:13 +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=1784275814; cv=none; b=ifIOJ4c7Ve01aADPG/A7D7iVBRpoT9VmTcb/k1e/BNUdLHu17rOamsuvdjZrGPj8DYJmJQPu6npDUojabn8zl3hY9vpVZN8W5f13cn+q009J25+Qdzk1OuLjmbjUW4Rnkww1CFJvmJrgGtfaF9UYBTJLsS0uNu4fpowCIY3CBvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275814; c=relaxed/simple; bh=Yuqa9q0jsrYddRslOfOdEVoCVy3IgWWB+234NiGqkoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W5JPKwnCfJEi1VSJ1EH8BaPvAzdjL42N/nwD55MfmhyESGF4HZxg8TtFrysU7YmmL/9WIwRdAxOp3p82m08/Bv3z3OXxNrrIYrVV4L24S2QWfeH9xYTBKyz/vDLcaGx5DwcVFM6VqV36NH/d8WZXIfnjuirXWfp7447CmG9ZJYQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BG1gnnxd; 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="BG1gnnxd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1AF81F00A3A; Fri, 17 Jul 2026 08:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784275813; bh=QdlqjIC+9mifni0x/50H8jxPTVWrHgCMVy6gkeAIqII=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BG1gnnxdtn0yKI8wsezbFiOcUbcNqeM1QXu5Kwo1MI3suM2Hja+Gl+coI8AK3a+wy 93vH+G6FBRqsbNRZD0ScllpiY3ClGnELnR4EE0HJSVI7GXhWfWcJObRy1XoK6oH1ID /QF2uLVoLM8YyRJCPYCtnpwndQq1SyoY2EJFDuNZbGRweO3jK77SVYp2Y9IyOOo8m4 64C0BBc3X+YlYiWlbGBJcqMJKT7Wn5ukAzr0281Z+ryhdjK3HVuol8f5mYzckXBY+Z dcM/4uvd/yR00cNUJNkXgfN2KIxiBjpM92w4M2ZLstW8eVUPjgz+3uRRBGGLeQd/6h VPAKtlYGMVr+A== 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 2/4] ACPI: PCC: Preserve shared memory signature in OpRegion handler Date: Fri, 17 Jul 2026 09:10:03 +0100 Message-ID: <20260717081005.470013-3-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260717081005.470013-1-sudeep.holla@kernel.org> References: <20260717081005.470013-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. The PCC address space handler currently copies the OperationRegion buffer to and from the start of the PCC shared memory region. That can overwrite or expose the signature at byte offset 0, and it also misses the last 4 bytes of the actual PCC OperationRegion data. Offset OperationRegion copies by the size of the signature and reject regions that do not fit in the shared memory after that signature. AML that sizes the PCC OperationRegion to include the signature is not conforming to the PCC OperationRegion definition. Cc: "Rafael J. Wysocki" Fixes: 77e2a04745ff ("ACPI: PCC: Implement OperationRegion handler for the = PCC Type 3 subtype") Signed-off-by: Sudeep Holla Reviewed-by: Huisong Li --- 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 Sat Jul 25 05:27:23 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 EB8723E2ADA; Fri, 17 Jul 2026 08:10:14 +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=1784275816; cv=none; b=Gjl32w6cr8ye9Q5xxVXOt66kx3Kt+37lPtCDsMxXrdM6Fx5YYLdb2lOkH/wAs0TGTrtNuGqK8QIW4+uXV1LQxd20R56EeRmXqebXIsDvbap8HmNsseH4jrNoYSFaQ/LpQo6rrD0Vf64i2cJZaGEKjo1HgO1pXOUX6BCb92bJj68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275816; c=relaxed/simple; bh=MemqyLxieiEyNK+XO4s2lXGsAWA+vjHukt6aIEZRi+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AFu3VYb0yDB55QThLdUrxyUam4B3hHXEOtGmJ4CSdAtxJTZLVqtkmch4ssC6FK2gMNC0Z6xq805y9t3TsdnCipnctcgBAlWbmWGcOXaWi9iWEHMVE5iHUtxXqc0Gum6OrVyb8ggojHMkdZE2B21W+mpLd9WFzZafR0z7CdaeRw4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HjzEB4cW; 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="HjzEB4cW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84A541F000E9; Fri, 17 Jul 2026 08:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784275814; bh=519etD8pZU652RzX5cEBzlM+ox71zUKAa7g95EGEnLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HjzEB4cWiPcmQigMMh9zkOuspfikti5d6/4sEtPtb9dF8KIOBayXV11gR5RtUD4OW OykzZxkB+ZliagFOvKErb/1z+Aa/6YmHM1kMJHlPAPm5trX0sFUSYHG/EfGfYjUcZY kr8/IVJmkc9OiGT6LAM3Z7Q1IhMjYqhJVh1h2wlBmI9EAKt+AnSqz5Glxm6pSLpn6R /dQDVcRYr5BdtOXj7437K14smnLOVV2usM6HDA/C15SGV1H1oOARwn2n7Mj/z+qqDc OqDM2o6iqeF+LkMfqZG93IVXJsEWJ5huuasuUOV8iBQ1kFag0xcCbUgwADjCFQiz3n r7EF2Dx1CRg/w== 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 3/4] ACPI: PCC: Free channel on OpRegion deactivation Date: Fri, 17 Jul 2026 09:10:04 +0100 Message-ID: <20260717081005.470013-4-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260717081005.470013-1-sudeep.holla@kernel.org> References: <20260717081005.470013-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") Signed-off-by: Sudeep Holla Reviewed-by: Huisong Li --- 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 Sat Jul 25 05:27:23 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 973903E0243; Fri, 17 Jul 2026 08:10:16 +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=1784275817; cv=none; b=C7uan/pEeZ8cmfyf32bZI4h8fNbF2x7LjL8ZjNH+n52dduoqpBCZ5lharYTrjFYwTnKRtzU3SSG4lgxavv2h1krOELav4xxfHUvc9XXXr9xZC+Yirn6NjE/0DuZIKzwWaFTkMnH+4Js4h2nIdqSUeJ/xMkp7779ZvCPeFfjTA5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784275817; c=relaxed/simple; bh=Rm6RggeBnb2WrzpF6YoiLr9znqsbkWpT0L4B+UirbNo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bKMJoo0mCV61QTucvfshSqBjGqs2UGTckJScFh9dLWKEr3hWGJOFdDIB1DJLPWlW1XY+iNh8eenlaj/Z/j4s2Bcm72toBk3CQ9I+KqwE3tMXZ23X7LFG8/LRQ8INRYf8UL9mj0LB3gUipK29ws/vi2d73oQ5aPh/ojl7ztLjrYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FLDQuWB7; 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="FLDQuWB7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17B9A1F00A3A; Fri, 17 Jul 2026 08:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784275816; bh=SJxWGu92T20ndEoyAT/nBPgIvwh7WjBcK0svGnMTGCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FLDQuWB7CM9KR7y30kGPScMbjufDX0JeCZNWhjp6YyAhIlEn5ak73oXv2587uAbDL 1Om9uDlcRNxdAyEwb53J+QmrgVnHn4TUqs6EQqpcKyct+Kuqf0H82RAGVfKN6Nt2d8 tHARSfmZhinFgCGoPO0kqs2Ihr89prc7jZusF1n4zOEwC4YQv/kRB+k0jBrEPUiz9C c1giOUUygPmE2unXy8sBTSlofx3WqwV4e0f9dtE2G0jsvPN8oJcNM5Tu8amTODPiqF Xk1MmFy6hoyyokTLRjH7eIN90/OUYrjjQZ4ePgLGI++2Y4g+zIU4PS5yVYSh993O5r BmDC262gb9RKA== 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 4/4] ACPI: PCC: Cache OpRegion command timeout Date: Fri, 17 Jul 2026 09:10:05 +0100 Message-ID: <20260717081005.470013-5-sudeep.holla@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260717081005.470013-1-sudeep.holla@kernel.org> References: <20260717081005.470013-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. Signed-off-by: Sudeep Holla Reviewed-by: Huisong Li --- 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