[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240324224720.1345309-64-sashal@kernel.org>
Date: Sun, 24 Mar 2024 18:36:29 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Matthew Auld <matthew.auld@...el.com>,
Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@....com>,
Christian König <christian.koenig@....com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 6.7 063/713] drm/buddy: check range allocation matches alignment
From: Matthew Auld <matthew.auld@...el.com>
[ Upstream commit 2986314aa811c8a23aeb292edd30315495d54966 ]
Likely not a big deal for real users, but for consistency we should
respect the min_page_size here. Main issue is that bias allocations
turns into normal range allocation if the range and size matches
exactly, and in the next patch we want to add some unit tests for this
part of the api.
Signed-off-by: Matthew Auld <matthew.auld@...el.com>
Cc: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@....com>
Cc: Christian König <christian.koenig@....com>
Reviewed-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@....com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240219121851.25774-5-matthew.auld@intel.com
Signed-off-by: Christian König <christian.koenig@....com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/gpu/drm/drm_buddy.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
index f3a6ac908f815..5ebdd6f8f36e6 100644
--- a/drivers/gpu/drm/drm_buddy.c
+++ b/drivers/gpu/drm/drm_buddy.c
@@ -771,8 +771,12 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm,
return -EINVAL;
/* Actual range allocation */
- if (start + size == end)
+ if (start + size == end) {
+ if (!IS_ALIGNED(start | end, min_block_size))
+ return -EINVAL;
+
return __drm_buddy_alloc_range(mm, start, size, NULL, blocks);
+ }
original_size = size;
original_min_size = min_block_size;
--
2.43.0
Powered by blists - more mailing lists