All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Linux PCI <linux-pci@vger.kernel.org>,
	pm list <linux-pm@lists.linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [RFC][PATCH 2/2] radeonfb: Avoid open coding of PCI PM operations
Date: Sun, 22 Mar 2009 22:13:13 +0100	[thread overview]
Message-ID: <200903222213.14186.rjw@sisk.pl> (raw)
In-Reply-To: <200903222208.22434.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

The radeonfb driver uses open coded programming of the low power
state D2 into the device, because it has to handle some chips
that don't follow the specification.  Avoid that by making it use
__pci_set_power_state() for this purpose.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/video/aty/radeon_pm.c |   26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)

Index: linux-2.6/drivers/video/aty/radeon_pm.c
===================================================================
--- linux-2.6.orig/drivers/video/aty/radeon_pm.c
+++ linux-2.6/drivers/video/aty/radeon_pm.c
@@ -2507,25 +2507,6 @@ static void radeon_reinitialize_QW(struc
 
 #endif /* CONFIG_PPC_OF */
 
-static void radeonfb_whack_power_state(struct radeonfb_info *rinfo, pci_power_t state)
-{
-	u16 pwr_cmd;
-
-	for (;;) {
-		pci_read_config_word(rinfo->pdev,
-				     rinfo->pm_reg+PCI_PM_CTRL,
-				     &pwr_cmd);
-		if (pwr_cmd & 2)
-			break;
-		pwr_cmd = (pwr_cmd & ~PCI_PM_CTRL_STATE_MASK) | 2;
-		pci_write_config_word(rinfo->pdev,
-				      rinfo->pm_reg+PCI_PM_CTRL,
-				      pwr_cmd);
-		msleep(500);
-	}
-	rinfo->pdev->current_state = state;
-}
-
 static void radeon_set_suspend(struct radeonfb_info *rinfo, int suspend)
 {
 	u32 tmp;
@@ -2578,11 +2559,10 @@ static void radeon_set_suspend(struct ra
 		pci_disable_device(rinfo->pdev);
 		pci_save_state(rinfo->pdev);
 		/* The chip seems to need us to whack the PM register
-		 * repeatedly until it sticks. We do that -prior- to
-		 * calling pci_set_power_state()
+		 * repeatedly until it sticks.  However, with the 500 ms delay,
+		 * it's better to give up after 10 unsuccessful attempts.
 		 */
-		radeonfb_whack_power_state(rinfo, PCI_D2);
-		pci_set_power_state(rinfo->pdev, PCI_D2);
+		__pci_set_power_state(rinfo->pdev, PCI_D2, 10, 500);
 	} else {
 		printk(KERN_DEBUG "radeonfb (%s): switching to D0 state...\n",
 		       pci_name(rinfo->pdev));

  parent reply	other threads:[~2009-03-22 21:14 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-20 23:03 [RFC][PATCH] PCI PM: Be extra careful when changing power states of devices Rafael J. Wysocki
2009-03-22 21:08 ` [RFC][PATCH 0/2] Make radeonfb use PCI PM core for suspendig device (was: Re: [RFC][PATCH] PCI PM: Be extra careful when changing power states of devices) Rafael J. Wysocki
2009-03-22 21:08 ` Rafael J. Wysocki
2009-03-22 21:11   ` [RFC][PATCH 1/2] PCI PM: Introduce __pci_set_power_state() Rafael J. Wysocki
2009-03-22 23:08     ` [linux-pm] " Nigel Cunningham
2009-03-22 23:08       ` Nigel Cunningham
2009-03-23 18:14       ` [linux-pm] " Rafael J. Wysocki
2009-03-23 18:14       ` Rafael J. Wysocki
2009-03-22 21:11   ` Rafael J. Wysocki
2009-03-22 21:13   ` Rafael J. Wysocki [this message]
2009-03-22 21:13   ` [RFC][PATCH 2/2] radeonfb: Avoid open coding of PCI PM operations Rafael J. Wysocki
2009-03-23  0:09   ` [RFC][PATCH 0/2] Make radeonfb use PCI PM core for suspendig device (was: Re: [RFC][PATCH] PCI PM: Be extra careful when changing power states of devices) Benjamin Herrenschmidt
2009-03-23  0:09   ` Benjamin Herrenschmidt
2009-03-23 23:01     ` Rafael J. Wysocki
2009-03-23 23:01     ` Rafael J. Wysocki
2009-03-23 21:30   ` [RFC][PATCH 0/2] Export platform_pci_set_power_state() and make radeonfb use it Rafael J. Wysocki
2009-03-23 21:31     ` [RFC][PATCH 1/2] PCI PM: Export platform_pci_set_power_state() Rafael J. Wysocki
2009-03-23 21:31     ` Rafael J. Wysocki
2009-03-23 21:32     ` [RFC][PATCH 2/2] radeonfb: Use platform_pci_set_power_state() Rafael J. Wysocki
2009-03-23 21:32     ` Rafael J. Wysocki
2009-03-23 22:23     ` [RFC][PATCH 0/2] Export platform_pci_set_power_state() and make radeonfb use it Jesse Barnes
2009-03-23 22:23     ` Jesse Barnes
2009-03-24  0:57       ` Benjamin Herrenschmidt
2009-03-24  0:57       ` Benjamin Herrenschmidt
2009-03-24  1:14         ` Jesse Barnes
2009-03-24  1:14         ` Jesse Barnes
2009-03-24 11:00           ` Rafael J. Wysocki
2009-03-24 21:12             ` Benjamin Herrenschmidt
2009-03-24 21:12             ` Benjamin Herrenschmidt
2009-03-24 22:00               ` Rafael J. Wysocki
2009-03-24 22:00               ` Rafael J. Wysocki
2009-03-24 22:25               ` Rafael J. Wysocki
2009-03-24 22:25               ` Rafael J. Wysocki
2009-03-24 11:00           ` Rafael J. Wysocki
2009-03-24 22:04           ` Alex Deucher
2009-03-24 22:04           ` Alex Deucher
2009-03-23 21:30   ` Rafael J. Wysocki

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=200903222213.14186.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.