Lines Matching refs:channel

23 	 * PTA_SCMI_CMD_CAPABILITIES - Get channel capabilities
36 * already identified and bound to channel handle in both SCMI agent
58 * PTA_SCMI_CMD_GET_CHANNEL - Get channel handle
63 * [out] value[0].a: Returned channel handle
104 * struct scmi_optee_channel - Description of an OP-TEE SCMI channel
106 * @channel_id: OP-TEE channel ID used for this transport
108 * @caps: OP-TEE SCMI channel capabilities
110 * @mu: Mutex protection on channel access
111 * @cinfo: SCMI channel information
117 * @link: Reference in agent's channel list
139 * @caps: Supported channel capabilities
223 static int get_channel(struct scmi_optee_channel *channel)
231 if (channel->tee_shm)
237 arg.session = channel->tee_session;
241 param[0].u.value.a = channel->channel_id;
247 dev_err(dev, "Can't get channel with caps %#x: %d / %#x\n", caps, ret, arg.ret);
251 /* From now on use channel identifer provided by OP-TEE SCMI service */
252 channel->channel_id = param[0].u.value.a;
253 channel->caps = caps;
258 static int invoke_process_smt_channel(struct scmi_optee_channel *channel)
262 .session = channel->tee_session,
269 param[0].u.value.a = channel->channel_id;
273 dev_err(scmi_optee_private->dev, "Can't invoke channel %u: %d / %#x\n",
274 channel->channel_id, ret, arg.ret);
281 static int invoke_process_msg_channel(struct scmi_optee_channel *channel, size_t msg_size)
285 .session = channel->tee_session,
292 param[0].u.value.a = channel->channel_id;
295 param[1].u.memref.shm = channel->tee_shm;
299 param[2].u.memref.shm = channel->tee_shm;
304 dev_err(scmi_optee_private->dev, "Can't invoke channel %u: %d / %#x\n",
305 channel->channel_id, ret, arg.ret);
310 channel->rx_len = param[2].u.memref.size;
337 return !of_property_read_u32_index(of_node, "linaro,optee-channel-id",
343 struct scmi_optee_channel *channel = cinfo->transport_info;
345 if (!channel->tee_shm)
346 shmem_clear_channel(channel->req.shmem);
349 static int setup_dynamic_shmem(struct device *dev, struct scmi_optee_channel *channel)
354 channel->tee_shm = tee_shm_alloc_kernel_buf(scmi_optee_private->tee_ctx, msg_size);
355 if (IS_ERR(channel->tee_shm)) {
356 dev_err(channel->cinfo->dev, "shmem allocation failed\n");
360 shbuf = tee_shm_get_va(channel->tee_shm, 0);
362 channel->req.msg = shbuf;
363 channel->rx_len = msg_size;
369 struct scmi_optee_channel *channel)
390 channel->req.shmem = devm_ioremap(dev, res.start, size);
391 if (!channel->req.shmem) {
406 struct scmi_optee_channel *channel)
409 return setup_static_shmem(dev, cinfo, channel);
411 return setup_dynamic_shmem(dev, channel);
416 struct scmi_optee_channel *channel;
423 channel = devm_kzalloc(dev, sizeof(*channel), GFP_KERNEL);
424 if (!channel)
427 ret = of_property_read_u32_index(cinfo->dev->of_node, "linaro,optee-channel-id",
432 cinfo->transport_info = channel;
433 channel->cinfo = cinfo;
434 channel->channel_id = channel_id;
435 mutex_init(&channel->mu);
437 ret = setup_shmem(dev, cinfo, channel);
441 ret = open_session(scmi_optee_private, &channel->tee_session);
445 ret = tee_client_system_session(scmi_optee_private->tee_ctx, channel->tee_session);
449 ret = get_channel(channel);
457 list_add(&channel->link, &scmi_optee_private->channel_list);
463 close_session(scmi_optee_private, channel->tee_session);
465 if (channel->tee_shm)
466 tee_shm_free(channel->tee_shm);
474 struct scmi_optee_channel *channel = cinfo->transport_info;
477 list_del(&channel->link);
480 close_session(scmi_optee_private, channel->tee_session);
482 if (channel->tee_shm) {
483 tee_shm_free(channel->tee_shm);
484 channel->tee_shm = NULL;
488 channel->cinfo = NULL;
496 struct scmi_optee_channel *channel = cinfo->transport_info;
499 mutex_lock(&channel->mu);
501 if (channel->tee_shm) {
502 msg_tx_prepare(channel->req.msg, xfer);
503 ret = invoke_process_msg_channel(channel, msg_command_size(xfer));
505 shmem_tx_prepare(channel->req.shmem, xfer, cinfo);
506 ret = invoke_process_smt_channel(channel);
510 mutex_unlock(&channel->mu);
518 struct scmi_optee_channel *channel = cinfo->transport_info;
520 if (channel->tee_shm)
521 msg_fetch_response(channel->req.msg, channel->rx_len, xfer);
523 shmem_fetch_response(channel->req.shmem, xfer);
529 struct scmi_optee_channel *channel = cinfo->transport_info;
531 mutex_unlock(&channel->mu);