[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC XEN PATCH 6/6] tools/libs/light: pci: translate irq to gsi


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 16 Mar 2023 10:27:13 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=I1C8dBfsG21s0mNc6NHFCuH8z+BB42CbPVqLevqhTuY=; b=TUw8xUEXR8/VqMaaZiQfghEg7HzrO6tvmOpR3ghHZi89C7lb/YHTfC0AnNTw+bu5mO2s1i2vnhpYjfKl4f3bcjc0v7W/Dhf1QccDJTMOLNru3nnn/n47kwf++YVflO4MvVaRzY7XsA1GRFaXKrE6w7tdq2FQ6z8gl7AhUVc1zCSx9xij6ZCtErqqvAG93MzPEpWtlFggtQA2G0EkmThuvARwY+mTpqnpzG22YmiuKVgd48dzqTr7qVSguSr5CuQxzQ9QRHaVrOQe9KUAhdyiBx+aeyPq0MjE9qQa18AxtN8ShKLIb+fIjOSlVctgJ/twGKOodwVDvSIjsGqA0iZ+7g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YD5DbfvFXGse6e8dnbIlH1Qt0hk6x6w/mmv4gdg+YCC8bWPeWZz8dyb83aLuMGaJKd0U7G7t83JtGomwWH9GPQtPEb8lFdFsAoEm68WiBF9SkilHKkTk3jd9iNaKw9aAlIjAtd0qPnh/BZpCAOvgTyq53xUm65VwDKOIVVObOFXzYgoNIy0GDHvOKOtScbHBjHafTqwk4aVQQXIFE0oZM7TAIMATSUmhJu2KBmuqab9Ah+76P7nfoPwob6qkiX0FkC9juc01YHdumHEiR6AHcK4m4dKVIVZSAwN3JSxLVhvr9aIwmLrkjm+CszYr4cKW6g6MfGg86YwX0Br1ijqPwg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Huang Rui <ray.huang@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Alex Deucher <alexander.deucher@xxxxxxx>, Christian König <christian.koenig@xxxxxxx>, Stewart Hildebrand <Stewart.Hildebrand@xxxxxxx>, Xenia Ragiadakou <burzalodowa@xxxxxxxxx>, Honglei Huang <honglei1.huang@xxxxxxx>, Julia Zhang <julia.zhang@xxxxxxx>, Chen Jiqian <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Thu, 16 Mar 2023 09:27:38 +0000
  • Ironport-data: A9a23:SWeSD6omrCJWgFpYE+aer1Tb0tBeBmJ2ZRIvgKrLsJaIsI4StFCzt garIBnTO63ZamGjL410YYSypkkEsZaHxtRiGwBs/nswFS9E+JuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKm06WNwUmAWP6gR5weFzidNUvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXACJQbirEjMvn/JmcZvdKpfsxNpTCOapK7xmMzRmBZRonabbqZv2QoPV+hXI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jeGrbIO9lt+iHK25mm6Co W3L5SLhCwwyP92D0zuVtHmrg4cjmAuiANpOSefpp6cCbFu741IpJ14odVKAg6OQsQngV5Fgc mE15X97xUQ13AnxJjXnZDW6qnOZuh8XW/JLDvY3rgqKz8L8+B2FD2IJSjpAbt0Ot8IsQzEuk FiTkLvBHzV+9r2IQHSS3r6RoXW5Pi19BX8PY2oIQBUI5/HnoZovlVTfQ9B7Cqm3g9bpXzbqz FiipSwzl7wVgcMRkam24FvHjiiEr53FCAUy423/VWK/7xhlZYejIY+v5F7a4t5JKYrfRV6E1 FA/h8WB5foSS7GMkCCASv8EGr2B7vOJdjbbhDZHFYQ75T2p/HKkYol47zR3JUMvOcEBERfpZ 0ncvQ5QvdlTIXKsYod+Zo73AMMvpYDiCNDkX7bGbtNIbbB4cQPB9yZrDWay3nnsmU5quqEyP 7+SdMrqBnEfYZmL1xKzTuYZlLUtnyY3wDuJQYihl0j+l72DeHSSVLEJdkOUafw057+FpwOT9 MtDM8yNyFNUV+iWjjTrzLP/5GsidRATba0aYeQNHgJfCmKKwF0cNsI=
  • Ironport-hdrordr: A9a23:uW6EUajKra7CF2JYpEL4i4IGNHBQXiAji2hC6mlwRA09TyX5ra 2TdTogtSMc6QxhPE3I/OrrBEDuexzhHPJOj7X5Xo3SOTUO2lHYT72KhLGKq1Hd8kXFndK1vp 0QEZSWZueQMbB75/yKnTVREbwbsaW6GHbDv5ag859vJzsaFZ2J921Ce2Gm+tUdfng8OXI+fq DsgPZvln6bVlk8SN+0PXUBV/irnaywqHq3CSR2fiLO8WO1/EuV1II=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Mar 16, 2023 at 09:55:03AM +0100, Jan Beulich wrote:
> On 16.03.2023 01:44, Stefano Stabellini wrote:
> > On Wed, 15 Mar 2023, Roger Pau Monné wrote:
> >> On Sun, Mar 12, 2023 at 03:54:55PM +0800, Huang Rui wrote:
> >>> From: Chen Jiqian <Jiqian.Chen@xxxxxxx>
> >>>
> >>> Use new xc_physdev_gsi_from_irq to get the GSI number
> >>>
> >>> Signed-off-by: Chen Jiqian <Jiqian.Chen@xxxxxxx>
> >>> Signed-off-by: Huang Rui <ray.huang@xxxxxxx>
> >>> ---
> >>>  tools/libs/light/libxl_pci.c | 1 +
> >>>  1 file changed, 1 insertion(+)
> >>>
> >>> diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c
> >>> index f4c4f17545..47cf2799bf 100644
> >>> --- a/tools/libs/light/libxl_pci.c
> >>> +++ b/tools/libs/light/libxl_pci.c
> >>> @@ -1486,6 +1486,7 @@ static void pci_add_dm_done(libxl__egc *egc,
> >>>          goto out_no_irq;
> >>>      }
> >>>      if ((fscanf(f, "%u", &irq) == 1) && irq) {
> >>> +        irq = xc_physdev_gsi_from_irq(ctx->xch, irq);
> >>
> >> This is just a shot in the dark, because I don't really have enough
> >> context to understand what's going on here, but see below.
> >>
> >> I've taken a look at this on my box, and it seems like on
> >> dom0 the value returned by /sys/bus/pci/devices/SBDF/irq is not
> >> very consistent.
> >>
> >> If devices are in use by a driver the irq sysfs node reports either
> >> the GSI irq or the MSI IRQ (in case a single MSI interrupt is
> >> setup).
> >>
> >> It seems like pciback in Linux does something to report the correct
> >> value:
> >>
> >> root@lcy2-dt107:~# cat /sys/bus/pci/devices/0000\:00\:14.0/irq
> >> 74
> >> root@lcy2-dt107:~# xl pci-assignable-add 00:14.0
> >> root@lcy2-dt107:~# cat /sys/bus/pci/devices/0000\:00\:14.0/irq
> >> 16
> >>
> >> As you can see, making the device assignable changed the value
> >> reported by the irq node to be the GSI instead of the MSI IRQ, I would
> >> think you are missing something similar in the PVH setup (some pciback
> >> magic)?
> >>
> >> Albeit I have no idea why you would need to translate from IRQ to GSI
> >> in the way you do in this and related patches, because I'm missing the
> >> context.
> > 
> > As I mention in another email, also keep in mind that we need QEMU to
> > work and QEMU calls:
> > 1) xc_physdev_map_pirq (this is also called from libxl)
> > 2) xc_domain_bind_pt_pci_irq
> > 
> > 
> > In this case IRQ != GSI (IRQ == 112, GSI == 28). Sysfs returns the IRQ
> > in Linux (112), but actually xc_physdev_map_pirq expects the GSI, not
> > the IRQ. If you look at the implementation of xc_physdev_map_pirq,
> > you'll the type is "MAP_PIRQ_TYPE_GSI" and also see the check in Xen
> > xen/arch/x86/irq.c:allocate_and_map_gsi_pirq:
> > 
> >     if ( index < 0 || index >= nr_irqs_gsi )
> >     {
> >         dprintk(XENLOG_G_ERR, "dom%d: map invalid irq %d\n", d->domain_id,
> >                 index);
> >         return -EINVAL;
> >     }
> > 
> > nr_irqs_gsi < 112, and the check will fail.
> > 
> > So we need to pass the GSI to xc_physdev_map_pirq. To do that, we need
> > to discover the GSI number corresponding to the IRQ number.
> 
> That's one possible approach. Another could be (making a lot of assumptions)
> that a PVH Dom0 would pass in the IRQ it knows for this interrupt and Xen
> then translates that to GSI, knowing that PVH doesn't have (host) GSIs
> exposed to it.

I don't think Xen can translate a Linux IRQ to a GSI, as that's a
Linux abstraction Xen has no part in.

The GSIs exposed to a PVH dom0 are the native (host) ones, as we
create an emulated IO-APIC topology that mimics the physical one.

Question here is why Linux ends up with a IRQ != GSI, as it's my
understanding on Linux GSIs will always be identity mapped to IRQs, and
the IRQ space up to the last possible GSI is explicitly reserved for
this purpose.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.