On Thu Nov 28 19:33:21 2024 +0000, Paul Gofman wrote:
I am not reproducing the results you describe here. Attach the full test patch (on top of this MR) so it can be compiled and executed (to be sure the same actual code is tested). I am running it on real Win11 machine with driver signing enforcement disabled in boot options (choosable with reboot with Shift + Restart option in Start menu). What it outputs here is:
joystick8.c:6097: Subtest hid joystick8.c:6097: Subtest driver joystick8.c:6097: Subtest driver_bus joystick8.c:6097: Subtest driver_hid joystick8.c:6097: Subtest driver_hid_poll joystick8.c:6022: ----1. joystick8.c:5942: L"Wine Test", id 0, inst {6b2c8080-ad8c-11ef-8001-444553540000}, path L"\\\\?\\hid#vid_1209&pid_0001#2&2c33ed5d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". joystick8.c:6030: ----2. joystick8.c:5942: L"Wine Test", id 2, inst {d69a7790-a842-11ef-8004-444553540000}, path L"\\\\?\\hid#vid_1209&pid_0002#2&86033a3&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". joystick8.c:6036: ----3. joystick8.c:5942: L"Wine Test", id 0, inst {6b2c8080-ad8c-11ef-8001-444553540000}, path L"\\\\?\\hid#vid_1209&pid_0001#2&2c33ed5d&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". joystick8.c:5942: L"Wine Test", id 2, inst {d69a7790-a842-11ef-8004-444553540000}, path L"\\\\?\\hid#vid_1209&pid_0002#2&86033a3&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}". 0004:driver_hid: 47 tests executed (0 marked as todo, 0 as flaky, 0 failures), 0 skipped. 0004:driver_hid: 81 tests executed (0 marked as todo, 0 as flaky, 0 failures), 0 skipped. 0004:driver_bus: 59 tests executed (0 marked as todo, 0 as flaky, 0 failures), 0 skipped. 3504:joystick8: 341 tests executed (0 marked as todo, 0 as flaky, 0 failures), 0 skipped.
So the second device is created with id 2 at once, even though device 1 is destroyed (probably index 1 is busy with something else). Maybe your actual test is diffent in some ways, or something in machine setup which makes it always reset indexes, or you are using older Windows and that behaviour changed? FWIW I rebooted the machine before repeating this test to exclude some possible non-persistent leftover devices from previous test run. [test.patch](/uploads/5c1644a9d0527df7659caf5b07ce1d0f/test.patch)
On Testbot Win8 and Win10 machines that works like you describe. I am guessing that this was maybe changed in Win11 (as the behaviour with jumping joystick ID without any sort of unplugging of specific device involved, with it keeping the same instance id, looks like a bug), or it doesn't work very well on first device attach / remove on Windows but then it persists something and avoids jumping IDs even on earlier versions.