Commit 2202e437 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] pmac_zilog: sleep fix

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

This patch fix a problem with semaphore usage on wakeup from sleep in
pmac_zilog (crashing some laptops on wakeup).
parent e44af431
...@@ -1563,15 +1563,21 @@ static int pmz_detach(struct macio_dev *mdev) ...@@ -1563,15 +1563,21 @@ static int pmz_detach(struct macio_dev *mdev)
static int pmz_suspend(struct macio_dev *mdev, u32 pm_state) static int pmz_suspend(struct macio_dev *mdev, u32 pm_state)
{ {
struct uart_pmac_port *uap = dev_get_drvdata(&mdev->ofdev.dev); struct uart_pmac_port *uap = dev_get_drvdata(&mdev->ofdev.dev);
struct uart_state *state = pmz_uart_reg.state + uap->port.line; struct uart_state *state;
unsigned long flags; unsigned long flags;
if (uap == NULL) if (uap == NULL) {
printk("HRM... pmz_suspend with NULL uap\n");
return 0; return 0;
}
if (pm_state == mdev->ofdev.dev.power_state || pm_state < 2) if (pm_state == mdev->ofdev.dev.power_state || pm_state < 2)
return 0; return 0;
pmz_debug("suspend, switching to state %d\n", pm_state);
state = pmz_uart_reg.state + uap->port.line;
down(&pmz_irq_sem); down(&pmz_irq_sem);
down(&state->sem); down(&state->sem);
...@@ -1607,6 +1613,8 @@ static int pmz_suspend(struct macio_dev *mdev, u32 pm_state) ...@@ -1607,6 +1613,8 @@ static int pmz_suspend(struct macio_dev *mdev, u32 pm_state)
up(&state->sem); up(&state->sem);
up(&pmz_irq_sem); up(&pmz_irq_sem);
pmz_debug("suspend, switching complete\n");
mdev->ofdev.dev.power_state = pm_state; mdev->ofdev.dev.power_state = pm_state;
return 0; return 0;
...@@ -1616,7 +1624,7 @@ static int pmz_suspend(struct macio_dev *mdev, u32 pm_state) ...@@ -1616,7 +1624,7 @@ static int pmz_suspend(struct macio_dev *mdev, u32 pm_state)
static int pmz_resume(struct macio_dev *mdev) static int pmz_resume(struct macio_dev *mdev)
{ {
struct uart_pmac_port *uap = dev_get_drvdata(&mdev->ofdev.dev); struct uart_pmac_port *uap = dev_get_drvdata(&mdev->ofdev.dev);
struct uart_state *state = pmz_uart_reg.state + uap->port.line; struct uart_state *state;
unsigned long flags; unsigned long flags;
int pwr_delay; int pwr_delay;
...@@ -1626,6 +1634,10 @@ static int pmz_resume(struct macio_dev *mdev) ...@@ -1626,6 +1634,10 @@ static int pmz_resume(struct macio_dev *mdev)
if (mdev->ofdev.dev.power_state == 0) if (mdev->ofdev.dev.power_state == 0)
return 0; return 0;
pmz_debug("resume, switching to state 0\n");
state = pmz_uart_reg.state + uap->port.line;
down(&pmz_irq_sem); down(&pmz_irq_sem);
down(&state->sem); down(&state->sem);
...@@ -1658,6 +1670,7 @@ static int pmz_resume(struct macio_dev *mdev) ...@@ -1658,6 +1670,7 @@ static int pmz_resume(struct macio_dev *mdev)
enable_irq(uap->port.irq); enable_irq(uap->port.irq);
} }
bail:
up(&state->sem); up(&state->sem);
up(&pmz_irq_sem); up(&pmz_irq_sem);
...@@ -1670,7 +1683,8 @@ static int pmz_resume(struct macio_dev *mdev) ...@@ -1670,7 +1683,8 @@ static int pmz_resume(struct macio_dev *mdev)
schedule_timeout((pwr_delay * HZ)/1000); schedule_timeout((pwr_delay * HZ)/1000);
} }
bail: pmz_debug("resume, switching complete\n");
mdev->ofdev.dev.power_state = 0; mdev->ofdev.dev.power_state = 0;
return 0; return 0;
......
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