From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423128Ab3FUP6o (ORCPT ); Fri, 21 Jun 2013 11:58:44 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:53881 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422800Ab3FUP6m (ORCPT ); Fri, 21 Jun 2013 11:58:42 -0400 From: Arnd Bergmann To: Joe Perches Subject: Re: [PATCH v7] ethernet/arc/arc_emac - Add new driver Date: Fri, 21 Jun 2013 17:58:25 +0200 User-Agent: KMail/1.12.2 (Linux/3.8.0-22-generic; KDE/4.3.2; x86_64; ; ) Cc: Alexey Brodkin , "netdev@vger.kernel.org" , Andy Shevchenko , Francois Romieu , Vineet Gupta , Mischa Jonker , Grant Likely , Rob Herring , Paul Gortmaker , "David S. Miller" , "linux-kernel@vger.kernel.org" , "devicetree-discuss@lists.ozlabs.org" , Florian Fainelli References: <1371799241-27771-1-git-send-email-abrodkin@synopsys.com> <4881796E12491D4BB15146FE0209CE643F5F587E@DE02WEMBXB.internal.synopsys.com> <1371825813.19215.34.camel@joe-AO722> In-Reply-To: <1371825813.19215.34.camel@joe-AO722> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201306211758.26094.arnd@arndb.de> X-Provags-ID: V02:K0:/R/GiaOLtb7Hu3mgEHdFB3+AmiYtWXDblcRdBCTzYiO b0cV80zC43YHiLRCWvZ4jpMifgVyPoPpjxzITsQGajhnHeoZ9a wEt+9jyo8boM2dvSMKsz+J0bFGW9c2s8fiERGJUMMhX4Sj3mzs Gr3HH9mUUh/Rhunzoe1R0ugSirF/7JxkXaCCc79Aeo3nJK6w1G 5h/9jM+2GI2+PNFgqdL2CrFuuaKic2XwO7ZrnXWo1f5ZkGEBQL ArR0p/Pk5XSkyfO89z62A92ftDQfz4AnKkm9gM9Zj8hurv1Y0X vGdbcRVczGr1sUis2fPyBYzyPTACuumPbueBXhDZQpUEQkFD4s rOQLTmsNn7z3PnaRcMRg= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday 21 June 2013, Joe Perches wrote: > On Fri, 2013-06-21 at 10:53 +0000, Alexey Brodkin wrote: > > On 06/21/2013 02:32 PM, Joe Perches wrote: > > > On Fri, 2013-06-21 at 11:20 +0400, Alexey Brodkin wrote: > > >> Driver for non-standard on-chip ethernet device ARC EMAC 10/100, > > >> instantiated in some legacy ARC (Synopsys) FPGA Boards such as > > >> ARCAngel4/ML50x. > [] > > >> + rxbd->data = (unsigned char *)cpu_to_le32(rx_buff->skb->data); > > > > > > 32 bit only. Should the Kconfig block have some arch_arc dependency > > > so it can't get compiled for 64 bit systems? > [] > > So for now I may easily add dependency on ARC if it makes acceptance of > > driver easier. > > I don't think it's a big problem. > > Maybe add a Kconfig "depends on !64BIT". > > Another thing to do would be to run it through sparse > with make C=1 No, I think the driver should just be made 64-bit clean. Not because anyone is going to need that of course, but to avoid having to add silly dependencies. The problem is that rxbd->data is the wrong type. It is declared as a void*, but it is not a kernel pointer at all, it is a DMA pointer. Look at this code in context: + addr = dma_map_single(&ndev->dev, (void *)rx_buff->skb->data, + buflen, DMA_FROM_DEVICE); + if (dma_mapping_error(&ndev->dev, addr)) { + if (net_ratelimit()) + netdev_err(ndev, "cannot dma map\n"); + dev_kfree_skb(rx_buff->skb); + stats->rx_errors++; + continue; + } + dma_unmap_addr_set(&rx_buff, mapping, addr); + dma_unmap_len_set(&rx_buff, len, buflen); + + rxbd->data = (unsigned char *)cpu_to_le32(rx_buff->skb->data); the 'addr' returned by dma_map_single is what the device really needs, although it is the same as rx_buff->skb->data with the trivial definition of dma_map_single. The last line here needs to be rxbd->data = cpu_to_le32(addr); which fixes the bug, and has no dependency on a 32 bit CPU. Arnd