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

Commit 13c3ec01 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: mdss: Change IOMMU map sequence during splash cleanup"

parents 3f964e47 0e84af49
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
/* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -62,6 +62,9 @@
#define XIN_WRITEBACK	1
#define MAX_XIN		2

#define MDSS_MDP_HW_REV_320	0x30020000  /* sdm660 */
#define MDSS_MDP_HW_REV_330	0x30030000  /* sdm630 */

struct sde_mult_factor {
	uint32_t numer;
	uint32_t denom;
@@ -277,7 +280,9 @@ struct sde_rot_data_type {

	int iommu_attached;
	int iommu_ref_cnt;

	int (*iommu_ctrl)(int enable);
	int (*secure_session_ctrl)(int enable);
	int (*wait_for_transition)(int state, int request);
	struct sde_rot_vbif_debug_bus *nrt_vbif_dbg_bus;
	u32 nrt_vbif_dbg_bus_size;
	struct sde_rot_debug_bus *rot_dbg_bus;
@@ -295,6 +300,7 @@ struct sde_rot_data_type {
	struct sde_rot_lut_cfg inline_lut_cfg[SDE_ROT_OP_MAX];

	bool clk_always_on;
	bool callback_request;
};

int sde_rotator_base_init(struct sde_rot_data_type **pmdata,
+35 −2
Original line number Diff line number Diff line
/* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -581,7 +581,7 @@ static int sde_rotator_import_buffer(struct sde_layer_buffer *buffer,
	return ret;
}

static int sde_rotator_secure_session_ctrl(bool enable)
static int _sde_rotator_secure_session_ctrl(bool enable)
{
	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
	uint32_t *sid_info = NULL;
@@ -672,6 +672,39 @@ static int sde_rotator_secure_session_ctrl(bool enable)
	return resp;
}

static int sde_rotator_secure_session_ctrl(bool enable)
{
	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
	int ret = -EINVAL;

	/*
	 * wait_for_transition and secure_session_control are filled by client
	 * callback.
	 */
	if (mdata->wait_for_transition && mdata->secure_session_ctrl &&
		mdata->callback_request) {
		ret = mdata->wait_for_transition(mdata->sec_cam_en, enable);
		if (ret) {
			SDEROT_ERR("failed Secure wait for transition %d\n",
				   ret);
		} else {
			if (mdata->sec_cam_en ^ enable) {
				mdata->sec_cam_en = enable;
				ret = mdata->secure_session_ctrl(enable);
				if (ret)
					mdata->sec_cam_en = 0;
			}
		}
	} else if (!mdata->callback_request) {
		ret = _sde_rotator_secure_session_ctrl(enable);
	}

	if (ret)
		SDEROT_ERR("failed %d sde_rotator_secure_session %d\n",
			   ret, mdata->callback_request);

	return ret;
}

static int sde_rotator_map_and_check_data(struct sde_rot_entry *entry)
{
+61 −6
Original line number Diff line number Diff line
/* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -51,6 +51,15 @@ struct sde_smmu_domain {
	unsigned long size;
};

int sde_smmu_set_dma_direction(int dir)
{
	struct sde_rot_data_type *mdata = sde_rot_get_mdata();

	return ((mdata->mdss_version == MDSS_MDP_HW_REV_320) ||
	(mdata->mdss_version == MDSS_MDP_HW_REV_330)) ?
		DMA_BIDIRECTIONAL : dir;
}

static inline bool sde_smmu_is_valid_domain_type(
		struct sde_rot_data_type *mdata, int domain_type)
{
@@ -342,8 +351,8 @@ int sde_smmu_map_dma_buf(struct dma_buf *dma_buf,
		return -EINVAL;
	}

	rc = dma_map_sg_attrs(sde_smmu->dev, table->sgl, table->nents, dir,
			attrs);
	rc = dma_map_sg_attrs(sde_smmu->dev, table->sgl, table->nents,
		sde_smmu_set_dma_direction(dir), attrs);
	if (!rc) {
		SDEROT_ERR("dma map sg failed\n");
		return -ENOMEM;
@@ -364,12 +373,45 @@ void sde_smmu_unmap_dma_buf(struct sg_table *table, int domain,
		return;
	}

	dma_unmap_sg(sde_smmu->dev, table->sgl, table->nents, dir);
	dma_unmap_sg(sde_smmu->dev, table->sgl, table->nents,
		sde_smmu_set_dma_direction(dir));
}

static DEFINE_MUTEX(sde_smmu_ref_cnt_lock);

static void sde_smmu_callback(struct mdss_smmu_intf *smmu)
{
	struct sde_rot_data_type *mdata = sde_rot_get_mdata();

	if (!smmu)
		return;

	/* Copy mmu device info into sde private structure */
	mdata->iommu_ctrl = smmu->iommu_ctrl;
	mdata->wait_for_transition = smmu->wait_for_transition;
	mdata->secure_session_ctrl = smmu->secure_session_ctrl;
	if (smmu->is_secure) {
		mdata->sde_smmu[SDE_IOMMU_DOMAIN_ROT_SECURE].dev = smmu->dev;
		mdata->sde_smmu[SDE_IOMMU_DOMAIN_ROT_SECURE].domain =
			SDE_IOMMU_DOMAIN_ROT_SECURE;
	} else {
		mdata->sde_smmu[SDE_IOMMU_DOMAIN_ROT_UNSECURE].dev = smmu->dev;
		mdata->sde_smmu[SDE_IOMMU_DOMAIN_ROT_UNSECURE].domain =
			SDE_IOMMU_DOMAIN_ROT_UNSECURE;
	}

	SDEROT_INFO("%s registered domain: %d\n", __func__, smmu->is_secure);
}

int sde_smmu_ctrl(int enable)
{
	struct sde_rot_data_type *mdata = sde_rot_get_mdata();

	return ((mdata->iommu_ctrl) ?
		mdata->iommu_ctrl(enable) : -EINVAL);
}

static int _sde_smmu_ctrl(int enable)
{
	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
	int rc = 0;
@@ -448,13 +490,24 @@ int sde_smmu_secure_ctrl(int enable)
void sde_smmu_device_create(struct device *dev)
{
	struct device_node *parent, *child;
	struct sde_rot_data_type *mdata = sde_rot_get_mdata();
	bool child_rot_sec = false;
	bool child_rot_nsec = false;

	parent = dev->of_node;
	for_each_child_of_node(parent, child) {
		if (of_device_is_compatible(child, SMMU_SDE_ROT_SEC))
		if (of_device_is_compatible(child, SMMU_SDE_ROT_SEC)) {
			of_platform_device_create(child, NULL, dev);
		else if (of_device_is_compatible(child, SMMU_SDE_ROT_UNSEC))
			child_rot_sec = true;
		} else if (of_device_is_compatible(child, SMMU_SDE_ROT_UNSEC)) {
			of_platform_device_create(child, NULL, dev);
			child_rot_nsec = true;
		}
	}

	if (!child_rot_sec || !child_rot_nsec) {
		mdss_smmu_request_mappings(sde_smmu_callback);
		mdata->callback_request = true;
	}
}

@@ -660,6 +713,8 @@ int sde_smmu_probe(struct platform_device *pdev)
	sde_smmu_enable_power(sde_smmu, false);

	sde_smmu->dev = dev;
	mdata->iommu_ctrl = _sde_smmu_ctrl;

	SDEROT_INFO(
		"iommu v2 domain[%d] mapping and clk register successful!\n",
			smmu_domain.domain);
+3 −6
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2017,2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -17,6 +17,7 @@
#include <linux/types.h>
#include <linux/device.h>
#include <linux/dma-buf.h>
#include <linux/mdss_smmu_ext.h>

#include "sde_rotator_io_util.h"

@@ -28,11 +29,6 @@ enum sde_iommu_domain_type {

int sde_smmu_init(struct device *dev);

static inline int sde_smmu_dma_data_direction(int dir)
{
	return dir;
}

int sde_smmu_ctrl(int enable);

struct dma_buf_attachment *sde_smmu_dma_buf_attach(
@@ -47,4 +43,5 @@ void sde_smmu_unmap_dma_buf(struct sg_table *table, int domain,

int sde_smmu_secure_ctrl(int enable);

int sde_smmu_set_dma_direction(int dir);
#endif /* SDE_ROTATOR_SMMU_H */
+7 −4
Original line number Diff line number Diff line
/* Copyright (c) 2012, 2015-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012, 2015-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -806,7 +806,8 @@ static int sde_mdp_put_img(struct sde_mdp_img_data *data, bool rotator,
			data->srcp_attachment->dma_map_attrs |=
				DMA_ATTR_DELAYED_UNMAP;
			dma_buf_unmap_attachment(data->srcp_attachment,
				data->srcp_table, dir);
				data->srcp_table,
				sde_smmu_set_dma_direction(dir));
			dma_buf_detach(data->srcp_dma_buf,
					data->srcp_attachment);
			if (!(data->flags & SDE_ROT_EXT_DMA_BUF)) {
@@ -927,7 +928,8 @@ static int sde_mdp_map_buffer(struct sde_mdp_img_data *data, bool rotator,
		}

		sgt = dma_buf_map_attachment(
				data->srcp_attachment, dir);
				data->srcp_attachment,
				sde_smmu_set_dma_direction(dir));
		if (IS_ERR_OR_NULL(sgt) ||
				IS_ERR_OR_NULL(sgt->sgl)) {
			SDEROT_ERR("Failed to map attachment\n");
@@ -991,7 +993,8 @@ static int sde_mdp_map_buffer(struct sde_mdp_img_data *data, bool rotator,
	return ret;

err_unmap:
	dma_buf_unmap_attachment(data->srcp_attachment, data->srcp_table, dir);
	dma_buf_unmap_attachment(data->srcp_attachment, data->srcp_table,
			sde_smmu_set_dma_direction(dir));
err_detach:
	dma_buf_detach(data->srcp_dma_buf, data->srcp_attachment);
	if (!(data->flags & SDE_ROT_EXT_DMA_BUF)) {
Loading