Visa Hankala <v...@hankala.org> writes:

> On Fri, Nov 18, 2022 at 11:03:06AM -0500, Dave Voutila wrote:
>> That fixes booting and the Surface Keyboard is usable, but I'm getting
>> spurious faults coming from retpoline out of filt_wseventdetach if I
>> detach and reattach the Surface Keyboard multiple times while running
>> Xorg.
>>
>> It's not consistent, but I've been able to trigger it 3 times now. 2 via
>> physical detach/reattach of the Surface Keyboard and another by just
>> running `sysctl machdep.forceukdb=1` which apparently detaches/attaches
>> behind the scenes.
>
> It seems that the detaching can leave behind dangling wsevent knotes.
> They should be ferreted out before the device disappears.
>
> Does the following patch help?
>
> klist_invalidate() can block, so I put it before ev->q is freed and
> set NULL. This tries to avoid causing new races with wsevent_init().
>
> The detach logic is tangled and particularly so with ws devices,
> so I am uncertain if tweaking just wsevent_fini() is enough.
>

I can't trigger the same fault, so that's a step forward.

However with some rapid physical attach/detach I can trigger some very
noticeable lag in devices coming back up and being responsive. Easily 5+
seconds on this machine.

I also managed to trigger this kernel message once (no panic or halt):

  usb_transfer_complete: xfer=0xfffffd821190b580 not on queue

I've found other issues while being abusive towards my USB devices on
this machine, but they're reproducible on a fresh kernel from the tree
so I believe unrelated to anton's diff. (I'll have to document and send
out once I can reproduce them.)

Not sure best way to proceed here. anton's (2nd) diff seems to work, but
might be surfacing a bigger issue in wscons?

Would be good to hear test reports from other Surface devices.

-dv

> Index: dev/wscons/wsevent.c
> ===================================================================
> RCS file: src/sys/dev/wscons/wsevent.c,v
> retrieving revision 1.26
> diff -u -p -r1.26 wsevent.c
> --- dev/wscons/wsevent.c      2 Jul 2022 08:50:42 -0000       1.26
> +++ dev/wscons/wsevent.c      19 Nov 2022 15:05:26 -0000
> @@ -131,6 +131,9 @@ wsevent_fini(struct wseventvar *ev)
>  #endif
>               return;
>       }
> +
> +     klist_invalidate(&ev->sel.si_note);
> +
>       free(ev->q, M_DEVBUF, WSEVENT_QSIZE * sizeof(struct wscons_event));
>       ev->q = NULL;
>

Reply via email to