Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7adda30c authored by Brice Goglin's avatar Brice Goglin Committed by Jeff Garzik
Browse files

myri10ge: match number of save_state and restore



Since pci_save_state() pushes MSI and PCIe states on a kind of stack,
myri10ge saving the state in advance for parity recovery will push the
state again on the stack on suspend. This leads to some memory leak.
We add a couple additional calls to save_state and restore_state so
that we don't leak anymore.

For the future, we are thinking of a better way to recover from parity
error without using pci_save_state().

Signed-off-by: default avatarBrice Goglin <brice@myri.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent a27993f3
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -2641,6 +2641,10 @@ static void myri10ge_watchdog(struct work_struct *work)
		 * nic was resumed from power saving mode.
		 * nic was resumed from power saving mode.
		 */
		 */
		myri10ge_restore_state(mgp);
		myri10ge_restore_state(mgp);

		/* save state again for accounting reasons */
		myri10ge_save_state(mgp);

	} else {
	} else {
		/* if we get back -1's from our slot, perhaps somebody
		/* if we get back -1's from our slot, perhaps somebody
		 * powered off our card.  Don't try to reset it in
		 * powered off our card.  Don't try to reset it in
@@ -2907,7 +2911,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
	status = register_netdev(netdev);
	status = register_netdev(netdev);
	if (status != 0) {
	if (status != 0) {
		dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
		dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
		goto abort_with_irq;
		goto abort_with_state;
	}
	}
	dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n",
	dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n",
		 (mgp->msi_enabled ? "MSI" : "xPIC"),
		 (mgp->msi_enabled ? "MSI" : "xPIC"),
@@ -2916,7 +2920,8 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)


	return 0;
	return 0;


abort_with_irq:
abort_with_state:
	myri10ge_restore_state(mgp);
	free_irq(pdev->irq, mgp);
	free_irq(pdev->irq, mgp);
	if (mgp->msi_enabled)
	if (mgp->msi_enabled)
		pci_disable_msi(pdev);
		pci_disable_msi(pdev);
@@ -2976,6 +2981,9 @@ static void myri10ge_remove(struct pci_dev *pdev)


	myri10ge_dummy_rdma(mgp, 0);
	myri10ge_dummy_rdma(mgp, 0);


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

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