gpu: nova-core: apply the one "use" item per line policy
Subsystems (5)
PATCH 1/1 gpu: nova-core: apply the one "use" item per line policy
As per [1], we need one "use" item per line, in order to reduce merge conflicts. Furthermore, we need a trailing ", //" in order to tell rustfmt(1) to leave it alone.
This does that for the entire nova-core driver.
[1] https://docs.kernel.org/rust/coding-guidelines.html#imports
---
Tested on Ampere: GA104 (bare metal).
thanks,
John Hubbard
drivers/gpu/nova-core/dma.rs | 17 +++++--- drivers/gpu/nova-core/driver.rs | 11 +++-- drivers/gpu/nova-core/falcon.rs | 34 +++++++++------ drivers/gpu/nova-core/falcon/gsp.rs | 12 +++++- drivers/gpu/nova-core/falcon/hal.rs | 12 ++++-- drivers/gpu/nova-core/falcon/hal/ga102.rs | 26 ++++++++---- drivers/gpu/nova-core/falcon/sec2.rs | 10 ++++- drivers/gpu/nova-core/fb.rs | 28 +++++++----- drivers/gpu/nova-core/fb/hal.rs | 6 ++- drivers/gpu/nova-core/fb/hal/ga100.rs | 12 +++--- drivers/gpu/nova-core/fb/hal/ga102.rs | 8 ++-- drivers/gpu/nova-core/fb/hal/tu102.rs | 9 ++-- drivers/gpu/nova-core/firmware.rs | 30 +++++++------ drivers/gpu/nova-core/firmware/booter.rs | 46 ++++++++++++++------ drivers/gpu/nova-core/firmware/fwsec.rs | 52 +++++++++++++++++------ drivers/gpu/nova-core/firmware/gsp.rs | 33 +++++++++----- drivers/gpu/nova-core/firmware/riscv.rs | 16 ++++--- drivers/gpu/nova-core/gfw.rs | 14 +++--- drivers/gpu/nova-core/gpu.rs | 30 +++++++++---- drivers/gpu/nova-core/gsp/boot.rs | 44 ++++++++++++------- drivers/gpu/nova-core/regs.rs | 24 ++++++++--- drivers/gpu/nova-core/vbios.rs | 29 +++++++++---- 22 files changed, 344 insertions(+), 159 deletions(-)
drivers/gpu/nova-core/dma.rs +11 -6
@@ -2,12 +2,17 @@//! Simple DMA object wrapper. -use core::ops::{Deref ,DerefMut }; - -use kernel::device; -use kernel::dma::CoherentAllocation ; -use kernel::page::PAGE_SIZE ; -use kernel::prelude::*; +use core::ops::{ +Deref , +DerefMut ,// +}; + +use kernel::{ + device, + dma::CoherentAllocation , + page::PAGE_SIZE , + prelude::*,// +};pub (crate )struct DmaObject { dma:CoherentAllocation <u8 >,
drivers/gpu/nova-core/driver.rs +8 -3
@@ -1,13 +1,18 @@// SPDX-License-Identifier: GPL-2.0 use kernel::{ - auxiliary, c_str, + auxiliary, + c_str, device::Core , pci, - pci::{Class ,ClassMask ,Vendor }, + pci::{ +Class , +ClassMask , +Vendor ,// + }, prelude::*, sizes::SZ_16M , - sync::Arc , + sync::Arc ,// };use crate ::gpu::Gpu ;
drivers/gpu/nova-core/falcon.rs +21 -13
@@ -3,20 +3,28 @@//! Falcon microprocessor base support use core::ops::Deref ; +use hal::FalconHal ; -use kernel::device; -use kernel::dma::DmaAddress ; -use kernel::io::poll::read_poll_timeout; -use kernel::prelude::*; -use kernel::sync::aref::ARef ; -use kernel::time::delay::fsleep; -use kernel::time::Delta ; - -use crate ::dma::DmaObject ; -use crate ::driver::Bar0 ; -use crate ::gpu::Chipset ; -use crate ::regs; -use crate ::regs::macros::RegisterBase ; + +use kernel::{ + device, + dma::DmaAddress , + io::poll::read_poll_timeout, + prelude::*, + sync::aref::ARef , + time::{ + delay::fsleep, +Delta ,// + },// +}; + +use crate ::{ + dma::DmaObject , + driver::Bar0 , + gpu::Chipset , + regs, + regs::macros::RegisterBase ,// +};pub (crate )mod gsp;mod hal;
drivers/gpu/nova-core/falcon/gsp.rs +10 -2
@@ -2,8 +2,16 @@use crate ::{ driver::Bar0 , - falcon::{Falcon ,FalconEngine ,PFalcon2Base ,PFalconBase }, - regs::{self, macros::RegisterBase }, + falcon::{ +Falcon , +FalconEngine , +PFalcon2Base , +PFalconBase ,// + }, + regs::{ + self, + macros::RegisterBase ,// + },// };/// Type specifying the `Gsp` falcon engine. Cannot be instantiated.
drivers/gpu/nova-core/falcon/hal.rs +9 -3
@@ -2,9 +2,15 @@use kernel::prelude::*; -use crate ::driver::Bar0 ; -use crate ::falcon::{Falcon ,FalconBromParams ,FalconEngine }; -use crate ::gpu::Chipset ; +use crate ::{ + driver::Bar0 , + falcon::{ +Falcon , +FalconBromParams , +FalconEngine ,// + }, + gpu::Chipset ,// +};mod ga102;
drivers/gpu/nova-core/falcon/hal/ga102.rs +17 -9
@@ -2,16 +2,24 @@use core::marker::PhantomData ; -use kernel::device; -use kernel::io::poll::read_poll_timeout; -use kernel::prelude::*; -use kernel::time::Delta ; - -use crate ::driver::Bar0 ; -use crate ::falcon::{ -Falcon ,FalconBromParams ,FalconEngine ,FalconModSelAlgo ,PeregrineCoreSelect , +use kernel::{ + device, + io::poll::read_poll_timeout, + prelude::*, + time::Delta ,// +}; + +use crate ::{ + driver::Bar0 , + falcon::{ +Falcon , +FalconBromParams , +FalconEngine , +FalconModSelAlgo , +PeregrineCoreSelect ,// + }, + regs,// }; -use crate ::regs;use super ::FalconHal ;
drivers/gpu/nova-core/falcon/sec2.rs +8 -2
@@ -1,7 +1,13 @@// SPDX-License-Identifier: GPL-2.0 -use crate ::falcon::{FalconEngine ,PFalcon2Base ,PFalconBase }; -use crate ::regs::macros::RegisterBase ; +use crate ::{ + falcon::{ +FalconEngine , +PFalcon2Base , +PFalconBase ,// + }, + regs::macros::RegisterBase ,// +};/// Type specifying the `Sec2` falcon engine. Cannot be instantiated. pub (crate )struct Sec2 (());
drivers/gpu/nova-core/fb.rs +18 -10
@@ -2,16 +2,24 @@use core::ops::Range ; -use kernel::prelude::*; -use kernel::ptr::{Alignable ,Alignment }; -use kernel::sizes::*; -use kernel::sync::aref::ARef ; -use kernel::{dev_warn, device}; - -use crate ::dma::DmaObject ; -use crate ::driver::Bar0 ; -use crate ::gpu::Chipset ; -use crate ::regs; +use kernel::{ + dev_warn, + device, + prelude::*, + ptr::{ +Alignable , +Alignment ,// + }, + sizes::*, + sync::aref::ARef ,// +}; + +use crate ::{ + dma::DmaObject , + driver::Bar0 , + gpu::Chipset , + regs,// +};mod hal;
drivers/gpu/nova-core/fb/hal.rs +4 -2
@@ -2,8 +2,10 @@use kernel::prelude::*; -use crate ::driver::Bar0 ; -use crate ::gpu::Chipset ; +use crate ::{ + driver::Bar0 , + gpu::Chipset ,// +};mod ga100;mod ga102;
drivers/gpu/nova-core/fb/hal/ga100.rs +7 -5
@@ -1,15 +1,17 @@// SPDX-License-Identifier: GPL-2.0 -struct Ga100 ; -use kernel::prelude::*; -use crate ::driver::Bar0 ; -use crate ::fb::hal::FbHal ; -use crate ::regs; +use crate ::{ + driver::Bar0 , + fb::hal::FbHal , + regs,// +};use super ::tu102::FLUSH_SYSMEM_ADDR_SHIFT ; +struct Ga100 ; +pub (super )fn read_sysmem_flush_page_ga100 (bar: &Bar0 ) ->u64 { u64::from (regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR ::read (bar).adr_39_08 ()) <<FLUSH_SYSMEM_ADDR_SHIFT | u64::from (regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR_HI ::read (bar).adr_63_40 ())
drivers/gpu/nova-core/fb/hal/ga102.rs +5 -3
@@ -2,9 +2,11 @@use kernel::prelude::*; -use crate ::driver::Bar0 ; -use crate ::fb::hal::FbHal ; -use crate ::regs; +use crate ::{ + driver::Bar0 , + fb::hal::FbHal , + regs,// +};fn vidmem_size_ga102 (bar: &Bar0 ) ->u64 { regs::NV_USABLE_FB_SIZE_IN_MB ::read (bar).usable_fb_size ()
drivers/gpu/nova-core/fb/hal/tu102.rs +6 -3
@@ -1,10 +1,13 @@// SPDX-License-Identifier: GPL-2.0 -use crate ::driver::Bar0 ; -use crate ::fb::hal::FbHal ; -use crate ::regs;use kernel::prelude::*; +use crate ::{ + driver::Bar0 , + fb::hal::FbHal , + regs,// +}; +/// Shift applied to the sysmem address before it is written into `NV_PFB_NISO_FLUSH_SYSMEM_ADDR`, /// to be used by HALs. pub (super )const FLUSH_SYSMEM_ADDR_SHIFT :u32 =8 ;
drivers/gpu/nova-core/firmware.rs +18 -12
@@ -3,18 +3,24 @@//! Contains structures and functions dedicated to the parsing, building and patching of firmwares //! to be loaded into a given execution unit. -use core::marker::PhantomData ; -use core::mem::size_of; - -use kernel::device; -use kernel::firmware; -use kernel::prelude::*; -use kernel::str::CString ; -use kernel::transmute::FromBytes ; - -use crate ::dma::DmaObject ; -use crate ::falcon::FalconFirmware ; -use crate ::gpu; +use core::{ + marker::PhantomData , + mem::size_of,// +}; + +use kernel::{ + device, + firmware, + prelude::*, + str::CString , + transmute::FromBytes ,// +}; + +use crate ::{ + dma::DmaObject , + falcon::FalconFirmware , + gpu,// +};pub (crate )mod booter;pub (crate )mod fwsec;
drivers/gpu/nova-core/firmware/booter.rs +32 -14
52 lines not on this page · raw message
drivers/gpu/nova-core/firmware/fwsec.rs +38 -14
58 lines not on this page · raw message
drivers/gpu/nova-core/firmware/gsp.rs +23 -10
@@ -2,16 +2,29 @@use core::mem::size_of_val; -use kernel::device; -use kernel::dma::{DataDirection ,DmaAddress }; -use kernel::kvec; -use kernel::prelude::*; -use kernel::scatterlist::{Owned ,SGTable }; - -use crate ::dma::DmaObject ; -use crate ::firmware::riscv::RiscvFirmware ; -use crate ::gpu::{Architecture ,Chipset }; -use crate ::gsp::GSP_PAGE_SIZE ; +use kernel::{ + device, + dma::{ +DataDirection , +DmaAddress ,// + }, + kvec, + prelude::*, + scatterlist::{ +Owned , +SGTable ,// + },// +}; + +use crate ::{ + dma::DmaObject , + firmware::riscv::RiscvFirmware , + gpu::{ +Architecture , +Chipset ,// + }, + gsp::GSP_PAGE_SIZE ,// +};/// Ad-hoc and temporary module to extract sections from ELF images. ///
drivers/gpu/nova-core/firmware/riscv.rs +10 -6
@@ -5,13 +5,17 @@use core::mem::size_of; -use kernel::device; -use kernel::firmware::Firmware ; -use kernel::prelude::*; -use kernel::transmute::FromBytes ; +use kernel::{ + device, + firmware::Firmware , + prelude::*, + transmute::FromBytes ,// +}; -use crate ::dma::DmaObject ; -use crate ::firmware::BinFirmware ; +use crate ::{ + dma::DmaObject , + firmware::BinFirmware ,// +};/// Descriptor for microcode running on a RISC-V core. #[repr( C )]
drivers/gpu/nova-core/gfw.rs +9 -5
@@ -18,12 +18,16 @@//! //! Note that the devinit sequence also needs to run during suspend/resume. -use kernel::io::poll::read_poll_timeout; -use kernel::prelude::*; -use kernel::time::Delta ; +use kernel::{ + io::poll::read_poll_timeout, + prelude::*, + time::Delta ,// +}; -use crate ::driver::Bar0 ; -use crate ::regs; +use crate ::{ + driver::Bar0 , + regs,// +};/// Wait for the `GFW` (GPU firmware) boot completion signal (`GFW_BOOT`), or a 4 seconds timeout. ///
drivers/gpu/nova-core/gpu.rs +22 -8
@@ -1,13 +1,27 @@// SPDX-License-Identifier: GPL-2.0 -use kernel::{device, devres::Devres , error::code::*, fmt, pci, prelude::*, sync::Arc }; - -use crate ::driver::Bar0 ; -use crate ::falcon::{gsp::Gsp as GspFalcon , sec2::Sec2 as Sec2Falcon ,Falcon }; -use crate ::fb::SysmemFlush ; -use crate ::gfw; -use crate ::gsp::Gsp ; -use crate ::regs; +use kernel::{ + device, + devres::Devres , + error::code::*, + fmt, + pci, + prelude::*, + sync::Arc ,// +}; + +use crate ::{ + driver::Bar0 , + falcon::{ + gsp::Gsp as GspFalcon , + sec2::Sec2 as Sec2Falcon , +Falcon ,// + }, + fb::SysmemFlush , + gfw, + gsp::Gsp , + regs,// +};macro_rules! define_chipset { ({ $($variant:ident = $value:expr),* $(,)* }) =>
drivers/gpu/nova-core/gsp/boot.rs +29 -15
50 lines not on this page · raw message
drivers/gpu/nova-core/regs.rs +19 -5
@@ -7,13 +7,27 @@#[macro_use] pub (crate )mod macros; -use crate ::falcon::{ -DmaTrfCmdSize ,FalconCoreRev ,FalconCoreRevSubversion ,FalconFbifMemType ,FalconFbifTarget , -FalconModSelAlgo ,FalconSecurityModel ,PFalcon2Base ,PFalconBase ,PeregrineCoreSelect , -}; -use crate ::gpu::{Architecture ,Chipset };use kernel::prelude::*; +use crate ::{ + falcon::{ +DmaTrfCmdSize , +FalconCoreRev , +FalconCoreRevSubversion , +FalconFbifMemType , +FalconFbifTarget , +FalconModSelAlgo , +FalconSecurityModel , +PFalcon2Base , +PFalconBase , +PeregrineCoreSelect ,// + }, + gpu::{ +Architecture , +Chipset ,// + },// +}; +// PMC register! (NV_PMC_BOOT_0 @0x00000000 ,"Basic revision information about the GPU" {
drivers/gpu/nova-core/vbios.rs +20 -9
@@ -2,16 +2,27 @@//! VBIOS extraction and parsing. -use crate ::driver::Bar0 ; -use crate ::firmware::fwsec::Bcrt30Rsa3kSignature ; -use crate ::firmware::FalconUCodeDescV3 ;use core::convert::TryFrom ; -use kernel::device; -use kernel::error::Result ; -use kernel::prelude::*; -use kernel::ptr::{Alignable ,Alignment }; -use kernel::transmute::FromBytes ; -use kernel::types::ARef ; + +use kernel::{ + device, + error::Result , + prelude::*, + ptr::{ +Alignable , +Alignment ,// + }, + transmute::FromBytes , + types::ARef ,// +}; + +use crate ::{ + driver::Bar0 , + firmware::{ + fwsec::Bcrt30Rsa3kSignature , +FalconUCodeDescV3 ,// + },// +};/// The offset of the VBIOS ROM in the BAR0 space. const ROM_OFFSET :usize =0x300000 ;
base-commit: ade19c5060dfa39b84a9475a4a6b05e2a8a2b3ac
Signature · 1 line
2.51.2
Alexandre Courbot
maintainerQuoted 9 lines · John Hubbard
As per [1], we need one "use" item per line, in order to reduce merge conflicts. Furthermore, we need a trailing ", //" in order to tell rustfmt(1) to leave it alone.
This does that for the entire nova-core driver.
[1] https://docs.kernel.org/rust/coding-guidelines.html#imports
Signed-off-by John Hubbard <[email protected]>
Thanks a lot for this! I think we will want to merge this one before anything else so series currently under review can be rebased.
I will push this tomorrow unless someone objects by then.
Quoted 9 lines · John Hubbard
As per [1], we need one "use" item per line, in order to reduce merge conflicts. Furthermore, we need a trailing ", //" in order to tell rustfmt(1) to leave it alone.
This does that for the entire nova-core driver.
[1] https://docs.kernel.org/rust/coding-guidelines.html#imports
Signed-off-by John Hubbard <[email protected]>
Thanks for doing this!
Few nits below, I assume Alex will fix them up on apply, so no need to resend.
With those fixed,
Quoted 10 lines
drivers/gpu/nova-core/fb.rs +0
-2@@ -2,16 +2,24 @@use core::ops::Range ; -use kernel::prelude::*; -use kernel::ptr::{Alignable ,Alignment };
drivers/gpu/nova-core/fb.rs line 6
Quoted 10 lines
drivers/gpu/nova-core/fb.rs +2
-8-use kernel::sizes::*; -use kernel::sync::aref::ARef ; -use kernel::{dev_warn, device}; - -use crate ::dma::DmaObject ; -use crate ::driver::Bar0 ; -use crate ::gpu::Chipset ; -use crate ::regs; +use kernel::{ + dev_warn,
Should be in prelude and hence can be dropped.
Quoted 16 lines
drivers/gpu/nova-core/fb.rs +16
-0+ device, + prelude::*, + ptr::{ + Alignable, + Alignment, // + }, + sizes::*, + sync::aref::ARef, // +}; + +use crate ::{ + dma::DmaObject , + driver::Bar0 , + gpu::Chipset , + regs,// +};
<snip>
Quoted 13 lines
drivers/gpu/nova-core/firmware.rs +0
-5@@ -3,18 +3,24 @@//! Contains structures and functions dedicated to the parsing, building and patching of firmwares //! to be loaded into a given execution unit. -use core::marker::PhantomData ; -use core::mem::size_of; - -use kernel::device; -use kernel::firmware;
drivers/gpu/nova-core/firmware.rs line 8
Quoted 10 lines
drivers/gpu/nova-core/firmware.rs +3
-7-use kernel::prelude::*; -use kernel::str::CString ; -use kernel::transmute::FromBytes ; - -use crate ::dma::DmaObject ; -use crate ::falcon::FalconFirmware ; -use crate ::gpu; +use core::{ + marker::PhantomData , + mem::size_of,//
Should be in prelude.
Quoted 33 lines
drivers/gpu/nova-core/firmware.rs +15
-0+}; + +use kernel::{ + device, + firmware, + prelude::*, + str::CString , + transmute::FromBytes ,// +}; + +use crate ::{ + dma::DmaObject , + falcon::FalconFirmware , + gpu,// +};pub (crate )mod booter;pub (crate )mod fwsec;drivers/gpu/nova-core/firmware/booter.rs +0
-7@@ -4,20 +4,38 @@//! running on [`Sec2`], that is used on Turing/Ampere to load the GSP firmware into the GSP falcon //! (and optionally unload it through a separate firmware image). -use core::marker::PhantomData ; -use core::mem::size_of; -use core::ops::Deref ; - -use kernel::device; -use kernel::prelude::*; -use kernel::transmute::FromBytes ;
drivers/gpu/nova-core/firmware/booter.rs line 9
Quoted 10 lines
drivers/gpu/nova-core/firmware/booter.rs +3
-7- -use crate ::dma::DmaObject ; -use crate ::driver::Bar0 ; -use crate ::falcon::sec2::Sec2 ; -use crate ::falcon::{Falcon ,FalconBromParams ,FalconFirmware ,FalconLoadParams ,FalconLoadTarget }; -use crate ::firmware::{BinFirmware ,FirmwareDmaObject ,FirmwareSignature ,Signed ,Unsigned }; -use crate ::gpu::Chipset ; +use core::{ + marker::PhantomData , + mem::size_of,
Same here...
Quoted 29 lines
drivers/gpu/nova-core/firmware/booter.rs +29
-0+ ops::Deref, // +}; + +use kernel::{ + device, + prelude::*, + transmute::FromBytes ,// +}; + +use crate ::{ + dma::DmaObject , + driver::Bar0 , + falcon::{ + sec2::Sec2 , +Falcon , +FalconBromParams , +FalconFirmware , +FalconLoadParams , +FalconLoadTarget ,// + }, + firmware::{ +BinFirmware , +FirmwareDmaObject , +FirmwareSignature , +Signed , +Unsigned ,// + }, + gpu::Chipset ,// +};
<snip>
Quoted 9 lines
drivers/gpu/nova-core/gpu.rs +0
-2@@ -1,13 +1,27 @@// SPDX-License-Identifier: GPL-2.0 -use kernel::{device, devres::Devres , error::code::*, fmt, pci, prelude::*, sync::Arc }; -
drivers/gpu/nova-core/gpu.rs line 6
Quoted 10 lines
drivers/gpu/nova-core/gpu.rs +4
-6-use crate ::driver::Bar0 ; -use crate ::falcon::{gsp::Gsp as GspFalcon , sec2::Sec2 as Sec2Falcon ,Falcon }; -use crate ::fb::SysmemFlush ; -use crate ::gfw; -use crate ::gsp::Gsp ; -use crate ::regs; +use kernel::{ + device, + devres::Devres , + error::code::*,
That's also in prelude.
Quoted 18 lines
drivers/gpu/nova-core/gpu.rs +18
-0+ fmt, + pci, + prelude::*, + sync::Arc, // +}; + +use crate ::{ + driver::Bar0 , + falcon::{ + gsp::Gsp as GspFalcon , + sec2::Sec2 as Sec2Falcon , +Falcon ,// + }, + fb::SysmemFlush , + gfw, + gsp::Gsp , + regs,// +};
<snip>
Quoted 12 lines
drivers/gpu/nova-core/vbios.rs +0
-3@@ -2,16 +2,27 @@//! VBIOS extraction and parsing. -use crate ::driver::Bar0 ; -use crate ::firmware::fwsec::Bcrt30Rsa3kSignature ; -use crate ::firmware::FalconUCodeDescV3 ;use core::convert::TryFrom ;
drivers/gpu/nova-core/vbios.rs line 9
Quoted 10 lines
drivers/gpu/nova-core/vbios.rs +4
-6-use kernel::device; -use kernel::error::Result ; -use kernel::prelude::*; -use kernel::ptr::{Alignable ,Alignment }; -use kernel::transmute::FromBytes ; -use kernel::types::ARef ; + +use kernel::{ + device, + error::Result ,
prelude
Quoted 16 lines
drivers/gpu/nova-core/vbios.rs +16
-0+ prelude::*, + ptr::{ + Alignable, + Alignment, // + }, + transmute::FromBytes, + types::ARef, // +}; + +use crate ::{ + driver::Bar0 , + firmware::{ + fwsec::Bcrt30Rsa3kSignature , +FalconUCodeDescV3 ,// + },// +};
Quoted 11 lines · Danilo Krummrich
Quoted 9 lines · John Hubbard
As per [1], we need one "use" item per line, in order to reduce merge conflicts. Furthermore, we need a trailing ", //" in order to tell rustfmt(1) to leave it alone.
This does that for the entire nova-core driver.
[1] https://docs.kernel.org/rust/coding-guidelines.html#imports
Signed-off-by John Hubbard <[email protected]>
Quoted 7 lines
Thanks for doing this!
Few nits below, I assume Alex will fix them up on apply, so no need to resend.
With those fixed,
Acked-by Danilo Krummrich <[email protected]>
Applied these suggestions, thanks!
I've also noticed that sometimes the trailing // on the final line are not always necessary if some intermediate sub-blocks already had one, I've also removed such cases that do not affect rustfmt.
Planning on pushing tomorrow.