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