Skip to contentSkip to conversation

35022: hid-magicmouse broken

DISCUSSION Chase Douglas 2 participants 12 messages May 17, 2011 – May 23, 2011

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
Quoted 9 lines · Chase Douglas

Hi Jiri,

I've received a few emails about the magicmouse driver being broken on 2.6.39:

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

It seems hid_output_raw_report() is returning a different (incorrect?) value than in the past. Do you know what might be going on?

So we are getting EIO from the transport-level _raw callback.

Hmm, commit 0825411ade seems like a suspect here. Might be possible that magicmouse doesn't send ACK back, right?

Could you please try reverting that commit and re-test?

Adding Alan to CC.

Signature · 2 lines
Jiri Kosina
SUSE Labs
#2 lore raw
Quoted 12 lines · Jiri Kosina
Quoted 9 lines · Chase Douglas

Hi Jiri,

I've received a few emails about the magicmouse driver being broken on 2.6.39:

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

It seems hid_output_raw_report() is returning a different (incorrect?) value than in the past. Do you know what might be going on?

Quoted 6 lines

So we are getting EIO from the transport-level _raw callback.

Hmm, commit 0825411ade seems like a suspect here. Might be possible that magicmouse doesn't send ACK back, right?

Could you please try reverting that commit and re-test?

Yes, reverting that commit makes it work.

I'm just speculating here, based on commit message names and what you've said, that the magicmouse is not protocol compliant because it is not sending an ACK back? What do you think we should do in the driver? Should we ignore the return, or should we look specifically for EIO? (neither sounds very good to me, so I'm hoping you have a better solution :).

Thanks!

-- Chase

#3 lore raw
Quoted 8 lines · Chase Douglas
Quoted 8 lines
Quoted 2 lines

It seems hid_output_raw_report() is returning a different (incorrect?) value than in the past. Do you know what might be going on?

So we are getting EIO from the transport-level _raw callback.

Hmm, commit 0825411ade seems like a suspect here. Might be possible that magicmouse doesn't send ACK back, right?

Quoted 7 lines
Quoted 1 line

Could you please try reverting that commit and re-test?

Yes, reverting that commit makes it work.

I'm just speculating here, based on commit message names and what you've said, that the magicmouse is not protocol compliant because it is not sending an ACK back?

Yes, I believe that's what is happening. Could you please report what is the dmesg output with the patch below, just to make sure that we understand the situation precisely?

Quoted 3 lines

What do you think we should do in the driver? Should we ignore the return, or should we look specifically for EIO? (neither sounds very good to me, so I'm hoping you have a better solution :).

Well if the device indeed doesn't send the ACK and it should (I will have to check the specs first), we'll have to put a quirk into the driver. Otherwise if the ACK is not mandatory, we'll have to revert that commit (or at least make it non-fatal failure).

But I'll have to check the specs first.

 net/bluetooth/hidp/core.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
net/bluetooth/hidp/core.c +4 -1
index 5ec1297..21025ed 100644
@@ -403,6 +403,7 @@ static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, s
 	struct hidp_session *session = hid->driver_data;
 	int ret;
 
+	printk(KERN_DEBUG "hidp_output_raw_report, report_type: %d\n", report_type);
 	switch (report_type) {
 	case HID_FEATURE_REPORT:
 		report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE;
@@ -434,6 +435,7 @@ static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, s
 			10*HZ);
 		if (res == 0) {
 			/* timeout */
+			printk(KERN_DEBUG "hidp: returning -EIO because of timeout\n");
 			ret = -EIO;
 			goto err;
 		}
@@ -445,6 +447,7 @@ static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, s
 	}
 
 	if (!session->output_report_success) {
+		printk(KERN_DEBUG "hidp: returnign -EIO because of !output_report_success\n");
 		ret = -EIO;
 		goto err;
 	}
@@ -480,7 +483,7 @@ static inline void hidp_del_timer(struct hidp_session *session)
 static void hidp_process_handshake(struct hidp_session *session,
 					unsigned char param)
 {
-	BT_DBG("session %p param 0x%02x", session, param);
+	printk(KERN_DEBUG "session %p param 0x%02x", session, param);
 	session->output_report_success = 0; /* default condition */
 
 	switch (param) {
Signature · 2 lines
Jiri Kosina
SUSE Labs
#4 lore raw
Quoted 14 lines · Jiri Kosina
Quoted 12 lines · Chase Douglas
Quoted 9 lines
Quoted 2 lines

It seems hid_output_raw_report() is returning a different (incorrect?) value than in the past. Do you know what might be going on?

So we are getting EIO from the transport-level _raw callback.

Hmm, commit 0825411ade seems like a suspect here. Might be possible that magicmouse doesn't send ACK back, right?

Could you please try reverting that commit and re-test?

Yes, reverting that commit makes it work.

Quoted 7 lines
Quoted 3 lines

I'm just speculating here, based on commit message names and what you've said, that the magicmouse is not protocol compliant because it is not sending an ACK back?

Yes, I believe that's what is happening. Could you please report what is the dmesg output with the patch below, just to make sure that we understand the situation precisely?

Here's the output in dmesg:

[  195.491735] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[  222.693947] input: cndougla’s trackpad as
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/bluetooth/hci0/hci0:12/input16
[  222.694119] magicmouse 0005:05AC:030E.0005: input,hidraw3: BLUETOOTH
HID v1.60 Mouse [cndougla’s trackpad] on 50:63:13:90:AF:A4
[  222.694128] hidp_output_raw_report, report_type: 2
[  222.808111] session ffff88012d9b1200 param 0x02
[  222.808198] hidp: returnign -EIO because of !output_report_success
[  222.808209] magicmouse 0005:05AC:030E.0005: unable to request touch
data (-5)
[  222.809358] session ffff88012d9b1200 param 0x02
[  222.810606] session ffff88012d9b1200 param 0x02
[  222.813113] session ffff88012d9b1200 param 0x00
[  223.045363] magicmouse: probe of 0005:05AC:030E.0005 failed with error -5
Quoted 10 lines
Quoted 3 lines

What do you think we should do in the driver? Should we ignore the return, or should we look specifically for EIO? (neither sounds very good to me, so I'm hoping you have a better solution :).

Well if the device indeed doesn't send the ACK and it should (I will have to check the specs first), we'll have to put a quirk into the driver. Otherwise if the ACK is not mandatory, we'll have to revert that commit (or at least make it non-fatal failure).

But I'll have to check the specs first.

Sounds good to me :).

Thanks!

-- 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

#5 lore raw
Quoted 16 lines · Chase Douglas

Here's the output in dmesg:

[  195.491735] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[  222.693947] input: cndougla’s trackpad as
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/bluetooth/hci0/hci0:12/input16
[  222.694119] magicmouse 0005:05AC:030E.0005: input,hidraw3: BLUETOOTH
HID v1.60 Mouse [cndougla’s trackpad] on 50:63:13:90:AF:A4
[  222.694128] hidp_output_raw_report, report_type: 2
[  222.808111] session ffff88012d9b1200 param 0x02
[  222.808198] hidp: returnign -EIO because of !output_report_success
[  222.808209] magicmouse 0005:05AC:030E.0005: unable to request touch
data (-5)
[  222.809358] session ffff88012d9b1200 param 0x02
[  222.810606] session ffff88012d9b1200 param 0x02
[  222.813113] session ffff88012d9b1200 param 0x00
[  223.045363] magicmouse: probe of 0005:05AC:030E.0005 failed with error -5

Ok, so what is happening here is that magicmouse_probe() sends the { 0xd7, 0x01 } feature report to the device, and it responds with HIDP_HSHK_ERR_INVALID_REPORT_ID.

That's why the _raw callback (correctly) returns error.

So the question to the driver authors is -- what is the point behind the { 0xd7, 0x01 } report? Clearly the device doesn't like it during probe because of invalid report ID.
And it never did, we just silently ignored the error with the older kernels.

Michael?

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
#6 lore raw
Quoted 23 lines · Jiri Kosina
Quoted 16 lines · Chase Douglas

Here's the output in dmesg:

[  195.491735] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[  222.693947] input: cndougla’s trackpad as
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/bluetooth/hci0/hci0:12/input16
[  222.694119] magicmouse 0005:05AC:030E.0005: input,hidraw3: BLUETOOTH
HID v1.60 Mouse [cndougla’s trackpad] on 50:63:13:90:AF:A4
[  222.694128] hidp_output_raw_report, report_type: 2
[  222.808111] session ffff88012d9b1200 param 0x02
[  222.808198] hidp: returnign -EIO because of !output_report_success
[  222.808209] magicmouse 0005:05AC:030E.0005: unable to request touch
data (-5)
[  222.809358] session ffff88012d9b1200 param 0x02
[  222.810606] session ffff88012d9b1200 param 0x02
[  222.813113] session ffff88012d9b1200 param 0x00
[  223.045363] magicmouse: probe of 0005:05AC:030E.0005 failed with error -5

Ok, so what is happening here is that magicmouse_probe() sends the { 0xd7, 0x01 } feature report to the device, and it responds with HIDP_HSHK_ERR_INVALID_REPORT_ID.

Quoted 7 lines

That's why the _raw callback (correctly) returns error.

So the question to the driver authors is -- what is the point behind the { 0xd7, 0x01 } report? Clearly the device doesn't like it during probe because of invalid report ID.
And it never did, we just silently ignored the error with the older kernels.

The feature report is what flips the devices (magic mouse, magic trackpad) into multitouch mode. Without the report, the mouse will not emit the location of any touches on its surface, and the trackpad will only emit single touch data.

What do you think we should do? We can't get rid of the report. Should we silently ignore the error?

Thanks
--
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

#7 lore raw
Quoted 27 lines · Chase Douglas
Quoted 19 lines
Quoted 6 lines
[  195.491735] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[  222.693947] input: cndougla’s trackpad as
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/bluetooth/hci0/hci0:12/input16
[  222.694119] magicmouse 0005:05AC:030E.0005: input,hidraw3: BLUETOOTH
HID v1.60 Mouse [cndougla’s trackpad] on 50:63:13:90:AF:A4
[  222.694128] hidp_output_raw_report, report_type: 2
Quoted 8 lines
[  222.808111] session ffff88012d9b1200 param 0x02
[  222.808198] hidp: returnign -EIO because of !output_report_success
[  222.808209] magicmouse 0005:05AC:030E.0005: unable to request touch
data (-5)
[  222.809358] session ffff88012d9b1200 param 0x02
[  222.810606] session ffff88012d9b1200 param 0x02
[  222.813113] session ffff88012d9b1200 param 0x00
[  223.045363] magicmouse: probe of 0005:05AC:030E.0005 failed with error -5

Ok, so what is happening here is that magicmouse_probe() sends the { 0xd7, 0x01 } feature report to the device, and it responds with HIDP_HSHK_ERR_INVALID_REPORT_ID.

Quoted 7 lines

That's why the _raw callback (correctly) returns error.

So the question to the driver authors is -- what is the point behind the { 0xd7, 0x01 } report? Clearly the device doesn't like it during probe because of invalid report ID.
And it never did, we just silently ignored the error with the older kernels.

Quoted 7 lines

The feature report is what flips the devices (magic mouse, magic trackpad) into multitouch mode. Without the report, the mouse will not emit the location of any touches on its surface, and the trackpad will only emit single touch data.

What do you think we should do? We can't get rid of the report. Should we silently ignore the error?

Hmm, I am afraid that it's the only option (apart from thowing the whole 'waiting for ack' infrastructure away, which would be sad, as it's a good thing in principle).

So how about the patch below? :/ Could you please verify that it makes hid-magicmouse work again? Thanks.

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

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 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 · 6 lines
1.7.3.1

--
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
author Reviewed-by
#8 lore raw
Quoted 81 lines · Jiri Kosina
Quoted 27 lines · Chase Douglas
Quoted 19 lines
Quoted 6 lines
[  195.491735] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[  222.693947] input: cndougla’s trackpad as
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.3/1-1.3.3:1.0/bluetooth/hci0/hci0:12/input16
[  222.694119] magicmouse 0005:05AC:030E.0005: input,hidraw3: BLUETOOTH
HID v1.60 Mouse [cndougla’s trackpad] on 50:63:13:90:AF:A4
[  222.694128] hidp_output_raw_report, report_type: 2
Quoted 8 lines
[  222.808111] session ffff88012d9b1200 param 0x02
[  222.808198] hidp: returnign -EIO because of !output_report_success
[  222.808209] magicmouse 0005:05AC:030E.0005: unable to request touch
data (-5)
[  222.809358] session ffff88012d9b1200 param 0x02
[  222.810606] session ffff88012d9b1200 param 0x02
[  222.813113] session ffff88012d9b1200 param 0x00
[  223.045363] magicmouse: probe of 0005:05AC:030E.0005 failed with error -5

Ok, so what is happening here is that magicmouse_probe() sends the { 0xd7, 0x01 } feature report to the device, and it responds with HIDP_HSHK_ERR_INVALID_REPORT_ID.

Quoted 7 lines

That's why the _raw callback (correctly) returns error.

So the question to the driver authors is -- what is the point behind the { 0xd7, 0x01 } report? Clearly the device doesn't like it during probe because of invalid report ID.
And it never did, we just silently ignored the error with the older kernels.

Quoted 7 lines

The feature report is what flips the devices (magic mouse, magic trackpad) into multitouch mode. Without the report, the mouse will not emit the location of any touches on its surface, and the trackpad will only emit single touch data.

What do you think we should do? We can't get rid of the report. Should we silently ignore the error?

Hmm, I am afraid that it's the only option (apart from thowing the whole 'waiting for ack' infrastructure away, which would be sad, as it's a good thing in principle).

So how about the patch below? :/ Could you please verify that it makes hid-magicmouse work again? Thanks.

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

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 +5 -0
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,

drivers/hid/hid-magicmouse.c static int magicmouse_probe(struct hid_device *hdev, · line 517

Quoted 10 lines
drivers/hid/hid-magicmouse.c +4 -1
+	 * 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;
 	}

Seems to work for me :).

Thanks!
--
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
Quoted 1 line · Chase Douglas

Seems to work for me :).

I have applied the patch with your Tested-by. Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#10 lore raw
Quoted 5 lines · Jiri Kosina
Quoted 1 line · Chase Douglas

Seems to work for me :).

I have applied the patch with your Tested-by. Thanks,

Thanks Jiri!

Could you add 'Cc: [email protected]' if it hasn't been merged yet? It looks like .39 was just released without this patch...

#11 lore raw
Quoted 8 lines · Chase Douglas
Quoted 3 lines
Quoted 1 line

Seems to work for me :).

I have applied the patch with your Tested-by. Thanks,

Thanks Jiri!

Could you add 'Cc: [email protected]' if it hasn't been merged yet? It looks like .39 was just released without this patch...

I will be sending this patch to stable once it's in Linus tree (I will be sending pull request likely today).

Signature · 2 lines
Jiri Kosina
SUSE Labs