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

Commit f5b17d95 authored by Maheshwar Ajja's avatar Maheshwar Ajja
Browse files

msm: vidc: Fix device address comparison issue



In secure usecases the device address for input
and output buffers can be same and hence use
buffer type while comparing device addresses in
msm_comm_compare_device_plane() to resolve secure
video usecases failure.

Change-Id: I1660effc3650db5480a9020c994790647390328f
Signed-off-by: default avatarMaheshwar Ajja <majja@codeaurora.org>
parent 2cbcc095
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -1621,7 +1621,8 @@ static void handle_event_change(enum hal_command_response cmd, void *data)

		planes[0] = event_notify->packet_buffer;
		planes[1] = event_notify->extra_data_buffer;
		mbuf = msm_comm_get_buffer_using_device_planes(inst, planes);
		mbuf = msm_comm_get_buffer_using_device_planes(inst,
				V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, planes);
		if (!mbuf || !kref_get_mbuf(inst, mbuf)) {
			dprintk(VIDC_ERR,
				"%s: data_addr %x, extradata_addr %x not found\n",
@@ -2381,7 +2382,8 @@ static void handle_ebd(enum hal_command_response cmd, void *data)
	planes[0] = empty_buf_done->packet_buffer;
	planes[1] = empty_buf_done->extra_data_buffer;

	mbuf = msm_comm_get_buffer_using_device_planes(inst, planes);
	mbuf = msm_comm_get_buffer_using_device_planes(inst,
			V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, planes);
	if (!mbuf || !kref_get_mbuf(inst, mbuf)) {
		dprintk(VIDC_ERR,
			"%s: data_addr %x, extradata_addr %x not found\n",
@@ -2527,7 +2529,8 @@ static void handle_fbd(enum hal_command_response cmd, void *data)

	buffer_type = msm_comm_get_hal_output_buffer(inst);
	if (fill_buf_done->buffer_type == buffer_type) {
		mbuf = msm_comm_get_buffer_using_device_planes(inst, planes);
		mbuf = msm_comm_get_buffer_using_device_planes(inst,
				V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, planes);
		if (!mbuf || !kref_get_mbuf(inst, mbuf)) {
			dprintk(VIDC_ERR,
				"%s: data_addr %x, extradata_addr %x not found\n",
@@ -6054,7 +6057,7 @@ bool msm_comm_compare_dma_planes(struct msm_vidc_inst *inst,


bool msm_comm_compare_device_plane(struct msm_vidc_buffer *mbuf,
		u32 *planes, u32 i)
		u32 type, u32 *planes, u32 i)
{
	if (!mbuf || !planes) {
		dprintk(VIDC_ERR, "%s: invalid params, %pK %pK\n",
@@ -6062,14 +6065,15 @@ bool msm_comm_compare_device_plane(struct msm_vidc_buffer *mbuf,
		return false;
	}

	if (mbuf->smem[i].device_addr == planes[i])
	if (mbuf->vvb.vb2_buf.type == type &&
		mbuf->smem[i].device_addr == planes[i])
		return true;

	return false;
}

bool msm_comm_compare_device_planes(struct msm_vidc_buffer *mbuf,
		u32 *planes)
		u32 type, u32 *planes)
{
	int i = 0;

@@ -6077,7 +6081,7 @@ bool msm_comm_compare_device_planes(struct msm_vidc_buffer *mbuf,
		return false;

	for (i = 0; i < mbuf->vvb.vb2_buf.num_planes; i++) {
		if (!msm_comm_compare_device_plane(mbuf, planes, i))
		if (!msm_comm_compare_device_plane(mbuf, type, planes, i))
			return false;
	}

@@ -6085,7 +6089,7 @@ bool msm_comm_compare_device_planes(struct msm_vidc_buffer *mbuf,
}

struct msm_vidc_buffer *msm_comm_get_buffer_using_device_planes(
		struct msm_vidc_inst *inst, u32 *planes)
		struct msm_vidc_inst *inst, u32 type, u32 *planes)
{
	struct msm_vidc_buffer *mbuf;
	bool found = false;
@@ -6093,7 +6097,7 @@ struct msm_vidc_buffer *msm_comm_get_buffer_using_device_planes(
	mutex_lock(&inst->registeredbufs.lock);
	found = false;
	list_for_each_entry(mbuf, &inst->registeredbufs.list, list) {
		if (msm_comm_compare_device_planes(mbuf, planes)) {
		if (msm_comm_compare_device_planes(mbuf, type, planes)) {
			found = true;
			break;
		}
@@ -6534,7 +6538,8 @@ void handle_release_buffer_reference(struct msm_vidc_inst *inst,
	 */
	found = false;
	list_for_each_entry(temp, &inst->registeredbufs.list, list) {
		if (msm_comm_compare_device_plane(temp, planes, 0)) {
		if (msm_comm_compare_device_plane(temp,
			V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, planes, 0)) {
			mbuf = temp;
			found = true;
			break;
+3 −3
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ u32 get_frame_size_p010(int plane, u32 height, u32 width);
struct vb2_buffer *msm_comm_get_vb_using_vidc_buffer(
		struct msm_vidc_inst *inst, struct msm_vidc_buffer *mbuf);
struct msm_vidc_buffer *msm_comm_get_buffer_using_device_planes(
		struct msm_vidc_inst *inst, u32 *planes);
		struct msm_vidc_inst *inst, u32 type, u32 *planes);
struct msm_vidc_buffer *msm_comm_get_vidc_buffer(struct msm_vidc_inst *inst,
		struct vb2_buffer *vb2);
void msm_comm_put_vidc_buffer(struct msm_vidc_inst *inst,
@@ -205,9 +205,9 @@ bool msm_comm_compare_vb2_plane(struct msm_vidc_inst *inst,
bool msm_comm_compare_vb2_planes(struct msm_vidc_inst *inst,
		struct msm_vidc_buffer *mbuf, struct vb2_buffer *vb2);
bool msm_comm_compare_device_plane(struct msm_vidc_buffer *mbuf,
		u32 *planes, u32 i);
		u32 type, u32 *planes, u32 i);
bool msm_comm_compare_device_planes(struct msm_vidc_buffer *mbuf,
		u32 *planes);
		u32 type, u32 *planes);
int msm_comm_qbuf_cache_operations(struct msm_vidc_inst *inst,
		struct msm_vidc_buffer *mbuf);
int msm_comm_dqbuf_cache_operations(struct msm_vidc_inst *inst,