All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
To: Julien Grall <julien@xen.org>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "sstabellini@kernel.org" <sstabellini@kernel.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>,
	"jbeulich@suse.com" <jbeulich@suse.com>,
	"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
	"george.dunlap@citrix.com" <george.dunlap@citrix.com>,
	"paul@xen.org" <paul@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Rahul Singh <rahul.singh@arm.com>
Subject: Re: [PATCH v6 2/7] xen/arm: add pci-domain for disabled devices
Date: Wed, 24 Nov 2021 06:54:00 +0000	[thread overview]
Message-ID: <0d79bb2b-ae54-0875-e2f6-c3c4a0b1f1c7@epam.com> (raw)
In-Reply-To: <7192e606-eae2-e11f-9746-ec88afd1dd25@xen.org>

Hi, Julien!

On 23.11.21 19:15, Julien Grall wrote:
> Hi,
>
> On 23/11/2021 16:44, Oleksandr Andrushchenko wrote:
>> On 23.11.21 18:05, Julien Grall wrote:
>>> Hi Oleksandr,
>>>
>>> On 23/11/2021 06:31, Oleksandr Andrushchenko wrote:
>>>>
>>>>
>>>> On 22.11.21 19:17, Julien Grall wrote:
>>>>> Hi,
>>>>>
>>>>> On 22/11/2021 16:23, Oleksandr Andrushchenko wrote:
>>>>>> On 22.11.21 17:29, Julien Grall wrote:
>>>>>>> I would prefer to go with my way. This can be refined in the future if we find Device-Tree that matches what you wrote.
>>>>>> Ok, so just to make it clear:
>>>>>>     >a PCI device would always be described as a child of the hostbridges. So I would rework the 'if' to also check if the parent type is not "pci"
>>>>>
>>>>> That's correct. Thank you!
>>>> Ok, so how about
>>>>        if ( is_pci_passthrough_enabled() && dt_device_type_is_equal(node, "pci") )
>>>>        {
>>>>            bool skip = false;
>>>>
>>>>            /*
>>>>             * If the parent is also a "pci" device, then "linux,pci-domain"
>>>>             * should already be there, so nothing to do then.
>>>>             */
>>>
>>> This comment is a bit confusing.
>> Do you have something on your mind?
>
> Yes, explain that we only want to cover hostbridge (see my reply on the previous answer).
I guess this will be explained by the comment to handle_linux_pci_domain below
>
>>> I think what matter if the parent is a "pci" device, then the current node must not be a hostbridge. So we can skip it.
>> By skipping you only mean we do not need to add/assign "linux,pci-domain", right?
>
> Yes.
>
>>> However...
>>>
>>>>            if ( node->parent && dt_device_type_is_equal(node->parent, "pci") )
>>>>                skip = true;
>>>>
>>>>            if ( !skip && !dt_find_property(node, "linux,pci-domain", NULL) )
>>>>            {
>>>> I played with a single if and it looks scary...
>>>
>>> ... how about introducing an helper that will return true if this node is likely an hostbridge?
>> This is yet a single use of such a check: why would we need a helper and what would that
>> helper do?
>
> I like splitting code in multiple functions even if they are only called once because this:
>   1) keeps the functions line count small
>   2) easier to understand what is the purpose of the check
>
> In fact, I would actually move the handling for "linux,pci-domain" in a separate helper. Something like:
>
> /*
>  * When PCI passthrough is available we want to keep the
>  * "linux,pci-domain" in sync for every hostbridge.
>  *
>  * Xen may not have a driver for all the hostbridges. So we have
>  * to write an heuristic to detect whether a device node describes
>  * an hostbridge.
>  *
>  * The current heuristic assumes that a device is an hostbridge
>  * if the type is "pci" and then parent type is not "pci".
>  */
> static int handle_linux_pci_domain(struct dt_device *node)
> {
>         if ( !is_pci_passthrough_enabled() )
>           return 0;
>
>     if ( !dt_device_type_is_equal(node, "pci") )
>           return 0;
>
>         if ( node->parent && dt_device_type_is_equal(node->parent) )
>           return 0;
>
>         if ( dt_find_property(node, "linux,pci-domain", NULL )
>           return 0;
>
>         /* Allocate and create the linux,pci-domain */
> }
>
I'm fine with this, will move, thanks
> Cheers,
>
Thank you,
Oleksandr

  reply	other threads:[~2021-11-24  6:54 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05  6:33 [PATCH v6 0/7] PCI devices passthrough on Arm, part 2 Oleksandr Andrushchenko
2021-11-05  6:33 ` [PATCH v6 1/7] xen/arm: rename DEVICE_PCI to DEVICE_PCI_HOSTBRIDGE Oleksandr Andrushchenko
2021-11-16 18:26   ` Julien Grall
2021-11-05  6:33 ` [PATCH v6 2/7] xen/arm: add pci-domain for disabled devices Oleksandr Andrushchenko
2021-11-16 18:48   ` Julien Grall
2021-11-17  6:56     ` Oleksandr Andrushchenko
2021-11-17 21:33       ` Julien Grall
2021-11-18  7:13         ` Oleksandr Andrushchenko
2021-11-22 15:29           ` Julien Grall
2021-11-22 16:23             ` Oleksandr Andrushchenko
2021-11-22 17:17               ` Julien Grall
2021-11-23  6:31                 ` Oleksandr Andrushchenko
2021-11-23 16:05                   ` Julien Grall
2021-11-23 16:44                     ` Oleksandr Andrushchenko
2021-11-23 17:15                       ` Julien Grall
2021-11-24  6:54                         ` Oleksandr Andrushchenko [this message]
2021-11-05  6:33 ` [PATCH v6 3/7] xen/arm: setup MMIO range trap handlers for hardware domain Oleksandr Andrushchenko
2021-11-09  9:20   ` Oleksandr Andrushchenko
2021-11-16 19:12   ` Julien Grall
2021-11-18  7:27     ` Oleksandr Andrushchenko
2021-11-18 10:46       ` Oleksandr Andrushchenko
2021-11-22 17:36         ` Julien Grall
2021-11-23  6:58           ` Oleksandr Andrushchenko
2021-11-23 16:12             ` Julien Grall
2021-11-23 16:41               ` Oleksandr Andrushchenko
2021-11-23 16:58                 ` Julien Grall
2021-11-24  7:22                   ` Oleksandr Andrushchenko
2021-11-05  6:33 ` [PATCH v6 4/7] xen/arm: do not map PCI ECAM and MMIO space to Domain-0's p2m Oleksandr Andrushchenko
2021-11-23 16:42   ` Julien Grall
2021-11-24  7:42     ` Oleksandr Andrushchenko
2021-11-05  6:33 ` [PATCH v6 5/7] xen/arm: do not map IRQs and memory for disabled devices Oleksandr Andrushchenko
2021-11-16 19:22   ` Julien Grall
2021-11-18  6:59     ` Oleksandr Andrushchenko
2021-11-22 19:31       ` Julien Grall
2021-11-23  7:23         ` Oleksandr Andrushchenko
2021-11-05  6:33 ` [PATCH v6 6/7] xen/arm: process pending vPCI map/unmap operations Oleksandr Andrushchenko
2021-11-05  7:40   ` Jan Beulich
2021-11-17 21:26   ` Julien Grall
2021-11-05  6:33 ` [PATCH v6 7/7] xen/arm: do not use void pointer in pci_host_common_probe Oleksandr Andrushchenko
2021-11-17 11:12   ` Rahul Singh
2021-11-17 21:45   ` Julien Grall
2021-11-18  7:34     ` Oleksandr Andrushchenko
2021-11-22 17:48       ` Julien Grall

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=0d79bb2b-ae54-0875-e2f6-c3c4a0b1f1c7@epam.com \
    --to=oleksandr_andrushchenko@epam.com \
    --cc=Artem_Mygaiev@epam.com \
    --cc=Oleksandr_Tyshchenko@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=paul@xen.org \
    --cc=rahul.singh@arm.com \
    --cc=roger.pau@citrix.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 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.