No sound after sleep mode

I have a Xioami notebook pro laptop on fresh Manjaro GNOME.

After the laptop goes in sleep/hibernate mode, there is no sound that comes out of the speakers. The system settings (settings>sounds) are detecting music is being played and the headphones are working fine after sleep. The issue is only related to the speakers integrated in the laptop. As a quick fix, I need to reboot to have the speakers to work again.

I tried to use method that I had found:

$ sudo su -
$ echo 1 > /sys/bus/pci/devices/0000:00:1f.3/remove
$ echo 1 > /sys/bus/pci/rescan

But nothing happens after any of this commands. Cursor just blinking, tab in terminal looks frozen. Output device in GNOME Settings changes to dummy output.

Additional hardware info:

$ aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC256 Analog [ALC256 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
$ cat /proc/asound/cards

0 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xb4314000 irq 157
$ lspci -nnk | grep -A2 Audio

00:1f.3 Audio device [0403]: Intel Corporation Device [8086:02c8]
	Subsystem: Xiaomi Device [1d72:1905]
	Kernel driver in use: snd_hda_intel
pacmd list-cards

1 card(s) available.
    index: 0
	name: <alsa_card.pci-0000_00_1f.3>
	driver: <module-alsa-card.c>
	owner module: 6
	properties:
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0xb4314000 irq 157"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1f.3"
		sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "02c8"
		device.form_factor = "internal"
		device.string = "0"
		device.description = "Built-in Audio"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
...

For me disabling pipewire and restarting pulsaudio did the trick.

systemctl --user disable --now pipewire.socket
systemctl --user disable --now pipewire.service
systemctl --user restart pulseaudio.service

I also masked pipewire just to make sure.

@chromsky Thank you very much!

After disabling pipewire I added the restart audio script to /lib/systemd/system-sleep/99_restart_sound and now sound working after waking up.

#!/bin/sh
  
case "$1" in
    post)
        DEVICE_ID=`lspci -D |grep Audio|awk '{print $1}'`
        echo 1 > /sys/bus/pci/devices/${DEVICE_ID}/remove
        sleep 1
        echo 1 > /sys/bus/pci/rescan
esac

The file must be executable:

sudo chmod +x /lib/systemd/system-sleep/99_restart_sound

After disabling pipewire I didn’t have any issues with sound after sleep mode but I’ll keep your script in mind if the audio problems were to return.