Răsfoiți Sursa

video: driver: optimise release buffer function

Do not unmap buffers when firmware sends release
done. Only delete these buffers from release list.
Unmap buffers when removing stale entries from
mappings list.
update max dpb count to 32 and host buf count to 128.

Change-Id: I71fc3f722f068d8f2eeeb81041d4e495092c254f
Signed-off-by: Darshana Patil <[email protected]>
Darshana Patil 4 ani în urmă
părinte
comite
d538a9ff99
2 a modificat fișierele cu 21 adăugiri și 40 ștergeri
  1. 5 5
      driver/vidc/inc/msm_vidc_internal.h
  2. 16 35
      driver/vidc/src/msm_vdec.c

+ 5 - 5
driver/vidc/inc/msm_vidc_internal.h

@@ -43,7 +43,7 @@
 #define MAX_CAP_CHILDREN         16
 #define DEFAULT_BITSTREM_ALIGNMENT  16
 #define H265_BITSTREM_ALIGNMENT     32
-#define DEFAULT_MAX_HOST_BUF_COUNT  64
+#define DEFAULT_MAX_HOST_BUF_COUNT  128
 #define DEFAULT_MAX_HOST_BURST_BUF_COUNT 256
 #define BIT_DEPTH_8 (8 << 16 | 8)
 #define BIT_DEPTH_10 (10 << 16 | 10)
@@ -127,15 +127,15 @@
  * which might have many output buffers.
  */
 #define MAX_MAPPED_OUTPUT_COUNT 64
+#define MAX_DPB_COUNT 32
  /*
-  * max dpb count = 16
+  * max dpb count in firmware = 16
   * each dpb: 4 words - <base_address, addr_offset, data_offset>
   * dpb list array size = 16 * 4
   * dpb payload size = 16 * 4 * 4
   */
-#define MAX_DPB_COUNT 64
-#define MAX_DPB_LIST_ARRAY_SIZE (MAX_DPB_COUNT * 4)
-#define MAX_DPB_LIST_PAYLOAD_SIZE (MAX_DPB_COUNT * 4 * 4)
+#define MAX_DPB_LIST_ARRAY_SIZE (16 * 4)
+#define MAX_DPB_LIST_PAYLOAD_SIZE (16 * 4 * 4)
 
 enum msm_vidc_domain_type {
 	MSM_VIDC_ENCODER           = BIT(0),

+ 16 - 35
driver/vidc/src/msm_vdec.c

@@ -1801,7 +1801,7 @@ static int msm_vdec_release_nonref_buffers(struct msm_vidc_inst *inst)
 	list_for_each_entry(rel_buf, &inst->buffers.release.list, list) {
 		/* fw needs RO flag for FTB release buffer */
 		rel_buf->attr |= MSM_VIDC_ATTR_READ_ONLY;
-		print_vidc_buffer(VIDC_HIGH, "high", "release buf", inst, rel_buf);
+		print_vidc_buffer(VIDC_LOW, "low ", "release buf", inst, rel_buf);
 		rc = venus_hfi_release_buffer(inst, rel_buf);
 		if (rc)
 			return rc;
@@ -1814,36 +1814,13 @@ int msm_vdec_handle_release_buffer(struct msm_vidc_inst *inst,
 	struct msm_vidc_buffer *buf)
 {
 	int rc = 0;
-	struct msm_vidc_map *map;
-	bool found;
 
 	if (!inst || !buf) {
 		d_vpr_e("%s: invalid params\n", __func__);
 		return -EINVAL;
 	}
 
-	print_vidc_buffer(VIDC_HIGH, "high", "release done", inst, buf);
-
-	found = false;
-	list_for_each_entry(map, &inst->mappings.output.list, list) {
-		if (map->device_addr == buf->device_addr) {
-			found = true;
-			break;
-		}
-	}
-	if (found) {
-		/*
-		 * finally remove mappings if no one using it.
-		 * refcount will be more than 1 if anyone using it.
-		 */
-		if (map->refcount == 1) {
-			rc = msm_vidc_put_delayed_unmap(inst, map);
-			if (rc)
-				print_vidc_buffer(VIDC_ERR, "err ",
-					"delayed unmap failed", inst, buf);
-		}
-	}
-
+	print_vidc_buffer(VIDC_LOW, "low ", "release done", inst, buf);
 	/* delete the buffer from release list */
 	list_del(&buf->list);
 	msm_vidc_put_vidc_buffer(inst, buf);
@@ -1888,7 +1865,7 @@ static bool is_valid_removable_buffer(struct msm_vidc_inst *inst,
 static int msm_vidc_unmap_excessive_mappings(struct msm_vidc_inst *inst)
 {
 	int rc = 0;
-	struct msm_vidc_map *map;
+	struct msm_vidc_map *map, *temp;
 	u32 refcount_one_bufs_count = 0;
 
 	if (!inst) {
@@ -1911,12 +1888,12 @@ static int msm_vidc_unmap_excessive_mappings(struct msm_vidc_inst *inst)
 		return 0;
 
 	/* unmap these buffers as they are stale entries */
-	list_for_each_entry(map, &inst->mappings.output.list, list) {
+	list_for_each_entry_safe(map, temp, &inst->mappings.output.list, list) {
 		if (is_valid_removable_buffer(inst, map)) {
-			d_vpr_h(
+			i_vpr_l(inst,
 				"%s: type %11s, device_addr %#x, refcount %d, region %d\n",
-				__func__, buf_name(map->type), map->device_addr, map->refcount,
-				map->region);
+				__func__, buf_name(map->type), map->device_addr,
+				map->refcount, map->region);
 			rc = msm_vidc_put_delayed_unmap(inst, map);
 			if (rc)
 				return rc;
@@ -1940,10 +1917,6 @@ int msm_vdec_qbuf(struct msm_vidc_inst *inst, struct vb2_buffer *vb2)
 			if (rc)
 				return rc;
 		}
-
-		rc = msm_vidc_unmap_excessive_mappings(inst);
-		if (rc)
-			return rc;
 	}
 
 	if (vb2->type == OUTPUT_META_PLANE) {
@@ -1963,6 +1936,14 @@ int msm_vdec_qbuf(struct msm_vidc_inst *inst, struct vb2_buffer *vb2)
 		rc = msm_vdec_qbuf_batch(inst, vb2);
 	else
 		rc = msm_vidc_queue_buffer_single(inst, vb2);
+	if (rc)
+		return rc;
+
+	if (vb2->type == OUTPUT_MPLANE) {
+		rc = msm_vidc_unmap_excessive_mappings(inst);
+		if (rc)
+			return rc;
+	}
 
 	return rc;
 }
@@ -2585,4 +2566,4 @@ int msm_vdec_inst_deinit(struct msm_vidc_inst *inst)
 	rc = msm_vidc_ctrl_deinit(inst);
 
 	return rc;
-}
+}