Skip to content

Commit f3f6b36

Browse files
Gnurouojeda
authored andcommitted
gpu: nova-core: use Alignment for alignment-related operations
Make use of the newly-available `Alignment` type and remove the corresponding TODO item. Signed-off-by: Alexandre Courbot <[email protected]> Reviewed-by: Danilo Krummrich <[email protected]> Acked-by: Alexandre Courbot <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent ea60cea commit f3f6b36

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

Documentation/gpu/nova/core/todo.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ Numerical operations [NUMM]
147147
Nova uses integer operations that are not part of the standard library (or not
148148
implemented in an optimized way for the kernel). These include:
149149

150-
- Aligning up and down to a power of two,
151150
- The "Find Last Set Bit" (`fls` function of the C part of the kernel)
152151
operation.
153152

drivers/gpu/nova-core/fb.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use core::ops::Range;
44

55
use kernel::prelude::*;
6+
use kernel::ptr::{Alignable, Alignment};
67
use kernel::sizes::*;
78
use kernel::types::ARef;
89
use kernel::{dev_warn, device};
@@ -130,10 +131,9 @@ impl FbLayout {
130131
};
131132

132133
let frts = {
133-
const FRTS_DOWN_ALIGN: u64 = SZ_128K as u64;
134+
const FRTS_DOWN_ALIGN: Alignment = Alignment::new::<SZ_128K>();
134135
const FRTS_SIZE: u64 = SZ_1M as u64;
135-
// TODO[NUMM]: replace with `align_down` once it lands.
136-
let frts_base = (vga_workspace.start & !(FRTS_DOWN_ALIGN - 1)) - FRTS_SIZE;
136+
let frts_base = vga_workspace.start.align_down(FRTS_DOWN_ALIGN) - FRTS_SIZE;
137137

138138
frts_base..frts_base + FRTS_SIZE
139139
};

drivers/gpu/nova-core/vbios.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use kernel::device;
1010
use kernel::error::Result;
1111
use kernel::pci;
1212
use kernel::prelude::*;
13+
use kernel::ptr::{Alignable, Alignment};
1314

1415
/// The offset of the VBIOS ROM in the BAR0 space.
1516
const ROM_OFFSET: usize = 0x300000;
@@ -177,8 +178,7 @@ impl<'a> Iterator for VbiosIterator<'a> {
177178

178179
// Advance to next image (aligned to 512 bytes).
179180
self.current_offset += image_size;
180-
// TODO[NUMM]: replace with `align_up` once it lands.
181-
self.current_offset = self.current_offset.next_multiple_of(512);
181+
self.current_offset = self.current_offset.align_up(Alignment::new::<512>())?;
182182

183183
Some(Ok(full_image))
184184
}

0 commit comments

Comments
 (0)