Re: [Nouveau] [Intel-gfx] [PATCH v6 08/17] drm/ttm: use gem vma_node
On Wed, 11 Sep 2019 at 07:53, Thierry Reding wrote: > > On Sat, Sep 07, 2019 at 09:58:46PM -0400, Ilia Mirkin wrote: > > On Wed, Aug 21, 2019 at 7:55 AM Thierry Reding > > wrote: > > > > > > On Wed, Aug 21, 2019 at 04:33:58PM +1000, Ben Skeggs wrote: > > > > On Wed, 14 Aug 2019 at 20:14, Gerd Hoffmann wrote: > > > > > > > > > > Hi, > > > > > > > > > > > > Changing the order doesn't look hard. Patch attached (untested, > > > > > > > have no > > > > > > > test hardware). But maybe I missed some detail ... > > > > > > > > > > > > I came up with something very similar by splitting up > > > > > > nouveau_bo_new() > > > > > > into allocation and initialization steps, so that when necessary > > > > > > the GEM > > > > > > object can be initialized in between. I think that's slightly more > > > > > > flexible and easier to understand than a boolean flag. > > > > > > > > > > Yes, that should work too. > > > > > > > > > > Acked-by: Gerd Hoffmann > > > > Acked-by: Ben Skeggs > > > > > > Thanks guys, applied to drm-misc-next. > > > > Hi Thierry, > > > > Initial investigations suggest that this commit currently in drm-next > > > > commit 019cbd4a4feb3aa3a917d78e7110e3011bbff6d5 > > Author: Thierry Reding > > Date: Wed Aug 14 11:00:48 2019 +0200 > > > > drm/nouveau: Initialize GEM object before TTM object > > > > breaks nouveau userspace which tries to allocate GEM objects with a > > non-page-aligned size. Previously nouveau_gem_new would just call > > nouveau_bo_init which would call nouveau_bo_fixup_align before > > initializing the GEM object. With this change, it is done after. What > > do you think -- OK to just move that bit of logic into the new > > nouveau_bo_alloc() (and make size/align be pointers so that they can > > be fixed up?) > > Hi Ilia, > > sorry, got side-tracked earlier and forgot to send this out. I'll turn > this into a proper patch, but if you manage to find the time to test > this while I work out the userspace issues that are preventing me from > testing this more thoroughly, that'd be great. I can confirm both I can reproduce the bug, and that the fix here appears to do the trick nicely. Ben. > > Thierry > > --- >8 --- > diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c > b/drivers/gpu/drm/nouveau/nouveau_bo.c > index e918b437af17..7d5ede756711 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_bo.c > +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c > @@ -186,8 +186,8 @@ nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags, > } > > struct nouveau_bo * > -nouveau_bo_alloc(struct nouveau_cli *cli, u64 size, u32 flags, u32 tile_mode, > -u32 tile_flags) > +nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 flags, > +u32 tile_mode, u32 tile_flags) > { > struct nouveau_drm *drm = cli->drm; > struct nouveau_bo *nvbo; > @@ -195,8 +195,8 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 size, u32 > flags, u32 tile_mode, > struct nvif_vmm *vmm = cli->svm.cli ? >svm.vmm : >vmm.vmm; > int i, pi = -1; > > - if (!size) { > - NV_WARN(drm, "skipped size %016llx\n", size); > + if (!*size) { > + NV_WARN(drm, "skipped size %016llx\n", *size); > return ERR_PTR(-EINVAL); > } > > @@ -266,7 +266,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 size, u32 > flags, u32 tile_mode, > pi = i; > > /* Stop once the buffer is larger than the current page size. > */ > - if (size >= 1ULL << vmm->page[i].shift) > + if (*size >= 1ULL << vmm->page[i].shift) > break; > } > > @@ -281,6 +281,8 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 size, u32 > flags, u32 tile_mode, > } > nvbo->page = vmm->page[pi].shift; > > + nouveau_bo_fixup_align(nvbo, flags, align, size); > + > return nvbo; > } > > @@ -292,12 +294,11 @@ nouveau_bo_init(struct nouveau_bo *nvbo, u64 size, int > align, u32 flags, > size_t acc_size; > int ret; > > - acc_size = ttm_bo_dma_acc_size(nvbo->bo.bdev, size, sizeof(*nvbo)); > - > - nouveau_bo_fixup_align(nvbo, flags, , ); > nvbo->bo.mem.num_pages = size >> PAGE_SHIFT; > nouveau_bo_placement_set(nvbo, flags, 0); > > + acc_size = ttm_bo_dma_acc_size(nvbo->bo.bdev, size, sizeof(*nvbo)); > + > ret = ttm_bo_init(nvbo->bo.bdev, >bo, size, type, > >placement, align >> PAGE_SHIFT, false, > acc_size, sg, robj, nouveau_bo_del_ttm); > @@ -318,7 +319,8 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int > align, > struct nouveau_bo *nvbo; > int ret; > > - nvbo = nouveau_bo_alloc(cli, size, flags, tile_mode, tile_flags); > + nvbo = nouveau_bo_alloc(cli, , , flags, tile_mode, > + tile_flags); > if (IS_ERR(nvbo)) > return PTR_ERR(nvbo);
Re: [Nouveau] [Intel-gfx] [PATCH v6 08/17] drm/ttm: use gem vma_node
On Sat, Sep 07, 2019 at 09:58:46PM -0400, Ilia Mirkin wrote: > On Wed, Aug 21, 2019 at 7:55 AM Thierry Reding > wrote: > > > > On Wed, Aug 21, 2019 at 04:33:58PM +1000, Ben Skeggs wrote: > > > On Wed, 14 Aug 2019 at 20:14, Gerd Hoffmann wrote: > > > > > > > > Hi, > > > > > > > > > > Changing the order doesn't look hard. Patch attached (untested, > > > > > > have no > > > > > > test hardware). But maybe I missed some detail ... > > > > > > > > > > I came up with something very similar by splitting up nouveau_bo_new() > > > > > into allocation and initialization steps, so that when necessary the > > > > > GEM > > > > > object can be initialized in between. I think that's slightly more > > > > > flexible and easier to understand than a boolean flag. > > > > > > > > Yes, that should work too. > > > > > > > > Acked-by: Gerd Hoffmann > > > Acked-by: Ben Skeggs > > > > Thanks guys, applied to drm-misc-next. > > Hi Thierry, > > Initial investigations suggest that this commit currently in drm-next > > commit 019cbd4a4feb3aa3a917d78e7110e3011bbff6d5 > Author: Thierry Reding > Date: Wed Aug 14 11:00:48 2019 +0200 > > drm/nouveau: Initialize GEM object before TTM object > > breaks nouveau userspace which tries to allocate GEM objects with a > non-page-aligned size. Previously nouveau_gem_new would just call > nouveau_bo_init which would call nouveau_bo_fixup_align before > initializing the GEM object. With this change, it is done after. What > do you think -- OK to just move that bit of logic into the new > nouveau_bo_alloc() (and make size/align be pointers so that they can > be fixed up?) Hi Ilia, sorry, got side-tracked earlier and forgot to send this out. I'll turn this into a proper patch, but if you manage to find the time to test this while I work out the userspace issues that are preventing me from testing this more thoroughly, that'd be great. Thierry --- >8 --- diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index e918b437af17..7d5ede756711 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -186,8 +186,8 @@ nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags, } struct nouveau_bo * -nouveau_bo_alloc(struct nouveau_cli *cli, u64 size, u32 flags, u32 tile_mode, -u32 tile_flags) +nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 flags, +u32 tile_mode, u32 tile_flags) { struct nouveau_drm *drm = cli->drm; struct nouveau_bo *nvbo; @@ -195,8 +195,8 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 size, u32 flags, u32 tile_mode, struct nvif_vmm *vmm = cli->svm.cli ? >svm.vmm : >vmm.vmm; int i, pi = -1; - if (!size) { - NV_WARN(drm, "skipped size %016llx\n", size); + if (!*size) { + NV_WARN(drm, "skipped size %016llx\n", *size); return ERR_PTR(-EINVAL); } @@ -266,7 +266,7 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 size, u32 flags, u32 tile_mode, pi = i; /* Stop once the buffer is larger than the current page size. */ - if (size >= 1ULL << vmm->page[i].shift) + if (*size >= 1ULL << vmm->page[i].shift) break; } @@ -281,6 +281,8 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 size, u32 flags, u32 tile_mode, } nvbo->page = vmm->page[pi].shift; + nouveau_bo_fixup_align(nvbo, flags, align, size); + return nvbo; } @@ -292,12 +294,11 @@ nouveau_bo_init(struct nouveau_bo *nvbo, u64 size, int align, u32 flags, size_t acc_size; int ret; - acc_size = ttm_bo_dma_acc_size(nvbo->bo.bdev, size, sizeof(*nvbo)); - - nouveau_bo_fixup_align(nvbo, flags, , ); nvbo->bo.mem.num_pages = size >> PAGE_SHIFT; nouveau_bo_placement_set(nvbo, flags, 0); + acc_size = ttm_bo_dma_acc_size(nvbo->bo.bdev, size, sizeof(*nvbo)); + ret = ttm_bo_init(nvbo->bo.bdev, >bo, size, type, >placement, align >> PAGE_SHIFT, false, acc_size, sg, robj, nouveau_bo_del_ttm); @@ -318,7 +319,8 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align, struct nouveau_bo *nvbo; int ret; - nvbo = nouveau_bo_alloc(cli, size, flags, tile_mode, tile_flags); + nvbo = nouveau_bo_alloc(cli, , , flags, tile_mode, + tile_flags); if (IS_ERR(nvbo)) return PTR_ERR(nvbo); diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h b/drivers/gpu/drm/nouveau/nouveau_bo.h index 62930d834fba..38f9d8350963 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.h +++ b/drivers/gpu/drm/nouveau/nouveau_bo.h @@ -71,8 +71,8 @@ nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo) extern struct ttm_bo_driver nouveau_bo_driver; void nouveau_bo_move_init(struct nouveau_drm *);
Re: [Nouveau] [Intel-gfx] [PATCH v6 08/17] drm/ttm: use gem vma_node
On Wed, Aug 21, 2019 at 7:55 AM Thierry Reding wrote: > > On Wed, Aug 21, 2019 at 04:33:58PM +1000, Ben Skeggs wrote: > > On Wed, 14 Aug 2019 at 20:14, Gerd Hoffmann wrote: > > > > > > Hi, > > > > > > > > Changing the order doesn't look hard. Patch attached (untested, have > > > > > no > > > > > test hardware). But maybe I missed some detail ... > > > > > > > > I came up with something very similar by splitting up nouveau_bo_new() > > > > into allocation and initialization steps, so that when necessary the GEM > > > > object can be initialized in between. I think that's slightly more > > > > flexible and easier to understand than a boolean flag. > > > > > > Yes, that should work too. > > > > > > Acked-by: Gerd Hoffmann > > Acked-by: Ben Skeggs > > Thanks guys, applied to drm-misc-next. Hi Thierry, Initial investigations suggest that this commit currently in drm-next commit 019cbd4a4feb3aa3a917d78e7110e3011bbff6d5 Author: Thierry Reding Date: Wed Aug 14 11:00:48 2019 +0200 drm/nouveau: Initialize GEM object before TTM object breaks nouveau userspace which tries to allocate GEM objects with a non-page-aligned size. Previously nouveau_gem_new would just call nouveau_bo_init which would call nouveau_bo_fixup_align before initializing the GEM object. With this change, it is done after. What do you think -- OK to just move that bit of logic into the new nouveau_bo_alloc() (and make size/align be pointers so that they can be fixed up?) Cheers, -ilia ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Nouveau] [Intel-gfx] [PATCH v6 08/17] drm/ttm: use gem vma_node
On Wed, Aug 21, 2019 at 04:33:58PM +1000, Ben Skeggs wrote: > On Wed, 14 Aug 2019 at 20:14, Gerd Hoffmann wrote: > > > > Hi, > > > > > > Changing the order doesn't look hard. Patch attached (untested, have no > > > > test hardware). But maybe I missed some detail ... > > > > > > I came up with something very similar by splitting up nouveau_bo_new() > > > into allocation and initialization steps, so that when necessary the GEM > > > object can be initialized in between. I think that's slightly more > > > flexible and easier to understand than a boolean flag. > > > > Yes, that should work too. > > > > Acked-by: Gerd Hoffmann > Acked-by: Ben Skeggs Thanks guys, applied to drm-misc-next. Thierry signature.asc Description: PGP signature ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Nouveau] [Intel-gfx] [PATCH v6 08/17] drm/ttm: use gem vma_node
On Wed, 14 Aug 2019 at 20:14, Gerd Hoffmann wrote: > > Hi, > > > > Changing the order doesn't look hard. Patch attached (untested, have no > > > test hardware). But maybe I missed some detail ... > > > > I came up with something very similar by splitting up nouveau_bo_new() > > into allocation and initialization steps, so that when necessary the GEM > > object can be initialized in between. I think that's slightly more > > flexible and easier to understand than a boolean flag. > > Yes, that should work too. > > Acked-by: Gerd Hoffmann Acked-by: Ben Skeggs > > cheers, > Gerd > > ___ > Nouveau mailing list > nouv...@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/nouveau ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel