Skip to content

Commit

Permalink
Drivers: hv: vmbus: Move virt_to_hvpfn() to hyperv header
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Michael Kelley <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Wei Liu <[email protected]>
  • Loading branch information
fbq authored and liuw committed Sep 28, 2020
1 parent ef514d3 commit bca6b91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
13 changes: 0 additions & 13 deletions drivers/hv/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,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
*
Expand Down
15 changes: 15 additions & 0 deletions include/linux/hyperv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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 */
Expand Down Expand Up @@ -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 */

0 comments on commit bca6b91

Please sign in to comment.