aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000
diff options
context:
space:
mode:
authorTaku Izumi <izumi.taku@jp.fugitsu.com>2008-07-11 18:17:44 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-07-22 19:39:14 -0400
commit81250297d85b26eb4e9de5decf752dce430277f9 (patch)
treedf3783c21e01c35d3d0666533e731990c34cc8ea /drivers/net/e1000
parentc3570acb53c885f8accb8c85eda195781d30632f (diff)
e1000: make ioport free
This patch makes e1000 driver ioport-free. This corrects behavior in probe function so as not to request ioport resources as long as they are not really needed. This is based on the ioport-free patch of e1000 driver from Auke Kok and Tomohiro Kusumi. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@jp.fujitsu.com> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com> Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> Signed-off-by: Jeff Kirsher<jeffrey.t.kirsher@intel.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/e1000')
-rw-r--r--drivers/net/e1000/e1000.h4
-rw-r--r--drivers/net/e1000/e1000_main.c83
2 files changed, 74 insertions, 13 deletions
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 583b823f760c..19e317eaf5bc 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -340,6 +340,10 @@ struct e1000_adapter {
340 bool quad_port_a; 340 bool quad_port_a;
341 unsigned long flags; 341 unsigned long flags;
342 u32 eeprom_wol; 342 u32 eeprom_wol;
343
344 /* for ioport free */
345 int bars;
346 int need_ioport;
343}; 347};
344 348
345enum e1000_state_t { 349enum e1000_state_t {
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 190352c6216e..ad6da7b67e55 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -859,6 +859,42 @@ static void e1000_dump_eeprom(struct e1000_adapter *adapter)
859} 859}
860 860
861/** 861/**
862 * e1000_is_need_ioport - determine if an adapter needs ioport resources or not
863 * @pdev: PCI device information struct
864 *
865 * Return true if an adapter needs ioport resources
866 **/
867static int e1000_is_need_ioport(struct pci_dev *pdev)
868{
869 switch (pdev->device) {
870 case E1000_DEV_ID_82540EM:
871 case E1000_DEV_ID_82540EM_LOM:
872 case E1000_DEV_ID_82540EP:
873 case E1000_DEV_ID_82540EP_LOM:
874 case E1000_DEV_ID_82540EP_LP:
875 case E1000_DEV_ID_82541EI:
876 case E1000_DEV_ID_82541EI_MOBILE:
877 case E1000_DEV_ID_82541ER:
878 case E1000_DEV_ID_82541ER_LOM:
879 case E1000_DEV_ID_82541GI:
880 case E1000_DEV_ID_82541GI_LF:
881 case E1000_DEV_ID_82541GI_MOBILE:
882 case E1000_DEV_ID_82544EI_COPPER:
883 case E1000_DEV_ID_82544EI_FIBER:
884 case E1000_DEV_ID_82544GC_COPPER:
885 case E1000_DEV_ID_82544GC_LOM:
886 case E1000_DEV_ID_82545EM_COPPER:
887 case E1000_DEV_ID_82545EM_FIBER:
888 case E1000_DEV_ID_82546EB_COPPER:
889 case E1000_DEV_ID_82546EB_FIBER:
890 case E1000_DEV_ID_82546EB_QUAD_COPPER:
891 return true;
892 default:
893 return false;
894 }
895}
896
897/**
862 * e1000_probe - Device Initialization Routine 898 * e1000_probe - Device Initialization Routine
863 * @pdev: PCI device information struct 899 * @pdev: PCI device information struct
864 * @ent: entry in e1000_pci_tbl 900 * @ent: entry in e1000_pci_tbl
@@ -869,7 +905,6 @@ static void e1000_dump_eeprom(struct e1000_adapter *adapter)
869 * The OS initialization, configuring of the adapter private structure, 905 * The OS initialization, configuring of the adapter private structure,
870 * and a hardware reset occur. 906 * and a hardware reset occur.
871 **/ 907 **/
872
873static int __devinit e1000_probe(struct pci_dev *pdev, 908static int __devinit e1000_probe(struct pci_dev *pdev,
874 const struct pci_device_id *ent) 909 const struct pci_device_id *ent)
875{ 910{
@@ -882,9 +917,18 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
882 int i, err, pci_using_dac; 917 int i, err, pci_using_dac;
883 u16 eeprom_data = 0; 918 u16 eeprom_data = 0;
884 u16 eeprom_apme_mask = E1000_EEPROM_APME; 919 u16 eeprom_apme_mask = E1000_EEPROM_APME;
920 int bars, need_ioport;
885 DECLARE_MAC_BUF(mac); 921 DECLARE_MAC_BUF(mac);
886 922
887 err = pci_enable_device(pdev); 923 /* do not allocate ioport bars when not needed */
924 need_ioport = e1000_is_need_ioport(pdev);
925 if (need_ioport) {
926 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
927 err = pci_enable_device(pdev);
928 } else {
929 bars = pci_select_bars(pdev, IORESOURCE_MEM);
930 err = pci_enable_device(pdev);
931 }
888 if (err) 932 if (err)
889 return err; 933 return err;
890 934
@@ -904,7 +948,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
904 pci_using_dac = 0; 948 pci_using_dac = 0;
905 } 949 }
906 950
907 err = pci_request_regions(pdev, e1000_driver_name); 951 err = pci_request_selected_regions(pdev, bars, e1000_driver_name);
908 if (err) 952 if (err)
909 goto err_pci_reg; 953 goto err_pci_reg;
910 954
@@ -922,6 +966,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
922 adapter->netdev = netdev; 966 adapter->netdev = netdev;
923 adapter->pdev = pdev; 967 adapter->pdev = pdev;
924 adapter->msg_enable = (1 << debug) - 1; 968 adapter->msg_enable = (1 << debug) - 1;
969 adapter->bars = bars;
970 adapter->need_ioport = need_ioport;
925 971
926 hw = &adapter->hw; 972 hw = &adapter->hw;
927 hw->back = adapter; 973 hw->back = adapter;
@@ -932,12 +978,14 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
932 if (!hw->hw_addr) 978 if (!hw->hw_addr)
933 goto err_ioremap; 979 goto err_ioremap;
934 980
935 for (i = BAR_1; i <= BAR_5; i++) { 981 if (adapter->need_ioport) {
936 if (pci_resource_len(pdev, i) == 0) 982 for (i = BAR_1; i <= BAR_5; i++) {
937 continue; 983 if (pci_resource_len(pdev, i) == 0)
938 if (pci_resource_flags(pdev, i) & IORESOURCE_IO) { 984 continue;
939 hw->io_base = pci_resource_start(pdev, i); 985 if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
940 break; 986 hw->io_base = pci_resource_start(pdev, i);
987 break;
988 }
941 } 989 }
942 } 990 }
943 991
@@ -1202,7 +1250,7 @@ err_sw_init:
1202err_ioremap: 1250err_ioremap:
1203 free_netdev(netdev); 1251 free_netdev(netdev);
1204err_alloc_etherdev: 1252err_alloc_etherdev:
1205 pci_release_regions(pdev); 1253 pci_release_selected_regions(pdev, bars);
1206err_pci_reg: 1254err_pci_reg:
1207err_dma: 1255err_dma:
1208 pci_disable_device(pdev); 1256 pci_disable_device(pdev);
@@ -1249,7 +1297,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
1249 iounmap(hw->hw_addr); 1297 iounmap(hw->hw_addr);
1250 if (hw->flash_address) 1298 if (hw->flash_address)
1251 iounmap(hw->flash_address); 1299 iounmap(hw->flash_address);
1252 pci_release_regions(pdev); 1300 pci_release_selected_regions(pdev, adapter->bars);
1253 1301
1254 free_netdev(netdev); 1302 free_netdev(netdev);
1255 1303
@@ -5040,7 +5088,11 @@ static int e1000_resume(struct pci_dev *pdev)
5040 5088
5041 pci_set_power_state(pdev, PCI_D0); 5089 pci_set_power_state(pdev, PCI_D0);
5042 pci_restore_state(pdev); 5090 pci_restore_state(pdev);
5043 err = pci_enable_device(pdev); 5091
5092 if (adapter->need_ioport)
5093 err = pci_enable_device(pdev);
5094 else
5095 err = pci_enable_device_mem(pdev);
5044 if (err) { 5096 if (err) {
5045 printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n"); 5097 printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n");
5046 return err; 5098 return err;
@@ -5136,8 +5188,13 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
5136 struct net_device *netdev = pci_get_drvdata(pdev); 5188 struct net_device *netdev = pci_get_drvdata(pdev);
5137 struct e1000_adapter *adapter = netdev->priv; 5189 struct e1000_adapter *adapter = netdev->priv;
5138 struct e1000_hw *hw = &adapter->hw; 5190 struct e1000_hw *hw = &adapter->hw;
5191 int err;
5139 5192
5140 if (pci_enable_device(pdev)) { 5193 if (adapter->need_ioport)
5194 err = pci_enable_device(pdev);
5195 else
5196 err = pci_enable_device_mem(pdev);
5197 if (err) {
5141 printk(KERN_ERR "e1000: Cannot re-enable PCI device after reset.\n"); 5198 printk(KERN_ERR "e1000: Cannot re-enable PCI device after reset.\n");
5142 return PCI_ERS_RESULT_DISCONNECT; 5199 return PCI_ERS_RESULT_DISCONNECT;
5143 } 5200 }