Subject: kern/3753: cyclades driver is broken
To: None <gnats-bugs@gnats.netbsd.org>
From: Jarkko Torppa <torppa@cute.fi>
List: netbsd-bugs
Date: 06/16/1997 19:52:20
>Number:         3753
>Category:       kern
>Synopsis:       cyclades driver is broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 16 10:05:02 1997
>Last-Modified:
>Originator:     Jarkko Torppa
>Organization:
 Jarkko.Torppa@cute.fi     +358-9-34871220         Cute Communications Oy
>Release:        NetBSD1.2D
>Environment:
NetBSD spotty.cute.fi 1.2D NetBSD 1.2D (SPOTTY) #20: Mon Jun 16 03:26:58 EEST 1997     root@spotty.cute.fi:/mnt/src/sys/arch/i386/compile/SPOTTY i386


>Description:
cy driver has the following bugs/problems:
 it doesnt like pci cards of type PCI_MAPREG_MEM_TYPE_32BIT_1M
 it only probes first 16 ports on a 32 port card
 only the first 4 ports actually work
 tries to access non exisistent card when ports > 16 are tried
 it's internal counters (CY_DEBUG1) conflicts somehow with general 
  interrupt counters

After this patch some interrupts seem to go missed, but the ports do
work ok.

>How-To-Repeat:
 get a cyclades(32) and try
>Fix:
Apply the following patch in sys/dev current of today (970616) has
these files

diff -u -r cy.orig/ic/cy.c cy/ic/cy.c
--- cy.orig/ic/cy.c	Mon Jun 16 19:29:55 1997
+++ cy/ic/cy.c	Mon Jun 16 19:35:20 1997
@@ -98,7 +98,7 @@
 			chip -= (CY32_ADDR_FIX << bustype);
 
 #ifdef CY_DEBUG
-		printf("%s probe chip %d offset 0x%lx ... ",
+		printf("%s probe chip %d offset 0x%x ...\n",
 		    sc->sc_dev.dv_xname, cy_chip, chip);
 #endif
 
@@ -122,7 +122,7 @@
 	         * cleared chip 0 GFRCR. In that case we have a 16 port card.
 	         */
 		if (cy_chip == 4 &&
-		    bus_space_read_1(tag, bsh, chip +
+		    bus_space_read_1(tag, bsh,
 		       ((CD1400_GFRCR << 1) << bustype)) == 0)
 			break;
 
@@ -201,7 +201,7 @@
 
 		for (cdu = 0; cdu < CD1400_NO_OF_CHANNELS; cdu++) {
 			sc->sc_ports[port].cy_port_num = port;
-			sc->sc_ports[port].cy_chip = chip;
+			sc->sc_ports[port].cy_chip = cy_chip;
 
 			/* should we initialize anything else here? */
 			port++;
diff -u -r cy.orig/ic/cyvar.h cy/ic/cyvar.h
--- cy.orig/ic/cyvar.h	Mon Jun 16 19:30:01 1997
+++ cy/ic/cyvar.h	Mon Jun 16 19:35:25 1997
@@ -12,7 +12,7 @@
  */
 
 /* #define CY_DEBUG */
-#define CY_DEBUG1
+/* #define CY_DEBUG1 */
 
 /*
  * Maximum number of ports per card
@@ -32,7 +32,7 @@
  * card number in next 2 bits (only space for 4 cards)
  * high bit reserved for dialout flag
  */
-#define CY_PORT(x) (minor(x) & 0xf)
+#define CY_PORT(x) (minor(x) & 0x1f)
 #define CY_CARD(x) ((minor(x) >> 5) & 3)
 #define CY_DIALOUT(x) ((minor(x) & 0x80) != 0)
 #define CY_DIALIN(x) (!CY_DIALOUT(x))
diff -u -r cy.orig/pci/cy_pci.c cy/pci/cy_pci.c
--- cy.orig/pci/cy_pci.c	Mon Jun 16 19:30:20 1997
+++ cy/pci/cy_pci.c	Mon Jun 16 19:35:39 1997
@@ -53,7 +53,7 @@
 	    PCI_MAPREG_TYPE_IO, 0,
 	    iotp, iohp, NULL, iosizep) == 0);
 	memh_valid = (pci_mapreg_map(pap, 0x18,
-	    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
+	    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT | PCI_MAPREG_MEM_TYPE_32BIT_1M, 0,
 	    memtp, memhp, NULL, memsizep) == 0);
 
 	if (ioh_valid && memh_valid)
@@ -169,7 +169,7 @@
 	sc->sc_ih = pci_intr_establish(pap->pa_pc, intrhandle, IPL_TTY,
 	    cy_intr, sc);
 	if (sc->sc_ih == NULL) {
-		printf(": couldn't establish interrupt", sc->sc_dev.dv_xname);
+		printf("%s: couldn't establish interrupt", sc->sc_dev.dv_xname);
 		if (intrstr != NULL)
 			printf(" at %s", intrstr);
 		printf("\n");

>Audit-Trail:
>Unformatted: