Drivers: hv: vmbus: Move virt_to_hvpfn() to hyperv header
authorBoqun Feng <boqun.feng@gmail.com>
Wed, 16 Sep 2020 03:48:11 +0000 (11:48 +0800)
committerWei Liu <wei.liu@kernel.org>
Mon, 28 Sep 2020 08:55:13 +0000 (08:55 +0000)
There will be more places other than vmbus where we need to calculate
the Hyper-V page PFN from a virtual address, so move virt_to_hvpfn() to
hyperv generic header.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/20200916034817.30282-6-boqun.feng@gmail.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/hv/channel.c
include/linux/hyperv.h

index 45267b6d069ecffd0f247a5c527272a3cf12557b..fbdda9938039adbd4800bd16e3028897a4142048 100644 (file)
 
 #include "hyperv_vmbus.h"
 
-static unsigned long virt_to_hvpfn(void *addr)
-{
-       phys_addr_t paddr;
-
-       if (is_vmalloc_addr(addr))
-               paddr = page_to_phys(vmalloc_to_page(addr)) +
-                                        offset_in_page(addr);
-       else
-               paddr = __pa(addr);
-
-       return  paddr >> HV_HYP_PAGE_SHIFT;
-}
-
 /*
  * hv_gpadl_size - Return the real size of a gpadl, the size that Hyper-V uses
  *
index 9c19149c0e1a480837214e608a6f38a8c1cfa016..83456dc181a8fadf38df7a32fdd40a01db6ee3f7 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <uapi/linux/hyperv.h>
 
+#include <linux/mm.h>
 #include <linux/types.h>
 #include <linux/scatterlist.h>
 #include <linux/list.h>
@@ -23,6 +24,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/interrupt.h>
 #include <linux/reciprocal_div.h>
+#include <asm/hyperv-tlfs.h>
 
 #define MAX_PAGE_BUFFER_COUNT                          32
 #define MAX_MULTIPAGE_BUFFER_COUNT                     32 /* 128K */
@@ -1676,4 +1678,17 @@ struct hyperv_pci_block_ops {
 
 extern struct hyperv_pci_block_ops hvpci_block_ops;
 
+static inline unsigned long virt_to_hvpfn(void *addr)
+{
+       phys_addr_t paddr;
+
+       if (is_vmalloc_addr(addr))
+               paddr = page_to_phys(vmalloc_to_page(addr)) +
+                                    offset_in_page(addr);
+       else
+               paddr = __pa(addr);
+
+       return  paddr >> HV_HYP_PAGE_SHIFT;
+}
+
 #endif /* _HYPERV_H */