Skip to content

Commit bed23bb

Browse files
kelleymhmerwick
authored andcommitted
Drivers: hv: vmbus: Remove use of slow_virt_to_phys()
slow_virt_to_phys() is only implemented for arch/x86. Remove its use in arch independent Hyper-V drivers, and replace with test for vmalloc() address followed by appropriate v-to-p function. This follows the typical pattern of other drivers and avoids the need to implement slow_virt_to_phys() for Hyper-V on ARM64. Signed-off-by: Michael Kelley <[email protected]> Signed-off-by: K. Y. Srinivasan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 6ba3417) Orabug: 28671425 Signed-off-by: Liam Merwick <[email protected]> Reviewed-by: Darren Kenny <[email protected]> Reviewed-by: Alejandro Jimenez <[email protected]> Tested-by: Vijay Balakrishna <[email protected]>
1 parent c95a10b commit bed23bb

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

drivers/hv/channel.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,26 @@
2929
#include <linux/hyperv.h>
3030
#include <linux/uio.h>
3131
#include <linux/interrupt.h>
32+
#include <asm/page.h>
3233

3334
#include "hyperv_vmbus.h"
3435

3536
#define NUM_PAGES_SPANNED(addr, len) \
3637
((PAGE_ALIGN(addr + len) >> PAGE_SHIFT) - (addr >> PAGE_SHIFT))
3738

39+
static unsigned long virt_to_hvpfn(void *addr)
40+
{
41+
unsigned long paddr;
42+
43+
if (is_vmalloc_addr(addr))
44+
paddr = page_to_phys(vmalloc_to_page(addr)) +
45+
offset_in_page(addr);
46+
else
47+
paddr = __pa(addr);
48+
49+
return paddr >> PAGE_SHIFT;
50+
}
51+
3852
/*
3953
* vmbus_setevent- Trigger an event notification on the specified
4054
* channel.
@@ -298,8 +312,8 @@ static int create_gpadl_header(void *kbuffer, u32 size,
298312
gpadl_header->range[0].byte_offset = 0;
299313
gpadl_header->range[0].byte_count = size;
300314
for (i = 0; i < pfncount; i++)
301-
gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys(
302-
kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT;
315+
gpadl_header->range[0].pfn_array[i] = virt_to_hvpfn(
316+
kbuffer + PAGE_SIZE * i);
303317
*msginfo = msgheader;
304318

305319
pfnsum = pfncount;
@@ -350,9 +364,8 @@ static int create_gpadl_header(void *kbuffer, u32 size,
350364
* so the hypervisor guarantees that this is ok.
351365
*/
352366
for (i = 0; i < pfncurr; i++)
353-
gpadl_body->pfn[i] = slow_virt_to_phys(
354-
kbuffer + PAGE_SIZE * (pfnsum + i)) >>
355-
PAGE_SHIFT;
367+
gpadl_body->pfn[i] = virt_to_hvpfn(
368+
kbuffer + PAGE_SIZE * (pfnsum + i));
356369

357370
/* add to msg header */
358371
list_add_tail(&msgbody->msglistentry,
@@ -380,8 +393,8 @@ static int create_gpadl_header(void *kbuffer, u32 size,
380393
gpadl_header->range[0].byte_offset = 0;
381394
gpadl_header->range[0].byte_count = size;
382395
for (i = 0; i < pagecount; i++)
383-
gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys(
384-
kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT;
396+
gpadl_header->range[0].pfn_array[i] = virt_to_hvpfn(
397+
kbuffer + PAGE_SIZE * i);
385398

386399
*msginfo = msgheader;
387400
}

0 commit comments

Comments
 (0)