[PATCH] sky2: power management fix

Fix suspend/resume for sky2. The status ring was getting reallocated
and a bunch of other mistakes. Also, check return from power_state
on resume.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
This commit is contained in:
Stephen Hemminger 2006-01-30 11:37:54 -08:00 committed by Jeff Garzik
parent d561514f61
commit 08c06d8a90

View file

@ -26,7 +26,6 @@
/* /*
* TOTEST * TOTEST
* - speed setting * - speed setting
* - suspend/resume
*/ */
#include <linux/config.h> #include <linux/config.h>
@ -198,7 +197,7 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control); pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control);
vaux = (sky2_read8(hw, B0_CTST) & Y2_VAUX_AVAIL) && vaux = (sky2_read16(hw, B0_CTST) & Y2_VAUX_AVAIL) &&
(power_control & PCI_PM_CAP_PME_D3cold); (power_control & PCI_PM_CAP_PME_D3cold);
pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control); pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control);
@ -2141,14 +2140,12 @@ static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
static int sky2_reset(struct sky2_hw *hw) static int sky2_reset(struct sky2_hw *hw)
{ {
u32 ctst;
u16 status; u16 status;
u8 t8, pmd_type; u8 t8, pmd_type;
int i; int i;
ctst = sky2_read32(hw, B0_CTST);
sky2_write8(hw, B0_CTST, CS_RST_CLR); sky2_write8(hw, B0_CTST, CS_RST_CLR);
hw->chip_id = sky2_read8(hw, B2_CHIP_ID); hw->chip_id = sky2_read8(hw, B2_CHIP_ID);
if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) { if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) {
printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n", printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n",
@ -2156,12 +2153,6 @@ static int sky2_reset(struct sky2_hw *hw)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
/* ring for status responses */
hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
&hw->st_dma);
if (!hw->st_le)
return -ENOMEM;
/* disable ASF */ /* disable ASF */
if (hw->chip_id <= CHIP_ID_YUKON_EC) { if (hw->chip_id <= CHIP_ID_YUKON_EC) {
sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
@ -3135,6 +3126,12 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
} }
hw->pm_cap = pm_cap; hw->pm_cap = pm_cap;
/* ring for status responses */
hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
&hw->st_dma);
if (!hw->st_le)
goto err_out_iounmap;
err = sky2_reset(hw); err = sky2_reset(hw);
if (err) if (err)
goto err_out_iounmap; goto err_out_iounmap;
@ -3263,25 +3260,33 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
static int sky2_resume(struct pci_dev *pdev) static int sky2_resume(struct pci_dev *pdev)
{ {
struct sky2_hw *hw = pci_get_drvdata(pdev); struct sky2_hw *hw = pci_get_drvdata(pdev);
int i; int i, err;
pci_restore_state(pdev); pci_restore_state(pdev);
pci_enable_wake(pdev, PCI_D0, 0); pci_enable_wake(pdev, PCI_D0, 0);
sky2_set_power_state(hw, PCI_D0); err = sky2_set_power_state(hw, PCI_D0);
if (err)
goto out;
sky2_reset(hw); err = sky2_reset(hw);
if (err)
goto out;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
struct net_device *dev = hw->dev[i]; struct net_device *dev = hw->dev[i];
if (dev) { if (dev && netif_running(dev)) {
if (netif_running(dev)) { netif_device_attach(dev);
netif_device_attach(dev); err = sky2_up(dev);
if (sky2_up(dev)) if (err) {
dev_close(dev); printk(KERN_ERR PFX "%s: could not up: %d\n",
dev->name, err);
dev_close(dev);
break;
} }
} }
} }
return 0; out:
return err;
} }
#endif #endif