[PATCH 1/2] drm/xe/display: Unify DPT mappings
Juha-Pekka Heikkila
juhapekka.heikkila at gmail.com
Tue Mar 19 17:07:33 UTC 2024
Unify writing of rotated and remapped DPTs
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
drivers/gpu/drm/xe/display/xe_fb_pin.c | 104 ++++++++++---------------
1 file changed, 41 insertions(+), 63 deletions(-)
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 2eb622510186..2d1259a884d6 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -13,66 +13,43 @@
#include <drm/ttm/ttm_bo.h>
-static void
-write_dpt_rotated(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs, u32 bo_ofs,
- u32 width, u32 height, u32 src_stride, u32 dst_stride)
+static void encode_and_write_pte(struct xe_bo *bo, struct iosys_map *map,
+ u32 *ofs, u32 src_idx, struct xe_device *xe)
{
- struct xe_device *xe = xe_bo_device(bo);
struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
- u32 column, row;
-
- /* TODO: Maybe rewrite so we can traverse the bo addresses sequentially,
- * by writing dpt/ggtt in a different order?
- */
-
- for (column = 0; column < width; column++) {
- u32 src_idx = src_stride * (height - 1) + column + bo_ofs;
-
- for (row = 0; row < height; row++) {
- u64 pte = ggtt->pt_ops->pte_encode_bo(bo, src_idx * XE_PAGE_SIZE,
- xe->pat.idx[XE_CACHE_NONE]);
-
- iosys_map_wr(map, *dpt_ofs, u64, pte);
- *dpt_ofs += 8;
- src_idx -= src_stride;
- }
+ u64 pte = ggtt->pt_ops->pte_encode_bo(bo, src_idx * XE_PAGE_SIZE,
+ xe->pat.idx[XE_CACHE_NONE]);
+ iosys_map_wr(map, *ofs, u64, pte);
+ *ofs += 8;
+}
- /* The DE ignores the PTEs for the padding tiles */
- *dpt_ofs += (dst_stride - height) * 8;
- }
+static u32 calc_src_idx_rotated(u32 base, u32 offset, u32 stride, u32 width,
+ u32 height, u32 row, u32 column)
+{
+ return base + stride * (height - 1 - row) + column;
+}
- /* Align to next page */
- *dpt_ofs = ALIGN(*dpt_ofs, 4096);
+static u32 calc_src_idx_remapped(u32 base, u32 offset, u32 src_stride,
+ u32 width, u32 height, u32 row, u32 column)
+{
+ return base + offset + row * src_stride + column;
}
-static void
-write_dpt_remapped(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs,
- u32 bo_ofs, u32 width, u32 height, u32 src_stride,
- u32 dst_stride)
+static void write_dpt(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs,
+ u32 bo_ofs, u32 width, u32 height, u32 src_stride,
+ u32 dst_stride,
+ u32 (*calc_src_idx)(u32, u32, u32, u32, u32, u32, u32))
{
struct xe_device *xe = xe_bo_device(bo);
- struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
- u64 (*pte_encode_bo)(struct xe_bo *bo, u64 bo_offset, u16 pat_index)
- = ggtt->pt_ops->pte_encode_bo;
- u32 column, row;
-
- for (row = 0; row < height; row++) {
- u32 src_idx = src_stride * row + bo_ofs;
-
- for (column = 0; column < width; column++) {
- iosys_map_wr(map, *dpt_ofs, u64,
- pte_encode_bo(bo, src_idx * XE_PAGE_SIZE,
- xe->pat.idx[XE_CACHE_NONE]));
-
- *dpt_ofs += 8;
- src_idx++;
+ for (u32 row = 0; row < height; ++row) {
+ for (u32 column = 0; column < width; ++column) {
+ u32 src_idx = calc_src_idx(bo_ofs, 0, src_stride,
+ width, height, row, column);
+ encode_and_write_pte(bo, map, dpt_ofs, src_idx, xe);
}
-
- /* The DE ignores the PTEs for the padding tiles */
- *dpt_ofs += (dst_stride - width) * 8;
+ *dpt_ofs += (dst_stride - (calc_src_idx == calc_src_idx_rotated
+ ? height : width)) * 8;
}
-
- /* Align to next page */
*dpt_ofs = ALIGN(*dpt_ofs, 4096);
}
@@ -131,24 +108,25 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
u32 i, dpt_ofs = 0;
for (i = 0; i < ARRAY_SIZE(remap_info->plane); i++)
- write_dpt_remapped(bo, &dpt->vmap, &dpt_ofs,
- remap_info->plane[i].offset,
- remap_info->plane[i].width,
- remap_info->plane[i].height,
- remap_info->plane[i].src_stride,
- remap_info->plane[i].dst_stride);
-
+ write_dpt(bo, &dpt->vmap, &dpt_ofs,
+ remap_info->plane[i].offset,
+ remap_info->plane[i].width,
+ remap_info->plane[i].height,
+ remap_info->plane[i].src_stride,
+ remap_info->plane[i].dst_stride,
+ calc_src_idx_remapped);
} else {
const struct intel_rotation_info *rot_info = &view->rotated;
u32 i, dpt_ofs = 0;
for (i = 0; i < ARRAY_SIZE(rot_info->plane); i++)
- write_dpt_rotated(bo, &dpt->vmap, &dpt_ofs,
- rot_info->plane[i].offset,
- rot_info->plane[i].width,
- rot_info->plane[i].height,
- rot_info->plane[i].src_stride,
- rot_info->plane[i].dst_stride);
+ write_dpt(bo, &dpt->vmap, &dpt_ofs,
+ rot_info->plane[i].offset,
+ rot_info->plane[i].width,
+ rot_info->plane[i].height,
+ rot_info->plane[i].src_stride,
+ rot_info->plane[i].dst_stride,
+ calc_src_idx_rotated);
}
vma->dpt = dpt;
--
2.25.1
More information about the Intel-xe
mailing list