From 3447ba1f0405a8590ec31e4b79737efe151c3d5b Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Mon, 22 Jan 2024 21:41:14 +0530 Subject: [PATCH 1/2] feat(css): initialise generic timer early in the boot Initialize generic delay timer to enable its use to insert delays in execution paths as required. Change-Id: I52232796f20d9692f0115d5e5395451a54b489c6 Signed-off-by: Pranav Madhu --- plat/arm/css/sgi/sgi-common.mk | 5 +++-- plat/arm/css/sgi/sgi_bl31_setup.c | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/plat/arm/css/sgi/sgi-common.mk b/plat/arm/css/sgi/sgi-common.mk index 2cd703422..efa3cc6a5 100644 --- a/plat/arm/css/sgi/sgi-common.mk +++ b/plat/arm/css/sgi/sgi-common.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2018-2022, Arm Limited and Contributors. All rights reserved. +# Copyright (c) 2018-2024, Arm Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -50,7 +50,8 @@ BL2_SOURCES += ${CSS_ENT_BASE}/sgi_image_load.c \ BL31_SOURCES += ${INTERCONNECT_SOURCES} \ ${ENT_GIC_SOURCES} \ ${CSS_ENT_BASE}/sgi_bl31_setup.c \ - ${CSS_ENT_BASE}/sgi_topology.c + ${CSS_ENT_BASE}/sgi_topology.c \ + drivers/delay_timer/generic_delay_timer.c ifneq (${RESET_TO_BL31},0) $(error "Using BL31 as the reset vector is not supported on ${PLAT} platform. \ diff --git a/plat/arm/css/sgi/sgi_bl31_setup.c b/plat/arm/css/sgi/sgi_bl31_setup.c index 7aa7b34a8..ac1ea486a 100644 --- a/plat/arm/css/sgi/sgi_bl31_setup.c +++ b/plat/arm/css/sgi/sgi_bl31_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2023, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -104,6 +105,8 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, void sgi_bl31_common_platform_setup(void) { + generic_delay_timer_init(); + arm_bl31_platform_setup(); /* Configure the warm reboot SGI for primary core */ From af1ac2d7db47717bc69afd69b56f398aa34b2fb6 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Thu, 18 Jan 2024 18:55:18 +0530 Subject: [PATCH 2/2] fix(scmi): induce a delay in monitoring SCMI channel status Reading the SCMI mailbox status in polling mode causes a burst of bus accesses. On certain platforms, this would not be ideal as the shared bus on the CPU subsystem might cause contentions across all the CPUs. So allow platforms to specify a delay to be introduced while polling. Change-Id: Ib90ad7b5954854071cfd543f4a27a178dde3d5c6 Signed-off-by: Pranav Madhu --- drivers/arm/css/scmi/scmi_common.c | 9 ++++++--- include/drivers/arm/css/scmi.h | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/arm/css/scmi/scmi_common.c b/drivers/arm/css/scmi/scmi_common.c index ec749fb56..ca855fe71 100644 --- a/drivers/arm/css/scmi/scmi_common.c +++ b/drivers/arm/css/scmi/scmi_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -9,6 +9,7 @@ #include #include #include +#include #include "scmi_private.h" @@ -60,8 +61,10 @@ void scmi_send_sync_command(scmi_channel_t *ch) dmbsy(); /* Wait for channel to be free */ - while (!SCMI_IS_CHANNEL_FREE(mbx_mem->status)) - ; + while (!SCMI_IS_CHANNEL_FREE(mbx_mem->status)) { + if (ch->info->delay != 0) + udelay(ch->info->delay); + } /* * Ensure that any read to the SCMI payload area is done after reading diff --git a/include/drivers/arm/css/scmi.h b/include/drivers/arm/css/scmi.h index 356012bf9..96e192469 100644 --- a/include/drivers/arm/css/scmi.h +++ b/include/drivers/arm/css/scmi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -123,6 +123,8 @@ typedef struct scmi_channel_plat_info { void (*ring_doorbell)(struct scmi_channel_plat_info *plat_info); /* cookie is unused now. But added for future enhancements. */ void *cookie; + /* Delay in micro-seconds while polling the channel status. */ + uint32_t delay; } scmi_channel_plat_info_t;