Commit 6e4f6f6b authored by Taku Izumi's avatar Taku Izumi Committed by Jeff Garzik

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: default avatarTaku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent d03157ba
...@@ -283,6 +283,10 @@ struct e1000_adapter { ...@@ -283,6 +283,10 @@ struct e1000_adapter {
unsigned long led_status; unsigned long led_status;
unsigned int flags; unsigned int flags;
/* for ioport free */
int bars;
int need_ioport;
}; };
struct e1000_info { struct e1000_info {
......
...@@ -4002,7 +4002,11 @@ static int e1000_resume(struct pci_dev *pdev) ...@@ -4002,7 +4002,11 @@ static int e1000_resume(struct pci_dev *pdev)
pci_set_power_state(pdev, PCI_D0); pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev); pci_restore_state(pdev);
e1000e_disable_l1aspm(pdev); e1000e_disable_l1aspm(pdev);
err = pci_enable_device(pdev);
if (adapter->need_ioport)
err = pci_enable_device(pdev);
else
err = pci_enable_device_mem(pdev);
if (err) { if (err) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Cannot enable PCI device from suspend\n"); "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,9 +4107,14 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
struct net_device *netdev = pci_get_drvdata(pdev); struct net_device *netdev = pci_get_drvdata(pdev);
struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
int err;
e1000e_disable_l1aspm(pdev); e1000e_disable_l1aspm(pdev);
if (pci_enable_device(pdev)) { if (adapter->need_ioport)
err = pci_enable_device(pdev);
else
err = pci_enable_device_mem(pdev);
if (err) {
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Cannot re-enable PCI device after reset.\n"); "Cannot re-enable PCI device after reset.\n");
return PCI_ERS_RESULT_DISCONNECT; return PCI_ERS_RESULT_DISCONNECT;
...@@ -4183,6 +4192,21 @@ static void e1000_print_device_info(struct e1000_adapter *adapter) ...@@ -4183,6 +4192,21 @@ static void e1000_print_device_info(struct e1000_adapter *adapter)
(pba_num >> 8), (pba_num & 0xff)); (pba_num >> 8), (pba_num & 0xff));
} }
/**
* e1000e_is_need_ioport - determine if an adapter needs ioport resources or not
* @pdev: PCI device information struct
*
* Returns true if an adapters needs ioport resources
**/
static int e1000e_is_need_ioport(struct pci_dev *pdev)
{
switch (pdev->device) {
/* Currently there are no adapters that need ioport resources */
default:
return false;
}
}
/** /**
* e1000_probe - Device Initialization Routine * e1000_probe - Device Initialization Routine
* @pdev: PCI device information struct * @pdev: PCI device information struct
...@@ -4208,9 +4232,19 @@ static int __devinit e1000_probe(struct pci_dev *pdev, ...@@ -4208,9 +4232,19 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
int i, err, pci_using_dac; int i, err, pci_using_dac;
u16 eeprom_data = 0; u16 eeprom_data = 0;
u16 eeprom_apme_mask = E1000_EEPROM_APME; u16 eeprom_apme_mask = E1000_EEPROM_APME;
int bars, need_ioport;
e1000e_disable_l1aspm(pdev); e1000e_disable_l1aspm(pdev);
err = pci_enable_device(pdev);
/* do not allocate ioport bars when not needed */
need_ioport = e1000e_is_need_ioport(pdev);
if (need_ioport) {
bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
err = pci_enable_device(pdev);
} else {
bars = pci_select_bars(pdev, IORESOURCE_MEM);
err = pci_enable_device_mem(pdev);
}
if (err) if (err)
return err; return err;
...@@ -4233,7 +4267,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, ...@@ -4233,7 +4267,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
} }
} }
err = pci_request_regions(pdev, e1000e_driver_name); err = pci_request_selected_regions(pdev, bars, e1000e_driver_name);
if (err) if (err)
goto err_pci_reg; goto err_pci_reg;
...@@ -4258,6 +4292,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev, ...@@ -4258,6 +4292,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
adapter->hw.adapter = adapter; adapter->hw.adapter = adapter;
adapter->hw.mac.type = ei->mac; adapter->hw.mac.type = ei->mac;
adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1; adapter->msg_enable = (1 << NETIF_MSG_DRV | NETIF_MSG_PROBE) - 1;
adapter->bars = bars;
adapter->need_ioport = need_ioport;
mmio_start = pci_resource_start(pdev, 0); mmio_start = pci_resource_start(pdev, 0);
mmio_len = pci_resource_len(pdev, 0); mmio_len = pci_resource_len(pdev, 0);
...@@ -4497,7 +4533,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev, ...@@ -4497,7 +4533,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
err_ioremap: err_ioremap:
free_netdev(netdev); free_netdev(netdev);
err_alloc_etherdev: err_alloc_etherdev:
pci_release_regions(pdev); pci_release_selected_regions(pdev, bars);
err_pci_reg: err_pci_reg:
err_dma: err_dma:
pci_disable_device(pdev); pci_disable_device(pdev);
...@@ -4545,7 +4581,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev) ...@@ -4545,7 +4581,7 @@ static void __devexit e1000_remove(struct pci_dev *pdev)
iounmap(adapter->hw.hw_addr); iounmap(adapter->hw.hw_addr);
if (adapter->hw.flash_address) if (adapter->hw.flash_address)
iounmap(adapter->hw.flash_address); iounmap(adapter->hw.flash_address);
pci_release_regions(pdev); pci_release_selected_regions(pdev, adapter->bars);
free_netdev(netdev); free_netdev(netdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment