Skip to content

Commit

Permalink
drivers/gicv3: use mpidr to probe GICR for current CPU
Browse files Browse the repository at this point in the history
In function gicv3_rdistif_probe(), line ARM-software#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: Heyi Guo <guoheyi@linux.alibaba.com>
Change-Id: I64add055385040fe0a56b977e2299608e2309a6e
  • Loading branch information
iwishguo authored and manish-pandey-arm committed Feb 3, 2021
1 parent 96edbe0 commit 60cd803
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/arm/gic/v3/gicv3_main.c
@@ -1,5 +1,5 @@
/*
* 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
*/
Expand Down Expand Up @@ -1299,8 +1299,8 @@ unsigned int gicv3_set_pmr(unsigned int mask)
******************************************************************************/
int gicv3_rdistif_probe(const uintptr_t gicr_frame)
{
u_register_t mpidr;
unsigned int proc_num, proc_self;
u_register_t mpidr, mpidr_self;
unsigned int proc_num;
uint64_t typer_val;
uintptr_t rdistif_base;
bool gicr_frame_found = false;
Expand All @@ -1314,18 +1314,18 @@ int gicv3_rdistif_probe(const uintptr_t gicr_frame)
assert((read_sctlr_el3() & SCTLR_C_BIT) != 0U);
#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;
do {
typer_val = gicr_read_typer(rdistif_base);
mpidr = mpidr_from_gicr_typer(typer_val);
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);
} else {
proc_num = (unsigned int)(typer_val >>
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
* every warm boot.
*/
Expand Down

0 comments on commit 60cd803

Please sign in to comment.