Skip to content
Permalink
Browse files
soc: apple: rtkit: Add recv_message_early callback and apple_rtkit_poll
These allow a client to receive contexts in atomic context, by polling.

Signed-off-by: Hector Martin <marcan@marcan.st>
  • Loading branch information
marcan committed Feb 15, 2022
1 parent 3d937ff commit 11c140423f34e589a6390d378267811426f82984
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
@@ -549,9 +549,15 @@ static void apple_rtkit_rx_callback(struct mbox_client *cl, void *mssg)
struct apple_rtkit *rtk = container_of(cl, struct apple_rtkit, mbox_cl);
struct apple_mbox_msg *msg = mssg;
struct apple_rtkit_work work;
u8 ep = msg->msg1;

dma_rmb();

if (ep >= APPLE_RTKIT_APP_ENDPOINT_START && ep <= 0xff &&
rtk->ops->recv_message_early &&
rtk->ops->recv_message_early(rtk->cookie, ep, msg->msg0))
return;

memcpy(&work.msg, msg, sizeof(*msg));
work.type = APPLE_RTKIT_WORK_MSG;

@@ -633,6 +639,12 @@ int apple_rtkit_send_message_atomic(struct apple_rtkit *rtk, u8 ep, u64 message)
}
EXPORT_SYMBOL_GPL(apple_rtkit_send_message_atomic);

int apple_rtkit_poll(struct apple_rtkit *rtk)
{
return mbox_client_peek_data(rtk->mbox_chan);
}
EXPORT_SYMBOL_GPL(apple_rtkit_poll);

int apple_rtkit_start_ep(struct apple_rtkit *rtk, u8 endpoint)
{
u64 msg;
@@ -38,8 +38,12 @@ struct apple_rtkit_shmem {
*
* @crashed: Called when the co-processor has crashed.
* @recv_message: Function called when a message from RTKit is recevied
* on a non-system endpoint. Called from a worker thread unless
* APPLE_RTKIT_RECV_ATOMIC is set.
* on a non-system endpoint. Called from a worker thread.
* @recv_message_early:
* Like recv_message, but called from atomic context. It
* should return true if it handled the message. If it
* returns false, the message will be passed on to the
* worker thread.
* @shmem_setup: Setup shared memory buffer. If bfr.is_iomem is true the
* buffer is managed by the co-processor and needs to be mapped.
* Otherwise the buffer is managed by Linux and needs to be
@@ -50,6 +54,7 @@ struct apple_rtkit_shmem {
struct apple_rtkit_ops {
void (*crashed)(void *cookie);
void (*recv_message)(void *cookie, u8 endpoint, u64 message);
bool (*recv_message_early)(void *cookie, u8 endpoint, u64 message);
int (*shmem_setup)(void *cookie, struct apple_rtkit_shmem *bfr,
dma_addr_t addr, size_t len);
void (*shmem_destroy)(void *cookie, struct apple_rtkit_shmem *bfr);
@@ -138,6 +143,11 @@ int apple_rtkit_send_message(struct apple_rtkit *rtk, u8 ep, u64 message);
*/
int apple_rtkit_send_message_atomic(struct apple_rtkit *rtk, u8 ep, u64 message);

/*
* Poll for messages to arrive, without sleeping
*/
int apple_rtkit_poll(struct apple_rtkit *rtk);

#else

static inline struct apple_rtkit *
@@ -210,6 +220,11 @@ static inline int apple_rtkit_send_message_atomic(struct apple_rtkit *rtk,
return -ENODEV;
}

int apple_rtkit_poll(struct apple_rtkit *rtk)
{
return -ENODEV;
}

#endif /* IS_ENABLED(CONFIG_APPLE_RTKIT) */

#endif /* _LINUX_APPLE_RTKIT_H_ */

0 comments on commit 11c1404

Please sign in to comment.