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 9833F606A32F for ; Fri, 4 Dec 2026 07:21:57 +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=cWLggZPb Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5EF88112C68; Fri, 4 Dec 2026 07:21:52 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 707DC112BC1; Fri, 4 Dec 2026 07:21:45 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 3358C43599; Fri, 4 Dec 2026 07:21:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9C721F00897; Fri, 4 Dec 2026 07:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796368905; bh=ogLxtpgKEPyqJaB/6bmH4JiF3c4wRy26hxAE8BRPb00=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=cWLggZPbitzgh22o4zzCnsA1e/qqSaaOj0h55xT6eHltZ0ohaWLPcpl6umKIcaG1l d7rvn2SUAjwrVAX04pXn/y/jh12+T/mwaNhEf6qAFFHNq6V9eYmjaJCNnpv0OfmIcT CrFNq3ZpKFn9++ZCfgtRMJ9r5mW5Qun+byBkk/8MRTxNolIgc1tXk0ekAiTJlo8NGD l1OElF6t+gyqKkiaRNFJgtL0QIEvjr7f0bXE7umHkhrsYQDGqzxqjEQw6wKcPUX8CE kYLFbaFzk3pkr0JA1S14cLL5e8fprIZ6yw7qSfJCtas+flSqaaWPC6835EMCuI8Wa0 xwhOOG4i1XZ+Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 1/2] drm/xe: Snapshot inline DMA addresses before staging page tables To: "Arvind Yadav" , dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org In-Reply-To: <20261204065318.1785149-2-arvind.yadav@intel.com> References: <20261204065318.1785149-1-arvind.yadav@intel.com> <20261204065318.1785149-2-arvind.yadav@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 07:21:44 +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=-11.2 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: - [Medium] drm/xe: unconditional extra pt_op scan in xe_pt_update_ops_run() -- commit ac07d47429f6fccce3b202a8348537d6d71f609b Author: Arvind Yadav drm/xe: Snapshot inline DMA addresses before staging page tables This commit protects userptr DMA address lookups with notifier_lock and copies inline DMA entries before staging page tables in xe_pt_stage_bind(). For invalidated userptrs outside fault mode, it stages cleared PTEs and keeps the affected tiles marked invalidated at commit time. > diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c > index 0e0bf428df0f7..4a6135ab2c8d3 100644 > --- a/drivers/gpu/drm/xe/xe_pt.c > +++ b/drivers/gpu/drm/xe/xe_pt.c [ ... ] > @@ -2869,7 +2904,6 @@ xe_pt_update_ops_run(struct xe_device *xe, struct x= e_vma_ops *vops) > xe_pt_commit(pt_op->vma, pt_op->entries, > pt_op->num_entries, > &pt_update_ops->pt_job_ops->deferred); > - pt_op->vma =3D NULL; /* skip in xe_pt_update_ops_abort */ > tile_mask |=3D BIT(tile->id); > } > } > @@ -2905,6 +2939,38 @@ xe_pt_update_ops_run(struct xe_device *xe, struct = xe_vma_ops *vops) > tile_mask); > } > =20 > + /* > + * op_commit() assumes a normal bind installed valid PTEs. Restore the > + * actual userptr state from the staged operations, in operation order, > + * before releasing the notifier lock. With shared page tables, tile 0 > + * determines the state for all tiles. > + */ > + for_each_tile(tile, xe, j) { > + struct xe_vm_pgtable_update_ops *pt_update_ops =3D > + &vops->pt_update_ops[j]; > + u8 mask =3D xe->info.has_pt_mirror ? BIT(tile->id) : tile_mask; > + > + if (pt_mirroring_disabled_for_tile(vm, j)) > + continue; > + > + for (i =3D 0; i < get_current_op(pt_update_ops); ++i) { > + struct xe_vm_pgtable_update_op *pt_op =3D > + to_pt_op(pt_update_ops, i); > + struct xe_vma *vma =3D pt_op->vma; > + > + if (pt_op->bind && xe_vma_is_userptr(vma)) { > + /* Pairs with READ_ONCE in xe_vm_has_valid_gpu_mapping(). */ > + if (pt_op->pt_cleared) > + WRITE_ONCE(vma->tile_invalidated, > + vma->tile_invalidated | mask); > + else > + WRITE_ONCE(vma->tile_invalidated, > + vma->tile_invalidated & ~mask); > + } > + pt_op->vma =3D NULL; /* skip in xe_pt_update_ops_abort */ > + } > + } > + > if (needs_svm_lock) > xe_pt_svm_userptr_notifier_unlock(vm); [Severity: Medium] Can this second pass over pt_job_ops->ops be skipped when no userptr bind staged cleared PTEs? Moving pt_op->vma =3D NULL out of the xe_pt_commit() loop forces every xe_pt_update_ops_run() call to stride across all 384-byte pt_op entries again and dereference pt_op->vma on every bind, even for pure BO VM_BIND batches where needs_svm_lock is false and no userptr ops exist. When needs_svm_lock is true, such as multi-range SVM prefetches or normal non-invalidated userptr batches, this extra scan also runs while holding vm->svm.gpusvm.notifier_lock, extending the read-side hold window against MMU notifier invalidations. Recording a flag on pt_update_ops or vops when bind_op_prepare() stages a userptr with pt_op->pt_cleared would let pt_op->vma =3D NULL stay in the first loop and skip this post-op_commit() walk in the common case. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204065318.1785= 149-1-arvind.yadav@intel.com?part=3D1