Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpu: nova-core: use Coherent::init to initialize GspFwWprMeta

Convert wpr_meta to use Coherent::init() and simplify the
initialization. It also avoids a separate initialization of
GspFwWprMeta on the stack.

Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260320194626.36263-7-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

+17 -10
+2 -5
drivers/gpu/nova-core/gsp/boot.rs
··· 2 2 3 3 use kernel::{ 4 4 device, 5 - dma::CoherentAllocation, 6 - dma_write, 5 + dma::Coherent, 7 6 io::poll::read_poll_timeout, 8 7 pci, 9 8 prelude::*, ··· 163 164 bar, 164 165 )?; 165 166 166 - let wpr_meta = 167 - CoherentAllocation::<GspFwWprMeta>::alloc_coherent(dev, 1, GFP_KERNEL | __GFP_ZERO)?; 168 - dma_write!(wpr_meta, [0]?, GspFwWprMeta::new(&gsp_fw, &fb_layout)); 167 + let wpr_meta = Coherent::init(dev, GFP_KERNEL, GspFwWprMeta::new(&gsp_fw, &fb_layout))?; 169 168 170 169 self.cmdq 171 170 .send_command_no_wait(bar, commands::SetSystemInfo::new(pdev))?;
+15 -5
drivers/gpu/nova-core/gsp/fw.rs
··· 204 204 /// Structure passed to the GSP bootloader, containing the framebuffer layout as well as the DMA 205 205 /// addresses of the GSP bootloader and firmware. 206 206 #[repr(transparent)] 207 - pub(crate) struct GspFwWprMeta(bindings::GspFwWprMeta); 207 + pub(crate) struct GspFwWprMeta { 208 + inner: bindings::GspFwWprMeta, 209 + } 208 210 209 211 // SAFETY: Padding is explicit and does not contain uninitialized data. 210 212 unsafe impl AsBytes for GspFwWprMeta {} ··· 219 217 type GspFwWprMetaBootInfo = bindings::GspFwWprMeta__bindgen_ty_1__bindgen_ty_1; 220 218 221 219 impl GspFwWprMeta { 222 - /// Fill in and return a `GspFwWprMeta` suitable for booting `gsp_firmware` using the 220 + /// Returns an initializer for a `GspFwWprMeta` suitable for booting `gsp_firmware` using the 223 221 /// `fb_layout` layout. 224 - pub(crate) fn new(gsp_firmware: &GspFirmware, fb_layout: &FbLayout) -> Self { 225 - Self(bindings::GspFwWprMeta { 222 + pub(crate) fn new<'a>( 223 + gsp_firmware: &'a GspFirmware, 224 + fb_layout: &'a FbLayout, 225 + ) -> impl Init<Self> + 'a { 226 + #[allow(non_snake_case)] 227 + let init_inner = init!(bindings::GspFwWprMeta { 226 228 // CAST: we want to store the bits of `GSP_FW_WPR_META_MAGIC` unmodified. 227 229 magic: bindings::GSP_FW_WPR_META_MAGIC as u64, 228 230 revision: u64::from(bindings::GSP_FW_WPR_META_REVISION), ··· 261 255 fbSize: fb_layout.fb.end - fb_layout.fb.start, 262 256 vgaWorkspaceOffset: fb_layout.vga_workspace.start, 263 257 vgaWorkspaceSize: fb_layout.vga_workspace.end - fb_layout.vga_workspace.start, 264 - ..Default::default() 258 + ..Zeroable::init_zeroed() 259 + }); 260 + 261 + init!(GspFwWprMeta { 262 + inner <- init_inner, 265 263 }) 266 264 } 267 265 }