lkml.org 
[lkml]   [2022]   [Jun]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH 2/2] uio:powerpc:mpc85xx: l2-cache-sram uio driver implementation
Date


Le 14/06/2022 à 16:40, Wenhu Wang a écrit :
>>>>
>>>> I looked at that patch.
>>>>
>>>> I don't think you can just drop the #ifdef in function
>>>> __access_remote_vm() in mm/memory.c
>>>>
>>>> You have to replace it with something like:
>>>>
>>>>       if (!IS_ENABLED(CONFIG_HAVE_IOREMAP_PROT))
>>>>           break;
>>>>
>>>
>>>
>>> Another thing in that patch:
>>>
>>> By making generic_access_phys() a static inline, it means that everytime
>>> you refer to the address of that function in a vm_operations_struct
>>> struct, the compiler has to provide an outlined instance of the
>>> function. It means you'll likely have several instances of a
>>> generic_access_phys().
>>>
>>> What you could do instead is to add the following at the start of
>>> generic_access_phys() in mm/memory.c :
>>>
>>>         if (!IS_ENABLED(CONFIG_HAVE_IOREMAP_PROT))
>>>                 return 0;
>>>
>>
>> It is really a better chmoce, thanks for the advice.
>> Multiple instances exist as you mentioned, the block returns 0 with no-op
>> instance which makes no difference with the function return value.
>>
>> I will update the patch after a re-confirming.
>>
>
> I tried as adviced but when not defined, error happens on archectures such
> as arm64. Actually the function generic_access_phys calls a lot of functions
> that become undefined if we compile it with CONFIG_HAVE_IOREMAP_PROT disabled.
> The archectures that support CONFIG_HAVE_IOREMAP_PROT are mips, x86, sh, arc,
> s390, loongarch and powerpc.
>
> So we may just define the function with static inline and add IS_ENABLED
> condition branch in function __access_remote_vm in mm/memory.c. The executing
> path breaks if CONFIG_HAVE_IOREMAP_PROT is disabled, and never goes into the
> static no-op function.
>
> In short, the static inline no-op function would never be executed, the only
> difference is that there would be a lot of function code in compiled target.
>

In that case all you have to do is:

diff --git a/mm/memory.c b/mm/memory.c
index 7a089145cad4..39b369fc77f6 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -5413,6 +5413,13 @@ int generic_access_phys(struct vm_area_struct
*vma, unsigned long addr,
return ret;
}
EXPORT_SYMBOL_GPL(generic_access_phys);
+#else
+int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
+ void *buf, int len, int write)
+{
+ return 0;
+}
+EXPORT_SYMBOL_GPL(generic_access_phys);
#endif

/*


Christophe
\
 
 \ /
  Last update: 2022-06-14 17:01    [W:1.213 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site