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

Comment 10 Luya Tshimbalanga 2019-07-16 15:21:04 UTC
According to AMD, the driver will be ready somewhere on August:
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.

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. 
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:
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*
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:

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:

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
Comment 18 Luya Tshimbalanga 2020-03-18 23:46:48 UTC
Updated patches available:


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.