All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	"Huang Rui" <ray.huang@amd.com>,
	"Anthony PERARD" <anthony.perard@citrix.com>,
	xen-devel@lists.xenproject.org,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Stewart Hildebrand" <Stewart.Hildebrand@amd.com>,
	"Xenia Ragiadakou" <burzalodowa@gmail.com>,
	"Honglei Huang" <honglei1.huang@amd.com>,
	"Julia Zhang" <julia.zhang@amd.com>,
	"Chen Jiqian" <Jiqian.Chen@amd.com>
Subject: Re: [RFC XEN PATCH 6/6] tools/libs/light: pci: translate irq to gsi
Date: Thu, 16 Mar 2023 10:27:13 +0100	[thread overview]
Message-ID: <ZBLg8WB8HCoZvwz5@Air-de-Roger> (raw)
In-Reply-To: <e8843d7a-eecc-373c-a6b3-6a893bc0eb2a@suse.com>

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@amd.com>
> >>>
> >>> Use new xc_physdev_gsi_from_irq to get the GSI number
> >>>
> >>> Signed-off-by: Chen Jiqian <Jiqian.Chen@amd.com>
> >>> Signed-off-by: Huang Rui <ray.huang@amd.com>
> >>> ---
> >>>  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.


  reply	other threads:[~2023-03-16  9:27 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-12  7:54 [RFC XEN PATCH 0/6] Introduce VirtIO GPU and Passthrough GPU support on Xen PVH dom0 Huang Rui
2023-03-12  7:54 ` [RFC XEN PATCH 1/6] x86/pvh: report ACPI VFCT table to dom0 if present Huang Rui
2023-03-13 11:55   ` Andrew Cooper
2023-03-13 12:21     ` Roger Pau Monné
2023-03-13 12:27       ` Andrew Cooper
2023-03-21  6:26         ` Huang Rui
2023-03-12  7:54 ` [RFC XEN PATCH 2/6] vpci: accept BAR writes if dom0 is PVH Huang Rui
2023-03-13  7:23   ` Christian König
2023-03-13  7:26     ` Christian König
2023-03-13  8:46       ` Jan Beulich
2023-03-13  8:55       ` Huang Rui
2023-03-14 23:42       ` Stefano Stabellini
2023-03-14 16:02   ` Jan Beulich
2023-03-21  9:36     ` Huang Rui
2023-03-21  9:41       ` Jan Beulich
2023-03-21 10:14         ` Huang Rui
2023-03-21 10:20           ` Jan Beulich
2023-03-21 11:49             ` Huang Rui
2023-03-21 12:20               ` Roger Pau Monné
2023-03-21 12:25                 ` Jan Beulich
2023-03-21 12:59                 ` Huang Rui
2023-03-21 12:27               ` Jan Beulich
2023-03-21 13:03                 ` Huang Rui
2023-03-22  7:28                   ` Huang Rui
2023-03-22  7:45                     ` Jan Beulich
2023-03-22  9:34                     ` Roger Pau Monné
2023-03-22 12:33                       ` Huang Rui
2023-03-22 12:48                         ` Jan Beulich
2023-03-23 10:26                           ` Huang Rui
2023-03-23 14:16                             ` Jan Beulich
2023-03-23 10:43                           ` Roger Pau Monné
2023-03-23 13:34                             ` Huang Rui
2023-03-23 16:23                               ` Roger Pau Monné
2023-03-24  4:37                                 ` Huang Rui
2023-03-12  7:54 ` [RFC XEN PATCH 3/6] x86/pvh: shouldn't check pirq flag when map pirq in PVH Huang Rui
2023-03-14 16:27   ` Jan Beulich
2023-03-15 15:57   ` Roger Pau Monné
2023-03-16  0:22     ` Stefano Stabellini
2023-03-21 10:09     ` Huang Rui
2023-03-21 10:17       ` Jan Beulich
2023-03-12  7:54 ` [RFC XEN PATCH 4/6] x86/pvh: PVH dom0 also need PHYSDEVOP_setup_gsi call Huang Rui
2023-03-14 16:30   ` Jan Beulich
2023-03-15 17:01     ` Andrew Cooper
2023-03-16  0:26       ` Stefano Stabellini
2023-03-16  0:39         ` Stefano Stabellini
2023-03-16  8:51         ` Jan Beulich
2023-03-16  9:18           ` Roger Pau Monné
2023-03-16  7:05       ` Jan Beulich
2023-03-21 12:42       ` Huang Rui
2023-03-21 12:22     ` Huang Rui
2023-03-12  7:54 ` [RFC XEN PATCH 5/6] tools/libs/call: add linux os call to get gsi from irq Huang Rui
2023-03-14 16:36   ` Jan Beulich
2023-03-12  7:54 ` [RFC XEN PATCH 6/6] tools/libs/light: pci: translate irq to gsi Huang Rui
2023-03-14 16:39   ` Jan Beulich
2023-03-15 16:35   ` Roger Pau Monné
2023-03-16  0:44     ` Stefano Stabellini
2023-03-16  8:54       ` Roger Pau Monné
2023-03-16  8:55       ` Jan Beulich
2023-03-16  9:27         ` Roger Pau Monné [this message]
2023-03-16  9:42           ` Jan Beulich
2023-03-16 23:19             ` Stefano Stabellini
2023-03-17  8:39               ` Jan Beulich
2023-03-17  9:51                 ` Roger Pau Monné
2023-03-17 18:15                   ` Stefano Stabellini
2023-03-17 19:48                     ` Roger Pau Monné
2023-03-17 20:55                       ` Stefano Stabellini
2023-03-20 15:16                         ` Roger Pau Monné
2023-03-20 15:29                           ` Jan Beulich
2023-03-20 16:50                             ` Roger Pau Monné
2023-07-31 16:40                         ` Chen, Jiqian
2023-08-23  8:57                           ` Roger Pau Monné
2023-08-31  8:56                             ` Chen, Jiqian
2023-03-13  7:24 ` [RFC XEN PATCH 0/6] Introduce VirtIO GPU and Passthrough GPU support on Xen PVH dom0 Christian König
2023-03-21 10:26   ` Huang Rui
2023-03-20 16:22 ` Huang Rui

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=ZBLg8WB8HCoZvwz5@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=Jiqian.Chen@amd.com \
    --cc=Stewart.Hildebrand@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=anthony.perard@citrix.com \
    --cc=burzalodowa@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=honglei1.huang@amd.com \
    --cc=jbeulich@suse.com \
    --cc=julia.zhang@amd.com \
    --cc=ray.huang@amd.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.