IOMMU Archive on lore.kernel.org
 help / color / Atom feed
From: Nicolin Chen <nicoleotsuka@gmail.com>
To: Hillf Danton <hdanton@sina.com>,
	Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org, ath10k@lists.infradead.org,
	davem@davemloft.net, iommu@lists.linux-foundation.org,
	tobias.klausmann@freenet.de, robin.murphy@arm.com,
	Christoph Hellwig <hch@lst.de>,
	kvalo@codeaurora.org
Subject: Re: regression in ath10k dma allocation
Date: Mon, 19 Aug 2019 18:58:52 -0700
Message-ID: <20190820015852.GA15830@Asurada-Nvidia.nvidia.com> (raw)
In-Reply-To: <acd7a4b0-fde8-1aa2-af07-2b469e5d5ca7@mni.thm.de>

Hello Hillf,

On Mon, Aug 19, 2019 at 12:38:38AM +0200, Tobias Klausmann wrote:
> 
> On 18.08.19 05:13, Hillf Danton wrote:
> > On Sat, 17 Aug 2019 00:42:48 +0200 Tobias Klausmann wrote:
> > > Hi Nicolin,
> > > 
> > > On 17.08.19 00:25, Nicolin Chen wrote:
> > > > Hi Tobias
> > > > 
> > > > On Fri, Aug 16, 2019 at 10:16:45PM +0200, Tobias Klausmann wrote:
> > > > > > do you have CONFIG_DMA_CMA set in your config?  If not please make sure
> > > > > > you have this commit in your testing tree, and if the problem still
> > > > > > persists it would be a little odd and we'd have to dig deeper:
> > > > > > 
> > > > > > commit dd3dcede9fa0a0b661ac1f24843f4a1b1317fdb6
> > > > > > Author: Nicolin Chen <nicoleotsuka@gmail.com>
> > > > > > Date:   Wed May 29 17:54:25 2019 -0700
> > > > > > 
> > > > > >        dma-contiguous: fix !CONFIG_DMA_CMA version of dma_{alloc, free}_contiguous()
> > > > > yes CONFIG_DMA_CMA is set (=y, see attached config), the commit you mention
> > > > > above is included, if you have any hints how to go forward, please let me
> > > > > know!
> > > > For CONFIG_DMA_CMA=y, by judging the log with error code -12, I
> > > > feel this one should work for you. Would you please check if it
> > > > is included or try it out otherwise?
> > > > 
> > > > dma-contiguous: do not overwrite align in dma_alloc_contiguous()
> > > > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c6622a425acd1d2f3a443cd39b490a8777b622d7
> > > 
> > > Thanks for the hint, yet the commit is included and does not fix the
> > > problem!
> > > 
> Hi Hillf,
> 
> i just tested you first hunk (which comes from kernel/dma/direct.c if i'm
> not mistaken), it did not compile on its own, yet with a tiny bit of work it
> did, and it does indeed solve the regression. But if using that is the
> "right" way to do it, not sure, but its not on me to decide.
> 
> Anyway: Thanks for the hint,
> 
> Tobias
> 
> 
> > Hi Tobias
> > 
> > Two minor diffs below in hope that they might make sense.
> > 
> > 1, fallback unless dma coherent ok.
> > 
> > --- a/kernel/dma/contiguous.c
> > +++ b/kernel/dma/contiguous.c
> > @@ -246,6 +246,10 @@ struct page *dma_alloc_contiguous(struct
> >   		size_t cma_align = min_t(size_t, align, CONFIG_CMA_ALIGNMENT);
> >   		page = cma_alloc(cma, count, cma_align, gfp & __GFP_NOWARN);
> > +		if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) {
> > +			dma_free_contiguous(dev, page, size);
> > +			page = NULL;
> > +		}

Right...the condition was in-between. However, not every caller
of dma_alloc_contiguous() is supposed to have a coherent check.
So we either add a 'bool coherent_ok' to the API or revert the
dma-direct part back to the original. Probably former option is
better?

Thank you for the debugging. I have been a bit distracted, may
not be able to submit a fix very soon. Would you like to help?

Thanks!
Nicolin

> >   	}
> >   	/* Fallback allocation of normal pages */
> > --
> > 
> > 2, cleanup: cma unless contiguous
> > 
> > --- a/kernel/dma/contiguous.c
> > +++ b/kernel/dma/contiguous.c
> > @@ -234,18 +234,13 @@ struct page *dma_alloc_contiguous(struct
> >   	size_t count = PAGE_ALIGN(size) >> PAGE_SHIFT;
> >   	size_t align = get_order(PAGE_ALIGN(size));
> >   	struct page *page = NULL;
> > -	struct cma *cma = NULL;
> > -
> > -	if (dev && dev->cma_area)
> > -		cma = dev->cma_area;
> > -	else if (count > 1)
> > -		cma = dma_contiguous_default_area;
> >   	/* CMA can be used only in the context which permits sleeping */
> > -	if (cma && gfpflags_allow_blocking(gfp)) {
> > +	if (count > 1 && gfpflags_allow_blocking(gfp)) {
> >   		size_t cma_align = min_t(size_t, align, CONFIG_CMA_ALIGNMENT);
> > -		page = cma_alloc(cma, count, cma_align, gfp & __GFP_NOWARN);
> > +		page = cma_alloc(dev_get_cma_area(dev), count, cma_align,
> > +							gfp & __GFP_NOWARN);
> >   		if (page && !dma_coherent_ok(dev, page_to_phys(page), size)) {
> >   			dma_free_contiguous(dev, page, size);
> >   			page = NULL;
> > --
> > 
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-16 16:08 Tobias Klausmann
2019-08-16 16:43 ` Christoph Hellwig
2019-08-16 20:16   ` Tobias Klausmann
2019-08-16 22:25     ` Nicolin Chen
2019-08-16 22:42       ` Tobias Klausmann
2019-08-18  3:13       ` Hillf Danton
2019-08-18 22:38         ` Tobias Klausmann
2019-08-20  1:58           ` Nicolin Chen [this message]
2019-08-20  2:14             ` Christoph Hellwig
2019-08-20  3:05           ` Christoph Hellwig
2019-08-20  6:58           ` Hillf Danton
2019-08-20  7:12             ` Christoph Hellwig
2019-08-20 20:24               ` Tobias Klausmann
2019-08-20  2:29 Hillf Danton

Reply instructions:

You may reply publically 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=20190820015852.GA15830@Asurada-Nvidia.nvidia.com \
    --to=nicoleotsuka@gmail.com \
    --cc=ath10k@lists.infradead.org \
    --cc=davem@davemloft.net \
    --cc=hch@lst.de \
    --cc=hdanton@sina.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=tobias.johannes.klausmann@mni.thm.de \
    --cc=tobias.klausmann@freenet.de \
    /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 iommu@archiver.kernel.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