What is the difference between pci_enable_device_mem and pci_enable_device?
In ixgbe pf driver uses pci_enable_device_mem and vf driver uses pci_enable_device.
Well, both functions internally call pci_enable_device_flags(). The difference is that pci_enable_device_mem() variant initializes only Memory-mapped BARs, whereas pci_enable_device() will initialize both Memory-mapped and IO BARs.
If your PCI device does not have IO spaces (most probably this is indeed the case) you can easily use pci_enable_device_mem().
This is the code from drivers/pci/pci.c:
int pci_enable_device_mem(struct pci_dev *dev)
{
return pci_enable_device_flags(dev, IORESOURCE_MEM);
}
int pci_enable_device(struct pci_dev *dev)
{
return pci_enable_device_flags(dev, IORESOURCE_MEM | IORESOURCE_IO);
}
The first one is the initialize the device so it can be used with memory space. The second one will initialize a device before it is used by a driver.