nouveau/winsys: Re-order channel creation

Also, rework the fail gotos so they make a little more sense.  Since we
were already calling dealloc the first time a subchan fails, we may as
well just always use dealloc.  Worst case the ioctl fails.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27205>
This commit is contained in:
Faith Ekstrand 2024-01-19 16:15:51 -06:00 committed by Marge Bot
parent ec4990ef41
commit c4ea8ab527

View file

@ -133,27 +133,21 @@ nouveau_ws_context_create(struct nouveau_ws_device *dev, struct nouveau_ws_conte
int ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_CHANNEL_ALLOC, &req, sizeof(req));
if (ret)
goto fail_chan;
goto fail_alloc;
ret = nouveau_ws_context_query_classes(dev->fd, req.channel, classes);
if (ret)
goto fail_chan;
goto fail_subchan;
base = (0xbeef + req.channel) << 16;
uint32_t obj_class = nouveau_ws_context_find_class(classes, 0x2d);
ret = nouveau_ws_subchan_alloc(dev->fd, req.channel, base | 0x902d, obj_class, &(*out)->eng2d);
if (ret)
goto fail_2d;
obj_class = nouveau_ws_context_find_class(classes, 0x40);
if (!obj_class)
obj_class = nouveau_ws_context_find_class(classes, 0x39);
ret = nouveau_ws_subchan_alloc(dev->fd, req.channel, base | 0x323f, obj_class, &(*out)->m2mf);
uint32_t obj_class = nouveau_ws_context_find_class(classes, 0xb5);
ret = nouveau_ws_subchan_alloc(dev->fd, req.channel, 0, obj_class, &(*out)->copy);
if (ret)
goto fail_subchan;
obj_class = nouveau_ws_context_find_class(classes, 0xb5);
ret = nouveau_ws_subchan_alloc(dev->fd, req.channel, 0, obj_class, &(*out)->copy);
obj_class = nouveau_ws_context_find_class(classes, 0x2d);
ret = nouveau_ws_subchan_alloc(dev->fd, req.channel, base | 0x902d, obj_class, &(*out)->eng2d);
if (ret)
goto fail_subchan;
@ -162,6 +156,13 @@ nouveau_ws_context_create(struct nouveau_ws_device *dev, struct nouveau_ws_conte
if (ret)
goto fail_subchan;
obj_class = nouveau_ws_context_find_class(classes, 0x40);
if (!obj_class)
obj_class = nouveau_ws_context_find_class(classes, 0x39);
ret = nouveau_ws_subchan_alloc(dev->fd, req.channel, base | 0x323f, obj_class, &(*out)->m2mf);
if (ret)
goto fail_subchan;
obj_class = nouveau_ws_context_find_class(classes, 0xc0);
ret = nouveau_ws_subchan_alloc(dev->fd, req.channel, base | 0x00c0, obj_class, &(*out)->compute);
if (ret)
@ -177,9 +178,8 @@ fail_subchan:
nouveau_ws_subchan_dealloc(dev->fd, &(*out)->copy);
nouveau_ws_subchan_dealloc(dev->fd, &(*out)->m2mf);
nouveau_ws_subchan_dealloc(dev->fd, &(*out)->eng2d);
fail_2d:
nouveau_ws_channel_dealloc(dev->fd, req.channel);
fail_chan:
fail_alloc:
FREE(*out);
return ret;
}