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

Commit a15f7c7c authored by Dhaval Patel's avatar Dhaval Patel Committed by Matt Wagantall
Browse files

mdss: rotator: move buffer mapping in workqueue from caller context



Rotator driver maps the same buffer twice. First time in caller
context while second time in worker queue. Ideally, it should
map buffer single time in worker queue. Mapping it in caller
context during validation will block the client call and can
cause the delay. Moving it to worker thread fixes double
mapping issue for same buffer.

Change-Id: I17ebe188ace2e54714247fc87277f3da51a64d73
Signed-off-by: default avatarDhaval Patel <pdhaval@codeaurora.org>
parent 5d25ab65
Loading
Loading
Loading
Loading
+61 −71
Original line number Diff line number Diff line
@@ -488,24 +488,78 @@ static int mdss_rotator_import_buffer(struct mdp_layer_buffer *buffer,
	return ret;
}

static int mdss_rotator_acquire_data(struct mdss_rot_entry *entry)
static int mdss_rotator_map_and_check_data(struct mdss_rot_entry *entry)
{
	int ret;
	struct mdp_layer_buffer *input;
	struct mdp_layer_buffer *output;
	struct mdss_mdp_format_params *fmt;
	struct mdss_mdp_plane_sizes ps;
	bool rotation;

	input = &entry->item.input;
	output = &entry->item.output;

	rotation = (entry->item.flags &  MDP_ROTATION_90) ? true : false;

	ret = mdss_iommu_ctrl(1);
	if (IS_ERR_VALUE(ret))
		return ret;

	/* if error during map, the caller will release the data */
	ret = mdss_mdp_data_map(&entry->src_buf, true, DMA_TO_DEVICE);
	if (!ret)
	if (ret) {
		pr_err("source buffer mapping failed ret:%d\n", ret);
		goto end;
	}

	ret = mdss_mdp_data_map(&entry->dst_buf, true, DMA_FROM_DEVICE);
	if (ret) {
		pr_err("destination buffer mapping failed ret:%d\n", ret);
		goto end;
	}

	fmt = mdss_mdp_get_format_params(input->format);
	if (!fmt) {
		pr_err("invalid input format:%d\n", input->format);
		ret = -EINVAL;
		goto end;
	}

	ret = mdss_mdp_get_plane_sizes(
			fmt, input->width, input->height, &ps, 0, rotation);
	if (ret) {
		pr_err("fail to get input plane size ret=%d\n", ret);
		goto end;
	}

	ret = mdss_mdp_data_check(&entry->src_buf, &ps, fmt);
	if (ret) {
		pr_err("fail to check input data ret=%d\n", ret);
		goto end;
	}

	fmt = mdss_mdp_get_format_params(output->format);
	if (!fmt) {
		pr_err("invalid output format:%d\n", output->format);
		ret = -EINVAL;
		goto end;
	}

	ret = mdss_mdp_get_plane_sizes(
			fmt, output->width, output->height, &ps, 0, rotation);
	if (ret) {
		pr_err("fail to get output plane size ret=%d\n", ret);
		goto end;
	}

	ret = mdss_mdp_data_check(&entry->dst_buf, &ps, fmt);
	if (ret) {
		pr_err("fail to check output data ret=%d\n", ret);
		goto end;
	}

end:
	mdss_iommu_ctrl(0);

	return ret;
@@ -539,15 +593,12 @@ static void mdss_rotator_release_data(struct mdss_rot_entry *entry)
	mdss_mdp_data_free(&entry->dst_buf, true, DMA_FROM_DEVICE);
}

static int mdss_rotator_validate_data(struct mdss_rot_mgr *mgr,
static int mdss_rotator_import_data(struct mdss_rot_mgr *mgr,
	struct mdss_rot_entry *entry)
{
	int ret;
	struct mdp_layer_buffer *input;
	struct mdp_layer_buffer *output;
	struct mdss_mdp_format_params *fmt;
	struct mdss_mdp_plane_sizes ps;
	bool rotation;
	u32 flag = 0;

	input = &entry->item.input;
@@ -556,8 +607,6 @@ static int mdss_rotator_validate_data(struct mdss_rot_mgr *mgr,
	if (entry->item.flags & MDP_ROTATION_SECURE)
		flag = MDP_SECURE_OVERLAY_SESSION;

	rotation = (entry->item.flags &  MDP_ROTATION_90) ? true : false;

	ret = mdss_rotator_import_buffer(input, &entry->src_buf, flag,
				&mgr->pdev->dev, true);
	if (ret) {
@@ -576,65 +625,6 @@ static int mdss_rotator_validate_data(struct mdss_rot_mgr *mgr,
		return ret;
	}

	ret = mdss_iommu_ctrl(1);
	if (IS_ERR_VALUE(ret))
		return ret;

	/* if error during map, the caller will release the data */
	ret = mdss_mdp_data_map(&entry->src_buf, true, DMA_TO_DEVICE);
	if (ret) {
		pr_err("fail to map input buffer ret =%d\n", ret);
		goto validate_data_err;
	}

	ret = mdss_mdp_data_map(&entry->dst_buf, true, DMA_FROM_DEVICE);
	if (ret) {
		pr_err("fail to map out buffer ret =%d\n", ret);
		goto validate_data_err;
	}

	fmt = mdss_mdp_get_format_params(input->format);
	if (!fmt) {
		pr_err("invalid input format:%d\n", input->format);
		ret = -EINVAL;
		goto validate_data_err;
	}

	ret = mdss_mdp_get_plane_sizes(
			fmt, input->width, input->height, &ps, 0, rotation);
	if (ret) {
		pr_err("fail to get input plane size ret=%d\n", ret);
		goto validate_data_err;
	}

	ret = mdss_mdp_data_check(&entry->src_buf, &ps, fmt);
	if (ret) {
		pr_err("fail to check input data ret=%d\n", ret);
		goto validate_data_err;
	}

	fmt = mdss_mdp_get_format_params(output->format);
	if (!fmt) {
		pr_err("invalid output format:%d\n", output->format);
		ret = -EINVAL;
		goto validate_data_err;
	}

	ret = mdss_mdp_get_plane_sizes(
			fmt, output->width, output->height, &ps, 0, rotation);
	if (ret) {
		pr_err("fail to get output plane size ret=%d\n", ret);
		goto validate_data_err;
	}

	ret = mdss_mdp_data_check(&entry->dst_buf, &ps, fmt);
	if (ret) {
		pr_err("fail to check output data ret=%d\n", ret);
		goto validate_data_err;
	}

validate_data_err:
	mdss_iommu_ctrl(0);
	return ret;
}

@@ -1327,9 +1317,9 @@ static int mdss_rotator_add_request(struct mdss_rot_mgr *mgr,
			return ret;
		}

		ret = mdss_rotator_validate_data(mgr, entry);
		ret = mdss_rotator_import_data(mgr, entry);
		if (ret) {
			pr_err("fail to validate data\n");
			pr_err("fail to import the data\n");
			return ret;
		}

@@ -1616,7 +1606,7 @@ static int mdss_rotator_handle_entry(struct mdss_rot_hw_resource *hw,
		return ret;
	}

	ret = mdss_rotator_acquire_data(entry);
	ret = mdss_rotator_map_and_check_data(entry);
	if (ret) {
		pr_err("fail to prepare input/output data %d\n", ret);
		return ret;