diff mbox series

drm/i915/selftests: Switch 4k kmalloc to use get_free_page for alignment

Message ID 20200923114156.17749-1-chris@chris-wilson.co.uk
State New
Headers show
Series drm/i915/selftests: Switch 4k kmalloc to use get_free_page for alignment | expand

Commit Message

Chris Wilson Sept. 23, 2020, 11:41 a.m. UTC
In generating the reference LRC, we want a page-aligned address for
simplicity in computing the offsets within. This then shares the
computation for the HW LRC which is mapped and so page aligned, making
the comparison straightforward. It seems that kmalloc(4k) is not always
returning from a 4k-aligned slab cache (which would give us a page aligned
address) so force alignment by explicitly allocating a page.

Reported-by: "Gote, Nitin R" <nitin.r.gote@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: "Gote, Nitin R" <nitin.r.gote@intel.com>
---
 drivers/gpu/drm/i915/gt/selftest_lrc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Matthew Auld Sept. 24, 2020, 9:01 a.m. UTC | #1
On Wed, 23 Sep 2020 at 12:42, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> In generating the reference LRC, we want a page-aligned address for
> simplicity in computing the offsets within. This then shares the
> computation for the HW LRC which is mapped and so page aligned, making
> the comparison straightforward. It seems that kmalloc(4k) is not always
> returning from a 4k-aligned slab cache (which would give us a page aligned
> address) so force alignment by explicitly allocating a page.
>
> Reported-by: "Gote, Nitin R" <nitin.r.gote@intel.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: "Gote, Nitin R" <nitin.r.gote@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index c8753559c44c..a885f2fb6e66 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -4761,7 +4761,7 @@  static int live_lrc_layout(void *arg)
 	 * match the layout saved by HW.
 	 */
 
-	lrc = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	lrc = (u32 *)__get_free_page(GFP_KERNEL);
 	if (!lrc)
 		return -ENOMEM;
 
@@ -4850,7 +4850,7 @@  static int live_lrc_layout(void *arg)
 			break;
 	}
 
-	kfree(lrc);
+	free_page((unsigned long)lrc);
 	return err;
 }