Skip to content

Commit

Permalink
drm/asahi: fw.channels: Add static assertions for message sizes
Browse files Browse the repository at this point in the history
Signed-off-by: Asahi Lina <[email protected]>
  • Loading branch information
asahilina committed Aug 3, 2023
1 parent d1d0846 commit 5c5368d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/gpu/drm/asahi/fw/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use super::types::*;
use crate::default_zeroed;
use core::sync::atomic::Ordering;
use kernel::static_assert;

pub(crate) mod raw {
use super::*;
Expand Down Expand Up @@ -215,6 +216,9 @@ pub(crate) enum DeviceControlMsg {
Initialize(Pad<DEVICECONTROL_SZ::ver>), // Update RegionC
}

#[versions(AGX)]
static_assert!(core::mem::size_of::<DeviceControlMsg::ver>() == 4 + DEVICECONTROL_SZ::ver);

#[versions(AGX)]
default_zeroed!(DeviceControlMsg::ver);

Expand Down Expand Up @@ -256,6 +260,8 @@ pub(crate) enum EventMsg {
}, // Max discriminant: 0x7
}

static_assert!(core::mem::size_of::<EventMsg>() == 4 + EVENT_SZ);

pub(crate) const EVENT_MAX: u32 = 0x7;

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -392,6 +398,9 @@ pub(crate) enum StatsMsg {
}, // Max discriminant: 0xe
}

#[versions(AGX)]
static_assert!(core::mem::size_of::<StatsMsg::ver>() == 4 + STATS_SZ::ver);

#[versions(AGX)]
pub(crate) const STATS_MAX: u32 = 0xe;

Expand Down

0 comments on commit 5c5368d

Please sign in to comment.