[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200721014135.84140-6-boqun.feng@gmail.com>
Date: Tue, 21 Jul 2020 09:41:29 +0800
From: Boqun Feng <boqun.feng@...il.com>
To: linux-hyperv@...r.kernel.org, linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
linux-scsi@...r.kernel.org
Cc: "K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Wei Liu <wei.liu@...nel.org>, Jiri Kosina <jikos@...nel.org>,
Benjamin Tissoires <benjamin.tissoires@...hat.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Michael Kelley <mikelley@...rosoft.com>,
Boqun Feng <boqun.feng@...il.com>
Subject: [RFC 05/11] Drivers: hv: vmbus: Move virt_to_hvpfn() to hyperv header
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@...il.com>
---
drivers/hv/channel.c | 13 -------------
include/linux/hyperv.h | 15 +++++++++++++++
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 13e98ac2a00f..ac7039fe2f29 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -21,19 +21,6 @@
#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
*
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 663f0a016237..eda8e5f9a49d 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -23,6 +23,8 @@
#include <linux/mod_devicetable.h>
#include <linux/interrupt.h>
#include <linux/reciprocal_div.h>
+#include <asm/memory.h>
+#include <asm/hyperv-tlfs.h>
#define MAX_PAGE_BUFFER_COUNT 32
#define MAX_MULTIPAGE_BUFFER_COUNT 32 /* 128K */
@@ -1688,4 +1690,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 */
--
2.27.0
Powered by blists - more mailing lists