From owner-freebsd-current@FreeBSD.ORG Sat Jun 25 20:53:08 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7921516A41C; Sat, 25 Jun 2005 20:53:08 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.village.org (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2D13243D48; Sat, 25 Jun 2005 20:53:08 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1]) by harmony.village.org (8.13.3/8.13.3) with ESMTP id j5PKqNkX003202; Sat, 25 Jun 2005 14:52:23 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sat, 25 Jun 2005 14:53:57 -0600 (MDT) Message-Id: <20050625.145357.85412052.imp@bsdimp.com> To: maksim.yevmenkin@savvis.net From: "M. Warner Losh" In-Reply-To: <42BD6865.4090608@savvis.net> References: <20050625115421.GA13063@ip.net.ua> <20050625120226.GK14567@elvis.mu.org> <42BD6865.4090608@savvis.net> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Sat_Jun_25_14:53:57_2005_677)--" Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: Re: [patch] ep(4) panic X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jun 2005 20:53:08 -0000 ----Next_Part(Sat_Jun_25_14:53:57_2005_677)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit In message: <42BD6865.4090608@savvis.net> Maksim Yevmenkin writes: : the way i understand it: this code is in the "probe" routine and when : its called ifp structure was not allocated/setup yet. the "attach" : routine will call "ep_attach" later that will allocate/setup ifp and : read/set mac address (once again). so, the card works just fine. : : it is interesting that my 4.x has different comment : : $FreeBSD: /repoman/r/ncvs/src/sys/dev/ep/if_ep_pccard.c,v 1.12.2.3 : 2003/10/06 02:53:51 imp Exp $ : : /* : * For some reason the 3c574 needs this. : */ : ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr); : : : perhaps the comment in -current should be changed as well? can anyone : please shed some light on this? The comment in -current is wrong. The routine doesn't set the MAC address, but instead just reads it out of EEPROM. For reasons I still don't know or understand, this still seems to be required. I'll have to look into when I have an hour or two to kill. The following patch works on: 3CCFE547BT, 3C574-TX, 3CCE589EC, 3C589D-TP, 3C589C, 3C589B, 3C562D/3C563D, 3CCFEM556 which covers almost all the cards that are obtainable these days. It doesn't work with: 3C1 (we've never worked with this card) 3C562 or 3C562B/3C563B I think that there's an address line work around needed for thse two cards. 5.x doesn't seem to work with them either. So I think it is good/safe to commit. I'll ask the RE if people here test it. Warner ----Next_Part(Sat_Jun_25_14:53:57_2005_677)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ep.diff" Index: if_ep.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/ep/if_ep.c,v retrieving revision 1.137 diff -u -r1.137 if_ep.c --- if_ep.c 10 Jun 2005 16:49:07 -0000 1.137 +++ if_ep.c 25 Jun 2005 20:12:06 -0000 @@ -129,7 +129,7 @@ * before */ int -get_e(struct ep_softc *sc, uint16_t offset, uint16_t *result) +ep_get_e(struct ep_softc *sc, uint16_t offset, uint16_t *result) { if (eeprom_rdy(sc)) @@ -158,7 +158,7 @@ GO_WINDOW(sc, 0); for (i = EEPROM_NODE_ADDR_0; i <= EEPROM_NODE_ADDR_2; i++) { - error = get_e(sc, i, &result); + error = ep_get_e(sc, i, &result); if (error) return (error); macaddr[i] = htons(result); @@ -203,12 +203,12 @@ GO_WINDOW(sc, 0); sc->epb.cmd_off = 0; - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); if (error) goto bad; sc->epb.prod_id = result; - error = get_e(sc, EEPROM_RESOURCE_CFG, &result); + error = ep_get_e(sc, EEPROM_RESOURCE_CFG, &result); if (error) goto bad; sc->epb.res_cfg = result; Index: if_ep_isa.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/ep/if_ep_isa.c,v retrieving revision 1.26 diff -u -r1.26 if_ep_isa.c --- if_ep_isa.c 20 Jan 2005 19:39:33 -0000 1.26 +++ if_ep_isa.c 25 Jun 2005 20:10:50 -0000 @@ -361,13 +361,13 @@ uint8_t cksum_high = 0; uint8_t cksum_low = 0; - error = get_e(sc, 0x0f, &val); + error = ep_get_e(sc, 0x0f, &val); if (error) return (ENXIO); cksum = val; for (i = 0; i < 0x0f; i++) { - error = get_e(sc, i, &val); + error = ep_get_e(sc, i, &val); if (error) return (ENXIO); switch (i) { Index: if_ep_pccard.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/ep/if_ep_pccard.c,v retrieving revision 1.44 diff -u -r1.44 if_ep_pccard.c --- if_ep_pccard.c 24 Jun 2005 14:36:52 -0000 1.44 +++ if_ep_pccard.c 25 Jun 2005 20:46:25 -0000 @@ -73,6 +73,7 @@ struct ep_board *epb = &sc->epb; const char *desc; uint16_t result; + uint8_t enaddr[6]; int error; error = ep_alloc(dev); @@ -96,7 +97,7 @@ epb->cmd_off = 0; /* XXX check return */ - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); epb->prod_id = result; if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) { @@ -105,7 +106,7 @@ "failed (nonfatal) id 0x%x\n", epb->prod_id); epb->cmd_off = 2; /* XXX check return */ - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); epb->prod_id = result; if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) { device_printf(dev, "Unit failed to come ready or " @@ -114,14 +115,16 @@ return (ENXIO); } } - device_set_desc(dev, desc); - /* - * Newer cards supported by this device need to have their - * MAC address set. + * For reasons unknown, getting the MAC address here makes the + * 3C574 and 3C556 families get the right MAC address later. + * otherwise, the ID field is used for each of the words of the + * MAC address instead of the proper one. It is unclear why + * ep_get_macaddr would have this side effect, or even what + * that side effect really is. */ - error = ep_get_macaddr(sc, (u_char *)&IFP2ENADDR(sc->ifp)); - + ep_get_macaddr(sc, enaddr); + device_set_desc(dev, desc); ep_free(dev); return (0); } @@ -189,14 +192,14 @@ sc->epb.cmd_off = 0; /* XXX check return */ - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); sc->epb.prod_id = result; if (!ep_pccard_card_attach(&sc->epb)) { sc->epb.cmd_off = 2; - error = get_e(sc, EEPROM_PROD_ID, &result); + error = ep_get_e(sc, EEPROM_PROD_ID, &result); sc->epb.prod_id = result; - error = get_e(sc, EEPROM_RESOURCE_CFG, &result); + error = ep_get_e(sc, EEPROM_RESOURCE_CFG, &result); sc->epb.res_cfg = result; if (!ep_pccard_card_attach(&sc->epb)) { device_printf(dev, @@ -205,7 +208,7 @@ goto bad; } } - error = get_e(sc, EEPROM_ADDR_CFG, &result); + error = ep_get_e(sc, EEPROM_ADDR_CFG, &result); /* ROM size = 0, ROM base = 0 */ /* For now, ignore AUTO SELECT feature of 3C589B and later. */ Index: if_epvar.h =================================================================== RCS file: /cache/ncvs/src/sys/dev/ep/if_epvar.h,v retrieving revision 1.16 diff -u -r1.16 if_epvar.h --- if_epvar.h 10 Jun 2005 16:49:07 -0000 1.16 +++ if_epvar.h 25 Jun 2005 20:11:31 -0000 @@ -79,7 +79,7 @@ void ep_get_media(struct ep_softc *); int ep_attach(struct ep_softc *); void ep_intr(void *); -int get_e(struct ep_softc *, uint16_t, uint16_t *); +int ep_get_e(struct ep_softc *, uint16_t, uint16_t *); int ep_get_macaddr(struct ep_softc *, u_char *); #define CSR_READ_1(sc, off) (bus_space_read_1((sc)->bst, (sc)->bsh, off)) ----Next_Part(Sat_Jun_25_14:53:57_2005_677)----