All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Shaposhnik <roman@zededa.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: "Jürgen Groß" <jgross@suse.com>, "Peng Fan" <peng.fan@nxp.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Julien Grall" <julien@xen.org>,
	"minyard@acm.org" <minyard@acm.org>,
	"jeff.kubascik@dornerworks.com" <jeff.kubascik@dornerworks.com>,
	"Julien Grall" <julien.grall@arm.com>,
	"Nataliya Korovkina" <malus.brandywine@gmail.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"Stefano Stabellini" <stefano.stabellini@xilinx.com>
Subject: Re: Troubles running Xen on Raspberry Pi 4 with 5.6.1 DomU
Date: Wed, 6 May 2020 14:10:56 -0700	[thread overview]
Message-ID: <CAMmSBy_2o6tsE1fsu_9=h8erOd9yHV-+ZkduTGqa-Gw7ra3mVQ@mail.gmail.com> (raw)
In-Reply-To: <a802a0d5-3ae3-97f5-af58-2e58123fec22@oracle.com>

On Wed, May 6, 2020 at 10:36 AM Boris Ostrovsky
<boris.ostrovsky@oracle.com> wrote:
>
>
> On 5/6/20 12:14 PM, Nataliya Korovkina wrote:
> > On Wed, May 6, 2020 at 9:43 AM Boris Ostrovsky
> > <boris.ostrovsky@oracle.com> wrote:
> >>
> >> On 5/6/20 9:08 AM, Nataliya Korovkina wrote:
> >>> Hello,
> >>>
> >>> What I found out: rpi_firmware_property_list() allocates memory from
> >>> dma_atomic_pool which was mapped to VMALLOC region, so virt_to_page()
> >>> is not eligible in this case.
> >>
> >> So then it seems it didn't go through xen_swiotlb_alloc_coherent(). In
> >> which case it has no business calling xen_swiotlb_free_coherent().
> >>
> >>
> >> -boris
> >>
> >>
> >>
> >>
> > It does go.
> > dma_alloc_coherent() indirectly calls xen_swiotlb_alloc_coherent(),
> > then  xen_alloc_coherent_pages() eventually calls arch_dma_alloc() in
> > remap.c which successfully allocates pages from atomic pool.
>
>
> Yes, I was looking at x86's implementation of xen_alloc_coherent_pages().
>
>
> >
> > The patch Julien offered for domian_build.c moved Dom0 banks in the
> > first G of RAM.
> > So it covered the previous symptom (a crash during allocation) because
> > now we avoid pathway  when we mark a page "XenMapped".
> >
> > But the symptom still remains in xen_swiotlb_free_coherent() because
> > "TestPage..." is called unconditionally. virt_to_page() is not
> > applicable to such allocations.
>
>
> Perhaps we just need to make sure we are using right virt-to-page
> method. Something like
>
>
> diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
> index b6d2776..f224e69 100644
> --- a/drivers/xen/swiotlb-xen.c
> +++ b/drivers/xen/swiotlb-xen.c
> @@ -335,6 +335,7 @@ int __ref xen_swiotlb_init(int verbose, bool early)
>         int order = get_order(size);
>         phys_addr_t phys;
>         u64 dma_mask = DMA_BIT_MASK(32);
> +       struct page *pg;
>
>         if (hwdev && hwdev->coherent_dma_mask)
>                 dma_mask = hwdev->coherent_dma_mask;
> @@ -346,9 +347,12 @@ int __ref xen_swiotlb_init(int verbose, bool early)
>         /* Convert the size to actually allocated. */
>         size = 1UL << (order + XEN_PAGE_SHIFT);
>
> +       pg = is_vmalloc_addr(vaddr) ? vmalloc_to_page(vaddr) :
> virt_to_page(vaddr);
> +       BUG_ON(!pg);
> +
>         if (!WARN_ON((dev_addr + size - 1 > dma_mask) ||
>                      range_straddles_page_boundary(phys, size)) &&
> -           TestClearPageXenRemapped(virt_to_page(vaddr)))
> +           TestClearPageXenRemapped(pg))
>                 xen_destroy_contiguous_region(phys, order);
>
>         xen_free_coherent_pages(hwdev, size, vaddr, (dma_addr_t)phys,
> attrs);
>
>
> (I have not tested this at all)

That's where I come in ;-)

It appears that your patch gets us closest to a fully functional 5.6.x
kernel under Xen on RPi4.

Thank you so much for that!

However, here's an interesting side-effect I'm now observing -- with
your patch + original
patch from Stefano (the one that only applies to
include/xen/arm/page-coherent.h) I can
now boot my RPi4 into a pretty functional system.

However, it is only possible if I allocate 512M (or fewer) memory
chunk to Dom0. If I try
to go higher (820M for example) and all the way to 1G -- I start getting:

[    3.195851] mmc0: unrecognised SCR structure version 7
[    3.200454] mmc0: error -22 whilst initialising SD card

and my SD card stays offline.

This is pretty reliable, and I guess is still related to some kind of
a DMA issue perhaps?

Thanks,
Roman.


  reply	other threads:[~2020-05-06 21:11 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01  2:20 Troubles running Xen on Raspberry Pi 4 with 5.6.1 DomU Roman Shaposhnik
2020-05-01 11:42 ` Corey Minyard
2020-05-02  1:06   ` Roman Shaposhnik
2020-05-02  2:16     ` Corey Minyard
2020-05-02 11:46       ` Julien Grall
2020-05-02 17:35         ` Corey Minyard
2020-05-02 17:48           ` Julien Grall
2020-05-04 12:44             ` Corey Minyard
2020-05-04 20:54               ` Roman Shaposhnik
2020-05-05  3:52                 ` Stefano Stabellini
2020-05-05  5:36                   ` Roman Shaposhnik
2020-05-05 22:34                     ` Stefano Stabellini
2020-05-06  1:25                       ` Boris Ostrovsky
2020-05-06  4:19                       ` Roman Shaposhnik
2020-05-06  5:41                       ` Jürgen Groß
2020-05-06  8:54                         ` Peng Fan
2020-05-06 13:08                           ` Nataliya Korovkina
2020-05-06 13:42                             ` Boris Ostrovsky
2020-05-06 16:14                               ` Nataliya Korovkina
2020-05-06 17:34                                 ` Stefano Stabellini
2020-05-06 21:12                                   ` Roman Shaposhnik
2020-05-13  0:33                                     ` Stefano Stabellini
2020-05-13 10:11                                       ` Julien Grall
2020-05-13 15:11                                         ` Stefano Stabellini
2020-05-13 18:19                                           ` Julien Grall
2020-05-13 18:26                                             ` Julien Grall
2020-05-13 19:51                                               ` Stefano Stabellini
2020-06-02 18:34                                                 ` Corey Minyard
2020-06-02 19:24                                                   ` Stefano Stabellini
2020-06-03 15:29                                                     ` Corey Minyard
2020-06-03 15:37                                                       ` Stefano Stabellini
2020-06-03 19:49                                                         ` Corey Minyard
2020-06-03 19:55                                                         ` Roman Shaposhnik
2020-05-13 19:13                                             ` Roman Shaposhnik
2020-05-13 19:49                                             ` Stefano Stabellini
2020-05-06 17:35                                 ` Boris Ostrovsky
2020-05-06 21:10                                   ` Roman Shaposhnik [this message]
2020-05-06 17:16                           ` Stefano Stabellini
2020-05-06 17:32                         ` Stefano Stabellini
2020-05-02 18:48           ` Elliott Mitchell
2020-05-02 19:43             ` Julien Grall
2020-05-06 13:48         ` Corey Minyard
2020-05-06 13:56           ` Julien Grall
2020-05-02  0:05 ` Stefano Stabellini
2020-05-02  1:12   ` Roman Shaposhnik

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='CAMmSBy_2o6tsE1fsu_9=h8erOd9yHV-+ZkduTGqa-Gw7ra3mVQ@mail.gmail.com' \
    --to=roman@zededa.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jeff.kubascik@dornerworks.com \
    --cc=jgross@suse.com \
    --cc=julien.grall@arm.com \
    --cc=julien@xen.org \
    --cc=malus.brandywine@gmail.com \
    --cc=minyard@acm.org \
    --cc=peng.fan@nxp.com \
    --cc=sstabellini@kernel.org \
    --cc=stefano.stabellini@xilinx.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.