Commit 5cca41ac authored by Ben Skeggs's avatar Ben Skeggs Committed by Danilo Krummrich

drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device

Both of these are stored in nouveau_cli already, and also allows the
removal of some void casts.
Signed-off-by: default avatarBen Skeggs <bskeggs@nvidia.com>
Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240726043828.58966-32-bskeggs@nvidia.com
parent 3019023e
...@@ -1172,7 +1172,7 @@ nv04_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, ...@@ -1172,7 +1172,7 @@ nv04_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
chan = drm->channel; chan = drm->channel;
if (!chan) if (!chan)
return -ENODEV; return -ENODEV;
cli = (void *)chan->user.client; cli = chan->cli;
push = chan->chan.push; push = chan->chan.push;
s = kzalloc(sizeof(*s), GFP_KERNEL); s = kzalloc(sizeof(*s), GFP_KERNEL);
......
...@@ -405,7 +405,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS) ...@@ -405,7 +405,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
list_add(&chan->head, &abi16->channels); list_add(&chan->head, &abi16->channels);
/* create channel object and initialise dma and fence management */ /* create channel object and initialise dma and fence management */
ret = nouveau_channel_new(drm, device, false, runm, init->fb_ctxdma_handle, ret = nouveau_channel_new(cli, false, runm, init->fb_ctxdma_handle,
init->tt_ctxdma_handle, &chan->chan); init->tt_ctxdma_handle, &chan->chan);
if (ret) if (ret)
goto done; goto done;
......
...@@ -859,7 +859,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, ...@@ -859,7 +859,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict,
{ {
struct nouveau_drm *drm = nouveau_bdev(bo->bdev); struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
struct nouveau_channel *chan = drm->ttm.chan; struct nouveau_channel *chan = drm->ttm.chan;
struct nouveau_cli *cli = (void *)chan->user.client; struct nouveau_cli *cli = chan->cli;
struct nouveau_fence *fence; struct nouveau_fence *fence;
int ret; int ret;
......
...@@ -52,7 +52,7 @@ static int ...@@ -52,7 +52,7 @@ static int
nouveau_channel_killed(struct nvif_event *event, void *repv, u32 repc) nouveau_channel_killed(struct nvif_event *event, void *repv, u32 repc)
{ {
struct nouveau_channel *chan = container_of(event, typeof(*chan), kill); struct nouveau_channel *chan = container_of(event, typeof(*chan), kill);
struct nouveau_cli *cli = (void *)chan->user.client; struct nouveau_cli *cli = chan->cli;
NV_PRINTK(warn, cli, "channel %d killed!\n", chan->chid); NV_PRINTK(warn, cli, "channel %d killed!\n", chan->chid);
...@@ -66,7 +66,7 @@ int ...@@ -66,7 +66,7 @@ int
nouveau_channel_idle(struct nouveau_channel *chan) nouveau_channel_idle(struct nouveau_channel *chan)
{ {
if (likely(chan && chan->fence && !atomic_read(&chan->killed))) { if (likely(chan && chan->fence && !atomic_read(&chan->killed))) {
struct nouveau_cli *cli = (void *)chan->user.client; struct nouveau_cli *cli = chan->cli;
struct nouveau_fence *fence = NULL; struct nouveau_fence *fence = NULL;
int ret; int ret;
...@@ -142,10 +142,11 @@ nouveau_channel_wait(struct nvif_push *push, u32 size) ...@@ -142,10 +142,11 @@ nouveau_channel_wait(struct nvif_push *push, u32 size)
} }
static int static int
nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device, nouveau_channel_prep(struct nouveau_cli *cli,
u32 size, struct nouveau_channel **pchan) u32 size, struct nouveau_channel **pchan)
{ {
struct nouveau_cli *cli = (void *)device->object.client; struct nouveau_drm *drm = cli->drm;
struct nvif_device *device = &cli->device;
struct nv_dma_v0 args = {}; struct nv_dma_v0 args = {};
struct nouveau_channel *chan; struct nouveau_channel *chan;
u32 target; u32 target;
...@@ -155,6 +156,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device, ...@@ -155,6 +156,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
if (!chan) if (!chan)
return -ENOMEM; return -ENOMEM;
chan->cli = cli;
chan->device = device; chan->device = device;
chan->drm = drm; chan->drm = drm;
chan->vmm = nouveau_cli_vmm(cli); chan->vmm = nouveau_cli_vmm(cli);
...@@ -253,7 +255,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device, ...@@ -253,7 +255,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
} }
static int static int
nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool priv, u64 runm, nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
struct nouveau_channel **pchan) struct nouveau_channel **pchan)
{ {
const struct nvif_mclass hosts[] = { const struct nvif_mclass hosts[] = {
...@@ -278,7 +280,7 @@ nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool p ...@@ -278,7 +280,7 @@ nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool p
struct nvif_chan_v0 chan; struct nvif_chan_v0 chan;
char name[TASK_COMM_LEN+16]; char name[TASK_COMM_LEN+16];
} args; } args;
struct nouveau_cli *cli = (void *)device->object.client; struct nvif_device *device = &cli->device;
struct nouveau_channel *chan; struct nouveau_channel *chan;
const u64 plength = 0x10000; const u64 plength = 0x10000;
const u64 ioffset = plength; const u64 ioffset = plength;
...@@ -297,7 +299,7 @@ nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool p ...@@ -297,7 +299,7 @@ nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool p
size = ioffset + ilength; size = ioffset + ilength;
/* allocate dma push buffer */ /* allocate dma push buffer */
ret = nouveau_channel_prep(drm, device, size, &chan); ret = nouveau_channel_prep(cli, size, &chan);
*pchan = chan; *pchan = chan;
if (ret) if (ret)
return ret; return ret;
...@@ -492,13 +494,12 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart) ...@@ -492,13 +494,12 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
} }
int int
nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device, nouveau_channel_new(struct nouveau_cli *cli,
bool priv, u64 runm, u32 vram, u32 gart, struct nouveau_channel **pchan) bool priv, u64 runm, u32 vram, u32 gart, struct nouveau_channel **pchan)
{ {
struct nouveau_cli *cli = (void *)device->object.client;
int ret; int ret;
ret = nouveau_channel_ctor(drm, device, priv, runm, pchan); ret = nouveau_channel_ctor(cli, priv, runm, pchan);
if (ret) { if (ret) {
NV_PRINTK(dbg, cli, "channel create, %d\n", ret); NV_PRINTK(dbg, cli, "channel create, %d\n", ret);
return ret; return ret;
......
...@@ -12,6 +12,7 @@ struct nouveau_channel { ...@@ -12,6 +12,7 @@ struct nouveau_channel {
struct nvif_push *push; struct nvif_push *push;
} chan; } chan;
struct nouveau_cli *cli;
struct nvif_device *device; struct nvif_device *device;
struct nouveau_drm *drm; struct nouveau_drm *drm;
struct nouveau_vmm *vmm; struct nouveau_vmm *vmm;
...@@ -62,7 +63,7 @@ struct nouveau_channel { ...@@ -62,7 +63,7 @@ struct nouveau_channel {
int nouveau_channels_init(struct nouveau_drm *); int nouveau_channels_init(struct nouveau_drm *);
void nouveau_channels_fini(struct nouveau_drm *); void nouveau_channels_fini(struct nouveau_drm *);
int nouveau_channel_new(struct nouveau_drm *, struct nvif_device *, bool priv, u64 runm, int nouveau_channel_new(struct nouveau_cli *, bool priv, u64 runm,
u32 vram, u32 gart, struct nouveau_channel **); u32 vram, u32 gart, struct nouveau_channel **);
void nouveau_channel_del(struct nouveau_channel **); void nouveau_channel_del(struct nouveau_channel **);
int nouveau_channel_idle(struct nouveau_channel *); int nouveau_channel_idle(struct nouveau_channel *);
......
...@@ -335,7 +335,7 @@ nouveau_accel_ce_init(struct nouveau_drm *drm) ...@@ -335,7 +335,7 @@ nouveau_accel_ce_init(struct nouveau_drm *drm)
return; return;
} }
ret = nouveau_channel_new(drm, device, false, runm, NvDmaFB, NvDmaTT, &drm->cechan); ret = nouveau_channel_new(&drm->client, false, runm, NvDmaFB, NvDmaTT, &drm->cechan);
if (ret) if (ret)
NV_ERROR(drm, "failed to create ce channel, %d\n", ret); NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
} }
...@@ -363,7 +363,7 @@ nouveau_accel_gr_init(struct nouveau_drm *drm) ...@@ -363,7 +363,7 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
return; return;
} }
ret = nouveau_channel_new(drm, device, false, runm, NvDmaFB, NvDmaTT, &drm->channel); ret = nouveau_channel_new(&drm->client, false, runm, NvDmaFB, NvDmaTT, &drm->channel);
if (ret) { if (ret) {
NV_ERROR(drm, "failed to create kernel channel, %d\n", ret); NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
nouveau_accel_gr_fini(drm); nouveau_accel_gr_fini(drm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment