xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall.oss@gmail.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: Rahul Singh <Rahul.Singh@arm.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	 Bertrand Marquis <Bertrand.Marquis@arm.com>,
	Andre Przywara <Andre.Przywara@arm.com>,
	 Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v2 11/17] xen/arm: PCI host bridge discovery within XEN on ARM
Date: Mon, 27 Sep 2021 18:59:24 +0200	[thread overview]
Message-ID: <CAJ=z9a3J7xgEJu8waQpnORO4=gcucK1oHrcjpzBrW1Fs0HY3oQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2109241422170.17979@sstabellini-ThinkPad-T480s>

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

On Fri, 24 Sep 2021, 23:42 Stefano Stabellini, <sstabellini@kernel.org>
wrote:

> On Fri, 24 Sep 2021, Rahul Singh wrote:
> > Hi Stefano,
> >
> > > On 23 Sep 2021, at 8:12 pm, Stefano Stabellini <sstabellini@kernel.org>
> wrote:
> > >
> > > On Thu, 23 Sep 2021, Rahul Singh wrote:
> > >>>> +            goto err_exit;
> > >>>> +    }
> > >>>
> > >>> This is unnecessary at the moment, right? Can we get rid of
> ops->init ?
> > >>
> > >> No this is required for N1SDP board. Please check below patch.
> > >>
> https://gitlab.com/rahsingh/xen-integration/-/commit/6379ba5764df33d57547087cff4ffc078dc515d5
> > >
> > > OK
> > >
> > >
> > >>>> +int pci_host_common_probe(struct dt_device_node *dev, const void
> *data)
> > >>>> +{
> > >>>> +    struct pci_host_bridge *bridge;
> > >>>> +    struct pci_config_window *cfg;
> > >>>> +    struct pci_ecam_ops *ops;
> > >>>> +    const struct dt_device_match *of_id;
> > >>>> +    int err;
> > >>>> +
> > >>>> +    if ( dt_device_for_passthrough(dev) )
> > >>>> +        return 0;
> > >>>> +
> > >>>> +    of_id = dt_match_node(dev->dev.of_match_table,
> dev->dev.of_node);
> > >>>> +    ops = (struct pci_ecam_ops *) of_id->data;
> > >>>
> > >>> Do we really need dt_match_node and dev->dev.of_match_table to get
> > >>> dt_device_match.data?
> > >>>
> > >>
> > >>> data is passed as a parameter to pci_host_common_probe, isn't it
> enough
> > >>> to do:
> > >>>
> > >>> ops = (struct pci_ecam_ops *) data;
> > >>
> > >> As of now not required but in future we might need it if we implement
> other ecam supported bridge
> > >>
> > >> static const struct dt_device_match gen_pci_dt_match[] = {
>
> > >>    { .compatible = "pci-host-ecam-generic",
>
> > >>      .data =       &pci_generic_ecam_ops },
> > >>
> > >>    { .compatible = "pci-host-cam-generic",
> > >>      .data = &gen_pci_cfg_cam_bus_ops },
>
> > >>
> > >>    { },
>
> > >> };
> > >
> > > Even if we add another ECAM-supported bridge, the following:
> > >
> > > ops = (struct pci_ecam_ops *) data;
> > >
> > > could still work, right? The probe function will directly receive as
> > > parameter the .data pointer. You shouldn't need the indirection via
> > > dt_match_node?
> >
> > As per my understanding probe function will not get .data pointer.Probe
> data argument is NULL in most of the cases in XEN
> > Please have a look once dt_pci_init() -> device_init(..) call flow
> implementation.
>
> You are right. Looking at the code, nobody is currently using
> dt_device_match.data and it is clear why: it is not passed to the
> device_desc.init function at all. As it is today, it is basically
> useless.
>

IIRC it is used by the SMMU driver. But you need to lookup for the desc
manually in each init callback.

If I am not mistaken, this is how Linux is dealing with it as well.
However...


> And there is only one case where device_init has a non-NULL data
> parameter and it is in xen/drivers/char/arm-uart.c. All the others are
> not even using the data parameter of device_init.


> I think we need to change device_init so that dt_device_match.data can
> be useful. Sorry for the scope-creep but I think we should do the
> following:
>
> - do not add of_match_table to struct device
>
> - add one more parameter to device_desc.init:
>   int (*init)(struct dt_device_node *dev, struct device_desc *desc, const
> void *data);
>
> - change device_init to call desc->init with the right parameters:
>   desc->init(dev, desc, data);
>
> This way pci_host_common_probe is just going to get a desc directly as
> parameter. I think it would make a lot more sense from an interface
> perspective. It does require a change in all the DT_DEVICE_START.init
> functions adding a struct device_desc *desc parameter, but it should be
> a mechanical change.
>
> Alternatively we could just change device_init to pass
> device_desc.dt_match.data when the data parameter is NULL but it feels
> like a hack.
>
>
> What do you think?


... I like the idea of passing desc parameter (we could also simply pass
desc.data in an argument named "priv").

Cheers,

>

[-- Attachment #2: Type: text/html, Size: 6519 bytes --]

  parent reply	other threads:[~2021-09-27 16:59 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22 11:34 [PATCH v2 00/17] PCI devices passthrough on Arm Rahul Singh
2021-09-22 11:34 ` [PATCH v2 01/17] xen/pci: Refactor MSI code that implements MSI functionality within XEN Rahul Singh
2021-09-22 11:34 ` [PATCH v2 02/17] xen/pci: solve compilation error on ARM with HAS_PCI enabled Rahul Singh
2021-09-22 22:04   ` Stefano Stabellini
2021-09-23  2:07   ` Julien Grall
2021-09-23 11:14     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 03/17] xen/arm: solve compilation error on ARM with ACPI && HAS_PCI Rahul Singh
2021-09-22 22:08   ` Stefano Stabellini
2021-09-22 11:34 ` [PATCH v2 04/17] xen/arm: xc_domain_ioport_permission(..) not supported on ARM Rahul Singh
2021-09-22 22:13   ` Stefano Stabellini
2021-09-22 11:34 ` [PATCH v2 05/17] xen/arm: Add PHYSDEVOP_pci_device_* support for ARM Rahul Singh
2021-09-22 22:37   ` Stefano Stabellini
2021-09-23 11:19     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 06/17] xen/device-tree: Add dt_property_read_variable_u32_array helper Rahul Singh
2021-09-22 23:06   ` Stefano Stabellini
2021-09-23 11:21     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 07/17] xen/device-tree: Add dt_property_read_u32_array helper Rahul Singh
2021-09-22 23:44   ` Stefano Stabellini
2021-09-22 11:34 ` [PATCH v2 08/17] xen/device-tree: Add dt_get_pci_domain_nr helper Rahul Singh
2021-09-22 23:50   ` Stefano Stabellini
2021-09-23 11:52     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 09/17] xen/arm: Add support for PCI init to initialize the PCI driver Rahul Singh
2021-09-23  0:03   ` Stefano Stabellini
2021-09-23 14:53     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 10/17] xen/arm: Add cmdline boot option "pci-passthrough = <boolean>" Rahul Singh
2021-09-23  0:14   ` Stefano Stabellini
2021-09-23 15:03     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 11/17] xen/arm: PCI host bridge discovery within XEN on ARM Rahul Singh
2021-09-23  2:09   ` Stefano Stabellini
2021-09-23 13:03     ` Oleksandr Andrushchenko
2021-09-23 15:36       ` Stefano Stabellini
2021-09-23 17:08     ` Rahul Singh
2021-09-23 19:12       ` Stefano Stabellini
2021-09-24 12:54         ` Rahul Singh
2021-09-24 21:42           ` Stefano Stabellini
2021-09-24 23:26             ` Stefano Stabellini
2021-09-27 16:20               ` Rahul Singh
2021-09-27 16:59             ` Julien Grall [this message]
2021-09-22 11:34 ` [PATCH v2 12/17] xen/arm: Add support for Xilinx ZynqMP PCI host controller Rahul Singh
2021-09-23  2:11   ` Stefano Stabellini
2021-09-23 15:08     ` Rahul Singh
2021-09-22 11:34 ` [PATCH v2 13/17] xen:arm: Implement pci access functions Rahul Singh
2021-09-23  2:23   ` Stefano Stabellini
2021-09-23  8:52     ` Julien Grall
2021-09-23 15:17       ` Rahul Singh
2021-09-23  9:02     ` Julien Grall
2021-09-23 15:19       ` Rahul Singh
2021-09-23 15:15     ` Rahul Singh
2021-09-22 11:35 ` [PATCH v2 14/17] xen/arm: Enable the existing x86 virtual PCI support for ARM Rahul Singh
2021-09-23  2:41   ` Stefano Stabellini
2021-09-23 15:34     ` Rahul Singh
2021-09-24  7:21       ` Oleksandr Andrushchenko
2021-09-24  7:37     ` Jan Beulich
2021-09-24  7:44   ` Jan Beulich
2021-09-28 16:32     ` Rahul Singh
2021-09-22 11:35 ` [PATCH v2 15/17] xen/arm: Transitional change to build HAS_VPCI on ARM Rahul Singh
2021-09-22 11:35 ` [PATCH v2 16/17] arm/libxl: Emulated PCI device tree node in libxl Rahul Singh
2021-09-23 20:41   ` Stefano Stabellini
2021-09-22 11:35 ` [PATCH v2 17/17] xen/arm: Add linux,pci-domain property for hwdom if not available Rahul Singh
2021-09-23  2:52   ` Stefano Stabellini
2021-09-23 15:21     ` Rahul Singh

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='CAJ=z9a3J7xgEJu8waQpnORO4=gcucK1oHrcjpzBrW1Fs0HY3oQ@mail.gmail.com' \
    --to=julien.grall.oss@gmail.com \
    --cc=Andre.Przywara@arm.com \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Rahul.Singh@arm.com \
    --cc=Volodymyr_Babchuk@epam.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).