From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32A59C67877 for ; Fri, 12 Oct 2018 17:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EDD9F21470 for ; Fri, 12 Oct 2018 17:05:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDD9F21470 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727787AbeJMAjU (ORCPT ); Fri, 12 Oct 2018 20:39:20 -0400 Received: from foss.arm.com ([217.140.101.70]:54906 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726665AbeJMAjU (ORCPT ); Fri, 12 Oct 2018 20:39:20 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 42E8115BF; Fri, 12 Oct 2018 10:05:54 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.80]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E43973F5D3; Fri, 12 Oct 2018 10:05:52 -0700 (PDT) Date: Fri, 12 Oct 2018 18:05:50 +0100 From: Catalin Marinas To: Christoph Hellwig Cc: Robin Murphy , Konrad Rzeszutek Wilk , Will Deacon , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 10/10] arm64: use the generic swiotlb_dma_ops Message-ID: <20181012170549.GD60150@arrakis.emea.arm.com> References: <20181008080246.20543-1-hch@lst.de> <20181008080246.20543-11-hch@lst.de> <8ae57670-ced9-5ebb-caf5-cc99f15fdf22@arm.com> <20181012144049.GA28925@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181012144049.GA28925@lst.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 12, 2018 at 04:40:49PM +0200, Christoph Hellwig wrote: > On Fri, Oct 12, 2018 at 02:01:00PM +0100, Robin Murphy wrote: > > On 08/10/18 09:02, Christoph Hellwig wrote: > >> Now that the generic swiotlb code supports non-coherent DMA we can switch > >> to it for arm64. For that we need to refactor the existing > >> alloc/free/mmap/pgprot helpers to be used as the architecture hooks, > >> and implement the standard arch_sync_dma_for_{device,cpu} hooks for > >> cache maintaincance in the streaming dma hooks, which also implies > >> using the generic dma_coherent flag in struct device. > >> > >> Note that we need to keep the old is_device_dma_coherent function around > >> for now, so that the shared arm/arm64 Xen code keeps working. > > > > OK, so when I said last night that it boot-tested OK, that much was true, > > but then I shut the board down as I left and got a megasplosion of bad page > > state BUGs, e.g.: > > I think this is because I am passing the wrong address to > dma_direct_free_pages. Please try this patch on top: > > diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c > index 3c75d69b54e7..4f0f92856c4c 100644 > --- a/arch/arm64/mm/dma-mapping.c > +++ b/arch/arm64/mm/dma-mapping.c > @@ -126,10 +126,12 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, > void arch_dma_free(struct device *dev, size_t size, void *vaddr, > dma_addr_t dma_handle, unsigned long attrs) > { > - if (__free_from_pool(vaddr, PAGE_ALIGN(size))) > - return; > - vunmap(vaddr); > - dma_direct_free_pages(dev, size, vaddr, dma_handle, attrs); > + if (!__free_from_pool(vaddr, PAGE_ALIGN(size))) > + void *kaddr = phys_to_virt(dma_to_phys(dev, dma_handle)); > + > + vunmap(vaddr); > + dma_direct_free_pages(dev, size, kaddr, dma_handle, attrs); > + } > } > > long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr, With this fix: Acked-by: Catalin Marinas