From patchwork Tue Aug 2 19:31:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Weiser X-Patchwork-Id: 9260263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9C91B6077C for ; Tue, 2 Aug 2016 19:40:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B50027F99 for ; Tue, 2 Aug 2016 19:40:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B8A8284F2; Tue, 2 Aug 2016 19:40:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E2A027F99 for ; Tue, 2 Aug 2016 19:40:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bUfW6-0000pJ-HI; Tue, 02 Aug 2016 19:38:18 +0000 Received: from heinz.dinsnail.net ([85.214.155.104]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bUfVk-0000fa-IJ for linux-arm-kernel@lists.infradead.org; Tue, 02 Aug 2016 19:37:57 +0000 Received: from heinz.dinsnail.net (localhost [127.0.0.1]) by heinz.dinsnail.net (8.14.9/8.14.9) with ESMTP id u72Ja3DH005333; Tue, 2 Aug 2016 21:36:03 +0200 Received: from eldalonde.UUCP (uucp@localhost) by heinz.dinsnail.net (8.14.9/8.14.9/Submit) with bsmtp id u72Ja2ud005332; Tue, 2 Aug 2016 21:36:02 +0200 Received: from rivendell.weiser.dinsnail.net (rivendell.weiser.dinsnail.net [192.168.1.8]) by eldalonde.weiser.dinsnail.net (8.14.9/8.14.8) with ESMTP id u72JWBXO014602; Tue, 2 Aug 2016 21:32:11 +0200 Received: (from michael@localhost) by rivendell.weiser.dinsnail.net (8.14.9/8.14.3/Submit) id u72JWB0b001641; Tue, 2 Aug 2016 21:32:11 +0200 From: Michael Weiser To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/5] net: ethernet: sun4i-emac: Read rxhdr in CPU byte-order Date: Tue, 2 Aug 2016 21:31:14 +0200 Message-Id: <20160802193115.850-5-michael.weiser@gmx.de> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20160802193115.850-1-michael.weiser@gmx.de> References: <20160802193115.850-1-michael.weiser@gmx.de> X-dinsnail.net-MailScanner-ID: u72Ja3DH005333 X-MailScanner: Found to be clean X-MailScanner-From: michael@rivendell.weiser.dinsnail.net X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160802_123756_825297_47BBE5BD X-CRM114-Status: UNSURE ( 8.96 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Maxime Ripard , Michael Weiser MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The EMAC EMAC_RX_IO_DATA_REG data register is dual-purpose: On one hand it is used to move actual packet data off the wire. This will be in wire-format and accepted as such by higher layers such as IP. Therefore it is correctly read as-is (i.e. raw) using readsl. On the other hand it provides metadata about incoming transfers to the driver such as length and checksum validation status. This data is little-endian, always and it is interpreted by the driver. Therefore it needs to be swapped to CPU endianness to make sense to the driver. This is already done for the "receive header" but not rxhdr. Read rxhdr using readl in order for sun4i-emac to work correctly when running a big-endian kernel. Signed-off-by: Michael Weiser Cc: Maxime Ripard Cc: netdev@vger.kernel.org --- drivers/net/ethernet/allwinner/sun4i-emac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c index cd08885..87d0b87 100644 --- a/drivers/net/ethernet/allwinner/sun4i-emac.c +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c @@ -592,8 +592,7 @@ static void emac_rx(struct net_device *dev) /* A packet ready now & Get status/length */ good_packet = true; - emac_inblk_32bit(db->membase + EMAC_RX_IO_DATA_REG, - &rxhdr, sizeof(rxhdr)); + rxhdr = readl(db->membase + EMAC_RX_IO_DATA_REG); if (netif_msg_rx_status(db)) dev_dbg(db->dev, "rxhdr: %x\n", *((int *)(&rxhdr)));