NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/42629: Update multiport ISA serial card drivers for device_t/softc split
>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@localhost | 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@localhost:/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:
Home |
Main Index |
Thread Index |
Old Index