linux/drivers/gpu/drm/nouveau/nvif/chan506f.c
Ben Skeggs 862450a85b drm/nouveau/gf100-: track chan progress with non-WFI semaphore release
From VOLTA_CHANNEL_GPFIFO_A onwards, HW no longer updates the GET/GP_GET
pointers in USERD following channel progress, but instead updates on a
timer for compatibility, and SW is expected to implement its own method
of tracking channel progress (typically via non-WFI semaphore release).

Nouveau has been making use of the compatibility mode up until now,
however, from BLACKWELL_CHANNEL_GPFIFO_A HW no longer supports USERD
writeback at all.

Allocate a per-channel buffer in system memory, and append a non-WFI
semaphore release to the end of each push buffer segment to simulate
the pointers previously read from USERD.

This change is implemented for Fermi (which is the first to support non-
WFI semaphore release) onwards, as readback from system memory is likely
faster than BAR1 reads.

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Timur Tabi <ttabi@nvidia.com>
Tested-by: Timur Tabi <ttabi@nvidia.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2025-05-19 07:14:44 +10:00

72 lines
1.8 KiB
C

/* SPDX-License-Identifier: MIT
*
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
*/
#include <nvif/chan.h>
void
nvif_chan506f_gpfifo_kick(struct nvif_chan *chan)
{
wmb();
nvif_wr32(&chan->userd, 0x8c, chan->gpfifo.cur);
}
void
nvif_chan506f_gpfifo_push(struct nvif_chan *chan, bool main, u64 addr, u32 size, bool no_prefetch)
{
u32 gpptr = chan->gpfifo.cur << 3;
if (WARN_ON(!chan->gpfifo.free))
return;
nvif_wr32(&chan->gpfifo, gpptr + 0, lower_32_bits(addr));
nvif_wr32(&chan->gpfifo, gpptr + 4, upper_32_bits(addr) |
(main ? 0 : BIT(9)) |
(size >> 2) << 10 |
(no_prefetch ? BIT(31) : 0));
chan->gpfifo.cur = (chan->gpfifo.cur + 1) & chan->gpfifo.max;
chan->gpfifo.free--;
if (!chan->gpfifo.free)
chan->push.end = chan->push.cur;
}
static u32
nvif_chan506f_gpfifo_read_get(struct nvif_chan *chan)
{
return nvif_rd32(&chan->userd, 0x88);
}
static u32
nvif_chan506f_read_get(struct nvif_chan *chan)
{
u32 tlgetlo = nvif_rd32(&chan->userd, 0x58);
u32 tlgethi = nvif_rd32(&chan->userd, 0x5c);
struct nvif_push *push = &chan->push;
/* Update cached GET pointer if TOP_LEVEL_GET is valid. */
if (tlgethi & BIT(31)) {
u64 tlget = ((u64)(tlgethi & 0xff) << 32) | tlgetlo;
push->hw.get = (tlget - push->addr) >> 2;
}
return push->hw.get;
}
static const struct nvif_chan_func
nvif_chan506f = {
.push.read_get = nvif_chan506f_read_get,
.gpfifo.read_get = nvif_chan506f_gpfifo_read_get,
.gpfifo.push = nvif_chan506f_gpfifo_push,
.gpfifo.kick = nvif_chan506f_gpfifo_kick,
};
int
nvif_chan506f_ctor(struct nvif_chan *chan, void *userd, void *gpfifo, u32 gpfifo_size,
void *push, u64 push_addr, u32 push_size)
{
nvif_chan_gpfifo_ctor(&nvif_chan506f, userd, gpfifo, gpfifo_size,
push, push_addr, push_size, chan);
return 0;
}