From: Alexander Graf <agraf@suse.de>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
rob.herring@linaro.org, devicetree@vger.kernel.org,
Will Deacon <Will.Deacon@arm.com>,
virtualization@lists.linux-foundation.org,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] virtio: Try to untangle DMA coherency
Date: Thu, 9 Feb 2017 23:20:30 +0100 [thread overview]
Message-ID: <8d239792-f33f-a811-e85d-36d191dd3c8a@suse.de> (raw)
In-Reply-To: <20170209225635-mutt-send-email-mst@kernel.org>
On 09/02/2017 21:57, Michael S. Tsirkin wrote:
> On Wed, Feb 08, 2017 at 01:58:10PM +0100, Alexander Graf wrote:
>> On 02/01/2017 08:19 PM, Michael S. Tsirkin wrote:
>>> On Wed, Feb 01, 2017 at 06:27:09PM +0000, Will Deacon wrote:
>>>> On Wed, Feb 01, 2017 at 08:09:21PM +0200, Michael S. Tsirkin wrote:
>>>>> On Wed, Feb 01, 2017 at 12:25:57PM +0000, Robin Murphy wrote:
>>>>>> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
>>>>>> index 7e38ed79c3fc..961af25b385c 100644
>>>>>> --- a/drivers/virtio/virtio_ring.c
>>>>>> +++ b/drivers/virtio/virtio_ring.c
>>>>>> @@ -20,6 +20,7 @@
>>>>>> #include <linux/virtio_ring.h>
>>>>>> #include <linux/virtio_config.h>
>>>>>> #include <linux/device.h>
>>>>>> +#include <linux/property.h>
>>>>>> #include <linux/slab.h>
>>>>>> #include <linux/module.h>
>>>>>> #include <linux/hrtimer.h>
>>>>>> @@ -160,10 +161,14 @@ static bool vring_use_dma_api(struct virtio_device *vdev)
>>>>>> return true;
>>>>>>
>>>>>> /*
>>>>>> - * On ARM-based machines, the DMA ops will do the right thing,
>>>>>> - * so always use them with legacy devices.
>>>>>> + * On ARM-based machines, the coherent DMA ops will do the right
>>>>>> + * thing, so always use them with legacy devices. However, using
>>>>>> + * non-coherent DMA when the host *is* actually coherent, but has
>>>>>> + * forgotten to tell us, is going to break badly; since this situation
>>>>>> + * already exists in the wild, maintain the old behaviour there.
>>>>>> */
>>>>>> - if (IS_ENABLED(CONFIG_ARM) || IS_ENABLED(CONFIG_ARM64))
>>>>>> + if ((IS_ENABLED(CONFIG_ARM) || IS_ENABLED(CONFIG_ARM64)) &&
>>>>>> + device_get_dma_attr(&vdev->dev) == DEV_DMA_COHERENT)
>>>>>> return !virtio_has_feature(vdev, VIRTIO_F_VERSION_1);
>>>>>>
>>>>>> return false;
>>>>>
>>>>> This is exactly what I feared.
>>>>
>>>> Yes, sorry about this. It works fine for virtio-pci (where "dma-coherent"
>>>> is used) and it also works on the fastmodel if you disable cache-modelling
>>>> (which is needed to make the thing run at a usable pace) so we didn't spot
>>>> this in testing.
>>>>
>>>>> Could we identify fastboot and do the special dance just for it?
>>>>
>>>> [assuming you mean fastmodel instead of fastboot]
>>>>
>>>>> I'd like to do that instead. It's fastboot doing the unreasonable thing
>>>>> here and deviating from what every other legacy device without exception
>>>>> did for years. If this means fastboot will need to update to virtio 1,
>>>>> all the better.
>>>>
>>>> The problem still exists with virtio 1, unless we require that the
>>>> "dma-coherent" property is set/unset correctly when VIRTIO_F_IOMMU_PLATFORM
>>>> is advertised by the device (which is what I suggested in my reply).
>>>
>>> I'm not ignoring that, but I need to understand that part a bit better.
>>> I'll reply to that patch in a day or two after looking at how _CCA is
>>> supposed to work.
>>>
>>>> We can't detect the fastmodel,
>>>
>>> Surely, it puts a hardware id somewhere? I think you mean
>>> fastmodel isn't always affected, right?
>>>
>>>> but we could implicitly treat virtio-mmio
>>>> devices as cache-coherent regardless of the "dma-coherent" flag. I already
>>>> prototyped this, but I suspect the devicetree people will push back (and
>>>> there's a similar patch needed for ACPI).
>>>>
>>>> See below. Do you prefer this approach?
>>>>
>>>> Will
>>>>
>>>> --->8
>>>
>>> I'd like to see basically
>>>
>>> if (fastmodel)
>>> a pile of special work-arounds
>>> else
>>> not less hacky but more common virtio work-arounds
>>>
>>> :)
>>>
>>> And then I can apply whatever comes from @arm.com and not
>>> worry about breaking actual hardware.
>>
>> I'm actually seeing the exact same breakage in QEMU right now, so it's not
>> fast model related at all. In QEMU we also don't properly set the
>> dma-coherent flag, so we run into cache coherency problems.
>>
>>
>> Alex
>
> But with latest revert QEMU should now work, right?
Yes, with the revert QEMU works fine. But please keep in mind that it's
not just the fast model that's broken here :).
Alex
prev parent reply other threads:[~2017-02-09 22:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-01 12:25 [PATCH] virtio: Try to untangle DMA coherency Robin Murphy
2017-02-01 14:57 ` Will Deacon
[not found] ` <20170201145711.GC8177-5wv7dgnIgG8@public.gmane.org>
2017-02-01 17:58 ` Rob Herring
[not found] ` <8a6494f6409c20b4609cd6bdcdd751f68b5c0564.1485951731.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2017-02-01 18:09 ` Michael S. Tsirkin
2017-02-01 18:27 ` Will Deacon
[not found] ` <20170201182659.GM8177-5wv7dgnIgG8@public.gmane.org>
2017-02-01 19:19 ` Michael S. Tsirkin
[not found] ` <20170201210648-mutt-send-email-mst-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-02-02 11:26 ` Will Deacon
2017-02-02 13:34 ` Robin Murphy
[not found] ` <bb041fbe-3fde-0dc1-ae28-cca5acfe9dc5-5wv7dgnIgG8@public.gmane.org>
2017-02-02 16:16 ` Michael S. Tsirkin
[not found] ` <20170202181357-mutt-send-email-mst-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-02-02 16:39 ` Marc Zyngier
[not found] ` <d9732885-7cd2-461c-6812-37581294b47f-5wv7dgnIgG8@public.gmane.org>
2017-02-02 16:44 ` Michael S. Tsirkin
2017-02-02 16:30 ` Michael S. Tsirkin
2017-02-02 16:40 ` Will Deacon
[not found] ` <20170202164049.GI13839-5wv7dgnIgG8@public.gmane.org>
2017-02-02 16:45 ` Michael S. Tsirkin
2017-02-09 18:17 ` Michael S. Tsirkin
2017-02-09 18:31 ` Will Deacon
2017-02-09 18:49 ` Michael S. Tsirkin
2017-02-09 18:54 ` Ard Biesheuvel
2017-02-09 18:56 ` Will Deacon
2017-02-10 17:16 ` Michael S. Tsirkin
2017-02-13 11:57 ` Will Deacon
2017-02-08 12:58 ` Alexander Graf
2017-02-09 20:57 ` Michael S. Tsirkin
2017-02-09 22:20 ` Alexander Graf [this message]
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=8d239792-f33f-a811-e85d-36d191dd3c8a@suse.de \
--to=agraf@suse.de \
--cc=Will.Deacon@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=mst@redhat.com \
--cc=rob.herring@linaro.org \
--cc=virtualization@lists.linux-foundation.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).