diff options
author | Dave Airlie <airlied@redhat.com> | 2024-01-16 11:49:46 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2024-01-16 11:49:46 +1000 |
commit | f6efb996a97abea2954b3bad38f2617712015844 (patch) | |
tree | 8f652a005c05797efbcb52e8bb15c22f530bf403 /drivers/gpu/drm/nova/driver.rs | |
parent | b6214aa6152cc7adf23f14d3c12bbd03ae2829d4 (diff) |
nova: add a gsp object with fw / radix3wip/fw-loader
The radix3 impl in this needs some scatterlist bindings I expect.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nova/driver.rs')
-rw-r--r-- | drivers/gpu/drm/nova/driver.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nova/driver.rs b/drivers/gpu/drm/nova/driver.rs index 33abf2545994..84e01dc04f82 100644 --- a/drivers/gpu/drm/nova/driver.rs +++ b/drivers/gpu/drm/nova/driver.rs @@ -22,6 +22,29 @@ struct NovaDevice; /// BAR Size pub(crate) const BAR_SIZE: usize = 16777216; +use core::ops::{Add, BitAnd, Div, Not, Sub}; + +/// Aligns an integer type to a power of two. +pub(crate) fn align<T>(a: T, b: T) -> T +where + T: Copy + + Default + + BitAnd<Output = T> + + Not<Output = T> + + Add<Output = T> + + Sub<Output = T> + + Div<Output = T> + + core::cmp::PartialEq, +{ + let def: T = Default::default(); + #[allow(clippy::eq_op)] + let one: T = !def / !def; + + assert!((b & (b - one)) == def); + + (a + b - one) & !(b - one) +} + impl pci::Driver for NovaDevice { define_pci_id_table! { |