[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aFMgLDfNKWPsSoD1@cassiopeiae>
Date: Wed, 18 Jun 2025 22:23:08 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
Benno Lossin <lossin@...nel.org>,
John Hubbard <jhubbard@...dia.com>, Ben Skeggs <bskeggs@...dia.com>,
Joel Fernandes <joelagnelf@...dia.com>,
Timur Tabi <ttabi@...dia.com>, Alistair Popple <apopple@...dia.com>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
nouveau@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
Lyude Paul <lyude@...hat.com>
Subject: Re: [PATCH v5 23/23] gpu: nova-core: load and run FWSEC-FRTS
On Thu, Jun 12, 2025 at 11:01:51PM +0900, Alexandre Courbot wrote:
> @@ -237,6 +237,67 @@ pub(crate) fn new(
> },
> )?;
>
> + // Check that the WPR2 region does not already exists - if it does, the GPU needs to be
> + // reset.
> + if regs::NV_PFB_PRI_MMU_WPR2_ADDR_HI::read(bar).hi_val() != 0 {
> + dev_err!(
> + pdev.as_ref(),
> + "WPR2 region already exists - GPU needs to be reset to proceed\n"
> + );
> + return Err(EBUSY);
> + }
> +
> + // Reset falcon, load FWSEC-FRTS, and run it.
> + gsp_falcon
> + .reset(bar)
> + .inspect_err(|e| dev_err!(pdev.as_ref(), "Failed to reset GSP falcon: {:?}\n", e))?;
> + gsp_falcon
> + .dma_load(bar, &fwsec_frts)
> + .inspect_err(|e| dev_err!(pdev.as_ref(), "Failed to load FWSEC-FRTS: {:?}\n", e))?;
> + let (mbox0, _) = gsp_falcon
> + .boot(bar, Some(0), None)
> + .inspect_err(|e| dev_err!(pdev.as_ref(), "Failed to boot FWSEC-FRTS: {:?}\n", e))?;
> + if mbox0 != 0 {
> + dev_err!(pdev.as_ref(), "FWSEC firmware returned error {}\n", mbox0);
> + return Err(EIO);
> + }
> +
> + // SCRATCH_E contains FWSEC-FRTS' error code, if any.
> + let frts_status = regs::NV_PBUS_SW_SCRATCH_0E::read(bar).frts_err_code();
> + if frts_status != 0 {
> + dev_err!(
> + pdev.as_ref(),
> + "FWSEC-FRTS returned with error code {:#x}",
> + frts_status
> + );
> + return Err(EIO);
> + }
> +
> + // Check the WPR2 has been created as we requested.
> + let (wpr2_lo, wpr2_hi) = (
> + (regs::NV_PFB_PRI_MMU_WPR2_ADDR_LO::read(bar).lo_val() as u64) << 12,
> + (regs::NV_PFB_PRI_MMU_WPR2_ADDR_HI::read(bar).hi_val() as u64) << 12,
> + );
> + if wpr2_hi == 0 {
> + dev_err!(
> + pdev.as_ref(),
> + "WPR2 region not created after running FWSEC-FRTS\n"
> + );
> +
> + return Err(EIO);
> + } else if wpr2_lo != fb_layout.frts.start {
> + dev_err!(
> + pdev.as_ref(),
> + "WPR2 region created at unexpected address {:#x}; expected {:#x}\n",
> + wpr2_lo,
> + fb_layout.frts.start,
> + );
> + return Err(EIO);
> + }
> +
> + dev_dbg!(pdev.as_ref(), "WPR2: {:#x}-{:#x}\n", wpr2_lo, wpr2_hi);
> + dev_dbg!(pdev.as_ref(), "GPU instance built\n");
> +
This makes Gpu::new() quite messy, can we move this to a separate function
please?
Powered by blists - more mailing lists