amdgpu: Abort probing if firmware is not installed, as we do in radeon

This commit is contained in:
Ben Hutchings 2018-03-14 19:09:56 +00:00
parent e7bdd24f18
commit 35e5ff18f3
4 changed files with 71 additions and 4 deletions

1
debian/changelog vendored
View File

@ -402,6 +402,7 @@ linux (4.15.9-1) UNRELEASED; urgency=medium
__flush_tlb_one_[user|kernel]()" to avoid an ABI change __flush_tlb_one_[user|kernel]()" to avoid an ABI change
* [x86] Revert "x86/debug: Use UD2 for WARN()" to avoid an ABI change * [x86] Revert "x86/debug: Use UD2 for WARN()" to avoid an ABI change
* drm/atomic: Avoid ABI change in 4.15.7 * drm/atomic: Avoid ABI change in 4.15.7
* amdgpu: Abort probing if firmware is not installed, as we do in radeon
[ Uwe Kleine-König ] [ Uwe Kleine-König ]
* netfilter: enable NFT_FIB_NETDEV as module * netfilter: enable NFT_FIB_NETDEV as module

View File

@ -1,5 +1,5 @@
From: Ben Hutchings <ben@decadent.org.uk> From: Ben Hutchings <ben@decadent.org.uk>
Subject: radeon: Firmware is required for DRM and KMS on R600 onward Subject: radeon, amdgpu: Firmware is required for DRM and KMS on R600 onward
Date: Tue, 08 Jan 2013 03:25:52 +0000 Date: Tue, 08 Jan 2013 03:25:52 +0000
Bug-Debian: https://bugs.debian.org/607194 Bug-Debian: https://bugs.debian.org/607194
Bug-Debian: https://bugs.debian.org/607471 Bug-Debian: https://bugs.debian.org/607471
@ -20,8 +20,8 @@ the firmware is not available, but becomes unstable - the framebuffer
and/or system memory may be corrupted, or the display may stay black. and/or system memory may be corrupted, or the display may stay black.
Therefore, perform a basic check for the existence of Therefore, perform a basic check for the existence of
/lib/firmware/radeon when a device is probed, and abort if it is /lib/firmware/{radeon,amdgpu} when a device is probed, and abort if it
missing, except for the pre-R600 case. is missing, except for the pre-R600 case.
--- ---
--- a/drivers/gpu/drm/radeon/radeon_drv.c --- a/drivers/gpu/drm/radeon/radeon_drv.c
@ -77,3 +77,55 @@ missing, except for the pre-R600 case.
/* Get rid of things like offb */ /* Get rid of things like offb */
ret = radeon_kick_out_firmware_fb(pdev); ret = radeon_kick_out_firmware_fb(pdev);
if (ret) if (ret)
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -40,6 +40,8 @@
#include <linux/pm_runtime.h>
#include <linux/vga_switcheroo.h>
#include <drm/drm_crtc_helper.h>
+#include <linux/namei.h>
+#include <linux/path.h>
#include "amdgpu.h"
#include "amdgpu_irq.h"
@@ -545,6 +547,28 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
static struct drm_driver kms_driver;
+/* Test that /lib/firmware/amdgpu is a directory (or symlink to a
+ * directory). We could try to match the udev search path, but let's
+ * keep it simple.
+ */
+static bool amdgpu_firmware_installed(void)
+{
+#if IS_BUILTIN(CONFIG_DRM_AMDGPU)
+ /* It may be too early to tell. Assume it's there. */
+ return true;
+#else
+ struct path path;
+
+ if (kern_path("/lib/firmware/amdgpu", LOOKUP_DIRECTORY | LOOKUP_FOLLOW,
+ &path) == 0) {
+ path_put(&path);
+ return true;
+ }
+
+ return false;
+#endif
+}
+
static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev)
{
struct apertures_struct *ap;
@@ -579,6 +603,11 @@ static int amdgpu_pci_probe(struct pci_d
return -ENODEV;
}
+ if (!amdgpu_firmware_installed()) {
+ DRM_ERROR("amdgpu requires firmware installed\n");
+ return -ENODEV;
+ }
+
/*
* Initialize amdkfd before starting radeon. If it was not loaded yet,
* defer radeon probing

View File

@ -9,6 +9,10 @@ message referring to our wiki page about firmware. This will explain
why some firmware is in non-free, or can't be packaged at all. Only why some firmware is in non-free, or can't be packaged at all. Only
do this once per boot. do this once per boot.
Do something similar in the radeon and amdgpu drivers, where we have
an early check to avoid failing at a point where we cannot display
anything.
--- ---
--- a/drivers/base/firmware_class.c --- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c
@ -36,3 +40,13 @@ do this once per boot.
return -ENODEV; return -ENODEV;
} }
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -605,6 +605,7 @@ static int amdgpu_pci_probe(struct pci_d
if (!amdgpu_firmware_installed()) {
DRM_ERROR("amdgpu requires firmware installed\n");
+ pr_err_once("See https://wiki.debian.org/Firmware for information about missing firmware\n");
return -ENODEV;
}

View File

@ -16,7 +16,7 @@ features/all/drivers-media-dvb-usb-af9005-request_firmware.patch
debian/iwlwifi-do-not-request-unreleased-firmware.patch debian/iwlwifi-do-not-request-unreleased-firmware.patch
bugfix/all/firmware_class-log-every-success-and-failure.patch bugfix/all/firmware_class-log-every-success-and-failure.patch
bugfix/all/firmware-remove-redundant-log-messages-from-drivers.patch bugfix/all/firmware-remove-redundant-log-messages-from-drivers.patch
bugfix/all/radeon-firmware-is-required-for-drm-and-kms-on-r600-onward.patch bugfix/all/radeon-amdgpu-firmware-is-required-for-drm-and-kms-on-r600-onward.patch
debian/firmware_class-refer-to-debian-wiki-firmware-page.patch debian/firmware_class-refer-to-debian-wiki-firmware-page.patch
# Patches from aufs4 repository, imported with # Patches from aufs4 repository, imported with