# Disable PCI-E device

## Belliash

Hello,

Could you tell me how an I completely turn off a PCI-E device and turn it on again?

I have mostly unused device that I would like to turn off to save energy and turn it on only when I need it. Can this be done via ACPI? I found acpi_call, but I cannot find a way to use it with my card. Seems its dedicated to use with DGPU on laptops, or at least I have not found other commands or the way to get a list of available commands...

----------

## mike155

Does this help? https://stackoverflow.com/questions/4117465/can-i-completely-disable-a-pci-slot-in-linux

----------

## Anon-E-moose

You can "disable" the device, as far as linux is concerned,

----------

## Ant P.

If you build the driver as a kernel module and then unload it, it should automatically put the device into power saving mode.

----------

## Belliash

 *Ant P. wrote:*   

> If you build the driver as a kernel module and then unload it, it should automatically put the device into power saving mode.

 

How can I check if device is in power saving mode?

----------

## mike155

 *Anon-E-moose wrote:*   

> You can "disable" the device, as far as linux is concerned,

 

Is there a generic way to disable any arbitrary device on the PCI bus?

 *Ant. P wrote:*   

> If you build the driver as a kernel module and then unload it, it should automatically put the device into power saving mode.

 

Is that true?

I ask, because I have a notebook with an nVidia graphics controller. I don't need the nVidia graphics controller and I don't want it. I use bbswitch to disable it. As soon as I run bbswitch to turn the nVidia graphics controller off, power consumption of my notebook goes down by 4 Watts, which is more than welcome. 

But it's not sufficient to 'not load' or to 'unload' the Nvidia graphics module to reach this low power consumption state. I really have to turn the nVidia graphics controller off using bbswitch.

----------

## Anon-E-moose

 *mike155 wrote:*   

>  *Anon-E-moose wrote:*   You can "disable" the device, as far as linux is concerned, 
> 
> Is there a generic way to disable an arbitary device on the PCI bus?
> 
> 

 

It depends on the device, you'd have to look in /sys find the device and see if there's an entry for it to manipulate, could be called disable or enable or something else. Naming between devices is not consistent.

----------

## Ant P.

 *Belliash wrote:*   

>  *Ant P. wrote:*   If you build the driver as a kernel module and then unload it, it should automatically put the device into power saving mode. 
> 
> How can I check if device is in power saving mode?

 

It'll usually print something in dmesg about disconnecting the PCIe device. It's possible it might not, depends entirely on the driver to implement it correctly.

----------

## bunder

afaik you can also disable pcie slots in the efi/bios, if your bios isn't completely stripped down (like on some laptops)

----------

## DaggyStyle

you can try via sysfs, see:

```

dagg@NCC-5001D ~ $ ll /sys/devices/pci0000\:00/0000\:00\:03.0/enable 

-rw-r--r-- 1 root root 4096 Jul 27 11:20 /sys/devices/pci0000:00/0000:00:03.0/enable

dagg@NCC-5001D ~ $ lspci | grep 03:00.0

03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 16)

```

just run echo 0 > /sys/devices/pci0000\:00/0000\:00\:03.0/enable

----------

