Skip to contentSkip to conversation

Splitting intel-gtt calls for non-x86 platforms

PATCH Superseded Casey Bowman 2 participants 4 messages Mar 30, 2022

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Splitting intel-gtt calls for non-x86 platforms

The intel-gtt module defines some functions used by i915, but they are only supported by x86 platforms. In order to bring i915 to a more arch-neutral state, we split out these functions and provide stubs in the case of non-x86 builds.

There may be a better filename choice for the files used in splitting the calls, it's very much open to discussion.

v2: Refactored to move gmch functions, renamed exported functions
v3: Added drm/i915_drm.h header
v4: Rebased on drm-intel-next, resolved build and naming issues

Casey Bowman (2):
drm/i915/gt: Split intel-gtt functions by arch
drm/i915: Require INTEL_GTT to depend on X86

 drivers/gpu/drm/i915/Kconfig            |   2 +-
 drivers/gpu/drm/i915/Makefile           |   2 +
 drivers/gpu/drm/i915/gt/intel_ggtt.c    | 664 +-----------------------
 drivers/gpu/drm/i915/gt/intel_gt.c      |   4 +-
 drivers/gpu/drm/i915/gt/intel_gt.h      |   9 +
 drivers/gpu/drm/i915/gt/intel_gt_gmch.c | 654 +++++++++++++++++++++++
 drivers/gpu/drm/i915/gt/intel_gt_gmch.h |  46 ++
 drivers/gpu/drm/i915/gt/intel_gtt.h     |   9 +
 8 files changed, 737 insertions(+), 653 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gt/intel_gt_gmch.c
 create mode 100644 drivers/gpu/drm/i915/gt/intel_gt_gmch.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 1/2 drm/i915/gt: Split intel-gtt functions by arch

Some functions defined in the intel-gtt module are used in several areas, but is only supported on x86 platforms.

By separating these calls and their static underlying functions to another area, we are able to compile out these functions for non-x86 builds and provide stubs for the non-x86 implementations.

In addition to the problematic calls, we are moving the gmch-related functions to the new area.

---
 drivers/gpu/drm/i915/Makefile           |   2 +
 drivers/gpu/drm/i915/gt/intel_ggtt.c    | 664 +-----------------------
 drivers/gpu/drm/i915/gt/intel_gt.c      |   4 +-
 drivers/gpu/drm/i915/gt/intel_gt.h      |   9 +
 drivers/gpu/drm/i915/gt/intel_gt_gmch.c | 654 +++++++++++++++++++++++
 drivers/gpu/drm/i915/gt/intel_gt_gmch.h |  46 ++
 drivers/gpu/drm/i915/gt/intel_gtt.h     |   9 +
 7 files changed, 736 insertions(+), 652 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gt/intel_gt_gmch.c
 create mode 100644 drivers/gpu/drm/i915/gt/intel_gt_gmch.h
drivers/gpu/drm/i915/Makefile +2 -0
index 1a771ee5b1d0..4cac8250f2da 100644
@@ -124,6 +124,8 @@ gt-y += \
 	gt/intel_workarounds.o \
 	gt/shmem_utils.o \
 	gt/sysfs_engines.o
+# x86 intel-gtt module support
+gt-$(CONFIG_X86) += gt/intel_gt_gmch.o
 # autogenerated null render state
 gt-y += \
 	gt/gen6_renderstate.o \
drivers/gpu/drm/i915/gt/intel_ggtt.c +14 -650

750 lines not on this page · raw message

drivers/gpu/drm/i915/gt/intel_gt.c +2 -2
index e8403fa53909..97914beb38eb 100644
@@ -4,7 +4,6 @@
  */
 
 #include <drm/drm_managed.h>
-#include <drm/intel-gtt.h>
 
 #include "gem/i915_gem_internal.h"
 #include "gem/i915_gem_lmem.h"
@@ -17,6 +16,7 @@
 #include "intel_gt_buffer_pool.h"
 #include "intel_gt_clock_utils.h"
 #include "intel_gt_debugfs.h"
+#include "intel_gt_gmch.h"
 #include "intel_gt_pm.h"
 #include "intel_gt_regs.h"
 #include "intel_gt_requests.h"
@@ -441,7 +441,7 @@ void intel_gt_chipset_flush(struct intel_gt *gt)
 {
 	wmb();
 	if (GRAPHICS_VER(gt->i915) < 6)
-		intel_gtt_chipset_flush();
+		intel_gt_gmch_gen5_chipset_flush(gt);
 }
 
 void intel_gt_driver_register(struct intel_gt *gt)
drivers/gpu/drm/i915/gt/intel_gt.h +9 -0
index 2dad46c3eff2..47bb0cae4238 100644
@@ -13,6 +13,13 @@
 struct drm_i915_private;
 struct drm_printer;
 
+struct insert_entries {
+	struct i915_address_space *vm;
+	struct i915_vma_resource *vma_res;
+	enum i915_cache_level level;
+	u32 flags;
+};
+
 #define GT_TRACE(gt, fmt, ...) do {					\
 	const struct intel_gt *gt__ __maybe_unused = (gt);		\
 	GEM_TRACE("%s " fmt, dev_name(gt__->i915->drm.dev),		\
@@ -93,4 +100,6 @@ void intel_gt_watchdog_work(struct work_struct *work);
 
 void intel_gt_invalidate_tlbs(struct intel_gt *gt);
 
+struct resource intel_pci_resource(struct pci_dev *pdev, int bar);
+
 #endif /* __INTEL_GT_H__ */
drivers/gpu/drm/i915/gt/intel_gt_gmch.c new file +654 -0

654 lines not on this page · raw message

drivers/gpu/drm/i915/gt/intel_gt_gmch.h new file +46 -0

46 lines not on this page · raw message

drivers/gpu/drm/i915/gt/intel_gtt.h +9 -0
index b12ecee49de0..24f37ec0154d 100644
@@ -534,6 +534,14 @@ i915_page_dir_dma_addr(const struct i915_ppgtt *ppgtt, const unsigned int n)
 void ppgtt_init(struct i915_ppgtt *ppgtt, struct intel_gt *gt,
 		unsigned long lmem_pt_obj_flags);
 
+void intel_ggtt_bind_vma(struct i915_address_space *vm,
+			  struct i915_vm_pt_stash *stash,
+			  struct i915_vma_resource *vma_res,
+			  enum i915_cache_level cache_level,
+			  u32 flags);
+void intel_ggtt_unbind_vma(struct i915_address_space *vm,
+			    struct i915_vma_resource *vma_res);
+
 int i915_ggtt_probe_hw(struct drm_i915_private *i915);
 int i915_ggtt_init_hw(struct drm_i915_private *i915);
 int i915_ggtt_enable_hw(struct drm_i915_private *i915);
@@ -604,6 +612,7 @@ release_pd_entry(struct i915_page_directory * const pd,
 		 struct i915_page_table * const pt,
 		 const struct drm_i915_gem_object * const scratch);
 void gen6_ggtt_invalidate(struct i915_ggtt *ggtt);
+void gen8_ggtt_invalidate(struct i915_ggtt *ggtt);
 
 void ppgtt_bind_vma(struct i915_address_space *vm,
 		    struct i915_vm_pt_stash *stash,
Signature · 1 line
2.25.1
#2 lore raw

PATCH v4 2/2 drm/i915: Require INTEL_GTT to depend on X86

In reply to Casey Bowman

The intel-gtt module is not used on other, non-x86 platforms, so we will restrict it to x86 platforms only.

---
 drivers/gpu/drm/i915/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/Kconfig +1 -1
index 42b5400f0fef..0e23a62895ce 100644
@@ -3,7 +3,7 @@ config DRM_I915
 	tristate "Intel 8xx/9xx/G3x/G4x/HD Graphics"
 	depends on DRM
 	depends on X86 && PCI
-	select INTEL_GTT
+	select INTEL_GTT if X86
 	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.25.1
#3 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for Splitting intel-gtt calls for non-x86 platforms (rev4)

In reply to Casey Bowman
== Series Details ==

== Series Details ==

Series: Splitting intel-gtt calls for non-x86 platforms (rev4)
URL : https://patchwork.freedesktop.org/series/101552/
State : failure

== Summary ==

Applying: drm/i915/gt: Split intel-gtt functions by arch
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/Makefile
M drivers/gpu/drm/i915/gt/intel_ggtt.c
M drivers/gpu/drm/i915/gt/intel_gt.c
M drivers/gpu/drm/i915/gt/intel_gt.h
M drivers/gpu/drm/i915/gt/intel_gtt.h
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/gt/intel_gtt.h
Auto-merging drivers/gpu/drm/i915/gt/intel_gt.h
Auto-merging drivers/gpu/drm/i915/gt/intel_gt.c
Auto-merging drivers/gpu/drm/i915/gt/intel_ggtt.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/gt/intel_ggtt.c Auto-merging drivers/gpu/drm/i915/Makefile
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 drm/i915/gt: Split intel-gtt functions by arch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".