Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plat-k3: Add locks for TI-SCI protocol #7089

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions core/arch/arm/plat-k3/drivers/ti_sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#include <assert.h>
#include <kernel/thread.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer kernel/mutex.h for mutex support.

#include <malloc.h>
#include <platform_config.h>
#include <string.h>
Expand All @@ -20,6 +21,7 @@
#include "ti_sci_protocol.h"

static uint8_t message_sequence;
static struct mutex ti_sci_mutex_lock = MUTEX_INITIALIZER;

/**
* struct ti_sci_xfer - Structure representing a message flow
Expand Down Expand Up @@ -136,22 +138,26 @@ static inline int ti_sci_do_xfer(struct ti_sci_xfer *xfer)
struct k3_sec_proxy_msg *msg = &xfer->tx_message;
int ret = 0;

mutex_lock(&ti_sci_mutex_lock);

/* Send the message */
ret = k3_sec_proxy_send(msg);
if (ret) {
EMSG("Message sending failed (%d)", ret);
return ret;
goto unlock;
}

/* Get the response */
ret = ti_sci_get_response(xfer);
if (ret) {
if ((TEE_Result)ret != TEE_ERROR_ACCESS_DENIED)
EMSG("Failed to get response (%d)", ret);
return ret;
goto unlock;
}

return 0;
unlock:
mutex_unlock(&ti_sci_mutex_lock);
return ret;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way and out of the scope of this change: I see k3_sec_proxy_xxx() return TEE_Result values while caller use int. Likely something to be fixed at some point of time.

}

int ti_sci_get_revision(struct ti_sci_msg_resp_version *rev_info)
Expand Down