Skip to content

Commit

Permalink
drm/nouveau/kms: remove push pointer from nv50_dmac
Browse files Browse the repository at this point in the history
The struct itself lives in nv50_dmac already, just use that.

Signed-off-by: Ben Skeggs <bskeggs@nvidia.com>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240726043828.58966-38-bskeggs@nvidia.com
  • Loading branch information
Ben Skeggs authored and Danilo Krummrich committed Jul 27, 2024
1 parent 723388b commit 61671d8
Show file tree
Hide file tree
Showing 30 changed files with 122 additions and 124 deletions.
18 changes: 9 additions & 9 deletions drivers/gpu/drm/nouveau/dispnv50/base507c.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
int
base507c_update(struct nv50_wndw *wndw, u32 *interlock)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 2)))
Expand All @@ -48,7 +48,7 @@ base507c_update(struct nv50_wndw *wndw, u32 *interlock)
int
base507c_image_clr(struct nv50_wndw *wndw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 4)))
Expand All @@ -65,7 +65,7 @@ base507c_image_clr(struct nv50_wndw *wndw)
static int
base507c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 13)))
Expand Down Expand Up @@ -118,7 +118,7 @@ base507c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
int
base507c_xlut_clr(struct nv50_wndw *wndw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 2)))
Expand All @@ -132,7 +132,7 @@ base507c_xlut_clr(struct nv50_wndw *wndw)
int
base507c_xlut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 2)))
Expand All @@ -158,7 +158,7 @@ base507c_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset,
int
base507c_ntfy_clr(struct nv50_wndw *wndw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 2)))
Expand All @@ -171,7 +171,7 @@ base507c_ntfy_clr(struct nv50_wndw *wndw)
int
base507c_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 3)))
Expand All @@ -195,7 +195,7 @@ base507c_ntfy_reset(struct nouveau_bo *bo, u32 offset)
int
base507c_sema_clr(struct nv50_wndw *wndw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 2)))
Expand All @@ -208,7 +208,7 @@ base507c_sema_clr(struct nv50_wndw *wndw)
int
base507c_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 5)))
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/dispnv50/base827c.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
static int
base827c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 13)))
Expand Down
10 changes: 5 additions & 5 deletions drivers/gpu/drm/nouveau/dispnv50/base907c.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
static int
base907c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 10)))
Expand Down Expand Up @@ -65,7 +65,7 @@ base907c_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
static int
base907c_xlut_clr(struct nv50_wndw *wndw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 6)))
Expand All @@ -84,7 +84,7 @@ base907c_xlut_clr(struct nv50_wndw *wndw)
static int
base907c_xlut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 6)))
Expand Down Expand Up @@ -156,7 +156,7 @@ base907c_csc(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
static int
base907c_csc_clr(struct nv50_wndw *wndw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 2)))
Expand All @@ -170,7 +170,7 @@ base907c_csc_clr(struct nv50_wndw *wndw)
static int
base907c_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
{
struct nvif_push *push = wndw->wndw.push;
struct nvif_push *push = &wndw->wndw.push;
int ret;

if ((ret = PUSH_WAIT(push, 13)))
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/nouveau/dispnv50/core507d.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
int
core507d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
{
struct nvif_push *push = core->chan.push;
struct nvif_push *push = &core->chan.push;
int ret;

if ((ret = PUSH_WAIT(push, (ntfy ? 2 : 0) + 3)))
Expand Down Expand Up @@ -80,7 +80,7 @@ core507d_ntfy_init(struct nouveau_bo *bo, u32 offset)
int
core507d_read_caps(struct nv50_disp *disp)
{
struct nvif_push *push = disp->core->chan.push;
struct nvif_push *push = &disp->core->chan.push;
int ret;

ret = PUSH_WAIT(push, 6);
Expand Down Expand Up @@ -130,7 +130,7 @@ core507d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
int
core507d_init(struct nv50_core *core)
{
struct nvif_push *push = core->chan.push;
struct nvif_push *push = &core->chan.push;
int ret;

if ((ret = PUSH_WAIT(push, 2)))
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/nouveau/dispnv50/corec37d.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
int
corec37d_wndw_owner(struct nv50_core *core)
{
struct nvif_push *push = core->chan.push;
struct nvif_push *push = &core->chan.push;
const u32 windows = 8; /*XXX*/
int ret, i;

Expand All @@ -51,7 +51,7 @@ corec37d_wndw_owner(struct nv50_core *core)
int
corec37d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
{
struct nvif_push *push = core->chan.push;
struct nvif_push *push = &core->chan.push;
int ret;

if ((ret = PUSH_WAIT(push, (ntfy ? 2 * 2 : 0) + 5)))
Expand Down Expand Up @@ -127,7 +127,7 @@ int corec37d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
static int
corec37d_init(struct nv50_core *core)
{
struct nvif_push *push = core->chan.push;
struct nvif_push *push = &core->chan.push;
const u32 windows = 8; /*XXX*/
int ret, i;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/dispnv50/corec57d.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
static int
corec57d_init(struct nv50_core *core)
{
struct nvif_push *push = core->chan.push;
struct nvif_push *push = &core->chan.push;
const u32 windows = 8; /*XXX*/
int ret, i;

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/nouveau/dispnv50/crc907d.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static int
crc907d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source,
struct nv50_crc_notifier_ctx *ctx)
{
struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
const int i = head->base.index;
u32 crc_args = NVDEF(NV907D, HEAD_SET_CRC_CONTROL, CONTROLLING_CHANNEL, CORE) |
NVDEF(NV907D, HEAD_SET_CRC_CONTROL, EXPECT_BUFFER_COLLAPSE, FALSE) |
Expand Down Expand Up @@ -74,7 +74,7 @@ crc907d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source
static int
crc907d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
{
struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
const int i = head->base.index;
int ret;

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static int
crcc37d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source,
struct nv50_crc_notifier_ctx *ctx)
{
struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
const int i = head->base.index;
u32 crc_args = NVVAL(NVC37D, HEAD_SET_CRC_CONTROL, CONTROLLING_CHANNEL, i * 4) |
NVDEF(NVC37D, HEAD_SET_CRC_CONTROL, EXPECT_BUFFER_COLLAPSE, FALSE) |
Expand Down Expand Up @@ -53,7 +53,7 @@ crcc37d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source

int crcc37d_set_ctx(struct nv50_head *head, struct nv50_crc_notifier_ctx *ctx)
{
struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
const int i = head->base.index;
int ret;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/dispnv50/crcc57d.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
static int crcc57d_set_src(struct nv50_head *head, int or, enum nv50_crc_source_type source,
struct nv50_crc_notifier_ctx *ctx)
{
struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
struct nvif_push *push = &nv50_disp(head->base.base.dev)->core->chan.push;
const int i = head->base.index;
u32 crc_args = NVDEF(NVC57D, HEAD_SET_CRC_CONTROL, CONTROLLING_CHANNEL, CORE) |
NVDEF(NVC57D, HEAD_SET_CRC_CONTROL, EXPECT_BUFFER_COLLAPSE, FALSE) |
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/dispnv50/dac507d.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static int
dac507d_ctrl(struct nv50_core *core, int or, u32 ctrl,
struct nv50_head_atom *asyh)
{
struct nvif_push *push = core->chan.push;
struct nvif_push *push = &core->chan.push;
u32 sync = 0;
int ret;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/dispnv50/dac907d.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static int
dac907d_ctrl(struct nv50_core *core, int or, u32 ctrl,
struct nv50_head_atom *asyh)
{
struct nvif_push *push = core->chan.push;
struct nvif_push *push = &core->chan.push;
int ret;

if ((ret = PUSH_WAIT(push, 2)))
Expand Down
35 changes: 17 additions & 18 deletions drivers/gpu/drm/nouveau/dispnv50/disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ nv50_dmac_destroy(struct nv50_dmac *dmac)

nv50_chan_destroy(&dmac->base);

nvif_mem_dtor(&dmac->_push.mem);
nvif_mem_dtor(&dmac->push.mem);
}

static void
nv50_dmac_kick(struct nvif_push *push)
{
struct nv50_dmac *dmac = container_of(push, typeof(*dmac), _push);
struct nv50_dmac *dmac = container_of(push, typeof(*dmac), push);

dmac->cur = push->cur - (u32 __iomem *)dmac->_push.mem.object.map.ptr;
dmac->cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
if (dmac->put != dmac->cur) {
/* Push buffer fetches are not coherent with BAR1, we need to ensure
* writes have been flushed right through to VRAM before writing PUT.
*/
if (dmac->push->mem.type & NVIF_MEM_VRAM) {
if (dmac->push.mem.type & NVIF_MEM_VRAM) {
struct nvif_device *device = dmac->base.device;
nvif_wr32(&device->object, 0x070000, 0x00000001);
nvif_msec(device, 2000,
Expand Down Expand Up @@ -175,7 +175,7 @@ nv50_dmac_wind(struct nv50_dmac *dmac)
if (get == 0) {
/* Corner-case, HW idle, but non-committed work pending. */
if (dmac->put == 0)
nv50_dmac_kick(dmac->push);
nv50_dmac_kick(&dmac->push);

if (nvif_msec(dmac->base.device, 2000,
if (NVIF_TV32(&dmac->base.user, NV507C, GET, PTR, >, 0))
Expand All @@ -184,27 +184,27 @@ nv50_dmac_wind(struct nv50_dmac *dmac)
return -ETIMEDOUT;
}

PUSH_RSVD(dmac->push, PUSH_JUMP(dmac->push, 0));
PUSH_RSVD(&dmac->push, PUSH_JUMP(&dmac->push, 0));
dmac->cur = 0;
return 0;
}

static int
nv50_dmac_wait(struct nvif_push *push, u32 size)
{
struct nv50_dmac *dmac = container_of(push, typeof(*dmac), _push);
struct nv50_dmac *dmac = container_of(push, typeof(*dmac), push);
int free;

if (WARN_ON(size > dmac->max))
return -EINVAL;

dmac->cur = push->cur - (u32 __iomem *)dmac->_push.mem.object.map.ptr;
dmac->cur = push->cur - (u32 __iomem *)dmac->push.mem.object.map.ptr;
if (dmac->cur + size >= dmac->max) {
int ret = nv50_dmac_wind(dmac);
if (ret)
return ret;

push->cur = dmac->_push.mem.object.map.ptr;
push->cur = dmac->push.mem.object.map.ptr;
push->cur = push->cur + dmac->cur;
nv50_dmac_kick(push);
}
Expand All @@ -217,7 +217,7 @@ nv50_dmac_wait(struct nvif_push *push, u32 size)
return -ETIMEDOUT;
}

push->bgn = dmac->_push.mem.object.map.ptr;
push->bgn = dmac->push.mem.object.map.ptr;
push->bgn = push->bgn + dmac->cur;
push->cur = push->bgn;
push->end = push->cur + free;
Expand Down Expand Up @@ -252,16 +252,15 @@ nv50_dmac_create(struct nouveau_drm *drm,
(nv50_dmac_vram_pushbuf < 0 && device->info.family == NV_DEVICE_INFO_V0_PASCAL))
type |= NVIF_MEM_VRAM;

ret = nvif_mem_ctor_map(&drm->mmu, "kmsChanPush", type, 0x1000, &dmac->_push.mem);
ret = nvif_mem_ctor_map(&drm->mmu, "kmsChanPush", type, 0x1000, &dmac->push.mem);
if (ret)
return ret;

dmac->_push.wait = nv50_dmac_wait;
dmac->_push.kick = nv50_dmac_kick;
dmac->push = &dmac->_push;
dmac->push->bgn = dmac->_push.mem.object.map.ptr;
dmac->push->cur = dmac->push->bgn;
dmac->push->end = dmac->push->bgn;
dmac->push.wait = nv50_dmac_wait;
dmac->push.kick = nv50_dmac_kick;
dmac->push.bgn = dmac->push.mem.object.map.ptr;
dmac->push.cur = dmac->push.bgn;
dmac->push.end = dmac->push.bgn;
dmac->max = 0x1000/4 - 1;

/* EVO channels are affected by a HW bug where the last 12 DWORDs
Expand All @@ -270,7 +269,7 @@ nv50_dmac_create(struct nouveau_drm *drm,
if (disp->oclass < GV100_DISP)
dmac->max -= 12;

args->pushbuf = nvif_handle(&dmac->_push.mem.object);
args->pushbuf = nvif_handle(&dmac->push.mem.object);

ret = nv50_chan_create(device, disp, oclass, head, data, size,
&dmac->base);
Expand Down
3 changes: 1 addition & 2 deletions drivers/gpu/drm/nouveau/dispnv50/disp.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ struct nv50_chan {
struct nv50_dmac {
struct nv50_chan base;

struct nvif_push _push;
struct nvif_push *push;
struct nvif_push push;

struct nvif_object sync;
struct nvif_object vram;
Expand Down
Loading

0 comments on commit 61671d8

Please sign in to comment.