From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF13CD767DC for ; Fri, 19 Dec 2025 11:35:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 83D1410EF41; Fri, 19 Dec 2025 11:35:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="itx0bRH3"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 36CB310EF40; Fri, 19 Dec 2025 11:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1766144109; x=1797680109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VYywXm4UdkLrI+kyFm+UlWkaM12K80XJc7dlo+814pM=; b=itx0bRH3BYdSGIbfv6R3WHm0DDp4PGYekZaom8JL33/5B9e1YGAFFcYw HyzFHWqHWIDb7qAGo/T38ZyAfh5+zOuazzuVoxQSKtk2Pm6TIuF7aYvml qnm29Lx3EEn5e3ouZAZRRPZkAwEf6+V6NzHcTAYu+i9LUSKIJ88r2s7QD ULDlnaR8pS008zrDIgAHVjODsHTUCmOOw7fJ+zTT08pK1fIRRxn6Be9Hw gvFJFOKCrsZhxEgFdvJS0AJPjUztUv6pE+IlmA139B1+Drd/B0UJaAinV 9+Teq2K75yFQiGrEDhujYjY4JUwaNK+tqs60QVQLmI+lPKuPi1SKkqAs2 w==; X-CSE-ConnectionGUID: Ry67+gHrSFqnViFM6Rwopw== X-CSE-MsgGUID: GfS5yv6iTuKYVG867HnhLQ== X-IronPort-AV: E=McAfee;i="6800,10657,11646"; a="79224596" X-IronPort-AV: E=Sophos;i="6.21,161,1763452800"; d="scan'208";a="79224596" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2025 03:35:09 -0800 X-CSE-ConnectionGUID: whhxm24rQU27M6E2xPlSRw== X-CSE-MsgGUID: PPD52RKkT6iBw7tb8JzYfA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,161,1763452800"; d="scan'208";a="203005792" Received: from egrumbac-mobl6.ger.corp.intel.com (HELO fedora) ([10.245.244.251]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2025 03:35:05 -0800 From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Cc: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Matthew Brost , dri-devel@lists.freedesktop.org, himal.prasad.ghimiray@intel.com, apopple@nvidia.com, airlied@gmail.com, Simona Vetter , felix.kuehling@amd.com, =?UTF-8?q?Christian=20K=C3=B6nig?= , dakr@kernel.org, "Mrozek, Michal" , Joonas Lahtinen Subject: [PATCH v6 18/24] drm/xe/svm: Document how xe keeps drm_pagemap references Date: Fri, 19 Dec 2025 12:33:14 +0100 Message-ID: <20251219113320.183860-19-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251219113320.183860-1-thomas.hellstrom@linux.intel.com> References: <20251219113320.183860-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" As an aid to understanding the lifetime of the drm_pagemaps used by the xe driver, document how the xe driver keeps the drm_pagemap references. v3: - Fix formatting (Matt Brost) Suggested-by: Matthew Brost Signed-off-by: Thomas Hellström Reviewed-by: Matthew Brost --- drivers/gpu/drm/xe/xe_svm.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c index 43af813276b8..68f30338abee 100644 --- a/drivers/gpu/drm/xe/xe_svm.c +++ b/drivers/gpu/drm/xe/xe_svm.c @@ -28,6 +28,27 @@ #define XE_PEER_PAGEMAP ((void *)0ul) #define XE_PEER_VM ((void *)1ul) +/** + * DOC: drm_pagemap reference-counting in xe: + * + * In addition to the drm_pagemap internal reference counting by its zone + * device data, the xe driver holds the following long-time references: + * + * - struct xe_pagemap: + * The xe_pagemap struct derives from struct drm_pagemap and uses its + * reference count. + * - SVM-enabled VMs: + * SVM-enabled VMs look up and keeps a reference to all xe_pagemaps on + * the same device. + * - VMAs: + * vmas keep a reference on the drm_pagemap indicated by a gpu_madvise() + * call. + * + * In addition, all drm_pagemap or xe_pagemap pointers where lifetime cannot + * be guaranteed by a vma reference under the vm lock should keep a reference. + * That includes the range->pages.dpagemap pointer. + */ + static int xe_svm_get_pagemaps(struct xe_vm *vm); void *xe_svm_private_page_owner(struct xe_vm *vm, bool force_smem) -- 2.51.1