Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Jun 2005 13:00:26 -0700
From:      Eric Anholt <eta@lclark.edu>
To:        Martin Cracauer <cracauer@cons.org>
Cc:        freebsd-current@freebsd.org, Adam K Kirchhoff <adamk@voicenet.com>, Warner Losh <imp@bsdimp.com>
Subject:   Re: 6.0-current panic: loading radeon module
Message-ID:  <1119816026.3817.20.camel@leguin>
In-Reply-To: <20050624195906.A5702@cons.org>
References:  <20050617173008.A11142@cons.org> <20050617194638.A13394@cons.org> <20050617.233055.41723867.imp@bsdimp.com> <200506241641.25433.jhb@FreeBSD.org> <1119650444.1173.105.camel@leguin> <20050624195906.A5702@cons.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Fri, 2005-06-24 at 19:59 -0400, Martin Cracauer wrote:
> > I'd forgotten about this thread.  I've got a proposed fix for this at:
> > http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/80718
> 
> I get the same panic and backtrace with that patch (on a 32 MB moobile
> Radeon 7500).
> 
> I will annotate the sourcecode now to verify (or not) the NULLs in the
> arguments for the bus argument.

OK, one more try, for everyone who's been having hangs/reboots on X
startup since April.  Attached is a patch that will hopefully kill the
problem off.

-- 
Eric Anholt                                     eta@lclark.edu
http://people.freebsd.org/~anholt/              anholt@FreeBSD.org

[-- Attachment #2 --]
Index: dev/drm/drmP.h
===================================================================
RCS file: /home/ncvs/src/sys/dev/drm/drmP.h,v
retrieving revision 1.13
diff -u -r1.13 drmP.h
--- dev/drm/drmP.h	16 Apr 2005 03:44:43 -0000	1.13
+++ dev/drm/drmP.h	26 Jun 2005 19:21:19 -0000
@@ -77,6 +77,7 @@
 #if __FreeBSD_version >= 500000
 #include <sys/mutex.h>
 #include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
 #include <sys/selinfo.h>
 #else /* __FreeBSD_version >= 500000 */
 #include <pci/pcivar.h>
Index: dev/drm/drm_bufs.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/drm/drm_bufs.c,v
retrieving revision 1.2
diff -u -r1.2 drm_bufs.c
--- dev/drm/drm_bufs.c	24 Apr 2005 19:03:32 -0000	1.2
+++ dev/drm/drm_bufs.c	26 Jun 2005 19:45:40 -0000
@@ -52,43 +52,33 @@
 
 unsigned long drm_get_resource_start(drm_device_t *dev, unsigned int resource)
 {
-	struct resource *bsr;
 	unsigned long offset;
+	unsigned long len;
+	int err;
 
-	resource = resource * 4 + 0x10;
-
-	bsr = bus_alloc_resource_any(dev->device, SYS_RES_MEMORY, &resource,
-	    RF_ACTIVE | RF_SHAREABLE);
-	if (bsr == NULL) {
-		DRM_ERROR("Couldn't find resource 0x%x\n", resource);
+	err = bus_get_resource(dev->device, SYS_RES_MEMORY, PCIR_BAR(resource),
+	    &offset, &len);
+	if (err != 0) {
+		DRM_ERROR("Failed to get start of resource 0x%x\n", resource);
 		return 0;
 	}
 
-	offset = rman_get_start(bsr);
-
-	bus_release_resource(dev->device, SYS_RES_MEMORY, resource, bsr);
-
 	return offset;
 }
 
 unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource)
 {
-	struct resource *bsr;
+	unsigned long offset;
 	unsigned long len;
+	int err;
 
-	resource = resource * 4 + 0x10;
-
-	bsr = bus_alloc_resource_any(dev->device, SYS_RES_MEMORY, &resource,
-	    RF_ACTIVE | RF_SHAREABLE);
-	if (bsr == NULL) {
-		DRM_ERROR("Couldn't find resource 0x%x\n", resource);
-		return ENOMEM;
+	err = bus_get_resource(dev->device, SYS_RES_MEMORY, PCIR_BAR(resource),
+	    &offset, &len);
+	if (err != 0) {
+		DRM_ERROR("Failed to get length of resource 0x%x\n", resource);
+		return 0;
 	}
 
-	len = rman_get_size(bsr);
-
-	bus_release_resource(dev->device, SYS_RES_MEMORY, resource, bsr);
-
 	return len;
 }
 
@@ -96,7 +86,6 @@
 		unsigned int resource, int type, int flags)
 {
 	drm_local_map_t *map;
-	struct resource *bsr;
 
 	if (type != _DRM_REGISTERS && type != _DRM_FRAME_BUFFER)
 		return EINVAL;
@@ -107,28 +96,29 @@
 	if (map == NULL)
 		return ENOMEM;
 
-	map->rid = resource * 4 + 0x10;
-	bsr = bus_alloc_resource_any(dev->device, SYS_RES_MEMORY, &map->rid,
-	    RF_ACTIVE | RF_SHAREABLE);
-	if (bsr == NULL) {
-		DRM_ERROR("Couldn't allocate %s resource\n",
-		    ((type == _DRM_REGISTERS) ? "mmio" : "framebuffer"));
-		free(map, M_DRM);
-		return ENOMEM;
+	if (type == _DRM_REGISTERS) {
+		struct resource *bsr;
+		map->rid = resource * 4 + 0x10;
+		bsr = bus_alloc_resource_any(dev->device, SYS_RES_MEMORY,
+		    &map->rid, RF_ACTIVE | RF_SHAREABLE);
+		if (bsr == NULL) {
+			DRM_ERROR("Couldn't allocate %s resource\n",
+			    ((type == _DRM_REGISTERS) ? "mmio" : "framebuffer"));
+			free(map, M_DRM);
+			return ENOMEM;
+		}
+		map->bsr = bsr;
+		map->bst = rman_get_bustag(bsr);
+		map->bsh = rman_get_bushandle(bsr);
+		map->handle = rman_get_virtual(bsr);
 	}
 
 	map->kernel_owned = 1;
 	map->type = type;
 	map->flags = flags;
-	map->bsr = bsr;
-	map->bst = rman_get_bustag(bsr);
-	map->bsh = rman_get_bushandle(bsr);
 	map->offset = start;
 	map->size = len;
 
-	if (type == _DRM_REGISTERS)
-		map->handle = rman_get_virtual(bsr);
-
 	DRM_DEBUG("initmap %d,0x%x@0x%lx/0x%lx\n", map->type, map->flags,
 	    map->offset, map->size);
 

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1119816026.3817.20.camel>