From: Julien Grall <julien@xen.org>
To: Roman Skakun <Roman_Skakun@epam.com>,
"sstabellini@kernel.org" <sstabellini@kernel.org>
Cc: Bertrand Marquis <bertrand.marquis@arm.com>,
Andrii Anisov <Andrii_Anisov@epam.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
Oleksandr Tyshchenko <Oleksandr_Tyshchenko@epam.com>,
Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Roman Skakun <rm.skakun@gmail.com>,
Jan Beulich <jbeulich@suse.com>
Subject: Re: Disable swiotlb for Dom0
Date: Wed, 11 Aug 2021 16:20:42 +0100 [thread overview]
Message-ID: <691e31db-c79b-9196-53e1-cbbdc9bd3a54@xen.org> (raw)
In-Reply-To: <AM7PR03MB6593834BA54AD8A126EF872185F89@AM7PR03MB6593.eurprd03.prod.outlook.com>
Hi,
On 11/08/2021 15:13, Roman Skakun wrote:
>> > Also, I added the log in xen_swiotlb_detect() and can see that swiotlb
>> > still used (other devices within dom0 used too), when dom0 is direct
> mapped:
>> >
>> > [ 1.870363] xen_swiotlb_detect() dev: rcar-fcp,
>> > XENFEAT_direct_mapped, use swiotlb
>> > [ 1.878352] xen_swiotlb_detect() dev: rcar-fcp,
>> > XENFEAT_direct_mapped, use swiotlb
>> > [ 1.886309] xen_swiotlb_detect() dev: rcar-fcp,
>> > XENFEAT_direct_mapped, use swiotlb
>> >
>>> This means, that all devices are using swiotlb-xen DMA fops.
>> > By the way, before applying this patches, dom0 always used swiotlb-xen
>> > fops for initial domain by design.
>
>> >This is expected because your domain is direct mapped.
>
> May be, I don't understand right, Stefano reported the same issue when
> dom0 is not direct mapped,
> but I have direct mapped dom0 and problem still exists.
I am not entirely sure why you think this is the same problem as
Stefano. He asked to bypass the swiotlb, but AFAIK, this is not because
the buffer get bounced.
Instead, it is because swiotlb-xen on Arm has been relying on its RAM to
be direct-mapped (GFN == MFN). With cache coloring, the memory will not
be direct-mapped, hence it will be broken.
>
>>Ok. Would you be able to provide more information on where the dom0
>>memory is allocated and the list of host RAM?
>
> Host memory:
> DRAM: 7.9 GiB
> Bank #0: 0x048000000 - 0x0bfffffff, 1.9 GiB
> Bank #1: 0x500000000 - 0x57fffffff, 2 GiB
> Bank #2: 0x600000000 - 0x67fffffff, 2 GiB
> Bank #3: 0x700000000 - 0x77fffffff, 2 GiB
>
> dom0 memory map:
> (XEN) Allocating 1:1 mappings totalling 2048MB for dom0:
> (XEN) BANK[0] 0x00000048000000-0x00000050000000 (128MB)
> (XEN) BANK[1] 0x00000058000000-0x000000c0000000 (1664MB)
> (XEN) BANK[2] 0x00000510000000-0x00000520000000 (256MB)
Thanks! So you have some memory assigned above 4GB to dom0 as well.
>>> We retrieved dev_addr(64b1d0000) + size > 32bit mask, but fcp driver
>>> wants to use only 32 bit boundary address, but that's consequence.
>>>
>> Ok. So your device is only capable to do a 32-bit DMA. Is that correct?
>
> Yes.
>
>> > I think, the main reason of using bounce buffer is MFN address, not DMA
>> > phys address.
>> >
>>I don't understand this sentence. Can you clarify it?
>
> This address looks like theMFN because I'm using mapped grant tables
> from domU.
>
> I've added the log and see the following:
> with swiotlb:
> [ 78.620386] dma_map_sg_attrs() dev: rcar-du swiotlb, sg_page:
> fffffe0001b80000, page_to_phy: b6000000, xen_phys_to_dma: 64b1d0000
>
> without swiotlb (worked fine):
> [ 74.456426] dma_map_sg_attrs() dev: rcar-du direct map, sg_page:
> fffffe0001b80000, page_to_phy: b6000000, xen_phys_to_dma:b6000000
>
> I guess, need to figure out why we got a normal dom0 DMA address
> (b6000000) and why 64b1d0000 when using swiotlb.
So 0xb6000000 is most likely the GFN used to mapped the grant from the domU.
swiotlb-xen on Arm will convert it to the MFN because it is not aware
whether the device is behind an IOMMU.
As the address is too high to be handled by the device, swiotlb will try
to bounce it. I think it is correct to bounce the page but I am not sure
why it can't. What the size of the DMA transaction?
However, even if you disable xen-swiotlb, you are likely going to face
the same issue sooner or later because the grant can be mapped anywhere
in the memory of dom0 (the balloon code doesn't look to restrict where
the memory can be allocated). So it is possible for the grant to be
mapped in the dom0 memory above 4GB.
Oleksandr is also looking to provide a safe range which would be outside
of the existing RAM. So, I believe, you will have to bounce the DMA
buffer unless we always force the grant/foreign mapping to be mapped
below 4GB.
Cheers,
--
Julien Grall
next prev parent reply other threads:[~2021-08-11 15:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-10 15:38 Disable swiotlb for Dom0 Roman Skakun
2021-08-10 16:16 ` Julien Grall
2021-08-11 8:49 ` Roman Skakun
2021-08-11 10:30 ` Julien Grall
2021-08-11 14:13 ` Roman Skakun
2021-08-11 15:20 ` Julien Grall [this message]
2021-08-13 9:38 ` Roman Skakun
2021-08-13 10:51 ` Julien Grall
2021-08-13 15:59 ` Roman Skakun
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=691e31db-c79b-9196-53e1-cbbdc9bd3a54@xen.org \
--to=julien@xen.org \
--cc=Andrii_Anisov@epam.com \
--cc=Oleksandr_Andrushchenko@epam.com \
--cc=Oleksandr_Tyshchenko@epam.com \
--cc=Roman_Skakun@epam.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=jbeulich@suse.com \
--cc=rm.skakun@gmail.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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).