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 5DB9B606A330 for ; Wed, 2 Dec 2026 23:53:00 +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=T+b1vMXr Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2780111264A; Wed, 2 Dec 2026 23:52:55 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB3AE112638; Wed, 2 Dec 2026 23:52:48 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id AFB3460DA8; Wed, 2 Dec 2026 23:52:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 501071F00899; Wed, 2 Dec 2026 23:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796255567; bh=ptlkyEi6VsLXeQWn/3hYuk7u/d5be3dLHleqg63n11A=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=T+b1vMXrGiYplmuFYOwTUAIralNKQ9yqUWZnGU/lH06FCRX6Ql9D+mP5X0FmP5FxN iEuzffpVmNW3rJP3fh56kTgK6NoCoBfo5dG68dy2etboVPZpo7WlMLZRlCLeE/yU1f 6nDosczfncKZ1hCp/e48Q+BPXtEQmS1tRUHJZxlX/BTZXA+2wVu9bYHl32Z/aj89gR UQjF7YLlOWZfjFIeHMcTwe5c/mg6UGXuvwGk1wyq8UgBb2rTbr74OGw5gaHVPbs2dN cYjI+JQYhhzMmbMkKYBgsHT5SmgXHHQSCPbiogg/l4vhXjQgSYKUeNP5cpoWJWzyAD SNiflbe+4ujeQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 26/36] drm/xe: Don't DMA map tt pages after device unplug To: "Matthew Brost" , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org In-Reply-To: <20261202233323.3743190-27-matthew.brost@intel.com> References: <20261202233323.3743190-1-matthew.brost@intel.com> <20261202233323.3743190-27-matthew.brost@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 23:52:46 +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=ham 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: broken VRAM dma-buf eviction on unplug in xe_tt_map_sg() -- commit 6ee99dc07c1b583a7ad70334282ca88f6e39b4b1 Author: Matthew Brost drm/xe: Don't DMA map tt pages after device unplug This commit rejects DMA-mapping ttm_tt pages in xe_tt_map_sg() with -ENODEV once the DRM device has been marked unplugged. > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > index 41092e2810b42..8ff92b2c91761 100644 > --- a/drivers/gpu/drm/xe/xe_bo.c > +++ b/drivers/gpu/drm/xe/xe_bo.c > @@ -499,6 +499,16 @@ static int xe_tt_map_sg(struct xe_device *xe, struct= ttm_tt *tt) > if (xe_tt->sg) > return 0; > =20 > + /* > + * Once the device is unplugged, xe_bo_pci_dev_remove_all() has dropped > + * (or is about to drop, under each bo's lock) all DMA mappings. Don't > + * create new ones, e.g. when an exported dma-buf moved out to system > + * is migrated back to TT by begin_cpu_access(): such a mapping would > + * outlive the device's IOMMU group and crash on unmap. > + */ > + if (drm_dev_is_unplugged(&xe->drm)) > + return -ENODEV; [Severity: High] Does this break evicting exported dma-buf BOs from VRAM during device removal? In xe_device_remove(), drm_dev_unplug() runs before xe_bo_pci_dev_remove_all(): drivers/gpu/drm/xe/xe_device.c:xe_device_remove() { ... drm_dev_unplug(&xe->drm); xe_bo_pci_dev_remove_all(xe); ... } When xe_bo_pci_dev_remove_all() evicts an exported dma-buf BO from XE_PL_VRAM0 or XE_PL_VRAM1, xe_evict_flags() selects tt_placement so the BO moves to XE_PL_TT before XE_PL_SYSTEM. That VRAM-to-TT move allocates a new ttm_tt and calls xe_bo_move() -> xe_tt_map_sg(), which now fails with -ENODEV because drm_dev_is_unplugged() is already true. As a result, ttm_resource_manager_evict_all() aborts with a warning, the exported dma-buf BO is left in VRAM, and xe_ttm_vram_mgr_fini() returns early without running gpu_buddy_fini() or ttm_resource_manager_cleanup(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202233323.3743= 190-1-matthew.brost@intel.com?part=3D26