From patchwork Fri Oct 9 10:20:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 35612 X-Patchwork-Delegate: davem@davemloft.net Return-Path: 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]) by ozlabs.org (Postfix) with ESMTP id 071FEB7B78 for ; Fri, 9 Oct 2009 21:34:06 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760638AbZJIKZa (ORCPT ); Fri, 9 Oct 2009 06:25:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760634AbZJIKZa (ORCPT ); Fri, 9 Oct 2009 06:25:30 -0400 Received: from mail-gx0-f212.google.com ([209.85.217.212]:34743 "EHLO mail-gx0-f212.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760587AbZJIKZ1 (ORCPT ); Fri, 9 Oct 2009 06:25:27 -0400 Received: by gxk4 with SMTP id 4so7798985gxk.8 for ; Fri, 09 Oct 2009 03:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=iWxtdMPgLSvm3m+oRtB1r56TWkRvubbMbwy5IthxQRA=; b=S+zD1G3c+u9DQo5wWFzbEnIrvqwReVOo5qSLDjm3w6ISjpMS03P3hag3nlFg8IinUl HrIEaBJKkjNKtMuTiVhoT6PPzwE+9lezEnWVeLth/cm7nAL/+wfKik/u9rrv1h8qFaN6 dTEh9OUYNuMTzAq6mF26tnt7i6XPIGypVzk5Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=TsL8gAXeF05iZhW1dnJp8bkxtl05jdhG1ggIgWwEtBbsl3cQ2y+ARwTX0T6npJZyol 5cmA2YfO5iOYtqKEbPLiDHozruPAyMxVVaSR+9Af7B3zbi1ubo4zLpNs+o6ycfCJO6v1 5sgWMLiR4rVWB/7KS15MZnHUMeUo9Bruql13k= Received: by 10.150.127.36 with SMTP id z36mr4371267ybc.326.1255083891225; Fri, 09 Oct 2009 03:24:51 -0700 (PDT) Received: from rxone.opensource.se (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id 15sm454108gxk.0.2009.10.09.03.24.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 09 Oct 2009 03:24:50 -0700 (PDT) From: Magnus Damm To: netdev@vger.kernel.org Cc: Magnus Damm , lethal@linux-sh.org, davem@davemloft.net, linux-sh@vger.kernel.org Date: Fri, 09 Oct 2009 19:20:04 +0900 Message-Id: <20091009102004.31062.83095.sendpatchset@rxone.opensource.se> Subject: [PATCH] net: add Runtime PM to the sh_eth driver Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Magnus Damm Add Runtime PM support to the sh_eth driver. The clock to the ethernet hardware block will be enabled as long as the network device is up. Signed-off-by: Magnus Damm Tested-by: Kuninori Morimoto --- drivers/net/sh_eth.c | 35 +++++++++++++++++++++++++++++++++-- drivers/net/sh_eth.h | 1 + 2 files changed, 34 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0003/drivers/net/sh_eth.c +++ work/drivers/net/sh_eth.c 2009-10-07 17:25:34.000000000 +0900 @@ -30,7 +30,7 @@ #include #include #include - +#include #include "sh_eth.h" /* There is CPU dependent code */ @@ -1012,6 +1012,8 @@ static int sh_eth_open(struct net_device int ret = 0; struct sh_eth_private *mdp = netdev_priv(ndev); + pm_runtime_get_sync(&mdp->pdev->dev); + ret = request_irq(ndev->irq, &sh_eth_interrupt, #if defined(CONFIG_CPU_SUBTYPE_SH7763) || defined(CONFIG_CPU_SUBTYPE_SH7764) IRQF_SHARED, @@ -1048,6 +1050,7 @@ static int sh_eth_open(struct net_device out_free_irq: free_irq(ndev->irq, ndev); + pm_runtime_put_sync(&mdp->pdev->dev); return ret; } @@ -1179,6 +1182,8 @@ static int sh_eth_close(struct net_devic ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE; dma_free_coherent(NULL, ringsize, mdp->tx_ring, mdp->tx_desc_dma); + pm_runtime_put_sync(&mdp->pdev->dev); + return 0; } @@ -1187,6 +1192,8 @@ static struct net_device_stats *sh_eth_g struct sh_eth_private *mdp = netdev_priv(ndev); u32 ioaddr = ndev->base_addr; + pm_runtime_get_sync(&mdp->pdev->dev); + mdp->stats.tx_dropped += ctrl_inl(ioaddr + TROCR); ctrl_outl(0, ioaddr + TROCR); /* (write clear) */ mdp->stats.collisions += ctrl_inl(ioaddr + CDCR); @@ -1202,6 +1209,8 @@ static struct net_device_stats *sh_eth_g mdp->stats.tx_carrier_errors += ctrl_inl(ioaddr + CNDCR); ctrl_outl(0, ioaddr + CNDCR); /* (write clear) */ #endif + pm_runtime_put_sync(&mdp->pdev->dev); + return &mdp->stats; } @@ -1410,6 +1419,9 @@ static int sh_eth_drv_probe(struct platf mdp = netdev_priv(ndev); spin_lock_init(&mdp->lock); + mdp->pdev = pdev; + pm_runtime_enable(&pdev->dev); + pm_runtime_resume(&pdev->dev); pd = (struct sh_eth_plat_data *)(pdev->dev.platform_data); /* get PHY ID */ @@ -1485,18 +1497,37 @@ static int sh_eth_drv_remove(struct plat sh_mdio_release(ndev); unregister_netdev(ndev); flush_scheduled_work(); - + pm_runtime_disable(&pdev->dev); free_netdev(ndev); platform_set_drvdata(pdev, NULL); return 0; } +static int sh_eth_runtime_nop(struct device *dev) +{ + /* + * Runtime PM callback shared between ->runtime_suspend() + * and ->runtime_resume(). Simply returns success. + * + * This driver re-initializes all registers after + * pm_runtime_get_sync() anyway so there is no need + * to save and restore registers here. + */ + return 0; +} + +static struct dev_pm_ops sh_eth_dev_pm_ops = { + .runtime_suspend = sh_eth_runtime_nop, + .runtime_resume = sh_eth_runtime_nop, +}; + static struct platform_driver sh_eth_driver = { .probe = sh_eth_drv_probe, .remove = sh_eth_drv_remove, .driver = { .name = CARDNAME, + .pm = &sh_eth_dev_pm_ops, }, }; --- 0001/drivers/net/sh_eth.h +++ work/drivers/net/sh_eth.h 2009-10-07 17:22:24.000000000 +0900 @@ -703,6 +703,7 @@ struct sh_eth_cpu_data { }; struct sh_eth_private { + struct platform_device *pdev; struct sh_eth_cpu_data *cd; dma_addr_t rx_desc_dma; dma_addr_t tx_desc_dma;