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: xen-devel@lists.xenproject.org, Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
	George Dunlap <gwd@xenproject.org>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Anthony PERARD <anthony@xenproject.org>,
	Juergen Gross <jgross@suse.com>,
	"Daniel P . Smith" <dpsmith@apertussolutions.com>,
	Stewart Hildebrand <Stewart.Hildebrand@amd.com>,
	Huang Rui <ray.huang@amd.com>
Subject: Re: [RFC XEN PATCH v12 6/7] tools: Add new function to get gsi from dev
Date: Thu, 1 Aug 2024 15:01:41 +0200	[thread overview]
Message-ID: <ZquHNURGoADdCy6y@macbook> (raw)
In-Reply-To: <20240708114124.407797-7-Jiqian.Chen@amd.com>

On Mon, Jul 08, 2024 at 07:41:23PM +0800, Jiqian Chen wrote:
> When passthrough a device to domU, QEMU and xl tools use its gsi
> number to do pirq mapping, see QEMU code
> xen_pt_realize->xc_physdev_map_pirq, and xl code
> pci_add_dm_done->xc_physdev_map_pirq, but the gsi number is got
> from file /sys/bus/pci/devices/<sbdf>/irq, that is wrong, because
> irq is not equal with gsi, they are in different spaces, so pirq
> mapping fails.
> 
> And in current codes, there is no method to get gsi for userspace.
> For above purpose, add new function to get gsi, and the
> corresponding ioctl is implemented on linux kernel side.
> 
> Signed-off-by: Jiqian Chen <Jiqian.Chen@amd.com>
> Signed-off-by: Huang Rui <ray.huang@amd.com>
> Signed-off-by: Chen Jiqian <Jiqian.Chen@amd.com>
> ---
> RFC: it needs to wait for the corresponding third patch on linux kernel side to be merged.
> https://lore.kernel.org/xen-devel/20240607075109.126277-4-Jiqian.Chen@amd.com/
> This patch must be merged after the patch on linux kernel side
> 
> CC: Anthony PERARD <anthony@xenproject.org>
> Remaining comment @Anthony PERARD:
> Do I need to make " opening of /dev/xen/privcmd " as a single function, then use it in this
> patch and other libraries?
> ---
>  tools/include/xen-sys/Linux/privcmd.h |  7 ++++++
>  tools/include/xenctrl.h               |  2 ++
>  tools/libs/ctrl/xc_physdev.c          | 35 +++++++++++++++++++++++++++
>  3 files changed, 44 insertions(+)
> 
> diff --git a/tools/include/xen-sys/Linux/privcmd.h b/tools/include/xen-sys/Linux/privcmd.h
> index bc60e8fd55eb..4cf719102116 100644
> --- a/tools/include/xen-sys/Linux/privcmd.h
> +++ b/tools/include/xen-sys/Linux/privcmd.h
> @@ -95,6 +95,11 @@ typedef struct privcmd_mmap_resource {
>  	__u64 addr;
>  } privcmd_mmap_resource_t;
>  
> +typedef struct privcmd_gsi_from_pcidev {
> +	__u32 sbdf;
> +	__u32 gsi;
> +} privcmd_gsi_from_pcidev_t;
> +
>  /*
>   * @cmd: IOCTL_PRIVCMD_HYPERCALL
>   * @arg: &privcmd_hypercall_t
> @@ -114,6 +119,8 @@ typedef struct privcmd_mmap_resource {
>  	_IOC(_IOC_NONE, 'P', 6, sizeof(domid_t))
>  #define IOCTL_PRIVCMD_MMAP_RESOURCE				\
>  	_IOC(_IOC_NONE, 'P', 7, sizeof(privcmd_mmap_resource_t))
> +#define IOCTL_PRIVCMD_GSI_FROM_PCIDEV				\
> +	_IOC(_IOC_NONE, 'P', 10, sizeof(privcmd_gsi_from_pcidev_t))
>  #define IOCTL_PRIVCMD_UNIMPLEMENTED				\
>  	_IOC(_IOC_NONE, 'P', 0xFF, 0)
>  
> diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
> index 9ceca0cffc2f..3720e22b399a 100644
> --- a/tools/include/xenctrl.h
> +++ b/tools/include/xenctrl.h
> @@ -1641,6 +1641,8 @@ int xc_physdev_unmap_pirq(xc_interface *xch,
>                            uint32_t domid,
>                            int pirq);
>  
> +int xc_physdev_gsi_from_pcidev(xc_interface *xch, uint32_t sbdf);
> +
>  /*
>   *  LOGGING AND ERROR REPORTING
>   */
> diff --git a/tools/libs/ctrl/xc_physdev.c b/tools/libs/ctrl/xc_physdev.c
> index e9fcd755fa62..54edb0f3c0dc 100644
> --- a/tools/libs/ctrl/xc_physdev.c
> +++ b/tools/libs/ctrl/xc_physdev.c
> @@ -111,3 +111,38 @@ int xc_physdev_unmap_pirq(xc_interface *xch,
>      return rc;
>  }
>  
> +int xc_physdev_gsi_from_pcidev(xc_interface *xch, uint32_t sbdf)

FWIW, I'm not sure it's fine to use the xc_physdev prefix here, as
this is not a PHYSDEVOP hypercall.

As Anthony suggested, it would be better placed in xc_linux.c, and
possibly named xc_pcidev_get_gsi() or similar, to avoid polluting the
xc_physdev namespace.

Thanks, Roger.


  parent reply	other threads:[~2024-08-01 13:02 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-08 11:41 [XEN PATCH v12 0/7] Support device passthrough when dom0 is PVH on Xen Jiqian Chen
2024-07-08 11:41 ` [XEN PATCH v12 1/7] xen/pci: Add hypercall to support reset of pcidev Jiqian Chen
2024-07-08 14:56   ` Jan Beulich
2024-07-09  2:47     ` Chen, Jiqian
2024-07-09  6:01       ` Jan Beulich
2024-07-31 15:55   ` Roger Pau Monné
2024-07-31 15:58     ` Jan Beulich
2024-07-31 16:13       ` Roger Pau Monné
2024-08-01  6:49         ` Jan Beulich
2024-08-02  2:56           ` Chen, Jiqian
2024-08-02  2:55     ` Chen, Jiqian
2024-08-02  6:25       ` Jan Beulich
2024-08-02  7:41         ` Chen, Jiqian
2024-08-02  7:43           ` Jan Beulich
2024-08-02  7:44         ` Roger Pau Monné
2024-07-08 11:41 ` [XEN PATCH v12 2/7] x86/pvh: Allow (un)map_pirq when dom0 is PVH Jiqian Chen
2024-07-08 14:58   ` Jan Beulich
2024-07-22 21:37   ` Stefano Stabellini
2024-07-30 13:09   ` Andrew Cooper
2024-07-31  1:47     ` Chen, Jiqian
2024-07-31  8:31     ` Chen, Jiqian
2024-07-31  8:42       ` Jan Beulich
2024-07-31  7:50   ` Roger Pau Monné
2024-07-31  7:58     ` Jan Beulich
2024-07-31  8:24       ` Roger Pau Monné
2024-07-31  8:40         ` Jan Beulich
2024-07-31  8:51           ` Roger Pau Monné
2024-07-31  9:02             ` Jan Beulich
2024-07-31  9:37               ` Roger Pau Monné
2024-07-31  9:55                 ` Jan Beulich
2024-07-31 11:29                   ` Roger Pau Monné
2024-07-31 11:39                     ` Jan Beulich
2024-07-31 13:03                       ` Roger Pau Monné
2024-08-02  2:37                         ` Chen, Jiqian
2024-08-02  8:11                           ` Roger Pau Monné
2024-08-02  8:17                             ` Chen, Jiqian
2024-08-02  8:35                               ` Roger Pau Monné
2024-08-02  8:40                                 ` Chen, Jiqian
2024-08-02  9:17                                   ` Jan Beulich
2024-08-02  9:37                             ` Jan Beulich
2024-07-31  8:39     ` Chen, Jiqian
2024-07-08 11:41 ` [XEN PATCH v12 3/7] x86/pvh: Add PHYSDEVOP_setup_gsi for PVH dom0 Jiqian Chen
2024-07-10  8:01   ` Chen, Jiqian
2024-07-11  7:58   ` Chen, Jiqian
2024-07-22 21:38   ` Stefano Stabellini
2024-07-08 11:41 ` [XEN PATCH v12 4/7] x86/domctl: Add hypercall to set the access of x86 gsi Jiqian Chen
2024-07-09 13:08   ` Jan Beulich
2024-07-26  6:55     ` Chen, Jiqian
2024-07-22 22:10   ` Stefano Stabellini
2024-07-26  6:53     ` Chen, Jiqian
2024-07-26 20:16       ` Stefano Stabellini
2024-08-01 11:06   ` Roger Pau Monné
2024-08-01 11:36     ` Jan Beulich
2024-08-01 12:41       ` Roger Pau Monné
2024-08-01 13:11         ` Jan Beulich
2024-08-02  3:10     ` Chen, Jiqian
2024-08-02  6:27       ` Jan Beulich
2024-08-02  7:44         ` Chen, Jiqian
2024-08-02  7:59       ` Roger Pau Monné
2024-08-02  8:08   ` Roger Pau Monné
2024-08-02  8:23     ` Chen, Jiqian
2024-08-02  9:40     ` Jan Beulich
2024-08-02 12:05       ` Roger Pau Monné
2024-07-08 11:41 ` [XEN PATCH v12 5/7] tools/libxc: Allow gsi be mapped into a free pirq Jiqian Chen
2024-07-09 13:26   ` Jan Beulich
2024-07-10  7:55     ` Chen, Jiqian
2024-08-01 12:55     ` Roger Pau Monné
2024-07-08 11:41 ` [RFC XEN PATCH v12 6/7] tools: Add new function to get gsi from dev Jiqian Chen
2024-07-08 13:27   ` Anthony PERARD
2024-07-09  3:35     ` Chen, Jiqian
2024-07-29 16:30       ` Anthony PERARD
2024-08-01 13:01   ` Roger Pau Monné [this message]
2024-08-02  3:13     ` Chen, Jiqian
2024-07-08 11:41 ` [RFC XEN PATCH v12 7/7] tools: Add new function to do PIRQ (un)map on PVH dom0 Jiqian Chen
2024-07-08 14:57   ` Anthony PERARD
2024-07-09  6:18     ` 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=ZquHNURGoADdCy6y@macbook \
    --to=roger.pau@citrix.com \
    --cc=Jiqian.Chen@amd.com \
    --cc=Stewart.Hildebrand@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony@xenproject.org \
    --cc=dpsmith@apertussolutions.com \
    --cc=gwd@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=ray.huang@amd.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.