Skip to content

Commit

Permalink
myri10ge: no need to save MSI and PCIe state in the driver
Browse files Browse the repository at this point in the history
The PCI MSI and express state are already saved and restored by the
current versions of pci_save_state/pci_restore_state.
Therefore it is no longer necessary for the driver to do it.

Signed-off-by: Brice Goglin <[email protected]>
Signed-off-by: Stephen Hemminger <[email protected]>
Signed-off-by: Jeff Garzik <[email protected]>
  • Loading branch information
Brice Goglin authored and Jeff Garzik committed Dec 26, 2006
1 parent 3621cec commit 83f6e15
Showing 1 changed file with 9 additions and 38 deletions.
47 changes: 9 additions & 38 deletions drivers/net/myri10ge/myri10ge.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ struct myri10ge_priv {
unsigned long serial_number;
int vendor_specific_offset;
int fw_multicast_support;
u32 devctl;
u16 msi_flags;
u32 read_dma;
u32 write_dma;
u32 read_write_dma;
Expand Down Expand Up @@ -2520,34 +2518,6 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
}
}

static void myri10ge_save_state(struct myri10ge_priv *mgp)
{
struct pci_dev *pdev = mgp->pdev;
int cap;

pci_save_state(pdev);
/* now save PCIe and MSI state that Linux will not
* save for us */
cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
pci_read_config_dword(pdev, cap + PCI_EXP_DEVCTL, &mgp->devctl);
cap = pci_find_capability(pdev, PCI_CAP_ID_MSI);
pci_read_config_word(pdev, cap + PCI_MSI_FLAGS, &mgp->msi_flags);
}

static void myri10ge_restore_state(struct myri10ge_priv *mgp)
{
struct pci_dev *pdev = mgp->pdev;
int cap;

/* restore PCIe and MSI state that linux will not */
cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
pci_write_config_dword(pdev, cap + PCI_CAP_ID_EXP, mgp->devctl);
cap = pci_find_capability(pdev, PCI_CAP_ID_MSI);
pci_write_config_word(pdev, cap + PCI_MSI_FLAGS, mgp->msi_flags);

pci_restore_state(pdev);
}

#ifdef CONFIG_PM

static int myri10ge_suspend(struct pci_dev *pdev, pm_message_t state)
Expand All @@ -2568,7 +2538,7 @@ static int myri10ge_suspend(struct pci_dev *pdev, pm_message_t state)
rtnl_unlock();
}
myri10ge_dummy_rdma(mgp, 0);
myri10ge_save_state(mgp);
pci_save_state(pdev);
pci_disable_device(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
return 0;
Expand All @@ -2593,7 +2563,8 @@ static int myri10ge_resume(struct pci_dev *pdev)
mgp->dev->name);
return -EIO;
}
myri10ge_restore_state(mgp);

pci_restore_state(pdev);

status = pci_enable_device(pdev);
if (status < 0) {
Expand All @@ -2608,7 +2579,7 @@ static int myri10ge_resume(struct pci_dev *pdev)

/* Save configuration space to be restored if the
* nic resets due to a parity error */
myri10ge_save_state(mgp);
pci_save_state(pdev);

if (netif_running(netdev)) {
rtnl_lock();
Expand Down Expand Up @@ -2674,10 +2645,10 @@ static void myri10ge_watchdog(struct work_struct *work)
* when the driver was loaded, or the last time the
* nic was resumed from power saving mode.
*/
myri10ge_restore_state(mgp);
pci_restore_state(mgp->pdev);

/* save state again for accounting reasons */
myri10ge_save_state(mgp);
pci_save_state(mgp->pdev);

} else {
/* if we get back -1's from our slot, perhaps somebody
Expand Down Expand Up @@ -2917,7 +2888,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

/* Save configuration space to be restored if the
* nic resets due to a parity error */
myri10ge_save_state(mgp);
pci_save_state(pdev);

/* Setup the watchdog timer */
setup_timer(&mgp->watchdog_timer, myri10ge_watchdog_timer,
Expand All @@ -2937,7 +2908,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return 0;

abort_with_state:
myri10ge_restore_state(mgp);
pci_restore_state(pdev);

abort_with_firmware:
myri10ge_dummy_rdma(mgp, 0);
Expand Down Expand Up @@ -2992,7 +2963,7 @@ static void myri10ge_remove(struct pci_dev *pdev)
myri10ge_dummy_rdma(mgp, 0);

/* avoid a memory leak */
myri10ge_restore_state(mgp);
pci_restore_state(pdev);

bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry);
dma_free_coherent(&pdev->dev, bytes,
Expand Down

0 comments on commit 83f6e15

Please sign in to comment.