summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFrancois Dugast <francois.dugast@intel.com>2025-08-05 16:59:04 +0300
committerFrancois Dugast <francois.dugast@intel.com>2025-08-06 14:34:50 +0300
commitd755ff6063852cbd43c666726b69333d33d0d379 (patch)
tree8e9810bd4fbd08bedb96f1bf67175a71394c4491 /include
parentf35a6cdf8a6d69f2fb35ece202a09f13fe7c87b2 (diff)
downloadlinux-d755ff6063852cbd43c666726b69333d33d0d379.tar.xz
drm/pagemap: DMA map folios when possible
If the page is part of a folio, DMA map the whole folio at once instead of mapping individual pages one after the other. For example if 2MB folios are used instead of 4KB pages, this reduces the number of DMA mappings by 512. The folio order (and consequently, the size) is persisted in the struct drm_pagemap_device_addr to be available at the time of unmapping. v2: - Initialize order variable (Matthew Brost) - Set proto and dir for completeness (Matthew Brost) - Do not populate drm_pagemap_addr, document it (Matthew Brost) - Add and use macro NR_PAGES(order) (Matthew Brost) Cc: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Acked-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://lore.kernel.org/r/20250805140028.599361-4-francois.dugast@intel.com Signed-off-by: Francois Dugast <francois.dugast@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/drm/drm_pagemap.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/drm/drm_pagemap.h b/include/drm/drm_pagemap.h
index 1d5919a99139..f6e7e234c089 100644
--- a/include/drm/drm_pagemap.h
+++ b/include/drm/drm_pagemap.h
@@ -6,6 +6,8 @@
#include <linux/hmm.h>
#include <linux/types.h>
+#define NR_PAGES(order) (1U << (order))
+
struct drm_pagemap;
struct drm_pagemap_zdd;
struct device;
@@ -173,7 +175,9 @@ struct drm_pagemap_devmem_ops {
* @pagemap_addr: Pointer to array of DMA information (source)
* @npages: Number of pages to copy
*
- * Copy pages to device memory.
+ * Copy pages to device memory. If the order of a @pagemap_addr entry
+ * is greater than 0, the entry is populated but subsequent entries
+ * within the range of that order are not populated.
*
* Return: 0 on success, a negative error code on failure.
*/
@@ -187,7 +191,9 @@ struct drm_pagemap_devmem_ops {
* @pagemap_addr: Pointer to array of DMA information (destination)
* @npages: Number of pages to copy
*
- * Copy pages to system RAM.
+ * Copy pages to system RAM. If the order of a @pagemap_addr entry
+ * is greater than 0, the entry is populated but subsequent entries
+ * within the range of that order are not populated.
*
* Return: 0 on success, a negative error code on failure.
*/