Bug 212615 - amd-sfh doesn't provide valid sensor data in Linux on HP x360 Envy systems
Summary: amd-sfh doesn't provide valid sensor data in Linux on HP x360 Envy systems
Status: ASSIGNED
Alias: None
Product: Drivers
Classification: Unclassified
Component: Input Devices (show other bugs)
Hardware: AMD Linux
: P1 normal
Assignee: drivers_input-devices
URL:
Keywords:
: 207431 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-04-08 20:48 UTC by Stuart Morgan
Modified: 2025-02-07 10:33 UTC (History)
26 users (show)

See Also:
Kernel Version: 5.19-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments
sensors missing from udevadm info --export-db after b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b (3.70 KB, text/plain)
2023-11-02 16:56 UTC, Mauricio Collares
Details
amd_s2idle.py report on stock 6.6 (108.85 KB, text/plain)
2023-11-03 08:00 UTC, Mauricio Collares
Details
outputs of various commands describing the problem (44.63 KB, text/plain)
2023-11-05 10:53 UTC, Laurence Bonat
Details
patch to stop all sensors during init (1.13 KB, patch)
2025-01-17 16:12 UTC, Mario Limonciello (AMD)
Details | Diff
patch to clear pending interrupts before starting (504 bytes, patch)
2025-01-17 18:01 UTC, Mario Limonciello (AMD)
Details | Diff

Description Stuart Morgan 2021-04-08 20:48:10 UTC
The amd-sfh driver loads correct and detects the hardware, but the output is all zeros no matter the device orientation.

This bug was originally raised downstream against iio_sensor_proxy where the determination was made that the problem originates at the driver level. The issue was reported against multiple laptop models using Ryzen mobile processors.

https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/issues/315


# iio_generic_buffer --device-num 0 -A -c 100
iio device number being used is 0
iio trigger number being used is 0
Enabling all channels
Enabling: in_accel_x_en
Enabling: in_accel_z_en
Enabling: in_timestamp_en
Enabling: in_accel_y_en
/sys/bus/iio/devices/iio:device0 accel_3d-dev0
514284.375000 816214.562500 816227.125000 1617913283256446331 
514284.375000 816214.562500 816227.125000 1617913283256478807 
0.000000 0.000000 0.000000 1617913283271095729 
0.000000 0.000000 0.000000 1617913283479099805 
0.000000 0.000000 0.000000 1617913283687318920 
0.000000 0.000000 0.000000 1617913283895314405 
0.000000 0.000000 0.000000 1617913284103289845 
0.000000 0.000000 0.000000 1617913284311314384 
0.000000 0.000000 0.000000 1617913284519359526 
0.000000 0.000000 0.000000 1617913284727312478
Comment 1 Daniel Parks 2021-04-14 20:15:43 UTC
On my system, the accelerometer is not always device #0. I get the exact same results as Stuart Morgan with the accelerometer, and similar results from the magnetometer and gyroscope:

# ./iio_generic_buffer --device-num 0 -a -c 5
iio device number being used is 0
iio trigger number being used is 0
Enabling all channels
Enabling: in_magn_z_en
Enabling: in_magn_y_en
Enabling: in_magn_x_en
/sys/bus/iio/devices/iio:device0 magn_3d-dev0
5.244241 8.323072 8.388735
5.244241 8.323072 8.388735
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
Disabling: in_magn_z_en
Disabling: in_magn_y_en
Disabling: in_magn_x_en

# ./iio_generic_buffer --device-num 1 -a -c 5
iio device number being used is 1
iio trigger number being used is 2
Enabling all channels
Enabling: in_anglvel_z_en
Enabling: in_anglvel_y_en
Enabling: in_anglvel_x_en
/sys/bus/iio/devices/iio:device1 gyro_3d-dev1
915.287903 1452.642456 1452.664795
915.287903 1452.642456 1452.664795
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.000000 0.000000 0.000000
Disabling: in_anglvel_z_en
Disabling: in_anglvel_y_en
Disabling: in_anglvel_x_en

While I was testing this, I unloaded and reloaded amd_sfh, and shortly afterwards, my system experienced a kernel panic. I don't have the logs, unfortunately, because all outputs froze (even the caps lock key didn't blink) and it didn't sync.

The last command in the audit log before the panic was:

./iio_generic_buffer --device-num 2 -a -c 5
Comment 2 Stuart Morgan 2021-04-20 16:39:02 UTC
I see some device quirks being added to the 5.12 branch, RC8, for HP Envy line model ag0* 

I'm using the HP Envy AY0009NA which isn't covered by those quirks.
Comment 3 Dylan MacKenzie 2021-06-22 01:57:09 UTC
I have an HP Envy x360 13-ay0xxx, which has a Ryzen 4700U (Renoir) processor. I am experiencing the same issue: 2 sensors are detected but `./iio_generic_buffer` shows the same nonsense value followed by all zeroes. Multiple other Linux users with Renoir chipsets are having the [same issue](https://bbs.archlinux.org/viewtopic.php?pid=1947124#p1947124).

I took a look at the Windows driver (amdsfhkmdf.sys), and found many similarities with the Linux driver. However, the Windows driver checks the lower four bits of [`activecontrolstatus`](
https://github.com/torvalds/linux/blob/a96bfed64c8986d6404e553f18203cae1f5ac7e6/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c#L112) for the magic value 2. If found, it uses very different set of MMIO writes to pass commands to the SFH. For example, here's pseudocode that mimics the Windows driver's method of enabling a given sensor:

```c
  c2p_cmd_idx_and_interval = sensor_idx | (uint)interval << 8;

  if (data->activecontrolstatus_lo4 == 2) {
    c2p_cmd_part = (param_4 & 1 | c2p_cmd_idx_and_interval << 0xc) << 4;
    c2p_cmd = c2p_cmd_part | 0x1001;

    // MMIO writes
    data->c2p_msg[2] = /* sensor addr hi */;
    data->c2p_msg[1] = /* sensor addr lo */;
    *data->c2p_msg = c2p_cmd;
  } else {
    c2p_cmd = c2p_cmd_idx_and_interval << 8 | AMD_SFH_CMD_ENABLE_SENSOR;

    // MMIO writes
    data->c2p_msg[3] = /* sensor addr hi */;
    data->c2p_msg[2] = /* sensor addr lo */;

                    /* amd_sfh_param {
                        .layout = 1,
                        .len = 0x20,
                       } */
    data->c2p_msg[1] = 0x41;
    *data->c2p_msg = c2p_cmd;
  }
```

The code in the `else` block is basically the same as `amd_start_sensor` in the Linux driver, but the code in the `if` block uses a different layout for the command register, has extra bit flags, and uses different address registers.

Sure enough, the lower bits of `activecontrolstatus` on my system are 2. I'm guessing that this is not the case on older architectures (Matisse, Starship, etc.), and those bits indicate a later revision of the SFH hardware with a different interface. I have not confirmed this, however.

cc nehal-bakulchandra.shah@amd.com
Comment 4 Dylan MacKenzie 2021-06-22 03:26:15 UTC
Ah, I just found a patch for the new architecture that was filed a couple days ago. Seems like this will be fixed soon.

https://patchwork.kernel.org/project/linux-input/patch/20210618081838.4156571-4-Basavaraj.Natikar@amd.com/
Comment 5 Maxwell Beck 2021-08-07 02:17:22 UTC
Unfortunately screen rotation still does not work for me on kernel 5.14-rc4, which should have all of the patches for Renoir/Cezanne support merged in. I get the same exact behavior as the others here. I also have the HP Envy x360 13-ay000 but with a 4500U, and it is updated to the latest available BIOS (F.18).
Comment 6 Nehal Shah 2021-08-07 03:36:35 UTC
Hi Maxwell

Can you please share your laptop model number
And also the ubuntu version?

Hi @Dylan, is it working fine in your laptop( presuming you have Renior based laptop)

Regards
Nehal
Comment 7 Stuart Morgan 2021-08-07 10:00:01 UTC
5.14-rc4 is also not working for me with the HP Envy x360 model AY0009NA. I see exactly the same behaviour as with earlier kernels and as shared in my initial bug report.
Comment 8 Stuart Morgan 2021-08-07 11:45:34 UTC
(In reply to Stuart Morgan from comment #7)
> 5.14-rc4 is also not working for me with the HP Envy x360 model AY0009NA. I
> see exactly the same behaviour as with earlier kernels and as shared in my
> initial bug report.

This is with Fedora 34.
Comment 9 Maxwell Beck 2021-08-09 20:13:21 UTC
The most exact model number I can get on my laptop is 13z-ay000 as it was a customized order. I have been testing with NixOS 21.05.
Comment 10 Swar Shah 2021-08-12 03:41:55 UTC
I just tried the 5.14-rc5 on my IdeaPad Flex 5 14ARE05 running on Ubuntu 20.04.2 and it still seems to be broken, at least in my case. It appears to detect the rotation but as soon as it detects it, the screen goes static like the old television static screen and only way to get screen working again is a hard reboot.
Comment 11 Nehal Shah 2021-08-12 05:15:51 UTC
Hi Swar and All,

We are setting up the same environment and looking into the issue as we are not getting the issue on available reference platform.

Thanks
Nehal Shah
Comment 12 Stormy 2021-08-16 15:31:11 UTC
Hello everyone,

I have the same issue with the following laptop...


Make/Model: HP ENVY x360 2-in-1 Convertible 15z-ee100

CPU/GPU: AMD Ryzen 5700U with Radeon Graphics


I hope this will help find a fix.
Comment 13 Mark Lee 2021-08-20 02:17:02 UTC
Hi Stormy,

May I know the BIOS version on the laptop?
Comment 14 Mark Lee 2021-08-20 02:41:18 UTC
Hi Swar,

May I know the BIOS version (Flex 5) you are using?
Comment 15 Stormy 2021-08-20 12:49:25 UTC
(In reply to Mark Lee from comment #13)
> Hi Stormy,
> 
> May I know the BIOS version on the laptop?

Hello Mark,

Is this what you are looking for? See attached images:
https://cdn.discordapp.com/attachments/365979535642066957/878256612740050974/20210820_083334.jpg
https://cdn.discordapp.com/attachments/365979535642066957/878257538762698802/20210820_084133.jpg


Images not working? Possible information:
BIOS Vendor: Insyde
BIOS Revision: F.03
Comment 16 Swar Shah 2021-08-20 17:51:27 UTC
(In reply to Mark Lee from comment #14)
> Hi Swar,
> 
> May I know the BIOS version (Flex 5) you are using?

BIOS Version: EECN30WW
Comment 17 Stuart Morgan 2021-09-29 21:45:09 UTC
As an update, this issue is still present with 5.15 rc1
Comment 18 Mek101 2021-10-06 12:03:56 UTC
I would like to confirm that this issue is also affecting the Lenovo Ideapad 14ALC05 with the Ryzen 3 5300U cpu, kernel 5.14.7


$ sudo ./iio_generic_buffer --device-num 0
iio device number being used is 0
iio trigger number being used is 0
/sys/bus/iio/devices/iio:device0 accel_3d-dev0
514284.375000 816214.562500 816227.125000 1633520534367737352 
514284.375000 816214.562500 816227.125000 1633520534367756348 
0.000000 0.000000 0.882599 1633520534567971505 
0.000000 0.000000 0.882599 1633520534771316637
Comment 19 Swar Shah 2021-10-19 01:07:45 UTC
I just tried the 5.15.0-rc6 and it seems to have resolved the issue for me. No more static screen on rotation or waking the display up from suspend. Thanks!
Comment 20 Mek101 2021-11-01 15:34:01 UTC
Apart for 1 more column of non-zero output, the bug is still present on the Lenovo 14ALC05 with Kernel 5.15.0 (Ryzen 3 5300U)

$ sudo ./iio_generic_buffer -a --device-num 0
iio device number being used is 0
iio trigger number being used is 0
Auto-channels selected but some channels are already activated in sysfs
Proceeding without activating any channels
/sys/bus/iio/devices/iio:device0 accel_3d-dev0
514284.375000 816214.562500 816227.125000 1635780653841921687 
514284.375000 816214.562500 816227.125000 1635780653841948835 
0.000000 -0.882599 -0.294199 1635780653951177401 
0.000000 -0.882599 -0.294199 1635780654154205185
Comment 21 Luka 2022-03-12 17:51:49 UTC
Can confirm issue on 5.16. Device is HP ENVY x360 Convertible 13-ay0xxx. Distro is Manjaro.
Comment 22 Mario Limonciello (AMD) 2022-07-09 13:56:45 UTC
*** Bug 207431 has been marked as a duplicate of this bug. ***
Comment 23 Mario Limonciello (AMD) 2022-07-09 13:58:09 UTC
Is this still an issue on 5.19-rc1 or later?  There is a patch that has gone in that might help.

https://github.com/torvalds/linux/commit/b5d7f43e97dabfa04a4be5ff027ce7da119332be
Comment 24 Laurence Bonat 2022-07-16 15:20:02 UTC
(In reply to Mario Limonciello (AMD) from comment #23)
> Is this still an issue on 5.19-rc1 or later?  There is a patch that has gone
> in that might help.
> 
> https://github.com/torvalds/linux/commit/
> b5d7f43e97dabfa04a4be5ff027ce7da119332be

Hi, 
I tried again with kernel 5.19-rc6 on kubuntu 22.04 and now I cannot even detect the sensor with monitor-sensor. The output is now:
monitor-sensor
    Waiting for iio-sensor-proxy to appear

I'm on a HP x360 Envy 13-ay0285ng With AMD ryzen 7 4700u and 16GB of Ram. Bios revision F.21 Rev.A. It still doesn't work.
I really don't know what to do. It appears that the sensor is still not recognized. 
Here is dmesg output for amd logged entries: 
sudo dmesg | grep amd
[    0.710440] perf/amd_iommu: Detected AMD IOMMU #0 (2 banks, 4 counters/bank).
[    1.803167] pcie_mp2_amd 0000:04:00.7: enabling device (0000 -> 0002)
[    2.978607] [drm] amdgpu kernel modesetting enabled.
[    2.979229] amdgpu: Virtual CRAT table created for CPU
[    2.979238] amdgpu: Topology: Add CPU node
[    2.979426] amdgpu 0000:04:00.0: vgaarb: deactivate vga console
[    2.979461] amdgpu 0000:04:00.0: enabling device (0006 -> 0007)
[    2.980929] amdgpu 0000:04:00.0: amdgpu: Fetched VBIOS from VFCT
[    2.980931] amdgpu: ATOM BIOS: 113-RENOIR-036
[    2.980966] amdgpu 0000:04:00.0: amdgpu: Trusted Memory Zone (TMZ) feature enabled
[    2.980968] amdgpu 0000:04:00.0: amdgpu: PCIE atomic ops is not supported
[    2.980973] amdgpu 0000:04:00.0: amdgpu: MODE2 reset
[    2.981069] amdgpu 0000:04:00.0: amdgpu: VRAM: 512M 0x000000F400000000 - 0x000000F41FFFFFFF (512M used)
[    2.981071] amdgpu 0000:04:00.0: amdgpu: GART: 1024M 0x0000000000000000 - 0x000000003FFFFFFF
[    2.981073] amdgpu 0000:04:00.0: amdgpu: AGP: 267419648M 0x000000F800000000 - 0x0000FFFFFFFFFFFF
[    2.981121] [drm] amdgpu: 512M of VRAM memory ready
[    2.981122] [drm] amdgpu: 7693M of GTT memory ready.
[    2.981442] amdgpu 0000:04:00.0: amdgpu: PSP runtime database doesn't exist
[    2.981444] amdgpu 0000:04:00.0: amdgpu: PSP runtime database doesn't exist
[    2.982362] amdgpu 0000:04:00.0: amdgpu: Will use PSP to load VCN firmware
[    3.768778] amdgpu 0000:04:00.0: amdgpu: RAS: optional ras ta ucode is not available
[    3.779882] amdgpu 0000:04:00.0: amdgpu: RAP: optional rap ta ucode is not available
[    3.779885] amdgpu 0000:04:00.0: amdgpu: SECUREDISPLAY: securedisplay ta ucode is not available
[    3.780695] amdgpu 0000:04:00.0: amdgpu: SMU is initialized successfully!
[    3.967644] kfd kfd: amdgpu: Allocated 3969056 bytes on gart
[    3.967732] amdgpu: sdma_bitmap: 3
[    4.003411] amdgpu: HMM registered 512MB device memory
[    4.003454] amdgpu: SRAT table not found
[    4.003455] amdgpu: Virtual CRAT table created for GPU
[    4.004178] amdgpu: Topology: Add dGPU node [0x1636:0x1002]
[    4.004185] kfd kfd: amdgpu: added device 1002:1636
[    4.004274] amdgpu 0000:04:00.0: amdgpu: SE 1, SH per SE 1, CU per SH 8, active_cu_number 7
[    4.004412] amdgpu 0000:04:00.0: amdgpu: ring gfx uses VM inv eng 0 on hub 0
[    4.004416] amdgpu 0000:04:00.0: amdgpu: ring comp_1.0.0 uses VM inv eng 1 on hub 0
[    4.004419] amdgpu 0000:04:00.0: amdgpu: ring comp_1.1.0 uses VM inv eng 4 on hub 0
[    4.004422] amdgpu 0000:04:00.0: amdgpu: ring comp_1.2.0 uses VM inv eng 5 on hub 0
[    4.004424] amdgpu 0000:04:00.0: amdgpu: ring comp_1.3.0 uses VM inv eng 6 on hub 0
[    4.004426] amdgpu 0000:04:00.0: amdgpu: ring comp_1.0.1 uses VM inv eng 7 on hub 0
[    4.004428] amdgpu 0000:04:00.0: amdgpu: ring comp_1.1.1 uses VM inv eng 8 on hub 0
[    4.004431] amdgpu 0000:04:00.0: amdgpu: ring comp_1.2.1 uses VM inv eng 9 on hub 0
[    4.004433] amdgpu 0000:04:00.0: amdgpu: ring comp_1.3.1 uses VM inv eng 10 on hub 0
[    4.004436] amdgpu 0000:04:00.0: amdgpu: ring kiq_2.1.0 uses VM inv eng 11 on hub 0
[    4.004438] amdgpu 0000:04:00.0: amdgpu: ring sdma0 uses VM inv eng 0 on hub 1
[    4.004441] amdgpu 0000:04:00.0: amdgpu: ring vcn_dec uses VM inv eng 1 on hub 1
[    4.004443] amdgpu 0000:04:00.0: amdgpu: ring vcn_enc0 uses VM inv eng 4 on hub 1
[    4.004446] amdgpu 0000:04:00.0: amdgpu: ring vcn_enc1 uses VM inv eng 5 on hub 1
[    4.004448] amdgpu 0000:04:00.0: amdgpu: ring jpeg_dec uses VM inv eng 6 on hub 1
[    4.006515] [drm] Initialized amdgpu 3.47.0 20150101 for 0000:04:00.0 on minor 0
[    4.012027] fbcon: amdgpudrmfb (fb0) is primary device
[    4.715658] amdgpu 0000:04:00.0: [drm] fb0: amdgpudrmfb frame buffer device
[    7.624518] snd_hda_intel 0000:04:00.1: bound 0000:04:00.0 (ops amdgpu_dm_audio_component_bind_ops [amdgpu])

lspci -knn output: 
lspci -knn
00:00.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir/Cezanne Root Complex [1022:1630]
        Subsystem: Hewlett-Packard Company Renoir/Cezanne Root Complex [103c:876e]
00:00.2 IOMMU [0806]: Advanced Micro Devices, Inc. [AMD] Renoir/Cezanne IOMMU [1022:1631]
        Subsystem: Hewlett-Packard Company Renoir/Cezanne IOMMU [103c:876e]
00:01.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir PCIe Dummy Host Bridge [1022:1632]
00:01.3 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Renoir/Cezanne PCIe GPP Bridge [1022:1634]
        Kernel driver in use: pcieport
00:02.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir PCIe Dummy Host Bridge [1022:1632]
00:02.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Renoir/Cezanne PCIe GPP Bridge [1022:1634]
        Kernel driver in use: pcieport
00:02.3 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Renoir/Cezanne PCIe GPP Bridge [1022:1634]
        Kernel driver in use: pcieport
00:08.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir PCIe Dummy Host Bridge [1022:1632]
00:08.1 PCI bridge [0604]: Advanced Micro Devices, Inc. [AMD] Renoir Internal PCIe GPP Bridge to Bus [1022:1635]
        Kernel driver in use: pcieport
00:14.0 SMBus [0c05]: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller [1022:790b] (rev 51)
        Subsystem: Hewlett-Packard Company FCH SMBus Controller [103c:876e]
        Kernel driver in use: piix4_smbus
        Kernel modules: i2c_piix4, sp5100_tco
00:14.3 ISA bridge [0601]: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge [1022:790e] (rev 51)
        Subsystem: Hewlett-Packard Company FCH LPC Bridge [103c:876e]
00:18.0 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 0 [1022:1448]
00:18.1 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 1 [1022:1449]
00:18.2 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 2 [1022:144a]
00:18.3 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 3 [1022:144b]
        Kernel driver in use: k10temp
        Kernel modules: k10temp
00:18.4 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 4 [1022:144c]
00:18.5 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 5 [1022:144d]
00:18.6 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 6 [1022:144e]
00:18.7 Host bridge [0600]: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 7 [1022:144f]
01:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8822CE 802.11ac PCIe Wireless Network Adapter [10ec:c822]
        DeviceName: WLAN
        Subsystem: Hewlett-Packard Company RTL8822CE 802.11ac PCIe Wireless Network Adapter [103c:85f7]
        Kernel driver in use: rtw_8822ce
        Kernel modules: rtw88_8822ce
02:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS522A PCI Express Card Reader [10ec:522a] (rev 01)
        DeviceName: Realtek PCIe CardReader
        Subsystem: Hewlett-Packard Company RTS522A PCI Express Card Reader [103c:876e]
        Kernel driver in use: rtsx_pci
        Kernel modules: rtsx_pci
03:00.0 Non-Volatile memory controller [0108]: Sandisk Corp WD Blue SN500 / PC SN520 NVMe SSD [15b7:5003] (rev 01)
        DeviceName: Realtek RTL8111E Ethernet LOM
        Subsystem: Sandisk Corp WD Blue SN500 / PC SN520 NVMe SSD [15b7:5003]
        Kernel driver in use: nvme
        Kernel modules: nvme
04:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Renoir [1002:1636] (rev c2)
        DeviceName: AMD Radeon(TM) Graphics
        Subsystem: Hewlett-Packard Company Renoir [103c:876e]
        Kernel driver in use: amdgpu
        Kernel modules: amdgpu
04:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Renoir Radeon High Definition Audio Controller [1002:1637]
        Subsystem: Hewlett-Packard Company Renoir Radeon High Definition Audio Controller [103c:876e]
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel
04:00.2 Encryption controller [1080]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) Platform Security Processor [1022:15df]
        Subsystem: Hewlett-Packard Company Family 17h (Models 10h-1fh) Platform Security Processor [103c:876e]
        Kernel driver in use: ccp
        Kernel modules: ccp
04:00.3 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Renoir/Cezanne USB 3.1 [1022:1639]
        Subsystem: Hewlett-Packard Company Renoir/Cezanne USB 3.1 [103c:876e]
        Kernel driver in use: xhci_hcd
        Kernel modules: xhci_pci
04:00.4 USB controller [0c03]: Advanced Micro Devices, Inc. [AMD] Renoir/Cezanne USB 3.1 [1022:1639]
        Subsystem: Hewlett-Packard Company Renoir/Cezanne USB 3.1 [103c:876e]
        Kernel driver in use: xhci_hcd
        Kernel modules: xhci_pci
04:00.5 Multimedia controller [0480]: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor [1022:15e2] (rev 01)
        Subsystem: Hewlett-Packard Company Raven/Raven2/FireFlight/Renoir Audio Processor [103c:876e]
        Kernel driver in use: snd_rn_pci_acp3x
        Kernel modules: snd_pci_acp3x, snd_rn_pci_acp3x, snd_pci_acp5x
04:00.6 Audio device [0403]: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) HD Audio Controller [1022:15e3]
        Subsystem: Hewlett-Packard Company Family 17h (Models 10h-1fh) HD Audio Controller [103c:876e]
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel
04:00.7 Signal processing controller [1180]: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/Renoir Sensor Fusion Hub [1022:15e4]
        Subsystem: Hewlett-Packard Company Raven/Raven2/Renoir Sensor Fusion Hub [103c:876e]
        Kernel driver in use: pcie_mp2_amd
        Kernel modules: amd_sfh


Hope this helps
Laurence
Comment 25 Mario Limonciello (AMD) 2022-07-16 16:36:55 UTC
That's actually exactly the outcome I was expecting. I think you really don't have a sensor connected but the SFH firmware was advertising one.

By the driver checking the discovery data it will now only advertise when it really is there.
Comment 26 Laurence Bonat 2022-07-16 17:01:16 UTC
(In reply to Mario Limonciello (AMD) from comment #25)
> That's actually exactly the outcome I was expecting. I think you really
> don't have a sensor connected but the SFH firmware was advertising one.
> 
> By the driver checking the discovery data it will now only advertise when it
> really is there.

Oh, I didn't expect this. 
But it doesn't actually make any sense. On windows I can rotate the screen and all of those things related to the accelerometer. 
Am I missing a piece of something? 
Let me know if you need to do some testing on my laptop, I will happily do them because I would really like to use this laptop with ubuntu, but the screen rotation is a must.

Thanks for the reply,
Laurence
Comment 27 Mario Limonciello (AMD) 2022-07-16 18:31:35 UTC
In Windows do you know if rotation data is actually coming from SFH? Maybe it's another source. 

Could you disable SFH device in Windows device manager and check whether rotation still works?
Comment 28 Laurence Bonat 2022-07-16 19:31:18 UTC
(In reply to Mario Limonciello (AMD) from comment #27)
> In Windows do you know if rotation data is actually coming from SFH? Maybe
> it's another source. 
> 
> Could you disable SFH device in Windows device manager and check whether
> rotation still works?

So I tried disabling "AMD Sensor Fusion Hub" in Windows and the rotation stops working. So I think that it's the SFH responsible for the rotation.

I found out that there is another sensor marked on device manager, called "AMD UMDF Sensor", and if I remove the driver of this device, the rotation stops working too. 

This UMDF sensor is dependent on the "AMD Sensor Fusion Hub", and when I disable AMD SFH, the "AMD UMDF Sensor" throws this error: "This Device Is Currently Waiting on Another Device (Code 51)"

So I think there is definetly the SFH in my laptop and it should be working even on Ubuntu. It's 2 years that I have this laptop and still there isn't a proper solution... 
Anyway let me know anything that may help resolve this issue

Cheers, 
Laurence
Comment 29 Mario Limonciello (AMD) 2022-07-18 15:50:33 UTC
Yeah that does confirm it is SFH doing the rotation.  From your above points:
* Bad data before discovery register checking added
* No sensors exported when checking discovery
* Windows only works with SFH driver(s) available

To me it sounds like some initialization is missing in the SFH driver for your particular combination.  This also agrees with comment #3 above.
Comment 30 Laurence Bonat 2022-07-18 16:26:03 UTC
(In reply to Mario Limonciello (AMD) from comment #29)
> Yeah that does confirm it is SFH doing the rotation.  From your above points:
> * Bad data before discovery register checking added
> * No sensors exported when checking discovery
> * Windows only works with SFH driver(s) available
> 
> To me it sounds like some initialization is missing in the SFH driver for
> your particular combination.  This also agrees with comment #3 above.

Let me know if you need any test or other things to help you resolve the bug. 

Cheers,
Laurence
Comment 31 Mehmet 2022-11-28 02:06:10 UTC
Was there any improvement on this issue since ?
Comment 32 Luís Zilhão 2023-03-09 21:20:14 UTC
Hello,

I can confirm I have the same issue. The accelerometer data was always at 0, after the update to Ubuntu 22.10 with kernel verion 5.19 the sensor no longer shows up, same behavior as Laurence. I am now on version 6.2.1, still the same. 
My laptop is an HP Envy x360 13-ay0010np, AMD Ryzen 5 4500U

Anything I can do to help?
Comment 33 Mario Limonciello (AMD) 2023-03-10 01:01:33 UTC
https://github.com/torvalds/linux/commit/b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b

This is the commit that changed the behavior to make the sensors not show up if they don't work.  There was a regression from that and so this commit went in to help that regression.

https://github.com/torvalds/linux/commit/7bcfdab3f0c6672ca52be3cb65a0550d8b99554b
Comment 34 Joe 2023-04-17 14:25:53 UTC
I can confirm the bug of rotation not working as well on an HP ENVY x360 Convertible 13-ay0xxxxx. Is there anything one can provide to further support fixing this issue?
If I read the comments correctly, the issue wasn't resolved yet as the sensor doesn't work in all cases. If it doesn't, it simply gets ignored. This seems like a temporary fix to me. Is there any more progress regarding this issue?
Comment 35 Firnin 2023-04-21 10:24:02 UTC
I can confirm this bug on HP Envy x360 15-eu0xxx
Comment 36 Firnin 2023-04-21 10:26:04 UTC
I can confirm this bug on HP Envy x360 15-eu0xxx
Comment 37 zymphad 2023-07-16 19:34:59 UTC
Is there a fix for this incoming?  HP HP Envy x360 2-in-1 Laptop 15-fh0xxx
Comment 38 gregory.clemenceau 2023-10-08 15:10:00 UTC
Hi,
I confirm this bug on HP Envy x360 15-ey0xxx with kernel "Linux arch 6.5.5-arch1-1" (last bios).
No sensor.

In the meantime, I made a shortcut :
gsettings set org.gnome.mutter.keybindings rotate-monitor "['XF86RotateWindows', '<Control>F12']"
But it's unfortunate to have a convertible screen and not be able to use it normally.
Best regards,
Comment 39 gregory.clemenceau 2023-10-08 15:23:52 UTC
For bios information:
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x0000000000000000-0x000000000009efff] usable
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x000000000009f000-0x00000000000bffff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x0000000000100000-0x0000000009beffff] usable
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x0000000009bf0000-0x0000000009dfffff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x0000000009e00000-0x0000000009efffff] usable
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x0000000009f00000-0x0000000009f0efff] ACPI NVS
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x0000000009f0f000-0x00000000c5f7efff] usable
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000c5f7f000-0x00000000caf7efff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000caf7f000-0x00000000cdf7efff] ACPI NVS
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000cdf7f000-0x00000000cdffefff] ACPI data
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000cdfff000-0x00000000cdffffff] usable
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000ce000000-0x00000000cfffffff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000f8000000-0x00000000fbffffff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000fde00000-0x00000000fdefffff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000fe000000-0x00000000fe0fffff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000fec00000-0x00000000fec01fff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000fec10000-0x00000000fec10fff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000fec20000-0x00000000fec20fff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000fed80000-0x00000000fed81fff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x00000000ff000000-0x00000000ffffffff] reserved
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x0000000100000000-0x000000040e2fffff] usable
oct. 08 14:24:33 arch kernel: BIOS-e820: [mem 0x000000040e300000-0x000000042fffffff] reserved
oct. 08 14:24:33 arch kernel: efi: ACPI=0xcdffe000 ACPI 2.0=0xcdffe014 ESRT=0xb1ce8b18 TPMFinalLog=0xcdf40000 SMBIOS=0xc961a000 SMBIOS 3.0=0xc9618000 MEMATTR=0xb2ab1018 INITRD=0xb257eb18 RNG=0xcdfdd018 TPMEventLog=0xb2577018 
oct. 08 14:24:33 arch kernel: SMBIOS 3.3.0 present.
oct. 08 14:24:33 arch kernel: DMI: HP HP ENVY x360 2-in-1 Laptop 15-ey0xxx/8A31, BIOS F.14 07/05/2023
oct. 08 14:24:33 arch kernel: acpi PNP0A08:00: FADT indicates ASPM is unsupported, using BIOS configuration
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: Fetched VBIOS from VFCT
oct. 08 14:24:33 arch kernel: amdgpu: ATOM BIOS: 113-BARCELO-004
oct. 08 14:24:34 arch kernel: ccp 0000:04:00.2: ccp: unable to access the device: you might be running a broken BIOS
Comment 40 gregory.clemenceau 2023-10-08 15:26:16 UTC
For amd information:
oct. 08 14:24:33 arch kernel: RAMDISK: [mem 0xaed71000-0xb1027fff]
oct. 08 14:24:33 arch kernel: AMD-Vi: ivrs, add hid:AMDI0020, uid:\_SB.FUR0, rdevid:160
oct. 08 14:24:33 arch kernel: AMD-Vi: ivrs, add hid:AMDI0020, uid:\_SB.FUR1, rdevid:160
oct. 08 14:24:33 arch kernel: AMD-Vi: ivrs, add hid:AMDI0020, uid:\_SB.FUR2, rdevid:160
oct. 08 14:24:33 arch kernel: AMD-Vi: ivrs, add hid:AMDI0020, uid:\_SB.FUR3, rdevid:160
oct. 08 14:24:33 arch kernel: AMD-Vi: Using global IVHD EFR:0x206d73ef22254ade, EFR2:0x0
oct. 08 14:24:33 arch kernel: smpboot: CPU0: AMD Ryzen 7 5825U with Radeon Graphics (family: 0x19, model: 0x50, stepping: 0x0)
oct. 08 14:24:33 arch kernel: Performance Events: Fam17h+ core perfctr, AMD PMU driver.
oct. 08 14:24:33 arch kernel: pci 0000:00:00.2: AMD-Vi: IOMMU performance counters supported
oct. 08 14:24:33 arch kernel: pci 0000:00:00.2: AMD-Vi: Found IOMMU cap 0x40
oct. 08 14:24:33 arch kernel: AMD-Vi: Extended features (0x206d73ef22254ade, 0x0): PPR X2APIC NX GT IA GA PC GA_vAPIC
oct. 08 14:24:33 arch kernel: AMD-Vi: Interrupt remapping enabled
oct. 08 14:24:33 arch kernel: AMD-Vi: X2APIC enabled
oct. 08 14:24:33 arch kernel: AMD-Vi: Virtual APIC enabled
oct. 08 14:24:33 arch kernel: perf: AMD IBS detected (0x000003ff)
oct. 08 14:24:33 arch kernel: perf/amd_iommu: Detected AMD IOMMU #0 (2 banks, 4 counters/bank).
oct. 08 14:24:33 arch kernel: AMD-Vi: AMD IOMMUv2 loaded and initialized
oct. 08 14:24:33 arch kernel: [drm] amdgpu kernel modesetting enabled.
oct. 08 14:24:33 arch kernel: amdgpu: CRAT table disabled by module option
oct. 08 14:24:33 arch kernel: amdgpu: Virtual CRAT table created for CPU
oct. 08 14:24:33 arch kernel: amdgpu: Topology: Add CPU node
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: enabling device (0006 -> 0007)
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: Fetched VBIOS from VFCT
oct. 08 14:24:33 arch kernel: amdgpu: ATOM BIOS: 113-BARCELO-004
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: vgaarb: deactivate vga console
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: Trusted Memory Zone (TMZ) feature enabled
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: MODE2 reset
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: VRAM: 512M 0x000000F400000000 - 0x000000F41FFFFFFF (512M used)
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: GART: 1024M 0x0000000000000000 - 0x000000003FFFFFFF
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: AGP: 267419648M 0x000000F800000000 - 0x0000FFFFFFFFFFFF
oct. 08 14:24:33 arch kernel: [drm] amdgpu: 512M of VRAM memory ready
oct. 08 14:24:33 arch kernel: [drm] amdgpu: 7649M of GTT memory ready.
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: Will use PSP to load VCN firmware
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: RAS: optional ras ta ucode is not available
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: RAP: optional rap ta ucode is not available
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: SECUREDISPLAY: securedisplay ta ucode is not available
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: SMU is initialized successfully!
oct. 08 14:24:33 arch kernel: amdgpu: HMM registered 512MB device memory
oct. 08 14:24:33 arch kernel: kfd kfd: amdgpu: Allocated 3969056 bytes on gart
oct. 08 14:24:33 arch kernel: kfd kfd: amdgpu: Total number of KFD nodes to be created: 1
oct. 08 14:24:33 arch kernel: amdgpu: Virtual CRAT table created for GPU
oct. 08 14:24:33 arch kernel: amdgpu: Topology: Add dGPU node [0x15e7:0x1002]
oct. 08 14:24:33 arch kernel: kfd kfd: amdgpu: added device 1002:15e7
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: SE 1, SH per SE 1, CU per SH 8, active_cu_number 8
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring gfx uses VM inv eng 0 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring gfx_low uses VM inv eng 1 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring gfx_high uses VM inv eng 4 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring comp_1.0.0 uses VM inv eng 5 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring comp_1.1.0 uses VM inv eng 6 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring comp_1.2.0 uses VM inv eng 7 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring comp_1.3.0 uses VM inv eng 8 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring comp_1.0.1 uses VM inv eng 9 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring comp_1.1.1 uses VM inv eng 10 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring comp_1.2.1 uses VM inv eng 11 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring comp_1.3.1 uses VM inv eng 12 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring kiq_0.2.1.0 uses VM inv eng 13 on hub 0
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring sdma0 uses VM inv eng 0 on hub 8
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring vcn_dec uses VM inv eng 1 on hub 8
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring vcn_enc0 uses VM inv eng 4 on hub 8
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring vcn_enc1 uses VM inv eng 5 on hub 8
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: amdgpu: ring jpeg_dec uses VM inv eng 6 on hub 8
oct. 08 14:24:33 arch kernel: [drm] Initialized amdgpu 3.54.0 20150101 for 0000:04:00.0 on minor 1
oct. 08 14:24:33 arch kernel: fbcon: amdgpudrmfb (fb0) is primary device
oct. 08 14:24:33 arch kernel: amdgpu 0000:04:00.0: [drm] fb0: amdgpudrmfb frame buffer device
oct. 08 14:24:34 arch kernel: pcie_mp2_amd 0000:04:00.7: enabling device (0000 -> 0002)
oct. 08 14:24:34 arch kernel: input: ELAN2513:00 04F3:2F96 Touchscreen as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input7
oct. 08 14:24:34 arch kernel: input: ELAN2513:00 04F3:2F96 as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input8
oct. 08 14:24:34 arch kernel: input: ELAN2513:00 04F3:2F96 as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input9
oct. 08 14:24:34 arch kernel: input: ELAN2513:00 04F3:2F96 Stylus as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input10
oct. 08 14:24:34 arch kernel: input: ELAN2513:00 04F3:2F96 Keyboard as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input11
oct. 08 14:24:34 arch kernel: input: ELAN2513:00 04F3:2F96 Mouse as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input12
oct. 08 14:24:34 arch kernel: input: ELAN2513:00 04F3:2F96 as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input14
oct. 08 14:24:34 arch kernel: input: ELAN2513:00 04F3:2F96 as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input15
oct. 08 14:24:34 arch kernel: input: ELAN2513:00 04F3:2F96 as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input16
oct. 08 14:24:34 arch systemd[1]: Starting Load/Save Screen Backlight Brightness of backlight:amdgpu_bl1...
oct. 08 14:24:34 arch kernel: input: SYNA32CB:00 06CB:CE7D Mouse as /devices/platform/AMDI0010:03/i2c-2/i2c-SYNA32CB:00/0018:06CB:CE7D.0003/input/input18
oct. 08 14:24:34 arch kernel: input: SYNA32CB:00 06CB:CE7D Touchpad as /devices/platform/AMDI0010:03/i2c-2/i2c-SYNA32CB:00/0018:06CB:CE7D.0003/input/input19
oct. 08 14:24:34 arch systemd[1]: Finished Load/Save Screen Backlight Brightness of backlight:amdgpu_bl1.
oct. 08 14:24:35 arch kernel: snd_hda_intel 0000:04:00.1: bound 0000:04:00.0 (ops amdgpu_dm_audio_component_bind_ops [amdgpu])
oct. 08 14:24:35 arch kernel: kvm_amd: TSC scaling supported
oct. 08 14:24:35 arch kernel: kvm_amd: Nested Virtualization enabled
oct. 08 14:24:35 arch kernel: kvm_amd: Nested Paging enabled
oct. 08 14:24:35 arch kernel: kvm_amd: Virtual VMLOAD VMSAVE supported
oct. 08 14:24:35 arch kernel: kvm_amd: Virtual GIF supported
oct. 08 14:24:35 arch kernel: kvm_amd: LBR virtualization supported
oct. 08 14:24:35 arch kernel: input: ELAN2513:00 04F3:2F96 as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input26
oct. 08 14:24:35 arch kernel: input: ELAN2513:00 04F3:2F96 UNKNOWN as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input27
oct. 08 14:24:35 arch kernel: input: ELAN2513:00 04F3:2F96 UNKNOWN as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input28
oct. 08 14:24:35 arch kernel: input: ELAN2513:00 04F3:2F96 Stylus as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input29
oct. 08 14:24:35 arch kernel: input: ELAN2513:00 04F3:2F96 Keyboard as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input30
oct. 08 14:24:35 arch kernel: input: ELAN2513:00 04F3:2F96 Mouse as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input31
oct. 08 14:24:35 arch kernel: input: ELAN2513:00 04F3:2F96 UNKNOWN as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input33
oct. 08 14:24:35 arch kernel: input: ELAN2513:00 04F3:2F96 UNKNOWN as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input34
oct. 08 14:24:35 arch kernel: input: ELAN2513:00 04F3:2F96 UNKNOWN as /devices/platform/AMDI0010:03/i2c-2/i2c-ELAN2513:00/0018:04F3:2F96.0002/input/input35
oct. 08 14:24:35 arch kernel: input: SYNA32CB:00 06CB:CE7D Mouse as /devices/platform/AMDI0010:03/i2c-2/i2c-SYNA32CB:00/0018:06CB:CE7D.0003/input/input37
oct. 08 14:24:35 arch kernel: input: SYNA32CB:00 06CB:CE7D Touchpad as /devices/platform/AMDI0010:03/i2c-2/i2c-SYNA32CB:00/0018:06CB:CE7D.0003/input/input38
oct. 08 14:24:36 arch gnome-shell[775]: Added device '/dev/dri/card1' (amdgpu) using atomic mode setting.
oct. 08 14:24:39 arch kernel: pcie_mp2_amd 0000:04:00.7: Failed to discover, sensors not enabled is 0
oct. 08 14:24:39 arch kernel: pcie_mp2_amd: probe of 0000:04:00.7 failed with error -95
oct. 08 14:24:41 arch gnome-shell[1297]: Added device '/dev/dri/card1' (amdgpu) using atomic mode setting
Comment 41 Mek101 2023-10-29 10:37:14 UTC
The bug seems to be solved on the Lenovo 14ALC05 with Kernel 6.5.5 (Ryzen 3 5300U)
Comment 42 Mauricio Collares 2023-11-02 16:56:18 UTC
Created attachment 305349 [details]
sensors missing from udevadm info --export-db after b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b

(In reply to Mario Limonciello (AMD) from comment #33)
> https://github.com/torvalds/linux/commit/
> b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b
> 
> This is the commit that changed the behavior to make the sensors not show up
> if they don't work.  There was a regression from that and so this commit
> went in to help that regression.
> 
> https://github.com/torvalds/linux/commit/
> 7bcfdab3f0c6672ca52be3cb65a0550d8b99554b

I have a HP ProBook x360 435 G7 (Ryzen 4700U). On GNOME Wayland with
the Screen Autorotate extension
(https://extensions.gnome.org/extension/4191/screen-autorotate/), I
confirmed by bisection that b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b
caused autorotation to stop working.

More specifically, before this commit (on aa0b724a2bf041036e56cbb3b4b3afde7c5e7c9e):

* `sudo iio-sensor-proxy -v -r` stays running (doesn't exit immediately) and prints nothing
* `monitor-sensor` starts up by saying "=== Has accelerometer (orientation: normal)" and prints "    Accelerometer orientation changed: bottom-up" when I physically rotate the screen.
* `udevadm info --export-db` contains the accelerometer/gyroscope sensor info I've pasted in the attachment.

After b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b:

* `sudo iio-sensor-proxy -v -r` exits immediately.
* `monitor-sensor` prints "    Waiting for iio-sensor-proxy to appear" on startup and does nothing when I rotate the screen.
* The sensors in the attachment are no longer listed in `udevadm info --export-db`.
* The `hid_sensor_gyro_3d` and `hid_sensor_accel_3d` kernel modules are no longer loaded automatically, and loading them does nothing.

I'd be happy to provide any information that might be useful.
Comment 43 Mauricio Collares 2023-11-02 17:54:05 UTC
Forgot to mention the most important piece of context: Screen autorotation continues not to work as of 6.6.0-rc7, exhibiting the same behavior as b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b.
Comment 44 Mario Limonciello (AMD) 2023-11-02 20:55:05 UTC
If you revert that commit on top of 6.6 does it start working?  Also; can you still get into the deepest s2idle sleep state in 6.6 with it reverted?  You can check with /sys/power/suspend_stats/last_hw_sleep.
Comment 45 Laurence Bonat 2023-11-02 21:53:15 UTC
I tried again with kernel v6.5.7 and still had no success. Will try to apply a patch to revert that commit and see what will do on my ryzen 4700u. I still think that the problem is not resolved for these hp envy x360 models.
Comment 46 Mauricio Collares 2023-11-03 08:00:20 UTC
Created attachment 305352 [details]
amd_s2idle.py report on stock 6.6

(In reply to Mario Limonciello (AMD) from comment #44)
> If you revert that commit on top of 6.6 does it start working?  Also; can
> you still get into the deepest s2idle sleep state in 6.6 with it reverted? 
> You can check with /sys/power/suspend_stats/last_hw_sleep.

Thanks for the reply! Reverting the commit on top of 6.6 makes screen autorotation work again. I don't have a /sys/power/suspend_stats/last_hw_sleep file (tested on stock 6.6, as well as on 6.6 + revert of b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b), but if I leave my computer idle for a while it enters standby and I see

Nov 03 08:47:29 hp kernel: PM: suspend entry (deep)

in journalctl. Also, the content of /sys/power/mem_sleep is "s2idle [deep]". I have attached the report produced by amd_s2idle.py run on stock 6.6 in case it is relevant (I can also attach it for 6.6 + revert if desired).
Comment 47 Laurence Bonat 2023-11-05 10:53:49 UTC
Created attachment 305367 [details]
outputs of various commands describing the problem
Comment 48 Laurence Bonat 2023-11-05 11:08:18 UTC
(In reply to Mauricio Collares from comment #43)
> Forgot to mention the most important piece of context: Screen autorotation
> continues not to work as of 6.6.0-rc7, exhibiting the same behavior as
> b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b.

Hi, I tried seeing if there where any improvements on my x360 ay0xxx convertible. 
On kernel 6.5.7 I had the same regression problem that Mauricio reported. 
So I tried to patch up kernel 6.6 with the revert of commit b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b, and monitor-sensor gives me this output: 
* Waiting for iio-sensor-proxy to appear
* +++ iio-sensor-proxy appeared
* === Has accelerometer (orientation: undefined)
* === No ambient light sensor
* === No proximity sensor

The problem I find is that the accelerometer cannot understand in which orientation is. I produced some more outputs using iio-sensor-proxy, that I have attached with the text file in comment #47. 

Notice that iio_generic_buffer gives in output always zeros:
* iio device number being used is 0
* iio trigger number being used is 0
* Enabling all channels
* Enabling: in_accel_x_en
* Enabling: in_accel_z_en
* Enabling: in_timestamp_en
* Enabling: in_accel_y_en
* /sys/bus/iio/devices/iio:device0 accel_3d-dev0
* 0.000000 0.000000 0.000000 1699106706297920691
* 0.000000 0.000000 0.000000 1699106706502232745
* 0.000000 0.000000 0.000000 1699106706705918733

I suppose that the matrix of the accelerometer is not initialized correctly, or even the sensor-mask. 

I attached the output of iio-sensor-proxy, and even that has some errors: 
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.755: Found associated trigger at /sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/trigger0
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.755: Found IIO buffer accelerometer at /sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/iio:device0
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.755: No auto-detected location, falling back to display location
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.755: Found device /sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/iio:device0 of type accelerometer at IIO Buffer accelerometer
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.764: Found associated trigger at /sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/trigger0
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.764: Already enabled sensor /sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/iio:device0/scan_elements/in_accel_x_en
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.764: Already enabled sensor /sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/iio:device0/scan_elements/in_accel_z_en
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.764: Already enabled sensor /sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/iio:device0/scan_elements/in_timestamp_en
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.765: Already enabled sensor /sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/iio:device0/scan_elements/in_accel_y_en
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.765: Trying to read 'in_accel_x_scale' (name) from dir '/sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/iio:device0'
** (iio-sensor-proxy:2949): DEBUG: 14:53:08.765: Failed to read float from /sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/iio:device0/in_accel_x_scale: Failed to open file “/sys/devices/0020:1022:0001.0001/HID-SENSOR-200073.1.auto/iio:device0/in_accel_x_scale”: No such file or directory

The problem I encounter I think is related to how the sensor-mask is loaded, and I don't understand how to fix it. 
As already discussed, in windows the drivers correctly rotates the screen. 
If any other information is needed please contact me, I really want the rotation to work on my pc.

Thanks, 
Laurence
Comment 49 Mauricio Collares 2023-11-05 12:13:23 UTC
Thanks to Laurence's previous comment, I now realize I should have filed a new bug instead, because my issue has different symptoms: after reverting b300667b33b2b5a2c8e5f8f22826befb3d7f4f2b `monitor-sensor` reports "=== Has accelerometer (orientation: normal)" and `iio_generic_buffer --device-num 2 -A -c 100` reports good accelerometer values. 

I have filed bug #218104 to track my issue. Apologies if you were inadvertently CC'd into it by the "Clone bug" feature.
Comment 50 Ethan Latimer 2024-04-16 23:23:31 UTC
I've got a similar HP Envy-x360 ee0000na laptop that runs a 4500U processor.
I have not been successful to even get sensors to be recognised at all on my system.

pcie_mp2_amd 0000:04:00.7: enabling device (0000 -> 0002)
pcie_mp2_amd 0000:04:00.7: Failed to discover, sensors not enabled is 0
pcie_mp2_amd: probe of 0000:04:00.7 failed with error -95

Result of this has been that iio-sensors-proxy will never recognise the sensor on this set of hardware. 

Almost exact same behaviour as this arch forum post:
https://bbs.archlinux.org/viewtopic.php?id=286254
Comment 51 Stormy 2024-06-21 12:42:46 UTC
(In reply to Stormy from comment #12)
> Hello everyone,
> 
> I have the same issue with the following laptop...
> 
> 
> Make/Model: HP ENVY x360 2-in-1 Convertible 15z-ee100
> 
> CPU/GPU: AMD Ryzen 5700U with Radeon Graphics
> 
> 
> I hope this will help find a fix.

Still an issue with Linux Kernel 6.9

Specific OS I tried, manjaro-kde-24.0.2-240611-linux69.iso
Comment 52 FNHG 2024-10-03 19:49:49 UTC
Hello everyone,

I'm also currently experiencing the bug in this thread.

When checking dmesg, i get this upon startup:

  [   12.142382] pcie_mp2_amd 0000:04:00.7: amd_sfh_hid_client_init failed err -95

The output of monitor-sensor then is as follows:

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

There is also no output using udevadm info --export-db | grep -i iio 

However when I then remove amd_sfh using modprobe and re-add itmmediately after, monitor sensors reports:

      Waiting for iio-sensor-proxy to appear
  +++ iio-sensor-proxy appeared
  === Has accelerometer (orientation: undefined)
  === No ambient light sensor
  === No proximity sensor

and udevadm info --export-db | grep -i iio reports

  P: /devices/0018:03FE:0001.0003/HID-SENSOR-200073.1.auto/iio:device0
  M: iio:device0
  U: iio
  T: iio_device
  N: iio:device0
  E: DEVPATH=/devices/0018:03FE:0001.0003/HID-SENSOR-200073.1.auto/iio:device0
  E: SUBSYSTEM=iio
  E: DEVNAME=/dev/iio:device0
  E: DEVTYPE=iio_device
  E: IIO_SENSOR_PROXY_TYPE=iio-poll-accel iio-buffer-accel
  E: SYSTEMD_WANTS=iio-sensor-proxy.service
  U: iio
  E: SUBSYSTEM=iio

Im currently using:

HP ENVY x360 13-ay0xxx
EndeavourOS with kernel 6.11.1

Although I probably dont have much new information, I just want to inform, that the issue is still persisting to this day.
Comment 53 caffeine01 2025-01-17 14:08:25 UTC
Hi all! I am currently on an HP Envy x360 15fh-0010na, I managed to get the accelerometer working under kernel 6.12.9!
I was messing around with passing through PCI devices to virtual machines when all of a sudden, I connected the accelerometer and then disconnected it and monitor-sensor started working along with iio-sensor-proxy!
So I created a systemd service which runs after (and is wanted by) "multi-user.target", "suspend.target", and "hibernate.target" to automatically remove the PCI device and then issue a PCI bus rescan to add it back.
For whatever reason, the sensor fusion hub for these laptops doesn't seem to get initialised properly by the kernel during boot and for me the network card sometimes breaks too after awaking from suspend.
This laptop only supports s2idle "modern suspend".

With all this, I suspect that (with my limited knowledge) the ACPI tables for this range/model of laptop are a little borked, hopefully it will be fixed at some point lol.

Here is the script if you want it (will only work if your sensor fusion hub shows up in lspci):
echo "1" > /sys/bus/pci/devices/0000:04:00.7/remove
sleep 1
echo "1" > /sys/bus/pci/rescan

Here is my corresponding nix module for it:
let 
  script = ''
        echo "Starting autorotate fix..."
        echo "1" > /sys/bus/pci/devices/0000:04:00.7/remove
        sleep 1
        echo "1" > /sys/bus/pci/rescan
      '';
in {
  systemd.services.reset-sfh = {
    enable = true;
    
    description = "Reset for AMD Sensor Fusion Hub PCI device.";
    after = [ "multi-user.target" "systemd-suspend.service" ];
    wantedBy = [ "multi-user.target" "systemd-suspend.service" ];
    
    serviceConfig = {
      Type = "oneshot";
    };
    
    inherit script;
  };
}

Hope this helps someone
Comment 54 Mario Limonciello (AMD) 2025-01-17 14:12:29 UTC
Considering the finding mentioned in #53; could you also experiment with unbinding/rebinding the driver to the PCI device?  Or is it specifically the PCI device reset that is getting it working?
Comment 55 caffeine01 2025-01-17 15:55:44 UTC
You seem to be correct! I will test further, but after disabling the automatic pci reset and checking that autorotate doesn't work, i ran:

❯ sudo modprobe -r amd_sfh
❯ sudo modprobe amd_sfh

(waited a couple seconds, tried rotating, didnt work)

❯ monitor-sensor
    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared //iio-sensor-proxy systemd service will reboot when a new device is detected
=== Has accelerometer (orientation: undefined) //behaviour like in the rest of the thread
=== No ambient light sensor
=== No proximity sensor
//couple more seconds go by
    Accelerometer orientation changed: normal
    Accelerometer orientation changed: right-up //i tilt the laptop
    Accelerometer orientation changed: normal

Simply unloading and reloading the kernel driver seems to do the trick!
Comment 56 caffeine01 2025-01-17 16:00:18 UTC
Please let me know a sequence of commands you would like me to perform for further info/testing.
Comment 57 Stuart Morgan 2025-01-17 16:07:04 UTC
Alas the 13-ay0009na (4700U) still doesn't work with 6.12.9 even after reloading the driver. As we approach the 4 year mark on this ticket, I sadly don't think these older generation Ryzen processors will ever be supported and it might be time to close this ticket and open new ones specific to the newer generation hardware.
Comment 58 Mario Limonciello (AMD) 2025-01-17 16:12:16 UTC
Created attachment 307500 [details]
patch to stop all sensors during init

Given that finding, can you see if perhaps this helps?  This will explicitly send a stop all sensors command before enabling them.
Comment 59 caffeine01 2025-01-17 16:27:08 UTC
Will try that patch shortly.

Again though, I do think that this has something to do with either amd_pmc, ACPI and modern standby as both the network card and sensor fusion hub need to be "reset" after waking up from the shitty modern standby.
❯ cat /sys/power/mem_sleep
[s2idle]

The wifi and bluetooth of this device work fine on fresh boot for example, but if i have my laptop connected to my bluetooth headphones and then close the lid it will disconnect (expected behaviour), after some time the laptop seems to randomly reconnect to the headphones for a short while (indicated by the lovely sony voice lady letting me know "bluetooth connected") and then subsequently disconnect. Usually if i open the laptop again then the network adapter might just stop working (might have something to do with the bluetooth weirdness) for whatever reason and be unable to discover any networks, requiring the pci reset thing OR a reboot (or maybe a driver reload as you correctly suggested for the sfh). 

Every single time without fail though, the sfh seems to not enjoy it when the laptop comes out of s2idle.
Just put the laptop to sleep while writing this and my screen is now stuck upside down after opening the laptop again (i suppose as the laptop goes in to s2idle the sfh reports its position as 'bottom-up' for some reason. This is confirmed by the current output:
❯ monitor-sensor
    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: bottom-up)
=== No ambient light sensor
=== No proximity sensor


This doesn't appear to be an issue with iio-sensor-proxy as i just restarted that service and the output is the exact same, and no rotations are occurring.
Then afterwards i reloaded the kernel driver -> it worked.
❯ monitor-sensor
    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: bottom-up)
=== No ambient light sensor
=== No proximity sensor
^C⏎                  
                                                              
❯ sudo modprobe -r amd_sfh

❯ sudo modprobe amd_sfh               

❯ monitor-sensor
    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared //this took a couple seconds
=== Has accelerometer (orientation: undefined)
=== No ambient light sensor
=== No proximity sensor
    Accelerometer orientation changed: normal
    Accelerometer orientation changed: right-up
    Accelerometer orientation changed: normal
Comment 60 Mario Limonciello (AMD) 2025-01-17 16:32:36 UTC
#57

You might be right.  Let's see what we come up with in this latest news.

#59

> Again though, I do think that this has something to do with either amd_pmc,
> ACPI and modern standby as both the network card and sensor fusion hub need
> to be "reset" after waking up from the shitty modern standby.

It's venturing outside of this issue, for the findings you have that are NOT SFH can you please open a new ticket?  Please CC me and include a report generated from https://gitlab.freedesktop.org/drm/amd/-/blob/master/scripts/amd_s2idle.py.

> Every single time without fail though, the sfh seems to not enjoy it when the
> laptop comes out of s2idle.

We might need to do the same stop before start sequence in the resume() callback.  Let's see what your findings are from that patch I shared at bootup.
Comment 61 caffeine01 2025-01-17 17:41:05 UTC
Nothing seems to have changed, i will re check and make sure 100% i am booting into the patched kernel, but i dont think the fix worked.
Comment 62 Mario Limonciello (AMD) 2025-01-17 17:43:12 UTC
>  i will re check and make sure 100% i am booting into the patched kernel

If you want a double check - throw a pr_info() into the patch to make sure you see it when the module loads.

> but i dont think the fix worked.

OK it's plausible that's not the specific action that happens on unload that helped.
Comment 63 FNHG 2025-01-17 17:49:36 UTC
I would like to help troubleshooting this, if I can. However my knowledge about this is somewhat limited.

My system is:
HP ENVY x360 Convertible 13-ay0xxx
AMD Ryzen 7 4700U
6.12.9-zen1-1-zen (issue persists on both linux and linux-zen)

The main problem for me is the autorotate which isn't working. However, iio_sensor_proxy does not appear anymore in monitor-sensors, even after unloading and reloading amd_sfh.

I found this error in dmesg, though:
[  112.966394] pcie_mp2_amd 0000:04:00.7: amd_sfh_hid_client_init failed err -95

Can I assist in providing information or testing?
Comment 64 Mario Limonciello (AMD) 2025-01-17 17:59:37 UTC
> I found this error in dmesg, though:
> [  112.966394] pcie_mp2_amd 0000:04:00.7: amd_sfh_hid_client_init failed err
> -95

# errno 95
EOPNOTSUPP 95 Operation not supported

> I would like to help troubleshooting this, if I can. However my knowledge
> about this is somewhat limited.

You should see paired warning with this message about sensors not being discovered.  IE:

https://github.com/torvalds/linux/commit/8031b001da700

I'm inclined to agree we have two different issues here that you and Stuart are observing and a different one that caffeine01 is observing.
Comment 65 Mario Limonciello (AMD) 2025-01-17 18:01:05 UTC
Created attachment 307502 [details]
patch to clear pending interrupts before starting

Here's another stab at caffeine01's reported behavior. This will clear the interrupt in case the firmware had one from before the driver got loaded.
Comment 66 FNHG 2025-01-17 18:18:20 UTC
Yes, indeed. This is dmesg output filtered for the device:

[    0.327378] pci 0000:04:00.7: [1022:15e4] type 00 class 0x118000 PCIe Endpoint
[    0.327390] pci 0000:04:00.7: BAR 2 [mem 0xd0000000-0xd00fffff]
[    0.327399] pci 0000:04:00.7: BAR 5 [mem 0xd04cc000-0xd04cdfff]
[    0.327406] pci 0000:04:00.7: enabling Extended Tags
[    0.543366] pci 0000:04:00.7: Adding to iommu group 5
[   82.985532] pcie_mp2_amd 0000:04:00.7: enabling device (0000 -> 0002)
[  112.966376] pcie_mp2_amd 0000:04:00.7: Failed to discover, sensors not enabled is 0
[  112.966394] pcie_mp2_amd 0000:04:00.7: amd_sfh_hid_client_init failed err -95
[  157.236581] pcie_mp2_amd 0000:04:00.7: Failed to discover, sensors not enabled is 0
[  157.236601] pcie_mp2_amd 0000:04:00.7: amd_sfh_hid_client_init failed err -95
[  193.260031] pcie_mp2_amd 0000:04:00.7: Failed to discover, sensors not enabled is 0
[  193.260053] pcie_mp2_amd 0000:04:00.7: amd_sfh_hid_client_init failed err -95

Currently reading about what has already been posted about this issue on other forums.

(In reply to Mario Limonciello (AMD) from comment #64)
Comment 67 caffeine01 2025-01-17 19:19:25 UTC
#65
> Created attachment 307502 [details]
> patch to clear pending interrupts before starting

> Here's another stab at caffeine01's reported behavior. This will clear the 
> interrupt in case the firmware had one from before the driver got loaded.

This patch also didn't work.
All I'm getting that could be related in dmesg is:
[Fri Jan 17 19:06:15 2025] pci 0000:04:00.7: [1022:15e4] type 00 class 0x118000 PCIe Endpoint
[Fri Jan 17 19:06:15 2025] pci 0000:04:00.7: BAR 2 [mem 0xd0300000-0xd03fffff]
[Fri Jan 17 19:06:15 2025] pci 0000:04:00.7: BAR 5 [mem 0xd05cc000-0xd05cdfff]
[Fri Jan 17 19:06:15 2025] pci 0000:04:00.7: enabling Extended Tags
[Fri Jan 17 19:06:15 2025] pci 0000:04:00.7: Adding to iommu group 20
[Fri Jan 17 19:06:20 2025] pcie_mp2_amd 0000:04:00.7: enabling device (0000 -> 0002)
[Fri Jan 17 19:06:30 2025] hid-sensor-hub 0020:1022:0001.0004: hidraw3: SENSOR HUB HID v0.00 Device [hid-amdsfh 1022:0001] on pcie_mp2_amd
Comment 68 caffeine01 2025-01-17 19:27:18 UTC
After unloading and reloading the kernel driver however, i get this line in dmesg:
[Fri Jan 17 19:24:01 2025] hid-sensor-hub 0020:1022:0001.0005: hidraw3: SENSOR HUB HID v0.00 Device [hid-amdsfh 1022:0001] on pcie_mp2_amd

0020:1022:0001.0005 is a new id that doesnt show up in dmesg before reloading the kernel driver.
Comment 69 caffeine01 2025-01-17 19:37:20 UTC
Nevermind, the .000x: at the end of the id seems to be merely incremental, put the laptop in s2idle and then woke it up again (sensor not working) then reloaded the kernel driver and yeah:

❯ sudo dmesg -T | head -n 20000 > output.txt
❯ cat output.txt | grep pcie_mp2
[Fri Jan 17 19:07:36 2025] pcie_mp2_amd 0000:04:00.7: enabling device (0000 -> 0002)
[Fri Jan 17 19:07:46 2025] hid-sensor-hub 0020:1022:0001.0004: hidraw3: SENSOR HUB HID v0.00 Device [hid-amdsfh 1022:0001] on pcie_mp2_amd
[Fri Jan 17 19:25:18 2025] hid-sensor-hub 0020:1022:0001.0005: hidraw3: SENSOR HUB HID v0.00 Device [hid-amdsfh 1022:0001] on pcie_mp2_amd
[Fri Jan 17 19:36:47 2025] hid-sensor-hub 0020:1022:0001.0006: hidraw3: SENSOR HUB HID v0.00 Device [hid-amdsfh 1022:0001] on pcie_mp2_amd
Comment 70 Laurence Bonat 2025-01-31 11:42:40 UTC
Hi, 
I tried what caffeine01 suggested but it still doesn't work for me with kernel 6.12.11. 

The output I get when I try to rescan for the sensor is the following:

[gen31 12:24] pci 0000:04:00.7: [1022:15e4] type 00 class 0x118000 PCIe Endpoint
[  +0,000047] pci 0000:04:00.7: BAR 2 [mem 0xd0000000-0xd00fffff]
[  +0,000026] pci 0000:04:00.7: BAR 5 [mem 0xd04cc000-0xd04cdfff]
[  +0,000306] pci 0000:04:00.7: Adding to iommu group 5
[  +0,000177] pci 0000:04:00.7: BAR 2 [mem 0xd0000000-0xd00fffff]: assigned
[  +0,000009] pci 0000:04:00.7: BAR 5 [mem 0xd04cc000-0xd04cdfff]: assigned
[gen31 12:25] pcie_mp2_amd 0000:04:00.7: Failed to discover, sensors not enabled is 0
[  +0,000020] pcie_mp2_amd 0000:04:00.7: amd_sfh_hid_client_init failed err -95

I think it is still a missing configuration on the initialization as commented in comment 29, since in Windows the sensor worked flawlessly. 
If you need more information/outputs contact me, I will try to see what I can do if you need more lower-level outputs. 
It's 5 years, but we can still give it a go.
Comment 71 Mario Limonciello (AMD) 2025-02-03 22:13:55 UTC
It might be worth comparing registers used by SFH in Windows and Linux by using RW Everything in Windows.

I had some guidance I provided in the past on the use of R/W everything with another driver issue (this was pinctrl-amd).  Do you think you can use this to experiment and gather info?

https://bugzilla.kernel.org/show_bug.cgi?id=217336#c126

It's possible this is a dead end because the use of SFH is state machine, but we can at least see if there is anything useful to compare.
Comment 72 Laurence Bonat 2025-02-06 20:10:44 UTC
(In reply to Mario Limonciello (AMD) from comment #71)
> It might be worth comparing registers used by SFH in Windows and Linux by
> using RW Everything in Windows.
> 
> I had some guidance I provided in the past on the use of R/W everything with
> another driver issue (this was pinctrl-amd).  Do you think you can use this
> to experiment and gather info?
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=217336#c126
> 
> It's possible this is a dead end because the use of SFH is state machine,
> but we can at least see if there is anything useful to compare.

Yes I can Try but which part of R/W everything should I look into? If you could give me a quick guide of which address and part should I look for?
Because it's my first time using it. 
What address should I add and use the MMIO tab?
Maybe I can find the address from the device manager under Windows?
Tell me so I can give you a detailed report
Comment 73 Mario Limonciello (AMD) 2025-02-06 20:44:41 UTC
To start out I think you should unload the driver and load with dyndbg enabled and check the messages you get to save some shortcuts on what to read and what not to read.

After that you need to find the MMIO base address for your SFH controller first.  On my system this is how you do that:

$ lspci -s c4:00.7 -vv
c4:00.7 Signal processing controller: Advanced Micro Devices, Inc. [AMD] Device 164a
        Subsystem: Advanced Micro Devices, Inc. [AMD] Device 164a
        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
        Interrupt: pin C routed to IRQ 59
        IOMMU group: 25
        Region 2: Memory at b0300000 (32-bit, non-prefetchable) [size=1M]
        Region 5: Memory at b05cc000 (32-bit, non-prefetchable) [size=8K]
        Capabilities: <access denied>
        Kernel driver in use: pcie_mp2_amd
        Kernel modules: amd_sfh

You can see that it shows Region 2 and Region 5.
Region 2 is what amd_mp2_pci_probe() uses for it's MMIO base address.
You'll add the offsets of other addresses to read a specific address.

For example this register:

#define AMD_P2C_MSG3	0x1068C /* Supported Sensors info */

For me that would be obtained by reading 0xb031068C.

So if you start out by reading that register, see what bits 0 through 3 get you.  If they're 0x2 then this is a v2 system that uses amd_sfh_ops_v2.

The supported sensors will be in the rest of the bits.  IE if you shift these:

#define ACEL_EN		BIT(0)
#define GYRO_EN		BIT(1)
#define MAGNO_EN	BIT(2)
#define HPD_EN		BIT(16)
#define ALS_EN		BIT(19)
#define ACS_EN		BIT(22)

The values you find here will be used to help interpret data in the other registers.

These are the 3 other mailbox registers used by the driver:

#define AMD_C2P_MSG0	0x10500
#define AMD_C2P_MSG1	0x10504
#define AMD_C2P_MSG2	0x10508

if this is a v2 system:

AMD_C2P_MSG0 is used to indicate the sensor index that is being accessed, the period and whether the interrupt is enabled/disabled.

AMD_C2P_MSG1 is used to write the DMA address that the sensor data is written.

if this is a v1 system:

AMD_C2P_MSG2 is used to write the DMA address that the sensor data is written.
AMD_C2P_MSG1 is used to indicate the command parameter layout
AMD_C2P_MSG0 is used to indicate period and sensor index.

Assuming all that can read well, the next thing to read is the registers that amd_get_c2p_val() and amd_get_p2c_val() fetch.  These will also be version dependent for how the macros work.

pc2_val (0) will get sensor responses.  If you read this a few times while flipping orientation we should see the sensor ID reporting data in the response register etc.

pc2_val (1) will get the sensors discovered. This is what we mostly want to find out if it differs from Linux side.

c2p_val (3) will get the placement information used by amd_sfh_mode_info().
c2p_val (4) will get the HPD information used by amd_sfh_hpd_info().

c2p_val (22) will get a region of memory reserved for the system firmware to communicate.

Sorry that's a lot, but see if you can get started on it.  I mostly want to see if there is a different sensor type /ID being used from the discovery data on Windows than on Linux.
Comment 74 Laurence Bonat 2025-02-07 10:33:30 UTC
Hi, 
I've read the registers from both ubuntu and Linux, here are the results.


Windows: 
NAME	        OFFSET	        ADDRESS	        VALUE
AMD_P2C_MSG3	0001068C	D001068C	002BDFF2
AMD_C2P_MSG0	00010500	D0010500	14000201
AMD_C2P_MSG1	00010504	D0010504	08F9A5C0
AMD_C2P_MSG2	00010508	D0010508	00000001

Linux:
              VALUE
AMD_P2C_MSG3: 0x002BDFF2
AMD_C2P_MSG0: 0xC8001011
AMD_C2P_MSG1: 0x4304F000
AMD_C2P_MSG2: 0x00000001

I read AMD_C2P_MSG2 just for the sake of security, but since it is a v2 system it reads 1. 

(In reply to Mario Limonciello (AMD) from comment #73)
> pc2_val (0) will get sensor responses.  If you read this a few times while
> flipping orientation we should see the sensor ID reporting data in the
> response register etc.
> 
> pc2_val (1) will get the sensors discovered. This is what we mostly want to
> find out if it differs from Linux side.
> 
> c2p_val (3) will get the placement information used by amd_sfh_mode_info().
> c2p_val (4) will get the HPD information used by amd_sfh_hpd_info().
> 
> c2p_val (22) will get a region of memory reserved for the system firmware to
> communicate.

I don't really understand this part. How can I run the singles functions from the driver itself? Should I write a module that calls those functions? Sorry but I found little resources online, or maybe I'm searching the wrong thing XD.

I enabled dyndbg=+p on the modprobe call, but it always give me this output on dmesg: 
[   34.509436] pcie_mp2_amd 0000:04:00.7: Failed to discover, sensors not enabled is 0
[   34.509459] pcie_mp2_amd 0000:04:00.7: amd_sfh_hid_client_init failed err -95

Thanks again for the patience, let me know what to do.
Laurence

Note You need to log in before you can comment on or make changes to this bug.