All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Zhang, Julia" <Julia.Zhang@amd.com>,
	Gurchetan Singh <gurchetansingh@chromium.org>,
	Chia-I Wu <olvaffe@gmail.com>, David Airlie <airlied@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"virtualization@lists.linux-foundation.org"
	<virtualization@lists.linux-foundation.org>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	David Airlie <airlied@gmail.com>,
	Erik Faye-Lund <kusmabite@gmail.com>,
	"Olsak, Marek" <Marek.Olsak@amd.com>,
	David Stevens <stevensd@chromium.org>,
	Daniel Vetter <daniel@ffwll.ch>
Cc: "Huang, Ray" <Ray.Huang@amd.com>,
	"Zhu, Lingshan" <Lingshan.Zhu@amd.com>,
	 "robdclark@chromium.org" <robdclark@chromium.org>,
	"Pelloux-Prayer,
	Pierre-Eric" <Pierre-eric.Pelloux-prayer@amd.com>,
	"Huang, Honglei1" <Honglei1.Huang@amd.com>,
	"Chen, Jiqian" <Jiqian.Chen@amd.com>
Subject: Re: [PATCH v2 1/1] drm/virtio: Implement device_attach
Date: Wed, 4 Dec 2024 10:32:30 +0100	[thread overview]
Message-ID: <bfe6a8b7-adcf-40e2-b7a2-4e64dc96862d@amd.com> (raw)
In-Reply-To: <IA1PR12MB6532BBDDA6B5DC4744E38232F2372@IA1PR12MB6532.namprd12.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 6306 bytes --]

Hi Julia,

sorry I totally missed your mail.

The basic problem for P2P is what I already described in my previous mail:

> Well the problem is the virtualized environment. pci_p2pdma_distance() 
> checks if two physical PCI devices can communicate with each other 
> (and returns how many hops are in between).
>
> But inside a VM you don't see the physical devices, you can only see 
> passed through devices plus your virtual device and a bunch of virtual 
> bridges.
>
> So what pci_p2pdma_distance() returns inside the VM is actually 
> completely meaningless. It can be that P2P works, but it can also be 
> P2P doesn't work because on the physical system you have a bridge, 
> root complex or whatever which is blacklisted and won't work for some 
> reason.

So the basic problem is that you can't figure out inside the VM if P2P 
is possible or not.

As long as you don't fix this it's irrelevant if you have get_sg_table 
implemented or not, you first need to figure out the basic and not try 
to implement some detail.

Regards,
Christian.

Am 04.12.24 um 04:46 schrieb Zhang, Julia:
>
> [AMD Official Use Only - AMD Internal Distribution Only]
>
>
> Hi Sima, Christian,
>
> I would like to rediscuss about p2p in guest VM, can you please take a 
> look. Thanks.
>
> Best regards,
>
> Julia
>
> *From:*Zhang, Julia <Julia.Zhang@amd.com>
> *Sent:* Friday, November 29, 2024 3:52 PM
> *To:* Koenig, Christian <Christian.Koenig@amd.com>; Zhang, Julia 
> <Julia.Zhang@amd.com>; Gurchetan Singh <gurchetansingh@chromium.org>; 
> Chia-I Wu <olvaffe@gmail.com>; David Airlie <airlied@redhat.com>; Gerd 
> Hoffmann <kraxel@redhat.com>; linux-kernel@vger.kernel.org; 
> dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; 
> virtualization@lists.linux-foundation.org; Deucher, Alexander 
> <Alexander.Deucher@amd.com>; David Airlie <airlied@gmail.com>; Erik 
> Faye-Lund <kusmabite@gmail.com>; Olsak, Marek <Marek.Olsak@amd.com>; 
> Pelloux-Prayer, Pierre-Eric <Pierre-eric.Pelloux-prayer@amd.com>; 
> Huang, Honglei1 <Honglei1.Huang@amd.com>; Chen, Jiqian 
> <Jiqian.Chen@amd.com>; Huang, Ray <Ray.Huang@amd.com>; David Stevens 
> <stevensd@chromium.org>
> *Cc:* Huang, Ray <Ray.Huang@amd.com>; Zhu, Lingshan 
> <Lingshan.Zhu@amd.com>; robdclark@chromium.org
> *Subject:* Re: [PATCH v2 1/1] drm/virtio: Implement device_attach
>
> Hi all,
>
> Sorry for my late reply. I don't know if you still remember this 
> thread, let me give a quick summary:
>
>  1. We want to implement the dGPU prime feature in guest VM. But we
>     encountered this issue: virtio-gpu doesn’t have ->get_sg_table
>     implemented which is required by drm_gem_map_attach(). This is
>     modified by: 207395da5a97 (“drm/prime: reject DMA-BUF attach when
>     get_sg_table is missing”).
>  2. To fix this, I override the function virtgpu_gem_device_attach()
>     to not call drm_gem_map_attach() for vram object so
>     drm_gem_map_attach() will not return -ENOSYS for not having
>     ->get_sg_table.
>  3. Then you think this is incorrect and drm_gem_map_attach() requires
>     get_sg_table to be implemented is intentional. I should either
>     implement ->attach or ->get_sg_table for virtio-gpu.
>  4. As discussed, I implemented ->attach for virtio-gpu, but you
>     suggested that I should check peer2peer flag first.
>  5. Now I have the implementation to get p2p_distance and check the
>     p2p flag already, but I found that Rob Clark merged a patch to fix
>     above patch: 207395da5a97 (“drm/prime: reject DMA-BUF attach when
>     get_sg_table is missing”)
>      1. Rob’s patch: https://patchwork.freedesktop.org/patch/584318/
>  6. With Rob’s patch, ->get_sg_table isn’t required for virtio-gpu
>     anymore and  it seems p2p flag also doesn’t need to be checked
>     anymore.
>
> So I want to rediscuss if we still need to do p2p checking now?
>
> If so, I will send out my implementation soon.
>
> Best regards,
>
> Julia
>
> On 2024/1/31 22:32, Christian König wrote:
>
>     Am 31.01.24 um 11:20 schrieb Zhang, Julia:
>
>         On 2024/1/30 22:23, Christian König wrote:
>
>             Am 30.01.24 um 12:16 schrieb Daniel Vetter:
>
>                 On Tue, Jan 30, 2024 at 12:10:31PM +0100, Daniel Vetter wrote:
>
>                     [SNIP]
>
>         Hi Sima, Christian,
>
>             Yeah, that is really just speculative. All importers need to set the peer2peer flag just in case.
>
>         I see, I will modify this.
>
>             What happens under the hood is that IOMMU redirects the "VRAM" memory access to whatever address the DMA-buf on the host is pointing to (system, VRAM, doorbell, IOMMU, whatever).
>
>             I'm also not 100% sure if all the cache snooping is done correctly in all cases, but for now it seems to work.
>
>                     Frankly the more I look at the original patch that added vram export
>
>                     support the more this just looks like a "pls revert, this is just too
>
>                     broken".
>
>                 The commit I mean is this one: ea5ea3d8a117 ("drm/virtio: support mapping
>
>                 exported vram"). The commit message definitely needs to cite that one, and
>
>                 also needs a cc: stable because not rejecting invalid imports is a pretty
>
>                 big deal.
>
>             Yeah, I've pointed out that commit in an internal discussion as well. I was just not aware that it's that severely broken.
>
>         Yeah we have mentioned this patch before, but I don't totally understand why this is too broken. Without exporting vram objects, dGPU prime feature would not be realized.
>
>         Would you mind to explain more about it. Thanks!
>
>
>     One reason is that using sg tables without struct pages is
>     actually a hack we came up with because we couldn't hope to clean
>     up the sg table structure any time soon to not include struct page
>     pointers.
>
>     Another reason is that using this with devices which don't expect
>     a DMA address pointing into a virtual PCI BAR. So doing this
>     without checking the peer2peer flag can most likely cause quite a
>     bit of trouble.
>
>     Regards,
>     Christian.
>
>         Best regards,
>
>         Julia
>
>             Regards,
>
>             Christian.
>

[-- Attachment #2: Type: text/html, Size: 16253 bytes --]

  reply	other threads:[~2024-12-04  9:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-29 10:31 [PATCH v2 1/1] drm/virtio: Implement device_attach Julia Zhang
2024-01-29 10:31 ` Julia Zhang
2024-01-29 13:12 ` Christian König
2024-01-29 13:12   ` Christian König
2024-01-30 11:10 ` Daniel Vetter
2024-01-30 11:10   ` Daniel Vetter
2024-01-30 11:10   ` Daniel Vetter
2024-01-30 11:16   ` Daniel Vetter
2024-01-30 14:23     ` Christian König
2024-01-31 10:20       ` Zhang, Julia
2024-01-31 14:32         ` Christian König
2024-11-29  7:51           ` Zhang, Julia
2024-12-04  3:46             ` Zhang, Julia
2024-12-04  9:32               ` Christian König [this message]
2024-12-06  6:43                 ` 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=bfe6a8b7-adcf-40e2-b7a2-4e64dc96862d@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Honglei1.Huang@amd.com \
    --cc=Jiqian.Chen@amd.com \
    --cc=Julia.Zhang@amd.com \
    --cc=Lingshan.Zhu@amd.com \
    --cc=Marek.Olsak@amd.com \
    --cc=Pierre-eric.Pelloux-prayer@amd.com \
    --cc=Ray.Huang@amd.com \
    --cc=airlied@gmail.com \
    --cc=airlied@redhat.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gurchetansingh@chromium.org \
    --cc=kraxel@redhat.com \
    --cc=kusmabite@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olvaffe@gmail.com \
    --cc=robdclark@chromium.org \
    --cc=stevensd@chromium.org \
    --cc=virtualization@lists.linux-foundation.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.