mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 13:06:59 +02:00
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 <acourbot@nvidia.com> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Acked-by: Alexandre Courbot <acourbot@nvidia.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
ea60cea07d
commit
f3f6b36643
|
|
@ -147,7 +147,6 @@ Numerical operations [NUMM]
|
|||
Nova uses integer operations that are not part of the standard library (or not
|
||||
implemented in an optimized way for the kernel). These include:
|
||||
|
||||
- Aligning up and down to a power of two,
|
||||
- The "Find Last Set Bit" (`fls` function of the C part of the kernel)
|
||||
operation.
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
use core::ops::Range;
|
||||
|
||||
use kernel::prelude::*;
|
||||
use kernel::ptr::{Alignable, Alignment};
|
||||
use kernel::sizes::*;
|
||||
use kernel::types::ARef;
|
||||
use kernel::{dev_warn, device};
|
||||
|
|
@ -130,10 +131,9 @@ pub(crate) fn new(chipset: Chipset, bar: &Bar0) -> Result<Self> {
|
|||
};
|
||||
|
||||
let frts = {
|
||||
const FRTS_DOWN_ALIGN: u64 = SZ_128K as u64;
|
||||
const FRTS_DOWN_ALIGN: Alignment = Alignment::new::<SZ_128K>();
|
||||
const FRTS_SIZE: u64 = SZ_1M as u64;
|
||||
// TODO[NUMM]: replace with `align_down` once it lands.
|
||||
let frts_base = (vga_workspace.start & !(FRTS_DOWN_ALIGN - 1)) - FRTS_SIZE;
|
||||
let frts_base = vga_workspace.start.align_down(FRTS_DOWN_ALIGN) - FRTS_SIZE;
|
||||
|
||||
frts_base..frts_base + FRTS_SIZE
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
use kernel::error::Result;
|
||||
use kernel::pci;
|
||||
use kernel::prelude::*;
|
||||
use kernel::ptr::{Alignable, Alignment};
|
||||
|
||||
/// The offset of the VBIOS ROM in the BAR0 space.
|
||||
const ROM_OFFSET: usize = 0x300000;
|
||||
|
|
@ -177,8 +178,7 @@ fn next(&mut self) -> Option<Self::Item> {
|
|||
|
||||
// Advance to next image (aligned to 512 bytes).
|
||||
self.current_offset += image_size;
|
||||
// TODO[NUMM]: replace with `align_up` once it lands.
|
||||
self.current_offset = self.current_offset.next_multiple_of(512);
|
||||
self.current_offset = self.current_offset.align_up(Alignment::new::<512>())?;
|
||||
|
||||
Some(Ok(full_image))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user