Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1034784pxu; Fri, 16 Oct 2020 02:02:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCF33z1XQJ63Q2XHsVCEirbZZKgIpFoagbNmk+KALfUWiowJNObbh9TRhSsFHi7VMNhHEx X-Received: by 2002:a17:907:382:: with SMTP id ss2mr2787256ejb.544.1602838920514; Fri, 16 Oct 2020 02:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602838920; cv=none; d=google.com; s=arc-20160816; b=PgVfHk4o7XOSWSpMMZsUQ5ck0I8Iyhr/6b1byz/idL1ZXFuweDcmIQVIMChgoOLn8o Tzh2XlRzQ3gy20k97d0fdEOElsXCmslHhQ6HX3swPlvV0zOLNdo5e+CZQKwwBTWiwSnK 5+Z5mmI2g2xnGHsOXKuaP+mOrtzjd8GrWafH7sfq/rVUs4L+Tjyn8aHWyTGyAkvu5xHp cLBOWd997Gzi1HIdzsJxPosrbrOluHu0PVXiekR9+ByxkcHUs5zkN9Y5sDV/Sz5MpkLF 772Q7HcKeE2VRmiNbG+LnwLCStMZolaNFhEnM71R5mKPEdG3oWslSD8YmkCamQIw4jgF L8Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=BpgeVRRTtp2pFGv5SN3FPM2KLub2sL9ycZBWNRgmEEw=; b=E+f6ngaQ/ZcoleBr6vR6aFCodl8epOT3qqV4xDSiouTd9Czq3jR2+/H0mkaskrGyiC c4HOZ5kbTy8//qdFrdQlDi73btGoUt26fyxbp023PqZclpHatlQcAvruI/7KJvioNR5Z qVJUFGVM8pnHBaCzwe9szOopAmIYSFFoVgVwpOpOXbYakkcg0lopvchhMsOWBG6Xasqo Ncoan7rSeVzNCW+7tgOY+6/5RKJr3Bo8TnMoNRQLtgqzj0PF0D3f/YCMggxFuP8OlHgD QM/tGmMPToapYRw0P1+3JQGyfoxQyEoGEjNfwM2Z4KOyjVrq9nNoKbcPAPhtxher3P+3 JAGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n13si1211959eji.447.2020.10.16.02.01.37; Fri, 16 Oct 2020 02:02:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394455AbgJPGv1 (ORCPT + 99 others); Fri, 16 Oct 2020 02:51:27 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:15302 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2391881AbgJPGv0 (ORCPT ); Fri, 16 Oct 2020 02:51:26 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 419B7DF0B12213270867; Fri, 16 Oct 2020 14:51:17 +0800 (CST) Received: from [10.174.179.182] (10.174.179.182) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 16 Oct 2020 14:51:09 +0800 Subject: Re: [PATCH v3 7/8] arm64: mm: Set ZONE_DMA size based on early IORT scan To: Catalin Marinas CC: Nicolas Saenz Julienne , , , , , "Lorenzo Pieralisi" , Sudeep Holla , , , , , , , "Anshuman Khandual" , Will Deacon , "Rafael J. Wysocki" , Len Brown , , Linuxarm References: <20201014191211.27029-1-nsaenzjulienne@suse.de> <20201014191211.27029-8-nsaenzjulienne@suse.de> <1a3df60a-4568-cb72-db62-36127d0ffb7e@huawei.com> <20201015180340.GB2624@gaia> From: Hanjun Guo Message-ID: <35faab1c-5c32-6cd3-0a14-77057dd223f5@huawei.com> Date: Fri, 16 Oct 2020 14:51:09 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20201015180340.GB2624@gaia> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.182] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/10/16 2:03, Catalin Marinas wrote: > On Thu, Oct 15, 2020 at 10:26:18PM +0800, Hanjun Guo wrote: >> On 2020/10/15 3:12, Nicolas Saenz Julienne wrote: >>> From: Ard Biesheuvel >>> >>> We recently introduced a 1 GB sized ZONE_DMA to cater for platforms >>> incorporating masters that can address less than 32 bits of DMA, in >>> particular the Raspberry Pi 4, which has 4 or 8 GB of DRAM, but has >>> peripherals that can only address up to 1 GB (and its PCIe host >>> bridge can only access the bottom 3 GB) >>> >>> Instructing the DMA layer about these limitations is straight-forward, >>> even though we had to fix some issues regarding memory limits set in >>> the IORT for named components, and regarding the handling of ACPI _DMA >>> methods. However, the DMA layer also needs to be able to allocate >>> memory that is guaranteed to meet those DMA constraints, for bounce >>> buffering as well as allocating the backing for consistent mappings. >>> >>> This is why the 1 GB ZONE_DMA was introduced recently. Unfortunately, >>> it turns out the having a 1 GB ZONE_DMA as well as a ZONE_DMA32 causes >>> problems with kdump, and potentially in other places where allocations >>> cannot cross zone boundaries. Therefore, we should avoid having two >>> separate DMA zones when possible. >>> >>> So let's do an early scan of the IORT, and only create the ZONE_DMA >>> if we encounter any devices that need it. This puts the burden on >>> the firmware to describe such limitations in the IORT, which may be >>> redundant (and less precise) if _DMA methods are also being provided. >>> However, it should be noted that this situation is highly unusual for >>> arm64 ACPI machines. Also, the DMA subsystem still gives precedence to >>> the _DMA method if implemented, and so we will not lose the ability to >>> perform streaming DMA outside the ZONE_DMA if the _DMA method permits >>> it. >> >> Sorry, I'm still a little bit confused. With this patch, if we have >> a device which set the right _DMA method (DMA size >= 32), but with the >> wrong DMA size in IORT, we still have the ZONE_DMA created which >> is actually not needed? > > With the current kernel, we get a ZONE_DMA already with an arbitrary > size of 1GB that matches what RPi4 needs. We are trying to eliminate > such unnecessary ZONE_DMA based on some heuristics (well, something that > looks "better" than a OEM ID based quirk). Now, if we learn that IORT > for platforms in the field is that broken as to describe few bits-wide > DMA masks, we may have to go back to the OEM ID quirk. Some platforms using 0 as the memory size limit, for example D05 [0] and D06 [1], I think we need to go back to the OEM ID quirk. For D05/D06, there are multi interrupt controllers named as mbigen, mbigen is using the named component to describe the mappings with the ITS controller, and mbigen is using 0 as the memory size limit. Also since the memory size limit for PCI RC was introduced by later IORT revision, so firmware people may think it's fine to set that as 0 because the system works without it. Thanks Hanjun [0]: https://github.com/tianocore/edk2-platforms/blob/master/Silicon/Hisilicon/Hi1616/D05AcpiTables/D05Iort.asl [1]: https://github.com/tianocore/edk2-platforms/blob/master/Silicon/Hisilicon/Hi1620/Hi1620AcpiTables/Hi1620Iort.asl