mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
Currently Nova code uses `&'a Bar0` a lot. This is `&'a Mmio`, where `Mmio` represents an owned MMIO region; this type only exists as a target for `Deref` so `Bar` and `IoMem` can share code and should be avoided to be named directly. The upcoming I/O projection series would make `Io` trait much simpler to implement, and thus the owned MMIO type would be removed in favour of direct `Io` implementation on `Bar` and `IoMem`. Add lifetime parameter to `Bar0<'a>` and change it to be alias of `&'a pci::Bar<'a, ..>`. This also prepares Nova core so that when I/O projection series land, this could be changed to using a MMIO view type directly which avoids double indirection. Signed-off-by: Gary Guo <gary@garyguo.net> Acked-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Eliot Courtney <ecourtney@nvidia.com> Link: https://patch.msgid.link/20260602170416.2268531-1-gary@kernel.org [ Rebase onto latest drm-rust-next (Blackwell enablement). - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
95 lines
2.7 KiB
Rust
95 lines
2.7 KiB
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
|
|
mod gh100;
|
|
mod tu102;
|
|
|
|
use kernel::prelude::*;
|
|
|
|
use kernel::{
|
|
device,
|
|
dma::Coherent, //
|
|
};
|
|
|
|
use crate::{
|
|
driver::Bar0,
|
|
falcon::{
|
|
gsp::Gsp as GspEngine,
|
|
sec2::Sec2,
|
|
Falcon, //
|
|
},
|
|
fb::FbLayout,
|
|
firmware::gsp::GspFirmware,
|
|
gpu::{
|
|
Architecture,
|
|
Chipset, //
|
|
},
|
|
gsp::{
|
|
boot::BootUnloadGuard,
|
|
Gsp,
|
|
GspFwWprMeta, //
|
|
},
|
|
};
|
|
|
|
/// Trait for types containing the resources and code required to fully reset the GSP.
|
|
///
|
|
/// The GSP unload code might run in a situation where we cannot load firmware dynamically (e.g.
|
|
/// because we are in shutdown and the file system is not accessible anymore). Thus, the firmware
|
|
/// required for unloading is prepared at load time, and stored here until it needs to be run.
|
|
pub(super) trait UnloadBundle: Send {
|
|
/// Performs the steps required to properly reset the GSP after it has been stopped.
|
|
fn run(
|
|
&self,
|
|
dev: &device::Device<device::Bound>,
|
|
bar: Bar0<'_>,
|
|
gsp_falcon: &Falcon<GspEngine>,
|
|
sec2_falcon: &Falcon<Sec2>,
|
|
) -> Result;
|
|
}
|
|
|
|
/// Trait implemented by GSP HALs.
|
|
pub(super) trait GspHal: Send {
|
|
/// Performs the GSP boot process, loading and running the required firmwares as needed.
|
|
///
|
|
/// Upon success, returns a guard that runs the GSP unload sequence if GSP boot does not
|
|
/// complete.
|
|
#[allow(clippy::too_many_arguments)]
|
|
fn boot<'a>(
|
|
&self,
|
|
gsp: &'a Gsp,
|
|
dev: &'a device::Device<device::Bound>,
|
|
bar: Bar0<'a>,
|
|
chipset: Chipset,
|
|
fb_layout: &FbLayout,
|
|
wpr_meta: &Coherent<GspFwWprMeta>,
|
|
gsp_falcon: &'a Falcon<GspEngine>,
|
|
sec2_falcon: &'a Falcon<Sec2>,
|
|
) -> Result<BootUnloadGuard<'a>>;
|
|
|
|
/// Performs HAL-specific post-GSP boot tasks.
|
|
///
|
|
/// This method is called by the GSP boot code after the GSP is confirmed to be running, and
|
|
/// after the initialization commands have been pushed onto its queue.
|
|
fn post_boot(
|
|
&self,
|
|
_gsp: &Gsp,
|
|
_dev: &device::Device<device::Bound>,
|
|
_bar: Bar0<'_>,
|
|
_gsp_fw: &GspFirmware,
|
|
_gsp_falcon: &Falcon<GspEngine>,
|
|
_sec2_falcon: &Falcon<Sec2>,
|
|
) -> Result {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
/// Returns the GSP HAL to be used for `chipset`.
|
|
pub(super) fn gsp_hal(chipset: Chipset) -> &'static dyn GspHal {
|
|
match chipset.arch() {
|
|
Architecture::Turing | Architecture::Ampere | Architecture::Ada => tu102::TU102_HAL,
|
|
Architecture::Hopper | Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => {
|
|
gh100::GH100_HAL
|
|
}
|
|
}
|
|
}
|