Bug 199715

Summary: hp_accel: probe of HPQ6007:00 failed with error -22 (HP Envy x360)
Product: Drivers Reporter: Lukas Kahnert (openproggerfreak)
Component: Platform_x86Assignee: drivers_platform_x86 (drivers_platform_x86)
Status: NEW ---    
Severity: normal CC: alexdeucher, bugzilla, luya, mail, maxime, russianneuromancer, sbergmans87, stasiek, sweetsound
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 4.16 Tree: Mainline
Regression: No
Attachments: dmesg 4.16.7 (Ignore ACPI Errors, its a different bug)
Disassembled ACPI table(DSDT)
EC Register Dump

Description Lukas Kahnert 2018-05-14 12:35:03 UTC
Created attachment 275967 [details]
dmesg 4.16.7 (Ignore ACPI Errors, its a different bug)

The HP Envy x360(Ryzen) uses an integrated accelerometer which get detected but probe fails with:

    lis3lv02d: unknown sensor type 0x0
    hp_accel: probe of HPQ6007:00 failed with error -22

I tried to search in the ACPI table and find out that the invalid return-value occurs cause of a "timeout". It looks like the EC needs some activation code to work, otherwise all querys will be returned with a "timeout" return-value. I have currently no Windows installation to compare the EC Register Dumps to find out why the EC is not responding for the accelerator.
Or am I absolutely wrong and the error is somewhere else?
I'm ready to help where I can.
Comment 1 Lukas Kahnert 2018-05-14 12:39:12 UTC
Created attachment 275969 [details]
Disassembled ACPI table(DSDT)
Comment 2 Lukas Kahnert 2018-05-14 12:42:10 UTC
Created attachment 275971 [details]
EC Register Dump
Comment 3 Luya Tshimbalanga 2018-11-21 04:43:41 UTC
I confirm this bug as I have similar model as list on journalctl boot report:
Nov 20 12:21:52 kernel: DMI: HP HP ENVY x360 Convertible 15-cp0xxx/8497, BIOS F.21 10/19/2018

The report suggest that hp_accel needs an update to allow the sensors functioning properly. It appears affecting all HP laptop powered wit AMD processors as Intel based have their functions working:
https://h30434.www3.hp.com/t5/Notebook-Video-Display-and-Touch/HP-Zbook-15-external-monitor-connected-to-docking-station/td-p/4985667
Comment 4 Luya Tshimbalanga 2018-11-21 23:02:36 UTC
After some investigation with Hans, the cause of the issue is the missing driver for AMD Sensor Fusion Hub (on some AMD laptop)  which does not exist in Linux. 

If you type lspci -nn, you should see one of message:

03:00.7 Non-VGA unclassified device [0000]: Advanced Micro Devices, Inc. [AMD] Device [1022:15e4]
Comment 5 Luya Tshimbalanga 2018-11-29 05:31:21 UTC
For better clarification, it would be better to rename the report "AMD Non-VGA unclassified device lacks non-existent AMD Sensor Fusion Hub for Linux".
Comment 6 P.Erbin 2019-01-26 13:07:25 UTC
Identical for me on my hp x360 envy 13-ag00xxx
As Luya did, ask for AMD support on this thread :
https://community.amd.com/thread/235302.
Comment 7 Luya Tshimbalanga 2019-03-16 21:03:21 UTC
The Sensor Fusion Hub is correctly identified on  kernel 4.20.14 displayed a more detailed information:

03:00.7 Non-VGA unclassified device [0000]: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/Renoir Sensor Fusion Hub [1022:15e4]

It looks like the info is from the linux-firmware. Still no driver.
Comment 9 Luya Tshimbalanga 2019-05-23 05:32:28 UTC
(In reply to Luya Tshimbalanga from comment #8)
> It looks like the driver has finally arrived:
> https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git/commit/?h=i2c/
> for-next&id=529766e0a0114438887382a68d97341fbf8349fb

Nevermind.
Comment 10 Luya Tshimbalanga 2019-07-16 15:21:04 UTC
According to AMD, the driver will be ready somewhere on August:
https://lists.freedesktop.org/archives/amd-gfx/2019-May/034431.html
Comment 11 JSaw 2019-09-17 17:01:26 UTC
Hi, it's September now, might there be any news on this? The screen rotation is not yet working for me. I am on Arch Linux and latest kernel. So I guess the driver isn't released yet?
Comment 12 Luya Tshimbalanga 2019-10-09 05:25:11 UTC
(In reply to JSaw from comment #11)
> Hi, it's September now, might there be any news on this? The screen rotation
> is not yet working for me. I am on Arch Linux and latest kernel. So I guess
> the driver isn't released yet?

Not yet at the time of writing. According to Alex from AMD, the FCH team clean up the initial implementation based on the community feedback. The patch should be available on the hid subsystem repository of the Linux kernel.


https://lists.freedesktop.org/archives/amd-gfx/2019-September/040553.html
Comment 13 Luya Tshimbalanga 2020-01-11 06:27:25 UTC
It looks like the patches for AMD Sensor Fusion HUB driver are finally available. 
https://patchwork.kernel.org/project/linux-iio/list/?submitter=175589
Comment 14 Stasiek Michalski 2020-01-12 14:30:47 UTC
Hm, this is interesting, I compiled the driver, and was going over the documentation. Intel ish comparison isn't wrong, however Intel implements a mechanism to register the sensors on the hub as devices with the kernel, for use with the user space applications. AMD seems to expect "hid user space" to implement the drivers based on hid input reports instead, which is an interesting approach. Maybe I'm missing something, but I don't really see a reason not to register devices based on those reports, instead of expecting user space to take care of this. I will keep poking at this though.
Comment 15 Luya Tshimbalanga 2020-01-31 20:56:47 UTC
New revised patches available:
https://patchwork.kernel.org/project/linux-iio/list/?submitter=175589
Comment 16 Luya Tshimbalanga 2020-02-05 05:03:10 UTC
I built a test kernel with enabled amd_sfh_hid as modules (amd_mp2_pcie and amd_sfhtp_hid) using the latest patches from comment #15 running on HP Envy x360 Ryzen 2500u

lspci -vv

03:00.7 Non-VGA unclassified device: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/Renoir Sensor Fusion Hub
	Subsystem: Hewlett-Packard Company Device 8497
	Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 0, Cache Line Size: 64 bytes
	Interrupt: pin D routed to IRQ 33
	Region 2: Memory at fc900000 (32-bit, non-prefetchable) [size=1M]
	Region 5: Memory at fcd8c000 (32-bit, non-prefetchable) [size=8K]
	Capabilities: [48] Vendor Specific Information: Len=08 <?>
	Capabilities: [50] Power Management version 3
		Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
		Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
	Capabilities: [64] Express (v2) Endpoint, MSI 00
		DevCap:	MaxPayload 256 bytes, PhantFunc 0, Latency L0s <4us, L1 unlimited
			ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 0.000W
		DevCtl:	CorrErr- NonFatalErr- FatalErr- UnsupReq-
			RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop+
			MaxPayload 256 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr- TransPend-
		LnkCap:	Port #0, Speed 8GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
			ClockPM- Surprise- LLActRep- BwNot- ASPMOptComp+
		LnkCtl:	ASPM L1 Enabled; RCB 64 bytes Disabled- CommClk+
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 8GT/s (ok), Width x16 (ok)
			TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
		DevCap2: Completion Timeout: Not Supported, TimeoutDis-, LTR+, OBFF Not Supported
			 AtomicOpsCap: 32bit- 64bit- 128bitCAS-
		DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
			 AtomicOpsCtl: ReqEn-
		LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
			 EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
	Capabilities: [a0] MSI: Enable- Count=1/2 Maskable- 64bit+
		Address: 0000000000000000  Data: 0000
	Capabilities: [c0] MSI-X: Enable- Count=2 Masked-
		Vector table: BAR=5 offset=00000000
		PBA: BAR=5 offset=00001000
	Capabilities: [100 v1] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
	Kernel driver in use: pcie_mp2_amd
	Kernel modules: amd_mp2_pcie


lsmod | grep amd
edac_mce_amd           32768  0
kvm_amd               110592  0
kvm                   802816  1 kvm_amd
ccp                   106496  1 kvm_amd
amdgpu               5308416  6
amd_iommu_v2           20480  1 amdgpu
gpu_sched              40960  1 amdgpu
i2c_algo_bit           16384  1 amdgpu
ttm                   122880  1 amdgpu
drm_kms_helper        233472  1 amdgpu
drm                   585728  9 gpu_sched,drm_kms_helper,amdgpu,ttm
amd_sfhtp_hid          24576  0
pinctrl_amd            32768  1
amd_mp2_pcie           20480  1 amd_sfhtp_hid


modinfo amd_mp2_pcie
filename:       /lib/modules/5.6.0-0.rc0.git1.9.amdsfh.fc31.x86_64/kernel/drivers/hid/amd-sfh-hid/amd-mp2-pcie.ko.xz
author:         Nehal Bakulchandra Shah <Nehal-bakulchandra.Shah@amd.com>
author:         Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
license:        Dual BSD/GPL
version:        1.0
description:    AMD(R) PCIe MP2 Communication Driver
srcversion:     320368C1AFB52D740BAD58E
alias:          pci:v00001022d000015E4sv*sd*bc*sc*i*
depends:        
retpoline:      Y
intree:         Y
name:           amd_mp2_pcie
vermagic:       5.6.0-0.rc0.git1.9.amdsfh.fc31.x86_64 SMP mod_unload 
sig_id:         PKCS#7
signer:         Fedora kernel signing key
sig_key:        0E:F7:1B:36:D8:00:09:AE:EB:27:DB:41:61:61:A1:4C:A0:2B:B8:43
sig_hashalgo:   sha256
signature:      4F:8B:A9:7C:00:F6:6B:83:7D:5E:CC:5A:87:3A:95:85:5B:D7:08:C0:
		57:F5:AC:61:56:FF:E7:55:7A:67:68:AE:29:DA:57:1A:98:7C:6B:B6:
		2B:C7:E1:DC:FF:DB:CA:69:EA:CB:FC:C8:53:43:55:B4:60:88:DC:B3:
		FF:69:CC:19:C0:B9:7E:EA:D0:89:29:F6:AC:61:C1:52:F8:5E:CF:E3:
		3D:A8:1B:21:A9:A4:7D:F4:81:CF:81:A2:A4:8B:5B:75:59:7F:34:3A:
		CA:F7:06:7E:EC:5A:33:B3:EC:D8:3A:D3:C1:D2:49:D2:76:31:D0:A0:
		A2:9E:A5:ED:41:FB:22:EC:53:CD:CC:A5:8C:2A:2C:F2:E0:90:87:9F:
		B2:DD:2E:E5:CB:40:10:52:D9:84:DE:8C:CF:21:D7:6C:6D:45:7F:85:
		B8:94:3E:46:9B:46:37:BA:F5:93:A8:75:BD:E2:A2:DE:A9:66:A6:11:
		95:99:6C:D2:9D:07:80:B6:16:31:8B:64:24:01:38:E3:F8:F1:7A:04:
		6A:B2:55:77:CD:89:95:9D:5A:99:2C:08:71:B3:83:2C:B1:12:4A:7C:
		A4:2F:31:9D:75:FC:C7:3E:51:B0:60:E4:69:61:DE:4F:92:7F:50:4F:
		9D:69:28:53:CF:E3:AF:78:EF:FE:27:F8:0E:CD:97:B1:13:03:79:66:
		2F:22:18:AC:86:F5:9D:AA:3B:D2:05:06:C6:14:BE:AA:C7:0D:1B:8E:
		50:E5:E3:74:F8:27:8A:3A:81:45:C4:65:BE:72:BA:75:37:05:F6:64:
		BD:0A:1D:67:1B:7D:7D:D2:DB:7B:D8:BA:08:AD:E4:3D:C0:2B:E7:C1:
		35:86:3C:B5:A7:95:32:C7:B3:11:8F:31:BE:D5:D6:ED:8E:66:73:C6:
		4B:76:26:A1:28:AF:C5:53:FA:52:BC:F4:B3:31:91:D1:0D:18:BF:44:
		32:FE:2E:E7:51:60:CF:7E:A5:F3:55:F6:0E:AF:A3:F1:77:C5:6F:9F:
		3C:F8:4C:E0:C9:68:AC:23:1B:1D:4E:9F:C6:EE:A8:AC:36:BE:7D:8E:
		FA:77:9B:01:5B:E8:4E:5E:74:B5:C9:53:56:B4:E4:5A:D9:85:F4:BE:
		6E:1A:03:D1:60:4F:14:71:F8:46:DC:02:DD:57:35:92:4B:C3:12:04:
		A3:AA:A8:98:F4:40:F4:9A:E7:EE:C7:05:7B:EC:9C:29:5C:97:AC:2A:
		46:D0:69:0A:D8:18:10:F7:51:E9:5B:49:13:69:5C:20:5C:4E:77:86:
		93:3B:DF:BE:B2:8A:AC:9A:C0:63:F1:5B:B0:F7:16:A9:9E:B7:1F:4E:
		59:93:04:3A:AE:B4:06:FA:0D:02:A0:D7

modinfo amd_sfhtp_hid
filename:       /lib/modules/5.6.0-0.rc0.git1.9.amdsfh.fc31.x86_64/kernel/drivers/hid/amd-sfh-hid/amd-sfhtp-hid.ko.xz
license:        Dual BSD/GPL
author:         Nehal Shah <nehal-bakulchandra.shah@amd.com>
description:    AMD(R) SFH Client Driver
alias:          acpi*:AMDI0080:*
depends:        amd-mp2-pcie
retpoline:      Y
intree:         Y
name:           amd_sfhtp_hid
vermagic:       5.6.0-0.rc0.git1.9.amdsfh.fc31.x86_64 SMP mod_unload 
sig_id:         PKCS#7
signer:         Fedora kernel signing key
sig_key:        0E:F7:1B:36:D8:00:09:AE:EB:27:DB:41:61:61:A1:4C:A0:2B:B8:43
sig_hashalgo:   sha256
signature:      57:57:03:D5:EB:7E:8F:9F:8B:5A:10:43:B1:93:B8:BF:74:7F:D5:05:
		31:24:32:FF:E5:AE:00:E1:9F:48:17:E5:80:CA:C0:FD:CF:21:C9:BC:
		A7:F7:E5:AA:F4:67:F3:AA:6C:31:3F:4B:08:82:1F:4A:C1:2F:3F:9D:
		FD:41:E7:5F:AD:5B:12:EC:9A:6A:F0:8F:42:3A:9A:67:01:B1:66:29:
		45:4D:46:C6:31:2B:EE:AE:4E:28:FA:30:8E:28:58:7C:CA:5E:F8:A6:
		A8:12:F3:0F:87:B1:2F:B2:F6:48:E3:AE:CE:B0:AD:06:15:C5:3A:F9:
		54:C3:2C:39:49:00:A0:C8:2D:64:B4:37:58:34:06:44:AB:90:11:BB:
		D2:EC:C3:32:6A:29:58:D7:38:10:D6:D1:12:61:8A:0F:B1:BE:FA:BD:
		DF:4F:44:4E:F2:23:2C:73:7D:4E:EE:66:6D:F4:E6:6B:50:B3:E2:01:
		0D:6B:6F:46:D6:13:73:E6:ED:A9:6A:48:05:25:5E:08:E1:1E:0F:CA:
		E2:DF:71:DC:04:B4:ED:8E:ED:DC:53:1E:BB:7B:91:AB:E1:50:B4:C7:
		5F:B9:C6:D7:00:58:2C:46:D5:C8:AC:85:34:7C:9F:A2:E2:D9:84:37:
		BC:C8:32:EE:70:4E:71:DD:59:0E:51:D2:EC:E6:19:61:50:03:8C:DB:
		59:BE:8E:A5:8E:CB:3B:3C:DA:F6:9F:00:1E:8C:91:F8:EA:0D:C9:46:
		75:B1:01:D0:E7:93:2E:D6:15:D5:C3:CB:71:AF:FF:B7:43:FB:BB:DC:
		B0:3F:EB:9D:60:C0:7F:52:E0:7A:65:9B:25:94:12:04:3F:83:B9:4B:
		45:00:23:9E:46:AB:04:7F:A9:D5:EF:08:3C:A0:62:1C:78:22:F5:50:
		28:95:49:90:03:10:5A:56:DA:A5:DD:5F:18:77:85:33:E9:F7:B9:DC:
		54:C2:0D:AB:D8:B8:33:94:53:00:6C:6A:8A:85:23:15:56:63:82:48:
		90:47:D3:FC:4B:6C:9C:B1:24:87:50:15:48:2D:D0:B6:99:43:A8:E7:
		0E:3A:51:E7:1E:A1:D2:97:E5:BD:D3:97:8F:82:23:59:8D:3F:12:B9:
		D3:28:FD:6E:BB:1E:0C:ED:43:98:68:E9:F9:79:B7:51:48:3A:78:8A:
		12:01:57:89:BF:2C:BF:E5:D3:D0:F8:39:02:E1:19:85:13:D8:F0:9B:
		E7:EF:48:43:3C:84:7F:FC:CD:B7:7A:BD:76:A6:7B:9E:CC:75:A4:5D:
		BE:3B:85:F6:A2:79:2C:1C:C3:25:C5:EB:5B:DD:FF:FE:1B:D3:09:19:
		1A:FC:BE:12:61:99:53:17:4B:4C:03:84


So far, the sensors are not working yet and I don't know how to properly enable them.
Comment 17 Luya Tshimbalanga 2020-02-05 05:05:15 UTC
Built kernel based on 5.6.0 rc0 git1.9
https://copr.fedorainfracloud.org/coprs/luya/kernel-amdsfh/
Comment 18 Luya Tshimbalanga 2020-03-18 23:46:48 UTC
Updated patches available:

https://patchwork.kernel.org/project/linux-iio/list/?submitter=175589

One problem is the driver needed to read the HID part did not build.

Could someone update the title by mentioning "Enable AMD Sensor Fusion HUB support" instead. Thanks
Comment 19 Richard Neumann 2020-03-25 13:39:30 UTC
With the 4th revision of AMD's patch series and kernel 5.5.11 the driver builds successfully. I put a patched version into the AUR [1].
However the driver seems to work as-is only on certain HP convertibles, reportedly the HP Envy 13-ar000nn [2] and Envy X360 15-ds0013nr [3] series.
For my convertible, an HP ENVY x360 13-ag0005ng, I needed to statically enable all available HID devices [4],[5] to make the driver work.


[1] https://aur.archlinux.org/packages/linux-sfh/
[2] https://bbs.archlinux.org/viewtopic.php?pid=1893646#p1893646
[3] https://bbs.archlinux.org/viewtopic.php?pid=1888580#p1888580
[4] https://bbs.archlinux.org/viewtopic.php?pid=1893924#p1893924
[5] https://gist.github.com/conqp/e8a0793406fbe7c9714f01f3078ea33a
Comment 20 Richard Neumann 2020-03-25 13:48:51 UTC
By "to make the driver work" I meant "to make the driver detect the HID devices".
It is also currently necessary to boot the kernel with "amd_iommu=off".
Comment 21 Alex Deucher 2020-03-30 20:16:13 UTC
(In reply to Richard Neumann from comment #20)
> By "to make the driver work" I meant "to make the driver detect the HID
> devices".
> It is also currently necessary to boot the kernel with "amd_iommu=off".

Does reverting:
be62dbf554c5 ("iommu/amd: Convert AMD iommu driver to the dma-iommu api")
fix the IOMMU issues?
Comment 22 Richard Neumann 2020-03-31 07:23:02 UTC
Unfortunately I cannot test this, since reverting the commit results in a merge conflict in drivers/iommu/amd_iommu.c that I am unable to resolve due to my limited knowledge of this file.
Comment 23 Luya Tshimbalanga 2020-04-01 02:54:03 UTC
(In reply to Richard Neumann from comment #19)
> 
> 
> [1] https://aur.archlinux.org/packages/linux-sfh/

Would you mind fixing the patch for the latest git snapshot. It failed when attempt to build the kernel. Thanks.