From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72E40606A682 for ; Tue, 1 Dec 2026 07:27:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=c3F7DYqb Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 36BCF10F046; Tue, 1 Dec 2026 07:26:57 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id A383A10E16A; Tue, 1 Dec 2026 07:26:50 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A844560E0F; Tue, 1 Dec 2026 07:26:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C65661F00898; Tue, 1 Dec 2026 07:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796110009; bh=UcVBCsXIjhKPuuJT+hmzicpZVk5SrTZ+RJU0kjYyu+k=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=c3F7DYqb+oE2AQOJHg1RwWInGqt8Sswenbdq53XggubiyOsWEEOsISuvg4v+qOG+Y cQeTkO4liVLr89vHBD9sxjcRkv7X64Rur2VZb0yMokQzU4lWmj3DA35DRJhCsoeazK 3yBxIQutICqn0z96QVYYwLT/QhUWMo9SH12W34p4Anxz/CJBXGUad3EYT6wU419Gkq 7PUbjr+jTysFNu8lHSVIweYCtdEZgL+4MZ2AepKRrovjx9fc2VQLH6ePZvBO8ArDdx 5at1LLDwuER88dQhKcAJRjM3WVlq2vlHNqeNVLXxh3fTmY7oimiMJTLZIKimumoLLq hwzYLp6hYtcEQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RFC 15/16] drm/xe/dma-buf: Export a dma_shared_buf instead of mapping the buffer To: "Alistair Popple" Cc: dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, kvm@vger.kernel.org, media-ci@linuxtv.org In-Reply-To: <20261201-dmabuf_shared_buf_v1_xe_rc5-v1-15-b672717c7fc9@nvidia.com> References: <20261201-dmabuf_shared_buf_v1_xe_rc5-v1-0-b672717c7fc9@nvidia.com> <20261201-dmabuf_shared_buf_v1_xe_rc5-v1-15-b672717c7fc9@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 07:26:48 +0000 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Intel-xe" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/xe/dma-buf: xe_dma_buf_attach() clears peer2peer for iommufd attachments -- commit afc228f35dfc8ad8b39e640599fbccbde0209c02 Author: Alistair Popple drm/xe/dma-buf: Export a dma_shared_buf instead of mapping the buffer This commit replaces xe_dma_buf_map() and xe_dma_buf_unmap() with map_dma_shared_buf() and unmap_dma_shared_buf() callbacks, initializing a p2pdma provider for the VRAM BAR so VRAM and system memory buffers are exported as dma_shared_buf ranges. > diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_= buf.c > index 97299ca8f8316..8727ca456f2fb 100644 > --- a/drivers/gpu/drm/xe/xe_dma_buf.c > +++ b/drivers/gpu/drm/xe/xe_dma_buf.c > @@ -111,14 +111,14 @@ static void xe_dma_buf_unpin(struct dma_buf_attachm= ent *attach) > xe_bo_unpin_external(bo); > } > =20 > -static struct sg_table *xe_dma_buf_map(struct dma_buf_attachment *attach, > - enum dma_data_direction dir) > +static struct dma_shared_buf * > +xe_dma_buf_map_dma_shared_buf(struct dma_buf_attachment *attach) > { > struct dma_buf *dma_buf =3D attach->dmabuf; > struct drm_gem_object *obj =3D dma_buf->priv; > struct xe_bo *bo =3D gem_to_xe_bo(obj); > struct drm_exec *exec =3D XE_VALIDATION_UNSUPPORTED; > - struct sg_table *sgt; > + struct dma_shared_buf *shared_buf; > int r =3D 0; > =20 > if (xe_bo_is_purged(bo)) > @@ -138,49 +138,24 @@ static struct sg_table *xe_dma_buf_map(struct dma_b= uf_attachment *attach, > =20 > switch (bo->ttm.resource->mem_type) { > case XE_PL_TT: > - sgt =3D drm_prime_pages_to_sg(obj->dev, > - bo->ttm.ttm->pages, > - obj->size >> PAGE_SHIFT); > - if (IS_ERR(sgt)) > - return sgt; > - > - if (dma_map_sgtable(attach->dev, sgt, dir, > - DMA_ATTR_SKIP_CPU_SYNC)) > - goto error_free; > - break; > - > + shared_buf =3D dma_shared_buf_from_pages(bo->ttm.ttm->pages, > + obj->size >> PAGE_SHIFT); > + if (!IS_ERR(shared_buf)) > + shared_buf->attrs =3D DMA_ATTR_SKIP_CPU_SYNC; > + return shared_buf; > case XE_PL_VRAM0: > case XE_PL_VRAM1: > - r =3D xe_ttm_vram_mgr_alloc_sgt(xe_bo_device(bo), > - bo->ttm.resource, 0, > - bo->ttm.base.size, attach->dev, > - dir, &sgt); > - if (r) > - return ERR_PTR(r); > - break; > + return xe_ttm_vram_mgr_alloc_shared_buf(xe_bo_device(bo), > + bo->ttm.resource); [Severity: High] Can iommufd ever reach the XE_PL_VRAM0 / XE_PL_VRAM1 path here to map VRAM buffers? When iopt_map_dmabuf() attaches to the dma-buf, it passes iommufd_global_device() (a virtual miscdevice, not a PCI device) as attach->dev. In xe_dma_buf_attach(), pci_p2pdma_distance() returns -1 because find_parent_pci_dev(attach->dev) is NULL: drivers/gpu/drm/xe/xe_dma_buf.c:xe_dma_buf_attach() { ... if (attach->peer2peer && pci_p2pdma_distance(to_pci_dev(obj->dev->dev), attach->dev, verbose_p2= p_dist) < 0) attach->peer2peer =3D false; if (!attach->peer2peer && !xe_bo_can_migrate(gem_to_xe_bo(obj), XE_PL_TT)) return -EOPNOTSUPP; ... } Clearing attach->peer2peer causes VRAM-only buffer objects to fail iommufd import with -EOPNOTSUPP, while buffers that allow XE_PL_TT are migrated out of VRAM into system memory and pinned there by xe_dma_buf_pin(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-dmabuf_sha= red_buf_v1_xe_rc5-v1-0-b672717c7fc9@nvidia.com?part=3D15