Re: atomic changes break drm-next-kmod?

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 3 Jul 2018 15:29:50 -0700
On 7/3/18 3:20 PM, Pete Wright wrote:
> 
> 
> On 07/03/2018 15:12, Pete Wright wrote:
>>
>>
>> On 07/03/2018 14:17, Pete Wright wrote:
>>>
>>>
>>> On 07/03/2018 12:02, John Baldwin wrote:
>>>> On 7/3/18 11:28 AM, Niclas Zeising wrote:
>>>>> On 07/03/18 17:02, O. Hartmann wrote:
>>>>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>>>> Hash: SHA512
>>>>>>
>>>>>> Am Tue, 3 Jul 2018 10:19:57 -0400
>>>>>> Michael Butler <imb_at_protected-networks.net> schrieb:
>>>>>>
>>>>>>> It seems recent changes (SVN r335873?) may have broken 
>>>>>>> drm-next-kmod ..
>>>>>>>
>>>>>>> --- i915_drv.o ---
>>>>>>> In file included from i915_drv.c:30:
>>>>>>> In file included from
>>>>>>> /usr/ports/graphics/drm-next-kmod/work/kms-drm-a753215/linuxkpi/gplv2/include/linux/acpi.h:26: 
>>>>>>>
>>>>>>> In file included from
>>>>>>> /usr/ports/graphics/drm-next-kmod/work/kms-drm-a753215/linuxkpi/gplv2/include/linux/device.h:4: 
>>>>>>>
>>>>>>> In file included from
>>>>>>> /usr/src/sys/compat/linuxkpi/common/include/linux/device.h:35:
>>>>>>> In file included from
>>>>>>> /usr/src/sys/compat/linuxkpi/common/include/linux/types.h:37:
>>>>>>> In file included from /usr/src/sys/sys/systm.h:44:
>>>>>>> ./machine/atomic.h:450:29: error: invalid operand for instruction
>>>>>>> ATOMIC_ASM(clear,    long,  "andq %1,%0",  "ir", ~v);
>>>>>>>                               ^
>>>>>>> <inline asm>:1:7: note: instantiated into assembly here
>>>>>>>           andq $9223372036854775807,40672(%r14)
>>>>>>>                ^~~~~~~~~~~~~~~~~~~~~
>>>>>>> 1 error generated.
>>>>>>> *** [i915_drv.o] Error code 1
>>>>>>>
>>>>>>> make[3]: stopped in
>>>>>>> /usr/ports/graphics/drm-next-kmod/work/kms-drm-a753215/i915
>>>>>>> --- i915_gem.o ---
>>>>>>> In file included from i915_gem.c:28:
>>>>>>> In file included from
>>>>>>> /usr/ports/graphics/drm-next-kmod/work/kms-drm-a753215/include/drm/drmP.h:38: 
>>>>>>>
>>>>>>> In file included from /usr/src/sys/sys/malloc.h:42:
>>>>>>> In file included from /usr/src/sys/sys/systm.h:44:
>>>>>>> ./machine/atomic.h:449:29: error: invalid operand for instruction
>>>>>>> ATOMIC_ASM(set,      long,  "orq %1,%0",   "ir",  v);
>>>>>>>                               ^
>>>>>>> <inline asm>:1:6: note: instantiated into assembly here
>>>>>>>           orq $-9223372036854775808,40672(%r14)
>>>>>>>               ^~~~~~~~~~~~~~~~~~~~~~
>>>>>>> 1 error generated.
>>>>>>> *** [i915_gem.o] Error code 1
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> freebsd-current_at_freebsd.org mailing list
>>>>>>> https://lists.freebsd.org/mailman/listinfo/freebsd-current
>>>>>>> To unsubscribe, send any mail to 
>>>>>>> "freebsd-current-unsubscribe_at_freebsd.org"
>>>>>>
>>>>>> It breaks also graphics/drm-stable-kmod (see PR 229484,
>>>>>> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229484, same 
>>>>>> error as you described
>>>>>> above) and also emulators/virtualbox-ose-kmod. As long as CURRENT 
>>>>>> revision is < r335873,
>>>>>> those kmod compile well.
>>>>> We are looking into why both the drm ports fail.
>>>>> Regards
>>>>>
>>>> I haven't yet tested an amd64 kernel with this, but I think this 
>>>> change to sys/amd64/include/atomic.h
>>>> might fix it:
>>>>
>>>> Index: atomic.h
>>>> ===================================================================
>>>> --- atomic.h    (revision 335896)
>>>> +++ atomic.h    (working copy)
>>>> _at__at_ -446,10 +446,10 _at__at_ ATOMIC_ASM(clear,    int,   "andl %1,%0", "ir", ~
>>>>   ATOMIC_ASM(add,         int,   "addl %1,%0",  "ir",  v);
>>>>   ATOMIC_ASM(subtract, int,   "subl %1,%0",  "ir",  v);
>>>>   -ATOMIC_ASM(set,         long,  "orq %1,%0",   "ir",  v);
>>>> -ATOMIC_ASM(clear,    long,  "andq %1,%0",  "ir", ~v);
>>>> -ATOMIC_ASM(add,         long,  "addq %1,%0",  "ir",  v);
>>>> -ATOMIC_ASM(subtract, long,  "subq %1,%0",  "ir",  v);
>>>> +ATOMIC_ASM(set,         long,  "orq %1,%0",   "er",  v);
>>>> +ATOMIC_ASM(clear,    long,  "andq %1,%0",  "er", ~v);
>>>> +ATOMIC_ASM(add,         long,  "addq %1,%0",  "er",  v);
>>>> +ATOMIC_ASM(subtract, long,  "subq %1,%0",  "er",  v);
>>>>     #define    ATOMIC_LOADSTORE(TYPE)                    \
>>>>       ATOMIC_LOAD(TYPE);                    \
>>>>
>>>>
>>>
>>> i've just built a kernel with this patch applied, rebooted into it 
>>> and was able to build the drm-next-kmod port.  i am also running X 
>>> without issues so far with this configuration.
>>>
>>
>>
>> oh neat - looks like this may have triggered a kernel panic. 
>> fortunately i was able to savecore.  here's the output of my info file:
>>
>> info:
>>   Version String: FreeBSD 12.0-CURRENT #7 d7ac1268f3a(master)-dirty: 
>> Tue Jul  3 13:53:50 PDT 2018
>> pete_at_duke:/usr/obj/usr/home/pete/git/freebsd/amd64.amd64/sys/GENERIC-EVDEV 
>>
>>   Panic String: Duplicate free of 0xfffff8010ac59000 from zone 
>> 0xfffff800340935a0(i915_gem_request) slab 0xfffff8010ac43af0(0)
>>
>> i didn't build a kernel.debug file unfortunately, but here's the 
>> output of my core.txt file, not sure how helpful it is:
> 
> darn, hit send too soon - i was looking in wrong place for debug kernel 
> - here is some hopefully more helpful info:
> 
> $ sudo kgdb /usr/lib/debug/boot/kernel/kernel.debug /var/crash/vmcore.1
> Unread portion of the kernel message buffer:
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !mutex_is_locked(&mode_config->mutex) && 
> !drm_modeset_is_locked(&mode_config->connection_mutex) failed at 
> /usr/home/pete/git/freebsd-ports/graphics/drm-next-kmod/work/kms-drm-a753215/include/drm/drm_crtc.h:1403
> WARNING !state->acquire_ctx failed at drm_atomic.c:909
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:909
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !mutex_is_locked(&mode_config->mutex) && 
> !drm_modeset_is_locked(&mode_config->connection_mutex) failed at 
> /usr/home/pete/git/freebsd-ports/graphics/drm-next-kmod/work/kms-drm-a753215/include/drm/drm_crtc.h:1403
> WARNING !state->acquire_ctx failed at drm_atomic.c:909
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:909
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:634
> WARNING !mutex_is_locked(&mode_config->mutex) && 
> !drm_modeset_is_locked(&mode_config->connection_mutex) failed at 
> /usr/home/pete/git/freebsd-ports/graphics/drm-next-kmod/work/kms-drm-a753215/include/drm/drm_crtc.h:1403
> WARNING !mutex_is_locked(&mode_config->mutex) && 
> !drm_modeset_is_locked(&mode_config->connection_mutex) failed at 
> /usr/home/pete/git/freebsd-ports/graphics/drm-next-kmod/work/kms-drm-a753215/include/drm/drm_crtc.h:1403
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> WARNING !state->acquire_ctx failed at drm_atomic.c:270
> panic: running but not TDS_RUNNING
> cpuid = 7
> time = 1530655265
> KDB: stack backtrace:
> db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 
> 0xfffffe00756b9ef0
> vpanic() at vpanic+0x1a3/frame 0xfffffe00756b9f50
> doadump() at doadump/frame 0xfffffe00756b9fd0
> sleepq_timedwait() at sleepq_timedwait+0x50/frame 0xfffffe00756ba010
> linux_add_to_sleepqueue() at linux_add_to_sleepqueue+0xfd/frame 
> 0xfffffe00756ba060
> linux_wait_event_common() at linux_wait_event_common+0x149/frame 
> 0xfffffe00756ba0b0
> intel_atomic_wait_for_vblanks() at 
> intel_atomic_wait_for_vblanks+0x38c/frame 0xfffffe00756ba200
> intel_atomic_commit_tail() at intel_atomic_commit_tail+0x808/frame 
> 0xfffffe00756ba3e0
> intel_atomic_commit() at intel_atomic_commit+0x24c/frame 0xfffffe00756ba460
> drm_atomic_commit() at drm_atomic_commit+0x95/frame 0xfffffe00756ba490
> restore_fbdev_mode_atomic() at restore_fbdev_mode_atomic+0x1da/frame 
> 0xfffffe00756ba510
> restore_fbdev_mode() at restore_fbdev_mode+0x43/frame 0xfffffe00756ba5b0
> drm_fb_helper_restore_fbdev_mode_unlocked() at 
> drm_fb_helper_restore_fbdev_mode_unlocked+0x45/frame 0xfffffe00756ba5f0
> vt_kms_postswitch() at vt_kms_postswitch+0x1e2/frame 0xfffffe00756ba660
> vt_window_switch() at vt_window_switch+0x128/frame 0xfffffe00756ba6a0
> vtterm_cngrab() at vtterm_cngrab+0x20/frame 0xfffffe00756ba6c0
> cngrab() at cngrab+0x42/frame 0xfffffe00756ba6e0
> vpanic() at vpanic+0xfb/frame 0xfffffe00756ba740
> panic() at panic+0x43/frame 0xfffffe00756ba7a0
> uma_dbg_free() at uma_dbg_free+0x174/frame 0xfffffe00756ba7d0
> uma_zfree_arg() at uma_zfree_arg+0xf6/frame 0xfffffe00756ba830
> linux_rcu_cleaner_func() at linux_rcu_cleaner_func+0xa2/frame 
> 0xfffffe00756ba860
> taskqueue_run_locked() at taskqueue_run_locked+0x14c/frame 
> 0xfffffe00756ba8c0
> taskqueue_run() at taskqueue_run+0x4a/frame 0xfffffe00756ba8e0
> intr_event_execute_handlers() at intr_event_execute_handlers+0x99/frame 
> 0xfffffe00756ba920
> ithread_loop() at ithread_loop+0xb7/frame 0xfffffe00756ba970
> fork_exit() at fork_exit+0x84/frame 0xfffffe00756ba9b0
> fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe00756ba9b0
> --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
> KDB: enter: panic
> <snip symbol loading>
> #0  cpustop_handler () at 
> /usr/home/pete/git/freebsd/sys/x86/x86/mp_x86.c:1379
> 1379        CPU_SET_ATOMIC(cpu, &stopped_cpus);
> (kgdb) bt
> #0  cpustop_handler () at 
> /usr/home/pete/git/freebsd/sys/x86/x86/mp_x86.c:1379
> #1  0xffffffff811e9ae4 in ipi_nmi_handler () at 
> /usr/home/pete/git/freebsd/sys/x86/x86/mp_x86.c:1337
> #2  0xffffffff81070d29 in trap (frame=0xffffffff81fb42f0) at 
> /usr/home/pete/git/freebsd/sys/amd64/amd64/trap.c:192
> #3  0xffffffff8104d0d4 in nmi_calltrap () at 
> /usr/home/pete/git/freebsd/sys/amd64/amd64/exception.S:768
> #4  0xffffffff811d9a2c in acpi_cpu_idle_mwait (mwait_hint=0) at 
> cpufunc.h:620
> Previous frame inner to this frame (corrupt stack?)
> Current language:  auto; currently minimal
> (kgdb)

That seems like kgdb is looking at the wrong CPU.  Can you use
'info threads' and look for threads not stopped in 'sched_switch'
and get their backtraces?  You could also just do 'thread apply
all bt' and put that file at a URL if that is easiest.

-- 
John Baldwin
Received on Tue Jul 03 2018 - 20:29:54 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:16 UTC