2013-01-08 03:27:57 +00:00
|
|
|
From: Ben Hutchings <ben@decadent.org.uk>
|
2018-03-14 19:09:56 +00:00
|
|
|
Subject: radeon, amdgpu: Firmware is required for DRM and KMS on R600 onward
|
2013-01-08 03:27:57 +00:00
|
|
|
Date: Tue, 08 Jan 2013 03:25:52 +0000
|
2014-03-15 15:45:47 +00:00
|
|
|
Bug-Debian: https://bugs.debian.org/607194
|
|
|
|
Bug-Debian: https://bugs.debian.org/607471
|
|
|
|
Bug-Debian: https://bugs.debian.org/610851
|
|
|
|
Bug-Debian: https://bugs.debian.org/627497
|
|
|
|
Bug-Debian: https://bugs.debian.org/632212
|
|
|
|
Bug-Debian: https://bugs.debian.org/637943
|
|
|
|
Bug-Debian: https://bugs.debian.org/649448
|
|
|
|
Bug-Debian: https://bugs.debian.org/697229
|
2013-07-01 01:12:30 +00:00
|
|
|
Forwarded: no
|
2013-01-08 03:27:57 +00:00
|
|
|
|
|
|
|
radeon requires firmware/microcode for the GPU in all chips, but for
|
|
|
|
newer chips (apparently R600 'Evergreen' onward) it also expects
|
|
|
|
firmware for the memory controller and other sub-blocks.
|
|
|
|
|
|
|
|
radeon attempts to gracefully fall back and disable some features if
|
|
|
|
the firmware is not available, but becomes unstable - the framebuffer
|
|
|
|
and/or system memory may be corrupted, or the display may stay black.
|
|
|
|
|
|
|
|
Therefore, perform a basic check for the existence of
|
2018-03-14 19:09:56 +00:00
|
|
|
/lib/firmware/{radeon,amdgpu} when a device is probed, and abort if it
|
|
|
|
is missing, except for the pre-R600 case.
|
2013-01-08 03:27:57 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
--- a/drivers/gpu/drm/radeon/radeon_drv.c
|
|
|
|
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
|
2017-12-26 18:54:17 +00:00
|
|
|
@@ -43,6 +43,8 @@
|
|
|
|
#include <drm/drm_fb_helper.h>
|
2014-12-09 03:06:08 +00:00
|
|
|
|
2017-08-13 13:45:14 +00:00
|
|
|
#include <drm/drm_crtc_helper.h>
|
2013-01-08 03:27:57 +00:00
|
|
|
+#include <linux/namei.h>
|
|
|
|
+#include <linux/path.h>
|
2016-02-15 16:36:21 +00:00
|
|
|
|
2013-01-08 03:27:57 +00:00
|
|
|
/*
|
2013-12-21 18:20:34 +00:00
|
|
|
* KMS wrapper.
|
2018-03-14 18:55:39 +00:00
|
|
|
@@ -311,6 +313,28 @@ static struct drm_driver kms_driver;
|
2013-01-08 03:27:57 +00:00
|
|
|
|
2016-10-28 23:36:56 +00:00
|
|
|
bool radeon_device_is_virtual(void);
|
2013-01-08 03:27:57 +00:00
|
|
|
|
|
|
|
+/* Test that /lib/firmware/radeon is a directory (or symlink to a
|
|
|
|
+ * directory). We could try to match the udev search path, but let's
|
2018-03-14 18:55:39 +00:00
|
|
|
+ * keep it simple.
|
2013-01-08 03:27:57 +00:00
|
|
|
+ */
|
2013-02-25 03:35:39 +00:00
|
|
|
+static bool radeon_firmware_installed(void)
|
2013-01-08 03:27:57 +00:00
|
|
|
+{
|
2014-09-30 00:22:37 +00:00
|
|
|
+#if IS_BUILTIN(CONFIG_DRM_RADEON)
|
|
|
|
+ /* It may be too early to tell. Assume it's there. */
|
|
|
|
+ return true;
|
|
|
|
+#else
|
2013-01-08 03:27:57 +00:00
|
|
|
+ struct path path;
|
|
|
|
+
|
|
|
|
+ if (kern_path("/lib/firmware/radeon", LOOKUP_DIRECTORY | LOOKUP_FOLLOW,
|
|
|
|
+ &path) == 0) {
|
|
|
|
+ path_put(&path);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
2014-09-30 00:22:37 +00:00
|
|
|
+#endif
|
2013-01-08 03:27:57 +00:00
|
|
|
+}
|
|
|
|
+
|
2013-02-25 03:35:39 +00:00
|
|
|
static int radeon_kick_out_firmware_fb(struct pci_dev *pdev)
|
2013-01-08 03:27:57 +00:00
|
|
|
{
|
|
|
|
struct apertures_struct *ap;
|
2018-03-14 18:55:39 +00:00
|
|
|
@@ -340,6 +364,12 @@ static int radeon_pci_probe(struct pci_d
|
2016-08-28 18:52:50 +00:00
|
|
|
if (vga_switcheroo_client_probe_defer(pdev))
|
2016-04-14 13:59:13 +00:00
|
|
|
return -EPROBE_DEFER;
|
2013-02-25 03:35:39 +00:00
|
|
|
|
2013-01-08 03:27:57 +00:00
|
|
|
+ if ((ent->driver_data & RADEON_FAMILY_MASK) >= CHIP_R600 &&
|
|
|
|
+ !radeon_firmware_installed()) {
|
2018-03-14 18:55:39 +00:00
|
|
|
+ DRM_ERROR("radeon kernel modesetting for R600 or later requires firmware installed\n");
|
2013-01-08 03:27:57 +00:00
|
|
|
+ return -ENODEV;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
/* Get rid of things like offb */
|
2013-02-25 03:35:39 +00:00
|
|
|
ret = radeon_kick_out_firmware_fb(pdev);
|
|
|
|
if (ret)
|
2018-03-14 19:09:56 +00:00
|
|
|
--- 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
|