From: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
To: Christian Loehle <christian.loehle@arm.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, Len Brown <lenb@kernel.org>,
Jie Zhan <zhanjie9@hisilicon.com>,
Lifeng Zheng <zhenglifeng1@huawei.com>,
Pierre Gondois <pierre.gondois@arm.com>,
Sumit Gupta <sumitg@nvidia.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Ionela Voinescu <ionela.voinescu@arm.com>,
zhongqiu.han@oss.qualcomm.com
Subject: Re: [PATCH 1/3] ACPI: CPPC: Avoid unnecessary reads for full-width writes
Date: Wed, 5 Aug 2026 21:04:09 +0800 [thread overview]
Message-ID: <1a89f834-93f3-4741-9979-39570af397af@oss.qualcomm.com> (raw)
In-Reply-To: <20260803210527.1285229-2-christian.loehle@arm.com>
On 8/4/2026 5:05 AM, Christian Loehle wrote:
> SystemMemory GAS entries may describe a field within a wider access
> unit, so cpc_write() reads the access unit before updating the field to
> preserve the surrounding bits. It also does this when the field covers
> the complete access unit.
>
> When the bit offset is zero and the register bit width equals the
> resolved access width, the previous value cannot affect the result. Skip
> the MMIO read and mask operation in that case. Retain rmw_lock because
> another entry in the same _CPC package may share the access unit.
>
> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
Nice optimization. Looks good to me.
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
> ---
> drivers/acpi/cppc_acpi.c | 43 ++++++++++++++++++++++++----------------
> 1 file changed, 26 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> index 53d09ca98f06..9b8d68b44ea9 100644
> --- a/drivers/acpi/cppc_acpi.c
> +++ b/drivers/acpi/cppc_acpi.c
> @@ -1162,25 +1162,34 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
> return -ENODEV;
> }
>
> + /*
> + * Only partial fields need the previous contents to preserve bits
> + * outside the field. Keep serializing full-width writes because
> + * another _CPC entry may share the access unit and require RMW.
> + */
> raw_spin_lock_irqsave(&cpc_desc->rmw_lock, flags);
> - switch (size) {
> - case 8:
> - prev_val = readb_relaxed(vaddr);
> - break;
> - case 16:
> - prev_val = readw_relaxed(vaddr);
> - break;
> - case 32:
> - prev_val = readl_relaxed(vaddr);
> - break;
> - case 64:
> - prev_val = readq_relaxed(vaddr);
> - break;
> - default:
> - raw_spin_unlock_irqrestore(&cpc_desc->rmw_lock, flags);
> - return -EFAULT;
> +
> + if (reg->bit_offset || reg->bit_width != size) {
> + switch (size) {
> + case 8:
> + prev_val = readb_relaxed(vaddr);
> + break;
> + case 16:
> + prev_val = readw_relaxed(vaddr);
> + break;
> + case 32:
> + prev_val = readl_relaxed(vaddr);
> + break;
> + case 64:
> + prev_val = readq_relaxed(vaddr);
> + break;
> + default:
> + raw_spin_unlock_irqrestore(&cpc_desc->rmw_lock,
> + flags);
> + return -EFAULT;
> + }
> + val = MASK_VAL_WRITE(reg, prev_val, val);
> }
> - val = MASK_VAL_WRITE(reg, prev_val, val);
> }
>
> switch (size) {
--
Thx and BRs,
Zhongqiu Han
next prev parent reply other threads:[~2026-08-05 13:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 21:05 [RESEND][PATCH 0/3] ACPI: CPPC: Reduce .target() callback overhead Christian Loehle
2026-08-03 21:05 ` [PATCH 1/3] ACPI: CPPC: Avoid unnecessary reads for full-width writes Christian Loehle
2026-08-05 13:04 ` Zhongqiu Han [this message]
2026-08-03 21:05 ` [PATCH 2/3] ACPI: CPPC: Avoid locking standalone full-width registers Christian Loehle
2026-08-03 21:05 ` [PATCH 3/3] ACPI: CPPC: Evaluate performance-control PCC use once Christian Loehle
2026-08-03 22:28 ` [RESEND][PATCH 0/3] ACPI: CPPC: Reduce .target() callback overhead Christian Loehle
2026-08-05 13:08 ` Rafael J. Wysocki (Intel)
2026-08-06 10:05 ` Christian Loehle
2026-08-06 10:36 ` Rafael J. Wysocki (Intel)
2026-08-06 14:25 ` Christian Loehle
-- strict thread matches above, loose matches on Subject: below --
2026-07-24 13:42 [PATCH " Christian Loehle
2026-07-24 13:42 ` [PATCH 1/3] ACPI: CPPC: Avoid unnecessary reads for full-width writes Christian Loehle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a89f834-93f3-4741-9979-39570af397af@oss.qualcomm.com \
--to=zhongqiu.han@oss.qualcomm.com \
--cc=christian.loehle@arm.com \
--cc=ionela.voinescu@arm.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pierre.gondois@arm.com \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.com \
--cc=sumitg@nvidia.com \
--cc=viresh.kumar@linaro.org \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox