All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	 "xen-devel@lists.xenproject.org"
	<xen-devel@lists.xenproject.org>,
	 "julien@xen.org" <julien@xen.org>,
	 Oleksandr Tyshchenko <Oleksandr_Tyshchenko@epam.com>,
	 Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	 Artem Mygaiev <Artem_Mygaiev@epam.com>,
	 "roger.pau@citrix.com" <roger.pau@citrix.com>,
	 Bertrand Marquis <bertrand.marquis@arm.com>,
	 Rahul Singh <rahul.singh@arm.com>
Subject: Re: [PATCH v2 10/11] xen/arm: Do not map PCI ECAM and MMIO space to Domain-0's p2m
Date: Tue, 28 Sep 2021 09:11:57 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.21.2109280911030.5022@sstabellini-ThinkPad-T480s> (raw)
In-Reply-To: <32ffee9e-8786-c91b-681c-7fa243f5d3fa@epam.com>

[-- Attachment #1: Type: text/plain, Size: 3687 bytes --]

On Tue, 28 Sep 2021, Oleksandr Andrushchenko wrote:
> [snip]
> >> Sorry I didn't follow your explanation.
> >>
> >> My suggestion is to remove the #ifdef CONFIG_HAS_PCI completely from
> >> map_range_to_domain. At the beginning of map_range_to_domain, there is
> >> already this line:
> >>
> >> bool need_mapping = !dt_device_for_passthrough(dev);
> >>
> >> We can change it into:
> >>
> >> bool need_mapping = !dt_device_for_passthrough(dev) &&
> >>                       !mr_data->skip_mapping;
> >>
> >>
> >> Then, in map_device_children we can set mr_data->skip_mapping to true
> >> for PCI devices.
> > This is the key. I am fine with this, but it just means we move the
> >
> > check to the outside of this function which looks good. Will do
> >
> >>    There is already a pci check there:
> >>
> >>    if ( dt_device_type_is_equal(dev, "pci") )
> >>
> >> so it should be easy to do. What am I missing?
> >>
> >>
> >
> I did some experiments. If we move the check to map_device_children
> 
> it is not enough because part of the ranges is still mapped at handle_device level:
> 
> handle_device:
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 1 addr fd0e0000
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 1 addr fd480000
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 1 addr 8000000000
> 
> map_device_children:
> (XEN) Mapping children of /axi/pcie@fd0e0000 to guest skip 1
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 0 addr e0000000
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 0 addr 600000000
> 
> pci_host_bridge_mappings:
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 1 addr fd0e0000
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 1 addr fd480000
> 
> So, I did more intrusive change:
> 
> @@ -1540,6 +1534,12 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev,
>       int res;
>       u64 addr, size;
>       bool need_mapping = !dt_device_for_passthrough(dev);
> +    struct map_range_data mr_data = {
> +        .d = d,
> +        .p2mt = p2mt,
> +        .skip_mapping = is_pci_passthrough_enabled() &&
> +                        (device_get_class(dev) == DEVICE_PCI)
> +    };
> 
> With this I see that now mappings are done correctly:
> 
> handle_device:
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 0 addr fd0e0000
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 0 addr fd480000
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 0 addr 8000000000
> 
> map_device_children:
> (XEN) Mapping children of /axi/pcie@fd0e0000 to guest skip 1
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 0 addr e0000000
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 0 addr 600000000
> 
> pci_host_bridge_mappings:
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 1 addr fd0e0000
> (XEN) --- /axi/pcie@fd0e0000 need_mapping 1 addr fd480000
> 
> So, handle_device seems to be the right place. While at it I have also
> 
> optimized the way we setup struct map_range_data mr_data in both
> 
> handle_device and map_device_children: I removed structure initialization
> 
> from within the relevant loop and also pass mr_data to map_device_children,
> 
> so it doesn't need to create its own copy of the same and perform yet
> 
> another computation for .skip_mapping: it does need to not only know
> 
> that dev is a PCI device (this is done by the dt_device_type_is_equal(dev, "pci")
> 
> check, but also account on is_pci_passthrough_enabled().
> 
> Thus, the change will be more intrusive, but I hope will simplify things.
> 
> I am attaching the fixup patch for just in case you want more details.

Yes, thanks, this is what I had in mind. Hopefully the resulting
combined patch will be simpler.

Cheers,

Stefano

  reply	other threads:[~2021-09-28 16:12 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23 12:54 [PATCH v2 00/11] PCI devices passthrough on Arm, part 2 Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 01/11] xen/arm: Fix dev_is_dt macro definition Oleksandr Andrushchenko
2021-09-24 23:39   ` Stefano Stabellini
2021-09-28  7:31   ` Michal Orzel
2021-09-23 12:54 ` [PATCH v2 02/11] xen/arm: Add new device type for PCI Oleksandr Andrushchenko
2021-09-24 23:45   ` Stefano Stabellini
2021-09-27  7:41   ` Jan Beulich
2021-09-27  8:18     ` Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 03/11] xen/arm: Introduce pci_find_host_bridge_node helper Oleksandr Andrushchenko
2021-09-24 23:48   ` Stefano Stabellini
2021-09-23 12:54 ` [PATCH v2 04/11] xen/device-tree: Make dt_find_node_by_phandle global Oleksandr Andrushchenko
2021-09-24 23:51   ` Stefano Stabellini
2021-09-23 12:54 ` [PATCH v2 05/11] xen/arm: Mark device as PCI while creating one Oleksandr Andrushchenko
2021-09-24 23:54   ` Stefano Stabellini
2021-09-27  7:13     ` Oleksandr Andrushchenko
2021-09-27  7:45   ` Jan Beulich
2021-09-27  8:45     ` Oleksandr Andrushchenko
2021-09-27  9:19       ` Jan Beulich
2021-09-27  9:35         ` Oleksandr Andrushchenko
2021-09-27 10:00           ` Jan Beulich
2021-09-27 10:04             ` Oleksandr Andrushchenko
2021-09-27 10:26               ` Jan Beulich
2021-09-28  8:09                 ` Oleksandr Andrushchenko
2021-09-28  8:26                   ` Jan Beulich
2021-09-28  8:29                     ` Oleksandr Andrushchenko
2021-09-28  8:39                       ` Jan Beulich
2021-09-28  8:54                         ` Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 06/11] xen/domain: Call pci_release_devices() when releasing domain resources Oleksandr Andrushchenko
2021-09-24 23:57   ` Stefano Stabellini
2021-09-23 12:54 ` [PATCH v2 07/11] libxl: Allow removing PCI devices for all types of domains Oleksandr Andrushchenko
2021-09-25  0:00   ` Stefano Stabellini
2021-09-27  7:17     ` Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 08/11] libxl: Only map legacy PCI IRQs if they are supported Oleksandr Andrushchenko
2021-09-25  0:06   ` Stefano Stabellini
2021-09-27 13:02     ` Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 09/11] xen/arm: Setup MMIO range trap handlers for hardware domain Oleksandr Andrushchenko
2021-09-25  0:18   ` Stefano Stabellini
2021-09-27  8:47     ` Oleksandr Andrushchenko
2021-09-23 12:54 ` [PATCH v2 10/11] xen/arm: Do not map PCI ECAM and MMIO space to Domain-0's p2m Oleksandr Andrushchenko
2021-09-25  0:44   ` Stefano Stabellini
2021-09-27 12:44     ` Oleksandr Andrushchenko
2021-09-28  4:00       ` Stefano Stabellini
2021-09-28  4:51         ` Oleksandr Andrushchenko
2021-09-28 14:39           ` Oleksandr Andrushchenko
2021-09-28 16:11             ` Stefano Stabellini [this message]
2021-09-23 12:54 ` [PATCH v2 11/11] xen/arm: Process pending vPCI map/unmap operations Oleksandr Andrushchenko
2021-09-25  1:20   ` Stefano Stabellini
2021-09-27  8:06   ` Jan Beulich
2021-09-27  8:39     ` Oleksandr Andrushchenko

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=alpine.DEB.2.21.2109280911030.5022@sstabellini-ThinkPad-T480s \
    --to=sstabellini@kernel.org \
    --cc=Artem_Mygaiev@epam.com \
    --cc=Oleksandr_Andrushchenko@epam.com \
    --cc=Oleksandr_Tyshchenko@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=rahul.singh@arm.com \
    --cc=roger.pau@citrix.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.