Skip to contentSkip to conversation

HID: magicmouse: ignore 'ivalid report id' while switching modes

PATCH In review Jaikumar Ganesh 3 participants 9 messages Aug 17, 2011 – Aug 25, 2011 1 message not in the archive HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: magicmouse: ignore 'ivalid report id' while switching modes

From: Jiri Kosina <[email protected]>

23746a introduced this commit but was reverted in c3a492. The trackpad uses report Ids which are not present in the report descriptor. These reports ids are not documented anywhere. There are devices in the market (Apple magic tracpkad, BT version 2.0 is one such device) with the same device id, which fail when we use 0xd7 as the report id. So we need the EIO change of 23746a as a failsafe to work with these devices.

Original Author: Jiri Kosina <[email protected]>

---
 drivers/hid/hid-magicmouse.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/hid/hid-magicmouse.c +9 -1
index 0ec91c1..a5eda4c 100644
@@ -501,9 +501,17 @@ static int magicmouse_probe(struct hid_device *hdev,
 	}
 	report->size = 6;
 
+	/*
+	 * The device reponds with 'invalid report id' when feature
+	 * report switching it into multitouch mode is sent to it.
+	 *
+	 * This results in -EIO from the _raw low-level transport callback,
+	 * but there seems to be no other way of switching the mode.
+	 * Thus the super-ugly hacky success check below.
+	 */
 	ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
 			HID_FEATURE_REPORT);
-	if (ret != sizeof(feature)) {
+	if (ret != -EIO) {
 		hid_err(hdev, "unable to request touch data (%d)\n", ret);
 		goto err_stop_hw;
 	}
Signature · 1 line
1.7.3.1
#1 lore raw
Quoted 10 lines · Jaikumar Ganesh

From: Jiri Kosina <[email protected]>

23746a introduced this commit but was reverted in c3a492. The trackpad uses report Ids which are not present in the report descriptor. These reports ids are not documented anywhere. There are devices in the market (Apple magic tracpkad, BT version 2.0 is one such device) with the same device id, which fail when we use 0xd7 as the report id. So we need the EIO change of 23746a as a failsafe to work with these devices.

Quoted 3 lines

Original Author: Jiri Kosina <[email protected]>

I worry this may just be papering over a bug elsewhere in the system again. I'm going to try to git bisect this today.

-- Chase

A message that is not in the archive (sent off-list or not yet received): CAA8bQNjQ2s4EY=2r455z-3r7yyV0uwSjhQ6m5g2+TCyMRvu0sQ@mail.gmail.com

#3 lore raw
Quoted 22 lines · Jaikumar Ganesh

Hi Chase

On Thu, Aug 18, 2011 at 9:25 AM, Chase Douglas <[email protected] <mailto:[email protected]>> wrote:

On 08/17/2011 12:59 PM, Jaikumar Ganesh wrote:
> From: Jiri Kosina <[email protected] <mailto:[email protected]>> >
> 23746a introduced this commit but was reverted in c3a492. > The trackpad uses report Ids which are not present in the > report descriptor. These reports ids are not documented > anywhere. There are devices in the market (Apple magic tracpkad, > BT version 2.0 is one such device) with the same device id, > which fail when we use 0xd7 as the report id. So we need the EIO > change of 23746a as a failsafe to work with these devices. >
> Original Author: Jiri Kosina <[email protected] <mailto:[email protected]>>
>
> Signed-off-by: Jaikumar Ganesh <[email protected] <mailto:[email protected]>>

Quoted 7 lines

I worry this may just be papering over a bug elsewhere in the system again. I'm going to try to git bisect this today.

The original commit explains in detail why it used to work before, so its not a regression in that sense. The commit was present in 2.6.39 stable tree too but was reverted in 3.0 tree.

It was reverted because it was papering over a bug in the bluetooth stack, and when that bug was fixed this commit broke things again.

I've determined that there's a bug between Ubuntu's 3.0-1.2 and 3.0-2.3 kernels. There does not appear to be any Ubuntu specific patches that went in between those versions that would affect this, but there was a rebase from upstream 3.0-rc3 to 3.0-rc4. There is likely a bug introduced sometime in there.

I'll be digging deeper...

-- Chase

#4 lore raw
Quoted 34 lines · Chase Douglas
Quoted 22 lines · Jaikumar Ganesh

Hi Chase

On Thu, Aug 18, 2011 at 9:25 AM, Chase Douglas <[email protected] <mailto:[email protected]>> wrote:

On 08/17/2011 12:59 PM, Jaikumar Ganesh wrote:
> From: Jiri Kosina <[email protected] <mailto:[email protected]>> >
> 23746a introduced this commit but was reverted in c3a492. > The trackpad uses report Ids which are not present in the > report descriptor. These reports ids are not documented > anywhere. There are devices in the market (Apple magic tracpkad, > BT version 2.0 is one such device) with the same device id, > which fail when we use 0xd7 as the report id. So we need the EIO > change of 23746a as a failsafe to work with these devices. >
> Original Author: Jiri Kosina <[email protected] <mailto:[email protected]>>
>
> Signed-off-by: Jaikumar Ganesh <[email protected] <mailto:[email protected]>>

Quoted 7 lines

I worry this may just be papering over a bug elsewhere in the system again. I'm going to try to git bisect this today.

The original commit explains in detail why it used to work before, so its not a regression in that sense. The commit was present in 2.6.39 stable tree too but was reverted in 3.0 tree.

It was reverted because it was papering over a bug in the bluetooth stack, and when that bug was fixed this commit broke things again.

Quoted 7 lines

I've determined that there's a bug between Ubuntu's 3.0-1.2 and 3.0-2.3 kernels. There does not appear to be any Ubuntu specific patches that went in between those versions that would affect this, but there was a rebase from upstream 3.0-rc3 to 3.0-rc4. There is likely a bug introduced sometime in there.

I'll be digging deeper...

After some more digging I realized that the bluetooth fix for some devices went in at 3.0-rc4, just as the reversion of this patch went in. Thus, my bisect of ubuntu kernels was unhelpful.

I decided to try a few tests:

3.0-rc0 kernel with the bluetooth fix and this patch reverted 2.6.39 kernel with the bluetooth fix (this patch was not committed yet)

Both failed to properly initialize the magic trackpad. The only conclusion I can come up with is that there are some hardware differences between the machine I am currently testing with, and the machine I previously had the magicmouse working with.

If that's the case, the safest thing to do would be to apply this patch with a tweak. Don't check only that -EIO is returned. Check for either success or -EIO is returned. This should allow good and bad behaving hardware to still function.

Jiri, do you want me to send a rework of the patch, or do you want to do it yourself?

-- Chase

#5 lore raw

Chase:

Quoted 58 lines · Chase Douglas
Quoted 34 lines · Chase Douglas
Quoted 22 lines · Jaikumar Ganesh

Hi Chase

On Thu, Aug 18, 2011 at 9:25 AM, Chase Douglas <[email protected] <mailto:[email protected]>> wrote:

    On 08/17/2011 12:59 PM, Jaikumar Ganesh wrote:
    > From: Jiri Kosina <[email protected] <mailto:[email protected]>> >
    > 23746a introduced this commit but was reverted in c3a492. > The trackpad uses report Ids which are not present in the > report descriptor. These reports ids are not documented > anywhere. There are devices in the market (Apple magic tracpkad, > BT version 2.0 is one such device) with the same device id, > which fail when we use 0xd7 as the report id. So we need the EIO > change of 23746a as a failsafe to work with these devices. >
    > Original Author: Jiri Kosina <[email protected] <mailto:[email protected]>>
    >
    > Signed-off-by: Jaikumar Ganesh <[email protected] <mailto:[email protected]>>

Quoted 7 lines

    I worry this may just be papering over a bug elsewhere in the system again. I'm going to try to git bisect this today.

The original commit explains in detail why it used to work before, so its not a regression in that sense. The commit was present in 2.6.39 stable tree too but was reverted in 3.0 tree.

It was reverted because it was papering over a bug in the bluetooth stack, and when that bug was fixed this commit broke things again.

Quoted 7 lines

I've determined that there's a bug between Ubuntu's 3.0-1.2 and 3.0-2.3 kernels. There does not appear to be any Ubuntu specific patches that went in between those versions that would affect this, but there was a rebase from upstream 3.0-rc3 to 3.0-rc4. There is likely a bug introduced sometime in there.

I'll be digging deeper...

After some more digging I realized that the bluetooth fix for some devices went in at 3.0-rc4, just as the reversion of this patch went in. Thus, my bisect of ubuntu kernels was unhelpful.

I decided to try a few tests:

3.0-rc0 kernel with the bluetooth fix and this patch reverted 2.6.39 kernel with the bluetooth fix (this patch was not committed yet)

Both failed to properly initialize the magic trackpad. The only conclusion I can come up with is that there are some hardware differences between the machine I am currently testing with, and the machine I previously had the magicmouse working with.

Quoted 4 lines

If that's the case, the safest thing to do would be to apply this patch with a tweak. Don't check only that -EIO is returned. Check for either success or -EIO is returned. This should allow good and bad behaving hardware to still function.

I also tracked down two Apple magic trackpads - both with the same Bluetooth version.
One which needs this patch (as it returns an invalid report id) and the other which doesn't need this patch.
Both use the same device id.

Quoted 5 lines

Jiri, do you want me to send a rework of the patch, or do you want to do it yourself?

-- Chase

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Tested-by Chase Douglas
#6 lore raw
Quoted 5 lines · Jaikumar Ganesh

I also tracked down two Apple magic trackpads - both with the same Bluetooth version.
One which needs this patch (as it returns an invalid report id) and the other which doesn't need this patch.
Both use the same device id.

Gotta love hardware vendors indeed.

So how about the patch below?

From: Jiri Kosina <[email protected]>
Subject: [PATCH] HID: magicmouse: ignore 'ivalid report id' while switching modes, v2

This is basically a more generic respin of 23746a6 ("HID: magicmouse: ignore 'ivalid report id' while switching modes") which got reverted later by c3a492.

It turns out that on some configurations, this is actually still the case and we are not able to detect in runtime.

The device reponds with 'invalid report id' when feature report switching it into multitouch mode is sent to it.

This has been silently ignored before 0825411ade ("HID: bt: Wait for ACK on Sent Reports"), but since this commit, it propagates -EIO from the _raw callback .

So let the driver ignore -EIO as response to 0xd7,0x01 report, as that's how the device reacts in normal mode.

Sad, but following reality.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=35022

---
 drivers/hid/hid-magicmouse.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/hid/hid-magicmouse.c +9 -1
index b5bdab3..f0fbd7b 100644
@@ -537,9 +537,17 @@ static int magicmouse_probe(struct hid_device *hdev,
 	}
 	report->size = 6;
 
+	/*
+	 * Some devices repond with 'invalid report id' when feature
+	 * report switching it into multitouch mode is sent to it.
+	 *
+	 * This results in -EIO from the _raw low-level transport callback,
+	 * but there seems to be no other way of switching the mode.
+	 * Thus the super-ugly hacky success check below.
+	 */
 	ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
 			HID_FEATURE_REPORT);
-	if (ret != sizeof(feature)) {
+	if (ret != -EIO && ret != sizeof(feature)) {
 		hid_err(hdev, "unable to request touch data (%d)\n", ret);
 		goto err_stop_hw;
 	}
Signature · 1 line
1.7.3.1
#7 lore raw

Hi Jiri,

Quoted 70 lines · Jiri Kosina
Quoted 5 lines · Jaikumar Ganesh

I also tracked down two Apple magic trackpads - both with the same Bluetooth version.
One which needs this patch (as it returns an invalid report id) and the other which doesn't need this patch.
Both use the same device id.

Gotta love hardware vendors indeed.

So how about the patch below?

From: Jiri Kosina <[email protected]>
Subject: [PATCH] HID: magicmouse: ignore 'ivalid report id' while switching modes, v2

This is basically a more generic respin of 23746a6 ("HID: magicmouse: ignore 'ivalid report id' while switching modes") which got reverted later by c3a492.

It turns out that on some configurations, this is actually still the case and we are not able to detect in runtime.

The device reponds with 'invalid report id' when feature report switching it into multitouch mode is sent to it.

This has been silently ignored before 0825411ade ("HID: bt: Wait for ACK on Sent Reports"), but since this commit, it propagates -EIO from the _raw callback .

So let the driver ignore -EIO as response to 0xd7,0x01 report, as that's how the device reacts in normal mode.

Sad, but following reality.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=35022

---
 drivers/hid/hid-magicmouse.c |   10 +++++++++-

 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/hid/hid-magicmouse.c +9 -2
index b5bdab3..f0fbd7b 100644
@@ -537,9 +537,17 @@ static int magicmouse_probe(struct hid_device *hdev,
        }
        report->size = 6;
 
+       /*
+        * Some devices repond with 'invalid report id' when feature
+        * report switching it into multitouch mode is sent to it.
+        *
+        * This results in -EIO from the _raw low-level transport callback,
+        * but there seems to be no other way of switching the mode.
+        * Thus the super-ugly hacky success check below.
+        */
        ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
                        HID_FEATURE_REPORT);
-       if (ret != sizeof(feature)) {
+       if (ret != -EIO && ret != sizeof(feature)) {
                hid_err(hdev, "unable to request touch data (%d)\n", ret);
                goto err_stop_hw;
        }
--
Quoted 3 lines

1.7.3.1

Tested. Please push.

Thanks
Jaikumar
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
Quoted 51 lines · Jaikumar Ganesh
Quoted 51 lines

From: Jiri Kosina <[email protected]>
Subject: [PATCH] HID: magicmouse: ignore 'ivalid report id' while switching modes, v2

This is basically a more generic respin of 23746a6 ("HID: magicmouse: ignore 'ivalid report id' while switching modes") which got reverted later by c3a492.

It turns out that on some configurations, this is actually still the case and we are not able to detect in runtime.

The device reponds with 'invalid report id' when feature report switching it into multitouch mode is sent to it.

This has been silently ignored before 0825411ade ("HID: bt: Wait for ACK on Sent Reports"), but since this commit, it propagates -EIO from the _raw callback .

So let the driver ignore -EIO as response to 0xd7,0x01 report, as that's how the device reacts in normal mode.

Sad, but following reality.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=35022

---
 drivers/hid/hid-magicmouse.c |   10 +++++++++-

 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/hid/hid-magicmouse.c +8 -1
index b5bdab3..f0fbd7b 100644
@@ -537,9 +537,17 @@ static int magicmouse_probe(struct hid_device *hdev,
        }
        report->size = 6;
 
+       /*
+        * Some devices repond with 'invalid report id' when feature
+        * report switching it into multitouch mode is sent to it.
+        *
+        * This results in -EIO from the _raw low-level transport callback,
+        * but there seems to be no other way of switching the mode.
+        * Thus the super-ugly hacky success check below.
+        */
        ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
                        HID_FEATURE_REPORT);
-       if (ret != sizeof(feature)) {
Quoted 8 lines
Quoted 6 lines
drivers/hid/hid-magicmouse.c +1 -1
+       if (ret != -EIO && ret != sizeof(feature)) {
                hid_err(hdev, "unable to request touch data (%d)\n", ret);
                goto err_stop_hw;
        }
--

1.7.3.1

Tested. Please push.

Okay, I have queued it with your Tested-by. Thanks,

Signature · 6 lines
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw
In reply to Jiri Kosina
Quoted 8 lines · Jiri Kosina
Quoted 5 lines · Jaikumar Ganesh

I also tracked down two Apple magic trackpads - both with the same Bluetooth version.
One which needs this patch (as it returns an invalid report id) and the other which doesn't need this patch.
Both use the same device id.

Quoted 8 lines

Gotta love hardware vendors indeed.

So how about the patch below?

From: Jiri Kosina <[email protected]>
Subject: [PATCH] HID: magicmouse: ignore 'ivalid report id' while switching modes, v2

spelling: ^

Quoted 18 lines

This is basically a more generic respin of 23746a6 ("HID: magicmouse: ignore 'ivalid report id' while switching modes") which got reverted later by c3a492.

It turns out that on some configurations, this is actually still the case and we are not able to detect in runtime.

The device reponds with 'invalid report id' when feature report switching it into multitouch mode is sent to it.

This has been silently ignored before 0825411ade ("HID: bt: Wait for ACK on Sent Reports"), but since this commit, it propagates -EIO from the _raw callback .

So let the driver ignore -EIO as response to 0xd7,0x01 report, as that's how the device reacts in normal mode.

Quoted 8 lines

Sad, but following reality.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=35022

Looks good to me. I tested it and it fixed things here.

Thanks!

-- Chase