Skip to contentSkip to conversation

efifb: Check efifb_pci_dev before using it

PATCH In review Kai-Heng Feng 4 participants 5 messages Apr 13, 2021 – Apr 22, 2021

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

PATCH 1/1 efifb: Check efifb_pci_dev before using it

On some platforms like Hyper-V and RPi4 with UEFI firmware, efifb is not a PCI device.

So make sure efifb_pci_dev is found before using it.

Fixes a6c0fd3d5a8b ("efifb: Ensure graphics device for efifb stays at PCI D0")
---
 drivers/video/fbdev/efifb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/video/fbdev/efifb.c +4 -2
index f58a545b3bf3..8ea8f079cde2 100644
@@ -575,7 +575,8 @@ static int efifb_probe(struct platform_device *dev)
 		goto err_fb_dealoc;
 	}
 	fb_info(info, "%s frame buffer device\n", info->fix.id);
-	pm_runtime_get_sync(&efifb_pci_dev->dev);
+	if (efifb_pci_dev)
+		pm_runtime_get_sync(&efifb_pci_dev->dev);
 	return 0;
 
 err_fb_dealoc:
@@ -602,7 +603,8 @@ static int efifb_remove(struct platform_device *pdev)
 	unregister_framebuffer(info);
 	sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
 	framebuffer_release(info);
-	pm_runtime_put(&efifb_pci_dev->dev);
+	if (efifb_pci_dev)
+		pm_runtime_put(&efifb_pci_dev->dev);
 
 	return 0;
 }
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Kai-Heng Feng

On some platforms like Hyper-V and RPi4 with UEFI firmware, efifb is not a PCI device.

So make sure efifb_pci_dev is found before using it.

Fixes a6c0fd3d5a8b ("efifb: Ensure graphics device for efifb stays at PCI D0")
Quoted 31 lines
---
 drivers/video/fbdev/efifb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/video/fbdev/efifb.c +4 -3
index f58a545b3bf3..8ea8f079cde2 100644
@@ -575,7 +575,8 @@ static int efifb_probe(struct platform_device *dev)
                goto err_fb_dealoc;
        }
        fb_info(info, "%s frame buffer device\n", info->fix.id);
-       pm_runtime_get_sync(&efifb_pci_dev->dev);
+       if (efifb_pci_dev)
+               pm_runtime_get_sync(&efifb_pci_dev->dev);
        return 0;
 
 err_fb_dealoc:
@@ -602,7 +603,8 @@ static int efifb_remove(struct platform_device *pdev)
        unregister_framebuffer(info);
        sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
        framebuffer_release(info);
-       pm_runtime_put(&efifb_pci_dev->dev);
+       if (efifb_pci_dev)
+               pm_runtime_put(&efifb_pci_dev->dev);
 
        return 0;
 }
--

2.30.2

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 7 lines · Alex Deucher
Quoted 4 lines · Kai-Heng Feng

On some platforms like Hyper-V and RPi4 with UEFI firmware, efifb is not a PCI device.

Quoted 7 lines
Quoted 5 lines

So make sure efifb_pci_dev is found before using it.

Fixes a6c0fd3d5a8b ("efifb: Ensure graphics device for efifb stays at PCI D0")

fbdev is in drm-misc, so maybe you can push this one too? -Daniel

Quoted 40 lines
Quoted 32 lines
---
 drivers/video/fbdev/efifb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/video/fbdev/efifb.c +4 -3
index f58a545b3bf3..8ea8f079cde2 100644
@@ -575,7 +575,8 @@ static int efifb_probe(struct platform_device *dev)
                goto err_fb_dealoc;
        }
        fb_info(info, "%s frame buffer device\n", info->fix.id);
-       pm_runtime_get_sync(&efifb_pci_dev->dev);
+       if (efifb_pci_dev)
+               pm_runtime_get_sync(&efifb_pci_dev->dev);
        return 0;
 
 err_fb_dealoc:
@@ -602,7 +603,8 @@ static int efifb_remove(struct platform_device *pdev)
        unregister_framebuffer(info);
        sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
        framebuffer_release(info);
-       pm_runtime_put(&efifb_pci_dev->dev);
+       if (efifb_pci_dev)
+               pm_runtime_put(&efifb_pci_dev->dev);
 
        return 0;
 }
--

2.30.2

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 11 lines · Daniel Vetter
Quoted 9 lines · Alex Deucher
Quoted 6 lines · Kai-Heng Feng

On some platforms like Hyper-V and RPi4 with UEFI firmware, efifb is not a PCI device.

So make sure efifb_pci_dev is found before using it.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes a6c0fd3d5a8b ("efifb: Ensure graphics device for efifb stays at PCI D0")

fbdev is in drm-misc, so maybe you can push this one too?

Yes, pushed. Thanks!

Alex

Quoted 45 lines

-Daniel

Quoted 32 lines
Quoted 32 lines
---
 drivers/video/fbdev/efifb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/video/fbdev/efifb.c +4 -3
index f58a545b3bf3..8ea8f079cde2 100644
@@ -575,7 +575,8 @@ static int efifb_probe(struct platform_device *dev)
                goto err_fb_dealoc;
        }
        fb_info(info, "%s frame buffer device\n", info->fix.id);
-       pm_runtime_get_sync(&efifb_pci_dev->dev);
+       if (efifb_pci_dev)
+               pm_runtime_get_sync(&efifb_pci_dev->dev);
        return 0;
 
 err_fb_dealoc:
@@ -602,7 +603,8 @@ static int efifb_remove(struct platform_device *pdev)
        unregister_framebuffer(info);
        sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
        framebuffer_release(info);
-       pm_runtime_put(&efifb_pci_dev->dev);
+       if (efifb_pci_dev)
+               pm_runtime_put(&efifb_pci_dev->dev);
 
        return 0;
 }
--

2.30.2

Quoted 8 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
Quoted 17 lines · Alex Deucher
Quoted 15 lines · Daniel Vetter
Quoted 13 lines · Alex Deucher
Quoted 9 lines · Kai-Heng Feng

On some platforms like Hyper-V and RPi4 with UEFI firmware, efifb is not a PCI device.

So make sure efifb_pci_dev is found before using it.

Fixes a6c0fd3d5a8b ("efifb: Ensure graphics device for efifb stays at PCI D0")
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

fbdev is in drm-misc, so maybe you can push this one too?

Yes, pushed. Thanks!

Can we have this pushed into the branch that gets merged into linux-next. I still don't see this fix in -next and we are unable to do testing on our platform as we hit a boot crash without this as reported in [1]. We prefer running tests on -next without any additional patches or reverts, hence the nagging, sorry for that.

Regards,
Sudeep

[1] https://lore.kernel.org/dri-devel/[email protected]/