[2/4] csky: apply page shift to PFN instead of VA in pfn_to_virt

Message ID 20240131055904.2652-1-yan.y.zhao@intel.com
State New
Headers
Series apply page shift to PFN instead of VA in pfn_to_virt |

Commit Message

Yan Zhao Jan. 31, 2024, 5:59 a.m. UTC
  Apply the page shift to PFN to get physical address for final VA.
The macro __va should take physical address instead of PFN as input.

Fixes: c1884e1e1164 ("csky: Make pfn accessors static inlines")
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
---
 arch/csky/include/asm/page.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Guo Ren Feb. 23, 2024, 11:26 a.m. UTC | #1
On Wed, Jan 31, 2024 at 2:28 PM Yan Zhao <yan.y.zhao@intel.com> wrote:
>
> Apply the page shift to PFN to get physical address for final VA.
> The macro __va should take physical address instead of PFN as input.
>
> Fixes: c1884e1e1164 ("csky: Make pfn accessors static inlines")
> Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
> ---
>  arch/csky/include/asm/page.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h
> index 4a0502e324a6..2c4cc7825a7b 100644
> --- a/arch/csky/include/asm/page.h
> +++ b/arch/csky/include/asm/page.h
> @@ -84,7 +84,7 @@ static inline unsigned long virt_to_pfn(const void *kaddr)
>
>  static inline void * pfn_to_virt(unsigned long pfn)
>  {
> -       return (void *)((unsigned long)__va(pfn) << PAGE_SHIFT);
> +       return __va(pfn << PAGE_SHIFT);
>  }
Reviewed-by: Guo Ren <guoren@kernel.org>

>
>  #define MAP_NR(x)      PFN_DOWN((unsigned long)(x) - PAGE_OFFSET - \
> --
> 2.17.1
>
  

Patch

diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h
index 4a0502e324a6..2c4cc7825a7b 100644
--- a/arch/csky/include/asm/page.h
+++ b/arch/csky/include/asm/page.h
@@ -84,7 +84,7 @@  static inline unsigned long virt_to_pfn(const void *kaddr)
 
 static inline void * pfn_to_virt(unsigned long pfn)
 {
-	return (void *)((unsigned long)__va(pfn) << PAGE_SHIFT);
+	return __va(pfn << PAGE_SHIFT);
 }
 
 #define MAP_NR(x)	PFN_DOWN((unsigned long)(x) - PAGE_OFFSET - \