* [RESEND PATCH v2 0/5] drm/msm: support for host-cached BOs
@ 2020-11-14 15:17 Jonathan Marek
2020-11-14 15:17 ` [RESEND PATCH v2 2/5] dma-direct: add dma_direct_bypass() to force direct ops Jonathan Marek
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Marek @ 2020-11-14 15:17 UTC (permalink / raw)
To: freedreno, hch
Cc: Sean Paul, David Airlie, open list:DRM DRIVER FOR MSM ADRENO GPU,
Sharat Masetty, open list:DRM DRIVER FOR MSM ADRENO GPU,
open list:DMA MAPPING HELPERS, Daniel Vetter, Shawn Guo,
Robin Murphy, open list
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(-)
--
2.26.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 3+ messages in thread
* [RESEND PATCH v2 2/5] dma-direct: add dma_direct_bypass() to force direct ops
2020-11-14 15:17 [RESEND PATCH v2 0/5] drm/msm: support for host-cached BOs Jonathan Marek
@ 2020-11-14 15:17 ` Jonathan Marek
2020-11-14 16:21 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Marek @ 2020-11-14 15:17 UTC (permalink / raw)
To: freedreno, hch; +Cc: open list:DMA MAPPING HELPERS, Robin Murphy, open list
Add a function to force direct ops and disable swiotlb for a deivce.
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
---
include/linux/dma-direct.h | 9 +++++++++
kernel/dma/direct.c | 23 +++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index 18aade195884..41f57e1b7aa5 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -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 */
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 06c111544f61..304a5a77cccb 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -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
--
2.26.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [RESEND PATCH v2 2/5] dma-direct: add dma_direct_bypass() to force direct ops
2020-11-14 15:17 ` [RESEND PATCH v2 2/5] dma-direct: add dma_direct_bypass() to force direct ops Jonathan Marek
@ 2020-11-14 16:21 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2020-11-14 16:21 UTC (permalink / raw)
To: Jonathan Marek
Cc: freedreno, open list, open list:DMA MAPPING HELPERS, Robin Murphy,
hch
On Sat, Nov 14, 2020 at 10:17:10AM -0500, Jonathan Marek wrote:
> Add a function to force direct ops and disable swiotlb for a deivce.
s/deivce/device/
> +#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED)
overly long line.
> +#if IS_ENABLED(CONFIG_DMA_OPS_BYPASS) && !IS_ENABLED(CONFIG_ARCH_HAS_FORCE_DMA_UNENCRYPTED)
Again.
> +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
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-14 16:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-14 15:17 [RESEND PATCH v2 0/5] drm/msm: support for host-cached BOs Jonathan Marek
2020-11-14 15:17 ` [RESEND PATCH v2 2/5] dma-direct: add dma_direct_bypass() to force direct ops Jonathan Marek
2020-11-14 16:21 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox