From nobody Sat Sep 26 13:47:20 2026 Received: from mx1.mail-out.lima-city.de (mx1.mail-out.lima-city.de [91.216.248.203]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44A834078E6; Mon, 31 Aug 2026 23:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.216.248.203 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788219662; cv=none; b=LUtQWv8Yk6jy0mXIAqb2XD+iL6Ppal5/e9/iN4K9RBQ9ecseedOv8jsktuW5/gNgp+0c87Otw2upH8FW+FJ2Zwbyu9IVGmSxJ4ea2vUuGH7Q0wqF4u/kmZcTbdkHCnZVJz5kzINPEG5SddnHdILEl+vGO9HGivu+wnxDoCV4i34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788219662; c=relaxed/simple; bh=Pd+xuj/awkQjzclpiwBAlCOaUDbx6XwHn6PW/HGWlGA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MSuuEp8YgjMAkm1VpmEs1odzpjmyMdnwTq3i+gE7zAREh7tB8YgzytFsOkvUv2QqNUW9opS1tMpXS8PAN4hAWGpNWRFrzIfSfVXPnIa4XxOBE04NsrMiIpXLGRXahvj2sjCjnZ8QPN380oem0mlttEZoApx2jCFxKKGfd00v4Us= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=matt3o12.de; spf=pass smtp.mailfrom=matt3o12.de; dkim=pass (2048-bit key) header.d=matt3o12.de header.i=@matt3o12.de header.b=NpCoRxf9; arc=none smtp.client-ip=91.216.248.203 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=matt3o12.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=matt3o12.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=matt3o12.de header.i=@matt3o12.de header.b="NpCoRxf9" From: Matteo Kloiber DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=matt3o12.de; s=securedbylima-20230709; t=1788219153; bh=Pd+xuj/awkQjzclpiwBAlCOaUDbx6XwHn6PW/HGWlGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NpCoRxf92FZv9ezg56i3s4eaV+rg3wSalMNrQ1ifw0PSoniBKhdKXfDqF7zK0a1WF hVqXw0Lfgz426mJuqN3i7DpJ7YtWVvFX/WtiMPuNOiLQfclMPFHFd3OBPUqkWWyC9Z eiX880QoRoI8IeYSOlfSH8ubn8oOLzhHRGIGPYPq0mpT9rex1hriMIP7fu17UzmBUB a6yspNk+lj0DuCdkzcA8MI0rSHOhE2xRlNvHhXSD+bsTWFRzHHf2X3G+iHkclS8Lb0 fUcJbckd8IDf2Dz32Vm/oQHBqFhiUIbocQgWvi5/JXvAu+Lg4AiQrzcyfSB+a3Y6b+ 0U9JupAyf3PGg== To: dakr@kernel.org, acourbot@nvidia.com Cc: aliceryhl@google.com, ojeda@kernel.org, airlied@gmail.com, simona@ffwll.ch, abdiel.janulgue@gmail.com, daniel.almeida@collabora.com, robin.murphy@arm.com, a.hindborg@kernel.org, nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Matteo Kloiber Subject: [PATCH 1/2] gpu: nova-core: declare unlimited DMA max segment size Date: Tue, 1 Sep 2026 01:32:14 +0200 Message-ID: <20260831233215.287881-2-kernel@matt3o12.de> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260831233215.287881-1-kernel@matt3o12.de> References: <20260831233215.287881-1-kernel@matt3o12.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The PCI default max_seg_size is 64 KiB. nova-core never raises it, so mapping the GSP firmware image (~60 MiB) as a scatter-gather table triggers a DMA-API debug warning when contiguous pages coalesce into segments that exceed the default: DMA-API: nova-core 0000:00:03.0: mapping sg segment longer than device claims to support [len=3D62914560] [max=3D65536] CONFIG_DMA_API_DEBUG=3Dy is required to see this warning. Signed-off-by: Matteo Kloiber Assisted-by: Claude:claude-opus-4-8 --- drivers/gpu/nova-core/gpu.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs index fd1414004dd0..233ef2dc9688 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -343,6 +343,13 @@ pub(crate) fn new<'a>( // still constructing it, so no concurrent DMA allocations= can exist. unsafe { pdev.dma_set_mask_and_coherent(dma_mask)? }; =20 + // Nova re-decomposes SG segments into 4 KiB page-table en= tries, so it + // has no upper bound on segment length; declare that to t= he DMA layer. + // + // SAFETY: same invariant as above -- still constructing, = no concurrent + // DMA mapping can exist. + unsafe { pdev.dma_set_max_seg_size(u32::MAX) }; + hal.wait_gfw_boot_completion(bar) .inspect_err(|_| dev_err!(dev, "GFW boot did not compl= ete\n"))?; }, --=20 2.51.2 From nobody Sat Sep 26 13:47:20 2026 Received: from mx1.mail-out.lima-city.de (mx1.mail-out.lima-city.de [91.216.248.203]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4490F37C92C; Mon, 31 Aug 2026 23:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.216.248.203 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788219662; cv=none; b=hg1klfpQkOW1rxuE876U7l2vZh+SBM9vj3+DXyk9hsv1ovuJgGC9bLpVSjYNj2tw2XJS7Rt0+GgBPENKGX1DmxQ5dEh3IHR2xxYlbG8QWeJFi8qo0UO4wU1Am9d2lKwAL8ABMOvsLkgaiQSf4+StRytHzdVnS8ZBFyLSeFOtMJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788219662; c=relaxed/simple; bh=Qiyg9lQAssUbltNwpPhMVEdLPGj+LqwyBdE919aevSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eFLGxhlJ74zUUq0092OF7jQk3Fr/DLf++xll9CzFEbh96uXHd+mLZ2UaNQm+BhBhQH1PW57aN+efkGW9JOK0ADuoe1rgGAf4vUFjyELjSFOGTRMPtZhC8Xp8cyWFedvOu0PT79iRgRE9L8s5V6ZCy/NSozgp0kBwkHj5TEVBN6c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=matt3o12.de; spf=pass smtp.mailfrom=matt3o12.de; dkim=pass (2048-bit key) header.d=matt3o12.de header.i=@matt3o12.de header.b=Urxzjh5S; arc=none smtp.client-ip=91.216.248.203 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=matt3o12.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=matt3o12.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=matt3o12.de header.i=@matt3o12.de header.b="Urxzjh5S" From: Matteo Kloiber DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=matt3o12.de; s=securedbylima-20230709; t=1788219154; bh=Qiyg9lQAssUbltNwpPhMVEdLPGj+LqwyBdE919aevSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Urxzjh5SRVPaNqUi9YwPSwI9tHjdEp1quxvomavJF8PyRl7PzBtk3ixmhP/MsBiap DnEYcUf3rmsELBXLQT9MxW0uRlYdlDdSbra31Xfr/bbWgxMEfqMED2/IEjjTdMKALA AWgU+G8tIc60SJvz4hlXmeeTkICGPBwB8cIfQgB+66r+UEgMCkt+xI/Uq9R4wcGO+t Fl5DnV6eqrBWtScw9ylXnvCDwb/xghQusRIOQYnggFSxSC45IIUjrhYvqM/2DVP4YX gpX5L1UN07WyQcc1KkEJIPRgpQWR56NgdbnZhlS96LS6DxJ9Uw2zb9Ueizcs6S8vCa UT6M73TaaRFZw== To: dakr@kernel.org, acourbot@nvidia.com Cc: aliceryhl@google.com, ojeda@kernel.org, airlied@gmail.com, simona@ffwll.ch, abdiel.janulgue@gmail.com, daniel.almeida@collabora.com, robin.murphy@arm.com, a.hindborg@kernel.org, nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Matteo Kloiber Subject: [PATCH 2/2] rust: scatterlist: honor the device's maximum segment size Date: Tue, 1 Sep 2026 01:32:15 +0200 Message-ID: <20260831233215.287881-3-kernel@matt3o12.de> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260831233215.287881-1-kernel@matt3o12.de> References: <20260831233215.287881-1-kernel@matt3o12.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" SGTable::new() caps segment length at dma_max_mapping_size() only, which limits the DMA mapping path (e.g. swiotlb), not the device itself. The per-device limit from dma_set_max_seg_size() is ignored, so contiguous page segments can be longer than the declared max segment size, potentially causing problems for future drivers that use this abstraction. nova-core declares an unlimited segment size, so this does not change its behavior. Fixes: 05aa6fb1c21d ("rust: scatterlist: Add abstraction for sg_table") Signed-off-by: Matteo Kloiber Reviewed-by: Alexandre Courbot --- rust/helpers/dma.c | 5 +++++ rust/kernel/scatterlist.rs | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rust/helpers/dma.c b/rust/helpers/dma.c index 9fbeb507b08c..ff8f24dae9df 100644 --- a/rust/helpers/dma.c +++ b/rust/helpers/dma.c @@ -49,3 +49,8 @@ __rust_helper void rust_helper_dma_set_max_seg_size(struc= t device *dev, { dma_set_max_seg_size(dev, size); } + +__rust_helper unsigned int rust_helper_dma_get_max_seg_size(struct device = *dev) +{ + return dma_get_max_seg_size(dev); +} diff --git a/rust/kernel/scatterlist.rs b/rust/kernel/scatterlist.rs index b83c468b5c63..d677dcbe7aac 100644 --- a/rust/kernel/scatterlist.rs +++ b/rust/kernel/scatterlist.rs @@ -350,15 +350,23 @@ fn new( page_vec.push(page.as_ptr(), flags)?; } =20 + // Cap segments at both the DMA mapping-path limit and the device'= s declared + // max segment size. + // // `dma_max_mapping_size` returns `size_t`, but `sg_alloc_table_fr= om_pages_segment()` takes // an `unsigned int`. // // SAFETY: `dev.as_raw()` is a valid pointer to a `struct device`. - let max_segment =3D match unsafe { bindings::dma_max_mapping_size(= dev.as_raw()) } { + let max_mapping =3D match unsafe { bindings::dma_max_mapping_size(= dev.as_raw()) } { 0 =3D> u32::MAX, - max_segment =3D> u32::try_from(max_segment).unwrap_or(u32::MAX= ), + max_mapping =3D> u32::try_from(max_mapping).unwrap_or(u32::MAX= ), }; =20 + // SAFETY: `dev.as_raw()` is a valid pointer to a `struct device`. + let max_seg_size =3D unsafe { bindings::dma_get_max_seg_size(dev.a= s_raw()) }; + + let max_segment =3D max_mapping.min(max_seg_size); + Ok(try_pin_init!(&this in Self { // SAFETY: // - `page_vec` is a `KVec` of valid `struct page *` obtained = from `pages`. --=20 2.51.2