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

Commit 24b7c36c authored by Clarence Ip's avatar Clarence Ip
Browse files

drm/msm: handle gem bo flags during dma buffer mapping



This patch adds a new MSM_BO_KEEPATTRS flag on the internal
msm gem object structure and propagates it to the msm_gem
module's map_dma_buf callback. This allows gem objects to
be created that specify the DMA_ATTR_IOMMU_USE_UPSTREAM_HINT
attribute during buffer mappings.

CRs-Fixed: 2048692
Change-Id: I0f38fae9e5e83846a64f47f9c5b0954dbc11b4e4
Signed-off-by: default avatarClarence Ip <cip@codeaurora.org>
parent 618de0ab
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -341,7 +341,8 @@ int msm_gem_get_iova_locked(struct drm_gem_object *obj, int id,
			if (obj->import_attach && mmu->funcs->map_dma_buf) {
				ret = mmu->funcs->map_dma_buf(mmu, msm_obj->sgt,
						obj->import_attach->dmabuf,
						DMA_BIDIRECTIONAL);
						DMA_BIDIRECTIONAL,
						msm_obj->flags);
				if (ret) {
					DRM_ERROR("Unable to map dma buf\n");
					return ret;
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

/* Additional internal-use only BO flags: */
#define MSM_BO_STOLEN        0x10000000    /* try to use stolen/splash memory */
#define MSM_BO_KEEPATTRS     0x20000000     /* keep h/w bus attributes */

struct msm_gem_object {
	struct drm_gem_object base;
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ struct msm_mmu_funcs {
	void (*unmap_sg)(struct msm_mmu *mmu, struct sg_table *sgt,
		enum dma_data_direction dir);
	int (*map_dma_buf)(struct msm_mmu *mmu, struct sg_table *sgt,
			struct dma_buf *dma_buf, int dir);
			struct dma_buf *dma_buf, int dir, u32 flags);
	void (*unmap_dma_buf)(struct msm_mmu *mmu, struct sg_table *sgt,
			struct dma_buf *dma_buf, int dir);
	void (*destroy)(struct msm_mmu *mmu);
+8 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <soc/qcom/secure_buffer.h>

#include "msm_drv.h"
#include "msm_gem.h"
#include "msm_mmu.h"

#ifndef SZ_4G
@@ -220,14 +221,18 @@ static void msm_smmu_destroy(struct msm_mmu *mmu)
}

static int msm_smmu_map_dma_buf(struct msm_mmu *mmu, struct sg_table *sgt,
			struct dma_buf *dma_buf, int dir)
			struct dma_buf *dma_buf, int dir, u32 flags)
{
	struct msm_smmu *smmu = to_msm_smmu(mmu);
	struct msm_smmu_client *client = msm_smmu_to_client(smmu);
	unsigned long attrs = 0x0;
	int ret;

	ret = msm_dma_map_sg_lazy(client->dev, sgt->sgl, sgt->nents, dir,
			dma_buf);
	if (flags & MSM_BO_KEEPATTRS)
		attrs |= DMA_ATTR_IOMMU_USE_UPSTREAM_HINT;

	ret = msm_dma_map_sg_attrs(client->dev, sgt->sgl, sgt->nents, dir,
			dma_buf, attrs);
	if (ret != sgt->nents) {
		DRM_ERROR("dma map sg failed\n");
		return -ENOMEM;