Lines Matching full:channel

24 	 * PTA_SCMI_CMD_CAPABILITIES - Get channel capabilities
34 * [in] value[0].a: Channel handle
37 * already identified and bound to channel handle in both SCMI agent
47 * [in] value[0].a: Channel handle
59 * PTA_SCMI_CMD_GET_CHANNEL - Get channel handle
63 * [in] value[0].a: Channel identifier
64 * [out] value[0].a: Returned channel handle
73 * [in] value[0].a: Channel handle
105 * struct scmi_optee_channel - Description of an OP-TEE SCMI channel
107 * @channel_id: OP-TEE channel ID used for this transport
109 * @caps: OP-TEE SCMI channel capabilities
111 * @mu: Mutex protection on channel access
112 * @cinfo: SCMI channel information
118 * @link: Reference in agent's channel list
140 * @caps: Supported channel capabilities
223 static int get_channel(struct scmi_optee_channel *channel) in get_channel() argument
231 if (channel->tee_shm) in get_channel()
237 arg.session = channel->tee_session; in get_channel()
241 param[0].u.value.a = channel->channel_id; in get_channel()
247 dev_err(dev, "Can't get channel with caps %#x: %d / %#x\n", caps, ret, arg.ret); in get_channel()
251 /* From now on use channel identifer provided by OP-TEE SCMI service */ in get_channel()
252 channel->channel_id = param[0].u.value.a; in get_channel()
253 channel->caps = caps; in get_channel()
258 static int invoke_process_smt_channel(struct scmi_optee_channel *channel) in invoke_process_smt_channel() argument
262 .session = channel->tee_session, in invoke_process_smt_channel()
269 param[0].u.value.a = channel->channel_id; in invoke_process_smt_channel()
273 dev_err(scmi_optee_private->dev, "Can't invoke channel %u: %d / %#x\n", in invoke_process_smt_channel()
274 channel->channel_id, ret, arg.ret); in invoke_process_smt_channel()
281 static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t msg_size) in invoke_process_msg_channel() argument
285 .session = channel->tee_session, in invoke_process_msg_channel()
292 param[0].u.value.a = channel->channel_id; in invoke_process_msg_channel()
295 param[1].u.memref.shm = channel->tee_shm; in invoke_process_msg_channel()
299 param[2].u.memref.shm = channel->tee_shm; in invoke_process_msg_channel()
304 dev_err(scmi_optee_private->dev, "Can't invoke channel %u: %d / %#x\n", in invoke_process_msg_channel()
305 channel->channel_id, ret, arg.ret); in invoke_process_msg_channel()
310 channel->rx_len = param[2].u.memref.size; in invoke_process_msg_channel()
319 return !of_property_read_u32_index(of_node, "linaro,optee-channel-id", in scmi_optee_chan_available()
325 struct scmi_optee_channel *channel = cinfo->transport_info; in scmi_optee_clear_channel() local
327 if (!channel->tee_shm) in scmi_optee_clear_channel()
328 core->shmem->clear_channel(channel->req.shmem); in scmi_optee_clear_channel()
331 static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *channel) in setup_dynamic_shmem() argument
336 channel->tee_shm = tee_shm_alloc_kernel_buf(scmi_optee_private->tee_ctx, msg_size); in setup_dynamic_shmem()
337 if (IS_ERR(channel->tee_shm)) { in setup_dynamic_shmem()
338 dev_err(channel->cinfo->dev, "shmem allocation failed\n"); in setup_dynamic_shmem()
342 shbuf = tee_shm_get_va(channel->tee_shm, 0); in setup_dynamic_shmem()
344 channel->req.msg = shbuf; in setup_dynamic_shmem()
345 channel->rx_len = msg_size; in setup_dynamic_shmem()
351 struct scmi_optee_channel *channel) in setup_static_shmem() argument
353 channel->req.shmem = core->shmem->setup_iomap(cinfo, dev, true, NULL); in setup_static_shmem()
354 if (IS_ERR(channel->req.shmem)) in setup_static_shmem()
355 return PTR_ERR(channel->req.shmem); in setup_static_shmem()
361 struct scmi_optee_channel *channel) in setup_shmem() argument
364 return setup_static_shmem(dev, cinfo, channel); in setup_shmem()
366 return setup_dynamic_shmem(dev, channel); in setup_shmem()
371 struct scmi_optee_channel *channel; in scmi_optee_chan_setup() local
378 channel = devm_kzalloc(dev, sizeof(*channel), GFP_KERNEL); in scmi_optee_chan_setup()
379 if (!channel) in scmi_optee_chan_setup()
382 ret = of_property_read_u32_index(cinfo->dev->of_node, "linaro,optee-channel-id", in scmi_optee_chan_setup()
387 cinfo->transport_info = channel; in scmi_optee_chan_setup()
388 channel->cinfo = cinfo; in scmi_optee_chan_setup()
389 channel->channel_id = channel_id; in scmi_optee_chan_setup()
390 mutex_init(&channel->mu); in scmi_optee_chan_setup()
392 ret = setup_shmem(dev, cinfo, channel); in scmi_optee_chan_setup()
396 ret = open_session(scmi_optee_private, &channel->tee_session); in scmi_optee_chan_setup()
400 ret = tee_client_system_session(scmi_optee_private->tee_ctx, channel->tee_session); in scmi_optee_chan_setup()
404 ret = get_channel(channel); in scmi_optee_chan_setup()
412 list_add(&channel->link, &scmi_optee_private->channel_list); in scmi_optee_chan_setup()
418 close_session(scmi_optee_private, channel->tee_session); in scmi_optee_chan_setup()
420 if (channel->tee_shm) in scmi_optee_chan_setup()
421 tee_shm_free(channel->tee_shm); in scmi_optee_chan_setup()
429 struct scmi_optee_channel *channel = cinfo->transport_info; in scmi_optee_chan_free() local
435 if (!channel) in scmi_optee_chan_free()
439 list_del(&channel->link); in scmi_optee_chan_free()
442 close_session(scmi_optee_private, channel->tee_session); in scmi_optee_chan_free()
444 if (channel->tee_shm) { in scmi_optee_chan_free()
445 tee_shm_free(channel->tee_shm); in scmi_optee_chan_free()
446 channel->tee_shm = NULL; in scmi_optee_chan_free()
450 channel->cinfo = NULL; in scmi_optee_chan_free()
458 struct scmi_optee_channel *channel = cinfo->transport_info; in scmi_optee_send_message() local
461 mutex_lock(&channel->mu); in scmi_optee_send_message()
463 if (channel->tee_shm) { in scmi_optee_send_message()
464 core->msg->tx_prepare(channel->req.msg, xfer); in scmi_optee_send_message()
465 ret = invoke_process_msg_channel(channel, in scmi_optee_send_message()
468 core->shmem->tx_prepare(channel->req.shmem, xfer, cinfo); in scmi_optee_send_message()
469 ret = invoke_process_smt_channel(channel); in scmi_optee_send_message()
473 mutex_unlock(&channel->mu); in scmi_optee_send_message()
481 struct scmi_optee_channel *channel = cinfo->transport_info; in scmi_optee_fetch_response() local
483 if (channel->tee_shm) in scmi_optee_fetch_response()
484 core->msg->fetch_response(channel->req.msg, in scmi_optee_fetch_response()
485 channel->rx_len, xfer); in scmi_optee_fetch_response()
487 core->shmem->fetch_response(channel->req.shmem, xfer); in scmi_optee_fetch_response()
493 struct scmi_optee_channel *channel = cinfo->transport_info; in scmi_optee_mark_txdone() local
495 mutex_unlock(&channel->mu); in scmi_optee_mark_txdone()