Disable Nvidia Graphics and Sound Completely

Laptops are bad at everything except portability. I like to use my laptop on battery power, without mains electricity occasionally but unfortunately, my built in Nvidia graphics chip keeps turning on, getting hot and using 12 Watts or more of power doing nothing (20 watts total). I cannot use the BIOS to turn off the NVIDIA GEFORCE GTX chip.

I used Linux Mint 20 and power consumption dropped to less than 8 Watts but Mint uses old vulnerable versions of applications like thunderbird etc. I tried the latest Ubuntu Mate but the lowest power consumption I could get was 12 Watts and there were many other bugs so I re-installed Ubuntu Mate 20.04 again and compiled my own Email client but I am left with the Nvidia power problem.

My best simple option is to use the nouveau open source graphic driver which drops to less than 12Watts doing nothing. Optimus-prime works for a while.

I tried Bumblebee, optimus-prime, Nvidia settings, removing all nvidia drivers, blacklisting nvidia and but unfortunately, the Ubuntu-mate sound system scans the PCI bus and activates the same nvidia graphics chip through some back door (HDMI scan?) and ignores the realtek and Intel HDA drivers even whilst I am only using Intel graphics!

install snd_hda_codec_hdmi /bin/false # Did not help

I had been able to start and stop the nvidia chip by starting and stopping pulseaudio and relying on ALSA audio but no modern web browser uses ALSA, only pulsaudio and after a kernel update, that pulseaudio on/off trick no longer works and the Sound Preferences applet only shows Intel HDA output in mono or Nvidia (despite removal and purge of all nvidia kernel modules) but neither works for sound output in a web browser but ALSA still works fine for normal audio application on my Mate desktop.

uname -r

dmesg shows that the nvidia PCI sound chip is started and the GPU just gulps down energy forever

[ 4.209655] snd_hda_intel 0000:01:00.1: Disabling MSI
[ 4.209661] snd_hda_intel 0000:01:00.1: Handle vga_switcheroo audio client
[ 4.211293] thermal thermal_zone5: failed to read out thermal zone (-61)
[ 4.219751] iwlwifi 0000:08:00.0: Applying debug destination EXTERNAL_DRAM
[ 4.220081] iwlwifi 0000:08:00.0: Allocated 0x00400000 bytes for firmware monitor.
[ 4.228026] iwlwifi 0000:08:00.0: base HW address: a4:02:b9:6b:3f:41
[ 4.246050] Adding 23448572k swap on /dev/sda5. Priority:-2 extents:1 across:23448572k SSFS
[ 4.278856] input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input11
[ 4.278899] input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input12
[ 4.278961] input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input13
[ 4.279022] input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input14
[ 4.290042] ieee80211 phy0: Selected rate control algorithm 'iwl-mvm-rs'

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Host Bridge/DRAM Registers (rev 07)
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
00:1f.3 Audio device: Intel Corporation 100 Series/C230 Series Chipset Family HD Audio Controller (rev 31)
01:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 960M] (rev a2)
01:00.1 Audio device: NVIDIA Corporation GM107 High Definition Audio Controller [GeForce 940MX] (rev a1)
07:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS522A PCI Express Card Reader (rev 01)

With a fresh install and optimus and low power settings, I can get on battery usage down to 5 Watts but something always gets broken after updates.

My simple question is: is it not possible to turn off my Nvidia graphics chip in some simple repeatable quick death ?

I have no nvidia modules loaded but the NVIDIA chip always turns on and makes the keyboard plate hot!

lsmod | grep snd
snd_ctl_led 24576 0
snd_hda_codec_realtek 139264 1
snd_hda_codec_generic 81920 1 snd_hda_codec_realtek
ledtrig_audio 16384 2 snd_ctl_led,snd_hda_codec_generic
snd_hda_codec_hdmi 61440 2
snd_hda_intel 53248 9
snd_intel_dspcfg 28672 1 snd_hda_intel
snd_intel_sdw_acpi 20480 1 snd_intel_dspcfg
snd_hda_codec 147456 4 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_realtek
snd_hda_core 94208 5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek
snd_hwdep 16384 1 snd_hda_codec
snd_pcm 114688 6 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_core
snd_seq_midi 20480 0
snd_seq_midi_event 16384 1 snd_seq_midi
snd_rawmidi 36864 1 snd_seq_midi
snd_seq 73728 2 snd_seq_midi,snd_seq_midi_event
snd_seq_device 16384 3 snd_seq,snd_seq_midi,snd_rawmidi
snd_timer 40960 2 snd_seq,snd_pcm
snd 94208 28 snd_ctl_led,snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
soundcore 16384 2 snd_ctl_led,snd

HP Pavilion 15-bc021tx Product Specifications
Product number X3C37P
Product name HP Pavilion 15-bc021tx
Microprocessor: Intel® Core™ i7-6700HQ (2.6 GHz, up to 3.5 GHz, 6 MB cache, 4 cores)
Chipset Intel HM170
Memory, standard 4 GB DDR4-2133 SDRAM (1 x 4 GB)
Video graphics NVIDIA® GeForce® GTX 960M (4 GB GDDR5 dedicated)
Hard drive 1 TB 7200 rpm SATA
Display 15.6" diagonal FHD IPS UWVA anti-glare WLED-backlit (1920 x 1080)
Keyboard Full-size island-style backlit keyboard with numeric keypad
Pointing device HP Imagepad with multi-touch gesture support
Wireless connectivity Intel® 802.11ac (2x2) Wi-Fi® and Bluetooth® 4.2 Combo (Miracast compatible)
Network interface Integrated 10/100/1000 GbE LAN
Expansion slots 1 multi-format SD media card reader
External ports 1 HDMI; 1 headphone/microphone combo; 1 USB 2.0; 2 USB 3.0; 1 RJ-45

I just want to turn the NVIDIA chip off and use the Intel Graphics instead - that must be possible?

I guess that the Nvidia GPU is being started through the sound system particularly some generic probe on the HDMI port ?
dmesg | grep -i nvidia
[ 3.196769] input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input12
[ 3.196840] input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input13
[ 3.196903] input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input14
[ 3.196966] input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input15
[ 4.911685] audit: type=1400 audit(1643957345.735:5): apparmor="STATUS" operation="profile_load" profile="unconfined" name="nvidia_modprobe" pid=854 comm="apparmor_parser"
[ 4.911694] audit: type=1400 audit(1643957345.735:6): apparmor="STATUS" operation="profile_load" profile="unconfined" name="nvidia_modprobe//kmod" pid=854 comm="apparmor_parser"

mate-optimus or nvidia-prime packages generate a module blacklist file to prevent nvidia graphics from starting:

This file was generated by nvidia-prime

blacklist nvidia
blacklist nvidia-drm
blacklist nvidia-modeset
alias nvidia off
alias nvidia-drm off
alias nvidia-modeset off

Try to use udev to disable dynamic discovery and use of nvidia

Use lspci | grep -i nvidia
cat >/etc/udev/rules.d/10-remove-nvidia-audio.rules
ACTION=="add", KERNEL=="0000:01:00.1", SUBSYSTEM=="pci", RUN+="/bin/sh -c 'echo 1 > /sys/bus/pci/devices/0000:01:00.1/remove'"
cat >/etc/udev/rules.d/10-remove-nvidia-video.rules
ACTION=="add", KERNEL=="0000:01:00.1", SUBSYSTEM=="pci", RUN+="/bin/sh -c 'echo 1 > /sys/bus/pci/devices/0000:01:00.0/remove'"
update-initramfs -u

Also learned a little from a nice French ALSA page explaining that the so called intel_hda sound card has nothing to do with having an actual Intel microprocessor: it is actually an intel standard that has been copied, implemented and extended by many manufacturers so they are all actually different! Something can go wrong with your ALSA driver of a built-in audio chip with any kernel update so forcing ALSA and Pulse Audio back onto using Nvidia even though it is alsa soundcard number 2, not default. Some intel_hda standard chips can be woken and restarted with cheat code options in the alsa configuration file. For example:
vi /etc/modprobe.d/alsa-base.conf
options snd-hda-intel model=hp power_save=0 power_save_controller=N

The codename for the old AC97 sound standard replacement is Azalia or intel_hd_audio
There is a man page in English:
and nice site with data in French:
and a wiki index of cards:

There is a rumour that pulse relies on ALSA which can sometimes call back to pulse !