mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
gpu: nova-core: move lifetime to Bar0
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>
This commit is contained in:
parent
723bd79ca9
commit
99676aed1f
|
|
@ -36,7 +36,7 @@ pub(crate) struct NovaCore<'bound> {
|
|||
|
||||
const BAR0_SIZE: usize = SZ_16M;
|
||||
|
||||
pub(crate) type Bar0 = kernel::io::Mmio<BAR0_SIZE>;
|
||||
pub(crate) type Bar0<'a> = &'a pci::Bar<'a, BAR0_SIZE>;
|
||||
|
||||
kernel::pci_device_table!(
|
||||
PCI_TABLE,
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ pub(crate) fn new(dev: &device::Device, chipset: Chipset) -> Result<Self> {
|
|||
}
|
||||
|
||||
/// Resets DMA-related registers.
|
||||
pub(crate) fn dma_reset(&self, bar: &Bar0) {
|
||||
pub(crate) fn dma_reset(&self, bar: Bar0<'_>) {
|
||||
bar.update(regs::NV_PFALCON_FBIF_CTL::of::<E>(), |v| {
|
||||
v.with_allow_phys_no_ctx(true)
|
||||
});
|
||||
|
|
@ -385,7 +385,7 @@ pub(crate) fn dma_reset(&self, bar: &Bar0) {
|
|||
}
|
||||
|
||||
/// Reset the controller, select the falcon core, and wait for memory scrubbing to complete.
|
||||
pub(crate) fn reset(&self, bar: &Bar0) -> Result {
|
||||
pub(crate) fn reset(&self, bar: Bar0<'_>) -> Result {
|
||||
self.hal.reset_eng(bar)?;
|
||||
self.hal.select_core(self, bar)?;
|
||||
self.hal.reset_wait_mem_scrubbing(bar)?;
|
||||
|
|
@ -404,7 +404,11 @@ pub(crate) fn reset(&self, bar: &Bar0) -> Result {
|
|||
/// Write a slice to Falcon IMEM memory using programmed I/O (PIO).
|
||||
///
|
||||
/// Returns `EINVAL` if `img.len()` is not a multiple of 4.
|
||||
fn pio_wr_imem_slice(&self, bar: &Bar0, load_offsets: FalconPioImemLoadTarget<'_>) -> Result {
|
||||
fn pio_wr_imem_slice(
|
||||
&self,
|
||||
bar: Bar0<'_>,
|
||||
load_offsets: FalconPioImemLoadTarget<'_>,
|
||||
) -> Result {
|
||||
// Rejecting misaligned images here allows us to avoid checking
|
||||
// inside the loops.
|
||||
if load_offsets.data.len() % 4 != 0 {
|
||||
|
|
@ -441,7 +445,11 @@ fn pio_wr_imem_slice(&self, bar: &Bar0, load_offsets: FalconPioImemLoadTarget<'_
|
|||
/// Write a slice to Falcon DMEM memory using programmed I/O (PIO).
|
||||
///
|
||||
/// Returns `EINVAL` if `img.len()` is not a multiple of 4.
|
||||
fn pio_wr_dmem_slice(&self, bar: &Bar0, load_offsets: FalconPioDmemLoadTarget<'_>) -> Result {
|
||||
fn pio_wr_dmem_slice(
|
||||
&self,
|
||||
bar: Bar0<'_>,
|
||||
load_offsets: FalconPioDmemLoadTarget<'_>,
|
||||
) -> Result {
|
||||
// Rejecting misaligned images here allows us to avoid checking
|
||||
// inside the loops.
|
||||
if load_offsets.data.len() % 4 != 0 {
|
||||
|
|
@ -469,7 +477,7 @@ fn pio_wr_dmem_slice(&self, bar: &Bar0, load_offsets: FalconPioDmemLoadTarget<'_
|
|||
/// Perform a PIO copy into `IMEM` and `DMEM` of `fw`, and prepare the falcon to run it.
|
||||
pub(crate) fn pio_load<F: FalconFirmware<Target = E> + FalconPioLoadable>(
|
||||
&self,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
fw: &F,
|
||||
) -> Result {
|
||||
bar.update(regs::NV_PFALCON_FBIF_CTL::of::<E>(), |v| {
|
||||
|
|
@ -505,7 +513,7 @@ pub(crate) fn pio_load<F: FalconFirmware<Target = E> + FalconPioLoadable>(
|
|||
/// `sec` is set if the loaded firmware is expected to run in secure mode.
|
||||
fn dma_wr(
|
||||
&self,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
dma_obj: &Coherent<[u8]>,
|
||||
target_mem: FalconMem,
|
||||
load_offsets: FalconDmaLoadTarget,
|
||||
|
|
@ -612,7 +620,7 @@ fn dma_wr(
|
|||
fn dma_load<F: FalconFirmware<Target = E> + FalconDmaLoadable>(
|
||||
&self,
|
||||
dev: &Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
fw: &F,
|
||||
) -> Result {
|
||||
// DMA object with firmware content as the source of the DMA engine.
|
||||
|
|
@ -660,7 +668,7 @@ fn dma_load<F: FalconFirmware<Target = E> + FalconDmaLoadable>(
|
|||
}
|
||||
|
||||
/// Wait until the falcon CPU is halted.
|
||||
pub(crate) fn wait_till_halted(&self, bar: &Bar0) -> Result<()> {
|
||||
pub(crate) fn wait_till_halted(&self, bar: Bar0<'_>) -> Result<()> {
|
||||
// TIMEOUT: arbitrarily large value, firmwares should complete in less than 2 seconds.
|
||||
read_poll_timeout(
|
||||
|| Ok(bar.read(regs::NV_PFALCON_FALCON_CPUCTL::of::<E>())),
|
||||
|
|
@ -673,7 +681,7 @@ pub(crate) fn wait_till_halted(&self, bar: &Bar0) -> Result<()> {
|
|||
}
|
||||
|
||||
/// Start the falcon CPU.
|
||||
pub(crate) fn start(&self, bar: &Bar0) -> Result<()> {
|
||||
pub(crate) fn start(&self, bar: Bar0<'_>) -> Result<()> {
|
||||
match bar
|
||||
.read(regs::NV_PFALCON_FALCON_CPUCTL::of::<E>())
|
||||
.alias_en()
|
||||
|
|
@ -692,7 +700,7 @@ pub(crate) fn start(&self, bar: &Bar0) -> Result<()> {
|
|||
}
|
||||
|
||||
/// Writes values to the mailbox registers if provided.
|
||||
pub(crate) fn write_mailboxes(&self, bar: &Bar0, mbox0: Option<u32>, mbox1: Option<u32>) {
|
||||
pub(crate) fn write_mailboxes(&self, bar: Bar0<'_>, mbox0: Option<u32>, mbox1: Option<u32>) {
|
||||
if let Some(mbox0) = mbox0 {
|
||||
bar.write(
|
||||
WithBase::of::<E>(),
|
||||
|
|
@ -709,19 +717,19 @@ pub(crate) fn write_mailboxes(&self, bar: &Bar0, mbox0: Option<u32>, mbox1: Opti
|
|||
}
|
||||
|
||||
/// Reads the value from `mbox0` register.
|
||||
pub(crate) fn read_mailbox0(&self, bar: &Bar0) -> u32 {
|
||||
pub(crate) fn read_mailbox0(&self, bar: Bar0<'_>) -> u32 {
|
||||
bar.read(regs::NV_PFALCON_FALCON_MAILBOX0::of::<E>())
|
||||
.value()
|
||||
}
|
||||
|
||||
/// Reads the value from `mbox1` register.
|
||||
pub(crate) fn read_mailbox1(&self, bar: &Bar0) -> u32 {
|
||||
pub(crate) fn read_mailbox1(&self, bar: Bar0<'_>) -> u32 {
|
||||
bar.read(regs::NV_PFALCON_FALCON_MAILBOX1::of::<E>())
|
||||
.value()
|
||||
}
|
||||
|
||||
/// Reads values from both mailbox registers.
|
||||
pub(crate) fn read_mailboxes(&self, bar: &Bar0) -> (u32, u32) {
|
||||
pub(crate) fn read_mailboxes(&self, bar: Bar0<'_>) -> (u32, u32) {
|
||||
let mbox0 = self.read_mailbox0(bar);
|
||||
let mbox1 = self.read_mailbox1(bar);
|
||||
|
||||
|
|
@ -737,7 +745,7 @@ pub(crate) fn read_mailboxes(&self, bar: &Bar0) -> (u32, u32) {
|
|||
/// the `MBOX0` and `MBOX1` registers.
|
||||
pub(crate) fn boot(
|
||||
&self,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
mbox0: Option<u32>,
|
||||
mbox1: Option<u32>,
|
||||
) -> Result<(u32, u32)> {
|
||||
|
|
@ -751,7 +759,7 @@ pub(crate) fn boot(
|
|||
/// falcon instance. `engine_id_mask` and `ucode_id` are obtained from the firmware header.
|
||||
pub(crate) fn signature_reg_fuse_version(
|
||||
&self,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
engine_id_mask: u16,
|
||||
ucode_id: u8,
|
||||
) -> Result<u32> {
|
||||
|
|
@ -762,7 +770,7 @@ pub(crate) fn signature_reg_fuse_version(
|
|||
/// Check if the RISC-V core is active.
|
||||
///
|
||||
/// Returns `true` if the RISC-V core is active, `false` otherwise.
|
||||
pub(crate) fn is_riscv_active(&self, bar: &Bar0) -> bool {
|
||||
pub(crate) fn is_riscv_active(&self, bar: Bar0<'_>) -> bool {
|
||||
self.hal.is_riscv_active(bar)
|
||||
}
|
||||
|
||||
|
|
@ -771,7 +779,7 @@ pub(crate) fn is_riscv_active(&self, bar: &Bar0) -> bool {
|
|||
pub(crate) fn load<F: FalconFirmware<Target = E> + FalconDmaLoadable>(
|
||||
&self,
|
||||
dev: &Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
fw: &F,
|
||||
) -> Result {
|
||||
match self.hal.load_method() {
|
||||
|
|
@ -781,7 +789,7 @@ pub(crate) fn load<F: FalconFirmware<Target = E> + FalconDmaLoadable>(
|
|||
}
|
||||
|
||||
/// Write the application version to the OS register.
|
||||
pub(crate) fn write_os_version(&self, bar: &Bar0, app_version: u32) {
|
||||
pub(crate) fn write_os_version(&self, bar: Bar0<'_>, app_version: u32) {
|
||||
bar.write(
|
||||
WithBase::of::<E>(),
|
||||
regs::NV_PFALCON_FALCON_OS::zeroed().with_value(app_version),
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ impl Falcon<Fsp> {
|
|||
///
|
||||
/// `data` is interpreted as little-endian 32-bit words. Returns `EINVAL`
|
||||
/// if the `data` length is not 4-byte aligned.
|
||||
fn write_emem(&mut self, bar: &Bar0, data: &[u8]) -> Result {
|
||||
fn write_emem(&mut self, bar: Bar0<'_>, data: &[u8]) -> Result {
|
||||
if data.len() % 4 != 0 {
|
||||
return Err(EINVAL);
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ fn write_emem(&mut self, bar: &Bar0, data: &[u8]) -> Result {
|
|||
///
|
||||
/// `data` is stored as little-endian 32-bit words. Returns `EINVAL` if
|
||||
/// the `data` length is not 4-byte aligned.
|
||||
fn read_emem(&mut self, bar: &Bar0, data: &mut [u8]) -> Result {
|
||||
fn read_emem(&mut self, bar: Bar0<'_>, data: &mut [u8]) -> Result {
|
||||
if data.len() % 4 != 0 {
|
||||
return Err(EINVAL);
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ fn read_emem(&mut self, bar: &Bar0, data: &mut [u8]) -> Result {
|
|||
///
|
||||
/// The FSP message queue is not circular. Pointers are reset to 0 after each
|
||||
/// message exchange, so `tail >= head` is always true when data is present.
|
||||
fn poll_msgq(&self, bar: &Bar0) -> u32 {
|
||||
fn poll_msgq(&self, bar: Bar0<'_>) -> u32 {
|
||||
let head = bar.read(regs::NV_PFSP_MSGQ_HEAD::at(0)).val();
|
||||
let tail = bar.read(regs::NV_PFSP_MSGQ_TAIL::at(0)).val();
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ fn poll_msgq(&self, bar: &Bar0) -> u32 {
|
|||
/// Writes `packet` to FSP EMEM and updates the queue pointers to notify FSP.
|
||||
///
|
||||
/// Returns `EINVAL` if `packet` is empty or its length is not 4-byte aligned.
|
||||
pub(crate) fn send_msg(&mut self, bar: &Bar0, packet: &[u8]) -> Result {
|
||||
pub(crate) fn send_msg(&mut self, bar: Bar0<'_>, packet: &[u8]) -> Result {
|
||||
if packet.is_empty() {
|
||||
return Err(EINVAL);
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ pub(crate) fn send_msg(&mut self, bar: &Bar0, packet: &[u8]) -> Result {
|
|||
///
|
||||
/// Returns `ETIMEDOUT` if no message was available until timeout, or a regular error code if a
|
||||
/// memory allocation error occurred.
|
||||
pub(crate) fn recv_msg(&mut self, bar: &Bar0) -> Result<KVec<u8>> {
|
||||
pub(crate) fn recv_msg(&mut self, bar: Bar0<'_>) -> Result<KVec<u8>> {
|
||||
let msg_size = read_poll_timeout(
|
||||
|| Ok(self.poll_msgq(bar)),
|
||||
|&size| size > 0,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl FalconEngine for Gsp {}
|
|||
impl Falcon<Gsp> {
|
||||
/// Clears the SWGEN0 bit in the Falcon's IRQ status clear register to
|
||||
/// allow GSP to signal CPU for processing new messages in message queue.
|
||||
pub(crate) fn clear_swgen0_intr(&self, bar: &Bar0) {
|
||||
pub(crate) fn clear_swgen0_intr(&self, bar: Bar0<'_>) {
|
||||
bar.write(
|
||||
WithBase::of::<Gsp>(),
|
||||
regs::NV_PFALCON_FALCON_IRQSCLR::zeroed().with_swgen0(true),
|
||||
|
|
@ -52,7 +52,7 @@ pub(crate) fn clear_swgen0_intr(&self, bar: &Bar0) {
|
|||
}
|
||||
|
||||
/// Checks if GSP reload/resume has completed during the boot process.
|
||||
pub(crate) fn check_reload_completed(&self, bar: &Bar0, timeout: Delta) -> Result<bool> {
|
||||
pub(crate) fn check_reload_completed(&self, bar: Bar0<'_>, timeout: Delta) -> Result<bool> {
|
||||
read_poll_timeout(
|
||||
|| Ok(bar.read(regs::NV_PGC6_BSI_SECURE_SCRATCH_14)),
|
||||
|val| val.boot_stage_3_handoff(),
|
||||
|
|
@ -63,13 +63,13 @@ pub(crate) fn check_reload_completed(&self, bar: &Bar0, timeout: Delta) -> Resul
|
|||
}
|
||||
|
||||
/// Returns whether the RISC-V branch privilege lockdown bit is set.
|
||||
pub(crate) fn riscv_branch_privilege_lockdown(&self, bar: &Bar0) -> bool {
|
||||
pub(crate) fn riscv_branch_privilege_lockdown(&self, bar: Bar0<'_>) -> bool {
|
||||
bar.read(regs::NV_PFALCON_FALCON_HWCFG2::of::<Gsp>())
|
||||
.riscv_br_priv_lockdown()
|
||||
}
|
||||
|
||||
/// Returns whether GSP registers can be read by the CPU.
|
||||
pub(crate) fn priv_target_mask_released(&self, bar: &Bar0) -> bool {
|
||||
pub(crate) fn priv_target_mask_released(&self, bar: Bar0<'_>) -> bool {
|
||||
let hwcfg2 = bar
|
||||
.read(regs::NV_PFALCON_FALCON_HWCFG2::of::<Gsp>())
|
||||
.into_raw();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ pub(crate) enum LoadMethod {
|
|||
/// registers.
|
||||
pub(crate) trait FalconHal<E: FalconEngine>: Send + Sync {
|
||||
/// Activates the Falcon core if the engine is a risvc/falcon dual engine.
|
||||
fn select_core(&self, _falcon: &Falcon<E>, _bar: &Bar0) -> Result {
|
||||
fn select_core(&self, _falcon: &Falcon<E>, _bar: Bar0<'_>) -> Result {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -43,23 +43,23 @@ fn select_core(&self, _falcon: &Falcon<E>, _bar: &Bar0) -> Result {
|
|||
fn signature_reg_fuse_version(
|
||||
&self,
|
||||
falcon: &Falcon<E>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
engine_id_mask: u16,
|
||||
ucode_id: u8,
|
||||
) -> Result<u32>;
|
||||
|
||||
/// Program the boot ROM registers prior to starting a secure firmware.
|
||||
fn program_brom(&self, falcon: &Falcon<E>, bar: &Bar0, params: &FalconBromParams);
|
||||
fn program_brom(&self, falcon: &Falcon<E>, bar: Bar0<'_>, params: &FalconBromParams);
|
||||
|
||||
/// Check if the RISC-V core is active.
|
||||
/// Returns `true` if the RISC-V core is active, `false` otherwise.
|
||||
fn is_riscv_active(&self, bar: &Bar0) -> bool;
|
||||
fn is_riscv_active(&self, bar: Bar0<'_>) -> bool;
|
||||
|
||||
/// Wait for memory scrubbing to complete.
|
||||
fn reset_wait_mem_scrubbing(&self, bar: &Bar0) -> Result;
|
||||
fn reset_wait_mem_scrubbing(&self, bar: Bar0<'_>) -> Result;
|
||||
|
||||
/// Reset the falcon engine.
|
||||
fn reset_eng(&self, bar: &Bar0) -> Result;
|
||||
fn reset_eng(&self, bar: Bar0<'_>) -> Result;
|
||||
|
||||
/// Returns the method used to load data into the falcon's memory.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
use super::FalconHal;
|
||||
|
||||
fn select_core_ga102<E: FalconEngine>(bar: &Bar0) -> Result {
|
||||
fn select_core_ga102<E: FalconEngine>(bar: Bar0<'_>) -> Result {
|
||||
let bcr_ctrl = bar.read(regs::NV_PRISCV_RISCV_BCR_CTRL::of::<E>());
|
||||
if bcr_ctrl.core_select() != PeregrineCoreSelect::Falcon {
|
||||
bar.write(
|
||||
|
|
@ -53,7 +53,7 @@ fn select_core_ga102<E: FalconEngine>(bar: &Bar0) -> Result {
|
|||
|
||||
fn signature_reg_fuse_version_ga102(
|
||||
dev: &device::Device,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
engine_id_mask: u16,
|
||||
ucode_id: u8,
|
||||
) -> Result<u32> {
|
||||
|
|
@ -86,7 +86,7 @@ fn signature_reg_fuse_version_ga102(
|
|||
Ok(u16::BITS - reg_fuse_version.leading_zeros())
|
||||
}
|
||||
|
||||
fn program_brom_ga102<E: FalconEngine>(bar: &Bar0, params: &FalconBromParams) {
|
||||
fn program_brom_ga102<E: FalconEngine>(bar: Bar0<'_>, params: &FalconBromParams) {
|
||||
bar.write(
|
||||
WithBase::of::<E>().at(0),
|
||||
regs::NV_PFALCON2_FALCON_BROM_PARAADDR::zeroed().with_value(params.pkc_data_offset),
|
||||
|
|
@ -115,30 +115,30 @@ pub(super) fn new() -> Self {
|
|||
}
|
||||
|
||||
impl<E: FalconEngine> FalconHal<E> for Ga102<E> {
|
||||
fn select_core(&self, _falcon: &Falcon<E>, bar: &Bar0) -> Result {
|
||||
fn select_core(&self, _falcon: &Falcon<E>, bar: Bar0<'_>) -> Result {
|
||||
select_core_ga102::<E>(bar)
|
||||
}
|
||||
|
||||
fn signature_reg_fuse_version(
|
||||
&self,
|
||||
falcon: &Falcon<E>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
engine_id_mask: u16,
|
||||
ucode_id: u8,
|
||||
) -> Result<u32> {
|
||||
signature_reg_fuse_version_ga102(&falcon.dev, bar, engine_id_mask, ucode_id)
|
||||
}
|
||||
|
||||
fn program_brom(&self, _falcon: &Falcon<E>, bar: &Bar0, params: &FalconBromParams) {
|
||||
fn program_brom(&self, _falcon: &Falcon<E>, bar: Bar0<'_>, params: &FalconBromParams) {
|
||||
program_brom_ga102::<E>(bar, params);
|
||||
}
|
||||
|
||||
fn is_riscv_active(&self, bar: &Bar0) -> bool {
|
||||
fn is_riscv_active(&self, bar: Bar0<'_>) -> bool {
|
||||
bar.read(regs::NV_PRISCV_RISCV_CPUCTL::of::<E>())
|
||||
.active_stat()
|
||||
}
|
||||
|
||||
fn reset_wait_mem_scrubbing(&self, bar: &Bar0) -> Result {
|
||||
fn reset_wait_mem_scrubbing(&self, bar: Bar0<'_>) -> Result {
|
||||
// TIMEOUT: memory scrubbing should complete in less than 20ms.
|
||||
read_poll_timeout(
|
||||
|| Ok(bar.read(regs::NV_PFALCON_FALCON_HWCFG2::of::<E>())),
|
||||
|
|
@ -149,7 +149,7 @@ fn reset_wait_mem_scrubbing(&self, bar: &Bar0) -> Result {
|
|||
.map(|_| ())
|
||||
}
|
||||
|
||||
fn reset_eng(&self, bar: &Bar0) -> Result {
|
||||
fn reset_eng(&self, bar: Bar0<'_>) -> Result {
|
||||
let _ = bar.read(regs::NV_PFALCON_FALCON_HWCFG2::of::<E>());
|
||||
|
||||
// According to OpenRM's `kflcnPreResetWait_GA102` documentation, HW sometimes does not set
|
||||
|
|
|
|||
|
|
@ -34,28 +34,28 @@ pub(super) fn new() -> Self {
|
|||
}
|
||||
|
||||
impl<E: FalconEngine> FalconHal<E> for Tu102<E> {
|
||||
fn select_core(&self, _falcon: &Falcon<E>, _bar: &Bar0) -> Result {
|
||||
fn select_core(&self, _falcon: &Falcon<E>, _bar: Bar0<'_>) -> Result {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn signature_reg_fuse_version(
|
||||
&self,
|
||||
_falcon: &Falcon<E>,
|
||||
_bar: &Bar0,
|
||||
_bar: Bar0<'_>,
|
||||
_engine_id_mask: u16,
|
||||
_ucode_id: u8,
|
||||
) -> Result<u32> {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
fn program_brom(&self, _falcon: &Falcon<E>, _bar: &Bar0, _params: &FalconBromParams) {}
|
||||
fn program_brom(&self, _falcon: &Falcon<E>, _bar: Bar0<'_>, _params: &FalconBromParams) {}
|
||||
|
||||
fn is_riscv_active(&self, bar: &Bar0) -> bool {
|
||||
fn is_riscv_active(&self, bar: Bar0<'_>) -> bool {
|
||||
bar.read(regs::NV_PRISCV_RISCV_CORE_SWITCH_RISCV_STATUS::of::<E>())
|
||||
.active_stat()
|
||||
}
|
||||
|
||||
fn reset_wait_mem_scrubbing(&self, bar: &Bar0) -> Result {
|
||||
fn reset_wait_mem_scrubbing(&self, bar: Bar0<'_>) -> Result {
|
||||
// TIMEOUT: memory scrubbing should complete in less than 10ms.
|
||||
read_poll_timeout(
|
||||
|| Ok(bar.read(regs::NV_PFALCON_FALCON_DMACTL::of::<E>())),
|
||||
|
|
@ -66,7 +66,7 @@ fn reset_wait_mem_scrubbing(&self, bar: &Bar0) -> Result {
|
|||
.map(|_| ())
|
||||
}
|
||||
|
||||
fn reset_eng(&self, bar: &Bar0) -> Result {
|
||||
fn reset_eng(&self, bar: Bar0<'_>) -> Result {
|
||||
regs::NV_PFALCON_FALCON_ENGINE::reset_engine::<E>(bar);
|
||||
self.reset_wait_mem_scrubbing(bar)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ pub(crate) struct SysmemFlush<'sys> {
|
|||
/// Chipset we are operating on.
|
||||
chipset: Chipset,
|
||||
device: &'sys device::Device,
|
||||
bar: &'sys Bar0,
|
||||
bar: Bar0<'sys>,
|
||||
/// Keep the page alive as long as we need it.
|
||||
page: CoherentHandle,
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ impl<'sys> SysmemFlush<'sys> {
|
|||
/// Allocate a memory page and register it as the sysmem flush page.
|
||||
pub(crate) fn register(
|
||||
dev: &'sys device::Device<device::Bound>,
|
||||
bar: &'sys Bar0,
|
||||
bar: Bar0<'sys>,
|
||||
chipset: Chipset,
|
||||
) -> Result<Self> {
|
||||
let page = CoherentHandle::alloc(dev, kernel::page::PAGE_SIZE, GFP_KERNEL)?;
|
||||
|
|
@ -171,7 +171,7 @@ pub(crate) struct FbLayout {
|
|||
|
||||
impl FbLayout {
|
||||
/// Computes the FB layout for `chipset` required to run the `gsp_fw` GSP firmware.
|
||||
pub(crate) fn new(chipset: Chipset, bar: &Bar0, gsp_fw: &GspFirmware) -> Result<Self> {
|
||||
pub(crate) fn new(chipset: Chipset, bar: Bar0<'_>, gsp_fw: &GspFirmware) -> Result<Self> {
|
||||
let hal = hal::fb_hal(chipset);
|
||||
|
||||
let fb = {
|
||||
|
|
|
|||
|
|
@ -20,18 +20,18 @@
|
|||
|
||||
pub(crate) trait FbHal {
|
||||
/// Returns the address of the currently-registered sysmem flush page.
|
||||
fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64;
|
||||
fn read_sysmem_flush_page(&self, bar: Bar0<'_>) -> u64;
|
||||
|
||||
/// Register `addr` as the address of the sysmem flush page.
|
||||
///
|
||||
/// This might fail if the address is too large for the receiving register.
|
||||
fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result;
|
||||
fn write_sysmem_flush_page(&self, bar: Bar0<'_>, addr: u64) -> Result;
|
||||
|
||||
/// Returns `true` is display is supported.
|
||||
fn supports_display(&self, bar: &Bar0) -> bool;
|
||||
fn supports_display(&self, bar: Bar0<'_>) -> bool;
|
||||
|
||||
/// Returns the VRAM size, in bytes.
|
||||
fn vidmem_size(&self, bar: &Bar0) -> u64;
|
||||
fn vidmem_size(&self, bar: Bar0<'_>) -> u64;
|
||||
|
||||
/// Returns the amount of VRAM to reserve for the PMU.
|
||||
fn pmu_reserved_size(&self) -> u32;
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@
|
|||
|
||||
struct Ga100;
|
||||
|
||||
pub(super) fn read_sysmem_flush_page_ga100(bar: &Bar0) -> u64 {
|
||||
pub(super) fn read_sysmem_flush_page_ga100(bar: Bar0<'_>) -> u64 {
|
||||
u64::from(bar.read(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR).adr_39_08()) << FLUSH_SYSMEM_ADDR_SHIFT
|
||||
| u64::from(bar.read(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR_HI).adr_63_40())
|
||||
<< FLUSH_SYSMEM_ADDR_SHIFT_HI
|
||||
}
|
||||
|
||||
pub(super) fn write_sysmem_flush_page_ga100(bar: &Bar0, addr: u64) {
|
||||
pub(super) fn write_sysmem_flush_page_ga100(bar: Bar0<'_>, addr: u64) {
|
||||
bar.write_reg(
|
||||
regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR_HI::zeroed().with_adr_63_40(
|
||||
Bounded::<u64, _>::from(addr)
|
||||
|
|
@ -40,7 +40,7 @@ pub(super) fn write_sysmem_flush_page_ga100(bar: &Bar0, addr: u64) {
|
|||
);
|
||||
}
|
||||
|
||||
pub(super) fn display_enabled_ga100(bar: &Bar0) -> bool {
|
||||
pub(super) fn display_enabled_ga100(bar: Bar0<'_>) -> bool {
|
||||
!bar.read(regs::ga100::NV_FUSE_STATUS_OPT_DISPLAY)
|
||||
.display_disabled()
|
||||
}
|
||||
|
|
@ -50,21 +50,21 @@ pub(super) fn display_enabled_ga100(bar: &Bar0) -> bool {
|
|||
const FLUSH_SYSMEM_ADDR_SHIFT_HI: u32 = 40;
|
||||
|
||||
impl FbHal for Ga100 {
|
||||
fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
|
||||
fn read_sysmem_flush_page(&self, bar: Bar0<'_>) -> u64 {
|
||||
read_sysmem_flush_page_ga100(bar)
|
||||
}
|
||||
|
||||
fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
|
||||
fn write_sysmem_flush_page(&self, bar: Bar0<'_>, addr: u64) -> Result {
|
||||
write_sysmem_flush_page_ga100(bar, addr);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn supports_display(&self, bar: &Bar0) -> bool {
|
||||
fn supports_display(&self, bar: Bar0<'_>) -> bool {
|
||||
display_enabled_ga100(bar)
|
||||
}
|
||||
|
||||
fn vidmem_size(&self, bar: &Bar0) -> u64 {
|
||||
fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {
|
||||
super::tu102::vidmem_size_gp102(bar)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,28 +12,28 @@
|
|||
regs, //
|
||||
};
|
||||
|
||||
pub(super) fn vidmem_size_ga102(bar: &Bar0) -> u64 {
|
||||
pub(super) fn vidmem_size_ga102(bar: Bar0<'_>) -> u64 {
|
||||
bar.read(regs::NV_USABLE_FB_SIZE_IN_MB).usable_fb_size()
|
||||
}
|
||||
|
||||
struct Ga102;
|
||||
|
||||
impl FbHal for Ga102 {
|
||||
fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
|
||||
fn read_sysmem_flush_page(&self, bar: Bar0<'_>) -> u64 {
|
||||
super::ga100::read_sysmem_flush_page_ga100(bar)
|
||||
}
|
||||
|
||||
fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
|
||||
fn write_sysmem_flush_page(&self, bar: Bar0<'_>, addr: u64) -> Result {
|
||||
super::ga100::write_sysmem_flush_page_ga100(bar, addr);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn supports_display(&self, bar: &Bar0) -> bool {
|
||||
fn supports_display(&self, bar: Bar0<'_>) -> bool {
|
||||
super::ga100::display_enabled_ga100(bar)
|
||||
}
|
||||
|
||||
fn vidmem_size(&self, bar: &Bar0) -> u64 {
|
||||
fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {
|
||||
vidmem_size_ga102(bar)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ impl RegisterBase<regs::Hshub0Base> for Gb100 {
|
|||
const BASE: usize = 0x0087_0000;
|
||||
}
|
||||
|
||||
fn read_sysmem_flush_page_gb100(bar: &Bar0) -> u64 {
|
||||
fn read_sysmem_flush_page_gb100(bar: Bar0<'_>) -> u64 {
|
||||
let lo = u64::from(
|
||||
bar.read(regs::NV_PFB_HSHUB_PCIE_FLUSH_SYSMEM_ADDR_LO::of::<Gb100>())
|
||||
.adr(),
|
||||
|
|
@ -50,7 +50,7 @@ fn read_sysmem_flush_page_gb100(bar: &Bar0) -> u64 {
|
|||
///
|
||||
/// Both the primary and EG (egress) register pairs must be programmed to the same address,
|
||||
/// as required by hardware.
|
||||
fn write_sysmem_flush_page_gb100(bar: &Bar0, addr: Bounded<u64, 52>) {
|
||||
fn write_sysmem_flush_page_gb100(bar: Bar0<'_>, addr: Bounded<u64, 52>) {
|
||||
// CAST: lower 32 bits. Hardware ignores bits 7:0.
|
||||
let addr_lo = *addr as u32;
|
||||
let addr_hi = addr.shr::<32, 20>().cast::<u32>();
|
||||
|
|
@ -84,11 +84,11 @@ pub(super) const fn pmu_reserved_size_gb100() -> u32 {
|
|||
}
|
||||
|
||||
impl FbHal for Gb100 {
|
||||
fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
|
||||
fn read_sysmem_flush_page(&self, bar: Bar0<'_>) -> u64 {
|
||||
read_sysmem_flush_page_gb100(bar)
|
||||
}
|
||||
|
||||
fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
|
||||
fn write_sysmem_flush_page(&self, bar: Bar0<'_>, addr: u64) -> Result {
|
||||
let addr = Bounded::<u64, 52>::try_new(addr).ok_or(EINVAL)?;
|
||||
|
||||
write_sysmem_flush_page_gb100(bar, addr);
|
||||
|
|
@ -96,11 +96,11 @@ fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn supports_display(&self, bar: &Bar0) -> bool {
|
||||
fn supports_display(&self, bar: Bar0<'_>) -> bool {
|
||||
super::ga100::display_enabled_ga100(bar)
|
||||
}
|
||||
|
||||
fn vidmem_size(&self, bar: &Bar0) -> u64 {
|
||||
fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {
|
||||
super::ga102::vidmem_size_ga102(bar)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ impl RegisterBase<regs::Fbhub0Base> for Gb202 {
|
|||
const BASE: usize = 0x008a_0000;
|
||||
}
|
||||
|
||||
fn read_sysmem_flush_page_gb202(bar: &Bar0) -> u64 {
|
||||
fn read_sysmem_flush_page_gb202(bar: Bar0<'_>) -> u64 {
|
||||
let lo = u64::from(
|
||||
bar.read(regs::NV_PFB_FBHUB_PCIE_FLUSH_SYSMEM_ADDR_LO::of::<Gb202>())
|
||||
.adr(),
|
||||
|
|
@ -42,7 +42,7 @@ fn read_sysmem_flush_page_gb202(bar: &Bar0) -> u64 {
|
|||
}
|
||||
|
||||
/// Write the sysmem flush page address through the GB20x FBHUB0 registers.
|
||||
fn write_sysmem_flush_page_gb202(bar: &Bar0, addr: Bounded<u64, 52>) {
|
||||
fn write_sysmem_flush_page_gb202(bar: Bar0<'_>, addr: Bounded<u64, 52>) {
|
||||
// Write HI first. The hardware will trigger the flush on the LO write.
|
||||
bar.write(
|
||||
regs::NV_PFB_FBHUB_PCIE_FLUSH_SYSMEM_ADDR_HI::of::<Gb202>(),
|
||||
|
|
@ -57,11 +57,11 @@ fn write_sysmem_flush_page_gb202(bar: &Bar0, addr: Bounded<u64, 52>) {
|
|||
}
|
||||
|
||||
impl FbHal for Gb202 {
|
||||
fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
|
||||
fn read_sysmem_flush_page(&self, bar: Bar0<'_>) -> u64 {
|
||||
read_sysmem_flush_page_gb202(bar)
|
||||
}
|
||||
|
||||
fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
|
||||
fn write_sysmem_flush_page(&self, bar: Bar0<'_>, addr: u64) -> Result {
|
||||
let addr = Bounded::<u64, 52>::try_new(addr).ok_or(EINVAL)?;
|
||||
|
||||
write_sysmem_flush_page_gb202(bar, addr);
|
||||
|
|
@ -69,11 +69,11 @@ fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn supports_display(&self, bar: &Bar0) -> bool {
|
||||
fn supports_display(&self, bar: Bar0<'_>) -> bool {
|
||||
super::ga100::display_enabled_ga100(bar)
|
||||
}
|
||||
|
||||
fn vidmem_size(&self, bar: &Bar0) -> u64 {
|
||||
fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {
|
||||
super::ga102::vidmem_size_ga102(bar)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,21 +14,21 @@
|
|||
struct Gh100;
|
||||
|
||||
impl FbHal for Gh100 {
|
||||
fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
|
||||
fn read_sysmem_flush_page(&self, bar: Bar0<'_>) -> u64 {
|
||||
super::ga100::read_sysmem_flush_page_ga100(bar)
|
||||
}
|
||||
|
||||
fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
|
||||
fn write_sysmem_flush_page(&self, bar: Bar0<'_>, addr: u64) -> Result {
|
||||
super::ga100::write_sysmem_flush_page_ga100(bar, addr);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn supports_display(&self, bar: &Bar0) -> bool {
|
||||
fn supports_display(&self, bar: Bar0<'_>) -> bool {
|
||||
super::ga100::display_enabled_ga100(bar)
|
||||
}
|
||||
|
||||
fn vidmem_size(&self, bar: &Bar0) -> u64 {
|
||||
fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {
|
||||
super::ga102::vidmem_size_ga102(bar)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@
|
|||
/// to be used by HALs.
|
||||
pub(super) const FLUSH_SYSMEM_ADDR_SHIFT: u32 = 8;
|
||||
|
||||
pub(super) fn read_sysmem_flush_page_gm107(bar: &Bar0) -> u64 {
|
||||
pub(super) fn read_sysmem_flush_page_gm107(bar: Bar0<'_>) -> u64 {
|
||||
u64::from(bar.read(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR).adr_39_08()) << FLUSH_SYSMEM_ADDR_SHIFT
|
||||
}
|
||||
|
||||
pub(super) fn write_sysmem_flush_page_gm107(bar: &Bar0, addr: u64) -> Result {
|
||||
pub(super) fn write_sysmem_flush_page_gm107(bar: Bar0<'_>, addr: u64) -> Result {
|
||||
// Check that the address doesn't overflow the receiving 32-bit register.
|
||||
u32::try_from(addr >> FLUSH_SYSMEM_ADDR_SHIFT)
|
||||
.map_err(|_| EINVAL)
|
||||
|
|
@ -30,12 +30,12 @@ pub(super) fn write_sysmem_flush_page_gm107(bar: &Bar0, addr: u64) -> Result {
|
|||
})
|
||||
}
|
||||
|
||||
pub(super) fn display_enabled_gm107(bar: &Bar0) -> bool {
|
||||
pub(super) fn display_enabled_gm107(bar: Bar0<'_>) -> bool {
|
||||
!bar.read(regs::gm107::NV_FUSE_STATUS_OPT_DISPLAY)
|
||||
.display_disabled()
|
||||
}
|
||||
|
||||
pub(super) fn vidmem_size_gp102(bar: &Bar0) -> u64 {
|
||||
pub(super) fn vidmem_size_gp102(bar: Bar0<'_>) -> u64 {
|
||||
bar.read(regs::NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE)
|
||||
.usable_fb_size()
|
||||
}
|
||||
|
|
@ -55,19 +55,19 @@ pub(super) const fn frts_size_tu102() -> u64 {
|
|||
struct Tu102;
|
||||
|
||||
impl FbHal for Tu102 {
|
||||
fn read_sysmem_flush_page(&self, bar: &Bar0) -> u64 {
|
||||
fn read_sysmem_flush_page(&self, bar: Bar0<'_>) -> u64 {
|
||||
read_sysmem_flush_page_gm107(bar)
|
||||
}
|
||||
|
||||
fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result {
|
||||
fn write_sysmem_flush_page(&self, bar: Bar0<'_>, addr: u64) -> Result {
|
||||
write_sysmem_flush_page_gm107(bar, addr)
|
||||
}
|
||||
|
||||
fn supports_display(&self, bar: &Bar0) -> bool {
|
||||
fn supports_display(&self, bar: Bar0<'_>) -> bool {
|
||||
display_enabled_gm107(bar)
|
||||
}
|
||||
|
||||
fn vidmem_size(&self, bar: &Bar0) -> u64 {
|
||||
fn vidmem_size(&self, bar: Bar0<'_>) -> u64 {
|
||||
vidmem_size_gp102(bar)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ pub(crate) fn new(
|
|||
chipset: Chipset,
|
||||
ver: &str,
|
||||
falcon: &Falcon<<Self as FalconFirmware>::Target>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
) -> Result<Self> {
|
||||
let fw_name = match kind {
|
||||
BooterKind::Loader => "booter_load",
|
||||
|
|
@ -405,7 +405,7 @@ pub(crate) fn new(
|
|||
pub(crate) fn run<T>(
|
||||
&self,
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
sec2_falcon: &Falcon<Sec2>,
|
||||
wpr_meta: &Coherent<T>,
|
||||
) -> Result {
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ impl FwsecFirmware {
|
|||
pub(crate) fn new(
|
||||
dev: &Device<device::Bound>,
|
||||
falcon: &Falcon<Gsp>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
bios: &Vbios,
|
||||
cmd: FwsecCommand,
|
||||
) -> Result<Self> {
|
||||
|
|
@ -394,7 +394,7 @@ pub(crate) fn run(
|
|||
&self,
|
||||
dev: &Device<device::Bound>,
|
||||
falcon: &Falcon<Gsp>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
) -> Result<()> {
|
||||
// Reset falcon, load the firmware, and run it.
|
||||
falcon
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ pub(crate) fn run(
|
|||
&self,
|
||||
dev: &Device<device::Bound>,
|
||||
falcon: &Falcon<Gsp>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
) -> Result<()> {
|
||||
// Reset falcon, load the firmware, and run it.
|
||||
falcon
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ impl Fsp {
|
|||
/// interface is not used before secure boot has completed.
|
||||
pub(crate) fn wait_secure_boot(
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
chipset: Chipset,
|
||||
fsp_fw: FspFirmware,
|
||||
) -> Result<Fsp> {
|
||||
|
|
@ -236,7 +236,7 @@ pub(crate) fn wait_secure_boot(
|
|||
}
|
||||
|
||||
/// Sends a message to FSP and waits for the response.
|
||||
fn send_sync_fsp<M>(&mut self, dev: &device::Device, bar: &Bar0, msg: &M) -> Result
|
||||
fn send_sync_fsp<M>(&mut self, dev: &device::Device, bar: Bar0<'_>, msg: &M) -> Result
|
||||
where
|
||||
M: MessageToFsp,
|
||||
{
|
||||
|
|
@ -304,7 +304,7 @@ fn send_sync_fsp<M>(&mut self, dev: &device::Device, bar: &Bar0, msg: &M) -> Res
|
|||
pub(crate) fn boot_fmc(
|
||||
&mut self,
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
fb_layout: &FbLayout,
|
||||
args: &FmcBootArgs,
|
||||
) -> Result {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
pub(super) trait FspHal {
|
||||
/// Returns the secure boot status from the architecture-specific `NV_THERM_I2CS_SCRATCH` register.
|
||||
fn fsp_boot_status(&self, bar: &Bar0) -> u32;
|
||||
fn fsp_boot_status(&self, bar: Bar0<'_>) -> u32;
|
||||
|
||||
/// Returns the FSP Chain of Trust protocol version this chipset advertises.
|
||||
fn cot_version(&self) -> u16;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
struct Gb100;
|
||||
|
||||
impl FspHal for Gb100 {
|
||||
fn fsp_boot_status(&self, bar: &Bar0) -> u32 {
|
||||
fn fsp_boot_status(&self, bar: Bar0<'_>) -> u32 {
|
||||
// GB10x shares Hopper's FSP secure boot status register.
|
||||
super::gh100::fsp_boot_status_gh100(bar)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
struct Gb202;
|
||||
|
||||
impl FspHal for Gb202 {
|
||||
fn fsp_boot_status(&self, bar: &Bar0) -> u32 {
|
||||
fn fsp_boot_status(&self, bar: Bar0<'_>) -> u32 {
|
||||
bar.read(regs::gb202::NV_THERM_I2CS_SCRATCH_FSP_BOOT_COMPLETE)
|
||||
.fsp_boot_complete()
|
||||
.into()
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@
|
|||
struct Gh100;
|
||||
|
||||
/// Reads the FSP secure boot status from the Hopper/GB10x thermal scratch register.
|
||||
pub(super) fn fsp_boot_status_gh100(bar: &Bar0) -> u32 {
|
||||
pub(super) fn fsp_boot_status_gh100(bar: Bar0<'_>) -> u32 {
|
||||
bar.read(regs::gh100::NV_THERM_I2CS_SCRATCH_FSP_BOOT_COMPLETE)
|
||||
.fsp_boot_complete()
|
||||
.into()
|
||||
}
|
||||
|
||||
impl FspHal for Gh100 {
|
||||
fn fsp_boot_status(&self, bar: &Bar0) -> u32 {
|
||||
fn fsp_boot_status(&self, bar: Bar0<'_>) -> u32 {
|
||||
fsp_boot_status_gh100(bar)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ pub(crate) struct Spec {
|
|||
}
|
||||
|
||||
impl Spec {
|
||||
fn new(dev: &device::Device, bar: &Bar0) -> Result<Spec> {
|
||||
fn new(dev: &device::Device, bar: Bar0<'_>) -> Result<Spec> {
|
||||
// Some brief notes about boot0 and boot42, in chronological order:
|
||||
//
|
||||
// NV04 through NV50:
|
||||
|
|
@ -269,7 +269,7 @@ pub(crate) struct Gpu<'gpu> {
|
|||
device: &'gpu device::Device<device::Bound>,
|
||||
spec: Spec,
|
||||
/// MMIO mapping of PCI BAR 0.
|
||||
bar: &'gpu Bar0,
|
||||
bar: Bar0<'gpu>,
|
||||
/// System memory page required for flushing all pending GPU-side memory writes done through
|
||||
/// PCIE into system memory, via sysmembar (A GPU-initiated HW memory-barrier operation).
|
||||
sysmem_flush: SysmemFlush<'gpu>,
|
||||
|
|
@ -287,7 +287,7 @@ pub(crate) struct Gpu<'gpu> {
|
|||
impl<'gpu> Gpu<'gpu> {
|
||||
pub(crate) fn new(
|
||||
pdev: &'gpu pci::Device<device::Core<'_>>,
|
||||
bar: &'gpu Bar0,
|
||||
bar: Bar0<'gpu>,
|
||||
) -> impl PinInit<Self, Error> + 'gpu {
|
||||
try_pin_init!(Self {
|
||||
device: pdev.as_ref(),
|
||||
|
|
@ -308,8 +308,6 @@ pub(crate) fn new(
|
|||
.inspect_err(|_| dev_err!(pdev, "GFW boot did not complete\n"))?;
|
||||
},
|
||||
|
||||
bar,
|
||||
|
||||
sysmem_flush: SysmemFlush::register(pdev.as_ref(), bar, spec.chipset)?,
|
||||
|
||||
gsp_falcon: Falcon::new(
|
||||
|
|
@ -326,6 +324,7 @@ pub(crate) fn new(
|
|||
// outside of the constructed `Gpu`, ensuring that the unload sequence is properly run
|
||||
// in case of failure.
|
||||
unload_bundle: gsp.boot(pdev, bar, spec.chipset, gsp_falcon, sec2_falcon)?,
|
||||
bar,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
pub(crate) trait GpuHal {
|
||||
/// Waits for GFW_BOOT completion if required by this hardware family.
|
||||
fn wait_gfw_boot_completion(&self, bar: &Bar0) -> Result;
|
||||
fn wait_gfw_boot_completion(&self, bar: Bar0<'_>) -> Result;
|
||||
|
||||
/// Returns the DMA mask for the current architecture.
|
||||
fn dma_mask(&self) -> DmaMask;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
struct Gh100;
|
||||
|
||||
impl GpuHal for Gh100 {
|
||||
fn wait_gfw_boot_completion(&self, _bar: &Bar0) -> Result {
|
||||
fn wait_gfw_boot_completion(&self, _bar: Bar0<'_>) -> Result {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl GpuHal for Tu102 {
|
|||
/// This function waits for a signal indicating that core initialization is complete. Before
|
||||
/// this signal is received, little can be done with the GPU. This signal is set by the FWSEC
|
||||
/// running on the GSP in Heavy-secured mode.
|
||||
fn wait_gfw_boot_completion(&self, bar: &Bar0) -> Result {
|
||||
fn wait_gfw_boot_completion(&self, bar: Bar0<'_>) -> Result {
|
||||
// Before accessing the completion status in `NV_PGC6_AON_SECURE_SCRATCH_GROUP_05`, we must
|
||||
// first check `NV_PGC6_AON_SECURE_SCRATCH_GROUP_05_PRIV_LEVEL_MASK`. This is because
|
||||
// `NV_PGC6_AON_SECURE_SCRATCH_GROUP_05` becomes accessible only after the secure firmware
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
pub(super) struct BootUnloadArgs<'a> {
|
||||
gsp: &'a super::Gsp,
|
||||
dev: &'a device::Device<device::Bound>,
|
||||
bar: &'a Bar0,
|
||||
bar: Bar0<'a>,
|
||||
gsp_falcon: &'a Falcon<Gsp>,
|
||||
sec2_falcon: &'a Falcon<Sec2>,
|
||||
unload_bundle: Option<super::UnloadBundle>,
|
||||
|
|
@ -57,7 +57,7 @@ impl<'a> BootUnloadGuard<'a> {
|
|||
pub(super) fn new(
|
||||
gsp: &'a super::Gsp,
|
||||
dev: &'a device::Device<device::Bound>,
|
||||
bar: &'a Bar0,
|
||||
bar: Bar0<'a>,
|
||||
gsp_falcon: &'a Falcon<Gsp>,
|
||||
sec2_falcon: &'a Falcon<Sec2>,
|
||||
unload_bundle: Option<super::UnloadBundle>,
|
||||
|
|
@ -104,7 +104,7 @@ impl super::Gsp {
|
|||
pub(crate) fn boot(
|
||||
self: Pin<&mut Self>,
|
||||
pdev: &pci::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
chipset: Chipset,
|
||||
gsp_falcon: &Falcon<Gsp>,
|
||||
sec2_falcon: &Falcon<Sec2>,
|
||||
|
|
@ -166,7 +166,7 @@ pub(crate) fn boot(
|
|||
/// Shut down the GSP and wait until it is offline.
|
||||
fn shutdown_gsp(
|
||||
cmdq: &Cmdq,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
gsp_falcon: &Falcon<Gsp>,
|
||||
mode: commands::PowerStateLevel,
|
||||
) -> Result {
|
||||
|
|
@ -190,7 +190,7 @@ fn shutdown_gsp(
|
|||
pub(crate) fn unload(
|
||||
&self,
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
gsp_falcon: &Falcon<Gsp>,
|
||||
sec2_falcon: &Falcon<Sec2>,
|
||||
unload_bundle: Option<super::UnloadBundle>,
|
||||
|
|
|
|||
|
|
@ -532,7 +532,7 @@ fn calculate_checksum<T: Iterator<Item = u8>>(it: T) -> u32 {
|
|||
}
|
||||
|
||||
/// Notifies the GSP that we have updated the command queue pointers.
|
||||
fn notify_gsp(bar: &Bar0) {
|
||||
fn notify_gsp(bar: Bar0<'_>) {
|
||||
bar.write_reg(regs::NV_PGSP_QUEUE_HEAD::zeroed().with_address(0u32));
|
||||
}
|
||||
|
||||
|
|
@ -552,7 +552,7 @@ fn notify_gsp(bar: &Bar0) {
|
|||
/// written to by its [`CommandToGsp::init_variable_payload`] method.
|
||||
///
|
||||
/// Error codes returned by the command and reply initializers are propagated as-is.
|
||||
pub(crate) fn send_command<M>(&self, bar: &Bar0, command: M) -> Result<M::Reply>
|
||||
pub(crate) fn send_command<M>(&self, bar: Bar0<'_>, command: M) -> Result<M::Reply>
|
||||
where
|
||||
M: CommandToGsp,
|
||||
M::Reply: MessageFromGsp,
|
||||
|
|
@ -580,7 +580,7 @@ pub(crate) fn send_command<M>(&self, bar: &Bar0, command: M) -> Result<M::Reply>
|
|||
/// written to by its [`CommandToGsp::init_variable_payload`] method.
|
||||
///
|
||||
/// Error codes returned by the command initializers are propagated as-is.
|
||||
pub(crate) fn send_command_no_wait<M>(&self, bar: &Bar0, command: M) -> Result
|
||||
pub(crate) fn send_command_no_wait<M>(&self, bar: Bar0<'_>, command: M) -> Result
|
||||
where
|
||||
M: CommandToGsp<Reply = NoReply>,
|
||||
Error: From<M::InitError>,
|
||||
|
|
@ -624,7 +624,7 @@ impl CmdqInner {
|
|||
/// written to by its [`CommandToGsp::init_variable_payload`] method.
|
||||
///
|
||||
/// Error codes returned by the command initializers are propagated as-is.
|
||||
fn send_single_command<M>(&mut self, bar: &Bar0, command: M) -> Result
|
||||
fn send_single_command<M>(&mut self, bar: Bar0<'_>, command: M) -> Result
|
||||
where
|
||||
M: CommandToGsp,
|
||||
// This allows all error types, including `Infallible`, to be used for `M::InitError`.
|
||||
|
|
@ -694,7 +694,7 @@ fn send_single_command<M>(&mut self, bar: &Bar0, command: M) -> Result
|
|||
/// written to by its [`CommandToGsp::init_variable_payload`] method.
|
||||
///
|
||||
/// Error codes returned by the command initializers are propagated as-is.
|
||||
fn send_command<M>(&mut self, bar: &Bar0, command: M) -> Result
|
||||
fn send_command<M>(&mut self, bar: Bar0<'_>, command: M) -> Result
|
||||
where
|
||||
M: CommandToGsp,
|
||||
Error: From<M::InitError>,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ pub(super) trait UnloadBundle: Send {
|
|||
fn run(
|
||||
&self,
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
gsp_falcon: &Falcon<GspEngine>,
|
||||
sec2_falcon: &Falcon<Sec2>,
|
||||
) -> Result;
|
||||
|
|
@ -58,7 +58,7 @@ fn boot<'a>(
|
|||
&self,
|
||||
gsp: &'a Gsp,
|
||||
dev: &'a device::Device<device::Bound>,
|
||||
bar: &'a Bar0,
|
||||
bar: Bar0<'a>,
|
||||
chipset: Chipset,
|
||||
fb_layout: &FbLayout,
|
||||
wpr_meta: &Coherent<GspFwWprMeta>,
|
||||
|
|
@ -74,7 +74,7 @@ fn post_boot(
|
|||
&self,
|
||||
_gsp: &Gsp,
|
||||
_dev: &device::Device<device::Bound>,
|
||||
_bar: &Bar0,
|
||||
_bar: Bar0<'_>,
|
||||
_gsp_fw: &GspFirmware,
|
||||
_gsp_falcon: &Falcon<GspEngine>,
|
||||
_sec2_falcon: &Falcon<Sec2>,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ struct GspMbox {
|
|||
|
||||
impl GspMbox {
|
||||
/// Reads both mailboxes from the GSP falcon.
|
||||
fn read(gsp_falcon: &Falcon<GspEngine>, bar: &Bar0) -> Self {
|
||||
fn read(gsp_falcon: &Falcon<GspEngine>, bar: Bar0<'_>) -> Self {
|
||||
Self {
|
||||
mbox0: gsp_falcon.read_mailbox0(bar),
|
||||
mbox1: gsp_falcon.read_mailbox1(bar),
|
||||
|
|
@ -65,7 +65,7 @@ fn combined_addr(&self) -> u64 {
|
|||
fn lockdown_released_or_error(
|
||||
&self,
|
||||
gsp_falcon: &Falcon<GspEngine>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
fmc_boot_params_addr: u64,
|
||||
) -> bool {
|
||||
// GSP-FMC normally clears the boot parameters address from the mailboxes early during
|
||||
|
|
@ -82,7 +82,7 @@ fn lockdown_released_or_error(
|
|||
/// Waits for GSP lockdown to be released after FSP Chain of Trust.
|
||||
fn wait_for_gsp_lockdown_release(
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
gsp_falcon: &Falcon<GspEngine>,
|
||||
fmc_boot_params_addr: u64,
|
||||
) -> Result {
|
||||
|
|
@ -126,7 +126,7 @@ impl UnloadBundle for FspUnloadBundle {
|
|||
fn run(
|
||||
&self,
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
gsp_falcon: &Falcon<GspEngine>,
|
||||
_sec2_falcon: &Falcon<Sec2>,
|
||||
) -> Result {
|
||||
|
|
@ -153,7 +153,7 @@ fn boot<'a>(
|
|||
&self,
|
||||
gsp: &'a Gsp,
|
||||
dev: &'a device::Device<device::Bound>,
|
||||
bar: &'a Bar0,
|
||||
bar: Bar0<'a>,
|
||||
chipset: Chipset,
|
||||
fb_layout: &FbLayout,
|
||||
wpr_meta: &Coherent<GspFwWprMeta>,
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ impl FwsecUnloadFirmware {
|
|||
/// Loads the FWSEC SB firmware, as well as its bootloader if `chipset` requires it.
|
||||
fn new(
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
chipset: Chipset,
|
||||
bios: &Vbios,
|
||||
gsp_falcon: &Falcon<GspEngine>,
|
||||
|
|
@ -79,7 +79,7 @@ fn new(
|
|||
fn run(
|
||||
&self,
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
gsp_falcon: &Falcon<GspEngine>,
|
||||
) -> Result {
|
||||
match self {
|
||||
|
|
@ -100,7 +100,7 @@ impl Sec2UnloadBundle {
|
|||
/// Load and prepare the resources required to properly reset the GSP after it has been stopped.
|
||||
fn build(
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
chipset: Chipset,
|
||||
bios: &Vbios,
|
||||
gsp_falcon: &Falcon<GspEngine>,
|
||||
|
|
@ -129,7 +129,7 @@ impl UnloadBundle for Sec2UnloadBundle {
|
|||
fn run(
|
||||
&self,
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
gsp_falcon: &Falcon<GspEngine>,
|
||||
sec2_falcon: &Falcon<Sec2>,
|
||||
) -> Result {
|
||||
|
|
@ -172,7 +172,7 @@ fn run_fwsec_frts(
|
|||
dev: &device::Device<device::Bound>,
|
||||
chipset: Chipset,
|
||||
falcon: &Falcon<GspEngine>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
bios: &Vbios,
|
||||
fb_layout: &FbLayout,
|
||||
) -> Result {
|
||||
|
|
@ -259,7 +259,7 @@ fn boot<'a>(
|
|||
&self,
|
||||
gsp: &'a Gsp,
|
||||
dev: &'a device::Device<device::Bound>,
|
||||
bar: &'a Bar0,
|
||||
bar: Bar0<'a>,
|
||||
chipset: Chipset,
|
||||
fb_layout: &FbLayout,
|
||||
wpr_meta: &Coherent<GspFwWprMeta>,
|
||||
|
|
@ -325,7 +325,7 @@ fn post_boot(
|
|||
&self,
|
||||
gsp: &Gsp,
|
||||
dev: &device::Device<device::Bound>,
|
||||
bar: &Bar0,
|
||||
bar: Bar0<'_>,
|
||||
gsp_fw: &GspFirmware,
|
||||
gsp_falcon: &Falcon<GspEngine>,
|
||||
sec2_falcon: &Falcon<Sec2>,
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ pub(crate) struct GspSequencer<'a> {
|
|||
/// Sequencer information with command data.
|
||||
seq_info: GspSequence,
|
||||
/// `Bar0` for register access.
|
||||
bar: &'a Bar0,
|
||||
bar: Bar0<'a>,
|
||||
/// SEC2 falcon for core operations.
|
||||
sec2_falcon: &'a Falcon<Sec2>,
|
||||
/// GSP falcon for core operations.
|
||||
|
|
@ -351,7 +351,7 @@ pub(crate) struct GspSequencerParams<'a> {
|
|||
/// Device for logging.
|
||||
pub(crate) dev: &'a device::Device,
|
||||
/// BAR0 for register access.
|
||||
pub(crate) bar: &'a Bar0,
|
||||
pub(crate) bar: Bar0<'a>,
|
||||
}
|
||||
|
||||
impl<'a> GspSequencer<'a> {
|
||||
|
|
|
|||
|
|
@ -518,7 +518,7 @@ pub(crate) fn with_falcon_mem(self, mem: FalconMem) -> Self {
|
|||
|
||||
impl NV_PFALCON_FALCON_ENGINE {
|
||||
/// Resets the falcon
|
||||
pub(crate) fn reset_engine<E: FalconEngine>(bar: &Bar0) {
|
||||
pub(crate) fn reset_engine<E: FalconEngine>(bar: Bar0<'_>) {
|
||||
bar.update(Self::of::<E>(), |r| r.with_reset(true));
|
||||
|
||||
// TIMEOUT: falcon engine should not take more than 10us to reset.
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ fn try_from(code: u8) -> Result<Self> {
|
|||
/// Vbios Reader for constructing the VBIOS data.
|
||||
struct VbiosIterator<'a> {
|
||||
dev: &'a device::Device,
|
||||
bar0: &'a Bar0,
|
||||
bar0: Bar0<'a>,
|
||||
/// VBIOS data vector: As BIOS images are scanned, they are added to this vector for reference
|
||||
/// or copying into other data structures. It is the entire scanned contents of the VBIOS which
|
||||
/// progressively extends. It is used so that we do not re-read any contents that are already
|
||||
|
|
@ -90,7 +90,7 @@ impl<'a> VbiosIterator<'a> {
|
|||
/// so that PROM reads transparently skip the header. On GA100, for some reason, the IFR offset
|
||||
/// is not applied to PROM reads. Therefore, the search for the PCI expansion must skip the IFR
|
||||
/// header, if found.
|
||||
fn rom_offset(dev: &device::Device, bar0: &Bar0) -> Result<usize> {
|
||||
fn rom_offset(dev: &device::Device, bar0: Bar0<'_>) -> Result<usize> {
|
||||
// IFR Header in VBIOS.
|
||||
register! {
|
||||
NV_PBUS_IFR_FMT_FIXED0(u32) @ 0x300000 {
|
||||
|
|
@ -158,7 +158,7 @@ fn rom_offset(dev: &device::Device, bar0: &Bar0) -> Result<usize> {
|
|||
}
|
||||
}
|
||||
|
||||
fn new(dev: &'a device::Device, bar0: &'a Bar0) -> Result<Self> {
|
||||
fn new(dev: &'a device::Device, bar0: Bar0<'a>) -> Result<Self> {
|
||||
Ok(Self {
|
||||
dev,
|
||||
bar0,
|
||||
|
|
@ -297,7 +297,7 @@ impl Vbios {
|
|||
/// Probe for VBIOS extraction.
|
||||
///
|
||||
/// Once the VBIOS object is built, `bar0` is not read for [`Vbios`] purposes anymore.
|
||||
pub(crate) fn new(dev: &device::Device, bar0: &Bar0) -> Result<Vbios> {
|
||||
pub(crate) fn new(dev: &device::Device, bar0: Bar0<'_>) -> Result<Vbios> {
|
||||
// Images to extract from iteration
|
||||
let mut pci_at_image: Option<PciAtBiosImage> = None;
|
||||
let mut fwsec_section: Option<KVVec<u8>> = None;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user