Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 May 2000 16:20:11 +0200 (CEST)
From:      Alexander Langer <alex@cichlids.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/18744: fix newbus stuff for bktr driver
Message-ID:  <200005221420.QAA00738@cichlids.cichlids.com>

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

>Number:         18744
>Category:       kern
>Synopsis:       fix newbus stuff for bktr driver
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 22 07:30:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Alexander Langer
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
none
>Environment:

recent HEAD

>Description:

The newbus stuff _worked_ that way, but was broken nevertheless.
This fixes the code in sense of newbus.

Note: The memory alloced by vm_page_alloc_contig never get's free'ed and
this prevents the module from being reloaded.

Must be fixed later.

>How-To-Repeat:

>Fix:

cvs diff: Diffing .
Index: bktr_os.c
===================================================================
RCS file: /usr/home/ncvs/src/sys/dev/bktr/bktr_os.c,v
retrieving revision 1.7
diff -u -r1.7 bktr_os.c
--- bktr_os.c	2000/04/16 07:50:09	1.7
+++ bktr_os.c	2000/05/22 14:16:11
@@ -274,7 +274,6 @@
 	unsigned int	rev;
 	unsigned int	unit;
 	int		error = 0;
-	int		rid;
 #ifdef BROOKTREE_IRQ
 	u_long		old_irq, new_irq;
 #endif 
@@ -293,8 +292,8 @@
 	/*
 	 * Map control/status registers.
 	 */
-	rid = PCI_MAP_REG_START;
-	bktr->res_mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
+	bktr->mem_rid = PCI_MAP_REG_START;
+	bktr->res_mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &bktr->mem_rid,
                                   0, ~0, 1, RF_ACTIVE);
 
 	if (!bktr->res_mem) {
@@ -324,9 +323,9 @@
 	/*
 	 * Allocate our interrupt.
 	 */
-	rid = 0;
-	bktr->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
-                                 RF_SHAREABLE | RF_ACTIVE);
+	bktr->irq_rid = 0;
+	bktr->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &bktr->irq_rid,
+                                 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE);
 	if (bktr->res_irq == NULL) {
 		device_printf(dev, "could not map interrupt\n");
 		error = ENXIO;
@@ -405,8 +404,11 @@
 	return 0;
 
 fail:
+    if (bktr->res_irq)
+        bus_release_resource(dev, SYS_RES_IRQ, bktr->irq_rid, bktr->res_irq);
+    if (bktr->res_mem)
+        bus_release_resource(dev, SYS_RES_IRQ, bktr->mem_rid, bktr->res_mem);
 	return error;
-
 }
 
 /*
@@ -423,12 +425,12 @@
 
 	/* FIXME - Free memory for RISC programs, grab buffer, vbi buffers */
 
 	/*
 	 * Deallocate resources.
 	 */
 	bus_teardown_intr(dev, bktr->res_irq, bktr->res_ih);
-	bus_release_resource(dev, SYS_RES_IRQ, 0, bktr->res_irq);
-	bus_release_resource(dev, SYS_RES_MEMORY, PCI_MAP_REG_START, bktr->res_mem);
+	bus_release_resource(dev, SYS_RES_IRQ, bktr->irq_rid, bktr->res_irq);
+	bus_release_resource(dev, SYS_RES_MEMORY, bktr->mem_rid, bktr->res_mem);
 
 	return 0;
 }
Index: bktr_reg.h
===================================================================
RCS file: /usr/home/ncvs/src/sys/dev/bktr/bktr_reg.h,v
retrieving revision 1.37
diff -u -r1.37 bktr_reg.h
--- bktr_reg.h	2000/04/04 16:54:13	1.37
+++ bktr_reg.h	2000/05/22 13:58:32
@@ -498,7 +498,9 @@
     pcici_t         tag;	/* 2.x PCI tag, for doing PCI commands */
     #endif
     #if (__FreeBSD_version >= 400000)
+    int             mem_rid;	/* 4.x resource id */
     struct resource *res_mem;	/* 4.x resource descriptor for registers */
+    int             irq_rid;	/* 4.x resource id */
     struct resource *res_irq;	/* 4.x resource descriptor for interrupt */
     void            *res_ih;	/* 4.x newbus interrupt handler cookie */
     #endif

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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