[PATCH 1/6] drm/radeon: add a way to get and set initial buffer domains (original) (raw)
Christian König deathsimple at vodafone.de
Mon Feb 24 08:17:37 PST 2014
- Previous message: [PATCH 1/6] drm/radeon: add a way to get and set initial buffer domains
- Next message: [PATCH 1/6] drm/radeon: add a way to get and set initial buffer domains
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Am 24.02.2014 16:20, schrieb Marek Olšák:
From: Marek Olšák <marek.olsak at amd.com>
When passing buffers between processes, the receiving process needs to know the original buffer domain, so that it doesn't accidentally move the buffer. Signed-off-by: Marek Olšák <marek.olsak at amd.com> --- drivers/gpu/drm/radeon/radeon.h | 3 +++ drivers/gpu/drm/radeon/radeondrv.c | 3 ++- drivers/gpu/drm/radeon/radeongem.c | 30 ++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeonkms.c | 1 + drivers/gpu/drm/radeon/radeonobject.c | 3 +++ include/uapi/drm/radeondrm.h | 12 ++++++++++++ 6 files changed, 51 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index a415f8e..3f10782 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -454,6 +454,7 @@ struct radeonbo { /* Protected by gem.mutex */ struct listhead list; /* Protected by tbo.reserved */ + u32 initialdomain; u32 placements[3]; struct ttmplacement placement; struct ttmbufferobject tbo; @@ -2114,6 +2115,8 @@ int radeongemwaitidleioctl(struct drmdevice *dev, void *data, struct drmfile *filp); int radeongemvaioctl(struct drmdevice *dev, void *data, struct drmfile *filp); +int radeongemopioctl(struct drmdevice *dev, void *data, + struct drmfile *filp); int radeoncsioctl(struct drmdevice *dev, void *data, struct drmfile *filp); int radeongemsettilingioctl(struct drmdevice *dev, void *data, struct drmfile *filp); diff --git a/drivers/gpu/drm/radeon/radeondrv.c b/drivers/gpu/drm/radeon/radeondrv.c index 84a1bbb7..4392b7c 100644 --- a/drivers/gpu/drm/radeon/radeondrv.c +++ b/drivers/gpu/drm/radeon/radeondrv.c @@ -79,9 +79,10 @@ * 2.35.0 - Add CIK macrotile mode array query * 2.36.0 - Fix CIK DCE tiling setup * 2.37.0 - allow GS ring setup on r6xx/r7xx + * 2.38.0 - RADEONGEMOP (GETINITIALDOMAIN, SETINITIALDOMAIN) */ #define KMSDRIVERMAJOR 2 -#define KMSDRIVERMINOR 37 +#define KMSDRIVERMINOR 38 #define KMSDRIVERPATCHLEVEL 0 int radeondriverloadkms(struct drmdevice *dev, unsigned long flags); int radeondriverunloadkms(struct drmdevice *dev); diff --git a/drivers/gpu/drm/radeon/radeongem.c b/drivers/gpu/drm/radeon/radeongem.c index b96c819..d7890f2 100644 --- a/drivers/gpu/drm/radeon/radeongem.c +++ b/drivers/gpu/drm/radeon/radeongem.c @@ -533,6 +533,36 @@ out: return r; } +int radeongemopioctl(struct drmdevice *dev, void *data, + struct drmfile *filp) +{ + struct drmradeongemop *args = data; + struct drmgemobject *gobj; + struct radeonbo *robj; + + gobj = drmgemobjectlookup(dev, filp, args->handle); + if (gobj == NULL) { + return -ENOENT; + } + robj = gemtoradeonbo(gobj); +
When the comment is correct and initial_domain is protected by reserving the BO you should actually reserve/unreserve it here. On the other hand locking might not be necessary.
+ switch (args->op) { + case RADEONGEMOPGETINITIALDOMAIN: + args->value = robj->initialdomain; + break; + case RADEONGEMOPSETINITIALDOMAIN: + robj->initialdomain = args->value & (RADEONGEMDOMAINVRAM | + RADEONGEMDOMAINGTT | + RADEONGEMDOMAINCPU); + break; + default: + ; /* do nothing */
Should probably return -EINVAL here.
+ } + + drmgemobjectunreferenceunlocked(gobj); + return 0; +} + int radeonmodedumbcreate(struct drmfile *filepriv, struct drmdevice *dev, struct drmmodecreatedumb *args) diff --git a/drivers/gpu/drm/radeon/radeonkms.c b/drivers/gpu/drm/radeon/radeonkms.c index baff98b..0b631eb 100644 --- a/drivers/gpu/drm/radeon/radeonkms.c +++ b/drivers/gpu/drm/radeon/radeonkms.c @@ -814,5 +814,6 @@ const struct drmioctldesc radeonioctlskms[] = { DRMIOCTLDEFDRV(RADEONGEMGETTILING, radeongemgettilingioctl, DRMAUTH|DRMUNLOCKED|DRMRENDERALLOW), DRMIOCTLDEFDRV(RADEONGEMBUSY, radeongembusyioctl, DRMAUTH|DRMUNLOCKED|DRMRENDERALLOW), DRMIOCTLDEFDRV(RADEONGEMVA, radeongemvaioctl, DRMAUTH|DRMUNLOCKED|DRMRENDERALLOW), + DRMIOCTLDEFDRV(RADEONGEMOP, radeongemopioctl, DRMAUTH|DRMUNLOCKED|DRMRENDERALLOW), }; int radeonmaxkmsioctl = DRMARRAYSIZE(radeonioctlskms); diff --git a/drivers/gpu/drm/radeon/radeonobject.c b/drivers/gpu/drm/radeon/radeonobject.c index 08595cf..dd12bb4 100644 --- a/drivers/gpu/drm/radeon/radeonobject.c +++ b/drivers/gpu/drm/radeon/radeonobject.c @@ -145,6 +145,9 @@ int radeonbocreate(struct radeondevice *rdev, bo->surfacereg = -1; INITLISTHEAD(&bo->list); INITLISTHEAD(&bo->va); + bo->initialdomain = domain & (RADEONGEMDOMAINVRAM | + RADEONGEMDOMAINGTT | + RADEONGEMDOMAINCPU); radeonttmplacementfromdomain(bo, domain); /* Kernel allocation are uninterruptible */ downread(&rdev->pm.mclklock); diff --git a/include/uapi/drm/radeondrm.h b/include/uapi/drm/radeondrm.h index 1cf18b4..cb5c93a 100644 --- a/include/uapi/drm/radeondrm.h +++ b/include/uapi/drm/radeondrm.h @@ -510,6 +510,7 @@ typedef struct { #define DRMRADEONGEMGETTILING 0x29 #define DRMRADEONGEMBUSY 0x2a #define DRMRADEONGEMVA 0x2b +#define DRMRADEONGEMOP 0x2c
#define DRMIOCTLRADEONCPINIT DRMIOW( DRMCOMMANDBASE + DRMRADEONCPINIT, drmradeoninitt) #define DRMIOCTLRADEONCPSTART DRMIO( DRMCOMMANDBASE + DRMRADEONCPSTART) @@ -552,6 +553,7 @@ typedef struct { #define DRMIOCTLRADEONGEMGETTILING DRMIOWR(DRMCOMMANDBASE + DRMRADEONGEMGETTILING, struct drmradeongemgettiling) #define DRMIOCTLRADEONGEMBUSY DRMIOWR(DRMCOMMANDBASE + DRMRADEONGEMBUSY, struct drmradeongembusy) #define DRMIOCTLRADEONGEMVA DRMIOWR(DRMCOMMANDBASE + DRMRADEONGEMVA, struct drmradeongemva) +#define DRMIOCTLRADEONGEMOP DRMIOWR(DRMCOMMANDBASE + DRMRADEONGEMOP, struct drmradeongemop) typedef struct drmradeoninit { enum { @@ -884,6 +886,16 @@ struct drmradeongempwrite { uint64t dataptr; }; +/* Sets or returns a value associated with a buffer. */ +struct drmradeongemop { + uint32t handle; /* buffer */ + uint32t op; /* RADEONGEMOP* */ + uint64t value; /* input or return value */ +}; + +#define RADEONGEMOPGETINITIALDOMAIN 0 +#define RADEONGEMOPSETINITIALDOMAIN 1 + #define RADEONVAMAP 1 #define RADEONVAUNMAP 2
- Previous message: [PATCH 1/6] drm/radeon: add a way to get and set initial buffer domains
- Next message: [PATCH 1/6] drm/radeon: add a way to get and set initial buffer domains
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]