diff options
author | David S. Miller <davem@davemloft.net> | 2008-06-29 00:28:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-06-29 00:28:46 -0400 |
commit | 332e4af80d1214fbf0e263e1408fc7c5b64ecdd6 (patch) | |
tree | 7c8f8ada7ab8fc9cb2497d95e52dce4d2c4493a3 /drivers/net/igb | |
parent | 1b63ba8a86c85524a8d7e5953b314ce71ebcb9c9 (diff) | |
parent | be0976be9148f31ee0d1997354c3e30ff8d07587 (diff) |
Merge branch 'davem-next' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6
Diffstat (limited to 'drivers/net/igb')
-rw-r--r-- | drivers/net/igb/igb.h | 4 | ||||
-rw-r--r-- | drivers/net/igb/igb_main.c | 47 |
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 | ||
276 | enum e1000_state_t { | 280 | enum e1000_state_t { |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index 6f1ad5368ae5..171d1fc1fbf8 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -821,6 +821,21 @@ void igb_reset(struct igb_adapter *adapter) | |||
821 | } | 821 | } |
822 | 822 | ||
823 | /** | 823 | /** |
824 | * igb_is_need_ioport - determine if an adapter needs ioport resources or not | ||
825 | * @pdev: PCI device information struct | ||
826 | * | ||
827 | * Returns true if an adapter needs ioport resources | ||
828 | **/ | ||
829 | static int igb_is_need_ioport(struct pci_dev *pdev) | ||
830 | { | ||
831 | switch (pdev->device) { | ||
832 | /* Currently there are no adapters that need ioport resources */ | ||
833 | default: | ||
834 | return false; | ||
835 | } | ||
836 | } | ||
837 | |||
838 | /** | ||
824 | * igb_probe - Device Initialization Routine | 839 | * igb_probe - Device Initialization Routine |
825 | * @pdev: PCI device information struct | 840 | * @pdev: PCI device information struct |
826 | * @ent: entry in igb_pci_tbl | 841 | * @ent: entry in igb_pci_tbl |
@@ -844,8 +859,17 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
844 | u16 eeprom_data = 0; | 859 | u16 eeprom_data = 0; |
845 | u16 eeprom_apme_mask = IGB_EEPROM_APME; | 860 | u16 eeprom_apme_mask = IGB_EEPROM_APME; |
846 | u32 part_num; | 861 | u32 part_num; |
862 | int bars, need_ioport; | ||
847 | 863 | ||
848 | err = pci_enable_device(pdev); | 864 | /* do not allocate ioport bars when not needed */ |
865 | need_ioport = igb_is_need_ioport(pdev); | ||
866 | if (need_ioport) { | ||
867 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); | ||
868 | err = pci_enable_device(pdev); | ||
869 | } else { | ||
870 | bars = pci_select_bars(pdev, IORESOURCE_MEM); | ||
871 | err = pci_enable_device_mem(pdev); | ||
872 | } | ||
849 | if (err) | 873 | if (err) |
850 | return err; | 874 | return err; |
851 | 875 | ||
@@ -867,7 +891,7 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
867 | } | 891 | } |
868 | } | 892 | } |
869 | 893 | ||
870 | err = pci_request_regions(pdev, igb_driver_name); | 894 | err = pci_request_selected_regions(pdev, bars, igb_driver_name); |
871 | if (err) | 895 | if (err) |
872 | goto err_pci_reg; | 896 | goto err_pci_reg; |
873 | 897 | ||
@@ -888,6 +912,8 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
888 | hw = &adapter->hw; | 912 | hw = &adapter->hw; |
889 | hw->back = adapter; | 913 | hw->back = adapter; |
890 | adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE; | 914 | adapter->msg_enable = NETIF_MSG_DRV | NETIF_MSG_PROBE; |
915 | adapter->bars = bars; | ||
916 | adapter->need_ioport = need_ioport; | ||
891 | 917 | ||
892 | mmio_start = pci_resource_start(pdev, 0); | 918 | mmio_start = pci_resource_start(pdev, 0); |
893 | mmio_len = pci_resource_len(pdev, 0); | 919 | mmio_len = pci_resource_len(pdev, 0); |
@@ -1128,7 +1154,7 @@ err_hw_init: | |||
1128 | err_ioremap: | 1154 | err_ioremap: |
1129 | free_netdev(netdev); | 1155 | free_netdev(netdev); |
1130 | err_alloc_etherdev: | 1156 | err_alloc_etherdev: |
1131 | pci_release_regions(pdev); | 1157 | pci_release_selected_regions(pdev, bars); |
1132 | err_pci_reg: | 1158 | err_pci_reg: |
1133 | err_dma: | 1159 | err_dma: |
1134 | pci_disable_device(pdev); | 1160 | pci_disable_device(pdev); |
@@ -1175,7 +1201,7 @@ static void __devexit igb_remove(struct pci_dev *pdev) | |||
1175 | iounmap(adapter->hw.hw_addr); | 1201 | iounmap(adapter->hw.hw_addr); |
1176 | if (adapter->hw.flash_address) | 1202 | if (adapter->hw.flash_address) |
1177 | iounmap(adapter->hw.flash_address); | 1203 | iounmap(adapter->hw.flash_address); |
1178 | pci_release_regions(pdev); | 1204 | pci_release_selected_regions(pdev, adapter->bars); |
1179 | 1205 | ||
1180 | free_netdev(netdev); | 1206 | free_netdev(netdev); |
1181 | 1207 | ||
@@ -3976,7 +4002,11 @@ static int igb_resume(struct pci_dev *pdev) | |||
3976 | 4002 | ||
3977 | pci_set_power_state(pdev, PCI_D0); | 4003 | pci_set_power_state(pdev, PCI_D0); |
3978 | pci_restore_state(pdev); | 4004 | pci_restore_state(pdev); |
3979 | err = pci_enable_device(pdev); | 4005 | |
4006 | if (adapter->need_ioport) | ||
4007 | err = pci_enable_device(pdev); | ||
4008 | else | ||
4009 | err = pci_enable_device_mem(pdev); | ||
3980 | if (err) { | 4010 | if (err) { |
3981 | dev_err(&pdev->dev, | 4011 | dev_err(&pdev->dev, |
3982 | "igb: Cannot enable PCI device from suspend\n"); | 4012 | "igb: Cannot enable PCI device from suspend\n"); |
@@ -4079,8 +4109,13 @@ static pci_ers_result_t igb_io_slot_reset(struct pci_dev *pdev) | |||
4079 | struct net_device *netdev = pci_get_drvdata(pdev); | 4109 | struct net_device *netdev = pci_get_drvdata(pdev); |
4080 | struct igb_adapter *adapter = netdev_priv(netdev); | 4110 | struct igb_adapter *adapter = netdev_priv(netdev); |
4081 | struct e1000_hw *hw = &adapter->hw; | 4111 | struct e1000_hw *hw = &adapter->hw; |
4112 | int err; | ||
4082 | 4113 | ||
4083 | if (pci_enable_device(pdev)) { | 4114 | if (adapter->need_ioport) |
4115 | err = pci_enable_device(pdev); | ||
4116 | else | ||
4117 | err = pci_enable_device_mem(pdev); | ||
4118 | if (err) { | ||
4084 | dev_err(&pdev->dev, | 4119 | dev_err(&pdev->dev, |
4085 | "Cannot re-enable PCI device after reset.\n"); | 4120 | "Cannot re-enable PCI device after reset.\n"); |
4086 | return PCI_ERS_RESULT_DISCONNECT; | 4121 | return PCI_ERS_RESULT_DISCONNECT; |