Lines Matching full:stream

66 	/* Lock to protect stream */
68 /* EU stall data stream */
69 struct xe_eu_stall_data_stream *stream; member
371 * @stream: xe EU stall data stream instance
376 static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream) in eu_stall_data_buf_poll() argument
379 u32 buf_size = stream->per_xecore_buf_size; in eu_stall_data_buf_poll()
381 struct xe_gt *gt = stream->gt; in eu_stall_data_buf_poll()
386 mutex_lock(&stream->xecore_buf_lock); in eu_stall_data_buf_poll()
388 xecore_buf = &stream->xecore_buf[xecore]; in eu_stall_data_buf_poll()
397 if (num_data_rows(total_data) >= stream->wait_num_reports) in eu_stall_data_buf_poll()
401 set_bit(xecore, stream->data_drop.mask); in eu_stall_data_buf_poll()
404 mutex_unlock(&stream->xecore_buf_lock); in eu_stall_data_buf_poll()
425 static int xe_eu_stall_data_buf_read(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_data_buf_read() argument
443 xecore_buf = &stream->xecore_buf[xecore]; in xe_eu_stall_data_buf_read()
447 buf_size = stream->per_xecore_buf_size; in xe_eu_stall_data_buf_read()
490 if (test_bit(xecore, stream->data_drop.mask)) { in xe_eu_stall_data_buf_read()
492 clear_bit(xecore, stream->data_drop.mask); in xe_eu_stall_data_buf_read()
500 * @stream: A stream opened for EU stall count metrics
501 * @file: An xe EU stall data stream file
509 static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_stream_read_locked() argument
513 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_read_locked()
519 mutex_lock(&stream->xecore_buf_lock); in xe_eu_stall_stream_read_locked()
520 if (bitmap_weight(stream->data_drop.mask, XE_MAX_DSS_FUSE_BITS)) { in xe_eu_stall_stream_read_locked()
521 if (!stream->data_drop.reported_to_user) { in xe_eu_stall_stream_read_locked()
522 stream->data_drop.reported_to_user = true; in xe_eu_stall_stream_read_locked()
524 XE_MAX_DSS_FUSE_BITS, stream->data_drop.mask); in xe_eu_stall_stream_read_locked()
525 mutex_unlock(&stream->xecore_buf_lock); in xe_eu_stall_stream_read_locked()
528 stream->data_drop.reported_to_user = false; in xe_eu_stall_stream_read_locked()
532 ret = xe_eu_stall_data_buf_read(stream, buf, count, &total_size, in xe_eu_stall_stream_read_locked()
537 mutex_unlock(&stream->xecore_buf_lock); in xe_eu_stall_stream_read_locked()
542 * Userspace must enable the EU stall stream with DRM_XE_OBSERVATION_IOCTL_ENABLE
551 struct xe_eu_stall_data_stream *stream = file->private_data; in xe_eu_stall_stream_read() local
552 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_read()
555 aligned_count = ALIGN_DOWN(count, stream->data_record_size); in xe_eu_stall_stream_read()
559 if (!stream->enabled) { in xe_eu_stall_stream_read()
560 xe_gt_dbg(gt, "EU stall data stream not enabled to read\n"); in xe_eu_stall_stream_read()
566 ret = wait_event_interruptible(stream->poll_wq, stream->pollin); in xe_eu_stall_stream_read()
571 ret = xe_eu_stall_stream_read_locked(stream, file, buf, aligned_count); in xe_eu_stall_stream_read()
576 ret = xe_eu_stall_stream_read_locked(stream, file, buf, aligned_count); in xe_eu_stall_stream_read()
585 stream->pollin = false; in xe_eu_stall_stream_read()
590 static void xe_eu_stall_stream_free(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_stream_free() argument
592 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_free()
594 mutex_destroy(&stream->xecore_buf_lock); in xe_eu_stall_stream_free()
595 gt->eu_stall->stream = NULL; in xe_eu_stall_stream_free()
596 kfree(stream); in xe_eu_stall_stream_free()
599 static void xe_eu_stall_data_buf_destroy(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_data_buf_destroy() argument
601 xe_bo_unpin_map_no_vm(stream->bo); in xe_eu_stall_data_buf_destroy()
602 kfree(stream->xecore_buf); in xe_eu_stall_data_buf_destroy()
605 static int xe_eu_stall_data_buf_alloc(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_data_buf_alloc() argument
608 struct xe_tile *tile = stream->gt->tile; in xe_eu_stall_data_buf_alloc()
612 stream->xecore_buf = kcalloc(last_xecore, sizeof(*stream->xecore_buf), GFP_KERNEL); in xe_eu_stall_data_buf_alloc()
613 if (!stream->xecore_buf) in xe_eu_stall_data_buf_alloc()
616 size = stream->per_xecore_buf_size * last_xecore; in xe_eu_stall_data_buf_alloc()
622 kfree(stream->xecore_buf); in xe_eu_stall_data_buf_alloc()
627 stream->bo = bo; in xe_eu_stall_data_buf_alloc()
632 static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_stream_enable() argument
636 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_enable()
665 write_ptr &= (stream->per_xecore_buf_size << 1) - 1; in xe_eu_stall_stream_enable()
666 xecore_buf = &stream->xecore_buf[xecore]; in xe_eu_stall_stream_enable()
670 stream->data_drop.reported_to_user = false; in xe_eu_stall_stream_enable()
671 bitmap_zero(stream->data_drop.mask, XE_MAX_DSS_FUSE_BITS); in xe_eu_stall_stream_enable()
676 stream->sampling_rate_mult)); in xe_eu_stall_stream_enable()
680 reg_value = xe_bo_ggtt_addr(stream->bo); in xe_eu_stall_stream_enable()
682 stream->per_xecore_buf_size / SZ_256K); in xe_eu_stall_stream_enable()
691 struct xe_eu_stall_data_stream *stream = in eu_stall_data_buf_poll_work_fn() local
692 container_of(work, typeof(*stream), buf_poll_work.work); in eu_stall_data_buf_poll_work_fn()
693 struct xe_gt *gt = stream->gt; in eu_stall_data_buf_poll_work_fn()
695 if (eu_stall_data_buf_poll(stream)) { in eu_stall_data_buf_poll_work_fn()
696 stream->pollin = true; in eu_stall_data_buf_poll_work_fn()
697 wake_up(&stream->poll_wq); in eu_stall_data_buf_poll_work_fn()
700 &stream->buf_poll_work, in eu_stall_data_buf_poll_work_fn()
704 static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_stream_init() argument
709 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_init()
729 init_waitqueue_head(&stream->poll_wq); in xe_eu_stall_stream_init()
730 mutex_init(&stream->xecore_buf_lock); in xe_eu_stall_stream_init()
731 INIT_DELAYED_WORK(&stream->buf_poll_work, eu_stall_data_buf_poll_work_fn); in xe_eu_stall_stream_init()
732 stream->per_xecore_buf_size = per_xecore_buf_size; in xe_eu_stall_stream_init()
733 stream->sampling_rate_mult = props->sampling_rate_mult; in xe_eu_stall_stream_init()
734 stream->wait_num_reports = props->wait_num_reports; in xe_eu_stall_stream_init()
735 stream->data_record_size = xe_eu_stall_data_record_size(gt_to_xe(gt)); in xe_eu_stall_stream_init()
737 ret = xe_eu_stall_data_buf_alloc(stream, last_xecore); in xe_eu_stall_stream_init()
742 xecore_buf = &stream->xecore_buf[xecore]; in xe_eu_stall_stream_init()
743 vaddr_offset = xecore * stream->per_xecore_buf_size; in xe_eu_stall_stream_init()
744 xecore_buf->vaddr = stream->bo->vmap.vaddr + vaddr_offset; in xe_eu_stall_stream_init()
749 static __poll_t xe_eu_stall_stream_poll_locked(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_stream_poll_locked() argument
754 poll_wait(file, &stream->poll_wq, wait); in xe_eu_stall_stream_poll_locked()
756 if (stream->pollin) in xe_eu_stall_stream_poll_locked()
764 struct xe_eu_stall_data_stream *stream = file->private_data; in xe_eu_stall_stream_poll() local
765 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_poll()
769 ret = xe_eu_stall_stream_poll_locked(stream, file, wait); in xe_eu_stall_stream_poll()
775 static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_enable_locked() argument
777 struct xe_gt *gt = stream->gt; in xe_eu_stall_enable_locked()
780 if (stream->enabled) in xe_eu_stall_enable_locked()
783 stream->enabled = true; in xe_eu_stall_enable_locked()
785 ret = xe_eu_stall_stream_enable(stream); in xe_eu_stall_enable_locked()
788 &stream->buf_poll_work, in xe_eu_stall_enable_locked()
793 static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_disable_locked() argument
795 struct xe_gt *gt = stream->gt; in xe_eu_stall_disable_locked()
797 if (!stream->enabled) in xe_eu_stall_disable_locked()
800 stream->enabled = false; in xe_eu_stall_disable_locked()
804 cancel_delayed_work_sync(&stream->buf_poll_work); in xe_eu_stall_disable_locked()
816 static long xe_eu_stall_stream_ioctl_locked(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_stream_ioctl_locked() argument
821 return xe_eu_stall_enable_locked(stream); in xe_eu_stall_stream_ioctl_locked()
823 return xe_eu_stall_disable_locked(stream); in xe_eu_stall_stream_ioctl_locked()
831 struct xe_eu_stall_data_stream *stream = file->private_data; in xe_eu_stall_stream_ioctl() local
832 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_ioctl()
836 ret = xe_eu_stall_stream_ioctl_locked(stream, cmd, arg); in xe_eu_stall_stream_ioctl()
844 struct xe_eu_stall_data_stream *stream = file->private_data; in xe_eu_stall_stream_close() local
845 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_close()
850 xe_eu_stall_disable_locked(stream); in xe_eu_stall_stream_close()
851 xe_eu_stall_data_buf_destroy(stream); in xe_eu_stall_stream_close()
852 xe_eu_stall_stream_free(stream); in xe_eu_stall_stream_close()
872 struct xe_eu_stall_data_stream *stream; in xe_eu_stall_stream_open_locked() local
878 if (gt->eu_stall->stream) { in xe_eu_stall_stream_open_locked()
883 stream = kzalloc(sizeof(*stream), GFP_KERNEL); in xe_eu_stall_stream_open_locked()
884 if (!stream) in xe_eu_stall_stream_open_locked()
887 gt->eu_stall->stream = stream; in xe_eu_stall_stream_open_locked()
888 stream->gt = gt; in xe_eu_stall_stream_open_locked()
890 ret = xe_eu_stall_stream_init(stream, props); in xe_eu_stall_stream_open_locked()
892 xe_gt_dbg(gt, "EU stall stream init failed : %d\n", ret); in xe_eu_stall_stream_open_locked()
896 stream_fd = anon_inode_getfd("[xe_eu_stall]", &fops_eu_stall, stream, f_flags); in xe_eu_stall_stream_open_locked()
911 xe_eu_stall_data_buf_destroy(stream); in xe_eu_stall_stream_open_locked()
913 xe_eu_stall_stream_free(stream); in xe_eu_stall_stream_open_locked()
918 * xe_eu_stall_stream_open - Open a xe EU stall data stream fd
925 * This function opens a EU stall data stream with input properties from
928 * Returns: EU stall data stream fd on success or a negative error code.