Skip to contentSkip to conversation

drm/msm: support for host-cached BOs

PATCH RESEND In review Jonathan Marek 4 participants 20 messages Nov 14, 2020 – Nov 29, 2020

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v2 cover drm/msm: support for host-cached BOs

v2:
- added patches 2/3 to enable using dma_ops_bypass
- changed DRM_MSM_GEM_SYNC_CACHE patch to use dma_sync_sg_for_device() and dma_sync_sg_for_cpu(), and renamed sync flags.

Not sure I did the right thing with for the dma_ops_bypass part, this is what I came up with reading the emails.

Jonathan Marek (5):
drm/msm: add MSM_BO_CACHED_COHERENT
dma-direct: add dma_direct_bypass() to force direct ops drm/msm: call dma_direct_bypass()
drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance drm/msm: bump up the uapi version

 drivers/gpu/drm/msm/Kconfig                |  1 +
 drivers/gpu/drm/msm/adreno/adreno_device.c |  1 +
 drivers/gpu/drm/msm/msm_drv.c              | 32 +++++++++++++++++++---
 drivers/gpu/drm/msm/msm_drv.h              |  3 ++
 drivers/gpu/drm/msm/msm_gem.c              | 31 +++++++++++++++++++++
 include/linux/dma-direct.h                 |  9 ++++++
 include/uapi/drm/msm_drm.h                 | 25 +++++++++++++++--
 kernel/dma/direct.c                        | 23 ++++++++++++++++
 8 files changed, 118 insertions(+), 7 deletions(-)
Signature · 1 line
2.26.1
#1 lore raw

PATCH RESEND v2 1/5 drm/msm: add MSM_BO_CACHED_COHERENT

Add a new cache mode for creating coherent host-cached BOs.

---
 drivers/gpu/drm/msm/adreno/adreno_device.c | 1 +
 drivers/gpu/drm/msm/msm_drv.h              | 1 +
 drivers/gpu/drm/msm/msm_gem.c              | 8 ++++++++
 include/uapi/drm/msm_drm.h                 | 5 ++---
 4 files changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +1 -0
index 58e03b20e1c7..21c9bc954f38 100644
@@ -410,6 +410,7 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)
 		config.rev.minor, config.rev.patchid);
 
 	priv->is_a2xx = config.rev.core == 2;
+	priv->has_cached_coherent = config.rev.core >= 6;
 
 	gpu = info->init(drm);
 	if (IS_ERR(gpu)) {
drivers/gpu/drm/msm/msm_drv.h +1 -0
index f33281ac7913..22ebecb28349 100644
@@ -168,6 +168,7 @@ struct msm_drm_private {
 	struct msm_file_private *lastctx;
 	/* gpu is only set on open(), but we need this info earlier */
 	bool is_a2xx;
+	bool has_cached_coherent;
 
 	struct drm_fb_helper *fbdev;
 
drivers/gpu/drm/msm/msm_gem.c +8 -0
index 04be4cfcccc1..3d8254b5de16 100644
@@ -420,6 +420,9 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj,
 	if (msm_obj->flags & MSM_BO_MAP_PRIV)
 		prot |= IOMMU_PRIV;
 
+	if (msm_obj->flags & MSM_BO_CACHED_COHERENT)
+		prot |= IOMMU_CACHE;
+
 	WARN_ON(!mutex_is_locked(&msm_obj->lock));
 
 	if (WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED))
@@ -1004,6 +1007,7 @@ static int msm_gem_new_impl(struct drm_device *dev,
 		uint32_t size, uint32_t flags,
 		struct drm_gem_object **obj)
 {
+	struct msm_drm_private *priv = dev->dev_private;
 	struct msm_gem_object *msm_obj;
 
 	switch (flags & MSM_BO_CACHE_MASK) {
@@ -1011,6 +1015,10 @@ static int msm_gem_new_impl(struct drm_device *dev,
 	case MSM_BO_CACHED:
 	case MSM_BO_WC:
 		break;
+	case MSM_BO_CACHED_COHERENT:
+		if (priv->has_cached_coherent)
+			break;
+		/* fallthrough */
 	default:
 		DRM_DEV_ERROR(dev->dev, "invalid cache flag: %x\n",
 				(flags & MSM_BO_CACHE_MASK));
include/uapi/drm/msm_drm.h +2 -3
index a6c1f3eb2623..474497e8743a 100644
@@ -94,12 +94,11 @@ struct drm_msm_param {
 #define MSM_BO_CACHED        0x00010000
 #define MSM_BO_WC            0x00020000
 #define MSM_BO_UNCACHED      0x00040000
+#define MSM_BO_CACHED_COHERENT 0x080000
 
 #define MSM_BO_FLAGS         (MSM_BO_SCANOUT | \
                               MSM_BO_GPU_READONLY | \
-                              MSM_BO_CACHED | \
-                              MSM_BO_WC | \
-                              MSM_BO_UNCACHED)
+                              MSM_BO_CACHE_MASK)
 
 struct drm_msm_gem_new {
 	__u64 size;           /* in */
Signature · 1 line
2.26.1
#2 lore raw

PATCH RESEND v2 2/5 dma-direct: add dma_direct_bypass() to force direct ops

In reply to Jonathan Marek

Add a function to force direct ops and disable swiotlb for a deivce.

---
 include/linux/dma-direct.h |  9 +++++++++
 kernel/dma/direct.c        | 23 +++++++++++++++++++++++
 2 files changed, 32 insertions(+)
include/linux/dma-direct.h +9 -0
index 18aade195884..41f57e1b7aa5 100644
@@ -124,4 +124,13 @@ int dma_direct_supported(struct device *dev, u64 mask);
 dma_addr_t dma_direct_map_resource(struct device *dev, phys_addr_t paddr,
 		size_t size, enum dma_data_direction dir, unsigned long attrs);
 
+#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED)
+int dma_direct_bypass(struct device *dev);
+#else
+static inline int dma_direct_bypass(struct device *dev)
+{
+	return -EIO;
+}
+#endif
+
 #endif /* _LINUX_DMA_DIRECT_H */
kernel/dma/direct.c +23 -0
index 06c111544f61..304a5a77cccb 100644
@@ -548,3 +548,26 @@ int dma_direct_set_offset(struct device *dev, phys_addr_t cpu_start,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(dma_direct_set_offset);
+
+/**
+ * dma_direct_bypass - always use direct mapping path for device
+ * @dev:	device pointer
+ *
+ * Note: this also bypasses swiotlb. Not available for arch with
+ * force_dma_unencrypted(), since this doesn't deal with that.
+ */
+#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED)
+int dma_direct_bypass(struct device *dev)
+{
+	int ret;
+
+	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
+	if (ret)
+		return ret;
+
+	dev->bus_dma_limit = DMA_BIT_MASK(64);
+	dev->dma_ops_bypass = true;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(dma_direct_bypass);
+#endif
Signature · 1 line
2.26.1
#3 lore raw

Re: [RESEND PATCH v2 2/5] dma-direct: add dma_direct_bypass() to force direct ops

Quoted 1 line · Jonathan Marek

Add a function to force direct ops and disable swiotlb for a deivce.

s/deivce/device/

Quoted 1 line

+#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED)

overly long line.

Quoted 1 line

+#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED)

Again.

kernel/dma/direct.c int dma_direct_set_offset(struct device *dev, phys_addr_t cpu_start, · line 572

Quoted 13 lines
kernel/dma/direct.c +13 -0
+int dma_direct_bypass(struct device *dev)
+{
+	int ret;
+
+	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
+	if (ret)
+		return ret;
+
+	dev->bus_dma_limit = DMA_BIT_MASK(64);
+	dev->dma_ops_bypass = true;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(dma_direct_bypass);

But more importantly ARCH_HAS_FORCE_DMA_UNENCRYPTED is just a compile time flag. With this you disable the functionality for all the usual x86, s390 and powerpc configs, while only a tiny number of systems for bounce buffering. But I think you can just trivialy check force_dma_unencrypted instead. We do not need an extra Kconfig symbol symbol for this trivial helper.

Also the helper is misnamed and misplaced. The semantics have nothing to do with dma-direct, the fact that is uses the ops bypass is an
implementation detail. It really fits into the iommu code, as it
allows the driver to use the IOMMU API for IOVA management, while using the DMA API for cache management. So it should be named to reflect that, and also grow a kerneldoc comment explaining how it will be used.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#4 lore raw

PATCH RESEND v2 3/5 drm/msm: call dma_direct_bypass()

In reply to Jonathan Marek

Always use direct dma ops and no swiotlb.

Note: arm-smmu-qcom already avoids creating iommu dma ops, but not everything uses arm-smmu-qcom and this also sets the dma mask.

---
 drivers/gpu/drm/msm/Kconfig   | 1 +
 drivers/gpu/drm/msm/msm_drv.c | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/Kconfig +1 -0
index e5816b498494..07c50405970a 100644
@@ -20,6 +20,7 @@ config DRM_MSM
 	select SND_SOC_HDMI_CODEC if SND_SOC
 	select SYNC_FILE
 	select PM_OPP
+	select DMA_OPS_BYPASS
 	help
 	  DRM/KMS driver for MSM/snapdragon.
 
drivers/gpu/drm/msm/msm_drv.c +5 -3
index 49685571dc0e..bae48afca82e 100644
@@ -6,6 +6,7 @@
  */
 
 #include <linux/dma-mapping.h>
+#include <linux/dma-direct.h>
 #include <linux/kthread.h>
 #include <linux/uaccess.h>
 #include <uapi/linux/sched/types.h>
@@ -1288,10 +1289,11 @@ static int msm_pdev_probe(struct platform_device *pdev)
 	if (ret)
 		goto fail;
 
-	/* on all devices that I am aware of, iommu's which can map
-	 * any address the cpu can see are used:
+	/* always use direct dma ops and no swiotlb
+	 * note: arm-smmu-qcom already avoids creating iommu dma ops, but
+	 * not everything uses arm-smmu-qcom and this also sets the dma mask
 	 */
-	ret = dma_set_mask_and_coherent(&pdev->dev, ~0);
+	ret = dma_direct_bypass(&pdev->dev);
 	if (ret)
 		goto fail;
 
Signature · 1 line
2.26.1
#5 lore raw

Re: [RESEND PATCH v2 3/5] drm/msm: call dma_direct_bypass()

Quoted 36 lines · Jonathan Marek

Always use direct dma ops and no swiotlb.

Note: arm-smmu-qcom already avoids creating iommu dma ops, but not everything uses arm-smmu-qcom and this also sets the dma mask.

---
 drivers/gpu/drm/msm/Kconfig   | 1 +
 drivers/gpu/drm/msm/msm_drv.c | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/Kconfig +1 -0
index e5816b498494..07c50405970a 100644
@@ -20,6 +20,7 @@ config DRM_MSM
 	select SND_SOC_HDMI_CODEC if SND_SOC
 	select SYNC_FILE
 	select PM_OPP
+	select DMA_OPS_BYPASS
 	help
 	  DRM/KMS driver for MSM/snapdragon.
 
drivers/gpu/drm/msm/msm_drv.c +1 -0
index 49685571dc0e..bae48afca82e 100644
@@ -6,6 +6,7 @@
  */
 
 #include <linux/dma-mapping.h>
+#include <linux/dma-direct.h>
 #include <linux/kthread.h>
 #include <linux/uaccess.h>
 #include <uapi/linux/sched/types.h>

drivers/gpu/drm/msm/msm_drv.c static int msm_pdev_probe(struct platform_device *pdev) · line 1292

Quoted 6 lines
drivers/gpu/drm/msm/msm_drv.c +1 -2
@@ -1288,10 +1289,11 @@ static int msm_pdev_probe(struct platform_device *pdev)
 	if (ret)
 		goto fail;
 
-	/* on all devices that I am aware of, iommu's which can map
-	 * any address the cpu can see are used:
+	/* always use direct dma ops and no swiotlb

Again, and implementation detail. Comments should not explain details obvious from the code (especially layers away) but the intent.

#6 lore raw

PATCH RESEND v2 4/5 drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

In reply to Jonathan Marek

This makes it possible to use the non-coherent cached MSM_BO_CACHED mode, which otherwise doesn't provide any method for cleaning/invalidating the cache to sync with the device.

---
 drivers/gpu/drm/msm/msm_drv.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/msm/msm_drv.h |  2 ++
 drivers/gpu/drm/msm/msm_gem.c | 23 +++++++++++++++++++++++
 include/uapi/drm/msm_drm.h    | 20 ++++++++++++++++++++
 4 files changed, 66 insertions(+)
drivers/gpu/drm/msm/msm_drv.c +21 -0
index bae48afca82e..3f17acdf6594 100644
@@ -959,6 +959,26 @@ static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data,
 	return msm_submitqueue_remove(file->driver_priv, id);
 }
 
+static int msm_ioctl_gem_sync_cache(struct drm_device *dev, void *data,
+		struct drm_file *file)
+{
+	struct drm_msm_gem_sync_cache *args = data;
+	struct drm_gem_object *obj;
+
+	if (args->flags & ~MSM_GEM_SYNC_CACHE_FLAGS)
+		return -EINVAL;
+
+	obj = drm_gem_object_lookup(file, args->handle);
+	if (!obj)
+		return -ENOENT;
+
+	msm_gem_sync_cache(obj, args->flags, args->offset, args->end);
+
+	drm_gem_object_put(obj);
+
+	return 0;
+}
+
 static const struct drm_ioctl_desc msm_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(MSM_GET_PARAM,    msm_ioctl_get_param,    DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(MSM_GEM_NEW,      msm_ioctl_gem_new,      DRM_RENDER_ALLOW),
@@ -971,6 +991,7 @@ static const struct drm_ioctl_desc msm_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_NEW,   msm_ioctl_submitqueue_new,   DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_CLOSE, msm_ioctl_submitqueue_close, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(MSM_GEM_SYNC_CACHE,    msm_ioctl_gem_sync_cache,    DRM_RENDER_ALLOW),
 };
 
 static const struct vm_operations_struct vm_ops = {
drivers/gpu/drm/msm/msm_drv.h +2 -0
index 22ebecb28349..f170f843010e 100644
@@ -318,6 +318,8 @@ void msm_gem_active_get(struct drm_gem_object *obj, struct msm_gpu *gpu);
 void msm_gem_active_put(struct drm_gem_object *obj);
 int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout);
 int msm_gem_cpu_fini(struct drm_gem_object *obj);
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+		size_t range_start, size_t range_end);
 void msm_gem_free_object(struct drm_gem_object *obj);
 int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
 		uint32_t size, uint32_t flags, uint32_t *handle, char *name);
drivers/gpu/drm/msm/msm_gem.c +23 -0
index 3d8254b5de16..039738696f9a 100644
@@ -797,6 +797,29 @@ int msm_gem_cpu_fini(struct drm_gem_object *obj)
 	return 0;
 }
 
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+		size_t range_start, size_t range_end)
+{
+	struct msm_gem_object *msm_obj = to_msm_bo(obj);
+	struct device *dev = msm_obj->base.dev->dev;
+
+	/* exit early if get_pages() hasn't been called yet */
+	if (!msm_obj->pages)
+		return;
+
+	/* TODO: sync only the specified range */
+
+	if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+		dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+				msm_obj->sgt->nents, DMA_TO_DEVICE);
+	}
+
+	if (flags & MSM_GEM_SYNC_FOR_CPU) {
+		dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+				msm_obj->sgt->nents, DMA_FROM_DEVICE);
+	}
+}
+
 #ifdef CONFIG_DEBUG_FS
 static void describe_fence(struct dma_fence *fence, const char *type,
 		struct seq_file *m)
include/uapi/drm/msm_drm.h +20 -0
index 474497e8743a..c8288f328528 100644
@@ -319,6 +319,24 @@ struct drm_msm_submitqueue_query {
 	__u32 pad;
 };
 
+/*
+ * Host cache maintenance (relevant for MSM_BO_CACHED)
+ * driver may both clean/invalidate (flush) for clean
+ */
+
+#define MSM_GEM_SYNC_FOR_DEVICE		0x1
+#define MSM_GEM_SYNC_FOR_CPU		0x2
+
+#define MSM_GEM_SYNC_CACHE_FLAGS	(MSM_GEM_SYNC_FOR_DEVICE | \
+					 MSM_GEM_SYNC_FOR_CPU)
+
+struct drm_msm_gem_sync_cache {
+	__u32 handle;
+	__u32 flags;
+	__u64 offset;
+	__u64 end;      /* offset + size */
+};
+
 #define DRM_MSM_GET_PARAM              0x00
 /* placeholder:
 #define DRM_MSM_SET_PARAM              0x01
@@ -336,6 +354,7 @@ struct drm_msm_submitqueue_query {
 #define DRM_MSM_SUBMITQUEUE_NEW        0x0A
 #define DRM_MSM_SUBMITQUEUE_CLOSE      0x0B
 #define DRM_MSM_SUBMITQUEUE_QUERY      0x0C
+#define DRM_MSM_GEM_SYNC_CACHE         0x0D
 
 #define DRM_IOCTL_MSM_GET_PARAM        DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
 #define DRM_IOCTL_MSM_GEM_NEW          DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
@@ -348,6 +367,7 @@ struct drm_msm_submitqueue_query {
 #define DRM_IOCTL_MSM_SUBMITQUEUE_NEW    DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_NEW, struct drm_msm_submitqueue)
 #define DRM_IOCTL_MSM_SUBMITQUEUE_CLOSE  DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_CLOSE, __u32)
 #define DRM_IOCTL_MSM_SUBMITQUEUE_QUERY  DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_QUERY, struct drm_msm_submitqueue_query)
+#define DRM_IOCTL_MSM_GEM_SYNC_CACHE     DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_SYNC_CACHE, struct drm_msm_gem_sync_cache)
 
 #if defined(__cplusplus)
 }
Signature · 1 line
2.26.1
#7 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

Quoted 11 lines · Jonathan Marek
drivers/gpu/drm/msm/msm_gem.c +11 -0
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+		size_t range_start, size_t range_end)
+{
+	struct msm_gem_object *msm_obj = to_msm_bo(obj);
+	struct device *dev = msm_obj->base.dev->dev;
+
+	/* exit early if get_pages() hasn't been called yet */
+	if (!msm_obj->pages)
+		return;
+
+	/* TODO: sync only the specified range */

drivers/gpu/drm/msm/msm_gem.c int msm_gem_cpu_fini(struct drm_gem_object *obj) · line 820

Quoted 10 lines
drivers/gpu/drm/msm/msm_gem.c +10 -0
+
+	if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+		dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+				msm_obj->sgt->nents, DMA_TO_DEVICE);
+	}
+
+	if (flags & MSM_GEM_SYNC_FOR_CPU) {
+		dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+				msm_obj->sgt->nents, DMA_FROM_DEVICE);
+	}

Splitting this helper from the only caller is rather strange, epecially with the two unused arguments. And I think the way this is specified to take a range, but ignoring it is actively dangerous. User space will rely on it syncing everything sooner or later and then you are stuck. So just define a sync all primitive for now, and if you really need a range sync and have actually implemented it add a new ioctl for that.

#8 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

Quoted 22 lines · Christoph Hellwig
Quoted 20 lines · Jonathan Marek
drivers/gpu/drm/msm/msm_gem.c +20 -0
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+             size_t range_start, size_t range_end)
+{
+     struct msm_gem_object *msm_obj = to_msm_bo(obj);
+     struct device *dev = msm_obj->base.dev->dev;
+
+     /* exit early if get_pages() hasn't been called yet */
+     if (!msm_obj->pages)
+             return;
+
+     /* TODO: sync only the specified range */
+
+     if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+             dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_TO_DEVICE);
+     }
+
+     if (flags & MSM_GEM_SYNC_FOR_CPU) {
+             dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_FROM_DEVICE);
Quoted 8 lines
Quoted 1 line

+ }

Splitting this helper from the only caller is rather strange, epecially with the two unused arguments. And I think the way this is specified to take a range, but ignoring it is actively dangerous. User space will rely on it syncing everything sooner or later and then you are stuck. So just define a sync all primitive for now, and if you really need a range sync and have actually implemented it add a new ioctl for that.

We do already have a split of ioctl "layer" which enforces valid ioctl params, etc, and gem (or other) module code which is called by the ioctl func. So I think it is fine to keep this split here. (Also, I think at some point there will be a uring type of ioctl alternative which would re-use the same gem func.)

But I do agree that the range should be respected or added later.. drm_ioctl() dispatch is well prepared for extending ioctls.

And I assume there should be some validation that the range is aligned to cache-line? Or can we flush a partial cache line?

BR,
-R
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

Quoted 38 lines · Rob Clark
Quoted 22 lines · Christoph Hellwig
Quoted 20 lines · Jonathan Marek
drivers/gpu/drm/msm/msm_gem.c +20 -0
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+             size_t range_start, size_t range_end)
+{
+     struct msm_gem_object *msm_obj = to_msm_bo(obj);
+     struct device *dev = msm_obj->base.dev->dev;
+
+     /* exit early if get_pages() hasn't been called yet */
+     if (!msm_obj->pages)
+             return;
+
+     /* TODO: sync only the specified range */
+
+     if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+             dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_TO_DEVICE);
+     }
+
+     if (flags & MSM_GEM_SYNC_FOR_CPU) {
+             dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_FROM_DEVICE);
Quoted 8 lines
Quoted 1 line

+ }

Splitting this helper from the only caller is rather strange, epecially with the two unused arguments. And I think the way this is specified to take a range, but ignoring it is actively dangerous. User space will rely on it syncing everything sooner or later and then you are stuck. So just define a sync all primitive for now, and if you really need a range sync and have actually implemented it add a new ioctl for that.

We do already have a split of ioctl "layer" which enforces valid ioctl params, etc, and gem (or other) module code which is called by the ioctl func. So I think it is fine to keep this split here. (Also, I think at some point there will be a uring type of ioctl alternative which would re-use the same gem func.)

Quoted 6 lines

But I do agree that the range should be respected or added later.. drm_ioctl() dispatch is well prepared for extending ioctls.

And I assume there should be some validation that the range is aligned to cache-line? Or can we flush a partial cache line?

The range is intended to be "sync at least this range", so that userspace doesn't have to worry about details like that.

Quoted 3 lines

BR,
-R

#10 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

Quoted 43 lines · Jonathan Marek
Quoted 41 lines · Rob Clark
Quoted 22 lines · Christoph Hellwig
Quoted 20 lines · Jonathan Marek
drivers/gpu/drm/msm/msm_gem.c +20 -0
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+             size_t range_start, size_t range_end)
+{
+     struct msm_gem_object *msm_obj = to_msm_bo(obj);
+     struct device *dev = msm_obj->base.dev->dev;
+
+     /* exit early if get_pages() hasn't been called yet */
+     if (!msm_obj->pages)
+             return;
+
+     /* TODO: sync only the specified range */
+
+     if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+             dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_TO_DEVICE);
+     }
+
+     if (flags & MSM_GEM_SYNC_FOR_CPU) {
+             dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_FROM_DEVICE);
Quoted 8 lines
Quoted 1 line

+ }

Splitting this helper from the only caller is rather strange, epecially with the two unused arguments. And I think the way this is specified to take a range, but ignoring it is actively dangerous. User space will rely on it syncing everything sooner or later and then you are stuck. So just define a sync all primitive for now, and if you really need a range sync and have actually implemented it add a new ioctl for that.

We do already have a split of ioctl "layer" which enforces valid ioctl params, etc, and gem (or other) module code which is called by the ioctl func. So I think it is fine to keep this split here. (Also, I think at some point there will be a uring type of ioctl alternative which would re-use the same gem func.)

But I do agree that the range should be respected or added later.. drm_ioctl() dispatch is well prepared for extending ioctls.

Quoted 7 lines
Quoted 3 lines

And I assume there should be some validation that the range is aligned to cache-line? Or can we flush a partial cache line?

The range is intended to be "sync at least this range", so that userspace doesn't have to worry about details like that.

I don't think userspace can *not* worry about details like that. Consider a case where the cpu and gpu are simultaneously accessing different parts of a buffer (for ex, sub-allocation). There needs to be cache-line separation between the two.

BR,
-R
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#11 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

Quoted 48 lines · Rob Clark
Quoted 47 lines · Jonathan Marek
Quoted 44 lines · Rob Clark
Quoted 22 lines · Christoph Hellwig
Quoted 20 lines · Jonathan Marek
drivers/gpu/drm/msm/msm_gem.c +20 -0
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+             size_t range_start, size_t range_end)
+{
+     struct msm_gem_object *msm_obj = to_msm_bo(obj);
+     struct device *dev = msm_obj->base.dev->dev;
+
+     /* exit early if get_pages() hasn't been called yet */
+     if (!msm_obj->pages)
+             return;
+
+     /* TODO: sync only the specified range */
+
+     if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+             dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_TO_DEVICE);
+     }
+
+     if (flags & MSM_GEM_SYNC_FOR_CPU) {
+             dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_FROM_DEVICE);
Quoted 8 lines
Quoted 1 line

+ }

Splitting this helper from the only caller is rather strange, epecially with the two unused arguments. And I think the way this is specified to take a range, but ignoring it is actively dangerous. User space will rely on it syncing everything sooner or later and then you are stuck. So just define a sync all primitive for now, and if you really need a range sync and have actually implemented it add a new ioctl for that.

We do already have a split of ioctl "layer" which enforces valid ioctl params, etc, and gem (or other) module code which is called by the ioctl func. So I think it is fine to keep this split here. (Also, I think at some point there will be a uring type of ioctl alternative which would re-use the same gem func.)

But I do agree that the range should be respected or added later.. drm_ioctl() dispatch is well prepared for extending ioctls.

And I assume there should be some validation that the range is aligned to cache-line? Or can we flush a partial cache line?

Quoted 9 lines
Quoted 3 lines

The range is intended to be "sync at least this range", so that userspace doesn't have to worry about details like that.

I don't think userspace can *not* worry about details like that. Consider a case where the cpu and gpu are simultaneously accessing different parts of a buffer (for ex, sub-allocation). There needs to be cache-line separation between the two.

Right.. and it also seems like we can't get away with just flushing/invalidating the whole thing.

qcom's vulkan driver has nonCoherentAtomSize=1, and it looks like dma_sync_single_for_cpu() does deal in some way with the partial cache line case, although I'm not sure that means we can have a nonCoherentAtomSize=1.

Quoted 3 lines

BR,
-R

#12 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

Quoted 60 lines · Jonathan Marek
Quoted 48 lines · Rob Clark
Quoted 47 lines · Jonathan Marek
Quoted 44 lines · Rob Clark
Quoted 22 lines · Christoph Hellwig
Quoted 20 lines · Jonathan Marek
drivers/gpu/drm/msm/msm_gem.c +20 -0
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+             size_t range_start, size_t range_end)
+{
+     struct msm_gem_object *msm_obj = to_msm_bo(obj);
+     struct device *dev = msm_obj->base.dev->dev;
+
+     /* exit early if get_pages() hasn't been called yet */
+     if (!msm_obj->pages)
+             return;
+
+     /* TODO: sync only the specified range */
+
+     if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+             dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_TO_DEVICE);
+     }
+
+     if (flags & MSM_GEM_SYNC_FOR_CPU) {
+             dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_FROM_DEVICE);
Quoted 8 lines
Quoted 1 line

+ }

Splitting this helper from the only caller is rather strange, epecially with the two unused arguments. And I think the way this is specified to take a range, but ignoring it is actively dangerous. User space will rely on it syncing everything sooner or later and then you are stuck. So just define a sync all primitive for now, and if you really need a range sync and have actually implemented it add a new ioctl for that.

We do already have a split of ioctl "layer" which enforces valid ioctl params, etc, and gem (or other) module code which is called by the ioctl func. So I think it is fine to keep this split here. (Also, I think at some point there will be a uring type of ioctl alternative which would re-use the same gem func.)

But I do agree that the range should be respected or added later.. drm_ioctl() dispatch is well prepared for extending ioctls.

And I assume there should be some validation that the range is aligned to cache-line? Or can we flush a partial cache line?

Quoted 9 lines
Quoted 3 lines

The range is intended to be "sync at least this range", so that userspace doesn't have to worry about details like that.

I don't think userspace can *not* worry about details like that. Consider a case where the cpu and gpu are simultaneously accessing different parts of a buffer (for ex, sub-allocation). There needs to be cache-line separation between the two.

Quoted 8 lines

Right.. and it also seems like we can't get away with just flushing/invalidating the whole thing.

qcom's vulkan driver has nonCoherentAtomSize=1, and it looks like dma_sync_single_for_cpu() does deal in some way with the partial cache line case, although I'm not sure that means we can have a nonCoherentAtomSize=1.

flush/inv the whole thing could be a useful first step, or at least I can think of some uses for it. But if it isn't useful for how vk sees the world, then maybe we should just implement the range properly from the get-go. (And I *think* requiring the range to be aligned to cacheline boundaries.. it is always easy from a kernel uabi PoV to loosen restrictions later, than the other way around.)

BR,
-R
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#13 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

In reply to Jonathan Marek
Quoted 3 lines · Jonathan Marek

qcom's vulkan driver has nonCoherentAtomSize=1, and it looks like dma_sync_single_for_cpu() does deal in some way with the partial cache line case, although I'm not sure that means we can have a nonCoherentAtomSize=1.

No, it doesn't. You need to ensure ownership is managed at dma_get_cache_alignment() granularity.

#14 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Jonathan Marek

qcom's vulkan driver has nonCoherentAtomSize=1, and it looks like dma_sync_single_for_cpu() does deal in some way with the partial cache line case, although I'm not sure that means we can have a nonCoherentAtomSize=1.

No, it doesn't. You need to ensure ownership is managed at dma_get_cache_alignment() granularity.

my guess is nonCoherentAtomSize=1 only works in the case of cache coherent buffers

BR,
-R
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

Quoted 7 lines · Rob Clark
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · Jonathan Marek

qcom's vulkan driver has nonCoherentAtomSize=1, and it looks like dma_sync_single_for_cpu() does deal in some way with the partial cache line case, although I'm not sure that means we can have a nonCoherentAtomSize=1.

Quoted 6 lines
Quoted 2 lines

No, it doesn't. You need to ensure ownership is managed at dma_get_cache_alignment() granularity.

my guess is nonCoherentAtomSize=1 only works in the case of cache coherent buffers

nonCoherentAtomSize doesn't apply to coherent memory (as the name implies), I guess qcom's driver is just wrong about having nonCoherentAtomSize=1.

Jordan just mentioned there is at least one conformance test for this, I wonder if it just doesn't test it well enough, or just doesn't test the non-coherent memory type?

#16 lore raw

Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

Quoted 16 lines · Jonathan Marek
Quoted 7 lines · Rob Clark
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · Jonathan Marek

qcom's vulkan driver has nonCoherentAtomSize=1, and it looks like dma_sync_single_for_cpu() does deal in some way with the partial cache line case, although I'm not sure that means we can have a nonCoherentAtomSize=1.

Quoted 6 lines
Quoted 2 lines

No, it doesn't. You need to ensure ownership is managed at dma_get_cache_alignment() granularity.

my guess is nonCoherentAtomSize=1 only works in the case of cache coherent buffers

Quoted 7 lines

nonCoherentAtomSize doesn't apply to coherent memory (as the name implies), I guess qcom's driver is just wrong about having nonCoherentAtomSize=1.

Jordan just mentioned there is at least one conformance test for this, I wonder if it just doesn't test it well enough, or just doesn't test the non-coherent memory type?

I was *assuming* (but could be wrong) that Jordan was referring to an opencl cts test?

At any rate, it is sounding like you should add a MSM_PARAM_CACHE_ALIGNMENT type of param that returns dma_get_cache_alignment(), and then properly implement offset/end

BR,
-R
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#17 lore raw

Re: [Freedreno] [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

In reply to Rob Clark
Quoted 48 lines · Rob Clark
Quoted 47 lines · Jonathan Marek
Quoted 44 lines · Rob Clark
Quoted 22 lines · Christoph Hellwig
Quoted 20 lines · Jonathan Marek
drivers/gpu/drm/msm/msm_gem.c +20 -0
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+             size_t range_start, size_t range_end)
+{
+     struct msm_gem_object *msm_obj = to_msm_bo(obj);
+     struct device *dev = msm_obj->base.dev->dev;
+
+     /* exit early if get_pages() hasn't been called yet */
+     if (!msm_obj->pages)
+             return;
+
+     /* TODO: sync only the specified range */
+
+     if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+             dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_TO_DEVICE);
+     }
+
+     if (flags & MSM_GEM_SYNC_FOR_CPU) {
+             dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+                             msm_obj->sgt->nents, DMA_FROM_DEVICE);
Quoted 8 lines
Quoted 1 line

+ }

Splitting this helper from the only caller is rather strange, epecially with the two unused arguments. And I think the way this is specified to take a range, but ignoring it is actively dangerous. User space will rely on it syncing everything sooner or later and then you are stuck. So just define a sync all primitive for now, and if you really need a range sync and have actually implemented it add a new ioctl for that.

We do already have a split of ioctl "layer" which enforces valid ioctl params, etc, and gem (or other) module code which is called by the ioctl func. So I think it is fine to keep this split here. (Also, I think at some point there will be a uring type of ioctl alternative which would re-use the same gem func.)

But I do agree that the range should be respected or added later.. drm_ioctl() dispatch is well prepared for extending ioctls.

And I assume there should be some validation that the range is aligned to cache-line? Or can we flush a partial cache line?

Quoted 8 lines
Quoted 3 lines

The range is intended to be "sync at least this range", so that userspace doesn't have to worry about details like that.

I don't think userspace can *not* worry about details like that. Consider a case where the cpu and gpu are simultaneously accessing different parts of a buffer (for ex, sub-allocation). There needs to be cache-line separation between the two.

There is at least one compute conformance test that I can think of that does exactly this.

Jordan

Quoted 6 lines

BR,
-R
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#18 lore raw

Re: [Freedreno] [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

In reply to Jonathan Marek
Quoted 69 lines · Jonathan Marek

This makes it possible to use the non-coherent cached MSM_BO_CACHED mode, which otherwise doesn't provide any method for cleaning/invalidating the cache to sync with the device.

---
 drivers/gpu/drm/msm/msm_drv.c | 21 +++++++++++++++++++++
 drivers/gpu/drm/msm/msm_drv.h |  2 ++
 drivers/gpu/drm/msm/msm_gem.c | 23 +++++++++++++++++++++++
 include/uapi/drm/msm_drm.h    | 20 ++++++++++++++++++++
 4 files changed, 66 insertions(+)
drivers/gpu/drm/msm/msm_drv.c +21 -0
index bae48afca82e..3f17acdf6594 100644
@@ -959,6 +959,26 @@ static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data,
 	return msm_submitqueue_remove(file->driver_priv, id);
 }
 
+static int msm_ioctl_gem_sync_cache(struct drm_device *dev, void *data,
+		struct drm_file *file)
+{
+	struct drm_msm_gem_sync_cache *args = data;
+	struct drm_gem_object *obj;
+
+	if (args->flags & ~MSM_GEM_SYNC_CACHE_FLAGS)
+		return -EINVAL;
+
+	obj = drm_gem_object_lookup(file, args->handle);
+	if (!obj)
+		return -ENOENT;
+
+	msm_gem_sync_cache(obj, args->flags, args->offset, args->end);
+
+	drm_gem_object_put(obj);
+
+	return 0;
+}
+
 static const struct drm_ioctl_desc msm_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(MSM_GET_PARAM,    msm_ioctl_get_param,    DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(MSM_GEM_NEW,      msm_ioctl_gem_new,      DRM_RENDER_ALLOW),
@@ -971,6 +991,7 @@ static const struct drm_ioctl_desc msm_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_NEW,   msm_ioctl_submitqueue_new,   DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_CLOSE, msm_ioctl_submitqueue_close, DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(MSM_GEM_SYNC_CACHE,    msm_ioctl_gem_sync_cache,    DRM_RENDER_ALLOW),
 };
 
 static const struct vm_operations_struct vm_ops = {
drivers/gpu/drm/msm/msm_drv.h +2 -0
index 22ebecb28349..f170f843010e 100644
@@ -318,6 +318,8 @@ void msm_gem_active_get(struct drm_gem_object *obj, struct msm_gpu *gpu);
 void msm_gem_active_put(struct drm_gem_object *obj);
 int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout);
 int msm_gem_cpu_fini(struct drm_gem_object *obj);
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+		size_t range_start, size_t range_end);
 void msm_gem_free_object(struct drm_gem_object *obj);
 int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
 		uint32_t size, uint32_t flags, uint32_t *handle, char *name);
drivers/gpu/drm/msm/msm_gem.c +0 -0
index 3d8254b5de16..039738696f9a 100644

drivers/gpu/drm/msm/msm_gem.c int msm_gem_cpu_fini(struct drm_gem_object *obj) · line 805

Quoted 9 lines
drivers/gpu/drm/msm/msm_gem.c +6 -0
@@ -797,6 +797,29 @@ int msm_gem_cpu_fini(struct drm_gem_object *obj)
 	return 0;
 }
 
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+		size_t range_start, size_t range_end)
+{
+	struct msm_gem_object *msm_obj = to_msm_bo(obj);
+	struct device *dev = msm_obj->base.dev->dev;
+

On a6xx targets with I/O coherency you can skip this (assuming that the IOMMU flag has been set for this buffer). I'm not sure if one of the other patches already does the bypass but I mention it here since this is the point of no-return.

Jordan

Quoted 72 lines
drivers/gpu/drm/msm/msm_gem.c +17 -0
+	/* exit early if get_pages() hasn't been called yet */
+	if (!msm_obj->pages)
+		return;
+
+	/* TODO: sync only the specified range */
+
+	if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+		dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+				msm_obj->sgt->nents, DMA_TO_DEVICE);
+	}
+
+	if (flags & MSM_GEM_SYNC_FOR_CPU) {
+		dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+				msm_obj->sgt->nents, DMA_FROM_DEVICE);
+	}
+}
+
 #ifdef CONFIG_DEBUG_FS
 static void describe_fence(struct dma_fence *fence, const char *type,
 		struct seq_file *m)
include/uapi/drm/msm_drm.h +20 -0
index 474497e8743a..c8288f328528 100644
@@ -319,6 +319,24 @@ struct drm_msm_submitqueue_query {
 	__u32 pad;
 };
 
+/*
+ * Host cache maintenance (relevant for MSM_BO_CACHED)
+ * driver may both clean/invalidate (flush) for clean
+ */
+
+#define MSM_GEM_SYNC_FOR_DEVICE		0x1
+#define MSM_GEM_SYNC_FOR_CPU		0x2
+
+#define MSM_GEM_SYNC_CACHE_FLAGS	(MSM_GEM_SYNC_FOR_DEVICE | \
+					 MSM_GEM_SYNC_FOR_CPU)
+
+struct drm_msm_gem_sync_cache {
+	__u32 handle;
+	__u32 flags;
+	__u64 offset;
+	__u64 end;      /* offset + size */
+};
+
 #define DRM_MSM_GET_PARAM              0x00
 /* placeholder:
 #define DRM_MSM_SET_PARAM              0x01
@@ -336,6 +354,7 @@ struct drm_msm_submitqueue_query {
 #define DRM_MSM_SUBMITQUEUE_NEW        0x0A
 #define DRM_MSM_SUBMITQUEUE_CLOSE      0x0B
 #define DRM_MSM_SUBMITQUEUE_QUERY      0x0C
+#define DRM_MSM_GEM_SYNC_CACHE         0x0D
 
 #define DRM_IOCTL_MSM_GET_PARAM        DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
 #define DRM_IOCTL_MSM_GEM_NEW          DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
@@ -348,6 +367,7 @@ struct drm_msm_submitqueue_query {
 #define DRM_IOCTL_MSM_SUBMITQUEUE_NEW    DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_NEW, struct drm_msm_submitqueue)
 #define DRM_IOCTL_MSM_SUBMITQUEUE_CLOSE  DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_CLOSE, __u32)
 #define DRM_IOCTL_MSM_SUBMITQUEUE_QUERY  DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_QUERY, struct drm_msm_submitqueue_query)
+#define DRM_IOCTL_MSM_GEM_SYNC_CACHE     DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_SYNC_CACHE, struct drm_msm_gem_sync_cache)
 
 #if defined(__cplusplus)
 }
Signature · 6 lines
2.26.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#19 lore raw

PATCH RESEND v2 5/5 drm/msm: bump up the uapi version

In reply to Jonathan Marek

Increase the minor version to indicate the presence of new features.

---
 drivers/gpu/drm/msm/msm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +2 -1
index 3f17acdf6594..7230d3c0eee5 100644
@@ -39,9 +39,10 @@
  *           GEM object's debug name
  * - 1.5.0 - Add SUBMITQUERY_QUERY ioctl
  * - 1.6.0 - Syncobj support
+ * - 1.7.0 - MSM_BO_CACHED_COHERENT and DRM_IOCTL_MSM_GEM_SYNC_CACHE
  */
 #define MSM_VERSION_MAJOR	1
-#define MSM_VERSION_MINOR	6
+#define MSM_VERSION_MINOR	7
 #define MSM_VERSION_PATCHLEVEL	0
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
Signature · 1 line
2.26.1