Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcf3f91c authored by Ben Skeggs's avatar Ben Skeggs
Browse files

drm/nouveau: remove unnecessary usage of object handles



No longer required in a lot of cases, as objects are identified over NVIF
via an alternate mechanism since the rework.

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent a0a49bac
Loading
Loading
Loading
Loading
+5 −12
Original line number Original line Diff line number Diff line
@@ -51,8 +51,7 @@ nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev)
			 * device (ie. the one that belongs to the fd it
			 * device (ie. the one that belongs to the fd it
			 * opened)
			 * opened)
			 */
			 */
			if (nvif_device_init(&cli->base.object,
			if (nvif_device_init(&cli->base.object, 0, NV_DEVICE,
					     NOUVEAU_ABI16_DEVICE, NV_DEVICE,
					     &args, sizeof(args),
					     &args, sizeof(args),
					     &abi16->device) == 0)
					     &abi16->device) == 0)
				return cli->abi16;
				return cli->abi16;
@@ -133,7 +132,6 @@ nouveau_abi16_chan_fini(struct nouveau_abi16 *abi16,


	/* destroy channel object, all children will be killed too */
	/* destroy channel object, all children will be killed too */
	if (chan->chan) {
	if (chan->chan) {
		abi16->handles &= ~(1ULL << (chan->chan->user.handle & 0xffff));
		nouveau_channel_idle(chan->chan);
		nouveau_channel_idle(chan->chan);
		nouveau_channel_del(&chan->chan);
		nouveau_channel_del(&chan->chan);
	}
	}
@@ -268,26 +266,21 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
		return nouveau_abi16_put(abi16, -EINVAL);
		return nouveau_abi16_put(abi16, -EINVAL);


	/* allocate "abi16 channel" data and make up a handle for it */
	/* allocate "abi16 channel" data and make up a handle for it */
	init->channel = __ffs64(~abi16->handles);
	if (~abi16->handles == 0)
		return nouveau_abi16_put(abi16, -ENOSPC);

	chan = kzalloc(sizeof(*chan), GFP_KERNEL);
	chan = kzalloc(sizeof(*chan), GFP_KERNEL);
	if (!chan)
	if (!chan)
		return nouveau_abi16_put(abi16, -ENOMEM);
		return nouveau_abi16_put(abi16, -ENOMEM);


	INIT_LIST_HEAD(&chan->notifiers);
	INIT_LIST_HEAD(&chan->notifiers);
	list_add(&chan->head, &abi16->channels);
	list_add(&chan->head, &abi16->channels);
	abi16->handles |= (1ULL << init->channel);


	/* create channel object and initialise dma and fence management */
	/* create channel object and initialise dma and fence management */
	ret = nouveau_channel_new(drm, device,
	ret = nouveau_channel_new(drm, device, init->fb_ctxdma_handle,
				  NOUVEAU_ABI16_CHAN(init->channel),
				  init->fb_ctxdma_handle,
				  init->tt_ctxdma_handle, &chan->chan);
				  init->tt_ctxdma_handle, &chan->chan);
	if (ret)
	if (ret)
		goto done;
		goto done;


	init->channel = chan->chan->chid;

	if (device->info.family >= NV_DEVICE_INFO_V0_TESLA)
	if (device->info.family >= NV_DEVICE_INFO_V0_TESLA)
		init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM |
		init->pushbuf_domains = NOUVEAU_GEM_DOMAIN_VRAM |
					NOUVEAU_GEM_DOMAIN_GART;
					NOUVEAU_GEM_DOMAIN_GART;
@@ -338,7 +331,7 @@ nouveau_abi16_chan(struct nouveau_abi16 *abi16, int channel)
	struct nouveau_abi16_chan *chan;
	struct nouveau_abi16_chan *chan;


	list_for_each_entry(chan, &abi16->channels, head) {
	list_for_each_entry(chan, &abi16->channels, head) {
		if (chan->chan->user.handle == NOUVEAU_ABI16_CHAN(channel))
		if (chan->chan->chid == channel)
			return chan;
			return chan;
	}
	}


+13 −17
Original line number Original line Diff line number Diff line
@@ -55,10 +55,8 @@ nouveau_channel_idle(struct nouveau_channel *chan)
		}
		}


		if (ret) {
		if (ret) {
			NV_PRINTK(err, cli, "failed to idle channel "
			NV_PRINTK(err, cli, "failed to idle channel %d [%s]\n",
					    "0x%08x [%s]\n",
				  chan->chid, nvxx_client(&cli->base)->name);
				  chan->user.handle,
				  nvxx_client(&cli->base)->name);
			return ret;
			return ret;
		}
		}
	}
	}
@@ -89,7 +87,7 @@ nouveau_channel_del(struct nouveau_channel **pchan)


static int
static int
nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
		     u32 handle, u32 size, struct nouveau_channel **pchan)
		     u32 size, struct nouveau_channel **pchan)
{
{
	struct nouveau_cli *cli = (void *)device->object.client;
	struct nouveau_cli *cli = (void *)device->object.client;
	struct nvkm_mmu *mmu = nvxx_mmu(device);
	struct nvkm_mmu *mmu = nvxx_mmu(device);
@@ -174,8 +172,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
		}
		}
	}
	}


	ret = nvif_object_init(&device->object, NVDRM_PUSH |
	ret = nvif_object_init(&device->object, 0, NV_DMA_FROM_MEMORY,
			       (handle & 0xffff), NV_DMA_FROM_MEMORY,
			       &args, sizeof(args), &chan->push.ctxdma);
			       &args, sizeof(args), &chan->push.ctxdma);
	if (ret) {
	if (ret) {
		nouveau_channel_del(pchan);
		nouveau_channel_del(pchan);
@@ -187,7 +184,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,


static int
static int
nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
		    u32 handle, u32 engine, struct nouveau_channel **pchan)
		    u32 engine, struct nouveau_channel **pchan)
{
{
	static const u16 oclasses[] = { MAXWELL_CHANNEL_GPFIFO_A,
	static const u16 oclasses[] = { MAXWELL_CHANNEL_GPFIFO_A,
					KEPLER_CHANNEL_GPFIFO_A,
					KEPLER_CHANNEL_GPFIFO_A,
@@ -206,7 +203,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
	int ret;
	int ret;


	/* allocate dma push buffer */
	/* allocate dma push buffer */
	ret = nouveau_channel_prep(drm, device, handle, 0x12000, &chan);
	ret = nouveau_channel_prep(drm, device, 0x12000, &chan);
	*pchan = chan;
	*pchan = chan;
	if (ret)
	if (ret)
		return ret;
		return ret;
@@ -236,7 +233,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
			size = sizeof(args.nv50);
			size = sizeof(args.nv50);
		}
		}


		ret = nvif_object_init(&device->object, handle, *oclass++,
		ret = nvif_object_init(&device->object, 0, *oclass++,
				       &args, size, &chan->user);
				       &args, size, &chan->user);
		if (ret == 0) {
		if (ret == 0) {
			if (chan->user.oclass >= KEPLER_CHANNEL_GPFIFO_A)
			if (chan->user.oclass >= KEPLER_CHANNEL_GPFIFO_A)
@@ -256,7 +253,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,


static int
static int
nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device,
nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device,
		    u32 handle, struct nouveau_channel **pchan)
		    struct nouveau_channel **pchan)
{
{
	static const u16 oclasses[] = { NV40_CHANNEL_DMA,
	static const u16 oclasses[] = { NV40_CHANNEL_DMA,
					NV17_CHANNEL_DMA,
					NV17_CHANNEL_DMA,
@@ -269,7 +266,7 @@ nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device,
	int ret;
	int ret;


	/* allocate dma push buffer */
	/* allocate dma push buffer */
	ret = nouveau_channel_prep(drm, device, handle, 0x10000, &chan);
	ret = nouveau_channel_prep(drm, device, 0x10000, &chan);
	*pchan = chan;
	*pchan = chan;
	if (ret)
	if (ret)
		return ret;
		return ret;
@@ -280,7 +277,7 @@ nouveau_channel_dma(struct nouveau_drm *drm, struct nvif_device *device,
	args.offset = chan->push.vma.offset;
	args.offset = chan->push.vma.offset;


	do {
	do {
		ret = nvif_object_init(&device->object, handle, *oclass++,
		ret = nvif_object_init(&device->object, 0, *oclass++,
				       &args, sizeof(args), &chan->user);
				       &args, sizeof(args), &chan->user);
		if (ret == 0) {
		if (ret == 0) {
			chan->chid = args.chid;
			chan->chid = args.chid;
@@ -401,8 +398,7 @@ 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_drm *drm, struct nvif_device *device,
		    u32 handle, u32 arg0, u32 arg1,
		    u32 arg0, u32 arg1, struct nouveau_channel **pchan)
		    struct nouveau_channel **pchan)
{
{
	struct nouveau_cli *cli = (void *)device->object.client;
	struct nouveau_cli *cli = (void *)device->object.client;
	bool super;
	bool super;
@@ -412,10 +408,10 @@ nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device,
	super = cli->base.super;
	super = cli->base.super;
	cli->base.super = true;
	cli->base.super = true;


	ret = nouveau_channel_ind(drm, device, handle, arg0, pchan);
	ret = nouveau_channel_ind(drm, device, arg0, pchan);
	if (ret) {
	if (ret) {
		NV_PRINTK(dbg, cli, "ib channel create, %d\n", ret);
		NV_PRINTK(dbg, cli, "ib channel create, %d\n", ret);
		ret = nouveau_channel_dma(drm, device, handle, pchan);
		ret = nouveau_channel_dma(drm, device, pchan);
		if (ret) {
		if (ret) {
			NV_PRINTK(dbg, cli, "dma channel create, %d\n", ret);
			NV_PRINTK(dbg, cli, "dma channel create, %d\n", ret);
			goto done;
			goto done;
+1 −2
Original line number Original line Diff line number Diff line
@@ -42,8 +42,7 @@ struct nouveau_channel {




int  nouveau_channel_new(struct nouveau_drm *, struct nvif_device *,
int  nouveau_channel_new(struct nouveau_drm *, struct nvif_device *,
			 u32 handle, u32 arg0, u32 arg1,
			 u32 arg0, u32 arg1, struct nouveau_channel **);
			 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 *);


+2 −3
Original line number Original line Diff line number Diff line
@@ -509,9 +509,8 @@ nouveau_display_create(struct drm_device *dev)
		int i;
		int i;


		for (i = 0, ret = -ENODEV; ret && i < ARRAY_SIZE(oclass); i++) {
		for (i = 0, ret = -ENODEV; ret && i < ARRAY_SIZE(oclass); i++) {
			ret = nvif_object_init(&drm->device.object,
			ret = nvif_object_init(&drm->device.object, 0,
					       NVDRM_DISPLAY, oclass[i],
					       oclass[i], NULL, 0, &disp->disp);
					       NULL, 0, &disp->disp);
		}
		}


		if (ret == 0) {
		if (ret == 0) {
+4 −6
Original line number Original line Diff line number Diff line
@@ -208,7 +208,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
	}
	}


	if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
	if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
		ret = nouveau_channel_new(drm, &drm->device, NVDRM_CHAN + 1,
		ret = nouveau_channel_new(drm, &drm->device,
					  KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE0|
					  KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE0|
					  KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE1,
					  KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE1,
					  0, &drm->cechan);
					  0, &drm->cechan);
@@ -221,7 +221,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
	if (device->info.chipset >= 0xa3 &&
	if (device->info.chipset >= 0xa3 &&
	    device->info.chipset != 0xaa &&
	    device->info.chipset != 0xaa &&
	    device->info.chipset != 0xac) {
	    device->info.chipset != 0xac) {
		ret = nouveau_channel_new(drm, &drm->device, NVDRM_CHAN + 1,
		ret = nouveau_channel_new(drm, &drm->device,
					  NvDmaFB, NvDmaTT, &drm->cechan);
					  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);
@@ -233,8 +233,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
		arg1 = NvDmaTT;
		arg1 = NvDmaTT;
	}
	}


	ret = nouveau_channel_new(drm, &drm->device, NVDRM_CHAN, arg0, arg1,
	ret = nouveau_channel_new(drm, &drm->device, arg0, arg1, &drm->channel);
				 &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_fini(drm);
		nouveau_accel_fini(drm);
@@ -403,8 +402,7 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)


	nouveau_get_hdmi_dev(drm);
	nouveau_get_hdmi_dev(drm);


	ret = nvif_device_init(&drm->client.base.object,
	ret = nvif_device_init(&drm->client.base.object, 0, NV_DEVICE,
			       NVDRM_DEVICE, NV_DEVICE,
			       &(struct nv_device_v0) {
			       &(struct nv_device_v0) {
					.device = ~0,
					.device = ~0,
			       }, sizeof(struct nv_device_v0),
			       }, sizeof(struct nv_device_v0),
Loading