drm/tests: Alloc drm_device on drm_exec tests
Subsystems (2)
PATCH 1/1 drm/tests: Alloc drm_device on drm_exec tests
The drm_exec tests where crashing[0] because of a null dereference. This is caused by a new access of the driver attribute of struct drm_driver on drm_gem_private_object_init(). Alloc the drm_device to fix that.
[0]
[15:05:24] ================== drm_exec (6 subtests) =================== [15:05:24] [PASSED] sanitycheck
^CERROR:root:Build interruption occurred. Cleaning console.
[15:05:50] [ERROR] Test: drm_exec: missing expected subtest!
[15:05:50] BUG: kernel NULL pointer dereference, address: 00000000000000b0 [15:05:50] #PF: supervisor read access in kernel mode
[15:05:50] #PF: error_code(0x0000) - not-present page
[15:05:50] PGD 0 P4D 0
[15:05:50] Oops: 0000 [#1] PREEMPT NOPTI
[15:05:50] CPU: 0 PID: 23 Comm: kunit_try_catch Tainted: G N 6.4.0-rc7-02032-ge6303f323b1a #69
[15:05:50] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014 [15:05:50] RIP: 0010:drm_gem_private_object_init+0x60/0xc0
--- drivers/gpu/drm/tests/drm_exec_test.c | 36 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-)
drivers/gpu/drm/tests/drm_exec_test.c +29 -7
@@ -12,11 +12,31 @@#include <drm/drm_exec.h> #include <drm/drm_device.h> +#include <drm/drm_drv.h> #include <drm/drm_gem.h> +#include <drm/drm_kunit_helpers.h> #include "../lib/drm_random.h" -static struct drm_device dev; +static struct device *dev; +static struct drm_device *drm; + +static int test_init (struct kunit *test) +{ + dev =drm_kunit_helper_alloc_device (test); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev); + + drm =__drm_kunit_helper_alloc_drm_device (test, dev,sizeof (*drm),0 , +DRIVER_MODESET ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, drm); + +return 0 ; +} + +static void test_exit (struct kunit *test) +{ +drm_kunit_helper_free_device (test, dev); +}static void sanitycheck (struct kunit *test) {
@@ -33,7 +53,7 @@ static void test_lock(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ); drm_exec_until_all_locked(&exec) {
@@ -52,7 +72,7 @@ static void test_lock_unlock(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ); drm_exec_until_all_locked(&exec) {
@@ -78,7 +98,7 @@ static void test_duplicates(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ); drm_exec_until_all_locked(&exec) {
@@ -106,7 +126,7 @@ static void test_prepare(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ); drm_exec_until_all_locked(&exec) {
@@ -127,8 +147,8 @@ static void test_prepare_array(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj1,PAGE_SIZE ); -drm_gem_private_object_init (&dev, &gobj2,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj1,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj2,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT );drm_exec_until_all_locked (&exec)
@@ -150,6 +170,8 @@ static struct kunit_case drm_exec_tests[] = {static struct kunit_suite drm_exec_test_suite = { .name ="drm_exec" , + .init = test_init, + .exit = test_exit, .test_cases = drm_exec_tests, };
Signature · 1 line
2.41.0
Quoted 19 lines · Arthur Grillo
The
drm_exectests where crashing[0] because of a null dereference. This is caused by a new access of thedriverattribute ofstruct drm_driverondrm_gem_private_object_init(). Alloc thedrm_deviceto fix that.[0]
[15:05:24] ==================drm_exec(6 subtests) =================== [15:05:24] [PASSED] sanitycheck
^CERROR:root:Build interruption occurred. Cleaning console.
[15:05:50] [ERROR] Test:drm_exec: missing expected subtest!
[15:05:50] BUG: kernel NULL pointer dereference, address:00000000000000b0[15:05:50] #PF: supervisor read access in kernel mode
[15:05:50] #PF:error_code(0x0000)- not-present page
[15:05:50] PGD 0 P4D 0
[15:05:50] Oops: 0000 [#1] PREEMPT NOPTI
[15:05:50] CPU: 0 PID: 23 Comm:kunit_try_catchTainted: G N 6.4.0-rc7-02032-ge6303f323b1a #69
[15:05:50] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014 [15:05:50] RIP: 0010:drm_gem_private_object_init+0x60/0xc0
Quoted 2 lines
Fixes e6303f323b1a ("drm: manager to keep track of GPUs VA mappings")Signed-off-by Arthur Grillo <[email protected]>
Quoted 97 lines
--- drivers/gpu/drm/tests/drm_exec_test.c | 36 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-)drivers/gpu/drm/tests/drm_exec_test.c +29
-7@@ -12,11 +12,31 @@#include <drm/drm_exec.h> #include <drm/drm_device.h> +#include <drm/drm_drv.h> #include <drm/drm_gem.h> +#include <drm/drm_kunit_helpers.h> #include "../lib/drm_random.h" -static struct drm_device dev; +static struct device *dev; +static struct drm_device *drm; + +static int test_init (struct kunit *test) +{ + dev =drm_kunit_helper_alloc_device (test); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev); + + drm =__drm_kunit_helper_alloc_drm_device (test, dev,sizeof (*drm),0 , +DRIVER_MODESET ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, drm); + +return 0 ; +} + +static void test_exit (struct kunit *test) +{ +drm_kunit_helper_free_device (test, dev); +}static void sanitycheck (struct kunit *test) {@@ -33,7 +53,7 @@ static void test_lock(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ); drm_exec_until_all_locked(&exec) {@@ -52,7 +72,7 @@ static void test_lock_unlock(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ); drm_exec_until_all_locked(&exec) {@@ -78,7 +98,7 @@ static void test_duplicates(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ); drm_exec_until_all_locked(&exec) {@@ -106,7 +126,7 @@ static void test_prepare(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ); drm_exec_until_all_locked(&exec) {@@ -127,8 +147,8 @@ static void test_prepare_array(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj1,PAGE_SIZE ); -drm_gem_private_object_init (&dev, &gobj2,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj1,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj2,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT );drm_exec_until_all_locked (&exec)@@ -150,6 +170,8 @@ static struct kunit_case drm_exec_tests[] = {static struct kunit_suite drm_exec_test_suite = { .name ="drm_exec" , + .init = test_init, + .exit = test_exit, .test_cases = drm_exec_tests, };
Hi Arthur,
Quoted 32 lines · Arthur Grillo
The
drm_exectests where crashing[0] because of a null dereference. This is caused by a new access of thedriverattribute ofstruct drm_driverondrm_gem_private_object_init(). Alloc thedrm_deviceto fix that.[0]
[15:05:24] ==================drm_exec(6 subtests) =================== [15:05:24] [PASSED] sanitycheck
^CERROR:root:Build interruption occurred. Cleaning console.
[15:05:50] [ERROR] Test:drm_exec: missing expected subtest!
[15:05:50] BUG: kernel NULL pointer dereference, address:00000000000000b0[15:05:50] #PF: supervisor read access in kernel mode
[15:05:50] #PF:error_code(0x0000)- not-present page
[15:05:50] PGD 0 P4D 0
[15:05:50] Oops: 0000 [#1] PREEMPT NOPTI
[15:05:50] CPU: 0 PID: 23 Comm:kunit_try_catchTainted: G N 6.4.0-rc7-02032-ge6303f323b1a #69
[15:05:50] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014 [15:05:50] RIP: 0010:drm_gem_private_object_init+0x60/0xc0Fixes e6303f323b1a ("drm: manager to keep track of GPUs VA mappings")Signed-off-by Arthur Grillo <[email protected]>--- drivers/gpu/drm/tests/drm_exec_test.c | 36 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-)drivers/gpu/drm/tests/drm_exec_test.c +0
-0@@ -12,11 +12,31 @@#include <drm/drm_exec.h>
drivers/gpu/drm/tests/drm_exec_test.c line 22
Quoted 10 lines
drivers/gpu/drm/tests/drm_exec_test.c +4
-1#include <drm/drm_device.h> +#include <drm/drm_drv.h> #include <drm/drm_gem.h> +#include <drm/drm_kunit_helpers.h> #include "../lib/drm_random.h" -static struct drm_device dev; +static struct device *dev; +static struct drm_device *drm;
Maybe we could use test->priv to store those variables.
drivers/gpu/drm/tests/drm_exec_test.c line 24
Quoted 2 lines
drivers/gpu/drm/tests/drm_exec_test.c +2
-0+ +static int test_init (struct kunit *test)
Nitpick: wouldn't be better to call it drm_exec_test_init()?
Anyway, with those fixes or not,
Best Regards,
- Maíra
Quoted 74 lines
drivers/gpu/drm/tests/drm_exec_test.c +23
-6+{ + dev =drm_kunit_helper_alloc_device (test); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev); + + drm =__drm_kunit_helper_alloc_drm_device (test, dev,sizeof (*drm),0 , +DRIVER_MODESET ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, drm); + +return 0 ; +} + +static void test_exit (struct kunit *test) +{ +drm_kunit_helper_free_device (test, dev); +}static void sanitycheck (struct kunit *test) {@@ -33,7 +53,7 @@ static void test_lock(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ); drm_exec_until_all_locked(&exec) {@@ -52,7 +72,7 @@ static void test_lock_unlock(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ); drm_exec_until_all_locked(&exec) {@@ -78,7 +98,7 @@ static void test_duplicates(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_IGNORE_DUPLICATES ); drm_exec_until_all_locked(&exec) {@@ -106,7 +126,7 @@ static void test_prepare(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT ); drm_exec_until_all_locked(&exec) {@@ -127,8 +147,8 @@ static void test_prepare_array(struct kunit *test)struct drm_exec exec;int ret; -drm_gem_private_object_init (&dev, &gobj1,PAGE_SIZE ); -drm_gem_private_object_init (&dev, &gobj2,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj1,PAGE_SIZE ); +drm_gem_private_object_init (drm, &gobj2,PAGE_SIZE );drm_exec_init (&exec,DRM_EXEC_INTERRUPTIBLE_WAIT );drm_exec_until_all_locked (&exec)@@ -150,6 +170,8 @@ static struct kunit_case drm_exec_tests[] = {static struct kunit_suite drm_exec_test_suite = { .name ="drm_exec" , + .init = test_init, + .exit = test_exit, .test_cases = drm_exec_tests, };
Hi,
Quoted 19 lines · Arthur Grillo
The
drm_exectests where crashing[0] because of a null dereference. This is caused by a new access of thedriverattribute ofstruct drm_driverondrm_gem_private_object_init(). Alloc thedrm_deviceto fix that.[0]
[15:05:24] ==================drm_exec(6 subtests) =================== [15:05:24] [PASSED] sanitycheck
^CERROR:root:Build interruption occurred. Cleaning console.
[15:05:50] [ERROR] Test:drm_exec: missing expected subtest!
[15:05:50] BUG: kernel NULL pointer dereference, address:00000000000000b0[15:05:50] #PF: supervisor read access in kernel mode
[15:05:50] #PF:error_code(0x0000)- not-present page
[15:05:50] PGD 0 P4D 0
[15:05:50] Oops: 0000 [#1] PREEMPT NOPTI
[15:05:50] CPU: 0 PID: 23 Comm:kunit_try_catchTainted: G N 6.4.0-rc7-02032-ge6303f323b1a #69
[15:05:50] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014 [15:05:50] RIP: 0010:drm_gem_private_object_init+0x60/0xc0
Quoted 2 lines
Fixes e6303f323b1a ("drm: manager to keep track of GPUs VA mappings")Signed-off-by Arthur Grillo <[email protected]>
You should Cc the list of people returned by scripts/get_maintainers.pl for all your patches.
Quoted 28 lines
--- drivers/gpu/drm/tests/drm_exec_test.c | 36 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-)drivers/gpu/drm/tests/drm_exec_test.c +11
-1@@ -12,11 +12,31 @@#include <drm/drm_exec.h> #include <drm/drm_device.h> +#include <drm/drm_drv.h> #include <drm/drm_gem.h> +#include <drm/drm_kunit_helpers.h> #include "../lib/drm_random.h" -static struct drm_device dev; +static struct device *dev; +static struct drm_device *drm; + +static int test_init (struct kunit *test) +{ + dev =drm_kunit_helper_alloc_device (test); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev); + + drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0,
drivers/gpu/drm/tests/drm_exec_test.c line 39
Quoted 10 lines
drivers/gpu/drm/tests/drm_exec_test.c +10
-0+ DRIVER_MODESET); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, drm); + +return 0 ; +} + +static void test_exit (struct kunit *test) +{ +drm_kunit_helper_free_device (test, dev); +}
You shouldn't be using a global variable here. test->priv is meant for those kind of things.
Maxime
Quoted 22 lines · Maxime Ripard
Hi,
Quoted 19 lines · Arthur Grillo
The
drm_exectests where crashing[0] because of a null dereference. This is caused by a new access of thedriverattribute ofstruct drm_driverondrm_gem_private_object_init(). Alloc thedrm_deviceto fix that.[0]
[15:05:24] ==================drm_exec(6 subtests) =================== [15:05:24] [PASSED] sanitycheck
^CERROR:root:Build interruption occurred. Cleaning console.
[15:05:50] [ERROR] Test:drm_exec: missing expected subtest!
[15:05:50] BUG: kernel NULL pointer dereference, address:00000000000000b0[15:05:50] #PF: supervisor read access in kernel mode
[15:05:50] #PF:error_code(0x0000)- not-present page
[15:05:50] PGD 0 P4D 0
[15:05:50] Oops: 0000 [#1] PREEMPT NOPTI
[15:05:50] CPU: 0 PID: 23 Comm:kunit_try_catchTainted: G N 6.4.0-rc7-02032-ge6303f323b1a #69
[15:05:50] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014 [15:05:50] RIP: 0010:drm_gem_private_object_init+0x60/0xc0
Quoted 6 lines
Quoted 2 lines
Fixes e6303f323b1a ("drm: manager to keep track of GPUs VA mappings")Signed-off-by Arthur Grillo <[email protected]>You should Cc the list of people returned by
scripts/get_maintainers.plfor all your patches.
The email of my patch that arrived in my inbox has all the people returned by scripts/get_maintainers.pl on Cc, but the email on the list has some people left out. Maybe is something wrong with my git send-email configuration. I will have a look on that.
Best Regards,
~Arthur Grillo
Quoted 43 lines
Quoted 28 lines
--- drivers/gpu/drm/tests/drm_exec_test.c | 36 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-)drivers/gpu/drm/tests/drm_exec_test.c +11
-1@@ -12,11 +12,31 @@#include <drm/drm_exec.h> #include <drm/drm_device.h> +#include <drm/drm_drv.h> #include <drm/drm_gem.h> +#include <drm/drm_kunit_helpers.h> #include "../lib/drm_random.h" -static struct drm_device dev; +static struct device *dev; +static struct drm_device *drm; + +static int test_init (struct kunit *test) +{ + dev =drm_kunit_helper_alloc_device (test); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev); + + drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0,drivers/gpu/drm/tests/drm_exec_test.c line 39
Quoted 10 lines
drivers/gpu/drm/tests/drm_exec_test.c +10
-0+ DRIVER_MODESET); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, drm); + +return 0 ; +} + +static void test_exit (struct kunit *test) +{ +drm_kunit_helper_free_device (test, dev); +}You shouldn't be using a global variable here.
test->privis meant for those kind of things.Maxime
Hi,
Quoted 29 lines · Arthur Grillo Queiroz Cabral
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/tests/drm_exec_test.c | 36 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-)drivers/gpu/drm/tests/drm_exec_test.c +13
-1@@ -12,11 +12,31 @@#include <drm/drm_exec.h> #include <drm/drm_device.h> +#include <drm/drm_drv.h> #include <drm/drm_gem.h> +#include <drm/drm_kunit_helpers.h> #include "../lib/drm_random.h" -static struct drm_device dev; +static struct device *dev; +static struct drm_device *drm; + +static int test_init (struct kunit *test) +{ + dev =drm_kunit_helper_alloc_device (test); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev); + + drm =__drm_kunit_helper_alloc_drm_device (test, dev,sizeof (*drm),0 , +DRIVER_MODESET ); +KUNIT_ASSERT_NOT_ERR_OR_NULL (test, drm);
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/tests/drm_exec_test.c line 39
Quoted 8 lines
drivers/gpu/drm/tests/drm_exec_test.c +8
-0+ +return 0 ; +} + +static void test_exit (struct kunit *test) +{ +drm_kunit_helper_free_device (test, dev); +}
Also, I just pushed changes that make the call todrm_kunit_helper_free_device unnecessary.
Maxime