-
Notifications
You must be signed in to change notification settings - Fork 5
/
nouveau-multithreading-fixes.patch
6151 lines (5379 loc) · 247 KB
/
nouveau-multithreading-fixes.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 03891efe6d84ccedfab025173b587bc59b487026 Mon Sep 17 00:00:00 2001
From: Karol Herbst <kherbst@redhat.com>
Date: Fri, 7 May 2021 14:48:42 +0200
Subject: [PATCH 01/17] nouveau/buffer: simplify uses of nouveau_fence_work
nouveau_fence_work already checks the state, so we can just call it
directly.
Strictly speaking, this isn't functional equivalent, but practically it
doesn't matter when we get the callback called.
Main reason for doing this is, that this makes locking way easier as we
can simply lock within nouveau_fence_* functions and callers don't have to
take locks themselves.
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: M Henning <drawoc@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10752>
---
src/gallium/drivers/nouveau/nouveau_buffer.c | 8 ++------
src/gallium/drivers/nouveau/nv50/nv50_miptree.c | 6 +-----
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c
index 284525086d0..78f8a9cb5d8 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -91,12 +91,8 @@ nouveau_buffer_release_gpu_storage(struct nv04_resource *buf)
{
assert(!(buf->status & NOUVEAU_BUFFER_STATUS_USER_PTR));
- if (buf->fence && buf->fence->state < NOUVEAU_FENCE_STATE_FLUSHED) {
- nouveau_fence_work(buf->fence, nouveau_fence_unref_bo, buf->bo);
- buf->bo = NULL;
- } else {
- nouveau_bo_ref(NULL, &buf->bo);
- }
+ nouveau_fence_work(buf->fence, nouveau_fence_unref_bo, buf->bo);
+ buf->bo = NULL;
if (buf->mm)
release_allocation(&buf->mm, buf->fence);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
index 8f45d9e659f..4554dbf02d4 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
@@ -163,11 +163,7 @@ nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt)
{
struct nv50_miptree *mt = nv50_miptree(pt);
- if (mt->base.fence && mt->base.fence->state < NOUVEAU_FENCE_STATE_FLUSHED)
- nouveau_fence_work(mt->base.fence, nouveau_fence_unref_bo, mt->base.bo);
- else
- nouveau_bo_ref(NULL, &mt->base.bo);
-
+ nouveau_fence_work(mt->base.fence, nouveau_fence_unref_bo, mt->base.bo);
nouveau_fence_ref(NULL, &mt->base.fence);
nouveau_fence_ref(NULL, &mt->base.fence_wr);
--
2.37.3
From 7d1872d683a62000dd5e878f14bb3e31c1a49a05 Mon Sep 17 00:00:00 2001
From: Karol Herbst <kherbst@redhat.com>
Date: Fri, 7 May 2021 15:01:18 +0200
Subject: [PATCH 02/17] nouveau/fence: rework nouveau_fence_emit so we can call
it on emitted fences
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10752>
---
src/gallium/drivers/nouveau/nouveau_fence.c | 10 ++++------
src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c | 4 ++--
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nouveau_fence.c b/src/gallium/drivers/nouveau/nouveau_fence.c
index 117bce3b5c8..a0789739fa3 100644
--- a/src/gallium/drivers/nouveau/nouveau_fence.c
+++ b/src/gallium/drivers/nouveau/nouveau_fence.c
@@ -60,7 +60,9 @@ nouveau_fence_emit(struct nouveau_fence *fence)
{
struct nouveau_screen *screen = fence->screen;
- assert(fence->state == NOUVEAU_FENCE_STATE_AVAILABLE);
+ assert(fence->state != NOUVEAU_FENCE_STATE_EMITTING);
+ if (fence->state >= NOUVEAU_FENCE_STATE_EMITTED)
+ return;
/* set this now, so that if fence.emit triggers a flush we don't recurse */
fence->state = NOUVEAU_FENCE_STATE_EMITTING;
@@ -190,11 +192,7 @@ nouveau_fence_kick(struct nouveau_fence *fence)
if (fence->state < NOUVEAU_FENCE_STATE_EMITTED) {
PUSH_SPACE(screen->pushbuf, 8);
- /* The space allocation might trigger a flush, which could emit the
- * current fence. So check again.
- */
- if (fence->state < NOUVEAU_FENCE_STATE_EMITTED)
- nouveau_fence_emit(fence);
+ nouveau_fence_emit(fence);
}
if (fence->state < NOUVEAU_FENCE_STATE_FLUSHED)
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
index d2c011fc1da..e1738508798 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
@@ -420,7 +420,7 @@ nvc0_hw_get_query_result_resource(struct nvc0_context *nvc0,
/* If the fence guarding this query has not been emitted, that makes a lot
* of the following logic more complicated.
*/
- if (hq->is64bit && hq->fence->state < NOUVEAU_FENCE_STATE_EMITTED)
+ if (hq->is64bit)
nouveau_fence_emit(hq->fence);
/* We either need to compute a 32- or 64-bit difference between 2 values,
@@ -642,7 +642,7 @@ nvc0_hw_query_fifo_wait(struct nvc0_context *nvc0, struct nvc0_query *q)
unsigned offset = hq->offset;
/* ensure the query's fence has been emitted */
- if (hq->is64bit && hq->fence->state < NOUVEAU_FENCE_STATE_EMITTED)
+ if (hq->is64bit)
nouveau_fence_emit(hq->fence);
PUSH_SPACE(push, 5);
--
2.37.3
From 05bfbdba563e3436100d7bf1cb7e360f7c7632b4 Mon Sep 17 00:00:00 2001
From: Karol Herbst <kherbst@redhat.com>
Date: Thu, 10 Jun 2021 16:16:24 +0200
Subject: [PATCH 03/17] nouveau: move nouveau_context initialization to common
code
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10752>
---
src/gallium/drivers/nouveau/nouveau_context.h | 2 +-
src/gallium/drivers/nouveau/nouveau_screen.c | 6 +++++-
src/gallium/drivers/nouveau/nv30/nv30_context.c | 14 +++-----------
src/gallium/drivers/nouveau/nv50/nv50_context.c | 5 +----
src/gallium/drivers/nouveau/nvc0/nvc0_context.c | 6 +-----
5 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h
index 3d4af8d765c..e7941b45ec5 100644
--- a/src/gallium/drivers/nouveau/nouveau_context.h
+++ b/src/gallium/drivers/nouveau/nouveau_context.h
@@ -66,7 +66,7 @@ void
nouveau_context_init_vdec(struct nouveau_context *);
void
-nouveau_context_init(struct nouveau_context *);
+nouveau_context_init(struct nouveau_context *, struct nouveau_screen *);
void
nouveau_scratch_runout_release(struct nouveau_context *);
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index 7312a5b1f98..ac69b9d3968 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -393,7 +393,11 @@ nouveau_set_debug_callback(struct pipe_context *pipe,
}
void
-nouveau_context_init(struct nouveau_context *context)
+nouveau_context_init(struct nouveau_context *context, struct nouveau_screen *screen)
{
context->pipe.set_debug_callback = nouveau_set_debug_callback;
+
+ context->screen = screen;
+ context->client = screen->client;
+ context->pushbuf = screen->pushbuf;
}
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_context.c b/src/gallium/drivers/nouveau/nv30/nv30_context.c
index 83c3c6fd82d..4ce28864b8d 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_context.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_context.c
@@ -191,7 +191,6 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
{
struct nv30_screen *screen = nv30_screen(pscreen);
struct nv30_context *nv30 = CALLOC_STRUCT(nv30_context);
- struct nouveau_pushbuf *push;
struct pipe_context *pipe;
int ret;
@@ -199,7 +198,6 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
return NULL;
nv30->screen = screen;
- nv30->base.screen = &screen->base;
nv30->base.copy_data = nv30_transfer_copy_data;
pipe = &nv30->base.pipe;
@@ -208,6 +206,9 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
pipe->destroy = nv30_context_destroy;
pipe->flush = nv30_context_flush;
+ nouveau_context_init(&nv30->base, &screen->base);
+ nv30->base.pushbuf->kick_notify = nv30_context_kick_notify;
+
nv30->base.pipe.stream_uploader = u_upload_create_default(&nv30->base.pipe);
if (!nv30->base.pipe.stream_uploader) {
nv30_context_destroy(pipe);
@@ -215,14 +216,6 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
}
nv30->base.pipe.const_uploader = nv30->base.pipe.stream_uploader;
- /*XXX: *cough* per-context client */
- nv30->base.client = screen->base.client;
-
- /*XXX: *cough* per-context pushbufs */
- push = screen->base.pushbuf;
- nv30->base.pushbuf = push;
- push->kick_notify = nv30_context_kick_notify;
-
nv30->base.invalidate_resource_storage = nv30_invalidate_resource_storage;
ret = nouveau_bufctx_new(nv30->base.client, 64, &nv30->bufctx);
@@ -244,7 +237,6 @@ nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
if (debug_get_bool_option("NV30_SWTNL", false))
nv30->draw_flags |= NV30_NEW_SWTNL;
- nouveau_context_init(&nv30->base);
nv30->sample_mask = 0xffff;
nv30_vbo_init(pipe);
nv30_query_init(pipe);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c b/src/gallium/drivers/nouveau/nv50/nv50_context.c
index c6ba3d4df9c..6b7b6889d38 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_context.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c
@@ -313,8 +313,7 @@ nv50_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
if (!nv50_blitctx_create(nv50))
goto out_err;
- nv50->base.pushbuf = screen->base.pushbuf;
- nv50->base.client = screen->base.client;
+ nouveau_context_init(&nv50->base, &screen->base);
ret = nouveau_bufctx_new(nv50->base.client, 2, &nv50->bufctx);
if (!ret)
@@ -326,7 +325,6 @@ nv50_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
if (ret)
goto out_err;
- nv50->base.screen = &screen->base;
nv50->base.copy_data = nv50_m2mf_copy_linear;
nv50->base.push_data = nv50_sifc_linear_u8;
nv50->base.push_cb = nv50_cb_push;
@@ -361,7 +359,6 @@ nv50_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
}
nv50->base.pushbuf->kick_notify = nv50_default_kick_notify;
- nouveau_context_init(&nv50->base);
nv50_init_query_functions(nv50);
nv50_init_surface_functions(nv50);
nv50_init_state_functions(nv50);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
index 546c92361c2..c21c5e130b8 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
@@ -425,8 +425,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
if (!nvc0_blitctx_create(nvc0))
goto out_err;
- nvc0->base.pushbuf = screen->base.pushbuf;
- nvc0->base.client = screen->base.client;
+ nouveau_context_init(&nvc0->base, &screen->base);
ret = nouveau_bufctx_new(nvc0->base.client, 2, &nvc0->bufctx);
if (!ret)
@@ -439,8 +438,6 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
goto out_err;
nvc0->screen = screen;
- nvc0->base.screen = &screen->base;
-
pipe->screen = pscreen;
pipe->priv = priv;
pipe->stream_uploader = u_upload_create_default(pipe);
@@ -464,7 +461,6 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
pipe->emit_string_marker = nvc0_emit_string_marker;
pipe->get_device_reset_status = nvc0_get_device_reset_status;
- nouveau_context_init(&nvc0->base);
nvc0_init_query_functions(nvc0);
nvc0_init_surface_functions(nvc0);
nvc0_init_state_functions(nvc0);
--
2.37.3
From bc4f80ef83e333b203ba37bff63474091dc6b6de Mon Sep 17 00:00:00 2001
From: Karol Herbst <kherbst@redhat.com>
Date: Fri, 25 Jun 2021 22:44:26 +0200
Subject: [PATCH 04/17] nouveau: wrap nouveau_bo_map
This makes it easier to insert locking code around libdrm.
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: M Henning <drawoc@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10752>
---
src/gallium/drivers/nouveau/nouveau_buffer.c | 22 +++++++++----------
src/gallium/drivers/nouveau/nouveau_video.c | 6 ++---
.../drivers/nouveau/nouveau_vp3_video.c | 4 +++-
src/gallium/drivers/nouveau/nouveau_winsys.h | 7 ++++++
.../drivers/nouveau/nv30/nv30_miptree.c | 2 +-
.../drivers/nouveau/nv30/nv30_screen.c | 2 +-
.../drivers/nouveau/nv30/nv30_transfer.c | 4 ++--
.../drivers/nouveau/nv50/nv50_compute.c | 2 +-
.../drivers/nouveau/nv50/nv50_query_hw.c | 2 +-
.../drivers/nouveau/nv50/nv50_screen.c | 2 +-
.../drivers/nouveau/nv50/nv50_transfer.c | 2 +-
src/gallium/drivers/nouveau/nv50/nv84_video.c | 11 +++++-----
src/gallium/drivers/nouveau/nv50/nv98_video.c | 2 +-
.../drivers/nouveau/nv50/nv98_video_bsp.c | 3 ++-
.../drivers/nouveau/nv50/nv98_video_vp.c | 3 ++-
.../drivers/nouveau/nvc0/nvc0_query_hw.c | 2 +-
.../drivers/nouveau/nvc0/nvc0_screen.c | 2 +-
.../drivers/nouveau/nvc0/nvc0_transfer.c | 4 ++--
src/gallium/drivers/nouveau/nvc0/nvc0_video.c | 2 +-
.../drivers/nouveau/nvc0/nvc0_video_bsp.c | 8 ++++---
.../drivers/nouveau/nvc0/nvc0_video_vp.c | 3 ++-
.../drivers/nouveau/nvc0/nve4_compute.c | 2 +-
22 files changed, 56 insertions(+), 41 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c
index 78f8a9cb5d8..e566541a579 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -168,7 +168,7 @@ nouveau_transfer_staging(struct nouveau_context *nv,
nouveau_mm_allocate(nv->screen->mm_GART, size, &tx->bo, &tx->offset);
if (tx->bo) {
tx->offset += adj;
- if (!nouveau_bo_map(tx->bo, 0, NULL))
+ if (!BO_MAP(nv->screen, tx->bo, 0, NULL))
tx->map = (uint8_t *)tx->bo->map + tx->offset;
}
}
@@ -471,9 +471,9 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe,
* wait on the whole slab and instead use the logic below to return a
* reasonable buffer for that case.
*/
- ret = nouveau_bo_map(buf->bo,
- buf->mm ? 0 : nouveau_screen_transfer_flags(usage),
- nv->client);
+ ret = BO_MAP(nv->screen, buf->bo,
+ buf->mm ? 0 : nouveau_screen_transfer_flags(usage),
+ nv->client);
if (ret) {
FREE(tx);
return NULL;
@@ -639,10 +639,10 @@ nouveau_resource_map_offset(struct nouveau_context *nv,
unsigned rw;
rw = (flags & NOUVEAU_BO_WR) ? PIPE_MAP_WRITE : PIPE_MAP_READ;
nouveau_buffer_sync(nv, res, rw);
- if (nouveau_bo_map(res->bo, 0, NULL))
+ if (BO_MAP(nv->screen, res->bo, 0, NULL))
return NULL;
} else {
- if (nouveau_bo_map(res->bo, flags, nv->client))
+ if (BO_MAP(nv->screen, res->bo, flags, nv->client))
return NULL;
}
return (uint8_t *)res->bo->map + res->offset + offset;
@@ -798,7 +798,7 @@ nouveau_buffer_data_fetch(struct nouveau_context *nv, struct nv04_resource *buf,
{
if (!nouveau_buffer_malloc(buf))
return false;
- if (nouveau_bo_map(bo, NOUVEAU_BO_RD, nv->client))
+ if (BO_MAP(nv->screen, bo, NOUVEAU_BO_RD, nv->client))
return false;
memcpy(buf->data, (uint8_t *)bo->map + offset, size);
return true;
@@ -823,7 +823,7 @@ nouveau_buffer_migrate(struct nouveau_context *nv,
if (new_domain == NOUVEAU_BO_GART && old_domain == 0) {
if (!nouveau_buffer_allocate(screen, buf, new_domain))
return false;
- ret = nouveau_bo_map(buf->bo, 0, nv->client);
+ ret = BO_MAP(nv->screen, buf->bo, 0, nv->client);
if (ret)
return ret;
memcpy((uint8_t *)buf->bo->map + buf->offset, buf->data, size);
@@ -893,7 +893,7 @@ nouveau_user_buffer_upload(struct nouveau_context *nv,
if (!nouveau_buffer_reallocate(screen, buf, NOUVEAU_BO_GART))
return false;
- ret = nouveau_bo_map(buf->bo, 0, nv->client);
+ ret = BO_MAP(nv->screen, buf->bo, 0, nv->client);
if (ret)
return false;
memcpy((uint8_t *)buf->bo->map + buf->offset + base, buf->data + base, size);
@@ -989,7 +989,7 @@ nouveau_scratch_runout(struct nouveau_context *nv, unsigned size)
ret = nouveau_scratch_bo_alloc(nv, &nv->scratch.runout->bo[n], size);
if (!ret) {
- ret = nouveau_bo_map(nv->scratch.runout->bo[n], 0, NULL);
+ ret = BO_MAP(nv->screen, nv->scratch.runout->bo[n], 0, NULL);
if (ret)
nouveau_bo_ref(NULL, &nv->scratch.runout->bo[--nv->scratch.runout->nr]);
}
@@ -1027,7 +1027,7 @@ nouveau_scratch_next(struct nouveau_context *nv, unsigned size)
nv->scratch.offset = 0;
nv->scratch.end = nv->scratch.bo_size;
- ret = nouveau_bo_map(bo, NOUVEAU_BO_WR, nv->client);
+ ret = BO_MAP(nv->screen, bo, NOUVEAU_BO_WR, nv->client);
if (!ret)
nv->scratch.map = bo->map;
return !ret;
diff --git a/src/gallium/drivers/nouveau/nouveau_video.c b/src/gallium/drivers/nouveau/nouveau_video.c
index 5c94686625f..787129b376e 100644
--- a/src/gallium/drivers/nouveau/nouveau_video.c
+++ b/src/gallium/drivers/nouveau/nouveau_video.c
@@ -37,12 +37,12 @@ nouveau_vpe_init(struct nouveau_decoder *dec) {
int ret;
if (dec->cmds)
return 0;
- ret = nouveau_bo_map(dec->cmd_bo, NOUVEAU_BO_RDWR, dec->client);
+ ret = BO_MAP(dec->screen, dec->cmd_bo, NOUVEAU_BO_RDWR, dec->client);
if (ret) {
debug_printf("Mapping cmd bo: %s\n", strerror(-ret));
return ret;
}
- ret = nouveau_bo_map(dec->data_bo, NOUVEAU_BO_RDWR, dec->client);
+ ret = BO_MAP(dec->screen, dec->data_bo, NOUVEAU_BO_RDWR, dec->client);
if (ret) {
debug_printf("Mapping data bo: %s\n", strerror(-ret));
return ret;
@@ -582,7 +582,7 @@ nouveau_create_decoder(struct pipe_context *context,
0, 4096, NULL, &dec->fence_bo);
if (ret)
goto fail;
- nouveau_bo_map(dec->fence_bo, NOUVEAU_BO_RDWR, NULL);
+ BO_MAP(screen, dec->fence_bo, NOUVEAU_BO_RDWR, NULL);
dec->fence_map = dec->fence_bo->map;
dec->fence_map[0] = 0;
#endif
diff --git a/src/gallium/drivers/nouveau/nouveau_vp3_video.c b/src/gallium/drivers/nouveau/nouveau_vp3_video.c
index 3b59fd0a513..b3d93a69195 100644
--- a/src/gallium/drivers/nouveau/nouveau_vp3_video.c
+++ b/src/gallium/drivers/nouveau/nouveau_vp3_video.c
@@ -27,6 +27,7 @@
#include <nvif/class.h>
+#include "nouveau_winsys.h"
#include "nouveau_screen.h"
#include "nouveau_context.h"
#include "nouveau_vp3_video.h"
@@ -284,13 +285,14 @@ nouveau_vp3_load_firmware(struct nouveau_vp3_decoder *dec,
char path[PATH_MAX];
ssize_t r;
uint32_t *end, endval;
+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen);
if (chipset >= 0xa3 && chipset != 0xaa && chipset != 0xac)
vp4_getpath(profile, path);
else
vp3_getpath(profile, path);
- if (nouveau_bo_map(dec->fw_bo, NOUVEAU_BO_WR, dec->client))
+ if (BO_MAP(screen, dec->fw_bo, NOUVEAU_BO_WR, dec->client))
return 1;
fd = open(path, O_RDONLY | O_CLOEXEC);
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index 94116cccfae..a5fbf7fb8a3 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -9,6 +9,8 @@
#include "drm-uapi/drm.h"
#include <nouveau.h>
+#include "nouveau_screen.h"
+
#ifndef NV04_PFIFO_MAX_PACKET_LEN
#define NV04_PFIFO_MAX_PACKET_LEN 2047
#endif
@@ -66,6 +68,11 @@ PUSH_KICK(struct nouveau_pushbuf *push)
nouveau_pushbuf_kick(push, push->channel);
}
+static inline int
+BO_MAP(struct nouveau_screen *screen, struct nouveau_bo *bo, uint32_t access, struct nouveau_client *client)
+{
+ return nouveau_bo_map(bo, access, client);
+}
#define NOUVEAU_RESOURCE_FLAG_LINEAR (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
#define NOUVEAU_RESOURCE_FLAG_DRV_PRIV (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c
index 5d1f16b28c9..ebbe3746717 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_miptree.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_miptree.c
@@ -359,7 +359,7 @@ nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_resource *pt,
if (usage & PIPE_MAP_WRITE)
access |= NOUVEAU_BO_WR;
- ret = nouveau_bo_map(tx->tmp.bo, access, nv30->base.client);
+ ret = BO_MAP(nv30->base.screen, tx->tmp.bo, access, nv30->base.client);
if (ret) {
pipe_resource_reference(&tx->base.resource, NULL);
FREE(tx);
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 615dd23bbd5..b0a08a207d5 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -732,7 +732,7 @@ nv30_screen_create(struct nouveau_device *dev)
ret = nouveau_bo_wrap(screen->base.device, fifo->notify, &screen->notify);
if (ret == 0)
- ret = nouveau_bo_map(screen->notify, 0, screen->base.client);
+ ret = BO_MAP(&screen->base, screen->notify, 0, screen->base.client);
if (ret)
FAIL_SCREEN_INIT("error mapping notifier memory: %d\n", ret);
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_transfer.c b/src/gallium/drivers/nouveau/nv30/nv30_transfer.c
index a79fd1f4545..1a5151acb89 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_transfer.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_transfer.c
@@ -635,8 +635,8 @@ nv30_transfer_rect_cpu(XFER_ARGS)
char *srcmap, *dstmap;
int x, y;
- nouveau_bo_map(src->bo, NOUVEAU_BO_RD, nv30->base.client);
- nouveau_bo_map(dst->bo, NOUVEAU_BO_WR, nv30->base.client);
+ BO_MAP(nv30->base.screen, src->bo, NOUVEAU_BO_RD, nv30->base.client);
+ BO_MAP(nv30->base.screen, dst->bo, NOUVEAU_BO_WR, nv30->base.client);
srcmap = src->bo->map + src->offset;
dstmap = dst->bo->map + dst->offset;
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_compute.c b/src/gallium/drivers/nouveau/nv50/nv50_compute.c
index 2e728f51662..d75aa0a9cd3 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_compute.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_compute.c
@@ -540,7 +540,7 @@ nv50_compute_upload_input(struct nv50_context *nv50, const uint32_t *input)
mm = nouveau_mm_allocate(screen->base.mm_GART, size, &bo, &offset);
assert(mm);
- nouveau_bo_map(bo, 0, nv50->base.client);
+ BO_MAP(&screen->base, bo, 0, nv50->base.client);
memcpy(bo->map + offset, input, size);
nouveau_bufctx_refn(nv50->bufctx, 0, bo, NOUVEAU_BO_GART | NOUVEAU_BO_RD);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c
index ff7f521df68..4d959426148 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c
@@ -63,7 +63,7 @@ nv50_hw_query_allocate(struct nv50_context *nv50, struct nv50_query *q,
return false;
hq->offset = hq->base_offset;
- ret = nouveau_bo_map(hq->bo, 0, nv50->base.client);
+ ret = BO_MAP(&screen->base, hq->bo, 0, nv50->base.client);
if (ret) {
nv50_hw_query_allocate(nv50, q, 0);
return false;
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index e54f0919390..eaa2e84e6ad 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -1070,7 +1070,7 @@ nv50_screen_create(struct nouveau_device *dev)
goto fail;
}
- nouveau_bo_map(screen->fence.bo, 0, NULL);
+ BO_MAP(&screen->base, screen->fence.bo, 0, NULL);
screen->fence.map = screen->fence.bo->map;
screen->base.fence.emit = nv50_screen_fence_emit;
screen->base.fence.update = nv50_screen_fence_update;
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_transfer.c b/src/gallium/drivers/nouveau/nv50/nv50_transfer.c
index 3ebd5e46809..d84a6763a46 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_transfer.c
@@ -453,7 +453,7 @@ nv50_miptree_transfer_map(struct pipe_context *pctx,
if (usage & PIPE_MAP_WRITE)
flags |= NOUVEAU_BO_WR;
- ret = nouveau_bo_map(tx->rect[1].bo, flags, nv50->base.client);
+ ret = BO_MAP(nv50->base.screen, tx->rect[1].bo, flags, nv50->base.client);
if (ret) {
nouveau_bo_ref(NULL, &tx->rect[1].bo);
FREE(tx);
diff --git a/src/gallium/drivers/nouveau/nv50/nv84_video.c b/src/gallium/drivers/nouveau/nv50/nv84_video.c
index 01ca0479b47..7e6aa8fffb3 100644
--- a/src/gallium/drivers/nouveau/nv50/nv84_video.c
+++ b/src/gallium/drivers/nouveau/nv50/nv84_video.c
@@ -69,6 +69,7 @@ nv84_load_firmwares(struct nouveau_device *dev, struct nv84_decoder *dec,
{
int ret, size1, size2 = 0;
struct nouveau_bo *fw;
+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen);
size1 = filesize(fw1);
if (fw2)
@@ -81,7 +82,7 @@ nv84_load_firmwares(struct nouveau_device *dev, struct nv84_decoder *dec,
ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, dec->vp_fw2_offset + size2, NULL, &fw);
if (ret)
return NULL;
- ret = nouveau_bo_map(fw, NOUVEAU_BO_WR, dec->client);
+ ret = BO_MAP(screen, fw, NOUVEAU_BO_WR, dec->client);
if (ret)
goto error;
@@ -406,14 +407,14 @@ nv84_create_decoder(struct pipe_context *context,
NULL, &dec->bitstream);
if (ret)
goto fail;
- ret = nouveau_bo_map(dec->bitstream, NOUVEAU_BO_WR, dec->client);
+ ret = BO_MAP(screen, dec->bitstream, NOUVEAU_BO_WR, dec->client);
if (ret)
goto fail;
ret = nouveau_bo_new(screen->device, NOUVEAU_BO_GART,
0, 0x2000, NULL, &dec->vp_params);
if (ret)
goto fail;
- ret = nouveau_bo_map(dec->vp_params, NOUVEAU_BO_WR, dec->client);
+ ret = BO_MAP(screen, dec->vp_params, NOUVEAU_BO_WR, dec->client);
if (ret)
goto fail;
}
@@ -425,7 +426,7 @@ nv84_create_decoder(struct pipe_context *context,
NULL, &dec->mpeg12_bo);
if (ret)
goto fail;
- ret = nouveau_bo_map(dec->mpeg12_bo, NOUVEAU_BO_WR, dec->client);
+ ret = BO_MAP(screen, dec->mpeg12_bo, NOUVEAU_BO_WR, dec->client);
if (ret)
goto fail;
}
@@ -434,7 +435,7 @@ nv84_create_decoder(struct pipe_context *context,
0, 0x1000, NULL, &dec->fence);
if (ret)
goto fail;
- ret = nouveau_bo_map(dec->fence, NOUVEAU_BO_WR, dec->client);
+ ret = BO_MAP(screen, dec->fence, NOUVEAU_BO_WR, dec->client);
if (ret)
goto fail;
*(uint32_t *)dec->fence->map = 0;
diff --git a/src/gallium/drivers/nouveau/nv50/nv98_video.c b/src/gallium/drivers/nouveau/nv50/nv98_video.c
index efa73294065..bc56aff2665 100644
--- a/src/gallium/drivers/nouveau/nv50/nv98_video.c
+++ b/src/gallium/drivers/nouveau/nv50/nv98_video.c
@@ -269,7 +269,7 @@ nv98_create_decoder(struct pipe_context *context,
if (ret)
goto fail;
- nouveau_bo_map(dec->fence_bo, NOUVEAU_BO_RDWR, screen->client);
+ BO_MAP(screen, dec->fence_bo, NOUVEAU_BO_RDWR, screen->client);
dec->fence_map = dec->fence_bo->map;
dec->fence_map[0] = dec->fence_map[4] = dec->fence_map[8] = 0;
dec->comm = (struct comm *)(dec->fence_map + (COMM_OFFSET/sizeof(*dec->fence_map)));
diff --git a/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c b/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c
index f77258de850..4c3a6172233 100644
--- a/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c
+++ b/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c
@@ -39,6 +39,7 @@ nv98_decoder_bsp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
unsigned *vp_caps, unsigned *is_ref,
struct nouveau_vp3_video_buffer *refs[16])
{
+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen);
struct nouveau_pushbuf *push = dec->pushbuf[0];
enum pipe_video_format codec = u_reduce_video_profile(dec->base.profile);
uint32_t bsp_addr, comm_addr, inter_addr;
@@ -95,7 +96,7 @@ nv98_decoder_bsp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
bo_refs[1].bo = dec->inter_bo[comm_seq & 1] = inter_bo = tmp_bo;
}
- ret = nouveau_bo_map(bsp_bo, NOUVEAU_BO_WR, dec->client);
+ ret = BO_MAP(screen, bsp_bo, NOUVEAU_BO_WR, dec->client);
if (ret) {
debug_printf("map failed: %i %s\n", ret, strerror(-ret));
return -1;
diff --git a/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c b/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c
index f1cdf168ed4..68dc3546d8e 100644
--- a/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c
+++ b/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c
@@ -44,7 +44,8 @@ static void dump_comm_vp(struct nouveau_vp3_decoder *dec, struct comm *comm, u32
if ((comm->pvp_stage & 0xff) != 0xff) {
unsigned *map;
- int ret = nouveau_bo_map(inter_bo, NOUVEAU_BO_RD|NOUVEAU_BO_NOBLOCK, dec->client);
+ int ret = BO_MAP(nouveau_screen(dec->base.context->screen), inter_bo,
+ NOUVEAU_BO_RD|NOUVEAU_BO_NOBLOCK, dec->client);
assert(ret >= 0);
map = inter_bo->map;
for (i = 0; i < comm->byte_ofs + slice_size; i += 0x10) {
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
index e1738508798..7daf65bb39b 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
@@ -55,7 +55,7 @@ nvc0_hw_query_allocate(struct nvc0_context *nvc0, struct nvc0_query *q,
return false;
hq->offset = hq->base_offset;
- ret = nouveau_bo_map(hq->bo, 0, nvc0->base.client);
+ ret = BO_MAP(&screen->base, hq->bo, 0, nvc0->base.client);
if (ret) {
nvc0_hw_query_allocate(nvc0, q, 0);
return false;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index a04969809c4..59a1d614f86 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -1123,7 +1123,7 @@ nvc0_screen_create(struct nouveau_device *dev)
ret = nouveau_bo_new(dev, flags, 0, 4096, NULL, &screen->fence.bo);
if (ret)
FAIL_SCREEN_INIT("Error allocating fence BO: %d\n", ret);
- nouveau_bo_map(screen->fence.bo, 0, NULL);
+ BO_MAP(&screen->base, screen->fence.bo, 0, NULL);
screen->fence.map = screen->fence.bo->map;
screen->base.fence.emit = nvc0_screen_fence_emit;
screen->base.fence.update = nvc0_screen_fence_update;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c
index cb345914510..7ede77333ec 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c
@@ -388,7 +388,7 @@ nvc0_miptree_transfer_map(struct pipe_context *pctx,
if (nvc0_mt_transfer_can_map_directly(mt)) {
ret = !nvc0_mt_sync(nvc0, mt, usage);
if (!ret)
- ret = nouveau_bo_map(mt->base.bo, 0, NULL);
+ ret = BO_MAP(nvc0->base.screen, mt->base.bo, 0, NULL);
if (ret &&
(usage & PIPE_MAP_DIRECTLY))
return NULL;
@@ -480,7 +480,7 @@ nvc0_miptree_transfer_map(struct pipe_context *pctx,
if (usage & PIPE_MAP_WRITE)
flags |= NOUVEAU_BO_WR;
- ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->base.client);
+ ret = BO_MAP(nvc0->base.screen, tx->rect[1].bo, flags, nvc0->base.client);
if (ret) {
pipe_resource_reference(&tx->base.resource, NULL);
nouveau_bo_ref(NULL, &tx->rect[1].bo);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_video.c b/src/gallium/drivers/nouveau/nvc0/nvc0_video.c
index 77895cdd6fa..60a90174b2c 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_video.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_video.c
@@ -293,7 +293,7 @@ nvc0_create_decoder(struct pipe_context *context,
if (ret)
goto fail;
- nouveau_bo_map(dec->fence_bo, NOUVEAU_BO_RDWR, screen->client);
+ BO_MAP(screen, dec->fence_bo, NOUVEAU_BO_RDWR, screen->client);
dec->fence_map = dec->fence_bo->map;
dec->fence_map[0] = dec->fence_map[4] = dec->fence_map[8] = 0;
dec->comm = (struct comm *)(dec->fence_map + (COMM_OFFSET/sizeof(*dec->fence_map)));
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c b/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
index ee54596e071..50e67bd81b7 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
@@ -34,10 +34,11 @@ static void dump_comm_bsp(struct comm *comm)
unsigned
nvc0_decoder_bsp_begin(struct nouveau_vp3_decoder *dec, unsigned comm_seq)
{
+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen);
struct nouveau_bo *bsp_bo = dec->bsp_bo[comm_seq % NOUVEAU_VP3_VIDEO_QDEPTH];
unsigned ret = 0;
- ret = nouveau_bo_map(bsp_bo, NOUVEAU_BO_WR, dec->client);
+ ret = BO_MAP(screen, bsp_bo, NOUVEAU_BO_WR, dec->client);
if (ret) {
debug_printf("map failed: %i %s\n", ret, strerror(-ret));
return -1;
@@ -53,6 +54,7 @@ nvc0_decoder_bsp_next(struct nouveau_vp3_decoder *dec,
unsigned comm_seq, unsigned num_buffers,
const void *const *data, const unsigned *num_bytes)
{
+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen);
struct nouveau_bo *bsp_bo = dec->bsp_bo[comm_seq % NOUVEAU_VP3_VIDEO_QDEPTH];
struct nouveau_bo *inter_bo = dec->inter_bo[comm_seq & 1];
uint32_t bsp_size = 0;
@@ -82,7 +84,7 @@ nvc0_decoder_bsp_next(struct nouveau_vp3_decoder *dec,
return -1;
}
- ret = nouveau_bo_map(tmp_bo, NOUVEAU_BO_WR, dec->client);
+ ret = BO_MAP(screen, tmp_bo, NOUVEAU_BO_WR, dec->client);
if (ret) {
debug_printf("map failed: %i %s\n", ret, strerror(-ret));
return -1;
@@ -114,7 +116,7 @@ nvc0_decoder_bsp_next(struct nouveau_vp3_decoder *dec,
return -1;
}
- ret = nouveau_bo_map(tmp_bo, NOUVEAU_BO_WR, dec->client);
+ ret = BO_MAP(screen, tmp_bo, NOUVEAU_BO_WR, dec->client);
if (ret) {
debug_printf("map failed: %i %s\n", ret, strerror(-ret));
return -1;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c b/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c
index 3de4ec14867..8ec09df01c6 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c
@@ -44,7 +44,8 @@ static void dump_comm_vp(struct nouveau_vp3_decoder *dec, struct comm *comm, u32
if ((comm->pvp_stage & 0xff) != 0xff) {
unsigned *map;
- int ret = nouveau_bo_map(inter_bo, NOUVEAU_BO_RD|NOUVEAU_BO_NOBLOCK, dec->client);
+ int ret = BO_MAP(nouveau_screen(dec->base.context->screen), inter_bo,
+ NOUVEAU_BO_RD|NOUVEAU_BO_NOBLOCK, dec->client);
assert(ret >= 0);
map = inter_bo->map;
for (i = 0; i < comm->byte_ofs + slice_size; i += 0x10) {
diff --git a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
index 03a88b87797..3944dfe23c7 100644
--- a/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
+++ b/src/gallium/drivers/nouveau/nvc0/nve4_compute.c
@@ -1031,7 +1031,7 @@ nve4_compute_trap_info(struct nvc0_context *nvc0)
volatile struct nve4_mp_trap_info *info;
uint8_t *map;
- ret = nouveau_bo_map(bo, NOUVEAU_BO_RDWR, nvc0->base.client);
+ ret = BO_MAP(&screen->base, bo, NOUVEAU_BO_RDWR, nvc0->base.client);
if (ret)
return;
map = (uint8_t *)bo->map;
--
2.37.3
From 2095734444387603ef8a6e8d90eef94594b1f07a Mon Sep 17 00:00:00 2001
From: Karol Herbst <kherbst@redhat.com>
Date: Fri, 25 Jun 2021 22:46:10 +0200
Subject: [PATCH 05/17] nouveau: wrap nouveau_bo_wait
This makes it easier to insert locking code around libdrm.
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: M Henning <drawoc@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10752>
---
src/gallium/drivers/nouveau/nouveau_buffer.c | 2 +-
src/gallium/drivers/nouveau/nouveau_winsys.h | 6 ++++++
src/gallium/drivers/nouveau/nv50/nv50_query_hw.c | 7 ++++---
src/gallium/drivers/nouveau/nv50/nv50_query_hw.h | 2 +-
src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c | 2 +-
src/gallium/drivers/nouveau/nv50/nv50_shader_state.c | 2 +-
src/gallium/drivers/nouveau/nv50/nv50_vbo.c | 2 +-
src/gallium/drivers/nouveau/nv50/nv84_video.c | 3 ++-
src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c | 3 ++-
src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c | 2 +-
src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c | 4 ++--
src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c | 2 +-
12 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c
index e566541a579..cfaf42d7086 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -191,7 +191,7 @@ nouveau_transfer_read(struct nouveau_context *nv, struct nouveau_transfer *tx)
nv->copy_data(nv, tx->bo, tx->offset, NOUVEAU_BO_GART,
buf->bo, buf->offset + base, buf->domain, size);
- if (nouveau_bo_wait(tx->bo, NOUVEAU_BO_RD, nv->client))
+ if (BO_WAIT(nv->screen, tx->bo, NOUVEAU_BO_RD, nv->client))
return false;
if (buf->data)
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index a5fbf7fb8a3..a18bd85ad9f 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -74,6 +74,12 @@ BO_MAP(struct nouveau_screen *screen, struct nouveau_bo *bo, uint32_t access, st
return nouveau_bo_map(bo, access, client);
}
+static inline int
+BO_WAIT(struct nouveau_screen *screen, struct nouveau_bo *bo, uint32_t access, struct nouveau_client *client)
+{
+ return nouveau_bo_wait(bo, access, client);
+}
+
#define NOUVEAU_RESOURCE_FLAG_LINEAR (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
#define NOUVEAU_RESOURCE_FLAG_DRV_PRIV (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c
index 4d959426148..5e079cf3307 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c
@@ -294,7 +294,7 @@ nv50_hw_get_query_result(struct nv50_context *nv50, struct nv50_query *q,
}
return false;
}
- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nv50->base.client))
+ if (BO_WAIT(&nv50->screen->base, hq->bo, NOUVEAU_BO_RD, nv50->base.client))
return false;
}
hq->state = NV50_HW_QUERY_STATE_READY;
@@ -447,14 +447,15 @@ nv50_hw_get_driver_query_info(struct nv50_screen *screen, unsigned id,
}
void
-nv50_hw_query_pushbuf_submit(struct nouveau_pushbuf *push, uint16_t method,
+nv50_hw_query_pushbuf_submit(struct nv50_context *nv50, uint16_t method,
struct nv50_query *q, unsigned result_offset)
{
+ struct nouveau_pushbuf *push = nv50->base.pushbuf;
struct nv50_hw_query *hq = nv50_hw_query(q);
nv50_hw_query_update(q);
if (hq->state != NV50_HW_QUERY_STATE_READY)
- nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, push->client);
+ BO_WAIT(&nv50->screen->base, hq->bo, NOUVEAU_BO_RD, push->client);
hq->state = NV50_HW_QUERY_STATE_READY;
BEGIN_NV04(push, SUBC_3D(method), 1);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.h b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.h
index 4a351510f72..ad2f7ec0f73 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw.h
+++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw.h
@@ -52,7 +52,7 @@ nv50_hw_get_driver_query_info(struct nv50_screen *, unsigned,
bool
nv50_hw_query_allocate(struct nv50_context *, struct nv50_query *, int);
void
-nv50_hw_query_pushbuf_submit(struct nouveau_pushbuf *, uint16_t,
+nv50_hw_query_pushbuf_submit(struct nv50_context *, uint16_t,
struct nv50_query *, unsigned);
void
nv84_hw_query_fifo_wait(struct nouveau_pushbuf *, struct nv50_query *);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c
index de3d8fd950e..a6c92bbbd1e 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c
@@ -321,7 +321,7 @@ nv50_hw_sm_query_read_data(uint32_t count[32][4],
if (hq->data[b + 4] != hq->sequence) {
if (!wait)
return false;
- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nv50->base.client))
+ if (BO_WAIT(&nv50->screen->base, hq->bo, NOUVEAU_BO_RD, nv50->base.client))
return false;
}
count[p][c] = hq->data[b + hsq->ctr[c]];
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c b/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c
index 5a3b911bfe1..3d17953ed37 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c
@@ -717,7 +717,7 @@ nv50_stream_output_validate(struct nv50_context *nv50)
PUSH_DATA(push, targ->pipe.buffer_size);
if (!targ->clean) {
assert(targ->pq);
- nv50_hw_query_pushbuf_submit(push, NVA0_3D_STRMOUT_OFFSET(i),
+ nv50_hw_query_pushbuf_submit(nv50, NVA0_3D_STRMOUT_OFFSET(i),
nv50_query(targ->pq), 0x4);
} else {
BEGIN_NV04(push, NVA0_3D(STRMOUT_OFFSET(i)), 1);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
index 600434f767d..2d1879ed72f 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c
@@ -737,7 +737,7 @@ nva0_draw_stream_output(struct nv50_context *nv50,
PUSH_DATA (push, 0);
BEGIN_NV04(push, NVA0_3D(DRAW_TFB_STRIDE), 1);
PUSH_DATA (push, so->stride);
- nv50_hw_query_pushbuf_submit(push, NVA0_3D_DRAW_TFB_BYTES,
+ nv50_hw_query_pushbuf_submit(nv50, NVA0_3D_DRAW_TFB_BYTES,
nv50_query(so->pq), 0x4);
BEGIN_NV04(push, NV50_3D(VERTEX_END_GL), 1);
PUSH_DATA (push, 0);
diff --git a/src/gallium/drivers/nouveau/nv50/nv84_video.c b/src/gallium/drivers/nouveau/nv50/nv84_video.c
index 7e6aa8fffb3..c5e04bb7dfb 100644
--- a/src/gallium/drivers/nouveau/nv50/nv84_video.c
+++ b/src/gallium/drivers/nouveau/nv50/nv84_video.c
@@ -184,11 +184,12 @@ nv84_decoder_begin_frame_mpeg12(struct pipe_video_codec *decoder,
struct pipe_video_buffer *target,
struct pipe_picture_desc *picture)
{
+ struct nouveau_screen *screen = nouveau_screen(decoder->context->screen);
struct nv84_decoder *dec = (struct nv84_decoder *)decoder;
struct pipe_mpeg12_picture_desc *desc = (struct pipe_mpeg12_picture_desc *)picture;
int i;
- nouveau_bo_wait(dec->mpeg12_bo, NOUVEAU_BO_RDWR, dec->client);
+ BO_WAIT(screen, dec->mpeg12_bo, NOUVEAU_BO_RDWR, dec->client);
dec->mpeg12_mb_info = dec->mpeg12_bo->map + 0x100;
dec->mpeg12_data = dec->mpeg12_bo->map + 0x100 +
align(0x20 * mb(dec->base.width) * mb(dec->base.height), 0x100);
diff --git a/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c b/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c
index 38eca1771c5..4bd96105bbb 100644
--- a/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c
+++ b/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c
@@ -89,6 +89,7 @@ nv84_decoder_bsp(struct nv84_decoder *dec,
const unsigned *num_bytes,
struct nv84_video_buffer *dest)
{
+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen);
struct iparm params;
uint32_t more_params[0x44 / 4] = {0};
unsigned total_bytes = 0;
@@ -103,7 +104,7 @@ nv84_decoder_bsp(struct nv84_decoder *dec,
{ dec->fence, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM },
};