Hi Kevin, On Sun, Sep 30, 2018 at 12:15:01PM +0300, Kevin Wilson wrote: > HI, linux-pci developers, > > There are very few Ethernet drivers which use > pcim_iomap_regions(); for example, > drivers/net/ethernet/realtek/r8169.c. > > My question is: why do they use this > Managed Device Resource API and not > the regular Device Resource API (ioremap() for example), which is used in > **most** Ethernet Linux device drivers, for example, in I40E driver: > > ... > err = pci_request_mem_regions(pdev, i40e_driver_name); > ... > hw->hw_addr = ioremap(pci_resource_start(pdev, 0), pf->ioremap_len); > ... > > Is there some inherent HW feature in r8169 (or the other > drivers, see list below) which requires using this API ? Is usage > of this API (the managed devices, with pcim_iomap_regions(), etc) is > mandatory for these device drivers, and cannot be > use in most drivers (like I40E and most of the others) ? > > The other Linux Ethenet drivers that use > pcim_iomap_regions() are: > amd/xgbe, cavium/common/cavium_ptp.c, intel/ice/ice_main.c, > oki-semi/pch_gbe/pch_gbe_main.c, stmicro/stmmac/stmmac_pci.c, > synopsys/dwc-xlgmac-pci.c and toshiba/tc35815.c. The choice of the managed API (pcim_iomap_regions(), etc) vs the regular one (ioremap()) has nothing to do with the features of the hardware. It's completely up to the driver writer. The managed API [1] is intended to make things easier for the driver writer by simplifying error and cleanup paths. Bjorn [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-model/devres.txt