All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
To: Jan Beulich <jbeulich@suse.com>,
	Oleksandr Andrushchenko <andr2000@gmail.com>
Cc: "iwj@xenproject.org" <iwj@xenproject.org>,
	"wl@xen.org" <wl@xen.org>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"Bertrand.Marquis@arm.com" <Bertrand.Marquis@arm.com>,
	"julien.grall@arm.com" <julien.grall@arm.com>,
	"sstabellini@kernel.org" <sstabellini@kernel.org>,
	"roger.pau@citrix.com" <roger.pau@citrix.com>,
	"Rahul.Singh@arm.com" <Rahul.Singh@arm.com>
Subject: Re: [PATCH 02/10] arm/pci: Maintain PCI assignable list
Date: Thu, 12 Nov 2020 12:53:47 +0000	[thread overview]
Message-ID: <eb50b7f2-a2fb-a7fb-7937-511e5b26f7a0@epam.com> (raw)
In-Reply-To: <6a2dc03e-202b-b8f9-46a5-9c90d9de8a6d@suse.com>


On 11/11/20 4:54 PM, Jan Beulich wrote:
> On 09.11.2020 13:50, Oleksandr Andrushchenko wrote:
>> --- a/xen/drivers/passthrough/pci.c
>> +++ b/xen/drivers/passthrough/pci.c
>> @@ -879,6 +879,43 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)
>>       return ret;
>>   }
>>   
>> +#ifdef CONFIG_ARM
>> +int pci_device_set_assigned(u16 seg, u8 bus, u8 devfn, bool assigned)
>> +{
>> +    struct pci_dev *pdev;
>> +
>> +    pdev = pci_get_pdev(seg, bus, devfn);
>> +    if ( !pdev )
>> +    {
>> +        printk(XENLOG_ERR "Can't find PCI device %04x:%02x:%02x.%u\n",
>> +               seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
>> +        return -ENODEV;
>> +    }
>> +
>> +    pdev->assigned = assigned;
>> +    printk(XENLOG_ERR "pciback %sassign PCI device %04x:%02x:%02x.%u\n",
>> +           assigned ? "" : "de-",
>> +           seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
>> +
>> +    return 0;
>> +}
>> +
>> +int pci_device_get_assigned(u16 seg, u8 bus, u8 devfn)
>> +{
>> +    struct pci_dev *pdev;
>> +
>> +    pdev = pci_get_pdev(seg, bus, devfn);
>> +    if ( !pdev )
>> +    {
>> +        printk(XENLOG_ERR "Can't find PCI device %04x:%02x:%02x.%u\n",
>> +               seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
>> +        return -ENODEV;
>> +    }
>> +
>> +    return pdev->assigned ? 0 : -ENODEV;
>> +}
>> +#endif
>> +
>>   #ifndef CONFIG_ARM
>>   /*TODO :Implement MSI support for ARM  */
>>   static int pci_clean_dpci_irq(struct domain *d,
>> @@ -1821,6 +1858,62 @@ int iommu_do_pci_domctl(
>>       return ret;
>>   }
>>   
>> +#ifdef CONFIG_ARM
>> +struct list_assigned {
>> +    uint32_t cur_idx;
>> +    uint32_t from_idx;
>> +    bool assigned;
>> +    domid_t *domain;
>> +    uint32_t *machine_sbdf;
>> +};
>> +
>> +static int _enum_assigned_pci_devices(struct pci_seg *pseg, void *arg)
>> +{
>> +    struct list_assigned *ctxt = arg;
>> +    struct pci_dev *pdev;
>> +
>> +    list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list )
>> +    {
>> +        if ( pdev->assigned == ctxt->assigned )
>> +        {
>> +            if ( ctxt->cur_idx == ctxt->from_idx )
>> +            {
>> +                *ctxt->domain = pdev->domain->domain_id;
>> +                *ctxt->machine_sbdf = pdev->sbdf.sbdf;
>> +                return 1;
>> +            }
>> +            ctxt->cur_idx++;
>> +        }
>> +    }
>> +    return 0;
>> +}
>> +
>> +int pci_device_enum_assigned(bool report_not_assigned,
>> +                             uint32_t from_idx, domid_t *domain,
>> +                             uint32_t *machine_sbdf)
>> +{
>> +    struct list_assigned ctxt = {
>> +        .assigned = !report_not_assigned,
>> +        .cur_idx = 0,
>> +        .from_idx = from_idx,
>> +        .domain = domain,
>> +        .machine_sbdf = machine_sbdf,
>> +    };
>> +    int ret;
>> +
>> +    pcidevs_lock();
>> +    ret = pci_segments_iterate(_enum_assigned_pci_devices, &ctxt);
>> +    pcidevs_unlock();
>> +    /*
>> +     * If not found then report as EINVAL to mark
>> +     * enumeration process finished.
>> +     */
>> +    if ( !ret )
>> +        return -EINVAL;
>> +    return 0;
>> +}
>> +#endif
> Just in case the earlier comments you've got don't lead to removal
> of this code - unless there's a real need for them to be put here,
> under #ifdef, please add a new xen/drivers/passthrough/arm/pci.c
> instead. Even if for just part of the code, this would then also
> help with more clear maintainership of this Arm specific code.
Yes, does make sense to move all ARM specifics into a dedicated file
>
> Jan

  reply	other threads:[~2020-11-12 12:54 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 12:50 [PATCH 00/10] [RFC] ARM PCI passthrough configuration and vPCI Oleksandr Andrushchenko
2020-11-09 12:50 ` [PATCH 01/10] pci/pvh: Allow PCI toolstack code run with PVH domains on ARM Oleksandr Andrushchenko
2020-11-11 12:31   ` [SUSPECTED SPAM][PATCH " Roger Pau Monné
2020-11-11 13:10     ` Oleksandr Andrushchenko
2020-11-11 13:55       ` Roger Pau Monné
2020-11-11 14:12         ` Oleksandr Andrushchenko
2020-11-11 14:21           ` Roger Pau Monné
2020-11-09 12:50 ` [PATCH 02/10] arm/pci: Maintain PCI assignable list Oleksandr Andrushchenko
2020-11-11 13:53   ` Roger Pau Monné
2020-11-11 14:38     ` Oleksandr Andrushchenko
2020-11-11 15:03       ` Roger Pau Monné
2020-11-11 15:13         ` Oleksandr Andrushchenko
2020-11-11 15:25           ` Jan Beulich
2020-11-11 15:28             ` Oleksandr Andrushchenko
2020-11-11 14:54   ` Jan Beulich
2020-11-12 12:53     ` Oleksandr Andrushchenko [this message]
2020-11-09 12:50 ` [PATCH 03/10] xen/arm: Setup MMIO range trap handlers for hardware domain Oleksandr Andrushchenko
2020-11-11 14:39   ` Roger Pau Monné
2020-11-11 14:42     ` Oleksandr Andrushchenko
2020-11-09 12:50 ` [PATCH 04/10] [WORKAROUND] xen/arm: Update hwdom's p2m to trap ECAM space Oleksandr Andrushchenko
2020-11-11 14:44   ` Roger Pau Monné
2020-11-12 12:54     ` Oleksandr Andrushchenko
2020-11-09 12:50 ` [PATCH 05/10] xen/arm: Process pending vPCI map/unmap operations Oleksandr Andrushchenko
2020-11-09 12:50 ` [PATCH 06/10] vpci: Make every domain handle its own BARs Oleksandr Andrushchenko
2020-11-12  9:40   ` Roger Pau Monné
2020-11-12 13:16     ` Oleksandr Andrushchenko
2020-11-12 14:46       ` Roger Pau Monné
2020-11-13  6:32         ` Oleksandr Andrushchenko
2020-11-13  6:48           ` Oleksandr Andrushchenko
2020-11-13 10:25           ` Jan Beulich
2020-11-13 10:36             ` Julien Grall
2020-11-13 10:53               ` Jan Beulich
2020-11-13 11:06                 ` Julien Grall
2020-11-13 11:26                   ` Jan Beulich
2020-11-13 11:53                     ` Julien Grall
2020-11-13 10:46             ` Oleksandr Andrushchenko
2020-11-13 10:50               ` Jan Beulich
2020-11-13 11:02                 ` Oleksandr Andrushchenko
2020-11-13 11:35                   ` Jan Beulich
2020-11-13 12:41                     ` Oleksandr Andrushchenko
2020-11-13 14:23                       ` Jan Beulich
2020-11-13 14:32                         ` Oleksandr Andrushchenko
2020-11-13 14:38                           ` Jan Beulich
2020-11-13 14:44                             ` Oleksandr Andrushchenko
2020-11-13 14:51                               ` Jan Beulich
2020-11-13 14:52                                 ` Oleksandr Andrushchenko
2020-12-04 14:38                                 ` Oleksandr Andrushchenko
2020-12-07  8:48                                   ` Jan Beulich
2020-12-07  9:11                                     ` Oleksandr Andrushchenko
2020-12-07  9:28                                       ` Jan Beulich
2020-12-07  9:37                                         ` Oleksandr Andrushchenko
2020-12-07  9:50                                           ` Jan Beulich
2020-11-09 12:50 ` [PATCH 07/10] xen/arm: Do not hardcode phycial PCI device addresses Oleksandr Andrushchenko
2020-11-09 12:50 ` [PATCH 08/10] vpci/arm: Allow updating BAR's header for non-ECAM bridges Oleksandr Andrushchenko
2020-11-12  9:56   ` Roger Pau Monné
2020-11-13  6:46     ` Oleksandr Andrushchenko
2020-11-13 10:29   ` Jan Beulich
2020-11-13 10:39     ` Oleksandr Andrushchenko
2020-11-13 10:47       ` Jan Beulich
2020-11-13 10:55         ` Oleksandr Andrushchenko
2020-11-09 12:50 ` [PATCH 09/10] vpci/rcar: Implement vPCI.update_bar_header callback Oleksandr Andrushchenko
2020-11-12 10:00   ` Roger Pau Monné
2020-11-13  6:50     ` Oleksandr Andrushchenko
2020-11-09 12:50 ` [PATCH 10/10] [HACK] vpci/rcar: Make vPCI know DomD is hardware domain 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=eb50b7f2-a2fb-a7fb-7937-511e5b26f7a0@epam.com \
    --to=oleksandr_andrushchenko@epam.com \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Rahul.Singh@arm.com \
    --cc=andr2000@gmail.com \
    --cc=iwj@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.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.