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 5F9AE606A32F for ; Tue, 1 Dec 2026 19:30:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=O1kN9P5i Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28BB010FC5D; Tue, 1 Dec 2026 19:30:06 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4056D10FC63; Tue, 1 Dec 2026 19:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796153400; x=1827689400; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=bk350zJo2JoGZiHrGq21mNal9AX6RWth5nDhsC+Cl1M=; b=O1kN9P5ieIOQ/osVPx7wO9rz/TqmwMpmvmeHes6gdU+kP5jsbD+W1ggJ hjosp3LBfJXwjNQhtLwELc6HP6Qz6dreYQvDp9Twei9dUQO7abh2eoCAY PgVRIPyNaotE2DrFyqR28OteyPoFLM2A1ezX2n4W/WjfrNPKXbRmpSTdH aBIE/ysfiBW0iNOBluXtwfSlg0uNEZwMq0Vcdm20xEkSCa0FKd9MEY7jf zw4ToUI9fZkyww27s5jAcCNHyTFVcBRWFBcFcRFFCrwKnHfh+Ky+bLBnK 7mTWEL+WAFgLxYRPoL6flojslr1WQeCwD6bXg6AuDA4hs/TO5IXpXapOU Q==; X-CSE-ConnectionGUID: vDyvz/pyS0+3DL9OweE2DA== X-CSE-MsgGUID: v6c8iZo2TzqFcLdT4U60gA== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5066578" X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="5066578" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 11:29:59 -0800 X-CSE-ConnectionGUID: m+zvo638Q2SsfeYoHY9ARw== X-CSE-MsgGUID: Me5aQhKnT7mL3kEo76loqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,245,1787036400"; d="scan'208";a="13614358" Received: from orsmsx901.amr.corp.intel.com ([10.22.229.23]) by fmviesa006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 11:29:59 -0800 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 11:29:59 -0800 Received: from ORSEDG902.ED.cps.intel.com (10.7.248.12) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Tue, 1 Dec 2026 11:29:59 -0800 Received: from CH4PR04CU002.outbound.protection.outlook.com (40.107.201.53) by edgegateway.intel.com (134.134.137.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 11:29:58 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CTRqYBH+LZTAJT+RK7z8rbQNyjnY1O9BsR7+PsTwQHcqV0nZ8GymYln4lLe7JA7fO/On9zN1SvV91wDa2tBzXj84MsT6Pp1/gA+3/lg5fzDfLMtS4a2bCE4k1j6SE7wTMmINQRQqwLmfKO8Eyr+IBS2dEO5sL2wgpFbZbqctnWb7rPxi0wSJFTV0yX+qInSApBOEMhDFm8bIpLQ5C9mQ4YH1cZ3TXcIFi66EUmK1Mn+UvcD5t7hlFdwYu86HyjoYFJykhs8x8JmtP8g2U/KFq4lBVBtfp1jHXwsEWQW9ZISaspzUfZvCgw0Q606UV9L/l/ESQHi2dgPeU3VV9t/Yig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b+snFRi/2JvxRDO/qFcANArPMyBXeK/dDeGQi66Zaj4=; b=tSxlj9cqpmxr4oyp+X0FR14irR6Ew5RgZLPeMTByUFFrmiPLeHWeFaWBFPf7bT1yB8sEAJ+DJQnTQVnGzzgTO7KWZrmTyk+2qz6diSPydH5ZLpW5tIuuaEFaB+UbAVd6M8WB4iZq849hCZSNdWFQvftCJQwVstM1JooBxbMQm+HcGZTG62U5Ql6YWmjVC3r2B9fHC8yzSHKNuOCvJgk/pLC1TzNjfUed1tEr3VFmakEzqQzNA4KD68T6RkwCcEmNrdnO1UIKvlTax4Y96HgW0MZ1HCWrsEbYPZhyYSXYsnGsaQvHltvx4ishrk7xNLIGYYtF/SpNYqKeo6c5GxHFiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) by IA1PR11MB8176.namprd11.prod.outlook.com (2603:10b6:208:452::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Tue, 1 Dec 2026 19:29:49 +0000 Received: from CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd]) by CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd%4]) with mapi id 15.21.0688.009; Tue, 1 Dec 2026 19:29:49 +0000 Date: Tue, 1 Dec 2026 11:29:46 -0800 From: Matthew Brost To: Niranjana Vishwanathapura CC: , , Carlos Santa , Ryan Neph , Christian Koenig , Huang Rui , Matthew Auld , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , , Thomas =?iso-8859-1?Q?Hellstr=F6m?= Subject: Re: [PATCH v3 27/33] drm/xe: Add IOVA-based xe_res_cursor variant Message-ID: References: <20260711025619.2540575-1-matthew.brost@intel.com> <20260711025619.2540575-28-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: BY1P220CA0020.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:5c3::7) To CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR11MB4787:EE_|IA1PR11MB8176:EE_ X-MS-Office365-Filtering-Correlation-Id: ca48ecc8-9a61-4947-15b0-08df4fe176f2 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|1800799024|366016|7416014|376014|11063799006|4143699003|6133799003|261009223027099003|18002099003|22082099003|10067099003|56012099006|261028144727099003|261026121527099003|261022105027099003|261026140227099003|261022075727099003|261021135927099003|261021121427099003|261102123227099003|261021123027099003; X-Microsoft-Antispam-Message-Info: kumtnpJjoF8YPTt16lpdjT225xuXeaaLYNjbN/hB0yaI25/sPZmUbUAGKjbK5jvpVWX8i58cB2+Zjma+qwd26hkk5Q2ut67ehrjoBcKIBb/tv5BtI/uBg/DZuVzuZEGlTHyby+IuG4p0tCqbXOXv0jgBMUVsa6Ukgl/Yx4VlIA2QzKil1jK5+6mrJDM1zrpTZHDh1kMS2wKyBNtpHxB/VDVD1ciwfTcr4faD1mdETKmm7VuIU5bxlV5umL60YUA8i8ALrdU8mkS13aMiXSsMa4D0+bKur+54V2FvOlttILdArxR6jmSKWCo1gq20RMo3HQVfky9OowOlk8DKKZgj2rUMHkwrmELBbnRYVhVIqjG+GgcKTuhOeNLNsoX28Gxa1/+UzVAtrFlHmrsQqPB6F0UTrXGZsZwy47nxjTyGqP1oNN58P28/xozRmcwSszCcSpLZYSiKe7dLrQzjuIz782Ahn8psdY9N93xauTkuqWgwXPHcdSZgSKy9UP/sY3PqwpLwFJe1E5xfj9ZXdBvtqQ5KGXgJc3eKHGdelCvqoNB0vvOY+3pAoygyCL5iq6nb26UEpH7aGVLESw9nQ2H8+WGNZoOSmVgExi+tr2MPs7xD8lSl+J052VIC7MbeQFEGZEvDea5DbvNN0QEYZSipjR8s8s0WCPx0rjeIHHofFcM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB4787.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(23010399003)(1800799024)(366016)(7416014)(376014)(11063799006)(4143699003)(6133799003)(261009223027099003)(18002099003)(22082099003)(10067099003)(56012099006)(261028144727099003)(261026121527099003)(261022105027099003)(261026140227099003)(261022075727099003)(261021135927099003)(261021121427099003)(261102123227099003)(261021123027099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?nH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bSGR3X5P+VGg4kLYmuNHQpUUSf5WFsoyiAdBZbtAfe?= =?iso-8859-1?Q?JdHrfqwJEF7neWUv3OLe0n42S7F+BmI=3D?= X-Exchange-RoutingPolicyChecked: huOx/QW585ZcboL2kIXzRHu8QjobDaHfS9UU/OINldrseq/pNyLk6jnjSm7Qgs5R7ggBeYoA6dmFPzAVIsOHlL0vW2DOxcPz6UJFnhXvILgVzRaLAfZvHgSyzh9zVa8wM6mmuk/d98Q5t6/TssL+6gkYwVcPB+qR4/6m2AZoI+BpivxkjbzFKlg0QbBM8eM4kw4prM3S2LdJuicT3Ajr8fehD+d+ihQhyRHVYxwW8O/ZBgz7ur/pl3KkH8qSe3NuLQ7lNWXJXdb9bzB0S6A0H84xy+3aMSOb1dXYsR/wxiIq8gY7Is6JxVc+Sps0OjQAt1bmS5Mdwze/0ClxRi8rSg== X-MS-Exchange-CrossTenant-Network-Message-Id: ca48ecc8-9a61-4947-15b0-08df4fe176f2 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4787.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 19:29:49.3318 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dCkQNxle+GiKU+qb0bDxZ+IzodLYi4S4RQ3us9bHo5aCY+J/A1BwGCMsFc81JaYOv/ic6Ax3pyWtYlYFbSb5xQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB8176 X-OriginatorOrg: intel.com 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: , Sender: "Intel-xe" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 On Thu, Nov 12, 2026 at 10:14:23PM -0800, Niranjana Vishwanathapura wrote: > On Fri, Jul 10, 2026 at 07:56:13PM -0700, Matthew Brost wrote: > > Introduce xe_res_first_iova() to walk a buffer that was DMA mapped using > > the IOVA-based DMA API (dma_iova_try_alloc() and friends). Such a mapping > > is described by a struct dma_iova_state and is a single contiguous IOVA > > range, so the cursor walks it as one segment. > > > > Add an is_iova flag to struct xe_res_cursor to distinguish this case. > > When set, xe_res_dma() returns the IOVA backing the current position > > (state->addr + cursor offset), xe_res_next() advances within the single > > contiguous segment, and xe_res_is_vram() returns false since IOVA > > mappings never point to same-device VRAM. > > > > The flag is explicitly cleared in the existing xe_res_first(), > > xe_res_first_sg() and xe_res_first_dma() initializers so stale stack > > values cannot leak into the new path. > > > > Cc: Carlos Santa > > Cc: Ryan Neph > > Cc: Christian Koenig > > Cc: Huang Rui > > Cc: Matthew Auld > > Cc: Maarten Lankhorst > > Cc: Maxime Ripard > > Cc: Thomas Zimmermann > > Cc: David Airlie > > Cc: Simona Vetter > > Cc: dri-devel@lists.freedesktop.org > > Cc: linux-kernel@vger.kernel.org > > Cc: Thomas Hellström > > Assisted-by: GitHub_Copilot:claude-opus-4.8 > > Signed-off-by: Matthew Brost > > --- > > drivers/gpu/drm/xe/xe_res_cursor.h | 56 +++++++++++++++++++++++++++++- > > 1 file changed, 55 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/xe/xe_res_cursor.h b/drivers/gpu/drm/xe/xe_res_cursor.h > > index 0522caafd89d..f0f1d699e16e 100644 > > --- a/drivers/gpu/drm/xe/xe_res_cursor.h > > +++ b/drivers/gpu/drm/xe/xe_res_cursor.h > > @@ -24,6 +24,7 @@ > > #ifndef _XE_RES_CURSOR_H_ > > #define _XE_RES_CURSOR_H_ > > > > +#include > > #include > > > > #include > > @@ -67,6 +68,12 @@ struct xe_res_cursor { > > u64 dma_start; > > /** @dma_seg_size: Size of the current DMA segment. */ > > u64 dma_seg_size; > > + /** > > + * @is_iova: Whether the cursor walks a single contiguous IOVA > > + * mapping described by a struct dma_iova_state. When true, the > > + * DMA address is @dma_start + @start and never points to VRAM. > > + */ > > + bool is_iova; > > }; > > > > static struct gpu_buddy *xe_res_get_buddy(struct ttm_resource *res) > > @@ -93,6 +100,7 @@ static inline void xe_res_first(struct ttm_resource *res, > > { > > cur->sgl = NULL; > > cur->dma_addr = NULL; > > + cur->is_iova = false; > > if (!res) > > goto fallback; > > > > @@ -224,6 +232,7 @@ static inline void xe_res_first_sg(const struct sg_table *sg, > > cur->dma_addr = NULL; > > cur->sgl = sg->sgl; > > cur->mem_type = XE_PL_TT; > > + cur->is_iova = false; > > __xe_res_sg_next(cur); > > } > > > > @@ -255,6 +264,41 @@ static inline void xe_res_first_dma(const struct drm_pagemap_addr *dma_addr, > > __xe_res_dma_next(cur); > > cur->sgl = NULL; > > cur->mem_type = XE_PL_TT; > > + cur->is_iova = false; > > +} > > Assisted-by: LLM > > NIT..Instead of defining and clearing is_iova flag, would it be better > to define enum defitions for different cursor types? > In general would should cleanup all of the cursor code, but let's do that in a follow up - also we have another cursor type being added for some dma-buf changes. It would be nice to have single *first* call which correctly sets up the cursor, a well defined way to fish out the address, and single next call. When we do this refactor we can look at adding a enum. > > + > > +/** > > + * xe_res_first_iova() - initialize a xe_res_cursor with a dma_iova_state > > + * > > + * @state: struct dma_iova_state describing a single contiguous IOVA mapping > > + * @start: Start of the range > > + * @size: Size of the range > > + * @cur: cursor object to initialize > > + * > > + * Start walking over the range of an allocation that was DMA mapped using the > > + * IOVA-based DMA API (see dma_iova_try_alloc()). Such a mapping is a single > > + * contiguous IOVA range, so the cursor walks it as one segment. Subsequent > > + * calls to xe_res_next() advance within that range and xe_res_dma() returns > > + * the IOVA backing the current position. xe_res_is_vram() always returns false > > + * for such a cursor. > > + */ > > +static inline void xe_res_first_iova(struct dma_iova_state *state, > > + u64 start, u64 size, > > + struct xe_res_cursor *cur) > > +{ > > + XE_WARN_ON(!state); > > + XE_WARN_ON(start + size > dma_iova_size(state)); > > + > > + cur->node = NULL; > > + cur->start = start; > > + cur->remaining = size; > > + cur->size = size; > > + cur->dma_addr = NULL; > > + cur->sgl = NULL; > > + cur->dma_start = state->addr; > > + cur->dma_seg_size = dma_iova_size(state); > > NIT...looks like cur->dma_seg_size is never used, but should be fine. > Yes, let me drop that. > > + cur->mem_type = XE_PL_TT; > > + cur->is_iova = true; > > } > > > > /** > > @@ -283,6 +327,13 @@ static inline void xe_res_next(struct xe_res_cursor *cur, u64 size) > > return; > > } > > > > + if (cur->is_iova) { > > + /* Single contiguous IOVA segment. */ > > + cur->start += size; > > + cur->size = cur->remaining; > > + return; > > + } > > This code never gets executed. Probably remove it and add an assert > if we reach here with cur->is_iova set (or add a comment)? > Yes, let's delete and assert here. Matt > Niranjana > > > + > > if (cur->dma_addr) { > > cur->start += size; > > __xe_res_dma_next(cur); > > @@ -334,7 +385,7 @@ static inline void xe_res_next(struct xe_res_cursor *cur, u64 size) > > */ > > static inline u64 xe_res_dma(const struct xe_res_cursor *cur) > > { > > - if (cur->dma_addr) > > + if (cur->is_iova || cur->dma_addr) > > return cur->dma_start + cur->start; > > else if (cur->sgl) > > return sg_dma_address(cur->sgl) + cur->start; > > @@ -351,6 +402,9 @@ static inline u64 xe_res_dma(const struct xe_res_cursor *cur) > > */ > > static inline bool xe_res_is_vram(const struct xe_res_cursor *cur) > > { > > + if (cur->is_iova) > > + return false; > > + > > if (cur->dma_addr) > > return cur->dma_addr->proto == XE_INTERCONNECT_VRAM; > > > > -- > > 2.34.1 > >