From 78ca48394009a6383d416e5778206bce2bec7bb9 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 22 Jan 2025 15:13:16 -0500 Subject: [PATCH] ail: add ail_bytes_to_pages helper this happens a bunch with sparse Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/layout/layout.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h index 914bae15ce5..51fdaae3420 100644 --- a/src/asahi/layout/layout.h +++ b/src/asahi/layout/layout.h @@ -520,6 +520,13 @@ ail_drm_modifier_to_tiling(uint64_t modifier) #define AIL_FOLIO_SIZE_EL (AIL_PAGES_PER_FOLIO * 2) #define AIL_FOLIO_SIZE_B (AIL_FOLIO_SIZE_EL * AIL_SPARSE_ELSIZE_B) +static inline unsigned +ail_bytes_to_pages(unsigned x_B) +{ + assert((x_B % AIL_PAGESIZE) == 0); + return x_B / AIL_PAGESIZE; +} + /* * Map a logical page of the image (i.e. page = logical address / page_size) to * a word-index into the sparse table.