aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e
diff options
context:
space:
mode:
authorTaku Izumi <izumi.taku@jp.fujitsu.com>2008-06-19 22:57:02 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-06-28 10:23:31 -0400
commit6e4f6f6b408cf3257c65cf4f3e299c098345b72f (patch)
tree49b8906590d7d695c17d251867fb9b2e741104d6 /drivers/net/e1000e
parentd03157babed7424f5391af43200593768ce69c9a (diff)
e1000e: make ioport free
This patch makes e1000e 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/e1000e')
-rw-r--r--drivers/net/e1000e/e1000.h4
-rw-r--r--drivers/net/e1000e/netdev.c48
2 files changed, 46 insertions, 6 deletions
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index d3bc6f8101fa..4a4f62e002b2 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -283,6 +283,10 @@ struct e1000_adapter {
283 unsigned long led_status; 283 unsigned long led_status;
284 284
285 unsigned int flags; 285 unsigned int flags;
286
287 /* for ioport free */
288 int bars;
289 int need_ioport;
286}; 290};
287 291
288struct e1000_info { 292struct e1000_info {
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index ccb8ca2cbb2b..22f2fc906354 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4002,7 +4002,11 @@ static int e1000_resume(struct pci_dev *pdev)
4002 pci_set_power_state(pdev, PCI_D0); 4002 pci_set_power_state(pdev, PCI_D0);
4003 pci_restore_state(pdev); 4003 pci_restore_state(pdev);
4004 e1000e_disable_l1aspm(pdev); 4004 e1000e_disable_l1aspm(pdev);
4005 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);
4006 if (err) { 4010 if (err) {
4007 dev_err(&pdev->dev, 4011 dev_err(&pdev->dev,
4008 "Cannot enable PCI device from suspend\n"); 4012 "Cannot enable PCI device from suspend\n");
@@ -4103,9 +4107,14 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4103 struct net_device *netdev = pci_get_drvdata(pdev); 4107 struct net_device *netdev = pci_get_drvdata(pdev);
4104 struct e1000_adapter *adapter = netdev_priv(netdev); 4108 struct e1000_adapter *adapter = netdev_priv(netdev);
4105 struct e1000_hw *hw = &adapter->hw; 4109 struct e1000_hw *hw = &adapter->hw;
4110 int err;
4106 4111
4107 e1000e_disable_l1aspm(pdev); 4112 e1000e_disable_l1aspm(pdev);
4108 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) {
4109 dev_err(&pdev->dev, 4118 dev_err(&pdev->dev,
4110 "Cannot re-enable PCI device after reset.\n"); 4119 "Cannot re-enable PCI device after reset.\n");
4111 return PCI_ERS_RESULT_DISCONNECT; 4120 return PCI_ERS_RESULT_DISCONNECT;
@@ -4184,6 +4193,21 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
4184} 4193}
4185 4194
4186/** 4195/**
4196 * e1000e_is_need_ioport - determine if an adapter needs ioport resources or not
4197 * @pdev: PCI device information struct
4198 *
4199 * Returns true if an adapters needs ioport resources
4200 **/
4201static int e1000e_is_need_ioport(struct pci_dev *pdev)
4202{
4203 switch (pdev->device) {
4204 /* Currently there are no adapters that need ioport resources */
4205 default:
4206 return false;
4207 }
4208}
4209
4210/**
4187 * e1000_probe - Device Initialization Routine 4211 * e1000_probe - Device Initialization Routine
4188 * @pdev: PCI device information struct 4212 * @pdev: PCI device information struct
4189 * @ent: entry in e1000_pci_tbl 4213 * @ent: entry in e1000_pci_tbl
@@ -4208,9 +4232,19 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4208 int i, err, pci_using_dac; 4232 int i, err, pci_using_dac;
4209 u16 eeprom_data = 0; 4233 u16 eeprom_data = 0;
4210 u16 eeprom_apme_mask = E1000_EEPROM_APME; 4234 u16 eeprom_apme_mask = E1000_EEPROM_APME;
4235 int bars, need_ioport;
4211 4236
4212 e1000e_disable_l1aspm(pdev); 4237 e1000e_disable_l1aspm(pdev);
4213 err = pci_enable_device(pdev); 4238
4239 /* do not allocate ioport bars when not needed */
4240 need_ioport = e1000e_is_need_ioport(pdev);
4241 if (need_ioport) {
4242 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
4243 err = pci_enable_device(pdev);
4244 } else {
4245 bars = pci_select_bars(pdev, IORESOURCE_MEM);
4246 err = pci_enable_device_mem(pdev);
4247 }
4214 if (err) 4248 if (err)
4215 return err; 4249 return err;
4216 4250
@@ -4233,7 +4267,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4233 } 4267 }
4234 } 4268 }
4235 4269
4236 err = pci_request_regions(pdev, e1000e_driver_name); 4270 err = pci_request_selected_regions(pdev, bars, e1000e_driver_name);
4237 if (err) 4271 if (err)
4238 goto err_pci_reg; 4272 goto err_pci_reg;
4239 4273
@@ -4258,6 +4292,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4258 adapter->hw.adapter = adapter; 4292 adapter->hw.adapter = adapter;
4259 adapter->hw.mac.type = ei->mac; 4293 adapter->hw.mac.type = ei->mac;
4260 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; 4294 adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
4295 adapter->bars = bars;
4296 adapter->need_ioport = need_ioport;
4261 4297
4262 mmio_start = pci_resource_start(pdev, 0); 4298 mmio_start = pci_resource_start(pdev, 0);
4263 mmio_len = pci_resource_len(pdev, 0); 4299 mmio_len = pci_resource_len(pdev, 0);
@@ -4497,7 +4533,7 @@ err_sw_init:
4497err_ioremap: 4533err_ioremap:
4498 free_netdev(netdev); 4534 free_netdev(netdev);
4499err_alloc_etherdev: 4535err_alloc_etherdev:
4500 pci_release_regions(pdev); 4536 pci_release_selected_regions(pdev, bars);
4501err_pci_reg: 4537err_pci_reg:
4502err_dma: 4538err_dma:
4503 pci_disable_device(pdev); 4539 pci_disable_device(pdev);
@@ -4545,7 +4581,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
4545 iounmap(adapter->hw.hw_addr); 4581 iounmap(adapter->hw.hw_addr);
4546 if (adapter->hw.flash_address) 4582 if (adapter->hw.flash_address)
4547 iounmap(adapter->hw.flash_address); 4583 iounmap(adapter->hw.flash_address);
4548 pci_release_regions(pdev); 4584 pci_release_selected_regions(pdev, adapter->bars);
4549 4585
4550 free_netdev(netdev); 4586 free_netdev(netdev);
4551 4587