Subject: kern/4095: There may be a bug in console support in multi-port serial
To: None <gnats-bugs@gnats.netbsd.org>
From: None <enami@but-b.or.jp>
List: netbsd-bugs
Date: 09/08/1997 10:06:46
>Number:         4095
>Category:       kern
>Synopsis:       There may be a bug in console support in multi-port serial cards
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep  7 18:20:01 1997
>Last-Modified:
>Originator:     enami tsugutomo
>Organization:
>Release:        NetBSD-current as of 1997 Sep 06
>Environment:
System: NetBSD pavlov.enami.ba2.so-net.or.jp 1.2G NetBSD 1.2G (PAVLOV) #318: Sun Aug 24 10:28:41 JST 1997 enami@pavlov.enami.ba2.so-net.or.jp:/b/netbsd/kernel/compile/PAVLOV i386


>Description:
	It seems that there may be a bug in console support in multi-port
	serial cards.  It doesn't check if a slave port is a console in
	attach routine when mapping the port.  In probe routine, it tests if
	a slave port is console, I believe that there is a case that a slave
	port is console.

>How-To-Repeat:
	Read the dev/isa/{ast.c,boca.c,rtfps.c}.  Sorry, since I don't have
	any multi-port serial cards, I can't test it.

>Fix:
	Here is possible fix, but untested:

Index: ast.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/sys/dev/isa/ast.c,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 ast.c
*** ast.c	1997/08/24 13:41:27	1.1.1.7
--- ast.c	1997/09/08 00:41:31
***************
*** 147,161 ****
  	struct isa_attach_args *ia = aux;
  	struct commulti_attach_args ca;
  	bus_space_tag_t iot = ia->ia_iot;
! 	int i;
  
  	sc->sc_iot = ia->ia_iot;
  	sc->sc_iobase = ia->ia_iobase;
  
! 	for (i = 0; i < NSLAVES; i++)
! 		if (bus_space_map(iot, sc->sc_iobase + i * COM_NPORTS,
! 		    COM_NPORTS, 0, &sc->sc_slaveioh[i]))
  			panic("astattach: couldn't map slave %d", i);
  
  	/*
  	 * Enable the master interrupt.
--- 147,164 ----
  	struct isa_attach_args *ia = aux;
  	struct commulti_attach_args ca;
  	bus_space_tag_t iot = ia->ia_iot;
! 	int i, iobase;
  
  	sc->sc_iot = ia->ia_iot;
  	sc->sc_iobase = ia->ia_iobase;
  
! 	for (i = 0; i < NSLAVES; i++) {
! 		iobase = sc->sc_iobase + i * COM_NPORTS;
! 		if (!com_is_console(iot, iobase, &sc->sc_slaveioh[i]) &&
! 		    bus_space_map(iot, iobase, COM_NPORTS, 0,
! 			&sc->sc_slaveioh[i]))
  			panic("astattach: couldn't map slave %d", i);
+ 	}
  
  	/*
  	 * Enable the master interrupt.
Index: boca.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/sys/dev/isa/boca.c,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 boca.c
*** boca.c	1997/08/24 13:41:28	1.1.1.7
--- boca.c	1997/09/08 00:44:39
***************
*** 147,161 ****
  	struct isa_attach_args *ia = aux;
  	struct commulti_attach_args ca;
  	bus_space_tag_t iot = ia->ia_iot;
! 	int i;
  
  	sc->sc_iot = ia->ia_iot;
  	sc->sc_iobase = ia->ia_iobase;
  
! 	for (i = 0; i < NSLAVES; i++)
! 		if (bus_space_map(iot, sc->sc_iobase + i * COM_NPORTS,
! 		    COM_NPORTS, 0, &sc->sc_slaveioh[i]))
  			panic("bocaattach: couldn't map slave %d", i);
  
  	printf("\n");
  
--- 147,164 ----
  	struct isa_attach_args *ia = aux;
  	struct commulti_attach_args ca;
  	bus_space_tag_t iot = ia->ia_iot;
! 	int i, iobase;
  
  	sc->sc_iot = ia->ia_iot;
  	sc->sc_iobase = ia->ia_iobase;
  
! 	for (i = 0; i < NSLAVES; i++) {
! 		iobase = sc->sc_iobase + i * COM_NPORTS;
! 		if (!com_is_console(iot, iobase, &sc->sc_slaveioh[i]) &&
! 		    bus_space_map(iot, iobase, COM_NPORTS, 0,
! 			&sc->sc_slaveioh[i]))
  			panic("bocaattach: couldn't map slave %d", i);
+ 	}
  
  	printf("\n");
  
Index: rtfps.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/sys/dev/isa/rtfps.c,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 rtfps.c
*** rtfps.c	1997/08/24 13:41:42	1.1.1.7
--- rtfps.c	1997/09/08 00:45:53
***************
*** 155,161 ****
  		IOBASEUNK, IOBASEUNK, IOBASEUNK, IOBASEUNK
  	};
  	bus_space_tag_t iot = ia->ia_iot;
! 	int i;
  
  	sc->sc_iot = ia->ia_iot;
  	sc->sc_iobase = ia->ia_iobase;
--- 155,161 ----
  		IOBASEUNK, IOBASEUNK, IOBASEUNK, IOBASEUNK
  	};
  	bus_space_tag_t iot = ia->ia_iot;
! 	int i, iobase;
  
  	sc->sc_iot = ia->ia_iot;
  	sc->sc_iobase = ia->ia_iobase;
***************
*** 164,173 ****
  		panic("rtfpsattach: invalid irq");
  	sc->sc_irqport = irqport[ia->ia_irq];
  
! 	for (i = 0; i < NSLAVES; i++)
! 		if (bus_space_map(iot, sc->sc_iobase + i * COM_NPORTS,
! 		    COM_NPORTS, 0, &sc->sc_slaveioh[i]))
  			panic("rtfpsattach: couldn't map slave %d", i);
  	if (bus_space_map(iot, sc->sc_irqport, 1, 0, &sc->sc_irqioh))
  		panic("rtfpsattach: couldn't map irq port at 0x%x\n",
  		    sc->sc_irqport);
--- 164,176 ----
  		panic("rtfpsattach: invalid irq");
  	sc->sc_irqport = irqport[ia->ia_irq];
  
! 	for (i = 0; i < NSLAVES; i++) {
! 		iobase = sc->sc_iobase + i * COM_NPORTS;
! 		if (!com_is_console(iot, iobase, &sc->sc_slaveioh[i]) &&
! 		    bus_space_map(iot, iobase, COM_NPORTS, 0,
! 			&sc->sc_slaveioh[i]))
  			panic("rtfpsattach: couldn't map slave %d", i);
+ 	}
  	if (bus_space_map(iot, sc->sc_irqport, 1, 0, &sc->sc_irqioh))
  		panic("rtfpsattach: couldn't map irq port at 0x%x\n",
  		    sc->sc_irqport);
>Audit-Trail:
>Unformatted: