From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965404AbbLHPdb (ORCPT ); Tue, 8 Dec 2015 10:33:31 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:53390 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965061AbbLHPd1 (ORCPT ); Tue, 8 Dec 2015 10:33:27 -0500 From: Arnd Bergmann To: netdev@vger.kernel.org Cc: Wingman Kwok , Murali Karicheri , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] netcp: add more __le32 annotations Date: Tue, 08 Dec 2015 16:32:59 +0100 Message-ID: <6435706.peaM34LhnV@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1578620.t1ANcREMZ8@wuerfel> References: <1578620.t1ANcREMZ8@wuerfel> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:oDJ3XPoizR+evzfXkgdwbi9ei8xD4ur6uViV0oEClwLKZvaWIua b1suVZ/NxLqfBBT6avam5OlwIrH7aOgPKPACEO0MEqSTZ4ckqviDVhwRstGadGXgX04GK4Z 7VVLP9/4rb7BBMgTQf4Jz40uEWHgCe/Me57EwX0RrAs0x01Nt+8LBUeb3bNco8tyVAJ6NRc ORYOYFQlT06V0QH2olZfA== X-UI-Out-Filterresults: notjunk:1;V01:K0:6XFHmxfZUGw=:YGO8TByoyb91nV35wo7Og+ hNbMPoOS7/OGmR74wVE5WpEdNWtWYXh4kZMCHeCZPzErQPr6M9narWTddeLckjSyqmSY41cc+ 43w2iV+KqvAj7WPiIJjdO1GbDi3jeA51DEPzvl4Anqu7iKMhz0cCL1osLonSL7MW0oWlT/829 9+8w4SF3nQMOx5BEygDFavVjF8GSs/xhX9XoniZHjhhp1aciDfESguiV8JPYEI6KJzdDCygsx SLQfKjgo3lrWOOVURrj7lgaz6TME+Y+fxfwCLCFl0Pww9l0xa0D/W++qQtKCN3gf3IbR0O4f0 Cb5N0SGCNfi7FahUSczZexiAlPMC/Etdu67FITPKJXVbGuoDC41I5I3KVC1mM/P4jJhMQmKmI w/xtlEkSRxDfGKwxehkuSzpQdtjVmGq5YVvu94PTTV7cY4RvuH0yb3SmlTiI5wBkYUf0PxFBp +gKxsm7yk2NBtqc1baYNX4Z40hgRWgNl71TERiLG00Zf1MrCN3JW20zWDfAasEh49JjOwhr8g 04qS8LOO36Uuv3kLTq4Cdlu1Wzu0mY9lTeXlWeNTZxzFn5UnGXPb/PVFE+MKA+wESPwU5x7mm hjZKf++4nkXQU94GDcPDfh+R8IB7YQ4r+0RteizlCfCyljAHqkX2A02vwYpU4fKwTjBFk3Tqk VzvL9A8rUVGiTQ9PIsaT353OJS3Ws5rHRh39W6WR4eZYbo/JGUNrqWiRmC06K+SRskx2hrYDK xpAr61yC/wRJ5Fmw Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The handling of epib and psdata remains a bit unclear in the driver, as we access the same fields both as CPU-endian and through DMA from the device. Sparse warns about this: ti/netcp_core.c:1147:21: warning: incorrect type in assignment (different base types) ti/netcp_core.c:1147:21: expected unsigned int [usertype] *[assigned] epib ti/netcp_core.c:1147:21: got restricted __le32 * This uses __le32 types in a few places and uses __force where the code looks fishy. The previous patch should really have produced the correct behavior, but this second patch is needed to shut up the warnings about it. Ideally it would be slightly rewritten to not need those casts, but I don't dare do that without access to the hardware for proper testing. Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/ti/netcp.h | 2 +- drivers/net/ethernet/ti/netcp_core.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/ti/netcp.h b/drivers/net/ethernet/ti/netcp.h index bb1bb72121c0..17a26a429b71 100644 --- a/drivers/net/ethernet/ti/netcp.h +++ b/drivers/net/ethernet/ti/netcp.h @@ -113,7 +113,7 @@ struct netcp_intf { #define NETCP_PSDATA_LEN KNAV_DMA_NUM_PS_WORDS struct netcp_packet { struct sk_buff *skb; - u32 *epib; + __le32 *epib; u32 *psdata; unsigned int psdata_len; struct netcp_intf *netcp; diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c index eb2585e777e1..92d08eb262c2 100644 --- a/drivers/net/ethernet/ti/netcp_core.c +++ b/drivers/net/ethernet/ti/netcp_core.c @@ -1145,8 +1145,8 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp, p_info.ts_context = NULL; p_info.txtstamp_complete = NULL; p_info.epib = desc->epib; - p_info.psdata = desc->psdata; - memset(p_info.epib, 0, KNAV_DMA_NUM_EPIB_WORDS * sizeof(u32)); + p_info.psdata = (u32 __force *)desc->psdata; + memset(p_info.epib, 0, KNAV_DMA_NUM_EPIB_WORDS * sizeof(__le32)); /* Find out where to inject the packet for transmission */ list_for_each_entry(tx_hook, &netcp->txhook_list_head, list) { @@ -1170,11 +1170,12 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp, /* update descriptor */ if (p_info.psdata_len) { - u32 *psdata = p_info.psdata; + /* psdata points to both native-endian and device-endian data */ + __le32 *psdata = (void __force *)p_info.psdata; memmove(p_info.psdata, p_info.psdata + p_info.psdata_len, p_info.psdata_len); - set_words(psdata, p_info.psdata_len, psdata); + set_words(p_info.psdata, p_info.psdata_len, psdata); tmp |= (p_info.psdata_len & KNAV_DMA_DESC_PSLEN_MASK) << KNAV_DMA_DESC_PSLEN_SHIFT; } -- 2.1.0.rc2