From nobody Fri Jul 24 21:30:14 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B35DE4334C8; Fri, 24 Jul 2026 13:43:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784900595; cv=none; b=e/OdQn51QF2KDs3yYycH0GmiY592KO9ONcJbZCz0JZeQGox9RYN4x7kddW8DdojivDk3NSH8nyk/xET5zta+guGxrjtPVLeD0cyx1D2WBUuv4fH/1l8kzzqAR9qrjIgJPZnAA21D0p3Z8DRg6/BfHAQ2N+MNLfhhZFRe1hcMbQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784900595; c=relaxed/simple; bh=dMB18QgeVAdPqzBMAuUOG2aj6yCR7463Svrc+87yX68=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xa/PLP/hCAVZWhD9kfym6nBDYZEVmTejuxXa0XT6i8IFcDNVyLT1VMFe0/i1jDfkfDmk4+iJ6tKgdo/Mk/gwmlMO5IXfRIq0Q9QqWO3LdOxqLI6aXw2s6tMq1TGYUecpW28O5S2iKt6UYGMXTwL8IfwS7BOpMnhEy9zbc0mtMew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=IrMctGv7; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="IrMctGv7" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0CACD1684; Fri, 24 Jul 2026 06:43:02 -0700 (PDT) Received: from e127648.arm.com (unknown [10.57.66.189]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7A00C3F59E; Fri, 24 Jul 2026 06:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784900586; bh=dMB18QgeVAdPqzBMAuUOG2aj6yCR7463Svrc+87yX68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IrMctGv71LZW6FNC/yLG7pWcdlxyQCJ79PnACGgJXLeM1waZ09r2tJNsXD6AHc6H0 vHtlJk5M5UuKYDf6mesverHvEnXQr3S3ig1IPQ19ocEL2vlOFSInVe3KZa18fJuUfZ i9a/jjSs4J1ZMcShYkepiNMej5Fp4HFmkbwOkgqs= From: Christian Loehle To: "Rafael J . Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Len Brown , Jie Zhan , Lifeng Zheng , Pierre Gondois , Sumit Gupta , Sudeep Holla , Ionela Voinescu , Christian Loehle Subject: [PATCH 1/3] ACPI: CPPC: Avoid unnecessary reads for full-width writes Date: Fri, 24 Jul 2026 14:42:49 +0100 Message-Id: <20260724134251.1632824-2-christian.loehle@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260724134251.1632824-1-christian.loehle@arm.com> References: <20260724134251.1632824-1-christian.loehle@arm.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 Content-Type: text/plain; charset="utf-8" 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 --- 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_r= esource *reg_res, u64 val) return -ENODEV; } =20 + /* + * 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 =3D readb_relaxed(vaddr); - break; - case 16: - prev_val =3D readw_relaxed(vaddr); - break; - case 32: - prev_val =3D readl_relaxed(vaddr); - break; - case 64: - prev_val =3D readq_relaxed(vaddr); - break; - default: - raw_spin_unlock_irqrestore(&cpc_desc->rmw_lock, flags); - return -EFAULT; + + if (reg->bit_offset || reg->bit_width !=3D size) { + switch (size) { + case 8: + prev_val =3D readb_relaxed(vaddr); + break; + case 16: + prev_val =3D readw_relaxed(vaddr); + break; + case 32: + prev_val =3D readl_relaxed(vaddr); + break; + case 64: + prev_val =3D readq_relaxed(vaddr); + break; + default: + raw_spin_unlock_irqrestore(&cpc_desc->rmw_lock, + flags); + return -EFAULT; + } + val =3D MASK_VAL_WRITE(reg, prev_val, val); } - val =3D MASK_VAL_WRITE(reg, prev_val, val); } =20 switch (size) { --=20 2.34.1 From nobody Fri Jul 24 21:30:14 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19C2B433BAB; Fri, 24 Jul 2026 13:43:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784900594; cv=none; b=P755XdLG85GYoH/d+JNMiCVSw+avJGqQ3P+mekotBQmEFLsHd4IoCYuwDHC/th7MXWe58NATnxVUzgSpCXJByF8/4Ekex3EbiDgM1Zqw/DlEDJEocwKLGCctiMV5wRCVgC+JbfZv6sGf/dD2BBqdeJ4tiVhewkB8Yl8A4KvL9oo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784900594; c=relaxed/simple; bh=gq9J1RvWC89pSiDbdZPLorYduWb+4Hbnf2Jhd3DjhiQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YzZ9vWkzUyvNnQqtxGszuEIyov0+nLKeroAHE0FMymLTAr4ElEAkZM0nJFu3kvCcmbEQQfFAQU7+4P5NXCgT+0UdPQe4xZeAgRMwnBgmKI/Za+zUYqGZ79sFNBk4qRCeJ/QhcSpuREYG2XuCvpkr+5Kb7TvT6PYCPXETiot0Oy0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=DCF+eGYO; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="DCF+eGYO" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 98A8B1BB0; Fri, 24 Jul 2026 06:43:06 -0700 (PDT) Received: from e127648.arm.com (unknown [10.57.66.189]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 94DE03F59E; Fri, 24 Jul 2026 06:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784900590; bh=gq9J1RvWC89pSiDbdZPLorYduWb+4Hbnf2Jhd3DjhiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DCF+eGYOMq+Jd0ixXHmdwZEPgUJw1vAJSbPmDCkcEEtYDsC8yyC71cIC8+qmx3yly LehvEIYduUdcYew87OEdEQHOj8E1NfzqjaO1SWcx+XmWGvJ+gA2luWMmwY6D+Mlcsr 6LZCooLX8jAvfm751Aosm1QYe5+KtFakcuy/CWPM= From: Christian Loehle To: "Rafael J . Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Len Brown , Jie Zhan , Lifeng Zheng , Pierre Gondois , Sumit Gupta , Sudeep Holla , Ionela Voinescu , Christian Loehle Subject: [PATCH 2/3] ACPI: CPPC: Avoid locking standalone full-width registers Date: Fri, 24 Jul 2026 14:42:50 +0100 Message-Id: <20260724134251.1632824-3-christian.loehle@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260724134251.1632824-1-christian.loehle@arm.com> References: <20260724134251.1632824-1-christian.loehle@arm.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 Content-Type: text/plain; charset="utf-8" cpc_write() serializes every SystemMemory write with the per-CPU rmw_lock. The lock is required for read-modify-write fields and for registers whose access units overlap, but not for a full-width register in a standalone access unit. The _CPC layout is immutable after it has been parsed. Classify each SystemMemory register at probe time and retain locking for partial fields, invalid access widths, and overlapping access units. Allow standalone full-width registers to bypass the descriptor lookup and spinlock. Store the classification in existing structure padding so that struct cpc_register_resource does not grow. Signed-off-by: Christian Loehle --- drivers/acpi/cppc_acpi.c | 97 ++++++++++++++++++++++++++++++++++------ include/acpi/cppc_acpi.h | 5 ++- 2 files changed, 88 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 9b8d68b44ea9..2793d6b7d40d 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -200,6 +200,72 @@ show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, = wraparound_time); ((((val) & GENMASK(((reg)->bit_width) - 1, 0)) << (reg)->bit_offset) | \ ((prev_val) & ~(GENMASK(((reg)->bit_width) - 1, 0) << (reg)->bit_offset))= ) \ =20 +static u64 cpc_sysmem_access_size(const struct cpc_register_resource *reg) +{ + const struct cpc_reg *gas =3D ®->cpc_entry.reg; + unsigned int width; + + if (gas->access_width > 4) + return 0; + + width =3D GET_BIT_WIDTH(gas); + + if (width !=3D 8 && width !=3D 16 && width !=3D 32 && width !=3D 64) + return 0; + + return width / 8; +} + +static bool cpc_sysmem_access_units_overlap(const struct cpc_register_reso= urce *a, + const struct cpc_register_resource *b) +{ + const struct cpc_reg *a_gas =3D &a->cpc_entry.reg; + const struct cpc_reg *b_gas =3D &b->cpc_entry.reg; + u64 a_size =3D cpc_sysmem_access_size(a); + u64 b_size =3D cpc_sysmem_access_size(b); + + /* Keep the conservative locking path for malformed access widths. */ + if (!a_size || !b_size) + return true; + + if (a_gas->address < b_gas->address) + return b_gas->address - a_gas->address < a_size; + + return a_gas->address - b_gas->address < b_size; +} + +static void cpc_mark_rmw_lock_users(struct cpc_desc *cpc_desc) +{ + int i, j; + + for (i =3D 0; i < cpc_desc->num_entries - 2; i++) { + struct cpc_register_resource *a =3D &cpc_desc->cpc_regs[i]; + struct cpc_reg *gas; + u64 access_size; + + if (!CPC_SUPPORTED(a) || !CPC_IN_SYSTEM_MEMORY(a)) + continue; + + gas =3D &a->cpc_entry.reg; + access_size =3D cpc_sysmem_access_size(a); + if (gas->bit_offset || !access_size || + gas->bit_width !=3D access_size * 8) + a->cpc_entry.use_rmw_lock =3D true; + + for (j =3D i + 1; j < cpc_desc->num_entries - 2; j++) { + struct cpc_register_resource *b =3D &cpc_desc->cpc_regs[j]; + + if (!CPC_SUPPORTED(b) || !CPC_IN_SYSTEM_MEMORY(b)) + continue; + if (!cpc_sysmem_access_units_overlap(a, b)) + continue; + + a->cpc_entry.use_rmw_lock =3D true; + b->cpc_entry.use_rmw_lock =3D true; + } + } +} + static ssize_t show_feedback_ctrs(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -904,6 +970,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) =20 /* Store CPU Logical ID */ cpc_ptr->cpu_id =3D pr->id; + cpc_mark_rmw_lock_users(cpc_ptr); raw_spin_lock_init(&cpc_ptr->rmw_lock); =20 /* Parse PSD data for this CPU */ @@ -1123,6 +1190,7 @@ static int cpc_write(int cpu, struct cpc_register_res= ource *reg_res, u64 val) struct cpc_reg *reg =3D ®_res->cpc_entry.reg; struct cpc_desc *cpc_desc; unsigned long flags; + bool locked =3D false; =20 size =3D GET_BIT_WIDTH(reg); =20 @@ -1156,18 +1224,20 @@ static int cpc_write(int cpu, struct cpc_register_r= esource *reg_res, u64 val) val, size); =20 if (reg->space_id =3D=3D ACPI_ADR_SPACE_SYSTEM_MEMORY) { - cpc_desc =3D per_cpu(cpc_desc_ptr, cpu); - if (!cpc_desc) { - pr_debug("No CPC descriptor for CPU:%d\n", cpu); - 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. + * The _CPC layout is immutable after probe. The precomputed flag + * retains serialization for partial fields or overlapping access + * units; standalone full-width registers avoid the lock. */ - raw_spin_lock_irqsave(&cpc_desc->rmw_lock, flags); + locked =3D reg_res->cpc_entry.use_rmw_lock; + if (locked) { + cpc_desc =3D per_cpu(cpc_desc_ptr, cpu); + if (!cpc_desc) { + pr_debug("No CPC descriptor for CPU:%d\n", cpu); + return -ENODEV; + } + raw_spin_lock_irqsave(&cpc_desc->rmw_lock, flags); + } =20 if (reg->bit_offset || reg->bit_width !=3D size) { switch (size) { @@ -1184,8 +1254,9 @@ static int cpc_write(int cpu, struct cpc_register_res= ource *reg_res, u64 val) prev_val =3D readq_relaxed(vaddr); break; default: - raw_spin_unlock_irqrestore(&cpc_desc->rmw_lock, - flags); + if (locked) + raw_spin_unlock_irqrestore(&cpc_desc->rmw_lock, + flags); return -EFAULT; } val =3D MASK_VAL_WRITE(reg, prev_val, val); @@ -1217,7 +1288,7 @@ static int cpc_write(int cpu, struct cpc_register_res= ource *reg_res, u64 val) break; } =20 - if (reg->space_id =3D=3D ACPI_ADR_SPACE_SYSTEM_MEMORY) + if (locked) raw_spin_unlock_irqrestore(&cpc_desc->rmw_lock, flags); =20 return ret_val; diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index 8c191b9ac18f..19830146c644 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -69,7 +69,10 @@ struct cpc_register_resource { acpi_object_type type; u64 __iomem *sys_mem_vaddr; union { - struct cpc_reg reg; + struct { + struct cpc_reg reg; + bool use_rmw_lock; + }; u64 int_value; } cpc_entry; }; --=20 2.34.1 From nobody Fri Jul 24 21:30:14 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4CA3439F8B; Fri, 24 Jul 2026 13:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784900598; cv=none; b=L8guaKhCSrzVKnsqjbvfUsyqf9F+/D8kJvmtGRlrWd7xNw7RgxpBTMFjxvbSut2FhL70fw4mTF3GR0pLXow04sPpbT49d8VZTclLUxyucn6e8Yg42MfhiJguuMUdQ4P/1oOleqRFm6TwJWaaKBuTgUPJ4ah3aAKhCaqyMt2nAUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784900598; c=relaxed/simple; bh=eNP5GqOW7zsH2R03Okaf82MSE794/afd4AaWtwVDhXs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TteoIVAlD0afXaJU4UX2wjM8s5LowR9UbweymcXtLaWjif+y2j5ZfTX34fVHELrnX+FbbxfHba6P8Zd9imk+FHZI0me1O4+PVyvwFmkp8bdyfD1bqSjt3b6lwaUzQnRavLM405ujA3BnxL9aSEJN2ufxwl5gj36LABkZghA3pDg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=vAneIkqs; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="vAneIkqs" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 828281477; Fri, 24 Jul 2026 06:43:10 -0700 (PDT) Received: from e127648.arm.com (unknown [10.57.66.189]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0ACDE3F59E; Fri, 24 Jul 2026 06:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784900594; bh=eNP5GqOW7zsH2R03Okaf82MSE794/afd4AaWtwVDhXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vAneIkqsNtELSt78+OyV+SJPCbyfA9QhK6ZqhTD75Y5FT9klhlElzdTL7S1oGcRuw 9vcVcKD2Pd3hriq3ISSr7GQupl+n/3JzvZYAix8DiIjyCJKNi5Z8hW5FGKEGS3ayFY fNzW/Fuelg95UXMcGeW2HYYnzmvtVqulgs/F/6KA= From: Christian Loehle To: "Rafael J . Wysocki" , Viresh Kumar Cc: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Len Brown , Jie Zhan , Lifeng Zheng , Pierre Gondois , Sumit Gupta , Sudeep Holla , Ionela Voinescu , Christian Loehle Subject: [PATCH 3/3] ACPI: CPPC: Evaluate performance-control PCC use once Date: Fri, 24 Jul 2026 14:42:51 +0100 Message-Id: <20260724134251.1632824-4-christian.loehle@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260724134251.1632824-1-christian.loehle@arm.com> References: <20260724134251.1632824-1-christian.loehle@arm.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 Content-Type: text/plain; charset="utf-8" cppc_set_perf() evaluates the same immutable address-space predicates before and after each phase of a performance-control update. This repeats the three-control PCC test three times for every target request. Evaluate the predicate once after resolving the control descriptors and reuse the result throughout the transaction. Signed-off-by: Christian Loehle --- drivers/acpi/cppc_acpi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 2793d6b7d40d..cd1c4a30eb6f 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -2002,6 +2002,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *pe= rf_ctrls) struct cpc_register_resource *desired_reg, *min_perf_reg, *max_perf_reg; int pcc_ss_id =3D per_cpu(cpu_pcc_subspace_idx, cpu); struct cppc_pcc_data *pcc_ss_data =3D NULL; + bool regs_in_pcc; int ret =3D 0; =20 if (!cpc_desc) { @@ -2012,6 +2013,8 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *pe= rf_ctrls) desired_reg =3D &cpc_desc->cpc_regs[DESIRED_PERF]; min_perf_reg =3D &cpc_desc->cpc_regs[MIN_PERF]; max_perf_reg =3D &cpc_desc->cpc_regs[MAX_PERF]; + regs_in_pcc =3D CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || + CPC_IN_PCC(max_perf_reg); =20 /* * This is Phase-I where we want to write to CPC registers @@ -2020,7 +2023,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *pe= rf_ctrls) * Since read_lock can be acquired by multiple CPUs simultaneously we * achieve that goal here */ - if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max= _perf_reg)) { + if (regs_in_pcc) { if (pcc_ss_id < 0) { pr_debug("Invalid pcc_ss_id\n"); return -ENODEV; @@ -2056,7 +2059,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *pe= rf_ctrls) if (perf_ctrls->max_perf && CPC_SUPPORTED(max_perf_reg)) cpc_write(cpu, max_perf_reg, perf_ctrls->max_perf); =20 - if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max= _perf_reg)) + if (regs_in_pcc) up_read(&pcc_ss_data->pcc_lock); /* END Phase-I */ /* * This is Phase-II where we transfer the ownership of PCC to Platform @@ -2104,7 +2107,7 @@ int cppc_set_perf(int cpu, struct cppc_perf_ctrls *pe= rf_ctrls) * case during a CMD_READ and if there are pending writes it delivers * the write command before servicing the read command */ - if (CPC_IN_PCC(desired_reg) || CPC_IN_PCC(min_perf_reg) || CPC_IN_PCC(max= _perf_reg)) { + if (regs_in_pcc) { if (down_write_trylock(&pcc_ss_data->pcc_lock)) {/* BEGIN Phase-II */ /* Update only if there are pending write commands */ if (pcc_ss_data->pending_pcc_write_cmd) --=20 2.34.1