video: driver: Add support for non-secure pix context bank

- Add support for a new non-secure pix context bank.
- Remove usage of deprecated 'buffer-types' in context banks.

Change-Id: I3a21eb8ce1d9aff277568d54aadb54193ad0ce75
Signed-off-by: Mihir Ganu <mganu@codeaurora.org>
This commit is contained in:
Mihir Ganu
2021-03-05 17:51:10 -08:00
parent 03bda80d9e
commit ccb6da7567
6 changed files with 75 additions and 55 deletions

View File

@@ -180,11 +180,17 @@ static inline bool is_active_session(u64 prev, u64 curr)
MSM_VIDC_SESSION_INACTIVE_THRESHOLD_MS); MSM_VIDC_SESSION_INACTIVE_THRESHOLD_MS);
} }
static inline bool is_session_error(struct msm_vidc_inst* inst) static inline bool is_session_error(struct msm_vidc_inst *inst)
{ {
return inst->state == MSM_VIDC_ERROR; return inst->state == MSM_VIDC_ERROR;
} }
static inline bool is_secure_region(enum msm_vidc_buffer_region region)
{
return !(region == MSM_VIDC_NON_SECURE ||
region == MSM_VIDC_NON_SECURE_PIXEL);
}
const char *cap_name(enum msm_vidc_inst_capability_type cap); const char *cap_name(enum msm_vidc_inst_capability_type cap);
void print_vidc_buffer(u32 tag, const char *tag_str, const char *str, struct msm_vidc_inst *inst, void print_vidc_buffer(u32 tag, const char *tag_str, const char *str, struct msm_vidc_inst *inst,
struct msm_vidc_buffer *vbuf); struct msm_vidc_buffer *vbuf);

View File

@@ -104,7 +104,6 @@ struct addr_set {
struct context_bank_info { struct context_bank_info {
struct list_head list; struct list_head list;
const char *name; const char *name;
u32 buffer_type;
bool is_secure; bool is_secure;
struct addr_range addr_range; struct addr_range addr_range;
struct device *dev; struct device *dev;

View File

@@ -168,6 +168,7 @@ enum msm_vidc_buffer_attributes {
enum msm_vidc_buffer_region { enum msm_vidc_buffer_region {
MSM_VIDC_REGION_NONE = 0, MSM_VIDC_REGION_NONE = 0,
MSM_VIDC_NON_SECURE, MSM_VIDC_NON_SECURE,
MSM_VIDC_NON_SECURE_PIXEL,
MSM_VIDC_SECURE_PIXEL, MSM_VIDC_SECURE_PIXEL,
MSM_VIDC_SECURE_NONPIXEL, MSM_VIDC_SECURE_NONPIXEL,
MSM_VIDC_SECURE_BITSTREAM, MSM_VIDC_SECURE_BITSTREAM,

View File

@@ -784,11 +784,31 @@ u32 msm_vidc_get_buffer_region(struct msm_vidc_inst *inst,
{ {
u32 region = MSM_VIDC_NON_SECURE; u32 region = MSM_VIDC_NON_SECURE;
if (!is_secure_session(inst) && if (!is_secure_session(inst)) {
buffer_type != MSM_VIDC_BUF_ARP) { switch (buffer_type) {
return region; case MSM_VIDC_BUF_ARP:
region = MSM_VIDC_SECURE_NONPIXEL;
break;
case MSM_VIDC_BUF_INPUT:
if (is_encode_session(inst))
region = MSM_VIDC_NON_SECURE_PIXEL;
else
region = MSM_VIDC_NON_SECURE;
break;
case MSM_VIDC_BUF_OUTPUT:
if (is_decode_session(inst))
region = MSM_VIDC_NON_SECURE_PIXEL;
else
region = MSM_VIDC_NON_SECURE;
break;
case MSM_VIDC_BUF_DPB:
region = MSM_VIDC_NON_SECURE_PIXEL;
break;
default:
region = MSM_VIDC_NON_SECURE;
break;
} }
} else {
switch (buffer_type) { switch (buffer_type) {
case MSM_VIDC_BUF_INPUT: case MSM_VIDC_BUF_INPUT:
if (is_encode_session(inst)) if (is_encode_session(inst))
@@ -818,7 +838,6 @@ u32 msm_vidc_get_buffer_region(struct msm_vidc_inst *inst,
region = MSM_VIDC_SECURE_PIXEL; region = MSM_VIDC_SECURE_PIXEL;
break; break;
case MSM_VIDC_BUF_PERSIST: case MSM_VIDC_BUF_PERSIST:
// TODO: Need to revisit for ARP
case MSM_VIDC_BUF_ARP: case MSM_VIDC_BUF_ARP:
region = MSM_VIDC_SECURE_NONPIXEL; region = MSM_VIDC_SECURE_NONPIXEL;
break; break;
@@ -826,6 +845,8 @@ u32 msm_vidc_get_buffer_region(struct msm_vidc_inst *inst,
i_vpr_e(inst, "%s: invalid driver buffer type %d\n", i_vpr_e(inst, "%s: invalid driver buffer type %d\n",
func, buffer_type); func, buffer_type);
} }
}
return region; return region;
} }
@@ -2283,7 +2304,7 @@ int msm_vidc_create_internal_buffer(struct msm_vidc_inst *inst,
alloc->region = msm_vidc_get_buffer_region(inst, alloc->region = msm_vidc_get_buffer_region(inst,
buffer_type, __func__); buffer_type, __func__);
alloc->size = buffer->buffer_size; alloc->size = buffer->buffer_size;
alloc->secure = (alloc->region > MSM_VIDC_NON_SECURE) ? 1 : 0; alloc->secure = is_secure_region(alloc->region);
rc = msm_vidc_memory_alloc(inst->core, alloc); rc = msm_vidc_memory_alloc(inst->core, alloc);
if (rc) if (rc)
return -ENOMEM; return -ENOMEM;

View File

@@ -819,10 +819,9 @@ static int msm_vidc_setup_context_bank(struct msm_vidc_core *core,
d_vpr_h("Attached %s and created mapping\n", dev_name(dev)); d_vpr_h("Attached %s and created mapping\n", dev_name(dev));
d_vpr_h( d_vpr_h(
"Context bank: %s, buffer_type: %#x, is_secure: %d, address range start: %#x, size: %#x, dev: %pK, domain: %pK", "Context bank: %s, is_secure: %d, address range start: %#x, size: %#x, dev: %pK, domain: %pK",
cb->name, cb->buffer_type, cb->is_secure, cb->addr_range.start, cb->name, cb->is_secure, cb->addr_range.start,
cb->addr_range.size, cb->dev, cb->domain); cb->addr_range.size, cb->dev, cb->domain);
remove_cb: remove_cb:
return rc; return rc;
} }
@@ -868,16 +867,9 @@ static int msm_vidc_populate_context_bank(struct device *dev,
d_vpr_h("context bank %s: secure = %d\n", d_vpr_h("context bank %s: secure = %d\n",
cb->name, cb->is_secure); cb->name, cb->is_secure);
/* setup buffer type for each sub device*/ d_vpr_h("context bank %s address start %x size %x\n",
rc = of_property_read_u32(np, "buffer-types", &cb->buffer_type);
if (rc) {
d_vpr_e("failed to load buffer_type info %d\n", rc);
rc = -ENOENT;
goto err_setup_cb;
}
d_vpr_h("context bank %s address start %x size %x buffer_type %x\n",
cb->name, cb->addr_range.start, cb->name, cb->addr_range.start,
cb->addr_range.size, cb->buffer_type); cb->addr_range.size);
rc = msm_vidc_setup_context_bank(core, cb, dev); rc = msm_vidc_setup_context_bank(core, cb, dev);
if (rc) { if (rc) {

View File

@@ -27,6 +27,7 @@ struct context_bank_info *get_context_bank(struct msm_vidc_core *core,
static const struct msm_vidc_buf_region_name buf_region_name[] = { static const struct msm_vidc_buf_region_name buf_region_name[] = {
{MSM_VIDC_REGION_NONE, "none" }, {MSM_VIDC_REGION_NONE, "none" },
{MSM_VIDC_NON_SECURE, "venus_ns" }, {MSM_VIDC_NON_SECURE, "venus_ns" },
{MSM_VIDC_NON_SECURE_PIXEL, "venus_ns_pixel" },
{MSM_VIDC_SECURE_PIXEL, "venus_sec_pixel" }, {MSM_VIDC_SECURE_PIXEL, "venus_sec_pixel" },
{MSM_VIDC_SECURE_NONPIXEL, "venus_sec_non_pixel" }, {MSM_VIDC_SECURE_NONPIXEL, "venus_sec_non_pixel" },
{MSM_VIDC_SECURE_BITSTREAM, "venus_sec_bitstream" }, {MSM_VIDC_SECURE_BITSTREAM, "venus_sec_bitstream" },