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 E3790CCF9F2 for ; Tue, 28 Oct 2025 12:25:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 98AD310E5D1; Tue, 28 Oct 2025 12:25:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ZLyr8Wz1"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFE9D10E3E8 for ; Tue, 28 Oct 2025 12:25: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=1761654310; x=1793190310; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x6yPlm5t1zWffXb3ozC0JCO6xS+sIUtcTs8NNVb0Xw4=; b=ZLyr8Wz1WUhyQGwhP6h4kpFwEeSi0I52I2YMMhCPUxtloEt09ubYT2Mj tvc2eYuFdLSodvAgJYM+iWUzGjvZaPzZSB+vptFTcWI/LFXS47dXPmcnE KzZAINKyZ6Cib0/CwqXbk1HMUivI1I16IYCC8anhFrMYW4TPdLzJgA+tP oAi7bF9pF7UksS/Ecmh9xRpaLiIodRtiFC4FPh/8xAW59pT9zZ8eRZrRi XUUerLxAQhG6dWrZ6Fzco7WJZgRKqhiuRZnX9IU3BbLCfxIZJ5dJegrKF E59dWyEal/Squex5TVuZcykJ1eojxOdP09t7Wa6Berw3ZbaEZUEMEnn+y g==; X-CSE-ConnectionGUID: aGgF6rAKR/2wmrO5mpPrHA== X-CSE-MsgGUID: +MtJ897DS5Ovp2aoxwS9NA== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="62956622" X-IronPort-AV: E=Sophos;i="6.19,261,1754982000"; d="scan'208";a="62956622" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2025 05:25:04 -0700 X-CSE-ConnectionGUID: Vj3YoNQeTEWgAq1qfMIWlg== X-CSE-MsgGUID: t8z5/K3aRNWIIf+3kjpebQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,261,1754982000"; d="scan'208";a="190524415" Received: from varungup-desk.iind.intel.com ([10.190.238.71]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2025 05:25:02 -0700 From: Arvind Yadav To: intel-xe@lists.freedesktop.org Cc: matthew.brost@intel.com, himal.prasad.ghimiray@intel.com, thomas.hellstrom@linux.intel.com Subject: [RFC PATCH 1/9] drm/xe/uapi: Add UAPI support for purgeable buffer objects Date: Tue, 28 Oct 2025 17:54:07 +0530 Message-ID: <20251028122415.1136721-2-arvind.yadav@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251028122415.1136721-1-arvind.yadav@intel.com> References: <20251028122415.1136721-1-arvind.yadav@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" 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: - WILLNEED: BO will be needed again, re-validate if purged. - DONTNEED: Buffer not currently needed, may be purged if needed. Cc: Matthew Brost Cc: Thomas Hellström Signed-off-by: Himal Prasad Ghimiray Signed-off-by: Arvind Yadav --- include/uapi/drm/xe_drm.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h index 47853659a705..e5345101a92a 100644 --- a/include/uapi/drm/xe_drm.h +++ b/include/uapi/drm/xe_drm.h @@ -2051,6 +2051,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; @@ -2129,6 +2130,30 @@ 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: BO is needed, + * should not be purged by the kernel. + * - DRM_XE_VMA_PURGEABLE_STATE_DONTNEED: BO is not currently needed, + * kernel may purge it to free memory if under pressure. + */ + 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.reserved: Reserved */ + __u32 reserved; + } purge_state_val; }; /** @reserved: Reserved */ -- 2.43.0