Commit 60cd8030 authored by Heyi Guo's avatar Heyi Guo Committed by Manish Pandey
Browse files

drivers/gicv3: use mpidr to probe GICR for current CPU



In function gicv3_rdistif_probe(), line #1322 implies
gicv3_driver_data->mpidr_to_core_pos() may be null, but the original
code uses this interface to get current CPU index unconditionally.

It is better to use MPIDR to probe GICR which does not depend on
gicv3_driver_data->mpidr_to_core_pos().
Signed-off-by: default avatarHeyi Guo <guoheyi@linux.alibaba.com>
Change-Id: I64add055385040fe0a56b977e2299608e2309a6e
parent 96edbe03
/* /*
* Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2015-2021, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -1299,8 +1299,8 @@ unsigned int gicv3_set_pmr(unsigned int mask) ...@@ -1299,8 +1299,8 @@ unsigned int gicv3_set_pmr(unsigned int mask)
******************************************************************************/ ******************************************************************************/
int gicv3_rdistif_probe(const uintptr_t gicr_frame) int gicv3_rdistif_probe(const uintptr_t gicr_frame)
{ {
u_register_t mpidr; u_register_t mpidr, mpidr_self;
unsigned int proc_num, proc_self; unsigned int proc_num;
uint64_t typer_val; uint64_t typer_val;
uintptr_t rdistif_base; uintptr_t rdistif_base;
bool gicr_frame_found = false; bool gicr_frame_found = false;
...@@ -1314,18 +1314,18 @@ int gicv3_rdistif_probe(const uintptr_t gicr_frame) ...@@ -1314,18 +1314,18 @@ int gicv3_rdistif_probe(const uintptr_t gicr_frame)
assert((read_sctlr_el3() & SCTLR_C_BIT) != 0U); assert((read_sctlr_el3() & SCTLR_C_BIT) != 0U);
#endif /* !__aarch64__ */ #endif /* !__aarch64__ */
proc_self = gicv3_driver_data->mpidr_to_core_pos(read_mpidr_el1()); mpidr_self = read_mpidr_el1() & MPIDR_AFFINITY_MASK;
rdistif_base = gicr_frame; rdistif_base = gicr_frame;
do { do {
typer_val = gicr_read_typer(rdistif_base); typer_val = gicr_read_typer(rdistif_base);
mpidr = mpidr_from_gicr_typer(typer_val);
if (gicv3_driver_data->mpidr_to_core_pos != NULL) { if (gicv3_driver_data->mpidr_to_core_pos != NULL) {
mpidr = mpidr_from_gicr_typer(typer_val);
proc_num = gicv3_driver_data->mpidr_to_core_pos(mpidr); proc_num = gicv3_driver_data->mpidr_to_core_pos(mpidr);
} else { } else {
proc_num = (unsigned int)(typer_val >> proc_num = (unsigned int)(typer_val >>
TYPER_PROC_NUM_SHIFT) & TYPER_PROC_NUM_MASK; TYPER_PROC_NUM_SHIFT) & TYPER_PROC_NUM_MASK;
} }
if (proc_num == proc_self) { if (mpidr == mpidr_self) {
/* The base address doesn't need to be initialized on /* The base address doesn't need to be initialized on
* every warm boot. * every warm boot.
*/ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment