使用 udev 禁用 PCI 声卡

使用 udev 禁用 PCI 声卡

GP104 高清音频控制器这似乎是使用 HDMI 的 NVidia GeForce GTX 1070 中的内置声卡。它不断出现在各种应用程序中,有时会干扰音频设置。我想用乌德夫如果可能的话。

% lspci -vvvvvvvvv -d 10de:10f0:

01:00.1 Audio device: NVIDIA Corporation GP104 High Definition Audio Controller (rev a1)
        Subsystem: ASUSTeK Computer Inc. Device 8599
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0, Cache Line Size: 64 bytes
        Interrupt: pin B routed to IRQ 17
        Region 0: Memory at c4080000 (32-bit, non-prefetchable) [size=16K]
        Capabilities: [60] Power Management version 3
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
                Address: 0000000000000000  Data: 0000
        Capabilities: [78] Express (v2) Endpoint, MSI 00
                DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s unlimited, L1 <64us
                        ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 75W
                DevCtl: CorrErr+ NonFatalErr+ FatalErr+ UnsupReq+
                        RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop+
                        MaxPayload 256 bytes, MaxReadReq 512 bytes
                DevSta: CorrErr+ NonFatalErr- FatalErr- UnsupReq+ AuxPwr- TransPend-
                LnkCap: Port #0, Speed 8GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <512ns, L1 <4us
                        ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
                LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk+
                        ExtSynch- ClockPM+ AutWidDis- BWInt- AutBWInt-
                LnkSta: Speed 2.5GT/s (downgraded), Width x16
                        TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
                DevCap2: Completion Timeout: Range AB, TimeoutDis+ NROPrPrP- LTR+
                         10BitTagComp- 10BitTagReq- OBFF Via message, ExtFmt- EETLPPrefix-
                         EmergencyPowerReduction Not Supported, EmergencyPowerReductionInit-
                         FRS- TPHComp- ExtTPHComp-
                         AtomicOpsCap: 32bit- 64bit- 128bitCAS-
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- LTR- 10BitTagReq- OBFF Disabled,
                         AtomicOpsCtl: ReqEn-
                LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete- EqualizationPhase1-
                         EqualizationPhase2- EqualizationPhase3- LinkEqualizationRequest-
                         Retimer- 2Retimers- CrosslinkRes: unsupported
        Capabilities: [100 v2] Advanced Error Reporting
                UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
                CESta:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr-
                CEMsk:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr+
                AERCap: First Error Pointer: 00, ECRCGenCap- ECRCGenEn- ECRCChkCap- ECRCChkEn-
                        MultHdrRecCap- MultHdrRecEn- TLPPfxPres- HdrLogCap-
                HeaderLog: 00000000 00000000 00000000 00000000
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel

% udevadm info -a /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1:

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1':
    KERNEL=="card1"
    SUBSYSTEM=="sound"
    DRIVER==""
    ATTR{id}=="NVidia"
    ATTR{number}=="1"
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:01.0/0000:01:00.1':
    KERNELS=="0000:01:00.1"
    SUBSYSTEMS=="pci"
    DRIVERS=="snd_hda_intel"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x040300"
    ATTRS{consistent_dma_mask_bits}=="40"
    ATTRS{current_link_speed}=="2.5 GT/s PCIe"
    ATTRS{current_link_width}=="16"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x10f0"
    ATTRS{dma_mask_bits}=="40"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="17"
    ATTRS{link/clkpm}=="1"
    ATTRS{local_cpulist}=="0-15"
    ATTRS{local_cpus}=="ffff"
    ATTRS{max_link_speed}=="8.0 GT/s PCIe"
    ATTRS{max_link_width}=="16"
    ATTRS{msi_bus}=="1"
    ATTRS{numa_node}=="-1"
    ATTRS{power/autosuspend_delay_ms}=="0"
    ATTRS{power/control}=="on"
    ATTRS{power/runtime_active_time}=="707756"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="2820"
    ATTRS{power/wakeup}=="disabled"
    ATTRS{power/wakeup_abort_count}==""
    ATTRS{power/wakeup_active}==""
    ATTRS{power/wakeup_active_count}==""
    ATTRS{power/wakeup_count}==""
    ATTRS{power/wakeup_expire_count}==""
    ATTRS{power/wakeup_last_time_ms}==""
    ATTRS{power/wakeup_max_time_ms}==""
    ATTRS{power/wakeup_total_time_ms}==""
    ATTRS{power_state}=="D0"
    ATTRS{remove}=="(not readable)"
    ATTRS{rescan}=="(not readable)"
    ATTRS{revision}=="0xa1"
    ATTRS{subsystem_device}=="0x8599"
    ATTRS{subsystem_vendor}=="0x1043"
    ATTRS{vendor}=="0x10de"

  looking at parent device '/devices/pci0000:00/0000:00:01.0':
    KERNELS=="0000:00:01.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="pcieport"
    ATTRS{aer_rootport_total_err_cor}=="0"
    ATTRS{aer_rootport_total_err_fatal}=="0"
    ATTRS{aer_rootport_total_err_nonfatal}=="0"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x060400"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{current_link_speed}=="2.5 GT/s PCIe"
    ATTRS{current_link_width}=="16"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x4c01"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="121"
    ATTRS{local_cpulist}=="0-15"
    ATTRS{local_cpus}=="ffff"
    ATTRS{max_link_speed}=="16.0 GT/s PCIe"
    ATTRS{max_link_width}=="16"
    ATTRS{msi_bus}=="1"
    ATTRS{msi_irqs/121}=="msi"
    ATTRS{numa_node}=="-1"
    ATTRS{power/autosuspend_delay_ms}=="100"
    ATTRS{power/control}=="on"
    ATTRS{power/runtime_active_time}=="710587"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{power/wakeup}=="enabled"
    ATTRS{power/wakeup_abort_count}=="0"
    ATTRS{power/wakeup_active}=="0"
    ATTRS{power/wakeup_active_count}=="0"
    ATTRS{power/wakeup_count}=="0"
    ATTRS{power/wakeup_expire_count}=="0"
    ATTRS{power/wakeup_last_time_ms}=="0"
    ATTRS{power/wakeup_max_time_ms}=="0"
    ATTRS{power/wakeup_total_time_ms}=="0"
    ATTRS{power_state}=="D0"
    ATTRS{remove}=="(not readable)"
    ATTRS{rescan}=="(not readable)"
    ATTRS{reset}=="(not readable)"
    ATTRS{reset_method}=="pm"
    ATTRS{revision}=="0x01"
    ATTRS{secondary_bus_number}=="1"
    ATTRS{subordinate_bus_number}=="1"
    ATTRS{subsystem_device}=="0x8694"
    ATTRS{subsystem_vendor}=="0x1043"
    ATTRS{vendor}=="0x8086"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{waiting_for_supplier}=="0"

我目前的尝试没有成功:

% cat /etc/udev/rules.d/70-nvidia-hdmi.rules:

# Disable NVidia (vendor = 10de) GP104 HDMI audio (device = 10f0)
ACTION=="add", SUBSYSTEM=="sound", ATTRS{vendor}=="10de", ATTRS{device}=="10f0" \
, RUN+="/bin/sh -c 'echo 0 > /sys/\$devpath/authorized'"

内核是 Linux 6.2.0-1-MANJARO #1 SMP PREEMPT_DYNAMIC 2 月 13 日星期一 11:56:21 UTC 2023 x86_64 GNU/Linux

systemd 252 (252.5-1-manjaro)

答案1

这终于奏效了。ATTRS{vendor}并且ATTRS{device}需要0x前缀并且remove需要被调用而不是authorized.基本上,该规则表示“设备已添加,因此请立即将其删除”。

/etc/udev/rules.d/70-nvidia-hdmi.rules:

# Disable NVidia (vendor = 0x10de) GP104 HDMI audio (device = 0x10f0)
ACTION=="add", SUBSYSTEM=="sound", ATTRS{vendor}=="0x10de", ATTRS{device}=="0x10f0" \
, RUN:="/bin/sh -c 'echo 1 > $sys$devpath/device/remove'"

相关内容