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 8C9D8EB104E for ; Tue, 10 Mar 2026 11:20:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6BBF10E240; Tue, 10 Mar 2026 11:20:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="fkJHucYB"; dkim-atps=neutral Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id E4E7010E240; Tue, 10 Mar 2026 11:20:40 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 3806E600C4; Tue, 10 Mar 2026 11:20:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CB06C2BC86; Tue, 10 Mar 2026 11:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773141639; bh=xGjVBeTYpyjTZwX3gFYF54w9+q8HTHPh6xi2cya8jck=; h=Date:Subject:Cc:To:From:References:In-Reply-To:From; b=fkJHucYBWZLi6X7ajADYfz3hex8bL9zwxxf+Qg3QdznH8ruuShORbyaf9dUBWKX/k 6IMV9Es4zvdNSfxvDlqIMwT7zIdwOLAuxhMhzKIsfgLA6HLecsylVuJDKzGC8cuNkf LgqHol1mk5uZmDxj7FqcxlgCxi3W5AVSAWd7ykXP9sHcykWOuPx5SbDsfELXrF9BHS HmU4OEXbmHGyc37rBbdTcH9za6VVEoNQCk/3piTjjK02V307rPoqT7DWwRSDv7JVAP 0V0VL5KLuTW/tKbUB6bq3SmsOuOZ8oIUH2Ct9ebL0+m/iaoiZam6FXuUeTSZYs0enq 4owbJQt4gDS8Q== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 10 Mar 2026 12:20:33 +0100 Message-Id: Subject: Re: [PATCH v4 4/4] gpu: nova-core: fix stack overflow in GSP memory allocation Cc: "Gary Guo" , "Tim Kovalenko via B4 Relay" , , "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "Miguel Ojeda" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Boqun Feng" , "Nathan Chancellor" , "Nicolas Schier" , "Abdiel Janulgue" , "Daniel Almeida" , "Robin Murphy" , , , , , , To: "Alexandre Courbot" From: "Danilo Krummrich" References: <20260309-drm-rust-next-v4-0-4ef485b19a4c@proton.me> <20260309-drm-rust-next-v4-4-4ef485b19a4c@proton.me> In-Reply-To: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue Mar 10, 2026 at 3:28 AM CET, Alexandre Courbot wrote: > On Tue Mar 10, 2026 at 10:51 AM JST, Gary Guo wrote: >> On Tue Mar 10, 2026 at 1:40 AM GMT, Alexandre Courbot wrote: >>> On Tue Mar 10, 2026 at 1:34 AM JST, Tim Kovalenko via B4 Relay wrote: >>>> diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core= /gsp/cmdq.rs >>>> index 0056bfbf0a44cfbc5a0ca08d069f881b877e1edc..c8327d3098f73f9b880eee= 99038ad10a16e1e32d 100644 >>>> --- a/drivers/gpu/nova-core/gsp/cmdq.rs >>>> +++ b/drivers/gpu/nova-core/gsp/cmdq.rs >>>> @@ -202,7 +202,20 @@ fn new(dev: &device::Device) -> Re= sult { >>>> =20 >>>> let gsp_mem =3D >>>> CoherentAllocation::::alloc_coherent(dev, 1, GFP_= KERNEL | __GFP_ZERO)?; >>>> - dma_write!(gsp_mem, [0]?.ptes, PteArray::new(gsp_mem.dma_hand= le())?); >>>> + >>>> + const NUM_PTES: usize =3D GSP_PAGE_SIZE / size_of::(); >>>> + >>>> + let start =3D gsp_mem.dma_handle(); >>>> + // One by one GSP Page write to the memory to avoid stack ove= rflow when allocating >>>> + // the whole array at once. >>>> + for i in 0..NUM_PTES { >>>> + dma_write!( >>>> + gsp_mem, >>>> + [0]?.ptes.0[i], >>>> + PteArray::::entry(start, i)? >>> >>> Does `::` need to be mentioned here, or is the compiler able >>> to infer it? >> >> The function signature doesn't mention NUM_PTES at all, so no. In fact, = perhaps >> the `entry` shouldn't be an associated method at all (even if is, it pro= bably >> should be of `PteArray::<0>` or something. I think <0> is probably the best choice for this fix for now. > I had that thought as well - this calls for a redesign of the `PteArray` > business - but also didn't want to interfere too much as this fix is > very much (and quickly) needed. We will probably re-write this once we > have access to the new I/O code anyway. Not sure it actually needs a redesign, as I think this just goes away with = I/O projections. That's also why I would add the following TODO comment on entr= y(). // TODO: Replace with `IoView` projections once available. I.e. it is just a workaround for now.