From owner-svn-src-stable-9@FreeBSD.ORG Fri Aug 9 20:58:08 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DDEECB51; Fri, 9 Aug 2013 20:58:07 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C9D9B2236; Fri, 9 Aug 2013 20:58:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r79Kw76V021331; Fri, 9 Aug 2013 20:58:07 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r79Kw7vc021328; Fri, 9 Aug 2013 20:58:07 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201308092058.r79Kw7vc021328@svn.freebsd.org> From: Marius Strobl Date: Fri, 9 Aug 2013 20:58:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r254160 - stable/9/sys/dev/scc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Aug 2013 20:58:08 -0000 Author: marius Date: Fri Aug 9 20:58:06 2013 New Revision: 254160 URL: http://svnweb.freebsd.org/changeset/base/254160 Log: MFC: r253899, r253920 - Implement iclear methods for QUICC and SAB 82532. With r253161 in place, this is is crucial at least for the latter. What happens is that attaching uart(4) to scc(4) causes the SAB 82532 to "receive" something and trigger a SER_INT_RXREADY interrupt, given that at least fast/filter interrupts are already enabled. Prior to r253161, uart_bus_ihand() was set up at this point and handled that condition, i. e. read the RX FIFO and issued a Receive Message Complete. Now, uart_bus_ihand() and uart_intr() are setup after attaching uart(4), leaving the SER_INT_RXREADY interrupt triggered during the latter to be handled by the iclear method. However, with that method not implement, this in turn causes SAB 82532 to not issue any further SER_INT_RXREADY interrupts until the RX FIFO is full again. Thus, 15 received bytes go to nowhere, given that "the other half" of the RX FIFO is used for status information. Hence, implementing sab82532_bfe_iclear() fixes things again. Potentially, the same problem exists for QUICC. - Remove unnecessary __RMAN_RESOURCE_VISIBLE. - Remove a superfluous header. - Use KOBJMETHOD_END. - Mark unused arguments as such. - Remove variables unused after initialization. Reviewed by: marcel (earlier version) Modified: stable/9/sys/dev/scc/scc_dev_quicc.c stable/9/sys/dev/scc/scc_dev_sab82532.c stable/9/sys/dev/scc/scc_dev_z8530.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/scc/scc_dev_quicc.c ============================================================================== --- stable/9/sys/dev/scc/scc_dev_quicc.c Fri Aug 9 20:08:42 2013 (r254159) +++ stable/9/sys/dev/scc/scc_dev_quicc.c Fri Aug 9 20:58:06 2013 (r254160) @@ -27,13 +27,10 @@ #include __FBSDID("$FreeBSD$"); -#define __RMAN_RESOURCE_VISIBLE - #include #include #include #include -#include #include #include #include @@ -47,9 +44,13 @@ __FBSDID("$FreeBSD$"); #define quicc_read2(bas, reg) \ bus_space_read_2((bas)->bst, (bas)->bsh, reg) +#define quicc_read4(bas, reg) \ + bus_space_read_4((bas)->bst, (bas)->bsh, reg) #define quicc_write2(bas, reg, val) \ bus_space_write_2((bas)->bst, (bas)->bsh, reg, val) +#define quicc_write4(bas, reg, val) \ + bus_space_write_4((bas)->bst, (bas)->bsh, reg, val) static int quicc_bfe_attach(struct scc_softc *, int); static int quicc_bfe_enabled(struct scc_softc *, struct scc_chan *); @@ -63,7 +64,7 @@ static kobj_method_t quicc_methods[] = { KOBJMETHOD(scc_iclear, quicc_bfe_iclear), KOBJMETHOD(scc_ipend, quicc_bfe_ipend), KOBJMETHOD(scc_probe, quicc_bfe_probe), - { 0, 0 } + KOBJMETHOD_END }; struct scc_class scc_quicc_class = { @@ -77,11 +78,9 @@ struct scc_class scc_quicc_class = { }; static int -quicc_bfe_attach(struct scc_softc *sc, int reset) +quicc_bfe_attach(struct scc_softc *sc __unused, int reset __unused) { - struct scc_bas *bas; - bas = &sc->sc_bas; return (0); } @@ -104,7 +103,18 @@ quicc_bfe_enabled(struct scc_softc *sc, static int quicc_bfe_iclear(struct scc_softc *sc, struct scc_chan *ch) { + struct scc_bas *bas; + uint16_t rb, st; + bas = &sc->sc_bas; + mtx_lock_spin(&sc->sc_hwmtx); + if (ch->ch_ipend & SER_INT_RXREADY) { + rb = quicc_read2(bas, QUICC_PRAM_SCC_RBASE(ch->ch_nr - 1)); + st = quicc_read2(bas, rb); + (void)quicc_read4(bas, rb + 4); + quicc_write2(bas, rb, st | 0x9000); + } + mtx_unlock_spin(&sc->sc_hwmtx); return (0); } @@ -142,10 +152,8 @@ quicc_bfe_ipend(struct scc_softc *sc) } static int -quicc_bfe_probe(struct scc_softc *sc) +quicc_bfe_probe(struct scc_softc *sc __unused) { - struct scc_bas *bas; - bas = &sc->sc_bas; return (0); } Modified: stable/9/sys/dev/scc/scc_dev_sab82532.c ============================================================================== --- stable/9/sys/dev/scc/scc_dev_sab82532.c Fri Aug 9 20:08:42 2013 (r254159) +++ stable/9/sys/dev/scc/scc_dev_sab82532.c Fri Aug 9 20:58:06 2013 (r254160) @@ -52,7 +52,7 @@ static kobj_method_t sab82532_methods[] KOBJMETHOD(scc_iclear, sab82532_bfe_iclear), KOBJMETHOD(scc_ipend, sab82532_bfe_ipend), KOBJMETHOD(scc_probe, sab82532_bfe_probe), - { 0, 0 } + KOBJMETHOD_END }; struct scc_class scc_sab82532_class = { @@ -66,18 +66,37 @@ struct scc_class scc_sab82532_class = { }; static int -sab82532_bfe_attach(struct scc_softc *sc, int reset) +sab82532_bfe_attach(struct scc_softc *sc __unused, int reset __unused) { - struct scc_bas *bas; - bas = &sc->sc_bas; return (0); } static int sab82532_bfe_iclear(struct scc_softc *sc, struct scc_chan *ch) { + struct scc_bas *bas; + int i, ofs, rbcl; + bas = &sc->sc_bas; + ofs = (ch->ch_nr - 1) * SAB_CHANLEN; + mtx_lock_spin(&sc->sc_hwmtx); + if (ch->ch_ipend & SER_INT_RXREADY) { + if (scc_getreg(bas, ofs + SAB_STAR) & SAB_STAR_RFNE) { + rbcl = scc_getreg(bas, ofs + SAB_RBCL) & 31; + if (rbcl == 0) + rbcl = 32; + for (i = 0; i < rbcl; i += 2) { + (void)scc_getreg(bas, ofs + SAB_RFIFO); + (void)scc_getreg(bas, ofs + SAB_RFIFO + 1); + } + } + while (scc_getreg(bas, ofs + SAB_STAR) & SAB_STAR_CEC) + ; + scc_setreg(bas, ofs + SAB_CMDR, SAB_CMDR_RMC); + scc_barrier(bas); + } + mtx_unlock_spin(&sc->sc_hwmtx); return (0); } @@ -124,10 +143,8 @@ sab82532_bfe_ipend(struct scc_softc *sc) } static int -sab82532_bfe_probe(struct scc_softc *sc) +sab82532_bfe_probe(struct scc_softc *sc __unused) { - struct scc_bas *bas; - bas = &sc->sc_bas; return (0); } Modified: stable/9/sys/dev/scc/scc_dev_z8530.c ============================================================================== --- stable/9/sys/dev/scc/scc_dev_z8530.c Fri Aug 9 20:08:42 2013 (r254159) +++ stable/9/sys/dev/scc/scc_dev_z8530.c Fri Aug 9 20:58:06 2013 (r254160) @@ -52,7 +52,7 @@ static kobj_method_t z8530_methods[] = { KOBJMETHOD(scc_iclear, z8530_bfe_iclear), KOBJMETHOD(scc_ipend, z8530_bfe_ipend), KOBJMETHOD(scc_probe, z8530_bfe_probe), - { 0, 0 } + KOBJMETHOD_END }; struct scc_class scc_z8530_class = { @@ -85,11 +85,9 @@ scc_getmreg(struct scc_bas *bas, int ch, } static int -z8530_bfe_attach(struct scc_softc *sc, int reset) +z8530_bfe_attach(struct scc_softc *sc __unused, int reset __unused) { - struct scc_bas *bas; - bas = &sc->sc_bas; return (0); } @@ -189,10 +187,8 @@ z8530_bfe_ipend(struct scc_softc *sc) } static int -z8530_bfe_probe(struct scc_softc *sc) +z8530_bfe_probe(struct scc_softc *sc __unused) { - struct scc_bas *bas; - bas = &sc->sc_bas; return (0); }