瀏覽代碼

Merge "video: driver: modify unmap excess mappings"

qctecmdr 4 年之前
父節點
當前提交
0287f0d1f4
共有 1 個文件被更改,包括 31 次插入3 次删除
  1. 31 3
      driver/vidc/src/msm_vdec.c

+ 31 - 3
driver/vidc/src/msm_vdec.c

@@ -1851,6 +1851,33 @@ int msm_vdec_handle_release_buffer(struct msm_vidc_inst *inst,
 	return rc;
 }
 
+static bool is_valid_removable_buffer(struct msm_vidc_inst *inst,
+	struct msm_vidc_map *map)
+{
+	bool found = false;
+	struct msm_vidc_buffer *ro_buf;
+
+	if (!inst || !map) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	if (map->refcount != 1)
+		return false;
+
+	list_for_each_entry(ro_buf, &inst->buffers.read_only.list, list) {
+		if (map->device_addr == ro_buf->device_addr) {
+			found = true;
+			break;
+		}
+	}
+
+	if (!found)
+		return true;
+
+	return false;
+}
+
 static int msm_vidc_unmap_excessive_mappings(struct msm_vidc_inst *inst)
 {
 	int rc = 0;
@@ -1863,12 +1890,13 @@ static int msm_vidc_unmap_excessive_mappings(struct msm_vidc_inst *inst)
 	}
 
 	/*
-	 * count entries from map list whose refcount is 1
+	 * count entries from map list which are not present in
+	 * read_only buffers list and whose refcount is 1.
 	 * these are excess mappings present due to delayed
 	 * unmap feature.
 	 */
 	list_for_each_entry(map, &inst->mappings.output.list, list) {
-		if (map->refcount == 1)
+		if (is_valid_removable_buffer(inst, map))
 			refcount_one_bufs_count++;
 	}
 
@@ -1877,7 +1905,7 @@ static int msm_vidc_unmap_excessive_mappings(struct msm_vidc_inst *inst)
 
 	/* unmap these buffers as they are stale entries */
 	list_for_each_entry(map, &inst->mappings.output.list, list) {
-		if (map->refcount == 1) {
+		if (is_valid_removable_buffer(inst, map)) {
 			d_vpr_h(
 				"%s: type %11s, device_addr %#x, refcount %d, region %d\n",
 				__func__, buf_name(map->type), map->device_addr, map->refcount,