Skip to content

Commit 0aac3fb

Browse files
Ben Skeggsgregkh
authored andcommitted
drm/nouveau: pass cli to nouveau_channel_new() instead of drm+device
[ Upstream commit 5cca41a ] Both of these are stored in nouveau_cli already, and also allows the removal of some void casts. 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-32-bskeggs@nvidia.com Stable-dep-of: 04e0481 ("nouveau/dmem: Fix privileged error in copy engine channel") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ca57186 commit 0aac3fb

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

drivers/gpu/drm/nouveau/dispnv04/crtc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ nv04_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
11571157
chan = drm->channel;
11581158
if (!chan)
11591159
return -ENODEV;
1160-
cli = (void *)chan->user.client;
1160+
cli = chan->cli;
11611161
push = chan->chan.push;
11621162

11631163
s = kzalloc(sizeof(*s), GFP_KERNEL);

drivers/gpu/drm/nouveau/nouveau_abi16.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
351351
list_add(&chan->head, &abi16->channels);
352352

353353
/* create channel object and initialise dma and fence management */
354-
ret = nouveau_channel_new(drm, device, false, runm, init->fb_ctxdma_handle,
354+
ret = nouveau_channel_new(cli, false, runm, init->fb_ctxdma_handle,
355355
init->tt_ctxdma_handle, &chan->chan);
356356
if (ret)
357357
goto done;

drivers/gpu/drm/nouveau/nouveau_bo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict,
843843
{
844844
struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
845845
struct nouveau_channel *chan = drm->ttm.chan;
846-
struct nouveau_cli *cli = (void *)chan->user.client;
846+
struct nouveau_cli *cli = chan->cli;
847847
struct nouveau_fence *fence;
848848
int ret;
849849

drivers/gpu/drm/nouveau/nouveau_chan.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static int
5252
nouveau_channel_killed(struct nvif_event *event, void *repv, u32 repc)
5353
{
5454
struct nouveau_channel *chan = container_of(event, typeof(*chan), kill);
55-
struct nouveau_cli *cli = (void *)chan->user.client;
55+
struct nouveau_cli *cli = chan->cli;
5656

5757
NV_PRINTK(warn, cli, "channel %d killed!\n", chan->chid);
5858

@@ -66,7 +66,7 @@ int
6666
nouveau_channel_idle(struct nouveau_channel *chan)
6767
{
6868
if (likely(chan && chan->fence && !atomic_read(&chan->killed))) {
69-
struct nouveau_cli *cli = (void *)chan->user.client;
69+
struct nouveau_cli *cli = chan->cli;
7070
struct nouveau_fence *fence = NULL;
7171
int ret;
7272

@@ -142,10 +142,11 @@ nouveau_channel_wait(struct nvif_push *push, u32 size)
142142
}
143143

144144
static int
145-
nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
145+
nouveau_channel_prep(struct nouveau_cli *cli,
146146
u32 size, struct nouveau_channel **pchan)
147147
{
148-
struct nouveau_cli *cli = (void *)device->object.client;
148+
struct nouveau_drm *drm = cli->drm;
149+
struct nvif_device *device = &cli->device;
149150
struct nv_dma_v0 args = {};
150151
struct nouveau_channel *chan;
151152
u32 target;
@@ -155,6 +156,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
155156
if (!chan)
156157
return -ENOMEM;
157158

159+
chan->cli = cli;
158160
chan->device = device;
159161
chan->drm = drm;
160162
chan->vmm = nouveau_cli_vmm(cli);
@@ -254,7 +256,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
254256
}
255257

256258
static int
257-
nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool priv, u64 runm,
259+
nouveau_channel_ctor(struct nouveau_cli *cli, bool priv, u64 runm,
258260
struct nouveau_channel **pchan)
259261
{
260262
const struct nvif_mclass hosts[] = {
@@ -279,7 +281,7 @@ nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool p
279281
struct nvif_chan_v0 chan;
280282
char name[TASK_COMM_LEN+16];
281283
} args;
282-
struct nouveau_cli *cli = (void *)device->object.client;
284+
struct nvif_device *device = &cli->device;
283285
struct nouveau_channel *chan;
284286
const u64 plength = 0x10000;
285287
const u64 ioffset = plength;
@@ -298,7 +300,7 @@ nouveau_channel_ctor(struct nouveau_drm *drm, struct nvif_device *device, bool p
298300
size = ioffset + ilength;
299301

300302
/* allocate dma push buffer */
301-
ret = nouveau_channel_prep(drm, device, size, &chan);
303+
ret = nouveau_channel_prep(cli, size, &chan);
302304
*pchan = chan;
303305
if (ret)
304306
return ret;
@@ -493,13 +495,12 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
493495
}
494496

495497
int
496-
nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device,
498+
nouveau_channel_new(struct nouveau_cli *cli,
497499
bool priv, u64 runm, u32 vram, u32 gart, struct nouveau_channel **pchan)
498500
{
499-
struct nouveau_cli *cli = (void *)device->object.client;
500501
int ret;
501502

502-
ret = nouveau_channel_ctor(drm, device, priv, runm, pchan);
503+
ret = nouveau_channel_ctor(cli, priv, runm, pchan);
503504
if (ret) {
504505
NV_PRINTK(dbg, cli, "channel create, %d\n", ret);
505506
return ret;

drivers/gpu/drm/nouveau/nouveau_chan.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct nouveau_channel {
1212
struct nvif_push *push;
1313
} chan;
1414

15+
struct nouveau_cli *cli;
1516
struct nvif_device *device;
1617
struct nouveau_drm *drm;
1718
struct nouveau_vmm *vmm;
@@ -62,7 +63,7 @@ struct nouveau_channel {
6263
int nouveau_channels_init(struct nouveau_drm *);
6364
void nouveau_channels_fini(struct nouveau_drm *);
6465

65-
int nouveau_channel_new(struct nouveau_drm *, struct nvif_device *, bool priv, u64 runm,
66+
int nouveau_channel_new(struct nouveau_cli *, bool priv, u64 runm,
6667
u32 vram, u32 gart, struct nouveau_channel **);
6768
void nouveau_channel_del(struct nouveau_channel **);
6869
int nouveau_channel_idle(struct nouveau_channel *);

drivers/gpu/drm/nouveau/nouveau_drm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ nouveau_accel_ce_init(struct nouveau_drm *drm)
343343
return;
344344
}
345345

346-
ret = nouveau_channel_new(drm, device, false, runm, NvDmaFB, NvDmaTT, &drm->cechan);
346+
ret = nouveau_channel_new(&drm->client, false, runm, NvDmaFB, NvDmaTT, &drm->cechan);
347347
if (ret)
348348
NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
349349
}
@@ -371,7 +371,7 @@ nouveau_accel_gr_init(struct nouveau_drm *drm)
371371
return;
372372
}
373373

374-
ret = nouveau_channel_new(drm, device, false, runm, NvDmaFB, NvDmaTT, &drm->channel);
374+
ret = nouveau_channel_new(&drm->client, false, runm, NvDmaFB, NvDmaTT, &drm->channel);
375375
if (ret) {
376376
NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
377377
nouveau_accel_gr_fini(drm);

0 commit comments

Comments
 (0)