NetBSD Problem Report #42629

From khym@azeotrope.org  Sun Jan 17 03:52:20 2010
Return-Path: <khym@azeotrope.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id C155C63C368
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 17 Jan 2010 03:52:19 +0000 (UTC)
Message-Id: <20100117035217.BCF1B1C7A18@yerfable.azeotrope.org>
Date: Sat, 16 Jan 2010 21:52:17 -0600 (CST)
From: khym@azeotrope.org
Reply-To: khym@azeotrope.org
To: gnats-bugs@gnats.NetBSD.org
Subject: Update multiport ISA serial card drivers for device_t/softc split
X-Send-Pr-Version: 3.95

>Number:         42629
>Category:       kern
>Synopsis:       Update multiport ISA serial card drivers for device_t/softc split
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 17 03:55:00 +0000 2010
>Originator:     Dave Huang
>Release:        NetBSD-current as of Jan 16, 2010
>Organization:
Name: Dave Huang         |  Mammal, mammal / their names are called /
INet: khym@azeotrope.org |  they raise a paw / the bat, the cat /
FurryMUCK: Dahan         |  dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 33 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Environment:


System: NetBSD yerfable.azeotrope.org 5.0_STABLE NetBSD 5.0_STABLE (YERFABLE) #0: Tue Sep 15 18:05:59 CDT 2009 khym@vmbsd.azeotrope.org:/usr/obj.alpha/sys/arch/alpha/compile/YERFABLE alpha
Architecture: alpha
Machine: alpha
>Description:
	Some changes to the com(4) driver were made back in
http://mail-index.netbsd.org/source-changes/2008/03/14/msg003488.html ,
but not all drivers that attach com(4) as a slave (i.e., multiport
serial cards) were updated. I had noticed this when accessing a port
on a tcom(4) caused a fatal page fault in supervisor mode, and filed
PR kern/39642, which has been fixed. However, code inspection shows
that boca, ioat, moxa, and rtfps almost certainly have the same
problem.
>How-To-Repeat:
	Attempt to access a serial port on one of the affected cards?
>Fix:
	Here's an untested patch... the same type of change fixed
tcom(4), so I'm guessing it'll work for these drivers too.

Index: addcom_isa.c
===================================================================
RCS file: /cvsroot/src/sys/dev/isa/addcom_isa.c,v
retrieving revision 1.19
diff -u -r1.19 addcom_isa.c
--- addcom_isa.c	12 May 2009 09:10:15 -0000	1.19
+++ addcom_isa.c	17 Jan 2010 03:23:44 -0000
@@ -88,7 +88,7 @@
 	int sc_iobase;

 	int sc_alive;			/* mask of slave units attached */
-	void *sc_slaves[NSLAVES];	/* com device unit numbers */
+	void *sc_slaves[NSLAVES];	/* com device softc pointers */
 	bus_space_handle_t sc_slaveioh[NSLAVES];
 	bus_space_handle_t sc_statusioh;
 };
@@ -186,11 +186,12 @@
 void
 addcomattach(device_t parent, device_t self, void *aux)
 {
-	struct addcom_softc *sc = (void *)self;
+	struct addcom_softc *sc = device_private(self);
 	struct isa_attach_args *ia = aux;
 	struct commulti_attach_args ca;
 	bus_space_tag_t iot = ia->ia_iot;
 	int i, iobase;
+	device_t slave;

 	printf("\n");

@@ -224,9 +225,11 @@
 			- SLAVE_IOBASE_OFFSET;
 		ca.ca_noien = 0;

-		sc->sc_slaves[i] = config_found(self, &ca, commultiprint);
-		if (sc->sc_slaves[i] != NULL)
+		slave = config_found(self, &ca, commultiprint);
+		if (slave != NULL) {
 			sc->sc_alive |= 1 << i;
+			sc->sc_slaves[i] = device_private(slave);
+		}
 	}

 	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
Index: boca.c
===================================================================
RCS file: /cvsroot/src/sys/dev/isa/boca.c,v
retrieving revision 1.53
diff -u -r1.53 boca.c
--- boca.c	12 May 2009 09:10:15 -0000	1.53
+++ boca.c	17 Jan 2010 03:23:45 -0000
@@ -62,7 +62,7 @@
 	int sc_iobase;

 	int sc_alive;			/* mask of slave units attached */
-	void *sc_slaves[NSLAVES];	/* com device unit numbers */
+	void *sc_slaves[NSLAVES];	/* com device softc pointers */
 	bus_space_handle_t sc_slaveioh[NSLAVES];
 	callout_t fixup;
 };
@@ -149,11 +149,12 @@
 void
 bocaattach(device_t parent, device_t self, void *aux)
 {
-	struct boca_softc *sc = (void *)self;
+	struct boca_softc *sc = device_private(self);
 	struct isa_attach_args *ia = aux;
 	struct commulti_attach_args ca;
 	bus_space_tag_t iot = ia->ia_iot;
 	int i, iobase;
+	device_t slave;

 	printf("\n");

@@ -178,9 +179,11 @@
 		ca.ca_iobase = sc->sc_iobase + i * COM_NPORTS;
 		ca.ca_noien = 0;

-		sc->sc_slaves[i] = config_found(self, &ca, commultiprint);
-		if (sc->sc_slaves[i] != NULL)
+		slave = config_found(self, &ca, commultiprint);
+		if (slave != NULL) {
 			sc->sc_alive |= 1 << i;
+			sc->sc_slaves[i] = device_private(slave);
+		}
 	}

 	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
Index: ioat66.c
===================================================================
RCS file: /cvsroot/src/sys/dev/isa/ioat66.c,v
retrieving revision 1.20
diff -u -r1.20 ioat66.c
--- ioat66.c	12 May 2009 09:10:15 -0000	1.20
+++ ioat66.c	17 Jan 2010 03:23:45 -0000
@@ -60,7 +60,7 @@
 	int sc_iobase;

 	int sc_alive;			/* mask of slave units attached */
-	void *sc_slaves[NSLAVES];	/* com device unit numbers */
+	void *sc_slaves[NSLAVES];	/* com device softc pointers */
 	bus_space_handle_t sc_slaveioh[NSLAVES];
 	bus_space_handle_t sc_intmasq;
 };
@@ -144,11 +144,12 @@
 void
 ioat66attach(device_t parent, device_t self, void *aux)
 {
-	struct ioat66_softc *sc = (void *)self;
+	struct ioat66_softc *sc = device_private(self);
 	struct isa_attach_args *ia = aux;
 	struct commulti_attach_args ca;
 	bus_space_tag_t iot = ia->ia_iot;
 	int i, iobase, irq;
+	device_t slave;

 	printf("\n");

@@ -179,9 +180,11 @@
 		ca.ca_iobase = ioatbases[i];
 		ca.ca_noien = 0;

-		sc->sc_slaves[i] = config_found(self, &ca, commultiprint);
-		if (sc->sc_slaves[i] != NULL)
+		slave = config_found(self, &ca, commultiprint);
+		if (slave != NULL) {
 			sc->sc_alive |= 1 << i;
+			sc->sc_slaves[i] = device_private(slave);
+		}
 	}

 	sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, IST_EDGE,
Index: moxa_isa.c
===================================================================
RCS file: /cvsroot/src/sys/dev/isa/moxa_isa.c,v
retrieving revision 1.19
diff -u -r1.19 moxa_isa.c
--- moxa_isa.c	12 May 2009 09:10:15 -0000	1.19
+++ moxa_isa.c	17 Jan 2010 03:23:45 -0000
@@ -60,7 +60,7 @@
 	int sc_iobase;

 	int sc_alive;			/* mask of slave units attached */
-	void *sc_slaves[NSLAVES];	/* com device unit numbers */
+	void *sc_slaves[NSLAVES];	/* com device softc pointers */
 	bus_space_handle_t sc_slaveioh[NSLAVES];
 };

@@ -143,11 +143,12 @@
 void
 moxa_isaattach(device_t parent, device_t self, void *aux)
 {
-	struct moxa_isa_softc *sc = (void *)self;
+	struct moxa_isa_softc *sc = device_private(self);
 	struct isa_attach_args *ia = aux;
 	struct commulti_attach_args ca;
 	bus_space_tag_t iot = ia->ia_iot;
 	int i, iobase;
+	device_t slave;

 	printf("\n");

@@ -171,9 +172,11 @@
 		ca.ca_iobase = sc->sc_iobase + i * COM_NPORTS;
 		ca.ca_noien = 1;

-		sc->sc_slaves[i] = config_found(self, &ca, commultiprint);
-		if (sc->sc_slaves[i] != NULL)
+		slave = config_found(self, &ca, commultiprint);
+		if (slave != NULL) {
 			sc->sc_alive |= 1 << i;
+			sc->sc_slaves[i] = device_private(slave);
+		}
 	}

 	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
Index: rtfps.c
===================================================================
RCS file: /cvsroot/src/sys/dev/isa/rtfps.c,v
retrieving revision 1.57
diff -u -r1.57 rtfps.c
--- rtfps.c	12 May 2009 09:10:15 -0000	1.57
+++ rtfps.c	17 Jan 2010 03:23:45 -0000
@@ -62,7 +62,7 @@
 	bus_space_handle_t sc_irqioh;

 	int sc_alive;			/* mask of slave units attached */
-	void *sc_slaves[NSLAVES];	/* com device unit numbers */
+	void *sc_slaves[NSLAVES];	/* com device softc pointers */
 	bus_space_handle_t sc_slaveioh[NSLAVES];
 };

@@ -142,7 +142,7 @@
 void
 rtfpsattach(device_t parent, device_t self, void *aux)
 {
-	struct rtfps_softc *sc = (void *)self;
+	struct rtfps_softc *sc = device_private(self);
 	struct isa_attach_args *ia = aux;
 	struct commulti_attach_args ca;
 	static int irqport[] = {
@@ -151,6 +151,7 @@
 	};
 	bus_space_tag_t iot = ia->ia_iot;
 	int i, iobase, irq;
+	device_t slave;

 	printf("\n");

@@ -188,9 +189,11 @@
 		ca.ca_iobase = sc->sc_iobase + i * COM_NPORTS;
 		ca.ca_noien = 0;

-		sc->sc_slaves[i] = config_found(self, &ca, commultiprint);
-		if (sc->sc_slaves[i] != NULL)
+		slave = config_found(self, &ca, commultiprint);
+		if (slave != NULL) {
 			sc->sc_alive |= 1 << i;
+			sc->sc_slaves[i] = device_private(slave);
+		}
 	}

 	sc->sc_ih = isa_intr_establish(ia->ia_ic, irq, IST_EDGE,

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.