Skip to contentSkip to conversation

nouveau: On nvc0 membar between semaphore write and

PATCH New Mel Henning 1 participant 2 messages Sep 23, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover nouveau: On nvc0 membar between semaphore write and

This takes the fix from 2cb66ae604 ("nouveau: Membar before between semaphore writes and the interrupt") and also applies it to nvc0_fence.c.

I've tested this on both ampere and kepler. Unfortunately, I don't have a maxwell card to test on so that branch in the patch hasn't been tested yet.

Mel Henning (1):
nouveau: On nvc0 membar between semaphore write and interrupt

 .../drm/nouveau/include/nvhw/class/cl906f.h   | 23 +++++
 .../drm/nouveau/include/nvhw/class/clb06f.h   | 54 +++++++++++
 .../drm/nouveau/include/nvhw/class/clc06f.h   | 93 +++++++++++++++++++
 .../gpu/drm/nouveau/include/nvif/push906f.h   |  2 +
 drivers/gpu/drm/nouveau/nvc0_fence.c          | 31 ++++++-
 5 files changed, 200 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvhw/class/clb06f.h
 create mode 100644 drivers/gpu/drm/nouveau/include/nvhw/class/clc06f.h
Signature · 1 line
2.51.0
#1 lore raw

PATCH 1/1 nouveau: On nvc0 membar between semaphore write and interrupt

This takes the fix from 2cb66ae604 ("nouveau: Membar before between semaphore writes and the interrupt") and applies it to nvc0_fence.c.

If I force my ampere system down the nvc0_fence path then I reproduce the same issues with transfer queues + The Talos Principle that were fixed by the above commit. This fixes that issue in exactly the same way for the old code path.

Fixes 60cdadace320 ("drm/nouveau/fence: use NVIDIA's headers for emit()")
---
 .../drm/nouveau/include/nvhw/class/cl906f.h   | 23 +++++
 .../drm/nouveau/include/nvhw/class/clb06f.h   | 54 +++++++++++
 .../drm/nouveau/include/nvhw/class/clc06f.h   | 93 +++++++++++++++++++
 .../gpu/drm/nouveau/include/nvif/push906f.h   |  2 +
 drivers/gpu/drm/nouveau/nvc0_fence.c          | 31 ++++++-
 5 files changed, 200 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/drm/nouveau/include/nvhw/class/clb06f.h
 create mode 100644 drivers/gpu/drm/nouveau/include/nvhw/class/clc06f.h
drivers/gpu/drm/nouveau/include/nvhw/class/cl906f.h +23 -0
index 673d668885bb..529c785b4651 100644
@@ -47,6 +47,29 @@
 #define NV906F_SEMAPHORED_RELEASE_SIZE_4BYTE                        0x00000001
 #define NV906F_NON_STALL_INTERRUPT                                 (0x00000020)
 #define NV906F_NON_STALL_INTERRUPT_HANDLE                                 31:0
+#define NV906F_MEM_OP_A                                            (0x00000028)
+#define NV906F_MEM_OP_A_OPERAND_LOW                                       31:2
+#define NV906F_MEM_OP_A_TLB_INVALIDATE_ADDR                               29:2
+#define NV906F_MEM_OP_A_TLB_INVALIDATE_TARGET                            31:30
+#define NV906F_MEM_OP_A_TLB_INVALIDATE_TARGET_VID_MEM               0x00000000
+#define NV906F_MEM_OP_A_TLB_INVALIDATE_TARGET_SYS_MEM_COHERENT      0x00000002
+#define NV906F_MEM_OP_A_TLB_INVALIDATE_TARGET_SYS_MEM_NONCOHERENT   0x00000003
+#define NV906F_MEM_OP_B                                            (0x0000002c)
+#define NV906F_MEM_OP_B_OPERAND_HIGH                                       7:0
+#define NV906F_MEM_OP_B_OPERATION                                        31:27
+#define NV906F_MEM_OP_B_OPERATION_SYSMEMBAR_FLUSH                   0x00000005
+#define NV906F_MEM_OP_B_OPERATION_SOFT_FLUSH                        0x00000006
+#define NV906F_MEM_OP_B_OPERATION_MMU_TLB_INVALIDATE                0x00000009
+#define NV906F_MEM_OP_B_OPERATION_L2_PEERMEM_INVALIDATE             0x0000000d
+#define NV906F_MEM_OP_B_OPERATION_L2_SYSMEM_INVALIDATE              0x0000000e
+#define NV906F_MEM_OP_B_OPERATION_L2_CLEAN_COMPTAGS                 0x0000000f
+#define NV906F_MEM_OP_B_OPERATION_L2_FLUSH_DIRTY                    0x00000010
+#define NV906F_MEM_OP_B_MMU_TLB_INVALIDATE_PDB                             0:0
+#define NV906F_MEM_OP_B_MMU_TLB_INVALIDATE_PDB_ONE                  0x00000000
+#define NV906F_MEM_OP_B_MMU_TLB_INVALIDATE_PDB_ALL                  0x00000001
+#define NV906F_MEM_OP_B_MMU_TLB_INVALIDATE_GPC                             1:1
+#define NV906F_MEM_OP_B_MMU_TLB_INVALIDATE_GPC_ENABLE               0x00000000
+#define NV906F_MEM_OP_B_MMU_TLB_INVALIDATE_GPC_DISABLE              0x00000001
 #define NV906F_SET_REFERENCE                                       (0x00000050)
 #define NV906F_SET_REFERENCE_COUNT                                        31:0
 
drivers/gpu/drm/nouveau/include/nvhw/class/clb06f.h new file +54 -0

54 lines not on this page · raw message

drivers/gpu/drm/nouveau/include/nvhw/class/clc06f.h new file +93 -0

93 lines not on this page · raw message

drivers/gpu/drm/nouveau/include/nvif/push906f.h +2 -0
index 79df71de98d2..3d506f4dc2c9 100644
@@ -7,6 +7,8 @@
 #ifndef PUSH906F_SUBC
 // Host methods
 #define PUSH906F_SUBC_NV906F	0
+#define PUSH906F_SUBC_NVB06F	0
+#define PUSH906F_SUBC_NVC06F	0
 #define PUSH906F_SUBC_NVC36F	0
 
 // Twod
drivers/gpu/drm/nouveau/nvc0_fence.c +28 -3
index a5e98d0d4217..8b36deaaf8cf 100644
@@ -27,15 +27,18 @@
 
 #include "nv50_display.h"
 
+#include <nvif/class.h>
 #include <nvif/push906f.h>
 
 #include <nvhw/class/cl906f.h>
+#include <nvhw/class/clb06f.h>
+#include <nvhw/class/clc06f.h>
 
 static int
 nvc0_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 {
 	struct nvif_push *push = &chan->chan.push;
-	int ret = PUSH_WAIT(push, 6);
+	int ret = PUSH_WAIT(push, 12);
 	if (ret == 0) {
 		PUSH_MTHD(push, NV906F, SEMAPHOREA,
 			  NVVAL(NV906F, SEMAPHOREA, OFFSET_UPPER, upper_32_bits(virtual)),
@@ -46,9 +49,31 @@ nvc0_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
 					SEMAPHORED,
 			  NVDEF(NV906F, SEMAPHORED, OPERATION, RELEASE) |
 			  NVDEF(NV906F, SEMAPHORED, RELEASE_WFI, EN) |
-			  NVDEF(NV906F, SEMAPHORED, RELEASE_SIZE, 16BYTE),
+			  NVDEF(NV906F, SEMAPHORED, RELEASE_SIZE, 16BYTE));
+
+		if (chan->user.oclass >= PASCAL_CHANNEL_GPFIFO_A) {
+			PUSH_MTHD(push, NVC06F, MEM_OP_A, 0,
+						MEM_OP_B, 0,
+
+						MEM_OP_C,
+				  NVDEF(NVC06F, MEM_OP_C, MEMBAR_TYPE, SYS_MEMBAR),
+
+						MEM_OP_D,
+				  NVDEF(NVC06F, MEM_OP_D, OPERATION, MEMBAR));
+		} else if (chan->user.oclass >= MAXWELL_CHANNEL_GPFIFO_A) {
+			PUSH_MTHD(push, NVB06F, MEM_OP_C, 0,
+
+						MEM_OP_D,
+				  NVDEF(NVC06F, MEM_OP_D, OPERATION, MEMBAR));
+		} else {
+			PUSH_MTHD(push, NV906F, MEM_OP_A, 0,
+
+						MEM_OP_B,
+				  NVDEF(NV906F, MEM_OP_B, OPERATION, SYSMEMBAR_FLUSH));
+		}
+
+		PUSH_MTHD(push, NV906F, NON_STALL_INTERRUPT, 0);
 
-					NON_STALL_INTERRUPT, 0);
 		PUSH_KICK(push);
 	}
 	return ret;
Signature · 1 line
2.51.0