Skip to contentSkip to conversation

video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.

PATCH In review Wei Hu 4 participants 4 messages Dec 9, 2019 – Jan 15, 2020

Subsystems (3)
lore
Share & tools
lore

Wei Hu

author maintainer
#0 lore raw

PATCH v4 1/1 video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.

On Hyper-V, Generation 1 VMs can directly use VM's physical memory for their framebuffers. This can improve the efficiency of framebuffer and overall performence for VM. The physical memory assigned to framebuffer must be contiguous. We use CMA allocator to get contiguouse physicial memory when the framebuffer size is greater than 4MB. For size under 4MB, we use alloc_pages to achieve this.

To enable framebuffer memory allocation from CMA, supply a kernel parameter to give enough space to CMA allocator at boot time. For example:

    cma0m

This gives 130MB memory to CAM allocator that can be allocated to framebuffer. If this fails, we fall back to the old way of using mmio for framebuffer.

---
v2: Incorporated review comments form [email protected], Michael Kelley and Dexuan Cui
- Use dma_alloc_coherent to allocate large contiguous memory
- Use phys_addr_t for physical addresses
- Corrected a few spelling errors and minor cleanups
- Also tested on 32 bit Ubuntu guest
v3: Fixed a build issue reported by kbuild test robot and incorported some review comments from Michael Kelley
- Add CMA check to avoid link failure
- Fixed small memory leak introduced by alloc_apertures
- Cleaned up so code
v4: Removed request_pages variable as it is no longer needed

 drivers/video/fbdev/Kconfig     |   1 +
 drivers/video/fbdev/hyperv_fb.c | 182 +++++++++++++++++++++++++-------
 2 files changed, 144 insertions(+), 39 deletions(-)
drivers/video/fbdev/Kconfig +1 -0
index aa9541bf964b..f65991a67af2 100644
@@ -2215,6 +2215,7 @@ config FB_HYPERV
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
 	select FB_DEFERRED_IO
+	select DMA_CMA if HAVE_DMA_CONTIGUOUS && CMA
 	help
 	  This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
 
drivers/video/fbdev/hyperv_fb.c +142 -38

291 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v4 1/1
#1 lore raw

From: Wei Hu <[email protected]> Sent: Sunday, December 8, 2019 11:58 PM

Quoted 32 lines

On Hyper-V, Generation 1 VMs can directly use VM's physical memory for their framebuffers. This can improve the efficiency of framebuffer and overall performence for VM. The physical memory assigned to framebuffer must be contiguous. We use CMA allocator to get contiguouse physicial memory when the framebuffer size is greater than 4MB. For size under 4MB, we use alloc_pages to achieve this.

To enable framebuffer memory allocation from CMA, supply a kernel parameter to give enough space to CMA allocator at boot time. For example:

    cma=130m

This gives 130MB memory to CAM allocator that can be allocated to framebuffer. If this fails, we fall back to the old way of using mmio for framebuffer.

---
v2: Incorporated review comments form [email protected], Michael Kelley and Dexuan Cui
- Use dma_alloc_coherent to allocate large contiguous memory
- Use phys_addr_t for physical addresses
- Corrected a few spelling errors and minor cleanups
- Also tested on 32 bit Ubuntu guest
v3: Fixed a build issue reported by kbuild test robot and incorported some review comments from Michael Kelley
- Add CMA check to avoid link failure
- Fixed small memory leak introduced by alloc_apertures
- Cleaned up so code
v4: Removed request_pages variable as it is no longer needed

Quoted 4 lines
 drivers/video/fbdev/Kconfig     |   1 +
 drivers/video/fbdev/hyperv_fb.c | 182 +++++++++++++++++++++++++-------
 2 files changed, 144 insertions(+), 39 deletions(-)
maintainer Tested-by
#2 lore raw
Quoted 50 lines

From: Michael Kelley <[email protected]>
Sent: Monday, December 9, 2019 8:33 AM
To: Wei Hu <[email protected]>; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Stephen Hemminger <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Dexuan Cui <[email protected]>
Cc: kbuild test robot <[email protected]>
Subject: RE: [PATCH v4] video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.

From: Wei Hu <[email protected]> Sent: Sunday, December 8, 2019 11:58 PM

Quoted 12 lines

On Hyper-V, Generation 1 VMs can directly use VM's physical memory for their framebuffers. This can improve the efficiency of framebuffer and overall performance for VM. The physical memory assigned to framebuffer must be contiguous. We use CMA allocator to get contiguous physicial memory when the framebuffer size is greater than 4MB. For size under 4MB, we use alloc_pages to achieve this.

To enable framebuffer memory allocation from CMA, supply a kernel parameter to give enough space to CMA allocator at boot time. For example:

    cma=130m
Quoted 8 lines

This gives 130MB memory to CAM allocator that can be allocated to framebuffer. If this fails, we fall back to the old way of using mmio for framebuffer.

---
v2: Incorporated review comments form [email protected], Michael Kelley

and

Quoted 12 lines

Dexuan Cui
- Use dma_alloc_coherent to allocate large contiguous memory
- Use phys_addr_t for physical addresses
- Corrected a few spelling errors and minor cleanups
- Also tested on 32 bit Ubuntu guest
v3: Fixed a build issue reported by kbuild test robot and incorported some review comments from Michael Kelley
- Add CMA check to avoid link failure
- Fixed small memory leak introduced by alloc_apertures
- Cleaned up so code
v4: Removed request_pages variable as it is no longer needed

Quoted 7 lines
Quoted 2 lines
 drivers/video/fbdev/Kconfig     |   1 +
 drivers/video/fbdev/hyperv_fb.c | 182

+++++++++++++++++++++++++-------

Quoted 2 lines
 2 files changed, 144 insertions(+), 39 deletions(-)

For a Gen-1 VM running on recent Hyper-V hosts, this patch can greatly reduce the CPU utilization because it avoids the slow data copy from the shadow framebuffer to the MMIO framebuffer, and hence it resolves the "blurred screen" issue when we output a lot of characters on the text-mode ternimal (e.g. "dmesg").

#3 lore raw
Quoted 58 lines · Dexuan Cui
Quoted 50 lines

From: Michael Kelley <[email protected]>
Sent: Monday, December 9, 2019 8:33 AM
To: Wei Hu <[email protected]>; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Stephen Hemminger <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Dexuan Cui <[email protected]>
Cc: kbuild test robot <[email protected]>
Subject: RE: [PATCH v4] video: hyperv: hyperv_fb: Use physical memory for fb on HyperV Gen 1 VMs.

From: Wei Hu <[email protected]> Sent: Sunday, December 8, 2019 11:58 PM

Quoted 12 lines

On Hyper-V, Generation 1 VMs can directly use VM's physical memory for their framebuffers. This can improve the efficiency of framebuffer and overall performance for VM. The physical memory assigned to framebuffer must be contiguous. We use CMA allocator to get contiguous physicial memory when the framebuffer size is greater than 4MB. For size under 4MB, we use alloc_pages to achieve this.

To enable framebuffer memory allocation from CMA, supply a kernel parameter to give enough space to CMA allocator at boot time. For example:

    cma0m
Quoted 8 lines

This gives 130MB memory to CAM allocator that can be allocated to framebuffer. If this fails, we fall back to the old way of using mmio for framebuffer.

---
v2: Incorporated review comments form [email protected], Michael Kelley

and

Quoted 12 lines

Dexuan Cui
- Use dma_alloc_coherent to allocate large contiguous memory
- Use phys_addr_t for physical addresses
- Corrected a few spelling errors and minor cleanups
- Also tested on 32 bit Ubuntu guest
v3: Fixed a build issue reported by kbuild test robot and incorported some review comments from Michael Kelley
- Add CMA check to avoid link failure
- Fixed small memory leak introduced by alloc_apertures
- Cleaned up so code
v4: Removed request_pages variable as it is no longer needed

Quoted 7 lines
Quoted 2 lines
 drivers/video/fbdev/Kconfig     |   1 +
 drivers/video/fbdev/hyperv_fb.c | 182

+++++++++++++++++++++++++-------

Quoted 2 lines
 2 files changed, 144 insertions(+), 39 deletions(-)
Quoted 7 lines

For a Gen-1 VM running on recent Hyper-V hosts, this patch can greatly reduce the CPU utilization because it avoids the slow data copy from the shadow framebuffer to the MMIO framebuffer, and hence it resolves the "blurred screen" issue when we output a lot of characters on the text-mode ternimal (e.g. "dmesg").

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics