From: Russell King - ARM Linux <linux@armlinux.org.uk>
To: Arnd Bergmann <arnd@arndb.de>
Cc: mst@redhat.com, will.deacon@arm.com,
virtualization@lists.linux-foundation.org, luto@kernel.org,
Robin Murphy <robin.murphy@arm.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] virtio_mmio: Set DMA masks appropriately
Date: Tue, 10 Jan 2017 13:25:43 +0000 [thread overview]
Message-ID: <20170110132543.GI14217@n2100.armlinux.org.uk> (raw)
In-Reply-To: <2220292.9CN9cxzsPe@wuerfel>
On Tue, Jan 10, 2017 at 02:15:57PM +0100, Arnd Bergmann wrote:
> On Tuesday, January 10, 2017 12:26:01 PM CET Robin Murphy wrote:
> > @@ -548,6 +550,14 @@ static int virtio_mmio_probe(struct platform_device *pdev)
> > if (vm_dev->version == 1)
> > writel(PAGE_SIZE, vm_dev->base + VIRTIO_MMIO_GUEST_PAGE_SIZE);
> >
> > + rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> > + if (rc)
> > + rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
>
> You don't seem to do anything different when 64-bit DMA is unsupported.
> How do you prevent the use of kernel buffers that are above the first 4G
> here?
>
> > + else if (vm_dev->version == 1)
> > + dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32 + PAGE_SHIFT));
>
> Why is this limitation only for the coherent mask?
It looks wrong for two reasons:
1. It is calling dma_set_coherent_mask(), so only the coherent mask
is being updated. What about streaming DMA?
Maybe include the comment from the commit you refer to (a0be1db4304f)
which explains this, which would help reviewers understand why you're
only changing the coherent mask.
2. It fails to check whether the coherent mask was accepted... which
I guess is okay, as the coherent allocation mask won't be updated
so you should get coherent memory below 4GB. Nevertheless, drivers
are expected to try setting a 32-bit coherent mask if setting a
larger mask fails. See examples in Documentation/DMA-API-HOWTO.txt.
Of course, if setting a 32-bit coherent mask fails, then the driver
should probably fail to initialise.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2017-01-10 13:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <50defbbe87d75db85a9d22f914258975d661208a.1484051089.git.robin.murphy@arm.com>
2017-01-10 13:15 ` [PATCH] virtio_mmio: Set DMA masks appropriately Arnd Bergmann
2017-01-10 13:25 ` Russell King - ARM Linux [this message]
2017-01-10 13:44 ` Robin Murphy
[not found] ` <c62753e7-2530-6e23-5a6c-77cf8bc92860@arm.com>
2017-01-10 14:10 ` Arnd Bergmann
2017-01-10 14:54 ` Michael S. Tsirkin
2017-01-10 15:55 ` Robin Murphy
[not found] ` <b60d0de1-a79b-50c0-f773-5a509b0e94d5@arm.com>
2017-01-10 16:07 ` Michael S. Tsirkin
2017-01-10 12:26 Robin Murphy
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=20170110132543.GI14217@n2100.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=luto@kernel.org \
--cc=mst@redhat.com \
--cc=robin.murphy@arm.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=will.deacon@arm.com \
/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).