Lines Matching refs:stream
69 struct xe_eu_stall_data_stream *stream; member
378 static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream) in eu_stall_data_buf_poll() argument
381 u32 buf_size = stream->per_xecore_buf_size; in eu_stall_data_buf_poll()
383 struct xe_gt *gt = stream->gt; in eu_stall_data_buf_poll()
388 mutex_lock(&stream->xecore_buf_lock); in eu_stall_data_buf_poll()
390 xecore_buf = &stream->xecore_buf[xecore]; in eu_stall_data_buf_poll()
399 if (num_data_rows(total_data) >= stream->wait_num_reports) in eu_stall_data_buf_poll()
403 set_bit(xecore, stream->data_drop.mask); in eu_stall_data_buf_poll()
406 mutex_unlock(&stream->xecore_buf_lock); in eu_stall_data_buf_poll()
427 static int xe_eu_stall_data_buf_read(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_data_buf_read() argument
445 xecore_buf = &stream->xecore_buf[xecore]; in xe_eu_stall_data_buf_read()
449 buf_size = stream->per_xecore_buf_size; in xe_eu_stall_data_buf_read()
492 if (test_bit(xecore, stream->data_drop.mask)) { in xe_eu_stall_data_buf_read()
494 clear_bit(xecore, stream->data_drop.mask); in xe_eu_stall_data_buf_read()
511 static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_stream_read_locked() argument
515 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_read_locked()
521 mutex_lock(&stream->xecore_buf_lock); in xe_eu_stall_stream_read_locked()
522 if (bitmap_weight(stream->data_drop.mask, XE_MAX_DSS_FUSE_BITS)) { in xe_eu_stall_stream_read_locked()
523 if (!stream->data_drop.reported_to_user) { in xe_eu_stall_stream_read_locked()
524 stream->data_drop.reported_to_user = true; in xe_eu_stall_stream_read_locked()
526 XE_MAX_DSS_FUSE_BITS, stream->data_drop.mask); in xe_eu_stall_stream_read_locked()
527 mutex_unlock(&stream->xecore_buf_lock); in xe_eu_stall_stream_read_locked()
530 stream->data_drop.reported_to_user = false; in xe_eu_stall_stream_read_locked()
534 ret = xe_eu_stall_data_buf_read(stream, buf, count, &total_size, in xe_eu_stall_stream_read_locked()
539 mutex_unlock(&stream->xecore_buf_lock); in xe_eu_stall_stream_read_locked()
553 struct xe_eu_stall_data_stream *stream = file->private_data; in xe_eu_stall_stream_read() local
554 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_read()
557 aligned_count = ALIGN_DOWN(count, stream->data_record_size); in xe_eu_stall_stream_read()
561 if (!stream->enabled) { in xe_eu_stall_stream_read()
568 ret = wait_event_interruptible(stream->poll_wq, stream->pollin); in xe_eu_stall_stream_read()
573 ret = xe_eu_stall_stream_read_locked(stream, file, buf, aligned_count); in xe_eu_stall_stream_read()
578 ret = xe_eu_stall_stream_read_locked(stream, file, buf, aligned_count); in xe_eu_stall_stream_read()
587 stream->pollin = false; in xe_eu_stall_stream_read()
592 static void xe_eu_stall_stream_free(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_stream_free() argument
594 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_free()
596 mutex_destroy(&stream->xecore_buf_lock); in xe_eu_stall_stream_free()
597 gt->eu_stall->stream = NULL; in xe_eu_stall_stream_free()
598 kfree(stream); in xe_eu_stall_stream_free()
601 static void xe_eu_stall_data_buf_destroy(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_data_buf_destroy() argument
603 xe_bo_unpin_map_no_vm(stream->bo); in xe_eu_stall_data_buf_destroy()
604 kfree(stream->xecore_buf); in xe_eu_stall_data_buf_destroy()
607 static int xe_eu_stall_data_buf_alloc(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_data_buf_alloc() argument
610 struct xe_tile *tile = stream->gt->tile; in xe_eu_stall_data_buf_alloc()
614 stream->xecore_buf = kcalloc(last_xecore, sizeof(*stream->xecore_buf), GFP_KERNEL); in xe_eu_stall_data_buf_alloc()
615 if (!stream->xecore_buf) in xe_eu_stall_data_buf_alloc()
618 size = stream->per_xecore_buf_size * last_xecore; in xe_eu_stall_data_buf_alloc()
624 kfree(stream->xecore_buf); in xe_eu_stall_data_buf_alloc()
629 stream->bo = bo; in xe_eu_stall_data_buf_alloc()
634 static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_stream_enable() argument
638 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_enable()
667 write_ptr &= (stream->per_xecore_buf_size << 1) - 1; in xe_eu_stall_stream_enable()
668 xecore_buf = &stream->xecore_buf[xecore]; in xe_eu_stall_stream_enable()
672 stream->data_drop.reported_to_user = false; in xe_eu_stall_stream_enable()
673 bitmap_zero(stream->data_drop.mask, XE_MAX_DSS_FUSE_BITS); in xe_eu_stall_stream_enable()
678 stream->sampling_rate_mult)); in xe_eu_stall_stream_enable()
682 reg_value = xe_bo_ggtt_addr(stream->bo); in xe_eu_stall_stream_enable()
684 stream->per_xecore_buf_size / SZ_256K); in xe_eu_stall_stream_enable()
693 struct xe_eu_stall_data_stream *stream = in eu_stall_data_buf_poll_work_fn() local
694 container_of(work, typeof(*stream), buf_poll_work.work); in eu_stall_data_buf_poll_work_fn()
695 struct xe_gt *gt = stream->gt; in eu_stall_data_buf_poll_work_fn()
697 if (eu_stall_data_buf_poll(stream)) { in eu_stall_data_buf_poll_work_fn()
698 stream->pollin = true; in eu_stall_data_buf_poll_work_fn()
699 wake_up(&stream->poll_wq); in eu_stall_data_buf_poll_work_fn()
702 &stream->buf_poll_work, in eu_stall_data_buf_poll_work_fn()
706 static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_stream_init() argument
711 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_init()
731 init_waitqueue_head(&stream->poll_wq); in xe_eu_stall_stream_init()
732 mutex_init(&stream->xecore_buf_lock); in xe_eu_stall_stream_init()
733 INIT_DELAYED_WORK(&stream->buf_poll_work, eu_stall_data_buf_poll_work_fn); in xe_eu_stall_stream_init()
734 stream->per_xecore_buf_size = per_xecore_buf_size; in xe_eu_stall_stream_init()
735 stream->sampling_rate_mult = props->sampling_rate_mult; in xe_eu_stall_stream_init()
736 stream->wait_num_reports = props->wait_num_reports; in xe_eu_stall_stream_init()
737 stream->data_record_size = xe_eu_stall_data_record_size(gt_to_xe(gt)); in xe_eu_stall_stream_init()
739 ret = xe_eu_stall_data_buf_alloc(stream, last_xecore); in xe_eu_stall_stream_init()
744 xecore_buf = &stream->xecore_buf[xecore]; in xe_eu_stall_stream_init()
745 vaddr_offset = xecore * stream->per_xecore_buf_size; in xe_eu_stall_stream_init()
746 xecore_buf->vaddr = stream->bo->vmap.vaddr + vaddr_offset; in xe_eu_stall_stream_init()
751 static __poll_t xe_eu_stall_stream_poll_locked(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_stream_poll_locked() argument
756 poll_wait(file, &stream->poll_wq, wait); in xe_eu_stall_stream_poll_locked()
758 if (stream->pollin) in xe_eu_stall_stream_poll_locked()
766 struct xe_eu_stall_data_stream *stream = file->private_data; in xe_eu_stall_stream_poll() local
767 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_poll()
771 ret = xe_eu_stall_stream_poll_locked(stream, file, wait); in xe_eu_stall_stream_poll()
777 static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_enable_locked() argument
779 struct xe_gt *gt = stream->gt; in xe_eu_stall_enable_locked()
782 if (stream->enabled) in xe_eu_stall_enable_locked()
785 stream->enabled = true; in xe_eu_stall_enable_locked()
787 ret = xe_eu_stall_stream_enable(stream); in xe_eu_stall_enable_locked()
790 &stream->buf_poll_work, in xe_eu_stall_enable_locked()
795 static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) in xe_eu_stall_disable_locked() argument
797 struct xe_gt *gt = stream->gt; in xe_eu_stall_disable_locked()
799 if (!stream->enabled) in xe_eu_stall_disable_locked()
802 stream->enabled = false; in xe_eu_stall_disable_locked()
806 cancel_delayed_work_sync(&stream->buf_poll_work); in xe_eu_stall_disable_locked()
818 static long xe_eu_stall_stream_ioctl_locked(struct xe_eu_stall_data_stream *stream, in xe_eu_stall_stream_ioctl_locked() argument
823 return xe_eu_stall_enable_locked(stream); in xe_eu_stall_stream_ioctl_locked()
825 return xe_eu_stall_disable_locked(stream); in xe_eu_stall_stream_ioctl_locked()
833 struct xe_eu_stall_data_stream *stream = file->private_data; in xe_eu_stall_stream_ioctl() local
834 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_ioctl()
838 ret = xe_eu_stall_stream_ioctl_locked(stream, cmd, arg); in xe_eu_stall_stream_ioctl()
846 struct xe_eu_stall_data_stream *stream = file->private_data; in xe_eu_stall_stream_close() local
847 struct xe_gt *gt = stream->gt; in xe_eu_stall_stream_close()
852 xe_eu_stall_disable_locked(stream); in xe_eu_stall_stream_close()
853 xe_eu_stall_data_buf_destroy(stream); in xe_eu_stall_stream_close()
854 xe_eu_stall_stream_free(stream); in xe_eu_stall_stream_close()
874 struct xe_eu_stall_data_stream *stream; in xe_eu_stall_stream_open_locked() local
880 if (gt->eu_stall->stream) { in xe_eu_stall_stream_open_locked()
885 stream = kzalloc(sizeof(*stream), GFP_KERNEL); in xe_eu_stall_stream_open_locked()
886 if (!stream) in xe_eu_stall_stream_open_locked()
889 gt->eu_stall->stream = stream; in xe_eu_stall_stream_open_locked()
890 stream->gt = gt; in xe_eu_stall_stream_open_locked()
892 ret = xe_eu_stall_stream_init(stream, props); in xe_eu_stall_stream_open_locked()
898 stream_fd = anon_inode_getfd("[xe_eu_stall]", &fops_eu_stall, stream, f_flags); in xe_eu_stall_stream_open_locked()
913 xe_eu_stall_data_buf_destroy(stream); in xe_eu_stall_stream_open_locked()
915 xe_eu_stall_stream_free(stream); in xe_eu_stall_stream_open_locked()