From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794631413; b=VOQ/nlmKvD/6KBnN+4qAB3l7wrEUij0/+yykiBzySWw/Stw5JCLa+H1NAjOyOGCVUg8C uvUA1WEmucGu8bo9LPnI6N04tm7Ww6iFNuTsa8+SLbKOAClqBRq1C1eBL7/DFm09rGt53 KLqWO3Yervmagcm7myk4nrIvXf4QErqs6oj4BB27tFWchR66dK2LxMFCTYLQxiMjb3kF7 jf6PMuITF/KibRPfz1JtNxVBI/qCC6AiFE3OFljSIk+oomuS39ZdYFkM6upWyqePnVUMX 9QCB5znCSBcgAJf/ADYAawyA2IHxGyhOX9TwQnSJ5FEoOlf+E1S40PmaEJpkcL6ShPA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794631413; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=GJEL2qZCX/w3GeXJL8sn0/654lUPemWjqgGuxwwRjck=; b=b1I95en/r5cdEVAYovGY8m+gjlljg3UYTNL5/pNYh4YTj7c1YVFSywBMbKKpaI26BTrx DFFsIu3lk1DfXSrKjbdTbdZBHTlyZ4NVND62VXcXEIUGaAON3tegms6CVd5Q3T1qfUhVA ysJp9gXZN+dxUvHdBaPRI8PSL2r2SZuTqVmojoX8N2YklPBoWU/munsoxqIkTlXwmXh4H T60u5XWI7RIH6LNDzsZbA8mvxul3cZLYnaRvdT4mrBj+1yr61zmnJZFPlS5g+CVAYA9rF ATzFXx9l9UDBt9HAjHjWzzmByoyQyKDm9GAV0FOP0xPKeQk8c7K3WJ2S1zvb75gmbrw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="Fui/6Fsm"; arc=none smtp.remote-ip=209.85.216.48 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA782606A32D for ; Sat, 14 Nov 2026 04:43:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CA782606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Fui/6Fsm Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-3b0b3754f57so1296737a91.0 for ; Fri, 13 Nov 2026 20:43:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794631412; x=1795236212; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GJEL2qZCX/w3GeXJL8sn0/654lUPemWjqgGuxwwRjck=; b=Fui/6Fsmz46smK4HQ0XLve6RRiGsNnHNNc0Vw3wk1sbbAm6n6QNjddrUjg/EFqyD0s Gti4CGA63a842IoqEUKdtidorDsZdzS2yw6ehMhFA++oadpdIJHxUIK3+xyiACl9UsST zZoTngu2zxrlktgIrZtn89vRtQ5WFKacQcRaeQE5CiZqZ6tfvIFLflsYFnKGlMCuwUiG cheMbaNS5wVWfzX3O5wqdgzgMKTjwaDdJ2u18Vl5lmhjx7rCrvXuBpPs0wHx+dCtGHR3 vagK50Vm7kvlYIhfLVygC+oVulxNVBXLLdz+n90BQTsRayffD8g4IPTZZWiQzJ55ufC1 8vUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794631412; x=1795236212; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=GJEL2qZCX/w3GeXJL8sn0/654lUPemWjqgGuxwwRjck=; b=kjwcog2Be11VDumiDGuPUtlWUE52O10WlYLF3/8P0PMTtd3PqYDxa8RF54zrrLEQvp eLpLpFKInP3GzZWZNRZwn0KKMMlBADzG6qbcmgzydUbGl7mH4w4wa1urYlh1RPwOi/jN nokDLcT5DYAq9Bssco+HUpOMH+ku0XEuDJ+W1VGBhsEZ1kdd/0C+GeJEMvSUT/ctK5py n7/DHBCg4A1faSDFqR6qIDUW6/Hg/VekFQEKzG7CxOtokzUpi3hVrcNEfXSqpH72hWAv uV+H8qPvOrEvWRTmGQTtqFAHfJvQj9ck7fRXOA54mGaDv1fyQjEnzNq11q1sYB+u1/CC Bgeg== X-Forwarded-Encrypted: i=1; AL+hErGP/WYTqjTx2YnPrGOCfwreSTTTWEfn8zrdoA/QMh/hoBRoLz8jOEqDrsErowJ/3DAFvWthCDQF4BTRx6g=@vger.kernel.org X-Gm-Message-State: APuU4Z9IyQ+ld1b54fbgeQmkAgAqPRJMI/28b0EuVsN1bnyj3Tgp6G+V qfoaQHhG+LGGBd/pMrvDWrJzqWgQ1gGl8z+pcAlWU0E6/FGqSVuXE7Zo X-Gm-Gg: AYBFou3f7kStSwyQZ6q1oahKiOT/rRht8JuLibPLf974GoRapU22jaBZMR6q1no005g Ye0zhSg8RIQKR9AY/4hutfCyb+cPxNAr17pwckm+r/EFAIeDLOd8GGtsDos7iMbQhKV5YRwX6Nf npPn95FXVGWLGoYFeegOLhVFVLpOvTH7+RoDAKaddfpIN+4FGwi7Z5Zcbgzn4kyfsqH8QvLk7wC nMxirsvTX3DWy0yTs7Owh6La1HTTm+Wb4/newKwzJ8cbZHGyhxGlAOdKyBvzvH8kr/6Lc5GaiZn AWoGhLygayNdM5nSNNMkgHee8KSCOnC52GrcC4VxbO/kCbDDqQXJ3GZ+xMZk1+setFL/EvOn3x6 p0KlVHuO2TKcyPvTZZRVC8clQU1QIPPgfhexAnwBg2uNfQudezzIIkdFRziKhxOl94WpwTgFG8h pFzwa24RR58yFkpdVH+gyBgzjKIE7tW2GEUAb2aU6yXt/NY3xJiDbWQ8Z5auF8D2oewMQ5PRnEg kpeZofhYoaWGmEJSBjUMdKjC1msgFzBULhR8+egvv+qHvj3VTLPEAd+8Wu9OjO9Anm/rEUd4lEz i3dBaQ0Xujw/ZzG8rSG6rEymmznRd5BhKdlg X-Received: by 2002:a17:90b:3146:b0:3ab:f38:2b43 with SMTP id 98e67ed59e1d1-3b1b0a4513emr4243189a91.34.1794631411951; Fri, 13 Nov 2026 20:43:31 -0800 (PST) Received: from localhost ([176.210.133.73]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b1b3eaf732sm3230685a91.3.2026.11.13.20.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2026 20:43:31 -0800 (PST) From: Vladislav Zaharov To: dakr@kernel.org, jhubbard@nvidia.com Cc: acourbot@nvidia.com, aliceryhl@google.com, ttabi@nvidia.com, gary@garyguo.net, nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, vladazaharova2018@gmail.com Subject: [PATCH v8 2/4] gpu: nova-core: gsp: move the log buffers into their own file Date: Sat, 14 Nov 2026 11:43:02 +0700 Message-ID: <20261114044304.245684-3-vladazaharova2018@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261114044304.245684-1-vladazaharova2018@gmail.com> References: <20261114044304.245684-1-vladazaharova2018@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Move the GSP-RM log buffer code from gsp.rs into gsp/logbuffer.rs, ahead of extending it. No functional change. Signed-off-by: Vladislav Zaharov Reviewed-by: Alexandre Courbot --- drivers/gpu/nova-core/gsp.rs | 59 +++-------------------- drivers/gpu/nova-core/gsp/logbuffer.rs | 65 ++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 52 deletions(-) create mode 100644 drivers/gpu/nova-core/gsp/logbuffer.rs diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs index 79ee74a0a16f..43df95406d35 100644 --- a/drivers/gpu/nova-core/gsp.rs +++ b/drivers/gpu/nova-core/gsp.rs @@ -12,11 +12,7 @@ CoherentView, DmaAddress, // }, - io::{ - io_project, - io_write, - Io, // - }, + io::io_write, pci, prelude::*, // }; @@ -24,10 +20,16 @@ pub(crate) mod cmdq; pub(crate) mod commands; mod fw; +mod logbuffer; mod nvkv; mod regs; mod sequencer; +use logbuffer::{ + LogBuffer, + LogBuffers, // +}; + pub(crate) use fw::{ GspFmcBootParams, GspFwWprMeta, @@ -78,10 +80,6 @@ pub(crate) fn dev(&self) -> &'gpu device::Device { } } -/// Number of GSP pages to use in a RM log buffer. -const RM_LOG_BUFFER_NUM_PAGES: usize = 0x10; -const LOG_BUFFER_SIZE: usize = RM_LOG_BUFFER_NUM_PAGES * GSP_PAGE_SIZE; - /// Array of page table entries, as understood by the GSP bootloader. #[repr(C)] #[derive(FromBytes, IntoBytes)] @@ -102,49 +100,6 @@ fn init(view: CoherentView<'_, Self>, start: DmaAddress) -> Result<()> { } } -/// The logging buffers are byte queues that contain encoded printf-like -/// messages from GSP-RM. They need to be decoded by a special application -/// that can parse the buffers. -/// -/// The 'loginit' buffer contains logs from early GSP-RM init and -/// exception dumps. The 'logrm' buffer contains the subsequent logs. Both are -/// written to directly by GSP-RM and can be any multiple of GSP_PAGE_SIZE. -/// -/// The physical address map for the log buffer is stored in the buffer -/// itself, starting with offset 1. Offset 0 contains the "put" pointer (pp). -/// Initially, pp is equal to 0. If the buffer has valid logging data in it, -/// then pp points to index into the buffer where the next logging entry will -/// be written. Therefore, the logging data is valid if: -/// 1 <= pp < sizeof(buffer)/sizeof(u64) -struct LogBuffer<'a>(Coherent<'a, [u8; LOG_BUFFER_SIZE]>); - -impl<'a> LogBuffer<'a> { - /// Creates a new `LogBuffer` mapped on `dev`. - fn new(dev: &'a device::Device) -> Result { - let obj = Self(Coherent::zeroed(dev, GFP_KERNEL)?); - - let start_addr = obj.0.dma_address(); - - let pte_view = io_project!( - obj.0, - [build: size_of::()..][build: ..RM_LOG_BUFFER_NUM_PAGES * size_of::()] - ) - .try_cast::>()?; - PteArray::init(pte_view, start_addr)?; - - Ok(obj) - } -} - -struct LogBuffers<'a> { - /// Init log buffer. - loginit: LogBuffer<'a>, - /// Interrupts log buffer. - logintr: LogBuffer<'a>, - /// RM log buffer. - logrm: LogBuffer<'a>, -} - /// GSP runtime data. #[pin_data] pub(crate) struct Gsp<'gsp> { diff --git a/drivers/gpu/nova-core/gsp/logbuffer.rs b/drivers/gpu/nova-core/gsp/logbuffer.rs new file mode 100644 index 000000000000..1fb411ce6d01 --- /dev/null +++ b/drivers/gpu/nova-core/gsp/logbuffer.rs @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 + +//! GSP-RM log buffers. + +use kernel::{ + device, + dma::Coherent, + io::{ + io_project, + Io, // + }, + prelude::*, // +}; + +use crate::gsp::{ + PteArray, + GSP_PAGE_SIZE, // +}; + +/// Number of GSP pages to use in a RM log buffer. +const RM_LOG_BUFFER_NUM_PAGES: usize = 0x10; +const LOG_BUFFER_SIZE: usize = RM_LOG_BUFFER_NUM_PAGES * GSP_PAGE_SIZE; + +/// The logging buffers are byte queues that contain encoded printf-like +/// messages from GSP-RM. They need to be decoded by a special application +/// that can parse the buffers. +/// +/// The 'loginit' buffer contains logs from early GSP-RM init and +/// exception dumps. The 'logrm' buffer contains the subsequent logs. Both are +/// written to directly by GSP-RM and can be any multiple of GSP_PAGE_SIZE. +/// +/// The physical address map for the log buffer is stored in the buffer +/// itself, starting with offset 1. Offset 0 contains the "put" pointer (pp). +/// Initially, pp is equal to 0. If the buffer has valid logging data in it, +/// then pp points to index into the buffer where the next logging entry will +/// be written. Therefore, the logging data is valid if: +/// 1 <= pp < sizeof(buffer)/sizeof(u64) +pub(super) struct LogBuffer<'a>(pub(super) Coherent<'a, [u8; LOG_BUFFER_SIZE]>); + +impl<'a> LogBuffer<'a> { + /// Creates a new `LogBuffer` mapped on `dev`. + pub(super) fn new(dev: &'a device::Device) -> Result { + let obj = Self(Coherent::zeroed(dev, GFP_KERNEL)?); + + let start_addr = obj.0.dma_address(); + + let pte_view = io_project!( + obj.0, + [build: size_of::()..][build: ..RM_LOG_BUFFER_NUM_PAGES * size_of::()] + ) + .try_cast::>()?; + PteArray::init(pte_view, start_addr)?; + + Ok(obj) + } +} + +pub(super) struct LogBuffers<'a> { + /// Init log buffer. + pub(super) loginit: LogBuffer<'a>, + /// Interrupts log buffer. + pub(super) logintr: LogBuffer<'a>, + /// RM log buffer. + pub(super) logrm: LogBuffer<'a>, +} -- 2.56.0