aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/igb
diff options
context:
space:
mode:
authorTaku Izumi <izumi.taku@jp.fujitsu.com>2008-06-19 23:10:30 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-06-28 10:23:32 -0400
commit42bfd33ab7bce7d2abaa8bd968ae9ad0dc9a4771 (patch)
treec2f734a25d1d87eaea76d5bcbb59a21725264452 /drivers/net/igb
parent6e4f6f6b408cf3257c65cf4f3e299c098345b72f (diff)
igb: make ioport free
This patch makes igb driver ioport-free. This corrects behavior in probe function so as not to request ioport resources as long as they are not really needed. Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/igb')
-rw-r--r--drivers/net/igb/igb.h4
-rw-r--r--drivers/net/igb/igb_main.c47
2 files changed, 45 insertions, 6 deletions
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h
index 6b2e7d351d65..0eecb8b2abd2 100644
--- a/drivers/net/igb/igb.h
+++ b/drivers/net/igb/igb.h
@@ -271,6 +271,10 @@ struct igb_adapter {
271 unsigned int msi_enabled; 271 unsigned int msi_enabled;
272 272
273 u32 eeprom_wol; 273 u32 eeprom_wol;
274
275 /* for ioport free */
276 int bars;
277 int need_ioport;
274}; 278};
275 279
276enum e1000_state_t { 280enum e1000_state_t {
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 7b6b780dc8a6..e13b8db67b7c 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -820,6 +820,21 @@ void igb_reset(struct igb_adapter *adapter)
820} 820}
821 821
822/** 822/**
823 * igb_is_need_ioport - determine if an adapter needs ioport resources or not
824 * @pdev: PCI device information struct
825 *
826 * Returns true if an adapter needs ioport resources
827 **/
828static int igb_is_need_ioport(struct pci_dev *pdev)
829{
830 switch (pdev->device) {
831 /* Currently there are no adapters that need ioport resources */
832 default:
833 return false;
834 }
835}
836
837/**
823 * igb_probe - Device Initialization Routine 838 * igb_probe - Device Initialization Routine
824 * @pdev: PCI device information struct 839 * @pdev: PCI device information struct
825 * @ent: entry in igb_pci_tbl 840 * @ent: entry in igb_pci_tbl
@@ -843,8 +858,17 @@ static int __devinit igb_probe(struct pci_dev *pdev,
843 u16 eeprom_data = 0; 858 u16 eeprom_data = 0;
844 u16 eeprom_apme_mask = IGB_EEPROM_APME; 859 u16 eeprom_apme_mask = IGB_EEPROM_APME;
845 u32 part_num; 860 u32 part_num;
861 int bars, need_ioport;
846 862
847 err = pci_enable_device(pdev); 863 /* do not allocate ioport bars when not needed */
864 need_ioport = igb_is_need_ioport(pdev);
865 if (need_ioport) {
866 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
867 err = pci_enable_device(pdev);
868 } else {
869 bars = pci_select_bars(pdev, IORESOURCE_MEM);
870 err = pci_enable_device_mem(pdev);
871 }
848 if (err) 872 if (err)
849 return err; 873 return err;
850 874
@@ -866,7 +890,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
866 } 890 }
867 } 891 }
868 892
869 err = pci_request_regions(pdev, igb_driver_name); 893 err = pci_request_selected_regions(pdev, bars, igb_driver_name);
870 if (err) 894 if (err)
871 goto err_pci_reg; 895 goto err_pci_reg;
872 896
@@ -887,6 +911,8 @@ static int __devinit igb_probe(struct pci_dev *pdev,
887 hw = &adapter->hw; 911 hw = &adapter->hw;
888 hw->back = adapter; 912 hw->back = adapter;
889 adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE; 913 adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE;
914 adapter->bars = bars;
915 adapter->need_ioport = need_ioport;
890 916
891 mmio_start = pci_resource_start(pdev, 0); 917 mmio_start = pci_resource_start(pdev, 0);
892 mmio_len = pci_resource_len(pdev, 0); 918 mmio_len = pci_resource_len(pdev, 0);
@@ -1127,7 +1153,7 @@ err_hw_init:
1127err_ioremap: 1153err_ioremap:
1128 free_netdev(netdev); 1154 free_netdev(netdev);
1129err_alloc_etherdev: 1155err_alloc_etherdev:
1130 pci_release_regions(pdev); 1156 pci_release_selected_regions(pdev, bars);
1131err_pci_reg: 1157err_pci_reg:
1132err_dma: 1158err_dma:
1133 pci_disable_device(pdev); 1159 pci_disable_device(pdev);
@@ -1174,7 +1200,7 @@ static void __devexit igb_remove(struct pci_dev *pdev)
1174 iounmap(adapter->hw.hw_addr); 1200 iounmap(adapter->hw.hw_addr);
1175 if (adapter->hw.flash_address) 1201 if (adapter->hw.flash_address)
1176 iounmap(adapter->hw.flash_address); 1202 iounmap(adapter->hw.flash_address);
1177 pci_release_regions(pdev); 1203 pci_release_selected_regions(pdev, adapter->bars);
1178 1204
1179 free_netdev(netdev); 1205 free_netdev(netdev);
1180 1206
@@ -3975,7 +4001,11 @@ static int igb_resume(struct pci_dev *pdev)
3975 4001
3976 pci_set_power_state(pdev, PCI_D0); 4002 pci_set_power_state(pdev, PCI_D0);
3977 pci_restore_state(pdev); 4003 pci_restore_state(pdev);
3978 err = pci_enable_device(pdev); 4004
4005 if (adapter->need_ioport)
4006 err = pci_enable_device(pdev);
4007 else
4008 err = pci_enable_device_mem(pdev);
3979 if (err) { 4009 if (err) {
3980 dev_err(&pdev->dev, 4010 dev_err(&pdev->dev,
3981 "igb: Cannot enable PCI device from suspend\n"); 4011 "igb: Cannot enable PCI device from suspend\n");
@@ -4078,8 +4108,13 @@ static pci_ers_result_t igb_io_slot_reset(struct pci_dev *pdev)
4078 struct net_device *netdev = pci_get_drvdata(pdev); 4108 struct net_device *netdev = pci_get_drvdata(pdev);
4079 struct igb_adapter *adapter = netdev_priv(netdev); 4109 struct igb_adapter *adapter = netdev_priv(netdev);
4080 struct e1000_hw *hw = &adapter->hw; 4110 struct e1000_hw *hw = &adapter->hw;
4111 int err;
4081 4112
4082 if (pci_enable_device(pdev)) { 4113 if (adapter->need_ioport)
4114 err = pci_enable_device(pdev);
4115 else
4116 err = pci_enable_device_mem(pdev);
4117 if (err) {
4083 dev_err(&pdev->dev, 4118 dev_err(&pdev->dev,
4084 "Cannot re-enable PCI device after reset.\n"); 4119 "Cannot re-enable PCI device after reset.\n");
4085 return PCI_ERS_RESULT_DISCONNECT; 4120 return PCI_ERS_RESULT_DISCONNECT;