Skip to content

Commit 73daf0b

Browse files
zhangshkwilldeacon
authored andcommitted
drivers/perf: hisi: Simplify hisi_read_sccl_and_ccl_id and its comment
hisi_read_sccl_and_ccl_id is not readable and its comment is a little confused, so simplify the function and its comment as Mark's suggestion. Acked-by: Mark Rutland <[email protected]> Reviewed-by: John Garry <[email protected]> Suggested-by: Mark Rutland <[email protected]> Signed-off-by: Shaokun Zhang <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 46cf053 commit 73daf0b

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

drivers/perf/hisilicon/hisi_uncore_pmu.c

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -337,38 +337,44 @@ void hisi_uncore_pmu_disable(struct pmu *pmu)
337337
hisi_pmu->ops->stop_counters(hisi_pmu);
338338
}
339339

340+
340341
/*
341-
* Read Super CPU cluster and CPU cluster ID from MPIDR_EL1.
342-
* If multi-threading is supported, On Huawei Kunpeng 920 SoC whose cpu
343-
* core is tsv110, CCL_ID is the low 3-bits in MPIDR[Aff2] and SCCL_ID
344-
* is the upper 5-bits of Aff2 field; while for other cpu types, SCCL_ID
345-
* is in MPIDR[Aff3] and CCL_ID is in MPIDR[Aff2], if not, SCCL_ID
346-
* is in MPIDR[Aff2] and CCL_ID is in MPIDR[Aff1].
342+
* The Super CPU Cluster (SCCL) and CPU Cluster (CCL) IDs can be
343+
* determined from the MPIDR_EL1, but the encoding varies by CPU:
344+
*
345+
* - For MT variants of TSV110:
346+
* SCCL is Aff2[7:3], CCL is Aff2[2:0]
347+
*
348+
* - For other MT parts:
349+
* SCCL is Aff3[7:0], CCL is Aff2[7:0]
350+
*
351+
* - For non-MT parts:
352+
* SCCL is Aff2[7:0], CCL is Aff1[7:0]
347353
*/
348-
static void hisi_read_sccl_and_ccl_id(int *sccl_id, int *ccl_id)
354+
static void hisi_read_sccl_and_ccl_id(int *scclp, int *cclp)
349355
{
350356
u64 mpidr = read_cpuid_mpidr();
351-
352-
if (mpidr & MPIDR_MT_BITMASK) {
353-
if (read_cpuid_part_number() == HISI_CPU_PART_TSV110) {
354-
int aff2 = MPIDR_AFFINITY_LEVEL(mpidr, 2);
355-
356-
if (sccl_id)
357-
*sccl_id = aff2 >> 3;
358-
if (ccl_id)
359-
*ccl_id = aff2 & 0x7;
360-
} else {
361-
if (sccl_id)
362-
*sccl_id = MPIDR_AFFINITY_LEVEL(mpidr, 3);
363-
if (ccl_id)
364-
*ccl_id = MPIDR_AFFINITY_LEVEL(mpidr, 2);
365-
}
357+
int aff3 = MPIDR_AFFINITY_LEVEL(mpidr, 3);
358+
int aff2 = MPIDR_AFFINITY_LEVEL(mpidr, 2);
359+
int aff1 = MPIDR_AFFINITY_LEVEL(mpidr, 1);
360+
bool mt = mpidr & MPIDR_MT_BITMASK;
361+
int sccl, ccl;
362+
363+
if (mt && read_cpuid_part_number() == HISI_CPU_PART_TSV110) {
364+
sccl = aff2 >> 3;
365+
ccl = aff2 & 0x7;
366+
} else if (mt) {
367+
sccl = aff3;
368+
ccl = aff2;
366369
} else {
367-
if (sccl_id)
368-
*sccl_id = MPIDR_AFFINITY_LEVEL(mpidr, 2);
369-
if (ccl_id)
370-
*ccl_id = MPIDR_AFFINITY_LEVEL(mpidr, 1);
370+
sccl = aff2;
371+
ccl = aff1;
371372
}
373+
374+
if (scclp)
375+
*scclp = sccl;
376+
if (cclp)
377+
*cclp = ccl;
372378
}
373379

374380
/*

0 commit comments

Comments
 (0)