Alexandre Courbot
2015-Mar-13 06:27 UTC
[Nouveau] [PATCH] nouveau: add coherent BO attribute
Add a flag allowing Nouveau to specify that an object should be coherent at allocation time. This is required for some class of objects like fences which are randomly-accessed by both the CPU and GPU. This flag instructs the kernel driver to make sure the object remains coherent even on architectures for which coherency is not guaranteed by the bus. Signed-off-by: Alexandre Courbot <acourbot at nvidia.com> --- include/drm/nouveau_drm.h | 1 + nouveau/abi16.c | 3 +++ nouveau/nouveau.h | 1 + 3 files changed, 5 insertions(+) diff --git a/include/drm/nouveau_drm.h b/include/drm/nouveau_drm.h index b18cad02419b..87aefc5e9d2f 100644 --- a/include/drm/nouveau_drm.h +++ b/include/drm/nouveau_drm.h @@ -96,6 +96,7 @@ struct drm_nouveau_setparam { #define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1) #define NOUVEAU_GEM_DOMAIN_GART (1 << 2) #define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) +#define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4) #define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00 #define NOUVEAU_GEM_TILE_16BPP 0x00000001 diff --git a/nouveau/abi16.c b/nouveau/abi16.c index ae13821bc0cc..d2d1d0d1942d 100644 --- a/nouveau/abi16.c +++ b/nouveau/abi16.c @@ -195,6 +195,9 @@ abi16_bo_init(struct nouveau_bo *bo, uint32_t alignment, if (bo->flags & NOUVEAU_BO_MAP) info->domain |= NOUVEAU_GEM_DOMAIN_MAPPABLE; + if (bo->flags & NOUVEAU_BO_COHERENT) + info->domain |= NOUVEAU_GEM_DOMAIN_COHERENT; + if (!(bo->flags & NOUVEAU_BO_CONTIG)) info->tile_flags = NOUVEAU_GEM_TILE_NONCONTIG; diff --git a/nouveau/nouveau.h b/nouveau/nouveau.h index a55e2b020778..4adda0e3594c 100644 --- a/nouveau/nouveau.h +++ b/nouveau/nouveau.h @@ -127,6 +127,7 @@ union nouveau_bo_config { #define NOUVEAU_BO_MAP 0x80000000 #define NOUVEAU_BO_CONTIG 0x40000000 #define NOUVEAU_BO_NOSNOOP 0x20000000 +#define NOUVEAU_BO_COHERENT 0x10000000 struct nouveau_bo { struct nouveau_device *device; -- 2.3.2
Doesn't this require a kernel version that has your other patch? What happens when this runs on an older kernel? Does it get silently ignored, or does it end up erroring out? If it errors out, that's fine. Otherwise some sort of version check should be put in, no? On Fri, Mar 13, 2015 at 2:27 AM, Alexandre Courbot <acourbot at nvidia.com> wrote:> Add a flag allowing Nouveau to specify that an object should be coherent > at allocation time. This is required for some class of objects like > fences which are randomly-accessed by both the CPU and GPU. This flag > instructs the kernel driver to make sure the object remains coherent > even on architectures for which coherency is not guaranteed by the bus. > > Signed-off-by: Alexandre Courbot <acourbot at nvidia.com> > --- > include/drm/nouveau_drm.h | 1 + > nouveau/abi16.c | 3 +++ > nouveau/nouveau.h | 1 + > 3 files changed, 5 insertions(+) > > diff --git a/include/drm/nouveau_drm.h b/include/drm/nouveau_drm.h > index b18cad02419b..87aefc5e9d2f 100644 > --- a/include/drm/nouveau_drm.h > +++ b/include/drm/nouveau_drm.h > @@ -96,6 +96,7 @@ struct drm_nouveau_setparam { > #define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1) > #define NOUVEAU_GEM_DOMAIN_GART (1 << 2) > #define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) > +#define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4) > > #define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00 > #define NOUVEAU_GEM_TILE_16BPP 0x00000001 > diff --git a/nouveau/abi16.c b/nouveau/abi16.c > index ae13821bc0cc..d2d1d0d1942d 100644 > --- a/nouveau/abi16.c > +++ b/nouveau/abi16.c > @@ -195,6 +195,9 @@ abi16_bo_init(struct nouveau_bo *bo, uint32_t alignment, > if (bo->flags & NOUVEAU_BO_MAP) > info->domain |= NOUVEAU_GEM_DOMAIN_MAPPABLE; > > + if (bo->flags & NOUVEAU_BO_COHERENT) > + info->domain |= NOUVEAU_GEM_DOMAIN_COHERENT; > + > if (!(bo->flags & NOUVEAU_BO_CONTIG)) > info->tile_flags = NOUVEAU_GEM_TILE_NONCONTIG; > > diff --git a/nouveau/nouveau.h b/nouveau/nouveau.h > index a55e2b020778..4adda0e3594c 100644 > --- a/nouveau/nouveau.h > +++ b/nouveau/nouveau.h > @@ -127,6 +127,7 @@ union nouveau_bo_config { > #define NOUVEAU_BO_MAP 0x80000000 > #define NOUVEAU_BO_CONTIG 0x40000000 > #define NOUVEAU_BO_NOSNOOP 0x20000000 > +#define NOUVEAU_BO_COHERENT 0x10000000 > > struct nouveau_bo { > struct nouveau_device *device; > -- > 2.3.2 >
Alexandre Courbot
2015-Mar-13 06:39 UTC
[Nouveau] [PATCH] nouveau: add coherent BO attribute
On Fri, Mar 13, 2015 at 3:36 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:> Doesn't this require a kernel version that has your other patch? What > happens when this runs on an older kernel? Does it get silently > ignored, or does it end up erroring out? If it errors out, that's > fine. Otherwise some sort of version check should be put in, no?The corresponding kernel patch is already merged in Ben's tree. If running with an older kernel, this flag will be a no-op, which is fine since GK20A's GPU (the reason for this patch as you have guessed :)) is not enabled for these kernels. I am fine with adding a version check if you think it is necessary.
Maarten Lankhorst
2015-Mar-13 19:33 UTC
[Nouveau] [PATCH] nouveau: add coherent BO attribute
Hey, Op 13-03-15 om 07:27 schreef Alexandre Courbot:> Add a flag allowing Nouveau to specify that an object should be coherent > at allocation time. This is required for some class of objects like > fences which are randomly-accessed by both the CPU and GPU. This flag > instructs the kernel driver to make sure the object remains coherent > even on architectures for which coherency is not guaranteed by the bus. > > Signed-off-by: Alexandre Courbot <acourbot at nvidia.com>I don't see a problem with this patch, but similar patches to intel to libdrm have been shot down when the changes weren't in an official kernel yet, so I think this should wait until the change is at least in drm-next. ;-)
Alexandre Courbot
2015-Mar-15 08:41 UTC
[Nouveau] [PATCH] nouveau: add coherent BO attribute
On 03/14/2015 04:33 AM, Maarten Lankhorst wrote:> Hey, > > Op 13-03-15 om 07:27 schreef Alexandre Courbot: >> Add a flag allowing Nouveau to specify that an object should be coherent >> at allocation time. This is required for some class of objects like >> fences which are randomly-accessed by both the CPU and GPU. This flag >> instructs the kernel driver to make sure the object remains coherent >> even on architectures for which coherency is not guaranteed by the bus. >> >> Signed-off-by: Alexandre Courbot <acourbot at nvidia.com> > I don't see a problem with this patch, but similar patches to intel to libdrm have been shot down when the changes weren't in an official kernel yet, so I think this should wait until the change is at least in drm-next. ;-)Sounds good. I will ping you again once the kernel change reaches -next.