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 B4172E8384C for ; Tue, 17 Feb 2026 02:35:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 663E110E421; Tue, 17 Feb 2026 02:35:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ELxfDzf4"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5518410E15A for ; Tue, 17 Feb 2026 02:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1771295749; x=1802831749; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hz13zQw2KfjgFebmdUfdRJc+sytwwIF5LQc6mZfims0=; b=ELxfDzf4UPygLyisVSh3s/bjrnB2AR0pak+4/SRQ1sMkiZLwOo0cJkVK mHPqyW7c6jdPyMP6Pyj/meKv3QHLVfxBrSq9AQcKzOCUen/CyXTTmna4w +2JP7Baf3Kgi4fFUxwP9mfDvaY+QtybVrtrbrRdcK0b5zTVp7SelDbHGf Wz3zsdAn5fB6Gt9QWBLmuLFgC1mJyr7NYA5l5p2HCPdvcspDPcWDEgUfm AnoUsA3QjXc0tzWhJMF1sMLVgkE7QfkJwp29hl5oy5GlbsnnLYBkAAYC/ m/9YgtKMy02lCB/uKxaj3RQe982KRSxPNsLNLUSf7GfKsZx3gXXkW90ju w==; X-CSE-ConnectionGUID: uXkuHyTSSXCzEutL4atISg== X-CSE-MsgGUID: uMeHlKBJTt+suY+/boJAIw== X-IronPort-AV: E=McAfee;i="6800,10657,11703"; a="72358384" X-IronPort-AV: E=Sophos;i="6.21,295,1763452800"; d="scan'208";a="72358384" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2026 18:35:48 -0800 X-CSE-ConnectionGUID: 7ZFpynodSri8s8fJdXEcYw== X-CSE-MsgGUID: TLHcUuMOQKOAmORC79NuXg== X-ExtLoop1: 1 Received: from varungup-desk.iind.intel.com ([10.190.238.71]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2026 18:34:34 -0800 From: Arvind Yadav To: igt-dev@lists.freedesktop.org Cc: matthew.brost@intel.com, himal.prasad.ghimiray@intel.com, thomas.hellstrom@linux.intel.com, nishit.sharma@intel.com, pravalika.gurram@intel.com Subject: [PATCH i-g-t v3 1/8] drm-uapi/xe_drm: Add UAPI support for purgeable buffer objects Date: Tue, 17 Feb 2026 08:04:12 +0530 Message-ID: <20260217023423.2632617-2-arvind.yadav@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260217023423.2632617-1-arvind.yadav@intel.com> References: <20260217023423.2632617-1-arvind.yadav@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" From: Himal Prasad Ghimiray Extend the DRM_XE_MADVISE ioctl to support purgeable buffer object management by adding DRM_XE_VMA_ATTR_PURGEABLE_STATE attribute type. This allows userspace applications to provide memory usage hints to the kernel for better memory management under pressure: This allows userspace applications to provide memory usage hints to the kernel for better memory management under pressure: - WILLNEED: Buffer is needed and should not be purged. If the BO was previously purged, retained field returns 0 indicating backing store was lost (once purged, always purged semantics matching i915). - DONTNEED: Buffer is not currently needed and may be purged by the kernel under memory pressure to free resources. Only applies to non-shared BOs. The implementation includes a 'retained' output field (matching i915's drm_i915_gem_madvise.retained) that indicates whether the BO's backing store still exists (1) or has been purged (0). v2: - Update UAPI documentation to clarify retained must be initialized to 0(Thomas) Cc: Nishit Sharma Cc: Pravalika Gurram Cc: Matthew Brost Cc: Thomas Hellström Signed-off-by: Himal Prasad Ghimiray Signed-off-by: Arvind Yadav --- include/drm-uapi/xe_drm.h | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/include/drm-uapi/xe_drm.h b/include/drm-uapi/xe_drm.h index 077e66a68..3dd1ba875 100644 --- a/include/drm-uapi/xe_drm.h +++ b/include/drm-uapi/xe_drm.h @@ -2099,6 +2099,7 @@ struct drm_xe_madvise { #define DRM_XE_MEM_RANGE_ATTR_PREFERRED_LOC 0 #define DRM_XE_MEM_RANGE_ATTR_ATOMIC 1 #define DRM_XE_MEM_RANGE_ATTR_PAT 2 +#define DRM_XE_VMA_ATTR_PURGEABLE_STATE 3 /** @type: type of attribute */ __u32 type; @@ -2189,6 +2190,49 @@ struct drm_xe_madvise { /** @pat_index.reserved: Reserved */ __u64 reserved; } pat_index; + + /** + * @purge_state_val: Purgeable state configuration + * + * Used when @type == DRM_XE_VMA_ATTR_PURGEABLE_STATE. + * + * Configures the purgeable state of buffer objects in the specified + * virtual address range. This allows applications to hint to the kernel + * about bo's usage patterns for better memory management. + * + * Supported values for @purge_state_val.val: + * - DRM_XE_VMA_PURGEABLE_STATE_WILLNEED (0): Marks BO as needed. + * If BO was purged, returns retained=0 (backing store lost). + * + * - DRM_XE_VMA_PURGEABLE_STATE_DONTNEED (1): Hints that BO is not + * currently needed. Kernel may purge it under memory pressure. + * Only applies to non-shared BOs. Returns retained=1 if not purged. + */ + struct { +#define DRM_XE_VMA_PURGEABLE_STATE_WILLNEED 0 +#define DRM_XE_VMA_PURGEABLE_STATE_DONTNEED 1 + /** @purge_state_val.val: value for DRM_XE_VMA_ATTR_PURGEABLE_STATE */ + __u32 val; + + /* @purge_state_val.pad */ + __u32 pad; + /** + * @purge_state_val.retained: Pointer to output field for backing + * store status. + * + * Userspace must initialize this u32 field to 0 before the + * ioctl. Kernel writes to it after the operation: + * - 1 if backing store exists (not purged) + * - 0 if backing store was purged + * + * If userspace fails to initialize to 0, ioctl returns -EINVAL. + * This ensures a safe default (0 = assume purged) if kernel + * cannot write the result. + * + * Similar to i915's drm_i915_gem_madvise.retained field. + */ + __u64 retained; + } purge_state_val; }; /** @reserved: Reserved */ -- 2.43.0