Skip to contentSkip to conversation

drm/xe: Fix 32bit build

PATCH Superseded Lucas De Marchi 2 participants 8 messages Dec 21, 2023 – Dec 22, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover drm/xe: Fix 32bit build

A few fixes when building xe with ARCH=i386. If getting the whole lot, we can simply skip the first and last patches. However they probably need to got through CI and be reviewed to avoid regressions. For the current pull request, simply disabling 32bits build is an alternative, so we'd apply patch 1 now and let the rest come later.

Lucas De Marchi (6):
drm/xe: Disable 32bits build
drm/xe: Use _ULL for u64 division
drm/xe/mmio: Cast to u64 when printing
drm/xe/display: Avoid calling readq()
drm/xe: Fix cast on trace variable
drm/xe: Enable 32bits build

 .../gpu/drm/xe/compat-i915-headers/gem/i915_gem_object.h   | 7 +++++--
 drivers/gpu/drm/xe/xe_device.c                             | 2 +-
 drivers/gpu/drm/xe/xe_mmio.c                               | 4 ++--
 drivers/gpu/drm/xe/xe_trace.h                              | 2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH 1/6 drm/xe: Disable 32bits build

Add a dependency on CONFIG_64BIT since currently the xe driver doesn't build on 32bits. It may be enabled again after all the issues are fixed.

---
 drivers/gpu/drm/xe/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/Kconfig +1 -1
index 5b3da06e7ba3..a53b0fdc15a7 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config DRM_XE
 	tristate "Intel Xe Graphics"
-	depends on DRM && PCI && MMU && (m || (y && KUNIT=y))
+	depends on DRM && PCI && MMU && (m || (y && KUNIT=y)) && 64BIT
 	select INTERVAL_TREE
 	# we need shmfs for the swappable backing store, and in particular
 	# the shmem_readpage() which depends upon tmpfs
Signature · 1 line
2.40.1
maintainer Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] drm/xe: Disable 32bits build

Quoted 4 lines · Lucas De Marchi

Add a dependency on CONFIG_64BIT since currently the xe driver doesn't build on 32bits. It may be enabled again after all the issues are fixed.

Quoted 20 lines
---
 drivers/gpu/drm/xe/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/Kconfig +1 -1
index 5b3da06e7ba3..a53b0fdc15a7 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config DRM_XE
 	tristate "Intel Xe Graphics"
-	depends on DRM && PCI && MMU && (m || (y && KUNIT=y))
+	depends on DRM && PCI && MMU && (m || (y && KUNIT=y)) && 64BIT
 	select INTERVAL_TREE
 	# we need shmfs for the swappable backing store, and in particular
 	# the shmem_readpage() which depends upon tmpfs
Signature · 1 line
2.40.1
#3 lore raw

PATCH 2/6 drm/xe: Use _ULL for u64 division

In reply to Lucas De Marchi

Use DIV_ROUND_UP_ULL() so it also works on 32bit build.

Fixes dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
---
 drivers/gpu/drm/xe/xe_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_device.c +1 -1
index 86867d42d532..3f0dcf54277b 100644
@@ -620,7 +620,7 @@ void xe_device_wmb(struct xe_device *xe)
 u32 xe_device_ccs_bytes(struct xe_device *xe, u64 size)
 {
 	return xe_device_has_flat_ccs(xe) ?
-		DIV_ROUND_UP(size, NUM_BYTES_PER_CCS_BYTE(xe)) : 0;
+		DIV_ROUND_UP_ULL(size, NUM_BYTES_PER_CCS_BYTE(xe)) : 0;
 }
 
 bool xe_device_mem_access_ongoing(struct xe_device *xe)
Signature · 1 line
2.40.1
#4 lore raw

PATCH 3/6 drm/xe/mmio: Cast to u64 when printing

In reply to Lucas De Marchi

resource_size_t uses %pa format in printk since the size varies depending on build options. However to keep the io_size/physical_size addition in the same call we can't pass the address without adding yet another variable in these function. Simply cast it to u64 and keep using %llx.

Fixes 286089ce6929 ("drm/xe: Improve vram info debug printing")
Cc Oak Zeng <[email protected]>
Cc Michael J. Ruhl <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/xe/xe_mmio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_mmio.c +2 -2
index f660cfb79f50..5c46f2d0b6dc 100644
@@ -272,8 +272,8 @@ int xe_mmio_probe_vram(struct xe_device *xe)
 		drm_info(&xe->drm, "VRAM[%u, %u]: Actual physical size %pa, usable size exclude stolen %pa, CPU accessible size %pa\n", id,
 			 tile->id, &tile->mem.vram.actual_physical_size, &tile->mem.vram.usable_size, &tile->mem.vram.io_size);
 		drm_info(&xe->drm, "VRAM[%u, %u]: DPA range: [%pa-%llx], io range: [%pa-%llx]\n", id, tile->id,
-			 &tile->mem.vram.dpa_base, tile->mem.vram.dpa_base + tile->mem.vram.actual_physical_size,
-			 &tile->mem.vram.io_start, tile->mem.vram.io_start + tile->mem.vram.io_size);
+			 &tile->mem.vram.dpa_base, tile->mem.vram.dpa_base + (u64)tile->mem.vram.actual_physical_size,
+			 &tile->mem.vram.io_start, tile->mem.vram.io_start + (u64)tile->mem.vram.io_size);
 
 		/* calculate total size using tile size to get the correct HW sizing */
 		total_size += tile_size;
Signature · 1 line
2.40.1
#5 lore raw

PATCH 4/6 drm/xe/display: Avoid calling readq()

In reply to Lucas De Marchi

readq() is not available in 32bits. iosys-map already has the logic in place to use read u64 in all cases, so simply add a helper variable for using that.

Fixes 44e694958b95 ("drm/xe/display: Implement display support")
---
 .../gpu/drm/xe/compat-i915-headers/gem/i915_gem_object.h   | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object.h +5 -2
index 5f19550cc845..6739dadaf1a9 100644
@@ -7,6 +7,7 @@
 #define _I915_GEM_OBJECT_H_
 
 #include <linux/types.h>
+#include <linux/iosys-map.h>
 
 #include "xe_bo.h"
 
@@ -36,6 +37,7 @@ static inline int i915_gem_object_read_from_page(struct xe_bo *bo,
 {
 	struct ttm_bo_kmap_obj map;
 	void *virtual;
+	struct iosys_map vaddr;
 	bool is_iomem;
 	int ret;
 
@@ -52,10 +54,11 @@ static inline int i915_gem_object_read_from_page(struct xe_bo *bo,
 	ofs &= ~PAGE_MASK;
 	virtual = ttm_kmap_obj_virtual(&map, &is_iomem);
 	if (is_iomem)
-		*ptr = readq((void __iomem *)(virtual + ofs));
+		iosys_map_set_vaddr_iomem(&vaddr, (void __iomem *)(virtual));
 	else
-		*ptr = *(u64 *)(virtual + ofs);
+		iosys_map_set_vaddr(&vaddr, virtual);
 
+	*ptr = iosys_map_rd(&vaddr, ofs, u64);
 	ttm_bo_kunmap(&map);
 out_unlock:
 	xe_bo_unlock(bo);
Signature · 1 line
2.40.1
#6 lore raw

PATCH 5/6 drm/xe: Fix cast on trace variable

In reply to Lucas De Marchi

Cast the pointer to unsigned long and let it be implicitly extended to u64. This fixes the build on 32bits arch.

Cc Matthew Brost <[email protected]>
Cc Niranjana Vishwanathapura <[email protected]>
Cc Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/xe/xe_trace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_trace.h +1 -1
index 95163c303f3e..e4e7262191ad 100644
@@ -31,7 +31,7 @@ DECLARE_EVENT_CLASS(xe_gt_tlb_invalidation_fence,
 			     ),
 
 		    TP_fast_assign(
-			   __entry->fence = (u64)fence;
+			   __entry->fence = (unsigned long)fence;
 			   __entry->seqno = fence->seqno;
 			   ),
 
Signature · 1 line
2.40.1
#7 lore raw

PATCH 6/6 drm/xe: Enable 32bits build

In reply to Lucas De Marchi

Now that all the issues with 32bits are fixed, enable it again.

---
 drivers/gpu/drm/xe/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/Kconfig +1 -1
index a53b0fdc15a7..5b3da06e7ba3 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config DRM_XE
 	tristate "Intel Xe Graphics"
-	depends on DRM && PCI && MMU && (m || (y && KUNIT=y)) && 64BIT
+	depends on DRM && PCI && MMU && (m || (y && KUNIT=y))
 	select INTERVAL_TREE
 	# we need shmfs for the swappable backing store, and in particular
 	# the shmem_readpage() which depends upon tmpfs
Signature · 1 line
2.40.1