1 // SPDX-License-Identifier: GPL-2.0 2 // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 4 mod ga102; 5 mod gh100; 6 mod tu102; 7 8 use kernel::{ 9 dma::Coherent, 10 prelude::*, // 11 }; 12 13 use crate::{ 14 fb::FbLayout, 15 firmware::gsp::GspFirmware, 16 gpu::{ 17 Architecture, 18 Chipset, // 19 }, 20 gsp::{ 21 Gsp, 22 GspBootContext, 23 GspFwWprMeta, // 24 }, 25 }; 26 27 /// Trait for types containing the resources and code required to fully reset the GSP. 28 /// 29 /// The GSP unload code might run in a situation where we cannot load firmware dynamically (e.g. 30 /// because we are in shutdown and the file system is not accessible anymore). Thus, the firmware 31 /// required for unloading is prepared at load time, and stored here until it needs to be run. 32 pub(super) trait UnloadBundle: Send { 33 /// Performs the steps required to properly reset the GSP after it has been stopped. 34 fn run(&self, ctx: &GspBootContext<'_>) -> Result; 35 } 36 37 /// Trait implemented by GSP HALs. 38 pub(super) trait GspHal: Send { 39 /// Performs the GSP boot process, loading and running the required firmwares as needed. 40 /// 41 /// Upon success, returns the [`crate::gsp::UnloadBundle`] to use with [`Gsp::unload`], if one 42 /// could be created. 43 fn boot( 44 &self, 45 gsp: &Gsp, 46 ctx: &GspBootContext<'_>, 47 fb_layout: &FbLayout, 48 wpr_meta: &Coherent<GspFwWprMeta>, 49 ) -> Result<Option<crate::gsp::UnloadBundle>>; 50 51 /// Performs HAL-specific post-GSP boot tasks. 52 /// 53 /// This method is called by the GSP boot code after the GSP is confirmed to be running, and 54 /// after the initialization commands have been pushed onto its queue. 55 fn post_boot(&self, _gsp: &Gsp, _ctx: &GspBootContext<'_>, _gsp_fw: &GspFirmware) -> Result { 56 Ok(()) 57 } 58 } 59 60 /// Returns the GSP HAL to be used for `chipset`. 61 pub(super) fn gsp_hal(chipset: Chipset) -> &'static dyn GspHal { 62 match chipset.arch() { 63 Architecture::Turing => tu102::TU102_HAL, 64 Architecture::Ampere if matches!(chipset, Chipset::GA100) => tu102::TU102_HAL, 65 Architecture::Ampere | Architecture::Ada => ga102::GA102_HAL, 66 Architecture::Hopper | Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => { 67 gh100::GH100_HAL 68 } 69 } 70 } 71