[Intel-xe] [PATCH] drm/xe: Align size to PAGE_SIZE

Lucas De Marchi lucas.demarchi at intel.com
Wed Sep 20 19:24:40 UTC 2023


On Wed, Sep 20, 2023 at 11:24:31PM +0530, Pallavi Mishra wrote:
>Ensure alignment with PAGE_SIZE for the size parameter
>passed to __xe_bo_create_locked()
>
>Signed-off-by: Pallavi Mishra <pallavi.mishra at intel.com>
>---
> drivers/gpu/drm/xe/xe_bo.c | 3 +++
> 1 file changed, 3 insertions(+)
>
>diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
>index 1ab682d61e3c..014d084632f2 100644
>--- a/drivers/gpu/drm/xe/xe_bo.c
>+++ b/drivers/gpu/drm/xe/xe_bo.c
>@@ -1199,6 +1199,9 @@ struct xe_bo *__xe_bo_create_locked(struct xe_device *xe, struct xe_bo *bo,
> 	/* Only kernel objects should set GT */
> 	XE_WARN_ON(tile && type != ttm_bo_type_kernel);
>
>+	if ((size & (PAGE_SIZE - 1)) != 0)

ALIGN()... but note that there is already a call to ALIGN() a few lines
below this hunk. Probably missing the `size = ALIGN(size, PAGE_SIZE)` in
the else condition?

Lucas De Marchi

>+		size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
>+
> 	if (XE_WARN_ON(!size)) {
> 		xe_bo_free(bo);
> 		return ERR_PTR(-EINVAL);
>-- 
>2.25.1
>


More information about the Intel-xe mailing list