From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zoltan Kiss Subject: Re: dma_map_single returns 0 on ARM Date: Mon, 27 Oct 2014 15:30:36 +0000 Message-ID: <544E651C.5040400@linaro.org> References: <544A80F1.5080203@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XimFk-0004DM-4h for xen-devel@lists.xenproject.org; Mon, 27 Oct 2014 15:30:40 +0000 Received: by mail-wi0-f179.google.com with SMTP id h11so4775108wiw.0 for ; Mon, 27 Oct 2014 08:30:38 -0700 (PDT) In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On 25/10/14 15:11, Stefano Stabellini wrote: > On Fri, 24 Oct 2014, Zoltan Kiss wrote: >> Hi, >> >> I'm trying to fire up the Ethernet port of a Hisilicon D01 board, and it fails >> when it wants to map the buffers to the device: >> >> phys = dma_map_single(&ndev->dev, priv->rx_buf[i], >> RX_BUF_SIZE, DMA_FROM_DEVICE); >> >> This returns 0, while running on bare metal it works. Does anyone has an >> advice where should I look? > > dma_map_single should just be a wrapper around dma_ops->map_page that in > dom0 is implemented by xen_swiotlb_map_page. > From looking at the code the issue appears to be that dma_capable > returns false for your device. > > In any case even if dma_map_single returned a valid address, keep in > mind that at the moment if the device is not dma coherent Linux needs > to be compiled with CONFIG_ARM_LPAE to be able to cache flush the > buffers correctly. But the failure in that case is a memory corruption > after the dma request is completed. > Thanks for the advices. I've managed to figure out that dma_map_single fails because dev->dma_mask was a NULL pointer. I've set it during probe with this: dma_coerce_mask_and_coherent(&ndev->dev, DMA_BIT_MASK(32)); And the mappings seems to be set up properly (a bit below 512M), but the returned buffers are filled up with 0xAA, which I guess is probably some default value. Turning on and off CONFIG_ARM_LPAE did not helped. I'll keep looking why is that, if you have an idea let me know. Zoli