svn commit: r263170 - in stable/9/sys: contrib/dev/drm2 dev/drm2 dev/drm2/radeon dev/drm2/ttm modules/drm2 modules/drm2/drm2 modules/drm2/radeonkms modules/drm2/radeonkmsfw

Jean-Sebastien Pedron dumbbell at FreeBSD.org
Fri Mar 14 12:37:45 UTC 2014


Author: dumbbell
Date: Fri Mar 14 12:37:42 2014
New Revision: 263170
URL: http://svnweb.freebsd.org/changeset/base/263170

Log:
  MFC Radeon KMS driver
  
  FreeBSD 9 already had modern Intel GPUs support, now this is the case for
  Radeon GPUs too. This will ease the work on ports, where there won't be a
  need to distinguish between FreeBSD 9/10 and different hardware vendors.
  
  Help from:	jhb@, jkim@, kan@, kib@,
  		J.R. Oldroyd <fbsd at opal.com> (previous version of the patch)
  
  The following revisions were merged in this single commit:
  
  r254885:
    drm/radeon: Import the Radeon KMS driver
  
    This driver is based on Linux 3.8 and a previous effort by kan at .
  
    More informations about this project can be found on the FreeBSD wiki:
        https://wiki.freebsd.org/AMD_GPU
  
    The driver is split into:
  
      sys/dev/drm2:
        The driver sources.
  
      sys/modules/drm2/radeonkmw:
        The driver main kernel module's Makefile.
  
      sys/modules/drm2/radeonkmsfw:
        All firmware kernel module Makefiles. There's one directory and one
        Makefile for each firmware.
  
      sys/contrib/dev/drm2/radeonkmsfw:
        All firmware binary sources.
  
      tools/tools/drm/radeon
        Tools to update firmwares or regenerate some headers.
  
    Merging the driver to FreeBSD 9.x may be possible but not a priority for
    now.
  
    Help from:	kib@, kan@
    Tested by:	avg@, kwm@, ray@,
  		Alexander Yerenkow <yerenkow at gmail.com>,
  		Anders Bolt-Evensen <andersbo87 at me.com>,
  		Denis Djubajlo <stdedjub at googlemail.com>,
  		J.R. Oldroyd <fbsd at opal.com>,
  		Mikaël Urankar <mikael.urankar at gmail.com>,
  		Pierre-Emmanuel Pédron <pepcitron at gmail.com>,
  		Sam Fourman Jr. <sfourman at gmail.com>,
  		Wade <wade-is-great at live.com>,
  		(probably other I forgot...)
    HW donations:	kyzh, Yakaz
  
  r254894:
    drm/radeon: Rename the (S)DEBUG macros in atom.c to avoid conflicts
  
    For instance, DEBUG is already defined in the LINT kernel configuration.
    This fixes the build of LINT.
  
  r254899:
    drm/radeon: Disable build on i386/pc98
  
  r255572:
    drm/radeon: Fix usage of vga_pci_map_bios()
  
    vga_pci_(un)map_bios() takes a vgapci device as argument, not a drmn
    one. This fixes a bug where the BIOS couldn't be mapped if the device
    wasn't the boot display.
  
    Approved by:	re (kib; blanket for following drm2/radeon commits)
  
  r255573:
    drm/radeon: Fix usage of pci_save_state() and pci_restore_state()
  
    Calling those functions with the drmn device as argument causes a panic,
    because it's not a direct child of pci$N. They must be called with the
    vgapci device instead.
  
    This fix is not enough to make suspend/resume work reliably.
  
    Approved by:	re (blanket)
  
  r255587:
    drm/radeon: Add missing "return false" after unmapping invalid BIOS
  
    Without that, we would try to copy the unmapped BIOS.
  
    Submitted by:	Christoph Mallon <christoph.mallon at gmx.de>
    Approved by:	re (blanket)
  
  r256771:
    drm/radeon: radeonkms depends on firmware(9)
  
    Submitted by:	tijl@
  
  r257869:
    drm: Initialize "handle" to 0 before calling drm_gem_handle_create()
  
    This is variable is being checked in drm_gem_name_create() before being
    set.
  
  r257870:
    drm/radeon: Wake up userland after page flip
  
    For instance, this caused issues in KDE, such as stuttered animations
    (with desktop effects enabled).
  
  r259003:
    Initialize modesetting sysctls in radeonkms.
  
    This is intended for MFC if re@ permits.
  
    Reviewed by:	kib, dumbbell
    Tested by:	Steven Chamberlain <steven at pyro.eu.org>
    MFC after:	3 days
  
  r259101:
    drm/radeon: agp_info->ai_aperture_size is in bytes, not Mbytes
  
    This fixes radeon_agp_init() and gtt_size is now correct. However, this
    is not enough to make Radeon AGP cards work: ttm_agp_backend.c isn't
    implemented yet.
  
    Submitted by:	tijl@
  
  r259104:
    drm/radeon: radeon_dp_i2c_aux_ch() must return 0 on FreeBSD
  
    The code was unmodified compared to Linux and returned the amount of
    received bytes from the i2c bus. This led to non-working i2c bus and
    failure to eg. read monitor's EDID, if connected to DisplayPort.
  
    MFC after:	3 days
    Tested by:	Mikaël Urankar <mikael.urankar at gmail.com>
  
  r259684:
    drm/ttm, drm/radeon: Replace EINTR/ERESTART by ERESTARTSYS...
  
    ... for msleep/cv_*wait() return values, where wait_event*() is used
    on Linux. ERESTARTSYS is the return code expected by callers when the
    operation was interrupted.
  
    For instance, this is the case of radeon_cs_ioctl() (radeon_cs.c): if
    an error occurs, and the code isn't ERESTARTSYS (eg. EINTR), it logs an
    error.
  
    Note that ERESTARTSYS is defined as ERESTART, but this keeps callers'
    code close to Linux.
  
    Submitted by:	avg@ (previous version)
  
  r261497:
    Abort when firmware isn't present in R600+ models.
  
    More details at:
    http://anonscm.debian.org/viewvc/kernel/dists/trunk/linux/debian/patches/bugfix/all/radeon-firmware-is-required-for-drm-and-kms-on-r600-onward.patch?revision=20909&view=co
  
    Reviewed by:	dumbbell
    MFC after:	1 week

Added:
  stable/9/sys/contrib/dev/drm2/
     - copied from r254885, head/sys/contrib/dev/drm2/
  stable/9/sys/dev/drm2/ati_pcigart.c
     - copied unchanged from r254885, head/sys/dev/drm2/ati_pcigart.c
  stable/9/sys/dev/drm2/radeon/
     - copied from r254885, head/sys/dev/drm2/radeon/
  stable/9/sys/modules/drm2/radeonkms/
     - copied from r254885, head/sys/modules/drm2/radeonkms/
  stable/9/sys/modules/drm2/radeonkmsfw/
     - copied from r254885, head/sys/modules/drm2/radeonkmsfw/
Modified:
  stable/9/sys/dev/drm2/drm_crtc.c
  stable/9/sys/dev/drm2/radeon/atom.c
  stable/9/sys/dev/drm2/radeon/atombios_dp.c
  stable/9/sys/dev/drm2/radeon/r100.c
  stable/9/sys/dev/drm2/radeon/r300.c
  stable/9/sys/dev/drm2/radeon/r600.c
  stable/9/sys/dev/drm2/radeon/radeon_agp.c
  stable/9/sys/dev/drm2/radeon/radeon_bios.c
  stable/9/sys/dev/drm2/radeon/radeon_device.c
  stable/9/sys/dev/drm2/radeon/radeon_display.c
  stable/9/sys/dev/drm2/radeon/radeon_drv.c
  stable/9/sys/dev/drm2/radeon/radeon_fence.c
  stable/9/sys/dev/drm2/radeon/radeon_gem.c
  stable/9/sys/dev/drm2/radeon/radeon_sa.c
  stable/9/sys/dev/drm2/radeon/rs600.c
  stable/9/sys/dev/drm2/radeon/rs690.c
  stable/9/sys/dev/drm2/radeon/rv770.c
  stable/9/sys/dev/drm2/ttm/ttm_bo.c
  stable/9/sys/dev/drm2/ttm/ttm_lock.c
  stable/9/sys/modules/drm2/Makefile
  stable/9/sys/modules/drm2/drm2/Makefile
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)
  stable/9/sys/modules/   (props changed)

Copied: stable/9/sys/dev/drm2/ati_pcigart.c (from r254885, head/sys/dev/drm2/ati_pcigart.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/sys/dev/drm2/ati_pcigart.c	Fri Mar 14 12:37:42 2014	(r263170, copy of r254885, head/sys/dev/drm2/ati_pcigart.c)
@@ -0,0 +1,210 @@
+/**
+ * \file ati_pcigart.c
+ * ATI PCI GART support
+ *
+ * \author Gareth Hughes <gareth at valinux.com>
+ */
+
+/*
+ * Created: Wed Dec 13 21:52:19 2000 by gareth at valinux.com
+ *
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <dev/drm2/drmP.h>
+
+# define ATI_PCIGART_PAGE_SIZE		4096	/**< PCI GART page size */
+
+static int drm_ati_alloc_pcigart_table(struct drm_device *dev,
+				       struct drm_ati_pcigart_info *gart_info)
+{
+	gart_info->table_handle = drm_pci_alloc(dev, gart_info->table_size,
+						PAGE_SIZE, 0xFFFFFFFFUL);
+	if (gart_info->table_handle == NULL)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void drm_ati_free_pcigart_table(struct drm_device *dev,
+				       struct drm_ati_pcigart_info *gart_info)
+{
+	drm_pci_free(dev, gart_info->table_handle);
+	gart_info->table_handle = NULL;
+}
+
+int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info)
+{
+	struct drm_sg_mem *entry = dev->sg;
+#ifdef __linux__
+	unsigned long pages;
+	int i;
+	int max_pages;
+#endif
+
+	/* we need to support large memory configurations */
+	if (!entry) {
+		DRM_ERROR("no scatter/gather memory!\n");
+		return 0;
+	}
+
+	if (gart_info->bus_addr) {
+#ifdef __linux__
+
+		max_pages = (gart_info->table_size / sizeof(u32));
+		pages = (entry->pages <= max_pages)
+		  ? entry->pages : max_pages;
+
+		for (i = 0; i < pages; i++) {
+			if (!entry->busaddr[i])
+				break;
+			pci_unmap_page(dev->pdev, entry->busaddr[i],
+					 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
+		}
+#endif
+
+		if (gart_info->gart_table_location == DRM_ATI_GART_MAIN)
+			gart_info->bus_addr = 0;
+	}
+
+	if (gart_info->gart_table_location == DRM_ATI_GART_MAIN &&
+	    gart_info->table_handle) {
+		drm_ati_free_pcigart_table(dev, gart_info);
+	}
+
+	return 1;
+}
+
+int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info)
+{
+	struct drm_local_map *map = &gart_info->mapping;
+	struct drm_sg_mem *entry = dev->sg;
+	void *address = NULL;
+	unsigned long pages;
+	u32 *pci_gart = NULL, page_base, gart_idx;
+	dma_addr_t bus_address = 0;
+	int i, j, ret = 0;
+	int max_ati_pages, max_real_pages;
+
+	if (!entry) {
+		DRM_ERROR("no scatter/gather memory!\n");
+		goto done;
+	}
+
+	if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
+		DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n");
+
+#ifdef __linux__
+		if (pci_set_dma_mask(dev->pdev, gart_info->table_mask)) {
+			DRM_ERROR("fail to set dma mask to 0x%Lx\n",
+				  (unsigned long long)gart_info->table_mask);
+			ret = 1;
+			goto done;
+		}
+#endif
+
+		ret = drm_ati_alloc_pcigart_table(dev, gart_info);
+		if (ret) {
+			DRM_ERROR("cannot allocate PCI GART page!\n");
+			goto done;
+		}
+
+		pci_gart = gart_info->table_handle->vaddr;
+		address = gart_info->table_handle->vaddr;
+		bus_address = gart_info->table_handle->busaddr;
+	} else {
+		address = gart_info->addr;
+		bus_address = gart_info->bus_addr;
+		DRM_DEBUG("PCI: Gart Table: VRAM %08LX mapped at %08lX\n",
+			  (unsigned long long)bus_address,
+			  (unsigned long)address);
+	}
+
+
+	max_ati_pages = (gart_info->table_size / sizeof(u32));
+	max_real_pages = max_ati_pages / (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE);
+	pages = (entry->pages <= max_real_pages)
+	    ? entry->pages : max_real_pages;
+
+	if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
+		memset(pci_gart, 0, max_ati_pages * sizeof(u32));
+	} else {
+		memset_io((void __iomem *)map->handle, 0, max_ati_pages * sizeof(u32));
+	}
+
+	gart_idx = 0;
+	for (i = 0; i < pages; i++) {
+#ifdef __linux__
+		/* we need to support large memory configurations */
+		entry->busaddr[i] = pci_map_page(dev->pdev, entry->pagelist[i],
+						 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
+		if (pci_dma_mapping_error(dev->pdev, entry->busaddr[i])) {
+			DRM_ERROR("unable to map PCIGART pages!\n");
+			drm_ati_pcigart_cleanup(dev, gart_info);
+			address = NULL;
+			bus_address = 0;
+			goto done;
+		}
+#endif
+		page_base = (u32) entry->busaddr[i];
+
+		for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
+			u32 val;
+
+			switch(gart_info->gart_reg_if) {
+			case DRM_ATI_GART_IGP:
+				val = page_base | 0xc;
+				break;
+			case DRM_ATI_GART_PCIE:
+				val = (page_base >> 8) | 0xc;
+				break;
+			default:
+			case DRM_ATI_GART_PCI:
+				val = page_base;
+				break;
+			}
+			if (gart_info->gart_table_location ==
+			    DRM_ATI_GART_MAIN)
+				pci_gart[gart_idx] = cpu_to_le32(val);
+			else
+				DRM_WRITE32(map, gart_idx * sizeof(u32), val);
+			gart_idx++;
+			page_base += ATI_PCIGART_PAGE_SIZE;
+		}
+	}
+	ret = 1;
+
+#if defined(__i386) || defined(__amd64)
+	wbinvd();
+#else
+	mb();
+#endif
+
+      done:
+	gart_info->addr = address;
+	gart_info->bus_addr = bus_address;
+	return ret;
+}

Modified: stable/9/sys/dev/drm2/drm_crtc.c
==============================================================================
--- stable/9/sys/dev/drm2/drm_crtc.c	Fri Mar 14 12:15:28 2014	(r263169)
+++ stable/9/sys/dev/drm2/drm_crtc.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -2317,6 +2317,7 @@ int drm_mode_getfb(struct drm_device *de
 	r->depth = fb->depth;
 	r->bpp = fb->bits_per_pixel;
 	r->pitch = fb->pitches[0];
+	r->handle = 0;
 	fb->funcs->create_handle(fb, file_priv, &r->handle);
 
 out:

Modified: stable/9/sys/dev/drm2/radeon/atom.c
==============================================================================
--- head/sys/dev/drm2/radeon/atom.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/atom.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -89,11 +89,11 @@ static void debug_print_spaces(int n)
 		printf("   ");
 }
 
-#define DEBUG(...) do if (atom_debug) { printf(__FILE__ __VA_ARGS__); } while (0)
-#define SDEBUG(...) do if (atom_debug) { printf(__FILE__); debug_print_spaces(debug_depth); printf(__VA_ARGS__); } while (0)
+#define ATOM_DEBUG_PRINT(...) do if (atom_debug) { printf(__FILE__ __VA_ARGS__); } while (0)
+#define ATOM_SDEBUG_PRINT(...) do if (atom_debug) { printf(__FILE__); debug_print_spaces(debug_depth); printf(__VA_ARGS__); } while (0)
 #else
-#define DEBUG(...) do { } while (0)
-#define SDEBUG(...) do { } while (0)
+#define ATOM_DEBUG_PRINT(...) do { } while (0)
+#define ATOM_SDEBUG_PRINT(...) do { } while (0)
 #endif
 
 static uint32_t atom_iio_execute(struct atom_context *ctx, int base,
@@ -183,7 +183,7 @@ static uint32_t atom_get_src_int(atom_ex
 		idx = U16(*ptr);
 		(*ptr) += 2;
 		if (print)
-			DEBUG("REG[0x%04X]", idx);
+			ATOM_DEBUG_PRINT("REG[0x%04X]", idx);
 		idx += gctx->reg_block;
 		switch (gctx->io_mode) {
 		case ATOM_IO_MM:
@@ -221,13 +221,13 @@ static uint32_t atom_get_src_int(atom_ex
 		 * tables, noticed on a DEC Alpha. */
 		val = get_unaligned_le32((u32 *)&ctx->ps[idx]);
 		if (print)
-			DEBUG("PS[0x%02X,0x%04X]", idx, val);
+			ATOM_DEBUG_PRINT("PS[0x%02X,0x%04X]", idx, val);
 		break;
 	case ATOM_ARG_WS:
 		idx = U8(*ptr);
 		(*ptr)++;
 		if (print)
-			DEBUG("WS[0x%02X]", idx);
+			ATOM_DEBUG_PRINT("WS[0x%02X]", idx);
 		switch (idx) {
 		case ATOM_WS_QUOTIENT:
 			val = gctx->divmul[0];
@@ -265,9 +265,9 @@ static uint32_t atom_get_src_int(atom_ex
 		(*ptr) += 2;
 		if (print) {
 			if (gctx->data_block)
-				DEBUG("ID[0x%04X+%04X]", idx, gctx->data_block);
+				ATOM_DEBUG_PRINT("ID[0x%04X+%04X]", idx, gctx->data_block);
 			else
-				DEBUG("ID[0x%04X]", idx);
+				ATOM_DEBUG_PRINT("ID[0x%04X]", idx);
 		}
 		val = U32(idx + gctx->data_block);
 		break;
@@ -281,7 +281,7 @@ static uint32_t atom_get_src_int(atom_ex
 		} else
 			val = gctx->scratch[(gctx->fb_base / 4) + idx];
 		if (print)
-			DEBUG("FB[0x%02X]", idx);
+			ATOM_DEBUG_PRINT("FB[0x%02X]", idx);
 		break;
 	case ATOM_ARG_IMM:
 		switch (align) {
@@ -289,7 +289,7 @@ static uint32_t atom_get_src_int(atom_ex
 			val = U32(*ptr);
 			(*ptr) += 4;
 			if (print)
-				DEBUG("IMM 0x%08X\n", val);
+				ATOM_DEBUG_PRINT("IMM 0x%08X\n", val);
 			return val;
 		case ATOM_SRC_WORD0:
 		case ATOM_SRC_WORD8:
@@ -297,7 +297,7 @@ static uint32_t atom_get_src_int(atom_ex
 			val = U16(*ptr);
 			(*ptr) += 2;
 			if (print)
-				DEBUG("IMM 0x%04X\n", val);
+				ATOM_DEBUG_PRINT("IMM 0x%04X\n", val);
 			return val;
 		case ATOM_SRC_BYTE0:
 		case ATOM_SRC_BYTE8:
@@ -306,7 +306,7 @@ static uint32_t atom_get_src_int(atom_ex
 			val = U8(*ptr);
 			(*ptr)++;
 			if (print)
-				DEBUG("IMM 0x%02X\n", val);
+				ATOM_DEBUG_PRINT("IMM 0x%02X\n", val);
 			return val;
 		}
 		return 0;
@@ -314,14 +314,14 @@ static uint32_t atom_get_src_int(atom_ex
 		idx = U8(*ptr);
 		(*ptr)++;
 		if (print)
-			DEBUG("PLL[0x%02X]", idx);
+			ATOM_DEBUG_PRINT("PLL[0x%02X]", idx);
 		val = gctx->card->pll_read(gctx->card, idx);
 		break;
 	case ATOM_ARG_MC:
 		idx = U8(*ptr);
 		(*ptr)++;
 		if (print)
-			DEBUG("MC[0x%02X]", idx);
+			ATOM_DEBUG_PRINT("MC[0x%02X]", idx);
 		val = gctx->card->mc_read(gctx->card, idx);
 		break;
 	}
@@ -332,28 +332,28 @@ static uint32_t atom_get_src_int(atom_ex
 	if (print)
 		switch (align) {
 		case ATOM_SRC_DWORD:
-			DEBUG(".[31:0] -> 0x%08X\n", val);
+			ATOM_DEBUG_PRINT(".[31:0] -> 0x%08X\n", val);
 			break;
 		case ATOM_SRC_WORD0:
-			DEBUG(".[15:0] -> 0x%04X\n", val);
+			ATOM_DEBUG_PRINT(".[15:0] -> 0x%04X\n", val);
 			break;
 		case ATOM_SRC_WORD8:
-			DEBUG(".[23:8] -> 0x%04X\n", val);
+			ATOM_DEBUG_PRINT(".[23:8] -> 0x%04X\n", val);
 			break;
 		case ATOM_SRC_WORD16:
-			DEBUG(".[31:16] -> 0x%04X\n", val);
+			ATOM_DEBUG_PRINT(".[31:16] -> 0x%04X\n", val);
 			break;
 		case ATOM_SRC_BYTE0:
-			DEBUG(".[7:0] -> 0x%02X\n", val);
+			ATOM_DEBUG_PRINT(".[7:0] -> 0x%02X\n", val);
 			break;
 		case ATOM_SRC_BYTE8:
-			DEBUG(".[15:8] -> 0x%02X\n", val);
+			ATOM_DEBUG_PRINT(".[15:8] -> 0x%02X\n", val);
 			break;
 		case ATOM_SRC_BYTE16:
-			DEBUG(".[23:16] -> 0x%02X\n", val);
+			ATOM_DEBUG_PRINT(".[23:16] -> 0x%02X\n", val);
 			break;
 		case ATOM_SRC_BYTE24:
-			DEBUG(".[31:24] -> 0x%02X\n", val);
+			ATOM_DEBUG_PRINT(".[31:24] -> 0x%02X\n", val);
 			break;
 		}
 	return val;
@@ -458,7 +458,7 @@ static void atom_put_dst(atom_exec_conte
 	case ATOM_ARG_REG:
 		idx = U16(*ptr);
 		(*ptr) += 2;
-		DEBUG("REG[0x%04X]", idx);
+		ATOM_DEBUG_PRINT("REG[0x%04X]", idx);
 		idx += gctx->reg_block;
 		switch (gctx->io_mode) {
 		case ATOM_IO_MM:
@@ -494,13 +494,13 @@ static void atom_put_dst(atom_exec_conte
 	case ATOM_ARG_PS:
 		idx = U8(*ptr);
 		(*ptr)++;
-		DEBUG("PS[0x%02X]", idx);
+		ATOM_DEBUG_PRINT("PS[0x%02X]", idx);
 		ctx->ps[idx] = cpu_to_le32(val);
 		break;
 	case ATOM_ARG_WS:
 		idx = U8(*ptr);
 		(*ptr)++;
-		DEBUG("WS[0x%02X]", idx);
+		ATOM_DEBUG_PRINT("WS[0x%02X]", idx);
 		switch (idx) {
 		case ATOM_WS_QUOTIENT:
 			gctx->divmul[0] = val;
@@ -538,45 +538,45 @@ static void atom_put_dst(atom_exec_conte
 				  gctx->fb_base + (idx * 4), gctx->scratch_size_bytes);
 		} else
 			gctx->scratch[(gctx->fb_base / 4) + idx] = val;
-		DEBUG("FB[0x%02X]", idx);
+		ATOM_DEBUG_PRINT("FB[0x%02X]", idx);
 		break;
 	case ATOM_ARG_PLL:
 		idx = U8(*ptr);
 		(*ptr)++;
-		DEBUG("PLL[0x%02X]", idx);
+		ATOM_DEBUG_PRINT("PLL[0x%02X]", idx);
 		gctx->card->pll_write(gctx->card, idx, val);
 		break;
 	case ATOM_ARG_MC:
 		idx = U8(*ptr);
 		(*ptr)++;
-		DEBUG("MC[0x%02X]", idx);
+		ATOM_DEBUG_PRINT("MC[0x%02X]", idx);
 		gctx->card->mc_write(gctx->card, idx, val);
 		return;
 	}
 	switch (align) {
 	case ATOM_SRC_DWORD:
-		DEBUG(".[31:0] <- 0x%08X\n", old_val);
+		ATOM_DEBUG_PRINT(".[31:0] <- 0x%08X\n", old_val);
 		break;
 	case ATOM_SRC_WORD0:
-		DEBUG(".[15:0] <- 0x%04X\n", old_val);
+		ATOM_DEBUG_PRINT(".[15:0] <- 0x%04X\n", old_val);
 		break;
 	case ATOM_SRC_WORD8:
-		DEBUG(".[23:8] <- 0x%04X\n", old_val);
+		ATOM_DEBUG_PRINT(".[23:8] <- 0x%04X\n", old_val);
 		break;
 	case ATOM_SRC_WORD16:
-		DEBUG(".[31:16] <- 0x%04X\n", old_val);
+		ATOM_DEBUG_PRINT(".[31:16] <- 0x%04X\n", old_val);
 		break;
 	case ATOM_SRC_BYTE0:
-		DEBUG(".[7:0] <- 0x%02X\n", old_val);
+		ATOM_DEBUG_PRINT(".[7:0] <- 0x%02X\n", old_val);
 		break;
 	case ATOM_SRC_BYTE8:
-		DEBUG(".[15:8] <- 0x%02X\n", old_val);
+		ATOM_DEBUG_PRINT(".[15:8] <- 0x%02X\n", old_val);
 		break;
 	case ATOM_SRC_BYTE16:
-		DEBUG(".[23:16] <- 0x%02X\n", old_val);
+		ATOM_DEBUG_PRINT(".[23:16] <- 0x%02X\n", old_val);
 		break;
 	case ATOM_SRC_BYTE24:
-		DEBUG(".[31:24] <- 0x%02X\n", old_val);
+		ATOM_DEBUG_PRINT(".[31:24] <- 0x%02X\n", old_val);
 		break;
 	}
 }
@@ -586,12 +586,12 @@ static void atom_op_add(atom_exec_contex
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, src, saved;
 	int dptr = *ptr;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
-	SDEBUG("   src: ");
+	ATOM_SDEBUG_PRINT("   src: ");
 	src = atom_get_src(ctx, attr, ptr);
 	dst += src;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
@@ -600,12 +600,12 @@ static void atom_op_and(atom_exec_contex
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, src, saved;
 	int dptr = *ptr;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
-	SDEBUG("   src: ");
+	ATOM_SDEBUG_PRINT("   src: ");
 	src = atom_get_src(ctx, attr, ptr);
 	dst &= src;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
@@ -620,9 +620,9 @@ static void atom_op_calltable(atom_exec_
 	int r = 0;
 
 	if (idx < ATOM_TABLE_NAMES_CNT)
-		SDEBUG("   table: %d (%s)\n", idx, atom_table_names[idx]);
+		ATOM_SDEBUG_PRINT("   table: %d (%s)\n", idx, atom_table_names[idx]);
 	else
-		SDEBUG("   table: %d\n", idx);
+		ATOM_SDEBUG_PRINT("   table: %d\n", idx);
 	if (U16(ctx->ctx->cmd_table + 4 + 2 * idx))
 		r = atom_execute_table_locked(ctx->ctx, idx, ctx->ps + ctx->ps_shift);
 	if (r) {
@@ -638,7 +638,7 @@ static void atom_op_clear(atom_exec_cont
 	attr &= 0x38;
 	attr |= atom_def_dst[attr >> 3] << 6;
 	atom_get_dst(ctx, arg, attr, ptr, &saved, 0);
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, 0, saved);
 }
 
@@ -646,20 +646,20 @@ static void atom_op_compare(atom_exec_co
 {
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, src;
-	SDEBUG("   src1: ");
+	ATOM_SDEBUG_PRINT("   src1: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, NULL, 1);
-	SDEBUG("   src2: ");
+	ATOM_SDEBUG_PRINT("   src2: ");
 	src = atom_get_src(ctx, attr, ptr);
 	ctx->ctx->cs_equal = (dst == src);
 	ctx->ctx->cs_above = (dst > src);
-	SDEBUG("   result: %s %s\n", ctx->ctx->cs_equal ? "EQ" : "NE",
+	ATOM_SDEBUG_PRINT("   result: %s %s\n", ctx->ctx->cs_equal ? "EQ" : "NE",
 	       ctx->ctx->cs_above ? "GT" : "LE");
 }
 
 static void atom_op_delay(atom_exec_context *ctx, int *ptr, int arg)
 {
 	unsigned count = U8((*ptr)++);
-	SDEBUG("   count: %d\n", count);
+	ATOM_SDEBUG_PRINT("   count: %d\n", count);
 	if (arg == ATOM_UNIT_MICROSEC)
 		DRM_UDELAY(count);
 	else if (!drm_can_sleep())
@@ -672,9 +672,9 @@ static void atom_op_div(atom_exec_contex
 {
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, src;
-	SDEBUG("   src1: ");
+	ATOM_SDEBUG_PRINT("   src1: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, NULL, 1);
-	SDEBUG("   src2: ");
+	ATOM_SDEBUG_PRINT("   src2: ");
 	src = atom_get_src(ctx, attr, ptr);
 	if (src != 0) {
 		ctx->ctx->divmul[0] = dst / src;
@@ -720,8 +720,8 @@ static void atom_op_jump(atom_exec_conte
 		break;
 	}
 	if (arg != ATOM_COND_ALWAYS)
-		SDEBUG("   taken: %s\n", execute ? "yes" : "no");
-	SDEBUG("   target: 0x%04X\n", target);
+		ATOM_SDEBUG_PRINT("   taken: %s\n", execute ? "yes" : "no");
+	ATOM_SDEBUG_PRINT("   target: 0x%04X\n", target);
 	if (execute) {
 		if (ctx->last_jump == (ctx->start + target)) {
 			cjiffies = jiffies;
@@ -748,15 +748,15 @@ static void atom_op_mask(atom_exec_conte
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, mask, src, saved;
 	int dptr = *ptr;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
 	mask = atom_get_src_direct(ctx, ((attr >> 3) & 7), ptr);
-	SDEBUG("   mask: 0x%08x", mask);
-	SDEBUG("   src: ");
+	ATOM_SDEBUG_PRINT("   mask: 0x%08x", mask);
+	ATOM_SDEBUG_PRINT("   src: ");
 	src = atom_get_src(ctx, attr, ptr);
 	dst &= mask;
 	dst |= src;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
@@ -771,9 +771,9 @@ static void atom_op_move(atom_exec_conte
 		atom_skip_dst(ctx, arg, attr, ptr);
 		saved = 0xCDCDCDCD;
 	}
-	SDEBUG("   src: ");
+	ATOM_SDEBUG_PRINT("   src: ");
 	src = atom_get_src(ctx, attr, ptr);
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, src, saved);
 }
 
@@ -781,9 +781,9 @@ static void atom_op_mul(atom_exec_contex
 {
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, src;
-	SDEBUG("   src1: ");
+	ATOM_SDEBUG_PRINT("   src1: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, NULL, 1);
-	SDEBUG("   src2: ");
+	ATOM_SDEBUG_PRINT("   src2: ");
 	src = atom_get_src(ctx, attr, ptr);
 	ctx->ctx->divmul[0] = dst * src;
 }
@@ -798,19 +798,19 @@ static void atom_op_or(atom_exec_context
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, src, saved;
 	int dptr = *ptr;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
-	SDEBUG("   src: ");
+	ATOM_SDEBUG_PRINT("   src: ");
 	src = atom_get_src(ctx, attr, ptr);
 	dst |= src;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
 static void atom_op_postcard(atom_exec_context *ctx, int *ptr, int arg)
 {
 	uint8_t val = U8((*ptr)++);
-	SDEBUG("POST card output: 0x%02X\n", val);
+	ATOM_SDEBUG_PRINT("POST card output: 0x%02X\n", val);
 }
 
 static void atom_op_repeat(atom_exec_context *ctx, int *ptr, int arg)
@@ -832,20 +832,20 @@ static void atom_op_setdatablock(atom_ex
 {
 	int idx = U8(*ptr);
 	(*ptr)++;
-	SDEBUG("   block: %d\n", idx);
+	ATOM_SDEBUG_PRINT("   block: %d\n", idx);
 	if (!idx)
 		ctx->ctx->data_block = 0;
 	else if (idx == 255)
 		ctx->ctx->data_block = ctx->start;
 	else
 		ctx->ctx->data_block = U16(ctx->ctx->data_table + 4 + 2 * idx);
-	SDEBUG("   base: 0x%04X\n", ctx->ctx->data_block);
+	ATOM_SDEBUG_PRINT("   base: 0x%04X\n", ctx->ctx->data_block);
 }
 
 static void atom_op_setfbbase(atom_exec_context *ctx, int *ptr, int arg)
 {
 	uint8_t attr = U8((*ptr)++);
-	SDEBUG("   fb_base: ");
+	ATOM_SDEBUG_PRINT("   fb_base: ");
 	ctx->ctx->fb_base = atom_get_src(ctx, attr, ptr);
 }
 
@@ -856,9 +856,9 @@ static void atom_op_setport(atom_exec_co
 	case ATOM_PORT_ATI:
 		port = U16(*ptr);
 		if (port < ATOM_IO_NAMES_CNT)
-			SDEBUG("   port: %d (%s)\n", port, atom_io_names[port]);
+			ATOM_SDEBUG_PRINT("   port: %d (%s)\n", port, atom_io_names[port]);
 		else
-			SDEBUG("   port: %d\n", port);
+			ATOM_SDEBUG_PRINT("   port: %d\n", port);
 		if (!port)
 			ctx->ctx->io_mode = ATOM_IO_MM;
 		else
@@ -880,7 +880,7 @@ static void atom_op_setregblock(atom_exe
 {
 	ctx->ctx->reg_block = U16(*ptr);
 	(*ptr) += 2;
-	SDEBUG("   base: 0x%04X\n", ctx->ctx->reg_block);
+	ATOM_SDEBUG_PRINT("   base: 0x%04X\n", ctx->ctx->reg_block);
 }
 
 static void atom_op_shift_left(atom_exec_context *ctx, int *ptr, int arg)
@@ -890,12 +890,12 @@ static void atom_op_shift_left(atom_exec
 	int dptr = *ptr;
 	attr &= 0x38;
 	attr |= atom_def_dst[attr >> 3] << 6;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
 	shift = atom_get_src_direct(ctx, ATOM_SRC_BYTE0, ptr);
-	SDEBUG("   shift: %d\n", shift);
+	ATOM_SDEBUG_PRINT("   shift: %d\n", shift);
 	dst <<= shift;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
@@ -906,12 +906,12 @@ static void atom_op_shift_right(atom_exe
 	int dptr = *ptr;
 	attr &= 0x38;
 	attr |= atom_def_dst[attr >> 3] << 6;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
 	shift = atom_get_src_direct(ctx, ATOM_SRC_BYTE0, ptr);
-	SDEBUG("   shift: %d\n", shift);
+	ATOM_SDEBUG_PRINT("   shift: %d\n", shift);
 	dst >>= shift;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
@@ -921,16 +921,16 @@ static void atom_op_shl(atom_exec_contex
 	uint32_t saved, dst;
 	int dptr = *ptr;
 	uint32_t dst_align = atom_dst_to_src[(attr >> 3) & 7][(attr >> 6) & 3];
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
 	/* op needs to full dst value */
 	dst = saved;
 	shift = atom_get_src(ctx, attr, ptr);
-	SDEBUG("   shift: %d\n", shift);
+	ATOM_SDEBUG_PRINT("   shift: %d\n", shift);
 	dst <<= shift;
 	dst &= atom_arg_mask[dst_align];
 	dst >>= atom_arg_shift[dst_align];
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
@@ -940,16 +940,16 @@ static void atom_op_shr(atom_exec_contex
 	uint32_t saved, dst;
 	int dptr = *ptr;
 	uint32_t dst_align = atom_dst_to_src[(attr >> 3) & 7][(attr >> 6) & 3];
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
 	/* op needs to full dst value */
 	dst = saved;
 	shift = atom_get_src(ctx, attr, ptr);
-	SDEBUG("   shift: %d\n", shift);
+	ATOM_SDEBUG_PRINT("   shift: %d\n", shift);
 	dst >>= shift;
 	dst &= atom_arg_mask[dst_align];
 	dst >>= atom_arg_shift[dst_align];
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
@@ -958,12 +958,12 @@ static void atom_op_sub(atom_exec_contex
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, src, saved;
 	int dptr = *ptr;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
-	SDEBUG("   src: ");
+	ATOM_SDEBUG_PRINT("   src: ");
 	src = atom_get_src(ctx, attr, ptr);
 	dst -= src;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
@@ -971,18 +971,18 @@ static void atom_op_switch(atom_exec_con
 {
 	uint8_t attr = U8((*ptr)++);
 	uint32_t src, val, target;
-	SDEBUG("   switch: ");
+	ATOM_SDEBUG_PRINT("   switch: ");
 	src = atom_get_src(ctx, attr, ptr);
 	while (U16(*ptr) != ATOM_CASE_END)
 		if (U8(*ptr) == ATOM_CASE_MAGIC) {
 			(*ptr)++;
-			SDEBUG("   case: ");
+			ATOM_SDEBUG_PRINT("   case: ");
 			val =
 			    atom_get_src(ctx, (attr & 0x38) | ATOM_ARG_IMM,
 					 ptr);
 			target = U16(*ptr);
 			if (val == src) {
-				SDEBUG("   target: %04X\n", target);
+				ATOM_SDEBUG_PRINT("   target: %04X\n", target);
 				*ptr = ctx->start + target;
 				return;
 			}
@@ -998,12 +998,12 @@ static void atom_op_test(atom_exec_conte
 {
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, src;
-	SDEBUG("   src1: ");
+	ATOM_SDEBUG_PRINT("   src1: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, NULL, 1);
-	SDEBUG("   src2: ");
+	ATOM_SDEBUG_PRINT("   src2: ");
 	src = atom_get_src(ctx, attr, ptr);
 	ctx->ctx->cs_equal = ((dst & src) == 0);
-	SDEBUG("   result: %s\n", ctx->ctx->cs_equal ? "EQ" : "NE");
+	ATOM_SDEBUG_PRINT("   result: %s\n", ctx->ctx->cs_equal ? "EQ" : "NE");
 }
 
 static void atom_op_xor(atom_exec_context *ctx, int *ptr, int arg)
@@ -1011,12 +1011,12 @@ static void atom_op_xor(atom_exec_contex
 	uint8_t attr = U8((*ptr)++);
 	uint32_t dst, src, saved;
 	int dptr = *ptr;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
-	SDEBUG("   src: ");
+	ATOM_SDEBUG_PRINT("   src: ");
 	src = atom_get_src(ctx, attr, ptr);
 	dst ^= src;
-	SDEBUG("   dst: ");
+	ATOM_SDEBUG_PRINT("   dst: ");
 	atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
 }
 
@@ -1169,7 +1169,7 @@ static int atom_execute_table_locked(str
 	ps = CU8(base + ATOM_CT_PS_PTR) & ATOM_CT_PS_MASK;
 	ptr = base + ATOM_CT_CODE_PTR;
 
-	SDEBUG(">> execute %04X (len %d, WS %d, PS %d)\n", base, len, ws, ps);
+	ATOM_SDEBUG_PRINT(">> execute %04X (len %d, WS %d, PS %d)\n", base, len, ws, ps);
 
 	ectx.ctx = ctx;
 	ectx.ps_shift = ps / 4;
@@ -1186,9 +1186,9 @@ static int atom_execute_table_locked(str
 	while (1) {
 		op = CU8(ptr++);
 		if (op < ATOM_OP_NAMES_CNT)
-			SDEBUG("%s @ 0x%04X\n", atom_op_names[op], ptr - 1);
+			ATOM_SDEBUG_PRINT("%s @ 0x%04X\n", atom_op_names[op], ptr - 1);
 		else
-			SDEBUG("[%d] @ 0x%04X\n", op, ptr - 1);
+			ATOM_SDEBUG_PRINT("[%d] @ 0x%04X\n", op, ptr - 1);
 		if (ectx.abort) {
 			DRM_ERROR("atombios stuck executing %04X (len %d, WS %d, PS %d) @ 0x%04X\n",
 				base, len, ws, ps, ptr - 1);
@@ -1206,7 +1206,7 @@ static int atom_execute_table_locked(str
 			break;
 	}
 	debug_depth--;
-	SDEBUG("<<\n");
+	ATOM_SDEBUG_PRINT("<<\n");
 
 free:
 	if (ws)

Modified: stable/9/sys/dev/drm2/radeon/atombios_dp.c
==============================================================================
--- head/sys/dev/drm2/radeon/atombios_dp.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/atombios_dp.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -272,7 +272,7 @@ int radeon_dp_i2c_aux_ch(device_t dev, i
 		case AUX_I2C_REPLY_ACK:
 			if (mode == MODE_I2C_READ)
 				*read_byte = reply[0];
-			return ret;
+			return (0); /* Return ret on Linux. */
 		case AUX_I2C_REPLY_NACK:
 			DRM_DEBUG_KMS("aux_i2c nack\n");
 			return -EREMOTEIO;

Modified: stable/9/sys/dev/drm2/radeon/r100.c
==============================================================================
--- head/sys/dev/drm2/radeon/r100.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/r100.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -2647,7 +2647,7 @@ int r100_asic_reset(struct radeon_device
 	WREG32(RADEON_CP_RB_WPTR, 0);
 	WREG32(RADEON_CP_RB_CNTL, tmp);
 	/* save PCI state */
-	pci_save_state(rdev->dev);
+	pci_save_state(device_get_parent(rdev->dev));
 	/* disable bus mastering */
 	r100_bm_disable(rdev);
 	WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_SE(1) |
@@ -2669,7 +2669,7 @@ int r100_asic_reset(struct radeon_device
 	status = RREG32(R_000E40_RBBM_STATUS);
 	dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
 	/* restore PCI & busmastering */
-	pci_restore_state(rdev->dev);
+	pci_restore_state(device_get_parent(rdev->dev));
 	r100_enable_bm(rdev);
 	/* Check if GPU is idle */
 	if (G_000E40_SE_BUSY(status) || G_000E40_RE_BUSY(status) ||

Modified: stable/9/sys/dev/drm2/radeon/r300.c
==============================================================================
--- head/sys/dev/drm2/radeon/r300.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/r300.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -401,7 +401,7 @@ int r300_asic_reset(struct radeon_device
 	WREG32(RADEON_CP_RB_WPTR, 0);
 	WREG32(RADEON_CP_RB_CNTL, tmp);
 	/* save PCI state */
-	pci_save_state(rdev->dev);
+	pci_save_state(device_get_parent(rdev->dev));
 	/* disable bus mastering */
 	r100_bm_disable(rdev);
 	WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_VAP(1) |
@@ -425,7 +425,7 @@ int r300_asic_reset(struct radeon_device
 	status = RREG32(R_000E40_RBBM_STATUS);
 	dev_info(rdev->dev, "(%s:%d) RBBM_STATUS=0x%08X\n", __func__, __LINE__, status);
 	/* restore PCI & busmastering */
-	pci_restore_state(rdev->dev);
+	pci_restore_state(device_get_parent(rdev->dev));
 	r100_enable_bm(rdev);
 	/* Check if GPU is idle */
 	if (G_000E40_GA_BUSY(status) || G_000E40_VAP_BUSY(status)) {

Modified: stable/9/sys/dev/drm2/radeon/r600.c
==============================================================================
--- head/sys/dev/drm2/radeon/r600.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/r600.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -3012,6 +3012,12 @@ int r600_init(struct radeon_device *rdev
 		rdev->accel_working = false;
 	}
 
+	/* Don't start up if the ucode is missing. */
+	if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
+		DRM_ERROR("radeon: ucode required for R600+.\n");
+		return -EINVAL;
+	}
+
 	return 0;
 }
 

Modified: stable/9/sys/dev/drm2/radeon/radeon_agp.c
==============================================================================
--- head/sys/dev/drm2/radeon/radeon_agp.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/radeon_agp.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -153,11 +153,11 @@ int radeon_agp_init(struct radeon_device
 		return ret;
 	}
 
-	if (rdev->ddev->agp->info.ai_aperture_size < 32) {
+	if ((rdev->ddev->agp->info.ai_aperture_size >> 20) < 32) {
 		drm_agp_release(rdev->ddev);
 		dev_warn(rdev->dev, "AGP aperture too small (%zuM) "
 			"need at least 32M, disabling AGP\n",
-			rdev->ddev->agp->info.ai_aperture_size);
+			rdev->ddev->agp->info.ai_aperture_size >> 20);
 		return -EINVAL;
 	}
 
@@ -246,7 +246,7 @@ int radeon_agp_init(struct radeon_device
 	}
 
 	rdev->mc.agp_base = rdev->ddev->agp->info.ai_aperture_base;
-	rdev->mc.gtt_size = rdev->ddev->agp->info.ai_aperture_size << 20;
+	rdev->mc.gtt_size = rdev->ddev->agp->info.ai_aperture_size;
 	rdev->mc.gtt_start = rdev->mc.agp_base;
 	rdev->mc.gtt_end = rdev->mc.gtt_start + rdev->mc.gtt_size - 1;
 	dev_info(rdev->dev, "GTT: %juM 0x%08jX - 0x%08jX\n",

Modified: stable/9/sys/dev/drm2/radeon/radeon_bios.c
==============================================================================
--- head/sys/dev/drm2/radeon/radeon_bios.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/radeon_bios.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -100,14 +100,16 @@ static bool igp_read_bios_from_vram(stru
 
 static bool radeon_read_bios(struct radeon_device *rdev)
 {
+	device_t vga_dev;
 	uint8_t __iomem *bios;
 	size_t size;
 
 	DRM_INFO("%s: ===> Try PCI Expansion ROM...\n", __func__);
 
+	vga_dev = device_get_parent(rdev->dev);
 	rdev->bios = NULL;
 	/* XXX: some cards may return 0 for rom size? ddx has a workaround */
-	bios = vga_pci_map_bios(rdev->dev, &size);
+	bios = vga_pci_map_bios(vga_dev, &size);
 	if (!bios) {
 		return false;
 	}
@@ -120,11 +122,12 @@ static bool radeon_read_bios(struct rade
 			DRM_INFO("%s: Incorrect BIOS signature: 0x%02X%02X\n",
 			    __func__, bios[0], bios[1]);
 		}
-		vga_pci_unmap_bios(rdev->dev, bios);
+		vga_pci_unmap_bios(vga_dev, bios);
+		return false;
 	}
 	rdev->bios = malloc(size, DRM_MEM_DRIVER, M_WAITOK);
 	memcpy(rdev->bios, bios, size);
-	vga_pci_unmap_bios(rdev->dev, bios);
+	vga_pci_unmap_bios(vga_dev, bios);
 	return true;
 }
 

Modified: stable/9/sys/dev/drm2/radeon/radeon_device.c
==============================================================================
--- head/sys/dev/drm2/radeon/radeon_device.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/radeon_device.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -1316,7 +1316,7 @@ int radeon_suspend_kms(struct drm_device
 
 	radeon_agp_suspend(rdev);
 
-	pci_save_state(dev->device);
+	pci_save_state(device_get_parent(rdev->dev));
 #ifdef DUMBBELL_WIP
 	if (state.event == PM_EVENT_SUSPEND) {
 		/* Shut down the device */
@@ -1356,7 +1356,7 @@ int radeon_resume_kms(struct drm_device 
 	console_lock();
 #endif /* DUMBBELL_WIP */
 	pci_set_powerstate(dev->device, PCI_POWERSTATE_D0);
-	pci_restore_state(dev->device);
+	pci_restore_state(device_get_parent(rdev->dev));
 #ifdef DUMBBELL_WIP
 	if (pci_enable_device(dev->pdev)) {
 		console_unlock();

Modified: stable/9/sys/dev/drm2/radeon/radeon_display.c
==============================================================================
--- head/sys/dev/drm2/radeon/radeon_display.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/radeon_display.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -336,9 +336,7 @@ void radeon_crtc_handle_flip(struct rade
 		e->event.tv_sec = now.tv_sec;
 		e->event.tv_usec = now.tv_usec;
 		list_add_tail(&e->base.link, &e->base.file_priv->event_list);
-#ifdef DUMBBELL_WIP
-		wake_up_interruptible(&e->base.file_priv->event_wait);
-#endif /* DUMBBELL_WIP */
+		drm_event_wakeup(&e->base);
 	}
 	DRM_SPINUNLOCK_IRQRESTORE(&rdev->ddev->event_lock, flags);
 

Modified: stable/9/sys/dev/drm2/radeon/radeon_drv.c
==============================================================================
--- head/sys/dev/drm2/radeon/radeon_drv.c	Sun Aug 25 19:37:15 2013	(r254885)
+++ stable/9/sys/dev/drm2/radeon/radeon_drv.c	Fri Mar 14 12:37:42 2014	(r263170)
@@ -338,6 +338,12 @@ static const struct file_operations rade
 };
 #endif /* DUMBBELL_WIP */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-stable-9 mailing list