IOMMU Archive on lore.kernel.org
 help / color / Atom feed
From: Hanjun Guo <guohanjun@huawei.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: devicetree@vger.kernel.org,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Will Deacon <will@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	linux-kernel@vger.kernel.org, jeremy.linton@arm.com,
	ardb@kernel.org, linux-acpi@vger.kernel.org,
	iommu@lists.linux-foundation.org, robh+dt@kernel.org,
	Linuxarm <linuxarm@huawei.com>,
	linux-arm-kernel@lists.infradead.org,
	Sudeep Holla <sudeep.holla@arm.com>, Len Brown <lenb@kernel.org>,
	robin.murphy@arm.com, hch@lst.de,
	linux-rpi-kernel@lists.infradead.org
Subject: Re: [PATCH v3 7/8] arm64: mm: Set ZONE_DMA size based on early IORT scan
Date: Fri, 16 Oct 2020 14:51:09 +0800
Message-ID: <35faab1c-5c32-6cd3-0a14-77057dd223f5@huawei.com> (raw)
In-Reply-To: <20201015180340.GB2624@gaia>

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 <ardb@kernel.org>
>>>
>>> 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
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply index

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-14 19:12 [PATCH v3 0/8] arm64: Default to 32-bit wide ZONE_DMA Nicolas Saenz Julienne
2020-10-14 19:12 ` [PATCH v3 1/8] arm64: mm: Move reserve_crashkernel() into mem_init() Nicolas Saenz Julienne
2020-10-15  8:40   ` Will Deacon
2020-10-15  8:55     ` Nicolas Saenz Julienne
2020-10-14 19:12 ` [PATCH v3 2/8] arm64: mm: Move zone_dma_bits initialization into zone_sizes_init() Nicolas Saenz Julienne
2020-10-14 19:12 ` [PATCH v3 3/8] of/address: Introduce of_dma_get_max_cpu_address() Nicolas Saenz Julienne
2020-10-14 22:02   ` Rob Herring
2020-10-15  6:56     ` Ard Biesheuvel
2020-10-15  9:16       ` Nicolas Saenz Julienne
2020-10-15  9:18         ` Ard Biesheuvel
2020-10-15  8:54     ` Nicolas Saenz Julienne
2020-10-15  5:42   ` Christoph Hellwig
2020-10-15 10:03     ` Nicolas Saenz Julienne
2020-10-16 13:19     ` Rob Herring
2020-10-14 19:12 ` [PATCH v3 4/8] of: unittest: Add test for of_dma_get_max_cpu_address() Nicolas Saenz Julienne
2020-10-14 22:04   ` Rob Herring
2020-10-15  9:51     ` Nicolas Saenz Julienne
2020-10-14 19:12 ` [PATCH v3 5/8] dma-direct: Turn zone_dma_bits default value into a define Nicolas Saenz Julienne
2020-10-15  5:38   ` Christoph Hellwig
2020-10-15 10:05     ` Nicolas Saenz Julienne
2020-10-14 19:12 ` [PATCH v3 6/8] arm64: mm: Set ZONE_DMA size based on devicetree's dma-ranges Nicolas Saenz Julienne
2020-10-15  5:39   ` Christoph Hellwig
2020-10-15 10:05     ` Nicolas Saenz Julienne
2020-10-14 19:12 ` [PATCH v3 7/8] arm64: mm: Set ZONE_DMA size based on early IORT scan Nicolas Saenz Julienne
2020-10-15 10:31   ` Lorenzo Pieralisi
2020-10-16  6:56     ` Ard Biesheuvel
2020-10-15 14:26   ` Hanjun Guo
2020-10-15 15:15     ` Nicolas Saenz Julienne
2020-10-15 18:03     ` Catalin Marinas
2020-10-16  6:51       ` Hanjun Guo [this message]
2020-10-16  6:54         ` Ard Biesheuvel
2020-10-16  7:27           ` Hanjun Guo
2020-10-16  7:34             ` Hanjun Guo
2020-10-14 19:12 ` [PATCH v3 8/8] mm: Update DMA zones description Nicolas Saenz Julienne
2020-10-15  5:40   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=35faab1c-5c32-6cd3-0a14-77057dd223f5@huawei.com \
    --to=guohanjun@huawei.com \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jeremy.linton@arm.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linuxarm@huawei.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=sudeep.holla@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

IOMMU Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iommu/0 linux-iommu/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iommu linux-iommu/ https://lore.kernel.org/linux-iommu \
		iommu@lists.linux-foundation.org
	public-inbox-index linux-iommu

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linux-foundation.lists.iommu


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git