From owner-freebsd-bugs@FreeBSD.ORG Thu Jan 26 02:10:02 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05DE8106566B for ; Thu, 26 Jan 2012 02:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B812D8FC17 for ; Thu, 26 Jan 2012 02:10:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q0Q2A1xg092949 for ; Thu, 26 Jan 2012 02:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q0Q2A1cZ092948; Thu, 26 Jan 2012 02:10:01 GMT (envelope-from gnats) Resent-Date: Thu, 26 Jan 2012 02:10:01 GMT Resent-Message-Id: <201201260210.q0Q2A1cZ092948@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Justin Hibbits Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E5EBA1065677 for ; Thu, 26 Jan 2012 02:05:12 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id D56578FC1A for ; Thu, 26 Jan 2012 02:05:12 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q0Q25CQt047489 for ; Thu, 26 Jan 2012 02:05:12 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q0Q25CU4047488; Thu, 26 Jan 2012 02:05:12 GMT (envelope-from nobody) Message-Id: <201201260205.q0Q25CU4047488@red.freebsd.org> Date: Thu, 26 Jan 2012 02:05:12 GMT From: Justin Hibbits To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/164499: if_wi needs fix for big endian architectures. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jan 2012 02:10:02 -0000 >Number: 164499 >Category: kern >Synopsis: if_wi needs fix for big endian architectures. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jan 26 02:10:01 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Justin Hibbits >Release: CURRENT >Organization: >Environment: >Description: if_wi(4) byte-swaps twice on big endian when reading from the device. The attached patch fixes this by calling the streaming read. Patch discussed with adrian@. >How-To-Repeat: >Fix: Patch attached with submission follows: Index: sys/dev/wi/if_wi.c =================================================================== --- sys/dev/wi/if_wi.c (revision 230483) +++ sys/dev/wi/if_wi.c (working copy) @@ -1898,8 +1898,7 @@ static int wi_read_bap(struct wi_softc *sc, int id, int off, void *buf, int buflen) { - u_int16_t *ptr; - int i, error, cnt; + int error, cnt; if (buflen == 0) return 0; @@ -1908,9 +1907,7 @@ return error; } cnt = (buflen + 1) / 2; - ptr = (u_int16_t *)buf; - for (i = 0; i < cnt; i++) - *ptr++ = CSR_READ_2(sc, WI_DATA0); + CSR_READ_MULTI_STREAM_2(sc, WI_DATA0, (u_int16_t *)buf, cnt); sc->sc_bap_off += cnt * 2; return 0; } @@ -1918,8 +1915,7 @@ static int wi_write_bap(struct wi_softc *sc, int id, int off, void *buf, int buflen) { - u_int16_t *ptr; - int i, error, cnt; + int error, cnt; if (buflen == 0) return 0; @@ -1929,9 +1925,7 @@ return error; } cnt = (buflen + 1) / 2; - ptr = (u_int16_t *)buf; - for (i = 0; i < cnt; i++) - CSR_WRITE_2(sc, WI_DATA0, ptr[i]); + CSR_WRITE_MULTI_STREAM_2(sc, WI_DATA0, (u_int16_t *)buf, cnt); sc->sc_bap_off += cnt * 2; return 0; >Release-Note: >Audit-Trail: >Unformatted: