[PATCH 2/2] uio:powerpc:mpc85xx: l2-cache-sram uio driver implementation

Wenhu Wang wenhu.wang at hotmail.com
Wed Jun 15 00:40:00 AEST 2022


>>>
>>> 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.

Thanks,
Wenhu


More information about the Linuxppc-dev mailing list