All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: "Baruch Siach" <baruch@tkos.co.il>,
	"Christoph Hellwig" <hch@lst.de>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	"Will Deacon" <will@kernel.org>,
	iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-s390@vger.kernel.org, "Petr Tesařík" <petr@tesarici.cz>,
	"Ramon Fried" <ramon@neureality.ai>,
	"Elad Nachman" <enachman@marvell.com>
Subject: Re: [PATCH v5 1/3] dma: improve DMA zone selection
Date: Wed, 7 Aug 2024 14:58:49 +0100	[thread overview]
Message-ID: <ZrN9mRoQj2lTo6L5@arm.com> (raw)
In-Reply-To: <8230985e-1581-411f-895c-b49065234520@arm.com>

Thanks Robin for having a look.

On Wed, Aug 07, 2024 at 02:13:06PM +0100, Robin Murphy wrote:
> On 2024-08-02 7:03 am, Baruch Siach wrote:
> > When device DMA limit does not fit in DMA32 zone it should use DMA zone,
> > even when DMA zone is stricter than needed.
> > 
> > Same goes for devices that can't allocate from the entire normal zone.
> > Limit to DMA32 in that case.
> 
> Per the bot report this only works for CONFIG_ARCH_KEEP_MEMBLOCK,

Yeah, I just noticed.

> however
> the whole concept looks wrong anyway. The logic here is that we're only
> forcing a particular zone if there's *no* chance of the higher zone being
> usable. For example, ignoring offsets for simplicity, if we have a 40-bit
> DMA mask then we *do* want to initially try allocating from ZONE_NORMAL even
> if max_pfn is above 40 bits, since we still might get a usable allocation
> from between 32 and 40 bits, and if we don't, then we'll fall back to
> retrying from the DMA zone(s) anyway.

Ah, I did not read the code further down in __dma_direct_alloc_pages(),
it does fall back to a GFP_DMA allocation if !dma_coherent_ok().
Similarly with swiotlb_alloc_tlb(), it keeps retrying until the
allocation fails.

So yes, this patch can be dropped.

-- 
Catalin

WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: linux-s390@vger.kernel.org, "Baruch Siach" <baruch@tkos.co.il>,
	"Ramon Fried" <ramon@neureality.ai>,
	"Petr Tesařík" <petr@tesarici.cz>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	iommu@lists.linux.dev, "Elad Nachman" <enachman@marvell.com>,
	"Will Deacon" <will@kernel.org>, "Christoph Hellwig" <hch@lst.de>,
	linux-arm-kernel@lists.infradead.org,
	"Marek Szyprowski" <m.szyprowski@samsung.com>
Subject: Re: [PATCH v5 1/3] dma: improve DMA zone selection
Date: Wed, 7 Aug 2024 14:58:49 +0100	[thread overview]
Message-ID: <ZrN9mRoQj2lTo6L5@arm.com> (raw)
In-Reply-To: <8230985e-1581-411f-895c-b49065234520@arm.com>

Thanks Robin for having a look.

On Wed, Aug 07, 2024 at 02:13:06PM +0100, Robin Murphy wrote:
> On 2024-08-02 7:03 am, Baruch Siach wrote:
> > When device DMA limit does not fit in DMA32 zone it should use DMA zone,
> > even when DMA zone is stricter than needed.
> > 
> > Same goes for devices that can't allocate from the entire normal zone.
> > Limit to DMA32 in that case.
> 
> Per the bot report this only works for CONFIG_ARCH_KEEP_MEMBLOCK,

Yeah, I just noticed.

> however
> the whole concept looks wrong anyway. The logic here is that we're only
> forcing a particular zone if there's *no* chance of the higher zone being
> usable. For example, ignoring offsets for simplicity, if we have a 40-bit
> DMA mask then we *do* want to initially try allocating from ZONE_NORMAL even
> if max_pfn is above 40 bits, since we still might get a usable allocation
> from between 32 and 40 bits, and if we don't, then we'll fall back to
> retrying from the DMA zone(s) anyway.

Ah, I did not read the code further down in __dma_direct_alloc_pages(),
it does fall back to a GFP_DMA allocation if !dma_coherent_ok().
Similarly with swiotlb_alloc_tlb(), it keeps retrying until the
allocation fails.

So yes, this patch can be dropped.

-- 
Catalin

  reply	other threads:[~2024-08-07 13:58 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-02  6:03 [PATCH v5 0/3] dma: support DMA zone starting above 4GB Baruch Siach
2024-08-02  6:03 ` Baruch Siach via Linuxppc-dev
2024-08-02  6:03 ` [PATCH v5 1/3] dma: improve DMA zone selection Baruch Siach
2024-08-02  6:03   ` Baruch Siach via Linuxppc-dev
2024-08-07 12:04   ` kernel test robot
2024-08-07 12:04     ` kernel test robot
2024-08-07 13:13   ` Robin Murphy
2024-08-07 13:13     ` Robin Murphy
2024-08-07 13:58     ` Catalin Marinas [this message]
2024-08-07 13:58       ` Catalin Marinas
2024-08-07 14:12       ` Petr Tesařík
2024-08-07 14:12         ` Petr Tesařík
2024-08-07 16:40   ` kernel test robot
2024-08-07 16:40     ` kernel test robot
2024-08-02  6:03 ` [PATCH v5 2/3] dma: replace zone_dma_bits by zone_dma_limit Baruch Siach
2024-08-02  6:03   ` Baruch Siach via Linuxppc-dev
2024-08-02  9:37   ` Catalin Marinas
2024-08-02  9:37     ` Catalin Marinas
2024-08-07 14:19     ` Petr Tesařík
2024-08-07 14:19       ` Petr Tesařík
2024-08-07 18:14       ` Catalin Marinas
2024-08-07 18:14         ` Catalin Marinas
2024-08-08  9:35         ` Petr Tesařík
2024-08-08  9:35           ` Petr Tesařík
2024-08-08 10:01           ` Robin Murphy
2024-08-08 10:01             ` Robin Murphy
2024-08-08 13:46           ` Catalin Marinas
2024-08-08 13:46             ` Catalin Marinas
2024-08-07 14:30   ` Petr Tesařík
2024-08-07 14:30     ` Petr Tesařík
2024-08-02  6:03 ` [PATCH v5 3/3] arm64: support DMA zone above 4GB Baruch Siach
2024-08-02  6:03   ` Baruch Siach via Linuxppc-dev

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=ZrN9mRoQj2lTo6L5@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=baruch@tkos.co.il \
    --cc=enachman@marvell.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=m.szyprowski@samsung.com \
    --cc=petr@tesarici.cz \
    --cc=ramon@neureality.ai \
    --cc=robin.murphy@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.