Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10d5754e authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "gpu: ion: only secure buffers when supported"

parents 6afebac0 628e28a3
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -492,7 +492,13 @@ static int ion_secure_cma_allocate(struct ion_heap *heap,
	if (buf) {
		int ret;

		if (!msm_secure_v2_is_supported()) {
			pr_debug("%s: securing buffers is not supported on this platform\n",
				__func__);
			ret = 1;
		} else {
			ret = msm_ion_secure_table(buf->table, 0, 0);
		}
		if (ret) {
			/*
			 * Don't treat the secure buffer failing here as an
@@ -516,6 +522,7 @@ static void ion_secure_cma_free(struct ion_buffer *buffer)
	struct ion_secure_cma_buffer_info *info = buffer->priv_virt;

	dev_dbg(sheap->dev, "Release buffer %p\n", buffer);
	if (msm_secure_v2_is_supported())
		msm_ion_unsecure_table(info->table);
	atomic_sub(buffer->size, &sheap->total_allocated);
	BUG_ON(atomic_read(&sheap->total_allocated) < 0);
+8 −0
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ int msm_ion_secure_table(struct sg_table *table, enum cp_mem_usage usage,

int msm_ion_unsecure_table(struct sg_table *table);

bool msm_secure_v2_is_supported(void);

#else
static inline int ion_cp_change_chunks_state(unsigned long chunks,
			unsigned int nchunks, unsigned int chunk_size,
@@ -123,6 +125,12 @@ int msm_ion_unsecure_table(struct sg_table *table)
{
	return -ENODEV;
}

bool msm_secure_v2_is_supported(void)
{
	return false;
}

#endif

#endif
+15 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ struct cp2_lock_req {

#define MEM_PROTECT_LOCK_ID2     0x0A
#define V2_CHUNK_SIZE		SZ_1M
#define FEATURE_ID_CP 12

static void secure_meta_add(struct secure_meta *meta)
{
@@ -281,3 +282,17 @@ int msm_ion_unsecure_buffer(struct ion_client *client,
out:
	return ret;
}

#define MAKE_CP_VERSION(major, minor, patch) \
	(((major & 0x3FF) << 22) | ((minor & 0x3FF) << 12) | (patch & 0xFFF))

bool msm_secure_v2_is_supported(void)
{
	int version = scm_get_feat_version(FEATURE_ID_CP);

	/*
	 * if the version is < 1.1.0 then dynamic buffer allocation is
	 * not supported
	 */
	return version >= MAKE_CP_VERSION(1, 1, 0);
}