linux/debian/patches/debian/radeon-firmware-is-required...

96 lines
3.0 KiB
Diff

From: Ben Hutchings <ben@decadent.org.uk>
Subject: radeon: Firmware is required for DRM and KMS on R600 onward
Date: Tue, 08 Jan 2013 03:25:52 +0000
Bug-Debian: http://bugs.debian.org/607194
Bug-Debian: http://bugs.debian.org/607471
Bug-Debian: http://bugs.debian.org/610851
Bug-Debian: http://bugs.debian.org/627497
Bug-Debian: http://bugs.debian.org/632212
Bug-Debian: http://bugs.debian.org/637943
Bug-Debian: http://bugs.debian.org/649448
Bug-Debian: http://bugs.debian.org/697229
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.
This does not seem to happen if KMS is disabled, but with both KMS
and GPU acceleration disabled radeon is not doing anything useful!
Therefore, perform a basic check for the existence of
/lib/firmware/radeon when a device is probed, and abort if it is
missing, except for the pre-R600 KMS case.
---
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -37,6 +37,8 @@
#include "drm_pciids.h"
#include <linux/console.h>
#include <linux/module.h>
+#include <linux/namei.h>
+#include <linux/path.h>
/*
@@ -257,6 +259,35 @@ static struct drm_driver driver_old = {
static struct drm_driver kms_driver;
+/* 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
+ * assume people take the easy route and install
+ * firmware-linux-nonfree.
+ */
+static bool __devinit radeon_firmware_installed(void)
+{
+ struct path path;
+
+ if (kern_path("/lib/firmware/radeon", LOOKUP_DIRECTORY | LOOKUP_FOLLOW,
+ &path) == 0) {
+ path_put(&path);
+ return true;
+ }
+
+ return false;
+}
+
+static int __devinit
+radeon_ums_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+ if (!radeon_firmware_installed()) {
+ DRM_ERROR("radeon DRM requires firmware-linux-nonfree.\n");
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
static void radeon_kick_out_firmware_fb(struct pci_dev *pdev)
{
struct apertures_struct *ap;
@@ -276,6 +307,12 @@ static void radeon_kick_out_firmware_fb(
static int __devinit
radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
+ if ((ent->driver_data & RADEON_FAMILY_MASK) >= CHIP_R600 &&
+ !radeon_firmware_installed()) {
+ DRM_ERROR("radeon kernel modesetting for R600 or later requires firmware-linux-nonfree.\n");
+ return -ENODEV;
+ }
+
/* Get rid of things like offb */
radeon_kick_out_firmware_fb(pdev);
@@ -367,6 +404,7 @@ static struct pci_driver *pdriver;
static struct pci_driver radeon_pci_driver = {
.name = DRIVER_NAME,
.id_table = pciidlist,
+ .probe = radeon_ums_pci_probe,
};
static struct pci_driver radeon_kms_pci_driver = {