All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jiqian Chen <Jiqian.Chen@amd.com>
Cc: Jan Beulich <jbeulich@suse.com>,
	"Daniel P . Smith" <dpsmith@apertussolutions.com>,
	Wei Liu <wl@xen.org>, Anthony PERARD <anthony.perard@citrix.com>,
	Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org,
	Stewart Hildebrand <Stewart.Hildebrand@amd.com>,
	Alex Deucher <Alexander.Deucher@amd.com>,
	Xenia Ragiadakou <xenia.ragiadakou@amd.com>,
	Stefano Stabellini <stefano.stabellini@amd.com>,
	Huang Rui <Ray.Huang@amd.com>,
	Honglei Huang <Honglei1.Huang@amd.com>,
	Julia Zhang <Julia.Zhang@amd.com>
Subject: Re: [RFC XEN PATCH v3 3/3] libxl: Use gsi instead of irq for mapping pirq
Date: Mon, 11 Dec 2023 16:48:59 +0100	[thread overview]
Message-ID: <ZXcvazeJlsfPsq0h@macbook> (raw)
In-Reply-To: <20231210164009.1551147-4-Jiqian.Chen@amd.com>

On Mon, Dec 11, 2023 at 12:40:09AM +0800, Jiqian Chen wrote:
> In PVH dom0, it uses the linux local interrupt mechanism,
> when it allocs irq for a gsi, it is dynamic, and follow
> the principle of applying first, distributing first. And
> the irq number is alloced from small to large, but the
> applying gsi number is not, may gsi 38 comes before gsi
> 28, that causes the irq number is not equal with the gsi
> number. And when passthrough a device, xl wants to use
> gsi to map pirq, see pci_add_dm_done->xc_physdev_map_pirq,
> but the gsi number is got from file
> /sys/bus/pci/devices/<sbdf>/irq in current code, so it
> will fail when mapping.
> 
> So, use real gsi number read from gsi sysfs.
> 
> Co-developed-by: Huang Rui <ray.huang@amd.com>
> Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
> ---
>  tools/libs/light/libxl_pci.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c
> index 96cb4da079..9e75f0c263 100644
> --- a/tools/libs/light/libxl_pci.c
> +++ b/tools/libs/light/libxl_pci.c
> @@ -1416,7 +1416,7 @@ static void pci_add_dm_done(libxl__egc *egc,
>      char *sysfs_path;
>      FILE *f;
>      unsigned long long start, end, flags, size;
> -    int irq, i;
> +    int gsi, i;
>      int r;
>      uint32_t flag = XEN_DOMCTL_DEV_RDM_RELAXED;
>      uint32_t domainid = domid;
> @@ -1439,7 +1439,7 @@ static void pci_add_dm_done(libxl__egc *egc,
>                             pci->bus, pci->dev, pci->func);
>      f = fopen(sysfs_path, "r");
>      start = end = flags = size = 0;
> -    irq = 0;
> +    gsi = 0;

unsigned int (so it matches the fscanf format), and initialized at
definition.

>  
>      if (f == NULL) {
>          LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path);
> @@ -1478,26 +1478,26 @@ static void pci_add_dm_done(libxl__egc *egc,
>      fclose(f);
>      if (!pci_supp_legacy_irq())
>          goto out_no_irq;
> -    sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/irq", pci->domain,
> +    sysfs_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/gsi", pci->domain,
>                                  pci->bus, pci->dev, pci->func);

You need to keep the fallback mechanism of reading the irq node, or
else xl would stop working on any kernel that doesn't expose this
sysfs node, you would break passthrough on all current Linux versions.

Thanks, Roger.


  reply	other threads:[~2023-12-11 15:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-10 16:40 [RFC XEN PATCH v3 0/3] Support device passthrough when dom0 is PVH on Xen Jiqian Chen
2023-12-10 16:40 ` [RFC XEN PATCH v3 1/3] xen/vpci: Clear all vpci status of device Jiqian Chen
2023-12-11 15:22   ` Roger Pau Monné
2023-12-12  6:44     ` Chen, Jiqian
2023-12-10 16:40 ` [RFC XEN PATCH v3 2/3] x86/pvh: Add (un)map_pirq and setup_gsi for PVH dom0 Jiqian Chen
2023-12-11 15:31   ` Roger Pau Monné
2023-12-12  6:49     ` Chen, Jiqian
2023-12-12  9:30       ` Jan Beulich
2023-12-13  2:47         ` Chen, Jiqian
2023-12-13  7:03           ` Jan Beulich
2023-12-14  8:55             ` Chen, Jiqian
2023-12-14  9:17               ` Jan Beulich
2023-12-14  9:55               ` Roger Pau Monné
2023-12-14  9:58                 ` Jan Beulich
2023-12-14 10:06                   ` Roger Pau Monné
2023-12-14 22:49                     ` Stefano Stabellini
2023-12-15  7:20                       ` Chen, Jiqian
2023-12-15  8:29                         ` Roger Pau Monné
2023-12-18  3:25                           ` Chen, Jiqian
2023-12-15  8:21                       ` Roger Pau Monné
2023-12-15  8:24                       ` Jan Beulich
2023-12-15  8:40                         ` Roger Pau Monné
2023-12-15 21:01                           ` Stefano Stabellini
2023-12-10 16:40 ` [RFC XEN PATCH v3 3/3] libxl: Use gsi instead of irq for mapping pirq Jiqian Chen
2023-12-11 15:48   ` Roger Pau Monné [this message]
2023-12-12  6:55     ` Chen, Jiqian

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=ZXcvazeJlsfPsq0h@macbook \
    --to=roger.pau@citrix.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Honglei1.Huang@amd.com \
    --cc=Jiqian.Chen@amd.com \
    --cc=Julia.Zhang@amd.com \
    --cc=Ray.Huang@amd.com \
    --cc=Stewart.Hildebrand@amd.com \
    --cc=anthony.perard@citrix.com \
    --cc=dpsmith@apertussolutions.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=sstabellini@kernel.org \
    --cc=stefano.stabellini@amd.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xenia.ragiadakou@amd.com \
    /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.