You are not logged in.

#1 2020-02-20 12:35:29

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,200
Website

[REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

I uploaded a modified version of the stable kernel package with added experimental drivers for the AMD Sensor Fusion Hub (SFH) to the AUR.
Currently, on my convertible (HP ENVY x360 13-ag0005ng), it does not yet detect any sensors. However, the kernel patches are still under development by AMD and have not yet been merged into the mainline kernel.
Hence the AUR package for anybody interested in testing the new drivers.

Update 2020-02-27
Package has been updated to Linux 5.5.6-arch1 with 4th revision of AMD's patch.

Update 2020-03-03
Package has been updated to Linux 5.5.7-arch1.

Update 2020-03-25
I wrote a patch to make the new drivers work on HP ENVY x360 13-ag000x series convertibles.
You can manually add it to the PKGBUILD, if necessary.
A patch to enable all sensors iff none are marked as enabled is now included per default.

Update 2020-04-13
Migrated to refactored patch series by myself. The driver is now implementing the hid_ll_driver API more cleanly and redundant code has been removed.
As a side-effect you no longer need to boot with amd_iommu=off. The driver now works with IOMMU.
The module parameters force_*= have been replaced by sensor_mask=<int>.
This is due to possible future extensions, since on my Laptop (model, see above), I discovered additional sensors (possibly acceleromerters) during the reverse-engineering of the PCI device.

Update 2020-04-18
As of today, there is a DKMS version of the driver in the AUR.
I will keep the kernel package in the AUR for the time being. However I am not certain whether I will keep updating it with future kernel releases or disown or event request do delete it.
Please consider migrating to the more lightweight DKMS driver.

Update 2020-04-21
Today my deletion request on linux-sfh was accepted.
Please migrate to amd-sfh-hid-dkms.

Last edited by schard (2020-04-21 07:38:36)

Offline

#2 2020-02-28 08:10:55

Cloud_Ninja
Member
Registered: 2019-03-09
Posts: 10

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

Having used the patched kernel package, also on an HP ENVY x360 13m-ag0xxx, i can also confirm it not working. Not sure if i'm doing something wrong, but i can't figure out how to get sensor info from it.

Offline

#3 2020-03-14 10:15:22

levat
Member
From: Novi Travnik , BA
Registered: 2013-11-28
Posts: 8
Website

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

For the first time I have some anwers from sensor but its not working and i get this message from monitor-sensor.

[peni@PeniLap ~]$ monitor-sensor
    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: undefined)
=== No ambient light sensor

Offline

#4 2020-03-24 10:14:57

levat
Member
From: Novi Travnik , BA
Registered: 2013-11-28
Posts: 8
Website

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

Its working now.

Using linux-sfh from aur and adding amd_iommu=off to kernel line got rotation working.

HP Envy 13-ar000nn / Ryzen 5 3500u.

Offline

#5 2020-03-24 12:22:22

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,200
Website

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

@levat
Glad to hear that.
If you find the time, I would be very thankful, if you could provide the output of

cat /proc/cmdline

and

dmesg

in this thread: https://bbs.archlinux.org/viewtopic.php?id=252815

It may help me and others narrow down, why it's not yet working for us.
Thank you.

Offline

#6 2020-03-24 13:09:56

levat
Member
From: Novi Travnik , BA
Registered: 2013-11-28
Posts: 8
Website

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

schard wrote:

@levat
Glad to hear that.
If you find the time, I would be very thankful, if you could provide the output of

cat /proc/cmdline

and

dmesg

in this thread: https://bbs.archlinux.org/viewtopic.php?id=252815

It may help me and others narrow down, why it's not yet working for us.
Thank you.

Did as you asked.

Offline

#7 2020-03-27 12:15:18

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,200
Website

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

Update 2020-03-27 linux-sfh-5.5.13.arch1-2
I updated the custom patch to use a kernel parameter to forcibly enable all HID devices rather than force-enabling them if none are marked active.
If you previously did not get any HID devices with the vanilla patch, but with the custom patch enabled, create the file /etc/modprobe.d/amd-sfh.conf with the following content:

options amd_mp2_pcie assume_all_active=1

Update 2020-03-27 linux-sfh-5.5.13.arch1-3
I updated the kernel parameters:

parm:           activestatus_override:Override the activestatus value reported by PCI device. (int)
parm:           force_accel:Force enabling of accelerometer. (bool)
parm:           force_gyro:Force enabling of gyroscope. (bool)
parm:           force_magno:Force enabling of magnetometer. (bool)
parm:           force_als:Force enabling of ambient light sensor. (bool)

So you may need to replace

options amd_mp2_pcie assume_all_active=1

with

options amd_mp2_pcie force_accel=1

Last edited by schard (2020-03-27 14:45:40)

Offline

#8 2020-03-27 13:28:12

progandy
Member
Registered: 2012-05-17
Posts: 4,434

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

For those who hesitate to compile the complete kernel, it might be possible to compile only the new module for the currently running kernel like this. This is only possible because the patches contain the complete code of the amd-sfh-hid modules.

$ mkcd /tmp/sfh
$ curl -o v4-2-4.patch https://patchwork.kernel.org/patch/11407747/raw/
$ curl -o v4-3-4.patch https://patchwork.kernel.org/patch/11407749/raw/
$ curl -o v4-4-4.patch https://patchwork.kernel.org/patch/11407753/raw/
$ curl -o sfh-fix.patch "https://gist.githubusercontent.com/conqp/e8a0793406fbe7c9714f01f3078ea33a/raw/0f11de9caa936428921e887b6ff3cba1e22ca499/amd-sfh.patch"
$ git apply --exclude drivers/hid/Kconfig --exclude drivers/hid/Makefile v4-2-4.patch v4-3-4.patch v4-4-4.patch sfh-fix.patch
$ cd drivers/hid/amd-sfh-hid
$ ln -sf ../amd_mp2_pcie.h hid_descriptor/
$ make -C /lib/modules/`uname -r`/build M=$PWD CONFIG_AMD_SFH_HID=m
$ sudo make -C /lib/modules/`uname -r`/build M=$PWD CONFIG_AMD_SFH_HID=m INSTALL_MOD_DIR=extramodules modules_install

| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#9 2020-03-27 14:47:22

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,200
Website

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

@progandy
Thanks for the hint. Based on it, I just attempted to create a dkms package to replace the kernel package.
But the shipped Makefile does not support dkms now and writing my own seems to be a lot of extra work.

Offline

#10 2020-04-13 03:23:13

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,200
Website

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

Over the last weeks I refactored the patch series. The current linux-sfh package is no longer using the original AMD patch series v4 from patchwork.kernel.org, but my refactored patch series.
If ypu previously used the force_*=1 params: They have been replaced by sensor_mask=<mask>.
If you e.g. used force_accel=1, you need to replace it with sensor_mask=0x1.

Last edited by schard (2020-04-13 03:25:09)

Offline

#11 2021-02-24 18:17:22

daenney
Member
Registered: 2020-05-23
Posts: 1

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

With 5.11 there's now an in-tree module, but it unfortunately doesn't work. I suspect it's pretty much the same issue in that some HP laptops don't correctly report which sensors they have, which we used to be able to get around with the sensor_mask.

The upstream module however has no such feature it seems:

$  modinfo amd_sfh
filename:       /lib/modules/5.11.1-arch1-1/kernel/drivers/hid/amd-sfh-hid/amd_sfh.ko.xz
author:         Sandeep Singh <Sandeep.singh@amd.com>
author:         Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
license:        Dual BSD/GPL
description:    AMD(R) PCIe MP2 Communication Driver
srcversion:     CA72DE5F8C86954F49D4343
alias:          pci:v00001022d000015E4sv*sd*bc*sc*i*
depends:        
retpoline:      Y
intree:         Y
name:           amd_sfh
vermagic:       5.11.1-arch1-1 SMP preempt mod_unload 
sig_id:         PKCS#7
signer:         Build time autogenerated kernel key
sig_key:        58:74:DE:6D:D1:EC:2E:14:C4:CF:FD:9D:77:14:1C:B0:E6:5D:84:65
sig_hashalgo:   sha512
signature:      <sig>

As a consequence iio-sensor-proxy never shows up either, and if you try to start it you just get:

$ monitor-sensor
    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared

** (process:2530): WARNING **: 19:06:36.162: Failed to claim accelerometer: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name :1.69 was not provided by any .service files

Or I'm misunderstanding something.

Offline

#12 2021-04-11 19:18:54

tikhon03
Member
Registered: 2020-12-30
Posts: 6

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

@schard
I have a lenovo ideapad flex5 with a Renoir sensor fusion hub. accel only. I made a file /etc/modprobe.d/amd-sfh.conf with the contents

options amd_mp2_pcie sensor_mask=0x1

Is this still valid for the current version of your driver? I posted on my debugging attempts here (https://bbs.archlinux.org/viewtopic.php?id=262776). There has been an improvement since then: iio-sensor-proxy no longer lists the orientation as undefined. Currently the orientation is listed as bottom-up, but it still does not seem to be changing. It may be better for me to post an update on that thread though.

Offline

#13 2021-04-12 05:45:42

schard
Member
From: Hannover
Registered: 2016-05-06
Posts: 1,200
Website

Re: [REPLACED] Linux Kernel with AMD Sensor Fusion Hub (SFH) driver

amd_mp2_pcie is no longer the name  for the PCIe driver for the AMD SFH. See the up to date kernel documentation or documentation of my refactored version for details.
Also, Renoir devices are not yet supported by AMD, who need to deliver descriptors for the sensors used on this generation of sensor hubs.

Last but not least, the package linux-sfh is no longer provided. At least not by me. Use the upstream driver, which is included since linux kernel v. 5.10 or alternatively my refactored version amd-sfh-hid-dkms from the AUR.

Last edited by schard (2021-04-12 06:31:05)

Offline

Board footer

Powered by FluxBB