Bug 9652 - joystick not working with 32 bit applications running on x86-64
Summary: joystick not working with 32 bit applications running on x86-64
Status: CLOSED CODE_FIX
Alias: None
Product: Platform Specific/Hardware
Classification: Unclassified
Component: x86-64 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Alexey Dobriyan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-28 08:55 UTC by Akos Maroy
Modified: 2008-09-13 01:12 UTC (History)
4 users (show)

See Also:
Kernel Version: 2.6.22
Subsystem:
Regression: ---
Bisected commit-id:


Attachments

Description Akos Maroy 2007-12-28 08:55:51 UTC
Most recent kernel where this bug did not occur: 2.6.22
Distribution: Gentoo
Hardware Environment: Intel Core Duo 2
Software Environment: 32 bit applications running on a 64-bit platform
Problem Description:

unfortunately 32 bit apps don't see the joysticks on a 64 bit system. this
prevents one playing X-Plane (http://www.x-plane.com/) or other 32-bit games
with joysticks.

this is a know issue, and already raised several times:

http://readlist.com/lists/vger.kernel.org/linux-kernel/28/144411.html

http://www.brettcsmith.org/wiki/wiki.cgi?action=browse&diff=1&id=OzyComputer/Joystick

unfortunately this is still not fixed in the mainline kerne


Steps to reproduce:

fire up a 32-bit application that uses joystick on a 64-bit system, like X-Plane, and see the joysticks not recognized


the following patch solves the problem:


diff -Naur linux-2.6.22-suspend2-r2/fs/compat_ioctl.c
linux-2.6.22-suspend2-r2-joystick/fs/compat_ioctl.c
--- linux-2.6.22-suspend2-r2/fs/compat_ioctl.c  2007-12-22 14:08:14.000000000
+0100
+++ linux-2.6.22-suspend2-r2-joystick/fs/compat_ioctl.c 2007-12-22
14:07:54.000000000 +0100
@@ -10,6 +10,8 @@
  * ioctls.
  */

+#include <linux/joystick.h>
+
 #include <linux/types.h>
 #include <linux/compat.h>
 #include <linux/kernel.h>
@@ -3259,6 +3261,12 @@
 COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
 COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)

+/* joystick */
+COMPATIBLE_IOCTL(JSIOCGVERSION)
+COMPATIBLE_IOCTL(JSIOCGAXES)
+COMPATIBLE_IOCTL(JSIOCGBUTTONS)
+COMPATIBLE_IOCTL(JSIOCGNAME(0x200)) /* for X-Plane 8.03 */
+
 /* now things that need handlers */
 HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
 HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
Comment 1 Andrew Morton 2007-12-28 14:45:58 UTC
Please send the patch via email to myself, Dmitry and linux-kernel@vger.kernel.org, thanks.
Comment 2 Akos Maroy 2008-01-01 11:07:43 UTC
I already sent the patch to the linux-kernel mailing list, before posting this ticket. should I send it again?

here's the post on the list:

http://lkml.org/lkml/2007/12/22/73
Comment 3 Ingo Molnar 2008-01-01 11:14:57 UTC
> I already sent the patch to the linux-kernel mailing list, before 
> posting this ticket. should I send it again?
> 
> here's the post on the list:
> 
> http://lkml.org/lkml/2007/12/22/73

hm, why is this one needed:

 +COMPATIBLE_IOCTL(JSIOCGNAME(0x200)) /* for X-Plane 8.03 */

?

(also, why are the other ones needed - these compat ioctl additions were 
never there before, so i'm not sure why it's a regression.)

	Ingo
Comment 4 Akos Maroy 2008-01-02 00:11:04 UTC
for COMPATIBLE_IOCTL(JSIOCGNAME(0x200)) - frankly, I don't know :) Bernhard Ager also submitted such a patch to the kernel mailing list in 2005, and he said:

he JSIOCGNAME ioctl causes a problem as it encodes the length of the return buffer into the ioctl number. This is solved by mapping all of the JSIOCGNAME ioctls to JSIOCGNAME(0).

his suggestion was JSIOCGNAME(0), see here: http://readlist.com/lists/vger.kernel.org/linux-kernel/28/144411.html

as for the other ones - as far as I understand, they are the ones passing the joystick controls to the 32 bit compatibility layer. on short: without this patch, 32 bit apps don't see the joystick, with the patch, they do.

as for why it's marked as regression - I don't know :)

Boldog uj evet :)
Comment 5 Daniel Drake 2008-02-07 04:30:43 UTC
It's marked as a regression because you wrote "Most recent kernel where this bug did not occur: 2.6.22" suggesting that this bug was introduced as of 2.6.23, but from your report I gather that is not what you meant - this has never worked for you on any kernel.

Brian Gerst rejected a similar patch in 2005, stating that it should already be fixed through ->compat_ioctl
http://readlist.com/lists/vger.kernel.org/linux-kernel/28/144411.html
It apparently is not, so I'll shoot him a quick email.

Downstream bug report: https://bugs.gentoo.org/show_bug.cgi?id=203011
Comment 6 Daniel Drake 2008-02-07 04:35:14 UTC
Linked to the wrong mail. This is the one I meant:
http://readlist.com/lists/vger.kernel.org/linux-kernel/28/144445.html
Comment 7 Daniel Drake 2008-02-07 07:38:13 UTC
Brian writes:
------
Commit 024ac44c701d43f5e2d34bd6a35b2813a36e6010 should have fixed the
compat ioctls in the correct manner.

Running "jstest --old js0" works for me on my amd64 system (kernel
2.6.23.14-107.fc8).
------

Can someone who is experiencing this bug please play around with jstest? In gentoo it's available in games-util/joystick, otherwise it can be found in this tarball: http://gentoo.virginmedia.com/distfiles/joystick-20060731.tar.bz2

If jstest seems to work, can you please give specific instructions how to reproduce this issue?
Comment 8 Akos Maroy 2008-02-25 12:03:54 UTC
I only have the patched kernel, there jstest seems to work fine:

$ jstest --old /dev/input/js0 
Driver version is 2.1.0.
Joystick (CH PRODUCTS CH FIGHTERSTICK USB ) has 5 axes (X, Y, Z, Hat0X, Hat0Y)
and 19 buttons (Trigger, ThumbBtn, ThumbBtn2, TopBtn, TopBtn2, PinkieBtn, BaseBtn, BaseBtn2, BaseBtn3, BaseBtn4, BaseBtn5, BaseBtn6, BtnDead, BtnA, BtnB, BtnC, BtnX, BtnY, BtnZ).
Testing ... (interrupt to exit)
Axes: X:127 Y:127 Buttons: A:off B:off


but this is with a kernel already containing the patch I posted above...
Comment 9 Daniel Drake 2008-02-25 16:49:31 UTC
Thanks for testing, but you need to do it on an unpatched kernel for the test to be of use
Comment 10 Alexey Dobriyan 2008-09-13 01:12:52 UTC
Reopen if mainline patch is wrong for some reason.

Note You need to log in before you can comment on or make changes to this bug.