Lines Matching refs:ctx
208 * allocate a ctx per file struct
213 struct bcm_vk_ctx *ctx = NULL;
227 for (i = 0; i < ARRAY_SIZE(vk->ctx); i++) {
228 if (!vk->ctx[i].in_use) {
229 vk->ctx[i].in_use = true;
230 ctx = &vk->ctx[i];
235 if (!ctx) {
242 ctx->pid = pid;
243 ctx->hash_idx = hash_idx;
244 list_add_tail(&ctx->node, &vk->pid_ht[hash_idx].head);
250 atomic_set(&ctx->pend_cnt, 0);
251 atomic_set(&ctx->dma_cnt, 0);
252 init_waitqueue_head(&ctx->rd_wq);
258 return ctx;
291 static int bcm_vk_free_ctx(struct bcm_vk *vk, struct bcm_vk_ctx *ctx)
299 if (!ctx) {
303 idx = ctx->idx;
304 pid = ctx->pid;
308 if (!vk->ctx[idx].in_use) {
311 vk->ctx[idx].in_use = false;
312 vk->ctx[idx].miscdev = NULL;
315 list_del(&ctx->node);
316 hash_idx = ctx->hash_idx;
334 atomic_dec(&entry->ctx->dma_cnt);
342 struct bcm_vk_ctx *ctx)
349 if (ctx)
350 vk = container_of(ctx->miscdev, struct bcm_vk, miscdev);
356 if ((!ctx) || (entry->ctx->idx == ctx->idx)) {
368 if (ctx) {
374 /* if it is specific ctx, log for any stuck */
381 "Drained: fid %u size %u msg 0x%x(seq-%x) ctx 0x%x[fd-%d] args:[0x%x 0x%x] resp %s, bmap %d\n",
384 msg->context_id, entry->ctx->idx,
388 atomic_dec(&ctx->pend_cnt);
394 if (num && ctx)
396 num, ctx->idx);
524 struct bcm_vk_ctx *ctx;
529 ctx = entry->ctx;
530 atomic_inc(&ctx->pend_cnt);
531 wake_up_interruptible(&ctx->rd_wq);
609 dev_err(dev, "number of blks %d not matching %d MsgId[0x%x]: func %d ctx 0x%x\n",
939 for (i = 0; i < ARRAY_SIZE(vk->ctx); i++) {
940 vk->ctx[i].in_use = false;
941 vk->ctx[i].idx = i; /* self identity */
942 vk->ctx[i].miscdev = NULL;
973 struct bcm_vk_ctx *ctx;
980 ctx = bcm_vk_get_ctx(vk, task_tgid_nr(current));
981 if (!ctx) {
993 ctx->miscdev = miscdev;
994 p_file->private_data = ctx;
996 ctx->idx, ctx->pid);
1007 struct bcm_vk_ctx *ctx = p_file->private_data;
1008 struct bcm_vk *vk = container_of(ctx->miscdev, struct bcm_vk,
1029 if (iter->ctx->idx == ctx->idx) {
1033 atomic_dec(&ctx->pend_cnt);
1077 struct bcm_vk_ctx *ctx = p_file->private_data;
1078 struct bcm_vk *vk = container_of(ctx->miscdev, struct bcm_vk,
1116 entry->ctx = ctx;
1139 ctx->q_num = q_num;
1142 "[Q-%d]Message ctx id %d, usr_msg_id 0x%x sent msg_id 0x%x\n",
1143 ctx->q_num, ctx->idx, entry->usr_msg_id,
1158 ctx->pid);
1187 atomic_inc(&ctx->dma_cnt);
1253 struct bcm_vk_ctx *ctx = p_file->private_data;
1254 struct bcm_vk *vk = container_of(ctx->miscdev, struct bcm_vk, miscdev);
1257 poll_wait(p_file, &ctx->rd_wq, wait);
1259 cnt = atomic_read(&ctx->pend_cnt);
1264 atomic_set(&ctx->pend_cnt, 0);
1274 struct bcm_vk_ctx *ctx = p_file->private_data;
1275 struct bcm_vk *vk = container_of(ctx->miscdev, struct bcm_vk, miscdev);
1277 pid_t pid = ctx->pid;
1294 dma_cnt, ctx->idx, pid);
1297 dma_cnt = atomic_read(&ctx->dma_cnt);
1302 ctx->idx, pid, jiffies_to_msecs(jiffies - start_time));
1304 bcm_vk_drain_all_pend(&vk->pdev->dev, &vk->to_v_msg_chan, ctx);
1305 bcm_vk_drain_all_pend(&vk->pdev->dev, &vk->to_h_msg_chan, ctx);
1307 ret = bcm_vk_free_ctx(vk, ctx);
1309 ret = bcm_vk_handle_last_sess(vk, pid, ctx->q_num);