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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 AF6B1C74A4B for ; Thu, 11 Jul 2019 11:10:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 685C221019 for ; Thu, 11 Jul 2019 11:10:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kS1Ab10W" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 685C221019 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NtpHtecPE1Qv5aH5FcmkANn+1a4YoYLXNdafBqhchug=; b=kS1Ab10WdbnYVz xvWSVwrawfWHlf/uwnjPD7p5kjt545ZLW38/Beo5VTsTbM7shlbHArj2+msTK9zYxqg07z58ChRKY 1eYob6mp+d5s7DN200c6DjtL5mfEVxC8RLNKNxjPJCHG0Uf0SsYX61if4I3xQM/uUmyByPxzF1CV5 5FGnaxx9mPSKXKbDUP4PcF+sKceNMOG5BCLpWX5Ilj1NS3/JuQikKKSkRcSgsb8AhWRjPB0zoDLxK BW4XpX35y20envcK03wAQreepWDtsl8N6NmXGblvnXr/sWJkiiJ6pQzR5Nq12uFSAZ9HV6l1UD/o8 Ec0utoBUeRgCnvrHKWvQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hlWyP-0000Wf-N6; Thu, 11 Jul 2019 11:10:49 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hlWyN-0000Vv-DN for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2019 11:10:48 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A99A9B0EA; Thu, 11 Jul 2019 11:10:43 +0000 (UTC) Message-ID: Subject: Re: Limiting the DMA zone in arm64 From: Nicolas Saenz Julienne To: Will Deacon Date: Thu, 11 Jul 2019 13:10:41 +0200 In-Reply-To: <20190711101717.meoyqu5h2zdptypf@willie-the-truck> References: <0439cc08532849b1d0adb44a7b2cbc9ce5dceaf7.camel@suse.de> <20190711101717.meoyqu5h2zdptypf@willie-the-truck> User-Agent: Evolution 3.32.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190711_041047_595506_F7C3C137 X-CRM114-Status: GOOD ( 22.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Wahren , Florian Fainelli , marc.zyngier@arm.com, andre.przywara@arm.com, phil@raspberrypi.org, Matthias Brugger , Catalin Marinas , robin.murphy@arm.com, linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Will, thanks for your response. [+ Matthias and Phill who might be interested ] On Thu, 2019-07-11 at 11:17 +0100, Will Deacon wrote: > Hi Nicolas, > > [+Robin, Andrew and Marc since we've been playing with getting arm64 Linux > up and running too] > > On Thu, Jul 11, 2019 at 11:51:57AM +0200, Nicolas Saenz Julienne wrote: > > I'm trying to bring up the new RPi4 on arm64, and running into issues with > > DMA > > allocations. The device has up to 4GB of ram, but AFAIK only the first GB of > > ram can be used for DMA: the DMA address range is 0xc0000000-0xffffffff > > which > > is aliased to the first GB of memory 0x00000000-0x40000000. > > Do you know for sure that these aliases are equivalant and so it's > inconsequential if we use the lower addresses for DMA? No, they are not exactly equivalent, see the 'dma-ranges' I posted on my other reply. I was being overly generic to make the explanation simpler. The actual size of the aliasing is smaller. That said, I don't think using the lower addresses would work for DMA. I tested some transfers and the offset is clearly being taken into account. > Also, does this > limitation apply to all DMA-capable peripherals, or just some of them? I infer from '.dma_zone_size = SZ_1G' and dma-ranges that it's a device wide limitation. Maybe Phill can contradict me. > > This is solved in arm32 using a board file with '.dma_zone_size = SZ_1G'. > > But I > > haven't found any similar mechanism for arm64. Any suggestions? > > > > Just it case it helps understand the issue, I managed to get things going by > > doing the following: > > > > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > > index f3c795278def..ec3cb7b76a76 100644 > > --- a/arch/arm64/mm/init.c > > +++ b/arch/arm64/mm/init.c > > @@ -407,7 +407,8 @@ void __init arm64_memblock_init(void) > > > > /* 4GB maximum for 32-bit only capable devices */ > > if (IS_ENABLED(CONFIG_ZONE_DMA32)) > > - arm64_dma_phys_limit = max_zone_dma_phys(); > > + arm64_dma_phys_limit = 0x40000000; > > else > > arm64_dma_phys_limit = PHYS_MASK + 1; > > My superficial understanding (mainly from talking to Robin, who actually > knows how this works), is that we'd need to extend our support for > dma-ranges in order to limit ZONE_DMA32 as you're proposing above. Noted. > However, this may not help for streaming DMA, where we need to force everything > above 1G through a bounce buffer and likely requires something weird like > a 30-bit DMA mask. > > Do you know how streaming DMA is handled in the 32-bit port for rpi4? Not really, I'll have a look and come back to you. Regards, Nicolas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel