Splitting up platform-specific calls
Subsystems (2)
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
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
@@ -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
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_guestinto a more arch-friendly function as non-x86 builds do not support this functionality.Signed-off-by Casey Bowman <[email protected]>
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@@ -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
Re: [Intel-gfx] [RFC PATCH v5 1/1] Split i915_run_as_guest into x86 and non-x86
In reply to Casey BowmanQuoted 13 lines · Casey Bowman
Splitting
i915_run_as_guestinto a more arch-friendly function as non-x86 builds do not support this functionality.Signed-off-by Casey Bowman <[email protected]>--- drivers/gpu/drm/i915/i915_utils.h | 5 +++++ 1 file changed, 5 insertions(+)drivers/gpu/drm/i915/i915_utils.h +0
-0
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);
Patchwork
CI[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".