@@ -52,6 +52,8 @@ struct xe_eu_stall_data_stream {
52
52
53
53
struct xe_gt * gt ;
54
54
struct xe_bo * bo ;
55
+ /* Lock to protect data buffer pointers */
56
+ struct mutex xecore_buf_lock ;
55
57
struct per_xecore_buf * xecore_buf ;
56
58
struct {
57
59
bool reported_to_user ;
@@ -378,7 +380,7 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)
378
380
u16 group , instance ;
379
381
unsigned int xecore ;
380
382
381
- mutex_lock (& gt -> eu_stall -> stream_lock );
383
+ mutex_lock (& stream -> xecore_buf_lock );
382
384
for_each_dss_steering (xecore , gt , group , instance ) {
383
385
xecore_buf = & stream -> xecore_buf [xecore ];
384
386
read_ptr = xecore_buf -> read ;
@@ -396,7 +398,7 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)
396
398
set_bit (xecore , stream -> data_drop .mask );
397
399
xecore_buf -> write = write_ptr ;
398
400
}
399
- mutex_unlock (& gt -> eu_stall -> stream_lock );
401
+ mutex_unlock (& stream -> xecore_buf_lock );
400
402
401
403
return min_data_present ;
402
404
}
@@ -511,11 +513,13 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st
511
513
unsigned int xecore ;
512
514
int ret = 0 ;
513
515
516
+ mutex_lock (& stream -> xecore_buf_lock );
514
517
if (bitmap_weight (stream -> data_drop .mask , XE_MAX_DSS_FUSE_BITS )) {
515
518
if (!stream -> data_drop .reported_to_user ) {
516
519
stream -> data_drop .reported_to_user = true;
517
520
xe_gt_dbg (gt , "EU stall data dropped in XeCores: %*pb\n" ,
518
521
XE_MAX_DSS_FUSE_BITS , stream -> data_drop .mask );
522
+ mutex_unlock (& stream -> xecore_buf_lock );
519
523
return - EIO ;
520
524
}
521
525
stream -> data_drop .reported_to_user = false;
@@ -527,6 +531,7 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st
527
531
if (ret || count == total_size )
528
532
break ;
529
533
}
534
+ mutex_unlock (& stream -> xecore_buf_lock );
530
535
return total_size ?: (ret ?: - EAGAIN );
531
536
}
532
537
@@ -583,6 +588,7 @@ static void xe_eu_stall_stream_free(struct xe_eu_stall_data_stream *stream)
583
588
{
584
589
struct xe_gt * gt = stream -> gt ;
585
590
591
+ mutex_destroy (& stream -> xecore_buf_lock );
586
592
gt -> eu_stall -> stream = NULL ;
587
593
kfree (stream );
588
594
}
@@ -718,6 +724,7 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,
718
724
}
719
725
720
726
init_waitqueue_head (& stream -> poll_wq );
727
+ mutex_init (& stream -> xecore_buf_lock );
721
728
INIT_DELAYED_WORK (& stream -> buf_poll_work , eu_stall_data_buf_poll_work_fn );
722
729
stream -> per_xecore_buf_size = per_xecore_buf_size ;
723
730
stream -> sampling_rate_mult = props -> sampling_rate_mult ;
0 commit comments