Linux virtualization list
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Julia Zhang <julia.zhang@amd.com>,
	David Airlie <airlied@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Gurchetan Singh <gurchetansingh@chromium.org>,
	Chia-I Wu <olvaffe@gmail.com>,
	dri-devel@lists.freedesktop.org,
	virtualization@lists.linux-foundation.org,
	Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>,
	xen-devel@lists.xenproject.org
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Chen Jiqian" <Jiqian.Chen@amd.com>,
	"Huang Rui" <ray.huang@amd.com>,
	"Penny Zheng" <penny.zheng@amd.com>,
	"Zhu Lingshan" <Lingshan.Zhu@amd.com>,
	"Anthony PERARD" <anthony.perard@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Jan Beulich" <jbeulich@suse.com>, "Paul Durrant" <paul@xen.org>
Subject: Re: [PATCH 3/3] drm/virtio: Implement device_attach
Date: Mon, 9 Dec 2024 13:28:16 +0100	[thread overview]
Message-ID: <36aa77a1-7a72-4cf4-850a-210e6f7f266a@amd.com> (raw)
In-Reply-To: <20241207105023.542399-4-julia.zhang@amd.com>

Am 07.12.24 um 11:50 schrieb Julia Zhang:
> As vram objects may be imported by other gpu drivers, peer2peer flag
> should be checked in dma_buf_ops->attach(). This reimplement virtio gpu
> dma_buf_ops->attach by adding a device_attach() function for virtio gpu.
> This function will get pci_p2pdma_distance and check attach->peer2peer
> before calling drm_gem_map_attach().
>
> Signed-off-by: Julia Zhang <julia.zhang@amd.com>

I can't judge that virtgpu or XEN code path, but that here looks like it 
should work.

Acked-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/virtio/virtgpu_prime.c | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
> index 4960620eba02..4f6bce79e10e 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_prime.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
> @@ -116,6 +116,18 @@ static int virtgpu_get_p2pdma_distance(struct dma_buf *dma_buf,
>   	return 0;
>   }
>   
> +static int virtgpu_gem_device_attach(struct dma_buf *dma_buf,
> +				     struct dma_buf_attachment *attach)
> +{
> +	int ret = virtgpu_get_p2pdma_distance(dma_buf, attach);
> +	if (ret)
> +		return ret;
> +	if (!attach->peer2peer)
> +		return -EBUSY;
> +
> +	return drm_gem_map_attach(dma_buf, attach);
> +}
> +
>   static const struct virtio_dma_buf_ops virtgpu_dmabuf_ops =  {
>   	.ops = {
>   		.cache_sgt_mapping = true,
> @@ -128,7 +140,7 @@ static const struct virtio_dma_buf_ops virtgpu_dmabuf_ops =  {
>   		.vmap = drm_gem_dmabuf_vmap,
>   		.vunmap = drm_gem_dmabuf_vunmap,
>   	},
> -	.device_attach = drm_gem_map_attach,
> +	.device_attach = virtgpu_gem_device_attach,
>   	.get_uuid = virtgpu_virtio_get_uuid,
>   };
>   


  reply	other threads:[~2024-12-09 12:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-07 10:50 [PATCH 0/3] virtgpu: check if P2P is possiable or not Julia Zhang
2024-12-07 10:50 ` [PATCH 1/3] xen:get p2pdma_distance Julia Zhang
2024-12-07 10:50 ` [PATCH 2/3] virtgpu: get p2pdma_distance Julia Zhang
2024-12-07 10:50 ` [PATCH 3/3] drm/virtio: Implement device_attach Julia Zhang
2024-12-09 12:28   ` Christian König [this message]
2024-12-12  7:43 ` [PATCH 0/3] virtgpu: check if P2P is possiable or not Juergen Gross
2024-12-13  9:58   ` Zhang, Julia

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=36aa77a1-7a72-4cf4-850a-210e6f7f266a@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Jiqian.Chen@amd.com \
    --cc=Lingshan.Zhu@amd.com \
    --cc=airlied@redhat.com \
    --cc=alexander.deucher@amd.com \
    --cc=anthony.perard@citrix.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gurchetansingh@chromium.org \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=julia.zhang@amd.com \
    --cc=kraxel@redhat.com \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=olvaffe@gmail.com \
    --cc=paul@xen.org \
    --cc=penny.zheng@amd.com \
    --cc=ray.huang@amd.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=virtualization@lists.linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox