Lines Matching refs:qh
57 #define for_each_handle_rcu(qh, inst) \
58 list_for_each_entry_rcu(qh, &inst->handles, list, \
86 struct knav_queue *qh;
92 for_each_handle_rcu(qh, inst) {
93 if (atomic_read(&qh->notifier_enabled) <= 0)
95 if (WARN_ON(!qh->notifier_fn))
97 this_cpu_inc(qh->stats->notifies);
98 qh->notifier_fn(qh->notifier_fn_arg);
218 struct knav_queue *qh;
222 qh = devm_kzalloc(inst->kdev->dev, sizeof(*qh), GFP_KERNEL);
223 if (!qh)
226 qh->stats = alloc_percpu(struct knav_queue_stats);
227 if (!qh->stats) {
232 qh->flags = flags;
233 qh->inst = inst;
235 qh->reg_push = &inst->qmgr->reg_push[id];
236 qh->reg_pop = &inst->qmgr->reg_pop[id];
237 qh->reg_peek = &inst->qmgr->reg_peek[id];
250 list_add_tail_rcu(&qh->list, &inst->handles);
251 return qh;
254 if (qh->stats)
255 free_percpu(qh->stats);
256 devm_kfree(inst->kdev->dev, qh);
264 struct knav_queue *qh;
268 qh = ERR_PTR(-ENODEV);
273 qh = ERR_PTR(-EEXIST);
277 qh = ERR_PTR(-EBUSY);
282 qh = __knav_queue_open(inst, name, flags);
287 return qh;
294 struct knav_queue *qh = ERR_PTR(-EINVAL);
306 qh = __knav_queue_open(inst, name, flags);
312 return qh;
323 static int knav_queue_enable_notifier(struct knav_queue *qh)
325 struct knav_queue_inst *inst = qh->inst;
328 if (WARN_ON(!qh->notifier_fn))
332 first = (atomic_inc_return(&qh->notifier_enabled) == 1);
344 static int knav_queue_disable_notifier(struct knav_queue *qh)
346 struct knav_queue_inst *inst = qh->inst;
349 last = (atomic_dec_return(&qh->notifier_enabled) == 0);
360 static int knav_queue_set_notifier(struct knav_queue *qh,
363 knav_queue_notify_fn old_fn = qh->notifier_fn;
368 if (!(qh->inst->range->flags & (RANGE_HAS_ACCUMULATOR | RANGE_HAS_IRQ)))
372 knav_queue_disable_notifier(qh);
374 qh->notifier_fn = cfg->fn;
375 qh->notifier_fn_arg = cfg->fn_arg;
378 knav_queue_enable_notifier(qh);
421 struct knav_queue *qh = qhandle;
422 struct knav_queue_inst *inst = qh->inst;
424 return readl_relaxed(&qh->reg_peek[0].entry_count) +
432 struct knav_queue *qh;
445 for_each_handle_rcu(qh, inst) {
447 pushes += per_cpu_ptr(qh->stats, cpu)->pushes;
448 pops += per_cpu_ptr(qh->stats, cpu)->pops;
449 push_errors += per_cpu_ptr(qh->stats, cpu)->push_errors;
450 pop_errors += per_cpu_ptr(qh->stats, cpu)->pop_errors;
451 notifies += per_cpu_ptr(qh->stats, cpu)->notifies;
455 qh,
458 knav_queue_get_count(qh),
502 static int knav_queue_flush(struct knav_queue *qh)
504 struct knav_queue_inst *inst = qh->inst;
529 struct knav_queue *qh = ERR_PTR(-EINVAL);
535 qh = knav_queue_open_by_type(name, id, flags);
539 qh = knav_queue_open_by_id(name, id, flags);
542 return qh;
548 * @qh - handle to close
552 struct knav_queue *qh = qhandle;
553 struct knav_queue_inst *inst = qh->inst;
555 while (atomic_read(&qh->notifier_enabled) > 0)
556 knav_queue_disable_notifier(qh);
559 list_del_rcu(&qh->list);
568 free_percpu(qh->stats);
569 devm_kfree(inst->kdev->dev, qh);
575 * @qh - queue handle
584 struct knav_queue *qh = qhandle;
590 ret = qh->inst->kdev->base_id + qh->inst->id;
594 ret = knav_queue_flush(qh);
599 ret = knav_queue_set_notifier(qh, cfg);
603 ret = knav_queue_enable_notifier(qh);
607 ret = knav_queue_disable_notifier(qh);
611 ret = knav_queue_get_count(qh);
626 * @qh - hardware queue handle
636 struct knav_queue *qh = qhandle;
640 writel_relaxed(val, &qh->reg_push[0].ptr_size_thresh);
642 this_cpu_inc(qh->stats->pushes);
649 * @qh - hardware queue handle
656 struct knav_queue *qh = qhandle;
657 struct knav_queue_inst *inst = qh->inst;
671 val = readl_relaxed(&qh->reg_pop[0].ptr_size_thresh);
680 this_cpu_inc(qh->stats->pops);