[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: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 16 Mar 2023 09:54:32 +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=QaYPxTxhzS68gjrMW2jNThGV0qPmZ6WiN4tI6D72svk=; b=cCcTMTsSrbCBcdFVmv4h00rWchWAdq2JIr0FWX2Xiu5JIl0krL4eQetZA0S5lxTQadFGkVA82oWlR/Z6ovlDXFoxQEqJ7BLa6Y1++zx1VbfpT6fNh/11lm/nm2ahYlqOZRlft4ZEeFYjSGCdOlGDi6f4Y1zaoFFA6+hwGA80v9NE8swj8UDfdjQGNUHQ9MFn6BX9c0VkJotbkVBl0gSQu4ZMmjcFQJWRBEURktz4mrJm/3PDUiOCmU7EfIdWbaYVCDgOV512zgT6741v+jVwsSYova3cewiEEvbwzY2ce0axYg+Ctk+Yk9RDlvDiBcEkVrahcApqyfBph26mlzAWXQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IfAwYqhtzVL0mCKu0d4xXjIcjYB8AF9iMYSm7jCEf1G0JV/V1A+62o4m/jKn6F3uPYYbvZj/29obAwGLolG7aNrqD9MeUrZSiBcr4kwNrSYJLt6xITmgX0dveaLjY2MiRKAZcnknpF+B40HMKqePj9nzZHBr0G86Lv2GElv1XNoQFXaGNcTtDE65D6ifDfQK93sPPixLrRWqGwxsUsoS2CYpxOSqeZCFaNPYG/ufX7YxMUrpeTAkXURP4Y5DlxSpjMq61xJMZhDXNGxD2qPyRKd6Q6R5gZH3lC0grY0rOQ4AmSK/CigS7Zhxw7b4vVLHzq6YQ3b/yLUL6120PjprQg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Huang Rui <ray.huang@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, 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 08:55:03 +0000
  • Ironport-data: A9a23:1VVcE69BkLVgz2wiSPBRDrUD7n6TJUtcMsCJ2f8bNWPcYEJGY0x3z 2EbXGiGa/mOZWT0et91b9nn/EpQ6pTXmNZnQVZppX88E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ire7kI/1BjOkGlA5AdmPqkV5AG2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDklI8 schOAISUSuBmr7n4Iy0Ycd9gt4KeZyD0IM34hmMzBn/JNN+HdXvZvuP4tVVmjAtmspJAPDSI dIDbiZiZwjBZBsJPUoLDJU5n6GjgXyXnz9w8QrJ4/ZopTeIilAtuFTuGIO9ltiiX8Jak1zev mvb12/4HgsbJJqUzj/tHneE37eXzHOqCdNDfFG+3t5qgliomnVLMUUTZVe5gvuJqWqVYc0Kf iT4/QJr98De7neDVcLhVhe1pHqFuB80WNdKFeA+rgaXxcL8+Q+IQGgZRzhOQNUjuIk9QjlC/ l2Dks7tBDdvmKaIUn/b/bCRxRuiNC5QIWIcaCssSQoe/8KlsIw1lgjITNtoDOiylNKdMTj0z iCDqiQznfMfgNMA16ih1VnCj3SnoZ2hZgU1/ATMQmOs6EV6Y4OjZoOA4F3Xq/1HKe6xdUWMo 3Eeh46+7eQCAJuXnSqBaOwIEPei4PPtGDfBm0xmG54t8Cuk03GmdIFUpjp5IS9BMsECdjvkY RaVuR5Y4pB7NX6mK6RwZuqZCdkuzKGmB9TsUP/8Z99CJJN2cWev3iB3ZEeWmUvtnU4EmKQzf 5ycdK6R4W0yDK1myH+6Qrkb2LpzmiQmnzuPGdb80git1qeYaDiNU7AZPVCSb+c/qqSZvAHS9 NUZPMyPo/lCbNDDjuDs2dZ7BTg3wbITXPgad+Q/mja/Hzdb
  • Ironport-hdrordr: A9a23:3QozEKE9RNosB7hipLqE7MeALOsnbusQ8zAXPhZKOHhom62j9/ xG885x6faZslwssRIb+OxoWpPufZqGz+8R3WB5B97LYOCBggaVxepZg7cKrQeNJ8VQnNQtsp uJ38JFeb7N5fkRt7eZ3DWF
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Mar 15, 2023 at 05:44:12PM -0700, 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

Those would be fine, and don't need any translation since it's QEMU
the one that creates and maps the MSI(-X) interrupts, so it knows the
PIRQ without requiring any translation because it has been allocated
by QEMU itself.

GSI is kind of special because it's a fixed (legacy) interrupt mapped
to an IO-APIC pin and assigned to the device by the firmware.  The
setup in that case gets done by the toolstack (libxl) because the
mapping is immutable for the lifetime of the domain.

> 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.

I think the real question here is why on this scenario IRQ != GSI for
GSI interrupts.  On one of my systems when booted as PVH dom0 with
pci=nomsi I get from /proc/interrupt:

  8:          0          0          0          0          0          0          
0   IO-APIC   8-edge      rtc0
  9:          1          0          0          0          0          0          
0   IO-APIC   9-fasteoi   acpi
 16:          0          0       8373          0          0          0          
0   IO-APIC  16-fasteoi   i801_smbus, xhci-hcd:usb1, ahci[0000:00:17.0]
 17:          0          0          0        542          0          0          
0   IO-APIC  17-fasteoi   eth0
 24:       4112          0          0          0          0          0          
0  xen-percpu    -virq      timer0
 25:        352          0          0          0          0          0          
0  xen-percpu    -ipi       resched0
 26:       6635          0          0          0          0          0          
0  xen-percpu    -ipi       callfunc0

So GSI == IRQ, and non GSI interrupts start past the last GSI, which
is 23 on this system because it has a single IO-APIC with 24 pins.

We need to figure out what causes GSIs to be mapped to IRQs != GSI on
your system, and then we can decide how to fix this.  I would expect
it could be fixed so that IRQ == GSI (like it's on PV dom0), and none
of this translation to be necessary.

Can you paste the output of /proc/interrupts on that system that has a
GSI not identity mapped to an 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.

Right, see above, I think the real problem is that IRQ != GSI on your
Linux dom0 for some reason.

Thanks, Roger.



 


Rackspace

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