Commit 98367c80 authored by Samuel Holland's avatar Samuel Holland
Browse files

arm/css/scpi: Don't panic if the SCP fails to respond



Instead, pass back the error to the calling function. This allows
platform code to fall back to another PSCI implementation if
scpi_wait_ready() or a later SCPI command fails.
Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
Change-Id: Ib4411e63c2512857f09ffffe1c405358dddeb4a6
parent 51d72d3a
/* /*
* Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -51,7 +51,7 @@ static void scpi_secure_message_send(size_t payload_size) ...@@ -51,7 +51,7 @@ static void scpi_secure_message_send(size_t payload_size)
mhu_secure_message_send(SCPI_MHU_SLOT_ID); mhu_secure_message_send(SCPI_MHU_SLOT_ID);
} }
static void scpi_secure_message_receive(scpi_cmd_t *cmd) static int scpi_secure_message_receive(scpi_cmd_t *cmd)
{ {
uint32_t mhu_status; uint32_t mhu_status;
...@@ -63,7 +63,7 @@ static void scpi_secure_message_receive(scpi_cmd_t *cmd) ...@@ -63,7 +63,7 @@ static void scpi_secure_message_receive(scpi_cmd_t *cmd)
if (mhu_status != (1 << SCPI_MHU_SLOT_ID)) { if (mhu_status != (1 << SCPI_MHU_SLOT_ID)) {
ERROR("MHU: Unexpected protocol (MHU status: 0x%x)\n", ERROR("MHU: Unexpected protocol (MHU status: 0x%x)\n",
mhu_status); mhu_status);
panic(); return -1;
} }
/* /*
...@@ -74,6 +74,8 @@ static void scpi_secure_message_receive(scpi_cmd_t *cmd) ...@@ -74,6 +74,8 @@ static void scpi_secure_message_receive(scpi_cmd_t *cmd)
dmbld(); dmbld();
memcpy(cmd, (void *) SCPI_SHARED_MEM_SCP_TO_AP, sizeof(*cmd)); memcpy(cmd, (void *) SCPI_SHARED_MEM_SCP_TO_AP, sizeof(*cmd));
return 0;
} }
static void scpi_secure_message_end(void) static void scpi_secure_message_end(void)
...@@ -84,14 +86,19 @@ static void scpi_secure_message_end(void) ...@@ -84,14 +86,19 @@ static void scpi_secure_message_end(void)
int scpi_wait_ready(void) int scpi_wait_ready(void)
{ {
scpi_cmd_t scpi_cmd; scpi_cmd_t scpi_cmd;
int rc;
VERBOSE("Waiting for SCP_READY command...\n"); VERBOSE("Waiting for SCP_READY command...\n");
/* Get a message from the SCP */ /* Get a message from the SCP */
scpi_secure_message_start(); scpi_secure_message_start();
scpi_secure_message_receive(&scpi_cmd); rc = scpi_secure_message_receive(&scpi_cmd);
scpi_secure_message_end(); scpi_secure_message_end();
/* If no message was received, don't send a response */
if (rc != 0)
return rc;
/* We are expecting 'SCP Ready', produce correct error if it's not */ /* We are expecting 'SCP Ready', produce correct error if it's not */
scpi_status_t status = SCP_OK; scpi_status_t status = SCP_OK;
if (scpi_cmd.id != SCPI_CMD_SCP_READY) { if (scpi_cmd.id != SCPI_CMD_SCP_READY) {
...@@ -209,7 +216,8 @@ int scpi_get_css_power_state(unsigned int mpidr, unsigned int *cpu_state_p, ...@@ -209,7 +216,8 @@ int scpi_get_css_power_state(unsigned int mpidr, unsigned int *cpu_state_p,
* Send message and wait for SCP's response * Send message and wait for SCP's response
*/ */
scpi_secure_message_send(0); scpi_secure_message_send(0);
scpi_secure_message_receive(&response); if (scpi_secure_message_receive(&response) != 0)
goto exit;
if (response.status != SCP_OK) if (response.status != SCP_OK)
goto exit; goto exit;
...@@ -254,7 +262,9 @@ uint32_t scpi_sys_power_state(scpi_system_state_t system_state) ...@@ -254,7 +262,9 @@ uint32_t scpi_sys_power_state(scpi_system_state_t system_state)
*payload_addr = system_state & 0xff; *payload_addr = system_state & 0xff;
scpi_secure_message_send(sizeof(*payload_addr)); scpi_secure_message_send(sizeof(*payload_addr));
scpi_secure_message_receive(&response); /* If no response is received, fill in an error status */
if (scpi_secure_message_receive(&response) != 0)
response.status = SCP_E_TIMEOUT;
scpi_secure_message_end(); scpi_secure_message_end();
......
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