Skip to contentSkip to conversation

Splitting up platform-specific calls

RFC PATCH Superseded Casey Bowman 4 participants 5 messages Mar 31, 2022

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Splitting up platform-specific calls

In this RFC I would like to ask the community their thoughts on how we can best handle splitting architecture-specific calls.

I would like to address the following:

1. How do we want to split architecture calls? Different object files per platform? Separate function calls within the same object file?

2. How do we address dummy functions? If we have a function call that is used for one or more platforms, but is not used in another, what should we do for this case?

I've given an example of splitting an architecture call in my patch with run_as_guest() being split into different implementations for x86 and arm64 in separate object files, sharing a single header.

Another suggestion from Michael ([email protected]) involved using a single object file, a single header, and splitting various functions calls via ifdefs in the header file.

I would appreciate any input on how we can avoid scaling issues when including multiple architectures and multiple functions (as the number of function calls will inevitably increase with more architectures).

v2: Revised to use kernel's platform-splitting scheme.
v3: Revised to use simple if-else structure.
v4: Modified into more arch-neutral split.
v5: Rebased on top of the run_as_guest -> i915_run_as_guest changes

Casey Bowman (1):
Split i915_run_as_guest into x86 and non-x86

 drivers/gpu/drm/i915/i915_utils.h | 5 +++++
 1 file changed, 5 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

RFC PATCH v5 1/1 Split i915_run_as_guest into x86 and non-x86

Splitting i915_run_as_guest into a more arch-friendly function as non-x86 builds do not support this functionality.

---
 drivers/gpu/drm/i915/i915_utils.h | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_utils.h +5 -0
index b2d89c43f24d..a42882e68eea 100644
@@ -428,7 +428,12 @@ static inline bool timer_expired(const struct timer_list *t)
 
 static inline bool i915_run_as_guest(void)
 {
+#if IS_ENABLED(CONFIG_X86)
 	return !hypervisor_is_type(X86_HYPER_NATIVE);
+#else
+	/* Not supported yet */
+	return false;
+#endif
 }
 
 bool i915_vtd_active(struct drm_i915_private *i915);
Signature · 1 line
2.25.1
Reviewed-by on v5 1/1
#2 lore raw

Re: [Intel-gfx] [RFC PATCH v5 1/1] Split i915_run_as_guest into x86 and non-x86

Quoted 4 lines · Casey Bowman

Splitting i915_run_as_guest into a more arch-friendly function as non-x86 builds do not support this functionality.

this is by no means and "RFC". For next patches please remove it when you get an idea of what the patch should be.

The CI failure is unrelated, please re-trigger it in patchwork.

+Tomi: can I get super powers to retrigger others' people patches? I promise I will use it responsibly :)

thanks
Lucas De Marchi

Quoted 24 lines

---
drivers/gpu/drm/i915/i915_utils.h | 5 +++++

1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_utils.h +5 -0
index b2d89c43f24d..a42882e68eea 100644
@@ -428,7 +428,12 @@ static inline bool timer_expired(const struct timer_list *t)
 
 static inline bool i915_run_as_guest(void)
 {
+#if IS_ENABLED(CONFIG_X86)
 	return !hypervisor_is_type(X86_HYPER_NATIVE);
+#else
+	/* Not supported yet */
+	return false;
+#endif
 }
 
 bool i915_vtd_active(struct drm_i915_private *i915);
Signature · 1 line
2.25.1
Acked-by on v5 1/1
#3 lore raw

Re: [Intel-gfx] [RFC PATCH v5 1/1] Split i915_run_as_guest into x86 and non-x86

In reply to Casey Bowman
Quoted 13 lines · Casey Bowman

Splitting i915_run_as_guest into a more arch-friendly function as non-x86 builds do not support this functionality.

---
  drivers/gpu/drm/i915/i915_utils.h | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/i915_utils.h +0 -0
index b2d89c43f24d..a42882e68eea 100644

drivers/gpu/drm/i915/i915_utils.h static inline bool timer_expired(const struct timer_list *t) · line 436

Quoted 9 lines
drivers/gpu/drm/i915/i915_utils.h +5 -0
@@ -428,7 +428,12 @@ static inline bool timer_expired(const struct timer_list *t)
 
  static inline bool i915_run_as_guest(void)
  {
+#if IS_ENABLED(CONFIG_X86)
  	return !hypervisor_is_type(X86_HYPER_NATIVE);
+#else
+	/* Not supported yet */
+	return false;
+#endif

Works for me.

You may want to #ifdef the inclusion of asm/hypervisor.h as well. It only happens to work by chance since Arm has that file. Although it becomes uglier at that point..

There is a function in there which appears may give you a way to query if under hypervisor, based on some feature flags, but you'd have to ask Arm experts if that would make sense.

Regards,

Tvrtko

Quoted 3 lines
drivers/gpu/drm/i915/i915_utils.h +0 -0
  }
 
  bool i915_vtd_active(struct drm_i915_private *i915);
#4 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for Splitting up platform-specific calls (rev5)

In reply to Casey Bowman
== Series Details ==

== Series Details ==

Series: Splitting up platform-specific calls (rev5)
URL : https://patchwork.freedesktop.org/series/99126/
State : failure

== Summary ==

Applying: Split i915_run_as_guest into x86 and non-x86
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/i915_utils.h
Falling back to patching base and 3-way merge... Auto-merging drivers/gpu/drm/i915/i915_utils.h
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/i915_utils.h
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Split i915_run_as_guest into x86 and non-x86 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".