mbox series

[v4,RESEND,0/9] Increase coverage on drm_framebuffer.c

Message ID 20240911001559.28284-1-gcarlos@disroot.org (mailing list archive)
Headers show
Series Increase coverage on drm_framebuffer.c | expand

Message

Carlos Eduardo Gallo Filho Sept. 11, 2024, 12:15 a.m. UTC
This patchset includes new KUnit tests for 5 untested functions from
drm_framebuffer.c and improvements to the existent one.

The first patch replace the use of dev_private member from drm_device
mock on the existent test by embedding it into an outer struct containing
a generic pointer.

The patches 2 and 4 extends the test of drm_internal_framebuffer_create()
by creating a new test case and adding new parameters to the existent case.

The patch 3 just replace a strcpy() call to strscpy().

Finally, the remainder of this set contains 5 new test cases, one for each
of the follow functions:

- drm_framebuffer_check_src_coords()
- drm_framebuffer_cleanup()
- drm_framebuffer_lookup()
- drm_framebuffer_init()
- drm_framebuffer_free()

---
v3:
  - Drop drm_mode_addfb2 and drm_fb_release tests (patches 10 and 11 from v2)
---

Carlos Eduardo Gallo Filho (9):
  drm/tests: Stop using deprecated dev_private member on drm_framebuffer
    tests
  drm/tests: Add parameters to the drm_test_framebuffer_create test
  drm/tests: Replace strcpy to strscpy on drm_test_framebuffer_create
    test
  drm/tests: Add test case for drm_internal_framebuffer_create()
  drm/tests: Add test for drm_framebuffer_check_src_coords()
  drm/tests: Add test for drm_framebuffer_cleanup()
  drm/tests: Add test for drm_framebuffer_lookup()
  drm/tests: Add test for drm_framebuffer_init()
  drm/tests: Add test for drm_framebuffer_free()

 drivers/gpu/drm/drm_framebuffer.c            |   2 +
 drivers/gpu/drm/drm_mode_object.c            |   1 +
 drivers/gpu/drm/tests/drm_framebuffer_test.c | 375 ++++++++++++++++++-
 3 files changed, 361 insertions(+), 17 deletions(-)

Comments

Maxime Ripard Sept. 11, 2024, 12:19 p.m. UTC | #1
On Tue, 10 Sep 2024 21:15:25 -0300, Carlos Eduardo Gallo Filho wrote:
> This patchset includes new KUnit tests for 5 untested functions from
> drm_framebuffer.c and improvements to the existent one.
> 
> The first patch replace the use of dev_private member from drm_device
> mock on the existent test by embedding it into an outer struct containing
> a generic pointer.
> 
> [...]

Applied to misc/kernel.git (drm-misc-next).

Thanks!
Maxime
Jani Nikula Sept. 13, 2024, 7:31 a.m. UTC | #2
On Wed, 11 Sep 2024, Maxime Ripard <mripard@kernel.org> wrote:
> On Tue, 10 Sep 2024 21:15:25 -0300, Carlos Eduardo Gallo Filho wrote:
>> This patchset includes new KUnit tests for 5 untested functions from
>> drm_framebuffer.c and improvements to the existent one.
>> 
>> The first patch replace the use of dev_private member from drm_device
>> mock on the existent test by embedding it into an outer struct containing
>> a generic pointer.
>> 
>> [...]
>
> Applied to misc/kernel.git (drm-misc-next).

How was this series itself tested? It would be prudent to Cc: intel-gfx
on stuff like this to run it through our CI. I don't think it ever
passed [1].

BR,
Jani.


[1] https://intel-gfx-ci.01.org/tree/drm-tip/shards-all.html?testfilter=drm_framebuffer
Maxime Ripard Sept. 13, 2024, 7:41 a.m. UTC | #3
On Fri, Sep 13, 2024 at 10:31:08AM GMT, Jani Nikula wrote:
> On Wed, 11 Sep 2024, Maxime Ripard <mripard@kernel.org> wrote:
> > On Tue, 10 Sep 2024 21:15:25 -0300, Carlos Eduardo Gallo Filho wrote:
> >> This patchset includes new KUnit tests for 5 untested functions from
> >> drm_framebuffer.c and improvements to the existent one.
> >> 
> >> The first patch replace the use of dev_private member from drm_device
> >> mock on the existent test by embedding it into an outer struct containing
> >> a generic pointer.
> >> 
> >> [...]
> >
> > Applied to misc/kernel.git (drm-misc-next).
> 
> How was this series itself tested? It would be prudent to Cc: intel-gfx
> on stuff like this to run it through our CI. I don't think it ever
> passed [1].

I'm not sure what's going on, but:

./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm//tests

Works like a charm with this series

Maxime
Jani Nikula Sept. 13, 2024, 9:13 a.m. UTC | #4
On Fri, 13 Sep 2024, Maxime Ripard <mripard@kernel.org> wrote:
> On Fri, Sep 13, 2024 at 10:31:08AM GMT, Jani Nikula wrote:
>> On Wed, 11 Sep 2024, Maxime Ripard <mripard@kernel.org> wrote:
>> > On Tue, 10 Sep 2024 21:15:25 -0300, Carlos Eduardo Gallo Filho wrote:
>> >> This patchset includes new KUnit tests for 5 untested functions from
>> >> drm_framebuffer.c and improvements to the existent one.
>> >> 
>> >> The first patch replace the use of dev_private member from drm_device
>> >> mock on the existent test by embedding it into an outer struct containing
>> >> a generic pointer.
>> >> 
>> >> [...]
>> >
>> > Applied to misc/kernel.git (drm-misc-next).
>> 
>> How was this series itself tested? It would be prudent to Cc: intel-gfx
>> on stuff like this to run it through our CI. I don't think it ever
>> passed [1].
>
> I'm not sure what's going on, but:
>
> ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm//tests
>
> Works like a charm with this series

We consistently hit the below warning in drm_framebuffer_free().

Looks like drm_test_framebuffer_free() fails to initialize the
framebuffer, there's no call to drm_framebuffer_init(), leaving
fb->filp_head list uninitialized. The list_empty() check in
drm_framebuffer_free() blows up. Why it doesn't fail for you, I don't
understand.

BR,
Jani.



<4> [131.574236] ------------[ cut here ]------------
<4> [131.574244] drm-kunit-mock-device drm_test_framebuffer_free.drm-kunit-mock-device: [drm] drm_WARN_ON(!list_empty(&fb->filp_head))
<4> [131.574269] WARNING: CPU: 8 PID: 1261 at drivers/gpu/drm/drm_framebuffer.c:832 drm_framebuffer_free+0x71/0x80
<4> [131.574281] Modules linked in: drm_framebuffer_test drm_kunit_helpers kunit vgem drm_shmem_helper snd_hda_codec_hdmi r8153_ecm cdc_ether usbnet i915 x86_pkg_temp_thermal coretemp kvm_intel kvm snd_hda_intel snd_intel_dspcfg mei_gsc_proxy snd_hda_codec prime_numbers crct10dif_pclmul r8152 snd_hwdep i2c_algo_bit crc32_pclmul wmi_bmof mii ghash_clmulni_intel ttm e1000e snd_hda_core video i2c_i801 mei_me drm_display_helper ptp i2c_mux snd_pcm thunderbolt mei drm_buddy pps_core i2c_smbus intel_lpss_pci wmi [last unloaded: drm_framebuffer_test]
<4> [131.574378] CPU: 8 UID: 0 PID: 1261 Comm: kunit_try_catch Tainted: G                 N 6.11.0-rc7-CI_DRM_15393-g2c6794afc551+ #1
<4> [131.574386] Tainted: [N]=TEST
<4> [131.574389] Hardware name: Intel Corporation Meteor Lake Client Platform/MTL-P LP5x T3 RVP, BIOS MTLPFWI1.R00.3471.D91.2401310918 01/31/2024
<4> [131.574393] RIP: 0010:drm_framebuffer_free+0x71/0x80
<4> [131.574400] Code: 4c 8b 6f 50 4d 85 ed 75 03 4c 8b 2f e8 48 c5 03 00 48 c7 c1 88 00 4f 82 4c 89 ea 48 c7 c7 53 8f 45 82 48 89 c6 e8 1f be 80 ff <0f> 0b eb ad 66 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90
<4> [131.574405] RSP: 0018:ffffc900013efd60 EFLAGS: 00010282
<4> [131.574413] RAX: 0000000000000000 RBX: ffffc900013efdc8 RCX: 0000000000000000
<4> [131.574418] RDX: 0000000000000002 RSI: ffffffff8243ccc2 RDI: 00000000ffffffff
<4> [131.574422] RBP: ffff8881190f9000 R08: 0000000000000000 R09: ffffc900013efb90
<4> [131.574425] R10: 0000000000000001 R11: 0000000000000001 R12: ffffc900013efda0
<4> [131.574429] R13: ffff888114cb9b40 R14: ffffffffa030e520 R15: ffffc9000169f8e0
<4> [131.574434] FS:  0000000000000000(0000) GS:ffff88885fc00000(0000) knlGS:0000000000000000
<4> [131.574441] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4> [131.574448] CR2: 000055cc6f2feed0 CR3: 000000000663a002 CR4: 0000000000f70ef0
<4> [131.574455] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
<4> [131.574463] DR3: 0000000000000000 DR6: 00000000ffff07f0 DR7: 0000000000000400
<4> [131.574470] PKRU: 55555554
<4> [131.574477] Call Trace:
<4> [131.574483]  <TASK>
<4> [131.574491]  ? __warn+0x8c/0x190
<4> [131.574505]  ? drm_framebuffer_free+0x71/0x80
<4> [131.574518]  ? report_bug+0x1f8/0x200
<4> [131.574535]  ? prb_read_valid+0x16/0x20
<4> [131.574553]  ? handle_bug+0x3c/0x70
<4> [131.574566]  ? exc_invalid_op+0x18/0x70
<4> [131.574579]  ? asm_exc_invalid_op+0x1a/0x20
<4> [131.574593]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10 [kunit]
<4> [131.574636]  ? drm_framebuffer_free+0x71/0x80
<4> [131.574658]  drm_test_framebuffer_free+0x88/0x220 [drm_framebuffer_test]
<4> [131.574709]  kunit_try_run_case+0x6d/0x150 [kunit]
<4> [131.574724]  ? __kthread_parkme+0x31/0xa0
<4> [131.574732]  ? lockdep_hardirqs_on+0x7b/0x100
<4> [131.574744]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10 [kunit]
<4> [131.574757]  kunit_generic_run_threadfn_adapter+0x19/0x40 [kunit]
<4> [131.574771]  kthread+0xeb/0x120
<4> [131.574779]  ? __pfx_kthread+0x10/0x10
<4> [131.574788]  ret_from_fork+0x2c/0x50
<4> [131.574796]  ? __pfx_kthread+0x10/0x10
<4> [131.574803]  ret_from_fork_asm+0x1a/0x30
<4> [131.574821]  </TASK>
<4> [131.574824] irq event stamp: 1017
<4> [131.574829] hardirqs last  enabled at (1023): [<ffffffff8113ec40>] console_unlock+0x110/0x120
<4> [131.574841] hardirqs last disabled at (1028): [<ffffffff8113ec25>] console_unlock+0xf5/0x120
<4> [131.574851] softirqs last  enabled at (14): [<ffffffff810a492c>] handle_softirqs+0x2ec/0x3f0
<4> [131.574859] softirqs last disabled at (5): [<ffffffff810a50a7>] irq_exit_rcu+0x87/0xc0
<4> [131.574867] ---[ end trace 0000000000000000 ]---