Skip to content

Commit 8e00fd6

Browse files
committed
[Decode] Add set fences and get fence implement in i915 drm
Signed-off-by: Xu, Zhengguo <zhengguo.xu@intel.com>
1 parent 8a1f79c commit 8e00fd6

File tree

5 files changed

+84
-20
lines changed

5 files changed

+84
-20
lines changed

media_softlet/linux/common/os/i915/include/mos_bufmgr_api.h

+1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ struct mos_drm_uc_version {
254254

255255
struct mos_exec_fences
256256
{
257+
#define FENCES_MAX 10
257258
int32_t *fences;
258259
int32_t count;
259260
};

media_softlet/linux/common/os/i915/include/mos_bufmgr_priv.h

+3
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ struct mos_bufmgr {
418418
uint8_t (*switch_off_n_bits)(struct mos_linux_context *ctx, uint8_t in_mask, int n) = nullptr;
419419
unsigned int (*hweight8)(struct mos_linux_context *ctx, uint8_t w) = nullptr;
420420

421+
int (*set_fences)(struct mos_bufmgr *bufmgr, struct mos_exec_fences *exec_fences) = nullptr;
422+
int (*get_fence)(struct mos_bufmgr *bufmgr, int32_t *fence_out) = nullptr;
423+
421424
/**< Enables verbose debugging printouts */
422425
int debug = 0;
423426
uint32_t *get_reserved = nullptr;

media_softlet/linux/common/os/i915/mos_bufmgr.c

+59
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ struct mos_bufmgr_gem {
140140
int exec_size;
141141
int exec_count;
142142

143+
struct mos_exec_fences exec_fences;
144+
143145
/** Array of lists of cached gem objects of power-of-two sizes */
144146
struct mos_gem_bo_bucket cache_bucket[64];
145147
int num_buckets;
@@ -5221,6 +5223,61 @@ mos_bufmgr_enable_turbo_boost(struct mos_bufmgr *bufmgr)
52215223
DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &ctxParam );
52225224
}
52235225

5226+
int
5227+
mos_bufmgr_set_fences(struct mos_bufmgr *bufmgr, struct mos_exec_fences *exec_fences)
5228+
{
5229+
if (!bufmgr || !exec_fences || exec_fences->count > FENCES_MAX)
5230+
{
5231+
return -EINVAL;
5232+
}
5233+
5234+
struct mos_bufmgr_gem *bufmgr_gem = (struct mos_bufmgr_gem *)bufmgr;
5235+
5236+
if (bufmgr_gem->exec_fences.fences == nullptr)
5237+
{
5238+
//fences[0] reserved for fence out
5239+
bufmgr_gem->exec_fences.fences = (int32_t *)malloc((FENCES_MAX + 1) * sizeof(int32_t));
5240+
5241+
if (bufmgr_gem->exec_fences.fences == nullptr)
5242+
{
5243+
return -ENOMEM;
5244+
}
5245+
5246+
bufmgr_gem->exec_fences.count = 0;
5247+
}
5248+
5249+
if (exec_fences->count > 0)
5250+
{
5251+
memcpy(bufmgr_gem->exec_fences.fences, exec_fences->fences, (exec_fences->count + 1) * sizeof(int32_t));
5252+
bufmgr_gem->exec_fences.fences[0] = 0;
5253+
bufmgr_gem->exec_fences.count = exec_fences->count;
5254+
}
5255+
5256+
return 0;
5257+
}
5258+
5259+
int
5260+
mos_bufmgr_get_fence(struct mos_bufmgr *bufmgr, int32_t *fence_out)
5261+
{
5262+
if (!bufmgr || !fence_out)
5263+
{
5264+
return -EINVAL;
5265+
}
5266+
5267+
struct mos_bufmgr_gem *bufmgr_gem = (struct mos_bufmgr_gem *)bufmgr;
5268+
5269+
if (bufmgr_gem->exec_fences.fences)
5270+
{
5271+
*fence_out = bufmgr_gem->exec_fences.fences[0];
5272+
}
5273+
else
5274+
{
5275+
*fence_out = 0;
5276+
}
5277+
5278+
return 0;
5279+
}
5280+
52245281
/**
52255282
* Initializes the GEM buffer manager, which uses the kernel to allocate, map,
52265283
* and manage map buffer objections.
@@ -5333,6 +5390,8 @@ mos_bufmgr_gem_init_i915(int fd, int batch_size)
53335390
bufmgr_gem->bufmgr.get_ts_frequency = mos_bufmgr_get_ts_frequency;
53345391
bufmgr_gem->bufmgr.has_bsd2 = mos_bufmgr_has_bsd2;
53355392
bufmgr_gem->bufmgr.enable_turbo_boost = mos_bufmgr_enable_turbo_boost;
5393+
bufmgr_gem->bufmgr.set_fences = mos_bufmgr_set_fences;
5394+
bufmgr_gem->bufmgr.get_fence = mos_bufmgr_get_fence;
53365395

53375396
bufmgr_gem->mem_profiler_path = getenv("MEDIA_MEMORY_PROFILER_LOG");
53385397
if (bufmgr_gem->mem_profiler_path != nullptr)

media_softlet/linux/common/os/i915/mos_bufmgr_api.c

+18-20
Original file line numberDiff line numberDiff line change
@@ -1232,16 +1232,15 @@ mos_set_fences(struct mos_bufmgr *bufmgr, struct mos_exec_fences *exec_fences)
12321232
return -EINVAL;
12331233
}
12341234

1235-
return 0;
1236-
//todo: add func pointer to bufmgr
1237-
//if (bufmgr->set_fences)
1238-
//{
1239-
// return bufmgr->set_fences(bufmgr, exec_fences);
1240-
//}
1241-
//else
1242-
//{
1243-
// MOS_OS_CRITICALMESSAGE("Unsupported\n");
1244-
//}
1235+
if (bufmgr->set_fences)
1236+
{
1237+
return bufmgr->set_fences(bufmgr, exec_fences);
1238+
}
1239+
else
1240+
{
1241+
MOS_OS_CRITICALMESSAGE("Unsupported\n");
1242+
return -EPERM;
1243+
}
12451244

12461245
}
12471246

@@ -1254,16 +1253,15 @@ mos_get_fence(struct mos_bufmgr *bufmgr, int32_t *fence_out)
12541253
return -EINVAL;
12551254
}
12561255

1257-
return 0;
1258-
//todo: add func pointer to bufmgr
1259-
//if (bufmgr->get_fence)
1260-
//{
1261-
// return bufmgr->get_fence(bufmgr, fence_out);
1262-
//}
1263-
//else
1264-
//{
1265-
// MOS_OS_CRITICALMESSAGE("Unsupported\n");
1266-
//}
1256+
if (bufmgr->get_fence)
1257+
{
1258+
return bufmgr->get_fence(bufmgr, fence_out);
1259+
}
1260+
else
1261+
{
1262+
MOS_OS_CRITICALMESSAGE("Unsupported\n");
1263+
return -EPERM;
1264+
}
12671265

12681266
}
12691267

media_softlet/linux/common/os/i915_production/mos_bufmgr_priv.h

+3
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ struct mos_bufmgr {
419419
uint8_t (*switch_off_n_bits)(struct mos_linux_context *ctx, uint8_t in_mask, int n) = nullptr;
420420
unsigned int (*hweight8)(struct mos_linux_context *ctx, uint8_t w) = nullptr;
421421

422+
int (*set_fences)(struct mos_bufmgr *bufmgr, struct mos_exec_fences *exec_fences) = nullptr;
423+
int (*get_fence)(struct mos_bufmgr *bufmgr, int32_t *fence_out) = nullptr;
424+
422425
/**< Enables verbose debugging printouts */
423426
int debug = 0;
424427
/** used for reserved info*/

0 commit comments

Comments
 (0)