Bug 275115 - ig4(4): Intel Ice Lake I2C not recognized
Summary: ig4(4): Intel Ice Lake I2C not recognized
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.2-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Vladimir Kondratyev
URL:
Keywords: needs-patch, needs-qa
Depends on:
Blocks:
 
Reported: 2023-11-15 18:04 UTC by Sam
Modified: 2023-12-21 12:36 UTC (History)
3 users (show)

See Also:


Attachments
dmesg output (16.02 KB, text/plain)
2023-11-15 18:04 UTC, Sam
no flags Details
pciconf -lv output (4.10 KB, text/plain)
2023-11-15 18:08 UTC, Sam
no flags Details
icelake-i2c.patch (1.86 KB, patch)
2023-11-19 19:28 UTC, Vladimir Kondratyev
no flags Details | Diff
dmesg output (18.63 KB, text/plain)
2023-11-22 14:17 UTC, Sam
no flags Details
pciconf -lv output (4.10 KB, text/plain)
2023-11-22 14:26 UTC, Sam
no flags Details
devinfo -rv output (16.89 KB, text/plain)
2023-11-22 14:30 UTC, Sam
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sam 2023-11-15 18:04:41 UTC
Created attachment 246341 [details]
dmesg output

This issue is similar to https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245654 but for Intel IceLake.
Comment 1 Sam 2023-11-15 18:08:09 UTC
Created attachment 246342 [details]
pciconf -lv output
Comment 2 Vladimir Kondratyev freebsd_committer freebsd_triage 2023-11-19 19:28:05 UTC
Created attachment 246428 [details]
icelake-i2c.patch

Test attached patch.
Comment 3 Sam 2023-11-22 14:17:21 UTC
Created attachment 246488 [details]
dmesg output
Comment 4 Sam 2023-11-22 14:26:35 UTC
Created attachment 246489 [details]
pciconf -lv output

Tell me if I tested the patch correctly. I'm a newbie.

I applied the patch by:
$ cd /sys/dev/ichiic/
$ sudo patch ig4_pci.c < icelake-i2c.patch

Then compiled it by:
$ cd /usr/src/sys/modules/i2c/controllers/ichiic/
$ sudo make

And then I loaded the module by:
$ sudo kldload /usr/obj/usr/src/amd64.amd64/sys/modules/i2c/controllers/ichiic/ig4.ko

But it did not work. So I added the above module in kldlist of /etc/rc.conf and rebooted. Still it didn't.
Comment 5 Sam 2023-11-22 14:30:08 UTC
Created attachment 246490 [details]
devinfo -rv output

Side question: How to add multiple attachments?
Comment 6 Sam 2023-11-22 14:39:13 UTC
(In reply to Sam from comment #5)
> Side question: How to add multiple attachments?
I got it, it's not possible. If we want to add output of multiple commands we need to concatenate the files.
Comment 7 Vladimir Kondratyev freebsd_committer freebsd_triage 2023-11-22 15:29:35 UTC
(In reply to Sam from comment #4)
> But it did not work. So I added the above module in kldlist of /etc/rc.conf and rebooted. Still it didn't.

ig4iic0 and ig4iic1 devices appeared in every file you attached.

What do you mean 'not work' ?
Comment 8 Sam 2023-11-22 18:36:06 UTC
(In reply to Vladimir Kondratyev from comment #7)
Touchpad did not work.
Comment 9 Sam 2023-11-23 17:03:47 UTC
I suspect that this touchpad is not working because of undetected serial bus devices.

As we can see in pciconf output these two devices are undetected:
none3@pci0:0:31:4:	class=0x0c0500 rev=0x30 hdr=0x00 vendor=0x8086 device=0x34a3 subvendor=0x103c subdevice=0x86c8
none4@pci0:0:31:5:	class=0x0c8000 rev=0x30 hdr=0x00 vendor=0x8086 device=0x34a4 subvendor=0x103c subdevice=0x86c8

After some work I managed to get the none3 device get detected by adding following lines in '/usr/src/sys/dev/ichsmb/ichsmb_pci.c'
#define	ID_ICELAKE			0x34a3
	{ PCI_DEV(PCI_VENDOR_INTEL, ID_ICELAKE),
	 PCI_DESCR("Intel Ice Lake SMBus controller") },

Now new pciconf line for none3 is:
ichsmb0@pci0:0:31:4:	class=0x0c0500 rev=0x30 hdr=0x00 vendor=0x8086 device=0x34a3 subvendor=0x103c subdevice=0x86c8

For none4 I think we need to edit files in '/usr/src/sys/modules/intelspi', but I'm not sure what to put in these files.
Here is the relevant file from Linux kernel https://lxr.linux.no/#linux+v6.0.9/drivers/spi/spi-intel-pci.c
Comment 10 Vladimir Kondratyev freebsd_committer freebsd_triage 2023-11-23 18:16:11 UTC
(In reply to Sam from comment #8)

iicbus driver did not find any ACPI info about devices attached to I2C bus.

To be on the safe side, rebuild and reinstall whole kernel rather than single module with 'make -j`sysctl -n kern.smp.cpus` kernel'. Than test again.

If it does not help, then attach 'acpidump -dt' output.
Comment 11 Sam 2023-11-24 04:48:44 UTC
(In reply to Vladimir Kondratyev from comment #10)
Thank you! Touchpad worked this time.
I wonder why after building the whole kernel.
Comment 12 commit-hook freebsd_committer freebsd_triage 2023-11-27 15:26:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=789ffce392946d2f71a51bbac60db16dcdea2928

commit 789ffce392946d2f71a51bbac60db16dcdea2928
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2023-11-27 15:25:48 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2023-11-27 15:25:48 +0000

    ig4: Add PCI IDs for Intel Ice Lake I2C controller.

    PR:             275115
    Tested by:      Sam <sam3423.yntmr_AT_slmail_DOT_me>
    MFC after:      2 weeks

 sys/dev/ichiic/ig4_pci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Comment 13 Vladimir Kondratyev freebsd_committer freebsd_triage 2023-11-27 16:05:12 UTC
(In reply to Sam from comment #11)

> I wonder why after building the whole kernel.
I don't know. May be updated linker hints did the trick.
Comment 14 Dmitry Lukhtionov 2023-12-15 11:02:39 UTC
Hi
Can you test this patch for intel spi ?

```
--- sys/dev/intel/spi_pci.c.orig	2023-11-28 11:52:25.113630000 +0200
+++ sys/dev/intel/spi_pci.c	2023-12-15 12:33:35.695709000 +0200
@@ -46,6 +46,7 @@
 	enum intelspi_vers vers;
 	const char *desc;
 } intelspi_pci_devices[] = {
+	{ 0x34a48086, SPI_SUNRISEPOINT, "Intel Ice Lake-LP SPI Controller" },
 	{ 0x9c658086, SPI_LYNXPOINT, "Intel Lynx Point-LP SPI Controller-0" },
 	{ 0x9c668086, SPI_LYNXPOINT, "Intel Lynx Point-LP SPI Controller-1" },
 	{ 0x9ce58086, SPI_LYNXPOINT, "Intel Wildcat Point SPI Controller-0" },
```
Comment 15 Sam 2023-12-16 16:14:53 UTC
(In reply to Dmitry Lukhtionov from comment #14)
I applied the patch and compiled the kernel but, I think it's not getting detected.

Relevant pciconf output:

```
none3@pci0:0:31:5:	class=0x0c8000 rev=0x30 hdr=0x00 vendor=0x8086 device=0x34a4 subvendor=0x103c subdevice=0x86c8
    vendor     = 'Intel Corporation'
    device     = 'Ice Lake-LP SPI Controller'
    class      = serial bus
```
Comment 16 Sam 2023-12-16 16:24:31 UTC
(In reply to Sam from comment #15)
Relevant dmesg | grep spi output:
```
spi0: <Intel Ice Lake-LP SPI Controller> mem 0xfe010000-0xfe010fff at device 31.5 on pci0
spi0: Using MSI
spi0: can't allocate IRQ resource
device_attach: spi0 attach returned 6
```
Comment 17 Dmitry Lukhtionov 2023-12-19 11:08:21 UTC
Can you use SPI_LYNXPOINT instead of SPI_SUNRISEPOINT ?
And recompile module again 

thanks in advance
Comment 18 commit-hook freebsd_committer freebsd_triage 2023-12-19 20:48:50 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=36d6a456547cfe2a565bc60990e9cf421d267d07

commit 36d6a456547cfe2a565bc60990e9cf421d267d07
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2023-11-27 15:25:48 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2023-12-19 20:34:56 +0000

    ig4: Add PCI IDs for Intel Ice Lake I2C controller.

    PR:             275115
    Tested by:      Sam <sam3423.yntmr_AT_slmail_DOT_me>

 sys/dev/ichiic/ig4_pci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Comment 19 commit-hook freebsd_committer freebsd_triage 2023-12-19 20:54:52 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2cbd132986a782f689e169f4bf47793e1fc8a147

commit 2cbd132986a782f689e169f4bf47793e1fc8a147
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2023-11-27 15:25:48 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2023-12-19 20:53:48 +0000

    ig4: Add PCI IDs for Intel Ice Lake I2C controller.

    PR:             275115
    Tested by:      Sam <sam3423.yntmr_AT_slmail_DOT_me>

    (cherry picked from commit 789ffce392946d2f71a51bbac60db16dcdea2928)

 sys/dev/ichiic/ig4_pci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Comment 20 Sam 2023-12-20 05:11:35 UTC
(In reply to Dmitry Lukhtionov from comment #17)
Still no success.

Relevant outputs:

dmesg | grep spi
```
spi0: <Intel Ice Lake-LP SPI Controller> mem 0xfe010000-0xfe010fff at device 31.5 on pci0
spi0: Using MSI
spi0: can't allocate IRQ resource
device_attach: spi0 attach returned 6
```

pciconf -lv
```
none3@pci0:0:31:5:	class=0x0c8000 rev=0x30 hdr=0x00 vendor=0x8086 device=0x34a4 subvendor=0x103c subdevice=0x86c8
    vendor     = 'Intel Corporation'
    device     = 'Ice Lake-LP SPI Controller'
    class      = serial bus
```
Comment 21 Vladimir Kondratyev freebsd_committer freebsd_triage 2023-12-21 12:36:11 UTC
Just my 2 cents:

There seems to be a bug in MSI support in intel_spi. It always reports 'Using MSI' but ever fails to allocate them and silently falls back to wired ones.

But according to pciconf output sent to me by Dmitry privately his Icelake SPI controller does not expose MSI capability, so that is not an issue.

The aforementioned bug is originated in ig4 driver and have to be fixed in ig4 too.