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

Mishra, Pallavi pallavi.mishra at intel.com
Wed Sep 20 19:30:16 UTC 2023



> -----Original Message-----
> From: De Marchi, Lucas <lucas.demarchi at intel.com>
> Sent: Wednesday, September 20, 2023 12:25 PM
> To: Mishra, Pallavi <pallavi.mishra at intel.com>
> Cc: intel-xe at lists.freedesktop.org; Summers, Stuart
> <stuart.summers at intel.com>; Roper, Matthew D
> <matthew.d.roper at intel.com>
> Subject: Re: [Intel-xe] [PATCH] drm/xe: Align size to PAGE_SIZE
> 
> 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?
> 
Yes. Let me add that under else.

Thanks! 
> 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