Lines Matching defs:stream
140 static u32 xe_oa_circ_diff(struct xe_oa_stream *stream, u32 tail, u32 head)
143 tail + stream->oa_buffer.circ_size - head;
146 static u32 xe_oa_circ_incr(struct xe_oa_stream *stream, u32 ptr, u32 n)
148 return ptr + n >= stream->oa_buffer.circ_size ?
149 ptr + n - stream->oa_buffer.circ_size : ptr + n;
195 static const struct xe_oa_regs *__oa_regs(struct xe_oa_stream *stream)
197 return &stream->hwe->oa_unit->regs;
200 static u32 xe_oa_hw_tail_read(struct xe_oa_stream *stream)
202 return xe_mmio_read32(&stream->gt->mmio, __oa_regs(stream)->oa_tail_ptr) &
209 static u64 oa_report_id(struct xe_oa_stream *stream, void *report)
211 return oa_report_header_64bit(stream) ? *(u64 *)report : *(u32 *)report;
214 static void oa_report_id_clear(struct xe_oa_stream *stream, u32 *report)
216 if (oa_report_header_64bit(stream))
222 static u64 oa_timestamp(struct xe_oa_stream *stream, void *report)
224 return oa_report_header_64bit(stream) ?
229 static void oa_timestamp_clear(struct xe_oa_stream *stream, u32 *report)
231 if (oa_report_header_64bit(stream))
237 static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream)
239 u32 gtt_offset = xe_bo_ggtt_addr(stream->oa_buffer.bo);
241 int report_size = stream->oa_buffer.format->size;
244 spin_lock_irqsave(&stream->oa_buffer.ptr_lock, flags);
246 hw_tail = xe_oa_hw_tail_read(stream);
254 partial_report_size = xe_oa_circ_diff(stream, hw_tail, stream->oa_buffer.tail);
258 hw_tail = xe_oa_circ_diff(stream, hw_tail, partial_report_size);
263 * Walk the stream backward until we find a report with report id and timestamp
270 while (xe_oa_circ_diff(stream, tail, stream->oa_buffer.tail) >= report_size) {
271 void *report = stream->oa_buffer.vaddr + tail;
273 if (oa_report_id(stream, report) || oa_timestamp(stream, report))
276 tail = xe_oa_circ_diff(stream, tail, report_size);
279 if (xe_oa_circ_diff(stream, hw_tail, tail) > report_size)
280 drm_dbg(&stream->oa->xe->drm,
282 stream->oa_buffer.head, tail, hw_tail);
284 stream->oa_buffer.tail = tail;
286 available = xe_oa_circ_diff(stream, stream->oa_buffer.tail, stream->oa_buffer.head);
287 stream->pollin = available >= stream->wait_num_reports * report_size;
289 spin_unlock_irqrestore(&stream->oa_buffer.ptr_lock, flags);
291 return stream->pollin;
296 struct xe_oa_stream *stream =
297 container_of(hrtimer, typeof(*stream), poll_check_timer);
299 if (xe_oa_buffer_check_unlocked(stream))
300 wake_up(&stream->poll_wq);
302 hrtimer_forward_now(hrtimer, ns_to_ktime(stream->poll_period_ns));
307 static int xe_oa_append_report(struct xe_oa_stream *stream, char __user *buf,
310 int report_size = stream->oa_buffer.format->size;
319 oa_buf_end = stream->oa_buffer.vaddr + stream->oa_buffer.circ_size;
327 if (copy_to_user(buf, stream->oa_buffer.vaddr,
339 static int xe_oa_append_reports(struct xe_oa_stream *stream, char __user *buf,
342 int report_size = stream->oa_buffer.format->size;
343 u8 *oa_buf_base = stream->oa_buffer.vaddr;
344 u32 gtt_offset = xe_bo_ggtt_addr(stream->oa_buffer.bo);
350 spin_lock_irqsave(&stream->oa_buffer.ptr_lock, flags);
351 head = stream->oa_buffer.head;
352 tail = stream->oa_buffer.tail;
353 spin_unlock_irqrestore(&stream->oa_buffer.ptr_lock, flags);
355 xe_assert(stream->oa->xe,
356 head < stream->oa_buffer.circ_size && tail < stream->oa_buffer.circ_size);
358 for (; xe_oa_circ_diff(stream, tail, head);
359 head = xe_oa_circ_incr(stream, head, report_size)) {
362 ret = xe_oa_append_report(stream, buf, count, offset, report);
366 if (!(stream->oa_buffer.circ_size % report_size)) {
368 oa_report_id_clear(stream, (void *)report);
369 oa_timestamp_clear(stream, (void *)report);
371 u8 *oa_buf_end = stream->oa_buffer.vaddr + stream->oa_buffer.circ_size;
385 struct xe_reg oaheadptr = __oa_regs(stream)->oa_head_ptr;
387 spin_lock_irqsave(&stream->oa_buffer.ptr_lock, flags);
388 xe_mmio_write32(&stream->gt->mmio, oaheadptr,
390 stream->oa_buffer.head = head;
391 spin_unlock_irqrestore(&stream->oa_buffer.ptr_lock, flags);
397 static void xe_oa_init_oa_buffer(struct xe_oa_stream *stream)
399 u32 gtt_offset = xe_bo_ggtt_addr(stream->oa_buffer.bo);
400 int size_exponent = __ffs(stream->oa_buffer.bo->size);
402 struct xe_mmio *mmio = &stream->gt->mmio;
412 spin_lock_irqsave(&stream->oa_buffer.ptr_lock, flags);
414 xe_mmio_write32(mmio, __oa_regs(stream)->oa_status, 0);
415 xe_mmio_write32(mmio, __oa_regs(stream)->oa_head_ptr,
417 stream->oa_buffer.head = 0;
422 xe_mmio_write32(mmio, __oa_regs(stream)->oa_buffer, oa_buf);
423 xe_mmio_write32(mmio, __oa_regs(stream)->oa_tail_ptr,
427 stream->oa_buffer.tail = 0;
429 spin_unlock_irqrestore(&stream->oa_buffer.ptr_lock, flags);
432 memset(stream->oa_buffer.vaddr, 0, stream->oa_buffer.bo->size);
442 static u32 __oa_ccs_select(struct xe_oa_stream *stream)
446 if (stream->hwe->class != XE_ENGINE_CLASS_COMPUTE)
449 val = REG_FIELD_PREP(OAG_OACONTROL_OA_CCS_SELECT_MASK, stream->hwe->instance);
450 xe_assert(stream->oa->xe,
451 REG_FIELD_GET(OAG_OACONTROL_OA_CCS_SELECT_MASK, val) == stream->hwe->instance);
455 static u32 __oactrl_used_bits(struct xe_oa_stream *stream)
457 return stream->hwe->oa_unit->type == DRM_XE_OA_UNIT_TYPE_OAG ?
461 static void xe_oa_enable(struct xe_oa_stream *stream)
463 const struct xe_oa_format *format = stream->oa_buffer.format;
468 * BSpec: 46822: Bit 0. Even if stream->sample is 0, for OAR to function, the OA
471 xe_oa_init_oa_buffer(stream);
473 regs = __oa_regs(stream);
475 __oa_ccs_select(stream) | OAG_OACONTROL_OA_COUNTER_ENABLE;
477 if (GRAPHICS_VER(stream->oa->xe) >= 20 &&
478 stream->hwe->oa_unit->type == DRM_XE_OA_UNIT_TYPE_OAG)
481 xe_mmio_rmw32(&stream->gt->mmio, regs->oa_ctrl, __oactrl_used_bits(stream), val);
484 static void xe_oa_disable(struct xe_oa_stream *stream)
486 struct xe_mmio *mmio = &stream->gt->mmio;
488 xe_mmio_rmw32(mmio, __oa_regs(stream)->oa_ctrl, __oactrl_used_bits(stream), 0);
489 if (xe_mmio_wait32(mmio, __oa_regs(stream)->oa_ctrl,
491 drm_err(&stream->oa->xe->drm,
494 if (GRAPHICS_VERx100(stream->oa->xe) <= 1270 && GRAPHICS_VERx100(stream->oa->xe) != 1260) {
498 drm_err(&stream->oa->xe->drm,
503 static int xe_oa_wait_unlocked(struct xe_oa_stream *stream)
506 if (!stream->periodic)
509 return wait_event_interruptible(stream->poll_wq,
510 xe_oa_buffer_check_unlocked(stream));
516 static int __xe_oa_read(struct xe_oa_stream *stream, char __user *buf,
520 stream->oa_status = xe_mmio_rmw32(&stream->gt->mmio, __oa_regs(stream)->oa_status,
524 * @DRM_XE_OBSERVATION_IOCTL_STATUS observation stream fd ioctl
526 if (stream->oa_status & OASTATUS_RELEVANT_BITS)
529 return xe_oa_append_reports(stream, buf, count, offset);
535 struct xe_oa_stream *stream = file->private_data;
540 if (!stream->enabled || !stream->sample)
545 ret = xe_oa_wait_unlocked(stream);
549 mutex_lock(&stream->stream_lock);
550 ret = __xe_oa_read(stream, buf, count, &offset);
551 mutex_unlock(&stream->stream_lock);
554 xe_oa_buffer_check_unlocked(stream);
555 mutex_lock(&stream->stream_lock);
556 ret = __xe_oa_read(stream, buf, count, &offset);
557 mutex_unlock(&stream->stream_lock);
570 stream->pollin = false;
576 static __poll_t xe_oa_poll_locked(struct xe_oa_stream *stream,
581 poll_wait(file, &stream->poll_wq, wait);
589 if (stream->pollin)
597 struct xe_oa_stream *stream = file->private_data;
600 mutex_lock(&stream->stream_lock);
601 ret = xe_oa_poll_locked(stream, file, wait);
602 mutex_unlock(&stream->stream_lock);
623 static struct dma_fence *xe_oa_submit_bb(struct xe_oa_stream *stream, enum xe_oa_submit_deps deps,
626 struct xe_exec_queue *q = stream->exec_q ?: stream->k_exec_q;
641 for (int i = 0; i < stream->num_syncs && !err; i++)
642 err = xe_sync_entry_add_deps(&stream->syncs[i], job);
644 drm_dbg(&stream->oa->xe->drm, "xe_sync_entry_add_deps err %d\n", err);
693 static void xe_oa_free_oa_buffer(struct xe_oa_stream *stream)
695 xe_bo_unpin_map_no_vm(stream->oa_buffer.bo);
698 static void xe_oa_free_configs(struct xe_oa_stream *stream)
702 xe_oa_config_put(stream->oa_config);
703 llist_for_each_entry_safe(oa_bo, tmp, stream->oa_config_bos.first, node)
704 free_oa_config_bo(oa_bo, stream->last_fence);
705 dma_fence_put(stream->last_fence);
708 static int xe_oa_load_with_lri(struct xe_oa_stream *stream, struct xe_oa_reg *reg_lri, u32 count)
714 bb = xe_bb_new(stream->gt, 2 * count + 1, false);
722 fence = xe_oa_submit_bb(stream, XE_OA_SUBMIT_NO_DEPS, bb);
737 static int xe_oa_configure_oar_context(struct xe_oa_stream *stream, bool enable)
739 const struct xe_oa_format *format = stream->oa_buffer.format;
745 OACTXCONTROL(stream->hwe->mmio_base),
753 RING_CONTEXT_CONTROL(stream->hwe->mmio_base),
759 return xe_oa_load_with_lri(stream, reg_lri, ARRAY_SIZE(reg_lri));
762 static int xe_oa_configure_oac_context(struct xe_oa_stream *stream, bool enable)
764 const struct xe_oa_format *format = stream->oa_buffer.format;
769 OACTXCONTROL(stream->hwe->mmio_base),
777 RING_CONTEXT_CONTROL(stream->hwe->mmio_base),
785 xe_mmio_write32(&stream->gt->mmio, __oa_regs(stream)->oa_ctrl,
786 __oa_ccs_select(stream));
788 return xe_oa_load_with_lri(stream, reg_lri, ARRAY_SIZE(reg_lri));
791 static int xe_oa_configure_oa_context(struct xe_oa_stream *stream, bool enable)
793 switch (stream->hwe->class) {
795 return xe_oa_configure_oar_context(stream, enable);
797 return xe_oa_configure_oac_context(stream, enable);
806 static u32 oag_configure_mmio_trigger(const struct xe_oa_stream *stream, bool enable)
809 enable && stream && stream->sample ?
813 static void xe_oa_disable_metric_set(struct xe_oa_stream *stream)
815 struct xe_mmio *mmio = &stream->gt->mmio;
819 if (XE_WA(stream->gt, 1508761755)) {
820 xe_gt_mcr_multicast_write(stream->gt, ROW_CHICKEN,
822 xe_gt_mcr_multicast_write(stream->gt, ROW_CHICKEN2,
826 xe_mmio_write32(mmio, __oa_regs(stream)->oa_debug,
827 oag_configure_mmio_trigger(stream, false));
830 if (stream->exec_q)
831 xe_oa_configure_oa_context(stream, false);
837 (HAS_OA_BPC_REPORTING(stream->oa->xe) ? SQCNT1_OABPC : 0);
843 static void xe_oa_stream_destroy(struct xe_oa_stream *stream)
845 struct xe_oa_unit *u = stream->hwe->oa_unit;
846 struct xe_gt *gt = stream->hwe->gt;
848 if (WARN_ON(stream != u->exclusive_stream))
853 mutex_destroy(&stream->stream_lock);
855 xe_oa_disable_metric_set(stream);
856 xe_exec_queue_put(stream->k_exec_q);
858 xe_oa_free_oa_buffer(stream);
861 xe_pm_runtime_put(stream->oa->xe);
864 if (stream->override_gucrc)
867 xe_oa_free_configs(stream);
868 xe_file_put(stream->xef);
871 static int xe_oa_alloc_oa_buffer(struct xe_oa_stream *stream, size_t size)
875 bo = xe_bo_create_pin_map(stream->oa->xe, stream->gt->tile, NULL,
881 stream->oa_buffer.bo = bo;
883 xe_assert(stream->oa->xe, bo->vmap.is_iomem == 0);
884 stream->oa_buffer.vaddr = bo->vmap.vaddr;
889 __xe_oa_alloc_config_buffer(struct xe_oa_stream *stream, struct xe_oa_config *oa_config)
902 bb = xe_bb_new(stream->gt, config_length, false);
910 llist_add(&oa_bo->node, &stream->oa_config_bos);
919 xe_oa_alloc_config_buffer(struct xe_oa_stream *stream, struct xe_oa_config *oa_config)
923 /* Look for the buffer in the already allocated BOs attached to the stream */
924 llist_for_each_entry(oa_bo, stream->oa_config_bos.first, node) {
931 oa_bo = __xe_oa_alloc_config_buffer(stream, oa_config);
936 static void xe_oa_update_last_fence(struct xe_oa_stream *stream, struct dma_fence *fence)
938 dma_fence_put(stream->last_fence);
939 stream->last_fence = dma_fence_get(fence);
979 static int xe_oa_emit_oa_config(struct xe_oa_stream *stream, struct xe_oa_config *config)
993 oa_bo = xe_oa_alloc_config_buffer(stream, config);
1000 fence = xe_oa_submit_bb(stream, XE_OA_SUBMIT_ADD_DEPS, oa_bo->bb);
1010 for (i = 0; i < stream->num_syncs; i++) {
1011 if (stream->syncs[i].flags & DRM_XE_SYNC_FLAG_SIGNAL)
1013 xe_sync_entry_signal(&stream->syncs[i], &ofence->base);
1021 xe_oa_update_last_fence(stream, fence);
1025 xe_gt_assert(stream->gt, !err || err == -ENOENT);
1036 for (i = 0; i < stream->num_syncs; i++)
1037 xe_sync_entry_cleanup(&stream->syncs[i]);
1038 kfree(stream->syncs);
1046 static u32 oag_report_ctx_switches(const struct xe_oa_stream *stream)
1050 stream->sample ?
1054 static u32 oag_buf_size_select(const struct xe_oa_stream *stream)
1057 stream->oa_buffer.bo->size > SZ_16M ?
1061 static int xe_oa_enable_metric_set(struct xe_oa_stream *stream)
1063 struct xe_mmio *mmio = &stream->gt->mmio;
1071 if (XE_WA(stream->gt, 1508761755)) {
1072 xe_gt_mcr_multicast_write(stream->gt, ROW_CHICKEN,
1074 xe_gt_mcr_multicast_write(stream->gt, ROW_CHICKEN2,
1082 if (GRAPHICS_VER(stream->oa->xe) >= 20)
1089 xe_mmio_write32(mmio, __oa_regs(stream)->oa_debug,
1091 oag_report_ctx_switches(stream) |
1092 oag_buf_size_select(stream) |
1093 oag_configure_mmio_trigger(stream, true));
1095 xe_mmio_write32(mmio, __oa_regs(stream)->oa_ctx_ctrl, stream->periodic ?
1099 stream->period_exponent)) : 0);
1107 (HAS_OA_BPC_REPORTING(stream->oa->xe) ? SQCNT1_OABPC : 0);
1112 if (stream->exec_q) {
1113 ret = xe_oa_configure_oa_context(stream, true);
1118 return xe_oa_emit_oa_config(stream, stream->oa_config);
1403 static void xe_oa_stream_enable(struct xe_oa_stream *stream)
1405 stream->pollin = false;
1407 xe_oa_enable(stream);
1409 if (stream->sample)
1410 hrtimer_start(&stream->poll_check_timer,
1411 ns_to_ktime(stream->poll_period_ns),
1415 static void xe_oa_stream_disable(struct xe_oa_stream *stream)
1417 xe_oa_disable(stream);
1419 if (stream->sample)
1420 hrtimer_cancel(&stream->poll_check_timer);
1423 static int xe_oa_enable_preempt_timeslice(struct xe_oa_stream *stream)
1425 struct xe_exec_queue *q = stream->exec_q;
1429 ret1 = q->ops->set_timeslice(q, stream->hwe->eclass->sched_props.timeslice_us);
1430 ret2 = q->ops->set_preempt_timeout(q, stream->hwe->eclass->sched_props.preempt_timeout_us);
1435 drm_dbg(&stream->oa->xe->drm, "%s failed ret1 %d ret2 %d\n", __func__, ret1, ret2);
1439 static int xe_oa_disable_preempt_timeslice(struct xe_oa_stream *stream)
1441 struct xe_exec_queue *q = stream->exec_q;
1455 xe_oa_enable_preempt_timeslice(stream);
1456 drm_dbg(&stream->oa->xe->drm, "%s failed %d\n", __func__, ret);
1460 static int xe_oa_enable_locked(struct xe_oa_stream *stream)
1462 if (stream->enabled)
1465 if (stream->no_preempt) {
1466 int ret = xe_oa_disable_preempt_timeslice(stream);
1472 xe_oa_stream_enable(stream);
1474 stream->enabled = true;
1478 static int xe_oa_disable_locked(struct xe_oa_stream *stream)
1482 if (!stream->enabled)
1485 xe_oa_stream_disable(stream);
1487 if (stream->no_preempt)
1488 ret = xe_oa_enable_preempt_timeslice(stream);
1490 stream->enabled = false;
1494 static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
1497 long ret = stream->oa_config->id;
1501 err = xe_oa_user_extensions(stream->oa, XE_OA_USER_EXTN_FROM_CONFIG, arg, 0, ¶m);
1505 config = xe_oa_get_oa_config(stream->oa, param.metric_set);
1509 param.xef = stream->xef;
1510 err = xe_oa_parse_syncs(stream->oa, ¶m);
1514 stream->num_syncs = param.num_syncs;
1515 stream->syncs = param.syncs;
1517 err = xe_oa_emit_oa_config(stream, config);
1519 config = xchg(&stream->oa_config, config);
1520 drm_dbg(&stream->oa->xe->drm, "changed to oa config uuid=%s\n",
1521 stream->oa_config->uuid);
1530 static long xe_oa_status_locked(struct xe_oa_stream *stream, unsigned long arg)
1536 if (stream->oa_status & OASTATUS_REPORT_LOST)
1538 if (stream->oa_status & OASTATUS_BUFFER_OVERFLOW)
1540 if (stream->oa_status & OASTATUS_COUNTER_OVERFLOW)
1542 if (stream->oa_status & OASTATUS_MMIO_TRG_Q_FULL)
1551 static long xe_oa_info_locked(struct xe_oa_stream *stream, unsigned long arg)
1553 struct drm_xe_oa_stream_info info = { .oa_buf_size = stream->oa_buffer.bo->size, };
1562 static long xe_oa_ioctl_locked(struct xe_oa_stream *stream,
1568 return xe_oa_enable_locked(stream);
1570 return xe_oa_disable_locked(stream);
1572 return xe_oa_config_locked(stream, arg);
1574 return xe_oa_status_locked(stream, arg);
1576 return xe_oa_info_locked(stream, arg);
1586 struct xe_oa_stream *stream = file->private_data;
1589 mutex_lock(&stream->stream_lock);
1590 ret = xe_oa_ioctl_locked(stream, cmd, arg);
1591 mutex_unlock(&stream->stream_lock);
1596 static void xe_oa_destroy_locked(struct xe_oa_stream *stream)
1598 if (stream->enabled)
1599 xe_oa_disable_locked(stream);
1601 xe_oa_stream_destroy(stream);
1603 if (stream->exec_q)
1604 xe_exec_queue_put(stream->exec_q);
1606 kfree(stream);
1611 struct xe_oa_stream *stream = file->private_data;
1612 struct xe_gt *gt = stream->gt;
1616 xe_oa_destroy_locked(stream);
1620 /* Release the reference the OA stream kept on the driver */
1628 struct xe_oa_stream *stream = file->private_data;
1629 struct xe_bo *bo = stream->oa_buffer.bo;
1634 drm_dbg(&stream->oa->xe->drm, "Insufficient privilege to map OA buffer\n");
1639 if (vma->vm_end - vma->vm_start != stream->oa_buffer.bo->size) {
1640 drm_dbg(&stream->oa->xe->drm, "Wrong mmap size, must be OA buffer size\n");
1649 drm_dbg(&stream->oa->xe->drm, "mmap must be read only\n");
1655 xe_assert(stream->oa->xe, bo->ttm.ttm->num_pages == vma_pages(vma));
1677 static int xe_oa_stream_init(struct xe_oa_stream *stream,
1685 stream->exec_q = param->exec_q;
1686 stream->poll_period_ns = DEFAULT_POLL_PERIOD_NS;
1687 stream->hwe = param->hwe;
1688 stream->gt = stream->hwe->gt;
1689 stream->oa_buffer.format = &stream->oa->oa_formats[param->oa_format];
1691 stream->sample = param->sample;
1692 stream->periodic = param->period_exponent >= 0;
1693 stream->period_exponent = param->period_exponent;
1694 stream->no_preempt = param->no_preempt;
1695 stream->wait_num_reports = param->wait_num_reports;
1697 stream->xef = xe_file_get(param->xef);
1698 stream->num_syncs = param->num_syncs;
1699 stream->syncs = param->syncs;
1706 if (GRAPHICS_VER(stream->oa->xe) >= 20 &&
1707 stream->hwe->oa_unit->type == DRM_XE_OA_UNIT_TYPE_OAG && stream->sample)
1708 stream->oa_buffer.circ_size =
1710 param->oa_buffer_size % stream->oa_buffer.format->size;
1712 stream->oa_buffer.circ_size = param->oa_buffer_size;
1714 stream->oa_config = xe_oa_get_oa_config(stream->oa, param->metric_set);
1715 if (!stream->oa_config) {
1716 drm_dbg(&stream->oa->xe->drm, "Invalid OA config id=%i\n", param->metric_set);
1725 if (XE_WA(stream->gt, 1509372804)) {
1731 stream->override_gucrc = true;
1735 xe_pm_runtime_get(stream->oa->xe);
1742 ret = xe_oa_alloc_oa_buffer(stream, param->oa_buffer_size);
1746 stream->k_exec_q = xe_exec_queue_create(stream->oa->xe, NULL,
1747 BIT(stream->hwe->logical_instance), 1,
1748 stream->hwe, EXEC_QUEUE_FLAG_KERNEL, 0);
1749 if (IS_ERR(stream->k_exec_q)) {
1750 ret = PTR_ERR(stream->k_exec_q);
1751 drm_err(&stream->oa->xe->drm, "gt%d, hwe %s, xe_exec_queue_create failed=%d",
1752 stream->gt->info.id, stream->hwe->name, ret);
1756 ret = xe_oa_enable_metric_set(stream);
1758 drm_dbg(&stream->oa->xe->drm, "Unable to enable metric set\n");
1762 drm_dbg(&stream->oa->xe->drm, "opening stream oa config uuid=%s\n",
1763 stream->oa_config->uuid);
1765 WRITE_ONCE(u->exclusive_stream, stream);
1767 hrtimer_setup(&stream->poll_check_timer, xe_oa_poll_check_timer_cb, CLOCK_MONOTONIC,
1769 init_waitqueue_head(&stream->poll_wq);
1771 spin_lock_init(&stream->oa_buffer.ptr_lock);
1772 mutex_init(&stream->stream_lock);
1777 xe_oa_disable_metric_set(stream);
1778 xe_exec_queue_put(stream->k_exec_q);
1780 xe_oa_free_oa_buffer(stream);
1783 xe_pm_runtime_put(stream->oa->xe);
1784 if (stream->override_gucrc)
1787 xe_oa_free_configs(stream);
1789 xe_file_put(stream->xef);
1796 struct xe_oa_stream *stream;
1807 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
1808 if (!stream) {
1813 stream->oa = oa;
1814 ret = xe_oa_stream_init(stream, param);
1819 ret = xe_oa_enable_locked(stream);
1824 stream_fd = anon_inode_getfd("[xe_oa]", &xe_oa_fops, stream, 0);
1831 drm_dev_get(&stream->oa->xe->drm);
1836 xe_oa_disable_locked(stream);
1838 xe_oa_stream_destroy(stream);
1840 kfree(stream);
1937 * xe_oa_stream_open_ioctl - Opens an OA stream
1942 * The functions opens an OA stream. An OA stream, opened with specified
1978 * without global stream access, can be an unprivileged operation
1993 drm_dbg(&oa->xe->drm, "Insufficient privileges to open xe OA stream\n");
2262 * OA stream.
2533 /* Ensure MMIO trigger remains disabled till there is a stream */