Skip to content

Commit b1ca384

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/gv100-: switch to volta semaphore methods
HOPPER_CHANNEL_GPFIFO_A removes the SEMAPHORE[A-D] methods that are currently used by nouveau to implement fences on GF100 and newer. Switch to the newer SEM methods available from VOLTA_CHANNEL_GPFIFO, which are also available on the Hopper/Blackwell host classes. Signed-off-by: Ben Skeggs <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Timur Tabi <[email protected]> Tested-by: Timur Tabi <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent 6c3ac7b commit b1ca384

File tree

6 files changed

+151
-1
lines changed

6 files changed

+151
-1
lines changed

drivers/gpu/drm/nouveau/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@ nouveau-y += nv17_fence.o
6969
nouveau-y += nv50_fence.o
7070
nouveau-y += nv84_fence.o
7171
nouveau-y += nvc0_fence.o
72+
nouveau-y += gv100_fence.o
7273

7374
obj-$(CONFIG_DRM_NOUVEAU) += nouveau.o

drivers/gpu/drm/nouveau/gv100_fence.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* SPDX-License-Identifier: MIT
2+
*
3+
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
4+
*/
5+
#include "nouveau_drv.h"
6+
#include "nouveau_dma.h"
7+
#include "nouveau_fence.h"
8+
9+
#include "nv50_display.h"
10+
11+
#include <nvif/push906f.h>
12+
13+
#include <nvhw/class/clc36f.h>
14+
15+
static int
16+
gv100_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
17+
{
18+
struct nvif_push *push = &chan->chan.push;
19+
int ret;
20+
21+
ret = PUSH_WAIT(push, 8);
22+
if (ret)
23+
return ret;
24+
25+
PUSH_MTHD(push, NVC36F, SEM_ADDR_LO, lower_32_bits(virtual),
26+
SEM_ADDR_HI, upper_32_bits(virtual),
27+
SEM_PAYLOAD_LO, sequence);
28+
29+
PUSH_MTHD(push, NVC36F, SEM_EXECUTE,
30+
NVDEF(NVC36F, SEM_EXECUTE, OPERATION, RELEASE) |
31+
NVDEF(NVC36F, SEM_EXECUTE, RELEASE_WFI, EN) |
32+
NVDEF(NVC36F, SEM_EXECUTE, PAYLOAD_SIZE, 32BIT) |
33+
NVDEF(NVC36F, SEM_EXECUTE, RELEASE_TIMESTAMP, DIS));
34+
35+
PUSH_MTHD(push, NVC36F, NON_STALL_INTERRUPT, 0);
36+
37+
PUSH_KICK(push);
38+
return 0;
39+
}
40+
41+
static int
42+
gv100_fence_sync32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
43+
{
44+
struct nvif_push *push = &chan->chan.push;
45+
int ret;
46+
47+
ret = PUSH_WAIT(push, 6);
48+
if (ret)
49+
return ret;
50+
51+
PUSH_MTHD(push, NVC36F, SEM_ADDR_LO, lower_32_bits(virtual),
52+
SEM_ADDR_HI, upper_32_bits(virtual),
53+
SEM_PAYLOAD_LO, sequence);
54+
55+
PUSH_MTHD(push, NVC36F, SEM_EXECUTE,
56+
NVDEF(NVC36F, SEM_EXECUTE, OPERATION, ACQ_CIRC_GEQ) |
57+
NVDEF(NVC36F, SEM_EXECUTE, ACQUIRE_SWITCH_TSG, EN) |
58+
NVDEF(NVC36F, SEM_EXECUTE, PAYLOAD_SIZE, 32BIT));
59+
60+
PUSH_KICK(push);
61+
return 0;
62+
}
63+
64+
static int
65+
gv100_fence_context_new(struct nouveau_channel *chan)
66+
{
67+
struct nv84_fence_chan *fctx;
68+
int ret;
69+
70+
ret = nv84_fence_context_new(chan);
71+
if (ret)
72+
return ret;
73+
74+
fctx = chan->fence;
75+
fctx->base.emit32 = gv100_fence_emit32;
76+
fctx->base.sync32 = gv100_fence_sync32;
77+
return 0;
78+
}
79+
80+
int
81+
gv100_fence_create(struct nouveau_drm *drm)
82+
{
83+
struct nv84_fence_priv *priv;
84+
int ret;
85+
86+
ret = nv84_fence_create(drm);
87+
if (ret)
88+
return ret;
89+
90+
priv = drm->fence;
91+
priv->base.context_new = gv100_fence_context_new;
92+
return 0;
93+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* SPDX-License-Identifier: MIT
2+
*
3+
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
4+
*/
5+
#ifndef _clc36f_h_
6+
#define _clc36f_h_
7+
8+
#define NVC36F_NON_STALL_INTERRUPT (0x00000020)
9+
#define NVC36F_NON_STALL_INTERRUPT_HANDLE 31:0
10+
#define NVC36F_SEM_ADDR_LO (0x0000005c)
11+
#define NVC36F_SEM_ADDR_LO_OFFSET 31:2
12+
#define NVC36F_SEM_ADDR_HI (0x00000060)
13+
#define NVC36F_SEM_ADDR_HI_OFFSET 7:0
14+
#define NVC36F_SEM_PAYLOAD_LO (0x00000064)
15+
#define NVC36F_SEM_PAYLOAD_LO_PAYLOAD 31:0
16+
#define NVC36F_SEM_PAYLOAD_HI (0x00000068)
17+
#define NVC36F_SEM_PAYLOAD_HI_PAYLOAD 31:0
18+
#define NVC36F_SEM_EXECUTE (0x0000006c)
19+
#define NVC36F_SEM_EXECUTE_OPERATION 2:0
20+
#define NVC36F_SEM_EXECUTE_OPERATION_ACQUIRE 0x00000000
21+
#define NVC36F_SEM_EXECUTE_OPERATION_RELEASE 0x00000001
22+
#define NVC36F_SEM_EXECUTE_OPERATION_ACQ_STRICT_GEQ 0x00000002
23+
#define NVC36F_SEM_EXECUTE_OPERATION_ACQ_CIRC_GEQ 0x00000003
24+
#define NVC36F_SEM_EXECUTE_OPERATION_ACQ_AND 0x00000004
25+
#define NVC36F_SEM_EXECUTE_OPERATION_ACQ_NOR 0x00000005
26+
#define NVC36F_SEM_EXECUTE_OPERATION_REDUCTION 0x00000006
27+
#define NVC36F_SEM_EXECUTE_ACQUIRE_SWITCH_TSG 12:12
28+
#define NVC36F_SEM_EXECUTE_ACQUIRE_SWITCH_TSG_DIS 0x00000000
29+
#define NVC36F_SEM_EXECUTE_ACQUIRE_SWITCH_TSG_EN 0x00000001
30+
#define NVC36F_SEM_EXECUTE_RELEASE_WFI 20:20
31+
#define NVC36F_SEM_EXECUTE_RELEASE_WFI_DIS 0x00000000
32+
#define NVC36F_SEM_EXECUTE_RELEASE_WFI_EN 0x00000001
33+
#define NVC36F_SEM_EXECUTE_PAYLOAD_SIZE 24:24
34+
#define NVC36F_SEM_EXECUTE_PAYLOAD_SIZE_32BIT 0x00000000
35+
#define NVC36F_SEM_EXECUTE_PAYLOAD_SIZE_64BIT 0x00000001
36+
#define NVC36F_SEM_EXECUTE_RELEASE_TIMESTAMP 25:25
37+
#define NVC36F_SEM_EXECUTE_RELEASE_TIMESTAMP_DIS 0x00000000
38+
#define NVC36F_SEM_EXECUTE_RELEASE_TIMESTAMP_EN 0x00000001
39+
#define NVC36F_SEM_EXECUTE_REDUCTION 30:27
40+
#define NVC36F_SEM_EXECUTE_REDUCTION_IMIN 0x00000000
41+
#define NVC36F_SEM_EXECUTE_REDUCTION_IMAX 0x00000001
42+
#define NVC36F_SEM_EXECUTE_REDUCTION_IXOR 0x00000002
43+
#define NVC36F_SEM_EXECUTE_REDUCTION_IAND 0x00000003
44+
#define NVC36F_SEM_EXECUTE_REDUCTION_IOR 0x00000004
45+
#define NVC36F_SEM_EXECUTE_REDUCTION_IADD 0x00000005
46+
#define NVC36F_SEM_EXECUTE_REDUCTION_INC 0x00000006
47+
#define NVC36F_SEM_EXECUTE_REDUCTION_DEC 0x00000007
48+
#define NVC36F_SEM_EXECUTE_REDUCTION_FORMAT 31:31
49+
#define NVC36F_SEM_EXECUTE_REDUCTION_FORMAT_SIGNED 0x00000000
50+
#define NVC36F_SEM_EXECUTE_REDUCTION_FORMAT_UNSIGNED 0x00000001
51+
52+
#endif

drivers/gpu/drm/nouveau/include/nvif/push906f.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef PUSH906F_SUBC
88
// Host methods
99
#define PUSH906F_SUBC_NV906F 0
10+
#define PUSH906F_SUBC_NVC36F 0
1011

1112
// Twod
1213
#define PUSH906F_SUBC_NV902D 3

drivers/gpu/drm/nouveau/nouveau_drm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,13 @@ nouveau_accel_init(struct nouveau_drm *drm)
503503
case KEPLER_CHANNEL_GPFIFO_B:
504504
case MAXWELL_CHANNEL_GPFIFO_A:
505505
case PASCAL_CHANNEL_GPFIFO_A:
506+
ret = nvc0_fence_create(drm);
507+
break;
506508
case VOLTA_CHANNEL_GPFIFO_A:
507509
case TURING_CHANNEL_GPFIFO_A:
508510
case AMPERE_CHANNEL_GPFIFO_A:
509511
case AMPERE_CHANNEL_GPFIFO_B:
510-
ret = nvc0_fence_create(drm);
512+
ret = gv100_fence_create(drm);
511513
break;
512514
default:
513515
break;

drivers/gpu/drm/nouveau/nouveau_fence.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ void nv17_fence_resume(struct nouveau_drm *drm);
8383
int nv50_fence_create(struct nouveau_drm *);
8484
int nv84_fence_create(struct nouveau_drm *);
8585
int nvc0_fence_create(struct nouveau_drm *);
86+
int gv100_fence_create(struct nouveau_drm *);
8687

8788
struct nv84_fence_chan {
8889
struct nouveau_fence_chan base;

0 commit comments

Comments
 (0)