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::prelude::*; 8 9 use kernel::{ 10 device, 11 dma::Coherent, // 12 }; 13 14 use crate::{ 15 driver::Bar0, 16 falcon::{ 17 gsp::Gsp as GspEngine, 18 sec2::Sec2, 19 Falcon, // 20 }, 21 fb::FbLayout, 22 firmware::gsp::GspFirmware, 23 gpu::{ 24 Architecture, 25 Chipset, // 26 }, 27 gsp::{ 28 boot::BootUnloadGuard, 29 Gsp, 30 GspFwWprMeta, // 31 }, 32 }; 33 34 /// Trait for types containing the resources and code required to fully reset the GSP. 35 /// 36 /// The GSP unload code might run in a situation where we cannot load firmware dynamically (e.g. 37 /// because we are in shutdown and the file system is not accessible anymore). Thus, the firmware 38 /// required for unloading is prepared at load time, and stored here until it needs to be run. 39 pub(super) trait UnloadBundle: Send { 40 /// Performs the steps required to properly reset the GSP after it has been stopped. 41 fn run( 42 &self, 43 dev: &device::Device<device::Bound>, 44 bar: Bar0<'_>, 45 gsp_falcon: &Falcon<GspEngine>, 46 sec2_falcon: &Falcon<Sec2>, 47 ) -> Result; 48 } 49 50 /// Trait implemented by GSP HALs. 51 pub(super) trait GspHal: Send { 52 /// Performs the GSP boot process, loading and running the required firmwares as needed. 53 /// 54 /// Upon success, returns a guard that runs the GSP unload sequence if GSP boot does not 55 /// complete. 56 #[allow(clippy::too_many_arguments)] 57 fn boot<'a>( 58 &self, 59 gsp: &'a Gsp, 60 dev: &'a device::Device<device::Bound>, 61 bar: Bar0<'a>, 62 chipset: Chipset, 63 fb_layout: &FbLayout, 64 wpr_meta: &Coherent<GspFwWprMeta>, 65 gsp_falcon: &'a Falcon<GspEngine>, 66 sec2_falcon: &'a Falcon<Sec2>, 67 ) -> Result<BootUnloadGuard<'a>>; 68 69 /// Performs HAL-specific post-GSP boot tasks. 70 /// 71 /// This method is called by the GSP boot code after the GSP is confirmed to be running, and 72 /// after the initialization commands have been pushed onto its queue. 73 fn post_boot( 74 &self, 75 _gsp: &Gsp, 76 _dev: &device::Device<device::Bound>, 77 _bar: Bar0<'_>, 78 _gsp_fw: &GspFirmware, 79 _gsp_falcon: &Falcon<GspEngine>, 80 _sec2_falcon: &Falcon<Sec2>, 81 ) -> Result { 82 Ok(()) 83 } 84 } 85 86 /// Returns the GSP HAL to be used for `chipset`. 87 pub(super) fn gsp_hal(chipset: Chipset) -> &'static dyn GspHal { 88 match chipset.arch() { 89 Architecture::Turing | Architecture::Ampere | Architecture::Ada => tu102::TU102_HAL, 90 Architecture::Hopper | Architecture::BlackwellGB10x | Architecture::BlackwellGB20x => { 91 gh100::GH100_HAL 92 } 93 } 94 } 95