Skip to contentSkip to conversation

fbdev/hyperv_fb: Fix logic error for Gen2 VMs in hvfb_getmem()

PATCH Applied [email protected] 6 participants 7 messages Feb 1, 2024 – Mar 1, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fbdev/hyperv_fb: Fix logic error for Gen2 VMs in hvfb_getmem()

From: Michael Kelley <[email protected]>

A recent commit removing the use of screen_info introduced a logic error. The error causes hvfb_getmem() to always return -ENOMEM for Generation 2 VMs. As a result, the Hyper-V frame buffer device fails to initialize. The error was introduced by removing an "else if" clause, leaving Gen2 VMs to always take the -ENOMEM error path.

Fix the problem by removing the error path "else" clause. Gen 2 VMs now always proceed through the MMIO memory allocation code, but with "base" and "size" defaulting to 0.

Fixes 0aa0838c84da ("fbdev/hyperv_fb: Remove firmware framebuffers with aperture helpers")
---
 drivers/video/fbdev/hyperv_fb.c | 2 --
 1 file changed, 2 deletions(-)
drivers/video/fbdev/hyperv_fb.c +0 -2
index c26ee6fd73c9..8fdccf033b2d 100644
@@ -1010,8 +1010,6 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
 			goto getmem_done;
 		}
 		pr_info("Unable to allocate enough contiguous physical memory on Gen 1 VM. Using MMIO instead.\n");
-	} else {
-		goto err1;
 	}
 
 	/*
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Hi

Am 01.02.24 um 07:00 schrieb [email protected]:

Quoted 9 lines

From: Michael Kelley <[email protected]>

A recent commit removing the use of screen_info introduced a logic error. The error causes hvfb_getmem() to always return -ENOMEM for Generation 2 VMs. As a result, the Hyper-V frame buffer device fails to initialize. The error was introduced by removing an "else if" clause, leaving Gen2 VMs to always take the -ENOMEM error path.

Quoted 3 lines

Fix the problem by removing the error path "else" clause. Gen 2 VMs now always proceed through the MMIO memory allocation code, but with "base" and "size" defaulting to 0.

Indeed, that's how it was supposed to work. IDK how I didn't notice this bug. Thanks a lot for the fix.

Quoted 3 lines
Fixes 0aa0838c84da ("fbdev/hyperv_fb: Remove firmware framebuffers with aperture helpers")
Quoted 17 lines
---
  drivers/video/fbdev/hyperv_fb.c | 2 --
  1 file changed, 2 deletions(-)
drivers/video/fbdev/hyperv_fb.c +0 -2
index c26ee6fd73c9..8fdccf033b2d 100644
@@ -1010,8 +1010,6 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
  			goto getmem_done;
  		}
  		pr_info("Unable to allocate enough contiguous physical memory on Gen 1 VM. Using MMIO instead.\n");
-	} else {
-		goto err1;
  	}
 
  	/*
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#2 lore raw

From: Thomas Zimmermann <[email protected]> Sent: Thursday, February 1, 2024 12:17 AM

Quoted 17 lines

Hi

Am 01.02.24 um 07:00 schrieb [email protected]:

Quoted 9 lines

From: Michael Kelley <[email protected]>

A recent commit removing the use of screen_info introduced a logic error. The error causes hvfb_getmem() to always return -ENOMEM for Generation 2 VMs. As a result, the Hyper-V frame buffer device fails to initialize. The error was introduced by removing an "else if" clause, leaving Gen2 VMs to always take the -ENOMEM error path.

Quoted 3 lines

Fix the problem by removing the error path "else" clause. Gen 2 VMs now always proceed through the MMIO memory allocation code, but with "base" and "size" defaulting to 0.

Quoted 8 lines

Indeed, that's how it was supposed to work. IDK how I didn't notice this bug. Thanks a lot for the fix.

Quoted 3 lines
Fixes 0aa0838c84da ("fbdev/hyperv_fb: Remove firmware framebufferswith aperture helpers")

Wei Liu and Helge Deller --

Should this fix go through the Hyper-V tree or the fbdev tree? I'm not
aware of a reason that it really matters, but it needs to be one or the other, and sooner rather than later, because the Hyper-V driver is broken starting in 6.8-rc1.

Michael

Quoted 21 lines

Review

Quoted 6 lines
---
  drivers/video/fbdev/hyperv_fb.c | 2 --
  1 file changed, 2 deletions(-)
(quoted diff) +0 -0

b/drivers/video/fbdev/hyperv_fb.c

drivers/video/fbdev/hyperv_fb.c static int hvfb_getmem(struct hv_device *hdev,

Quoted 4 lines

index c26ee6fd73c9..8fdccf033b2d 100644

drivers/video/fbdev/hyperv_fb.c +0 -0
@@ -1010,8 +1010,6 @@ static int hvfb_getmem(struct hv_device *hdev,

struct fb_info *info)

Quoted 8 lines
drivers/video/fbdev/hyperv_fb.c +0 -2
  			goto getmem_done;
  		}
  		pr_info("Unable to allocate enough contiguous physical memory on Gen 1 VM. Using MMIO instead.\n");
-	} else {
-		goto err1;
  	}
 
  	/*
maintainer
#3 lore raw
Quoted 25 lines · Michael Kelley

From: Thomas Zimmermann <[email protected]> Sent: Thursday, February 1, 2024 12:17 AM

Quoted 24 lines

Hi

Am 01.02.24 um 07:00 schrieb [email protected]:

Quoted 9 lines

From: Michael Kelley <[email protected]>

A recent commit removing the use of screen_info introduced a logic error. The error causes hvfb_getmem() to always return -ENOMEM for Generation 2 VMs. As a result, the Hyper-V frame buffer device fails to initialize. The error was introduced by removing an "else if" clause, leaving Gen2 VMs to always take the -ENOMEM error path.

Quoted 3 lines

Fix the problem by removing the error path "else" clause. Gen 2 VMs now always proceed through the MMIO memory allocation code, but with "base" and "size" defaulting to 0.

Indeed, that's how it was supposed to work. IDK how I didn't notice this bug. Thanks a lot for the fix.

Quoted 3 lines
Fixes 0aa0838c84da ("fbdev/hyperv_fb: Remove firmware framebufferswith aperture helpers")
Quoted 8 lines
Quoted 1 line

Wei Liu and Helge Deller --

Should this fix go through the Hyper-V tree or the fbdev tree? I'm not
aware of a reason that it really matters, but it needs to be one or the other, and sooner rather than later, because the Hyper-V driver is broken starting in 6.8-rc1.

I'm fine with either.
If there is an upcoming hyper-v pull request, I'm fine if this is included there. If not, let me know and I can take it via fbdev.

Helge

Quoted 26 lines

Michael

Quoted 21 lines

Review

Quoted 6 lines
---
   drivers/video/fbdev/hyperv_fb.c | 2 --
   1 file changed, 2 deletions(-)
(quoted diff) +0 -0

b/drivers/video/fbdev/hyperv_fb.c

drivers/video/fbdev/hyperv_fb.c static int hvfb_getmem(struct hv_device *hdev,

Quoted 4 lines

index c26ee6fd73c9..8fdccf033b2d 100644

drivers/video/fbdev/hyperv_fb.c +0 -0
@@ -1010,8 +1010,6 @@ static int hvfb_getmem(struct hv_device *hdev,

struct fb_info *info)

Quoted 8 lines
drivers/video/fbdev/hyperv_fb.c +0 -2
   			goto getmem_done;
   		}
   		pr_info("Unable to allocate enough contiguous physical memory on Gen 1 VM. Using MMIO instead.\n");
-	} else {
-		goto err1;
   	}
 
   	/*
maintainer Applied
#4 lore raw
Quoted 2 lines · Helge Deller
Quoted 1 line · Michael Kelley

From: Thomas Zimmermann <[email protected]> Sent: Thursday, February 1, 2024 12:17 AM

[...]

Quoted 11 lines
Quoted 7 lines

Wei Liu and Helge Deller --

Should this fix go through the Hyper-V tree or the fbdev tree? I'm not
aware of a reason that it really matters, but it needs to be one or the other, and sooner rather than later, because the Hyper-V driver is broken starting in 6.8-rc1.

I'm fine with either.
If there is an upcoming hyper-v pull request, I'm fine if this is included there. If not, let me know and I can take it via fbdev.

I've applied this to the hyperv-fixes tree. Thanks.

#5 lore raw

From: Wei Liu <[email protected]> Sent: Friday, March 1, 2024 1:26 AM

Quoted 13 lines · Helge Deller
Quoted 2 lines · Michael Kelley
Quoted 1 line

From: Thomas Zimmermann <[email protected]> Sent: Thursday, February 1, 2024 12:17 AM

[...]

Quoted 8 lines
Quoted 7 lines

Wei Liu and Helge Deller --

Should this fix go through the Hyper-V tree or the fbdev tree? I'm not
aware of a reason that it really matters, but it needs to be one or the other, and sooner rather than later, because the Hyper-V driver is broken starting in 6.8-rc1.

Quoted 5 lines
Quoted 3 lines

I'm fine with either.
If there is an upcoming hyper-v pull request, I'm fine if this is included there. If not, let me know and I can take it via fbdev.

I've applied this to the hyperv-fixes tree. Thanks.

Thanks, Wei, for picking up this patch as well as several others of mine.

Michael

Reviewed-by on v1 1/1
#6 lore raw
In reply to [email protected]
Quoted 35 lines · On Wed, Jan 31, 2024 at 10:00:22PM -0800, [email protected] wrote:

From: Michael Kelley <[email protected]>

A recent commit removing the use of screen_info introduced a logic error. The error causes hvfb_getmem() to always return -ENOMEM for Generation 2 VMs. As a result, the Hyper-V frame buffer device fails to initialize. The error was introduced by removing an "else if" clause, leaving Gen2 VMs to always take the -ENOMEM error path.

Fix the problem by removing the error path "else" clause. Gen 2 VMs now always proceed through the MMIO memory allocation code, but with "base" and "size" defaulting to 0.

Fixes 0aa0838c84da ("fbdev/hyperv_fb: Remove firmware framebuffers with aperture helpers")
---
 drivers/video/fbdev/hyperv_fb.c | 2 --
 1 file changed, 2 deletions(-)
drivers/video/fbdev/hyperv_fb.c +0 -2
index c26ee6fd73c9..8fdccf033b2d 100644
@@ -1010,8 +1010,6 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
 			goto getmem_done;
 		}
 		pr_info("Unable to allocate enough contiguous physical memory on Gen 1 VM. Using MMIO instead.\n");
-	} else {
-		goto err1;
 	}
 
 	/*
Signature · 1 line
2.25.1