Skip to content

Commit 7e05eea

Browse files
committed
drm/asahi: Get rid of util::div_ceil()
This is a primitive method these days. Signed-off-by: Asahi Lina <[email protected]>
1 parent c9f91cc commit 7e05eea

3 files changed

Lines changed: 12 additions & 29 deletions

File tree

drivers/gpu/drm/asahi/buffer.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,12 @@ impl Buffer::ver {
457457
used as usize
458458
});
459459

460-
let need_blocks = div_ceil(used_pages * 2, PAGES_PER_BLOCK).min(inner.max_blocks_nomemless);
461-
let want_blocks = div_ceil(used_pages * 3, PAGES_PER_BLOCK).min(inner.max_blocks_nomemless);
460+
let need_blocks = (used_pages * 2)
461+
.div_ceil(PAGES_PER_BLOCK)
462+
.min(inner.max_blocks_nomemless);
463+
let want_blocks = (used_pages * 3)
464+
.div_ceil(PAGES_PER_BLOCK)
465+
.min(inner.max_blocks_nomemless);
462466

463467
let cur_count = inner.blocks.len();
464468

drivers/gpu/drm/asahi/queue/render.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ impl super::QueueInner::ver {
121121

122122
let utiles_per_tile = utiles_per_tile_x * utiles_per_tile_y;
123123

124-
let tiles_x = (width + tile_width - 1) / tile_width;
125-
let tiles_y = (height + tile_height - 1) / tile_height;
124+
let tiles_x = width.div_ceil(tile_width);
125+
let tiles_y = height.div_ceil(tile_height);
126126
let tiles = tiles_x * tiles_y;
127127

128128
let mtiles_x = 4u32;
129129
let mtiles_y = 4u32;
130130
let mtiles = mtiles_x * mtiles_y;
131131

132-
let tiles_per_mtile_x = align(div_ceil(tiles_x, mtiles_x), 4);
133-
let tiles_per_mtile_y = align(div_ceil(tiles_y, mtiles_y), 4);
132+
let tiles_per_mtile_x = align(tiles_x.div_ceil(mtiles_x), 4);
133+
let tiles_per_mtile_y = align(tiles_y.div_ceil(mtiles_y), 4);
134134
let tiles_per_mtile = tiles_per_mtile_x * tiles_per_mtile_y;
135135

136136
let mtile_x1 = tiles_per_mtile_x;
@@ -156,15 +156,12 @@ impl super::QueueInner::ver {
156156
// GUESS: Number of 32K heap blocks to fit a 5-byte region header/pointer per tile?
157157
// That would make a ton of sense...
158158
let meta1_layer_stride = if num_clusters > 1 {
159-
div_ceil(
160-
align(tiles_x, 2) * align(tiles_y, 4) * utiles_per_tile,
161-
0x1980,
162-
)
159+
(align(tiles_x, 2) * align(tiles_y, 4) * utiles_per_tile).div_ceil(0x1980)
163160
} else {
164161
0
165162
};
166163

167-
let mut min_tvb_blocks = align(div_ceil(tiles_x * tiles_y, 128), 8);
164+
let mut min_tvb_blocks = align((tiles_x * tiles_y).div_ceil(128), 8);
168165

169166
if num_clusters > 1 {
170167
min_tvb_blocks = min_tvb_blocks.max(7 + 2 * layers);

drivers/gpu/drm/asahi/util.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,6 @@ where
4545
a & !(b - one)
4646
}
4747

48-
/// Integer division rounding up.
49-
pub(crate) fn div_ceil<T>(a: T, b: T) -> T
50-
where
51-
T: Copy
52-
+ Default
53-
+ BitAnd<Output = T>
54-
+ Not<Output = T>
55-
+ Add<Output = T>
56-
+ Sub<Output = T>
57-
+ Div<Output = T>,
58-
{
59-
let def: T = Default::default();
60-
#[allow(clippy::eq_op)]
61-
let one: T = !def / !def;
62-
63-
(a + b - one) / b
64-
}
65-
6648
pub(crate) trait RangeExt<T> {
6749
fn overlaps(&self, other: Self) -> bool;
6850
fn is_superset(&self, other: Self) -> bool;

0 commit comments

Comments
 (0)