Skip to content

Commit e10dcb9

Browse files
committed
gpu: nova-core: firmware: gsp: use dma::Coherent for level0 table
Replace the nova-core local `DmaObject` with a `CoherentBox` that can fulfill the same role. Since `CoherentBox` is more flexible than `DmaObject`, we can use the native `u64` type for page table entries instead of messing with bytes. The `dma` module becomes unused with that change, so remove it as well. Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260327-b4-nova-dma-removal-v2-7-616e1d0b5cb3@nvidia.com Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
1 parent 371db8b commit e10dcb9

3 files changed

Lines changed: 12 additions & 64 deletions

File tree

drivers/gpu/nova-core/dma.rs

Lines changed: 0 additions & 53 deletions
This file was deleted.

drivers/gpu/nova-core/firmware/gsp.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use kernel::{
44
device,
55
dma::{
66
Coherent,
7+
CoherentBox,
78
DataDirection,
89
DmaAddress, //
910
},
10-
kvec,
1111
prelude::*,
1212
scatterlist::{
1313
Owned,
@@ -16,7 +16,6 @@ use kernel::{
1616
};
1717

1818
use crate::{
19-
dma::DmaObject,
2019
firmware::riscv::RiscvFirmware,
2120
gpu::{
2221
Architecture,
@@ -137,7 +136,7 @@ pub(crate) struct GspFirmware {
137136
#[pin]
138137
level1: SGTable<Owned<VVec<u8>>>,
139138
/// Level 0 page table (single 4KB page) with one entry: DMA address of first level 1 page.
140-
level0: DmaObject,
139+
level0: Coherent<[u64]>,
141140
/// Size in bytes of the firmware contained in [`Self::fw`].
142141
pub(crate) size: usize,
143142
/// Device-mapped GSP signatures matching the GPU's [`Chipset`].
@@ -198,17 +197,20 @@ impl GspFirmware {
198197
// Allocate the level 0 page table as a device-visible DMA object, and map the
199198
// level 1 page table onto it.
200199

201-
// Level 0 page table data.
202-
let mut level0_data = kvec![0u8; GSP_PAGE_SIZE]?;
203-
204200
// Fill level 1 page entry.
205201
let level1_entry = level1.iter().next().ok_or(EINVAL)?;
206202
let level1_entry_addr = level1_entry.dma_address();
207-
let dst = &mut level0_data[..size_of_val(&level1_entry_addr)];
208-
dst.copy_from_slice(&level1_entry_addr.to_le_bytes());
209203

210-
// Turn the level0 page table into a [`DmaObject`].
211-
DmaObject::from_data(dev, &level0_data)?
204+
// Create level 0 page table data and fill its first entry with the level 1
205+
// table.
206+
let mut level0 = CoherentBox::<[u64]>::zeroed_slice(
207+
dev,
208+
GSP_PAGE_SIZE / size_of::<u64>(),
209+
GFP_KERNEL
210+
)?;
211+
level0[0] = level1_entry_addr.to_le();
212+
213+
level0.into()
212214
},
213215
size,
214216
signatures: {

drivers/gpu/nova-core/nova_core.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use kernel::{
1313
#[macro_use]
1414
mod bitfield;
1515

16-
mod dma;
1716
mod driver;
1817
mod falcon;
1918
mod fb;

0 commit comments

Comments
 (0)