From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH v3] arm DMA: Fix allocation from CMA for coherent DMA
Date: Mon, 29 Jun 2015 11:37:37 +0100 [thread overview]
Message-ID: <20150629103737.GC29907@e104818-lin.cambridge.arm.com> (raw)
In-Reply-To: <CAE=W-e3YUjT=KbYTizBwg+3huvFLDqHvhzZN-oPqEnOKUXAtoQ@mail.gmail.com>
On Sun, Jun 28, 2015 at 10:14:43PM +0200, Lorenzo Nava wrote:
> On Fri, Jun 26, 2015 at 6:25 PM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > On Thu, Jun 18, 2015 at 11:44:22PM +0200, Lorenzo Nava wrote:
> >> @@ -680,9 +694,14 @@ void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
> >> static void *arm_coherent_dma_alloc(struct device *dev, size_t size,
> >> dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs)
> >> {
> >> - pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL);
> >> + pgprot_t prot;
> >> void *memory;
> >>
> >> + if (attrs == NULL)
> >> + prot = PAGE_KERNEL;
> >> + else
> >> + prot = __get_dma_pgprot(attrs, PAGE_KERNEL);
> >> +
> >> if (dma_alloc_from_coherent(dev, size, handle, &memory))
> >> return memory;
> >
> > I still think this is the wrong way to fix. It doesn't address the
> > coherent dma mmap operation. I already replied on the previous version
> > that we should rather have an extra argument "coherent" to
> > __get_dma_pgprot().
>
> I avoided touching the __get_dma_pgprot() function because it affects
> a lot of different functions.
> If you think that the implementation you suggested in previous reply
> was ok and doesn't introduce problems on the other functions using the
> __get_dma_pgprot(), for me it's of course ok as well.
I forgot about the arm_dma_mmap fix here:
https://lkml.org/lkml/2015/5/7/512
So we either fix both cases by changing __get_dma_pgprot() or just go
for Mike's and your patches as above. It's up to Russell.
At some point, we could do with some more clean-up in the dma-mapping.c.
For example, both __alloc_simple_buffer() and __alloc_from_contiguous()
end up calling __dma_clear_buffer() even when not necessary (cacheable
mapping). Not too bad though as this is only done when setting up the
buffer.
> Do you see any code that maybe need a double check: I'm thinking, for
> example, at the function arm_iommu_alloc_attrs() and
> arm_iommu_mmap_attrs()?
I think this has bigger problems. The code seems to only be right for
non-cacheable mappings. For cacheable/coherent iommu mappings, I don't
see any use of the IOMMU_CACHE attribute (should it be returned by
__dma_direction_to_prot?).
--
Catalin
next prev parent reply other threads:[~2015-06-29 10:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-18 21:44 [RFC PATCH v3] arm DMA: Fix allocation from CMA for coherent DMA Lorenzo Nava
2015-06-26 16:25 ` Catalin Marinas
2015-06-28 20:14 ` Lorenzo Nava
2015-06-29 10:37 ` Catalin Marinas [this message]
2015-06-29 10:46 ` Russell King - ARM Linux
2015-06-29 11:05 ` Catalin Marinas
2015-06-29 11:30 ` Russell King - ARM Linux
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=20150629103737.GC29907@e104818-lin.cambridge.arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).