linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linuxppc-dev@ozlabs.org,
	Johannes Berg <johannes@sipsolutions.net>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH] power-management elements for 603e/fsl (version 2)
Date: Mon, 21 May 2007 10:57:12 -0500	[thread overview]
Message-ID: <20070521155712.GA16235@ld0162-tx32.am.freescale.net> (raw)
In-Reply-To: <Pine.LNX.4.60.0705192013010.10162@poirot.grange>

On Sat, May 19, 2007 at 09:22:10PM +0200, Guennadi Liakhovetski wrote:
> +static int ls_pm_enter(suspend_state_t state)
> +{
> +	char ier;
> +	int ret = 0;
> +	u64 tb;
> +
> +	/* Stop preemption */
> +	preempt_disable();
> +
> +	if ((ret = fsl_suspend(state)) < 0) {
> +		preempt_enable();
> +		return ret;
> +	}
> +
> +	local_irq_disable();

IRQs are already disabled when this function is called.

> +	/* go zzzzz... (re-enabling interrupts) */
> +	fsl_low_sleep();

IRQs really shouldn't be enabled here without something like the "Handle
HID0_SLEEP in the TLF_NAPPING hack" patch I posted recently.

> +	/* Re-enable local CPU interrupts */
> +	local_irq_enable();

Just leave them off.

> @@ -112,10 +155,15 @@ static int __init ls_uarts_init(void)
>  
>  	avr_clock = *(u32*)of_get_property(avr, "clock-frequency", &len);
>  	phys_addr = ((u32*)of_get_property(avr, "reg", &len))[0];
> + 	irq = ((u32*)get_property(avr, "interrupts", &len))[0];

Oopsing if a property is missing isn't nice.

> +
> +#ifdef CONFIG_PM
> +#include <linux/pci.h>
> +#include <asm/pci-bridge.h>
> +
> +#define	MPC10X_LP_REF_EN	(1<<12)
> +#define	MPC10X_PM		(1<<7)
> +#define MPC10X_DOZE		(1<<5)
> +#define	MPC10X_NAP		(1<<4)
> +#define	MPC10X_SLEEP		(1<<3)
> +
> +int fsl_suspend(suspend_state_t state)
> +{
> +	struct pci_dev *bridge;
> +	unsigned long flags;
> +	u16 pmcr1;
> +
> +	bridge = pci_find_slot(0, 0);
> +	if (!bridge)
> +		return -ENODEV;
> +
> +	pci_read_config_word(bridge, 0x70, &pmcr1);
> +	local_irq_save(flags);
> +	/* Apparently, MacOS uses NAP mode for Grackle ??? */
> +	pmcr1 &= ~(MPC10X_DOZE | MPC10X_NAP);
> +	pmcr1 |= MPC10X_PM | MPC10X_SLEEP | MPC10X_LP_REF_EN;
> +	pci_write_config_word(bridge, 0x70, pmcr1);
> +	local_irq_restore(flags);

This should probably be something like mpc10x_suspend.  Also, IRQs should
already be disabled when this is called.

> +	/* Make sure the decrementer won't interrupt us */
> +	asm volatile("mtdec %0" : : "r" (0x7fffffff));
> +	/* Make sure any pending DEC interrupt occurring while we did
> +	 * the above didn't re-enable the DEC */
> +	mb();
> +	asm volatile("mtdec %0" : : "r" (0x7fffffff)); /* 8 seconds */

IRQs are already disabled here, so if it was pending it still will be (at
least with some cores).  It needs to be done with the arch suspend hook.

-Scott

  parent reply	other threads:[~2007-05-21 15:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-19 19:22 [PATCH] power-management elements for 603e/fsl (version 2) Guennadi Liakhovetski
2007-05-21 15:54 ` Johannes Berg
2007-05-21 15:57 ` Scott Wood [this message]
2007-05-21 20:50   ` Guennadi Liakhovetski
2007-07-01 21:19     ` Guennadi Liakhovetski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070521155712.GA16235@ld0162-tx32.am.freescale.net \
    --to=scottwood@freescale.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=johannes@sipsolutions.net \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).