I test 15/stable on MateBookPro 2023, touchpad is not work anymore, It is working on 14.3-RELEASE, dmesg show: iichid0: <GXTP7863:00 27C6:01E0 I2C HID device> at addr 0x15 on iicbus14 iichid0: Using sampling mode hidbus0: <HID bus> on iichid0 acpi_pwr_switch_consumer: new power state D3cold is not the one requested D0 iichid1: <GXTP738X:00 27C6:0114 I2C HID device> at addr 0x5d on iicbus15 iichid1: Using sampling mode hidbus1: <HID bus> on iichid1 hmt0: <GXTP7863:00 27C6:01E0 TouchPad> on hidbus0 hconf0: <GXTP7863:00 27C6:01E0 Configuration> on hidbus0 hmt0: Multitouch touchpad with 2 external buttons, click-pad hmt0: 5 contacts with [C] properties. Report range [0:0] - [3684:2338] hmt1: <GXTP738X:00 27C6:0114 TouchScreen> on hidbus1 hmt1: Multitouch touchscreen with 0 external buttons hmt1: 10 contacts with [] properties. Report range [0:0] - [6240:4160] Security policy loaded: MAC/ntpd (mac_ntpd) wlan0: link state changed to UP ig4iic0: Failed to abort transfer. Do the controller reset. ig4iic0: Failed to abort transfer. Do the controller reset. ig4iic0: Failed to abort transfer. Do the controller reset. and a lot of: ig4iic0: Failed to abort transfer. Do the controller reset. # uname -a FreeBSD mbxp.jopens.cn 15.0-ALPHA1 FreeBSD 15.0-ALPHA1 #0 stable/15-n280099-0b3d82579a01-dirty: Sun Sep 7 19:28:24 CST 2025 root@mbxp.jopens.cn:/usr/obj/usr/src/amd64.amd64/sys/MBXP amd64
The culprit is "iichid: Stop using split I²C bus transactions" by git bisect: commit 36027361f9cfb76013153a032286eccda1512359 (HEAD) Author: Poul-Henning Kamp <phk@FreeBSD.org> Date: Tue Jul 29 06:17:43 2025 +0000 iichid: Stop using split I²C bus transactions Read IIC-HID reports as a single I²C transaction, instead of reading first the two byte length field, holding the bus, and then the rest of the report in a separate transaction. While technically legal, I²C bus split transactions are not universally supported, and in particular the "Snapdragon Elite" ARM CPU does not seem to support them. It is also not obvious that they are beneficial in this case, given the overhead of controller setup, interrupts and tear-down. Reviewed by: wulf Differential Revision: https://reviews.freebsd.org/D51302
Can you try to enable some of the debugging to see what it is actually trying to do at the I²C level ? In particular look for reports from the touch-pad where the first two bytes indicate a longer length than we expect to receive.
Created attachment 263848 [details] dmesg_good
Created attachment 263849 [details] dmesg_bad
I notice the "Using sampling mode", do you happen to know why interrupts could not be set up ? The only idea I have right now, is that because we are in polling mode, we are getting zero bytes back from the device which are not in fact indications that the RESET finished. Normally we would get an interrupt, read the zero bytes and be good to go. But in polling mode we may be reading before the interrupt happens and get zeros from the device as a surprised "you talkin' to me?" non-reply, which we then mistake for the RESET completed message. You can probably test this theory by sticking a sensibly long delay before: /* Wait for RESET response */ and see if that changes things ? If that theory holds, and by doing so we manage to wedge the device, ig4iic might be justified in not being able to get the bus back into whack, but it could also be that part of the ig4iic code needs to be looked at. (That will be wulf's department.)
(In reply to Poul-Henning Kamp from comment #5) I test long delay 5 seconds, not work. but I try to modify rdesc->rdsize: diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c index fdb4816b8bd9..90990da8afb3 100644 --- a/sys/dev/iicbus/iichid.c +++ b/sys/dev/iicbus/iichid.c @@ -820,8 +820,7 @@ iichid_intr_setup(device_t dev, device_t child __unused, hid_intr_t intr, * may set it to a wrong length. Also find the longest input report * in report descriptor, and add two for the length field. */ - rdesc->rdsize = 2 + - MAX(rdesc->isize, le16toh(sc->desc.wMaxInputLength)); + rdesc->rdsize = le16toh(sc->desc.wMaxInputLength); /* Write and get/set_report sizes are limited by I2C-HID protocol. */ rdesc->grsize = rdesc->srsize = IICHID_SIZE_MAX; rdesc->wrsize = IICHID_SIZE_MAX; this patch works, from my test: touchpad: rdesc->isize = 65 le16toh(sc->desc.wMaxInputLength) = 64 touchpad works if rdsize <= 64 for touchscreen: rdesc->isize = 65 le16toh(sc->desc.wMaxInputLength) = 34 touchscreen can work even rdsize = 67
I would personally not have a problem with that patch, but I do not know why we also walk the descriptors to find individual report lengths, nor if we calculate them correctly. Wulf@ knows the history better than I do, I just got rid of the split-i2c transactions. (although, the +2 is probably my mistake.)
Created attachment 263941 [details] Outline patch As mentioned, I am not qualified to say if rdesc->isize is calculated correctly, but if it is, this is the patch I would suggest. But as far as I can tell, the isize=65 will still break things for you, so this is mostly for reference.
> although, the +2 is probably my mistake. Just re-read specs. Correct formula is rdesc->rdsize = MAX(rdesc->isize + 2, le16toh(sc->desc.wMaxInputLength));
> rdesc->rdsize = le16toh(sc->desc.wMaxInputLength); This will broke some semi-HID devices like ietp(4) as they uses report descriptor overloading for input buffer sizing. Seems that le16toh(sc->desc.wMaxInputLength) should be used for HID devices and rdesc->isize + 2 for semi-HID
I hope this helps diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c index fdb4816b8bd..05d8dcf365e 100644 --- a/sys/dev/iicbus/iichid.c +++ b/sys/dev/iicbus/iichid.c @@ -820,8 +820,8 @@ iichid_intr_setup(device_t dev, device_t child __unused, hid_intr_t intr, * may set it to a wrong length. Also find the longest input report * in report descriptor, and add two for the length field. */ - rdesc->rdsize = 2 + - MAX(rdesc->isize, le16toh(sc->desc.wMaxInputLength)); + rdesc->rdsize = rdesc->rdsize == 0 ? + le16toh(sc->desc.wMaxInputLength) : rdesc->isize + 2; /* Write and get/set_report sizes are limited by I2C-HID protocol. */ rdesc->grsize = rdesc->srsize = IICHID_SIZE_MAX; rdesc->wrsize = IICHID_SIZE_MAX;
That works for the keyboard on my Snapdragon Thinkpad. (Cannot test touchpad until there's a X for arm64:16) With evidence that devices croak if we ask about too much data, I think we should truncate maxlen in iichid_read() appropriately ?
(In reply to Poul-Henning Kamp from comment #12) As I see maxlen == sc->intr_bufsize == rdesc->rdsize == le16toh(sc->desc.wMaxInputLength)
This works for both touchpad and touch screen.
In iichid_read() maxlen is a passed in parameter, which is passed (+2) to iichid_cmd_read(). (see line 930-ish) What I propose is that we trim it to be no larger than the "usual" maxlen.
(In reply to Poul-Henning Kamp from comment #15) IMO we should trim actlen when we invoke interrupt handler
Both maxlen and actlen includes length header
Here is the patch: diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c index 6d95d6d2d4f..c0119358f3f 100644 --- a/sys/dev/iicbus/iichid.c +++ b/sys/dev/iicbus/iichid.c @@ -299,11 +299,11 @@ iichid_cmd_read(struct iichid_softc* sc, void *buf, iichid_size_t maxlen, } } - if (actlen <= 2 || actlen > maxlen) { - actlen = 0; - } if (actual_len != NULL) { - *actual_len = actlen; + if (actlen <= 2 || actlen > maxlen) + *actual_len = 0; + else + *actual_len = actlen - 2; } return (error);
Ouch. You meant this? diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c index 6d95d6d2d4f..5bee2401f3a 100644 --- a/sys/dev/iicbus/iichid.c +++ b/sys/dev/iicbus/iichid.c @@ -278,7 +278,7 @@ iichid_cmd_read(struct iichid_softc* sc, void *buf, iichid_size_t maxlen, memset(buf, 0xaa, 2); // In case nothing gets read struct iic_msg msgs[] = { - { sc->addr, IIC_M_RD, maxlen, buf }, + { sc->addr, IIC_M_RD, maxlen + 2, buf }, }; int error; @@ -299,11 +299,11 @@ iichid_cmd_read(struct iichid_softc* sc, void *buf, iichid_size_t maxlen, } } - if (actlen <= 2 || actlen > maxlen) { - actlen = 0; - } if (actual_len != NULL) { - *actual_len = actlen; + if (actlen <= 2 || actlen > maxlen + 2) + *actual_len = 0; + else + *actual_len = actlen - 2; } return (error); @@ -537,7 +537,7 @@ iichid_sampling_task(void *context, int pending) if (!sc->power_on) goto out; - error = iichid_cmd_read(sc, sc->intr_buf, sc->intr_bufsize, &actual); + error = iichid_cmd_read(sc, sc->intr_buf, sc->intr_bufsize - 2, &actual); if (error == 0) { if (actual > 0) { sc->intr_handler(sc->intr_ctx, sc->intr_buf + 2, actual); @@ -601,7 +601,7 @@ iichid_intr(void *context) * acknowledge interrupts we fetch only length header and discard it. */ THREAD_SLEEPING_OK(); - error = iichid_cmd_read(sc, sc->intr_buf, sc->intr_bufsize, &actual); + error = iichid_cmd_read(sc, sc->intr_buf, sc->intr_bufsize - 2, &actual); THREAD_NO_SLEEPING(); if (error == 0) { if (sc->power_on && sc->open) {
But that still does not solve the problem I'm talking about: If the device croaks on IIC transactions longer than it has advertized, we should not attempt such transactions. That means that we have to cut maxlen down *before* we call iicbus_transfer() in iichid_cmd_read().
We can't cut maxlen down. It results in non-acknowledged interrupts on some devices.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=8f496952e3e6cdd531675a44b84b3f1954532afb commit 8f496952e3e6cdd531675a44b84b3f1954532afb Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2025-09-22 08:37:19 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2025-09-22 08:37:19 +0000 iichid(4): Always use wMaxInputLength bytes as input report length Lower values may result in non-acknowledged interrupts. E.g. ITE5570 device found in ASUS TUF. Greater values may result in read failures. E.g. GXTP7863 device found on MateBookPro 2023. Investigated by: huanghwh@gmail.com PR: 289353 MFC after: 1 week fixes: 36027361f9cf ("iichid: Stop using split I²C bus transactions") sys/dev/iicbus/iichid.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=c18032ba3172ec139056d71952b885b35f9fe107 commit c18032ba3172ec139056d71952b885b35f9fe107 Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2025-09-22 08:37:19 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2025-09-29 21:50:43 +0000 iichid(4): Always use wMaxInputLength bytes as input report length Lower values may result in non-acknowledged interrupts. E.g. ITE5570 device found in ASUS TUF. Greater values may result in read failures. E.g. GXTP7863 device found on MateBookPro 2023. Investigated by: huanghwh@gmail.com PR: 289353 MFC after: 1 week fixes: 36027361f9cf ("iichid: Stop using split I²C bus transactions") (cherry picked from commit 8f496952e3e6cdd531675a44b84b3f1954532afb) sys/dev/iicbus/iichid.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)