{"id":959,"url":"http://patchwork.ozlabs.org/api/1.0/patches/959/?format=json","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.0/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<200809222152.m8MLqBHL031945@imap1.linux-foundation.org>","date":"2008-09-22T21:52:11","name":"[04/21] skge: adapt skge to use reworked PCI PM","commit_ref":null,"pull_url":null,"state":"deferred","archived":true,"hash":"855547720c1fbc458482d19a38bad312f22c8aae","submitter":{"id":107,"url":"http://patchwork.ozlabs.org/api/1.0/people/107/?format=json","name":"Andrew Morton","email":"akpm@linux-foundation.org"},"delegate":{"id":36,"url":"http://patchwork.ozlabs.org/api/1.0/users/36/?format=json","username":"jgarzik","first_name":"Jeff","last_name":"Garzik","email":"jgarzik@pobox.com"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/200809222152.m8MLqBHL031945@imap1.linux-foundation.org/mbox/","series":[],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/959/checks/","tags":{},"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Received":["from vger.kernel.org (vger.kernel.org [209.132.176.167])\n\tby ozlabs.org (Postfix) with ESMTP id BAFE4DDF04\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 23 Sep 2008 07:53:26 +1000 (EST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753489AbYIVVxV (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 22 Sep 2008 17:53:21 -0400","(majordomo@vger.kernel.org) by vger.kernel.org id S1753499AbYIVVxU\n\t(ORCPT <rfc822; netdev-outgoing>); Mon, 22 Sep 2008 17:53:20 -0400","from smtp1.linux-foundation.org ([140.211.169.13]:33077 \"EHLO\n\tsmtp1.linux-foundation.org\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1753315AbYIVVxU (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 22 Sep 2008 17:53:20 -0400","from imap1.linux-foundation.org (imap1.linux-foundation.org\n\t[140.211.169.55])\n\tby smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with\n\tESMTP id m8MLqC77018343\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);\n\tMon, 22 Sep 2008 14:52:13 -0700","from localhost.localdomain (localhost [127.0.0.1])\n\tby imap1.linux-foundation.org\n\t(8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id\n\tm8MLqBHL031945; Mon, 22 Sep 2008 14:52:12 -0700"],"Message-Id":"<200809222152.m8MLqBHL031945@imap1.linux-foundation.org>","Subject":"[patch 04/21] skge: adapt skge to use reworked PCI PM","To":"jeff@garzik.org","Cc":"netdev@vger.kernel.org, akpm@linux-foundation.org, rjw@sisk.pl,\n\tjbarnes@virtuousgeek.org, shemminger@linux-foundation.org","From":"akpm@linux-foundation.org","Date":"Mon, 22 Sep 2008 14:52:11 -0700","X-Spam-Status":"No, hits=-3.359 required=5 tests=AWL, BAYES_00,\n\tOSDL_HEADER_SUBJECT_BRACKETED","X-Spam-Checker-Version":"SpamAssassin 3.2.4-osdl_revision__1.47__","X-MIMEDefang-Filter":"lf$Revision: 1.188 $","X-Scanned-By":"MIMEDefang 2.63 on 140.211.169.13","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: Rafael J. Wysocki <rjw@sisk.pl>\n\nAdapt the skge driver to the reworked PCI PM\n\n* Use device_set_wakeup_enable() and friends as needed\n* Remove an open-coded reference to the standard PCI PM registers\n* Use pci_prepare_to_sleep() and pci_back_from_sleep() in the\n  ->suspend() and ->resume() callbacks\n* Use the observation that it is sufficient to call pci_enable_wake()\n  once, unless it fails\n\nTested on Asus L5D (Yukon-Lite rev 7).\n\nSigned-off-by: Rafael J. Wysocki <rjw@sisk.pl>\nCc: Stephen Hemminger <shemminger@linux-foundation.org>\nCc: Jeff Garzik <jeff@garzik.org>\nCc: Jesse Barnes <jbarnes@virtuousgeek.org>\nSigned-off-by: Andrew Morton <akpm@linux-foundation.org>\n---\n\n drivers/net/skge.c |   38 +++++++++++---------------------------\n 1 file changed, 11 insertions(+), 27 deletions(-)","diff":"diff -puN drivers/net/skge.c~skge-adapt-skge-to-use-reworked-pci-pm drivers/net/skge.c\n--- a/drivers/net/skge.c~skge-adapt-skge-to-use-reworked-pci-pm\n+++ a/drivers/net/skge.c\n@@ -149,24 +149,6 @@ static u32 wol_supported(const struct sk\n \treturn WAKE_MAGIC | WAKE_PHY;\n }\n \n-static u32 pci_wake_enabled(struct pci_dev *dev)\n-{\n-\tint pm = pci_find_capability(dev, PCI_CAP_ID_PM);\n-\tu16 value;\n-\n-\t/* If device doesn't support PM Capabilities, but request is to disable\n-\t * wake events, it's a nop; otherwise fail */\n-\tif (!pm)\n-\t\treturn 0;\n-\n-\tpci_read_config_word(dev, pm + PCI_PM_PMC, &value);\n-\n-\tvalue &= PCI_PM_CAP_PME_MASK;\n-\tvalue >>= ffs(PCI_PM_CAP_PME_MASK) - 1;   /* First bit of mask */\n-\n-\treturn value != 0;\n-}\n-\n static void skge_wol_init(struct skge_port *skge)\n {\n \tstruct skge_hw *hw = skge->hw;\n@@ -254,10 +236,14 @@ static int skge_set_wol(struct net_devic\n \tstruct skge_port *skge = netdev_priv(dev);\n \tstruct skge_hw *hw = skge->hw;\n \n-\tif (wol->wolopts & ~wol_supported(hw))\n+\tif ((wol->wolopts & ~wol_supported(hw))\n+\t    || !device_can_wakeup(&hw->pdev->dev))\n \t\treturn -EOPNOTSUPP;\n \n \tskge->wol = wol->wolopts;\n+\n+\tdevice_set_wakeup_enable(&hw->pdev->dev, skge->wol);\n+\n \treturn 0;\n }\n \n@@ -3842,7 +3828,7 @@ static struct net_device *skge_devinit(s\n \tskge->speed = -1;\n \tskge->advertising = skge_supported_modes(hw);\n \n-\tif (pci_wake_enabled(hw->pdev))\n+\tif (device_may_wakeup(&hw->pdev->dev))\n \t\tskge->wol = wol_supported(hw) & WAKE_MAGIC;\n \n \thw->dev[port] = dev;\n@@ -4068,8 +4054,8 @@ static int skge_suspend(struct pci_dev *\n \t}\n \n \tskge_write32(hw, B0_IMSK, 0);\n-\tpci_enable_wake(pdev, pci_choose_state(pdev, state), wol);\n-\tpci_set_power_state(pdev, pci_choose_state(pdev, state));\n+\n+\tpci_prepare_to_sleep(pdev);\n \n \treturn 0;\n }\n@@ -4082,7 +4068,7 @@ static int skge_resume(struct pci_dev *p\n \tif (!hw)\n \t\treturn 0;\n \n-\terr = pci_set_power_state(pdev, PCI_D0);\n+\terr = pci_back_from_sleep(pdev);\n \tif (err)\n \t\tgoto out;\n \n@@ -4090,8 +4076,6 @@ static int skge_resume(struct pci_dev *p\n \tif (err)\n \t\tgoto out;\n \n-\tpci_enable_wake(pdev, PCI_D0, 0);\n-\n \terr = skge_reset(hw);\n \tif (err)\n \t\tgoto out;\n@@ -4132,8 +4116,8 @@ static void skge_shutdown(struct pci_dev\n \t\twol |= skge->wol;\n \t}\n \n-\tpci_enable_wake(pdev, PCI_D3hot, wol);\n-\tpci_enable_wake(pdev, PCI_D3cold, wol);\n+\tif (pci_enable_wake(pdev, PCI_D3cold, wol))\n+\t\tpci_enable_wake(pdev, PCI_D3hot, wol);\n \n \tpci_disable_device(pdev);\n \tpci_set_power_state(pdev, PCI_D3hot);\n","prefixes":["04/21"]}