* [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation @ 2013-04-11 9:29 Sebastian Hesselbarth [not found] ` <1365672574-31123-1-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Sebastian Hesselbarth @ 2013-04-11 9:29 UTC (permalink / raw) To: Sebastian Hesselbarth Cc: Andrew Lunn, Jason Cooper, Sergei Shtylyov, linux-doc-u79uwXL29TY76Z2rM5mHXA, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Paul Mackerras, netdev-u79uwXL29TY76Z2rM5mHXA, linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, Florian Fainelli, Lennert Buytenhek With introduction of common clock framework and the ability to provide gated clocks, mv643xx_eth required calls to get and enable these clock gates on some platforms. Back then, common clock framework api wasn't safe for architectures without support for common clocks. This has changed now and there are also managed (devm_) counterparts for clock related functions. The second patch in this series, also converts kzalloc to devm_kzalloc where applicable. Both patches have been sent to the corresponding mailing lists as individual patches before. To get the order required to apply them right, this patch set combines both patches into one set. Sebastian Hesselbarth (2): net: mv643xx_eth: add shared clk and cleanup existing clk handling net: mv643xx_eth: use managed devm_kzalloc Documentation/devicetree/bindings/marvell.txt | 3 ++ drivers/net/ethernet/marvell/mv643xx_eth.c | 44 +++++++++---------------- 2 files changed, 18 insertions(+), 29 deletions(-) --- Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> Cc: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org> Cc: Rob Landley <rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org> Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/NnBR394Jw@public.gmane.org> Cc: Sebastian Hesselbarth <sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org> Cc: Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org> Cc: Florian Fainelli <florian-p3rKhJxN3npAfugRpC6u6w@public.gmane.org> Cc: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org> Cc: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org> Cc: Paul Mackerras <paulus-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> Cc: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org -- 1.7.10.4 ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <1365672574-31123-1-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH 1/2] net: mv643xx_eth: add shared clk and cleanup existing clk handling [not found] ` <1365672574-31123-1-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2013-04-11 9:29 ` Sebastian Hesselbarth 2013-04-11 20:20 ` [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation David Miller 1 sibling, 0 replies; 5+ messages in thread From: Sebastian Hesselbarth @ 2013-04-11 9:29 UTC (permalink / raw) To: Sebastian Hesselbarth Cc: Andrew Lunn, Jason Cooper, Sergei Shtylyov, linux-doc-u79uwXL29TY76Z2rM5mHXA, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Paul Mackerras, netdev-u79uwXL29TY76Z2rM5mHXA, linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, Florian Fainelli, Lennert Buytenhek This patch adds an optional shared block clock to avoid lockups on clock gated controllers. Besides the new clock, clock handling for existing clocks is cleaned up and moved to devm_clk_get. Device tree binding documentation is updated for the new clocks property. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> Cc: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org> Cc: Rob Landley <rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org> Cc: Lennert Buytenhek <buytenh-OLH4Qvv75CYX/NnBR394Jw@public.gmane.org> Cc: Sebastian Hesselbarth <sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org> Cc: Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org> Cc: Florian Fainelli <florian-p3rKhJxN3npAfugRpC6u6w@public.gmane.org> Cc: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org> Cc: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org> Cc: Paul Mackerras <paulus-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> Cc: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org --- Documentation/devicetree/bindings/marvell.txt | 3 +++ drivers/net/ethernet/marvell/mv643xx_eth.c | 27 ++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Documentation/devicetree/bindings/marvell.txt b/Documentation/devicetree/bindings/marvell.txt index f1533d9..f7a0da6 100644 --- a/Documentation/devicetree/bindings/marvell.txt +++ b/Documentation/devicetree/bindings/marvell.txt @@ -115,6 +115,9 @@ prefixed with the string "marvell,", for Marvell Technology Group Ltd. - compatible : "marvell,mv64360-eth-block" - reg : Offset and length of the register set for this block + Optional properties: + - clocks : Phandle to the clock control device and gate bit + Example Discovery Ethernet block node: ethernet-block@2000 { #address-cells = <1>; diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index aedbd82..bbe6104 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -268,7 +268,7 @@ struct mv643xx_eth_shared_private { int extended_rx_coal_limit; int tx_bw_control; int tx_csum_limit; - + struct clk *clk; }; #define TX_BW_CONTROL_ABSENT 0 @@ -410,9 +410,7 @@ struct mv643xx_eth_private { /* * Hardware-specific parameters. */ -#if defined(CONFIG_HAVE_CLK) struct clk *clk; -#endif unsigned int t_clk; }; @@ -2569,6 +2567,10 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) if (msp->base == NULL) goto out_free; + msp->clk = devm_clk_get(&pdev->dev, NULL); + if (!IS_ERR(msp->clk)) + clk_prepare_enable(msp->clk); + /* * (Re-)program MBUS remapping windows if we are asked to. */ @@ -2595,6 +2597,8 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev) struct mv643xx_eth_shared_private *msp = platform_get_drvdata(pdev); iounmap(msp->base); + if (!IS_ERR(msp->clk)) + clk_disable_unprepare(msp->clk); kfree(msp); return 0; @@ -2801,13 +2805,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev) * it to override the default. */ mp->t_clk = 133000000; -#if defined(CONFIG_HAVE_CLK) - mp->clk = clk_get(&pdev->dev, (pdev->id ? "1" : "0")); + mp->clk = devm_clk_get(&pdev->dev, NULL); if (!IS_ERR(mp->clk)) { clk_prepare_enable(mp->clk); mp->t_clk = clk_get_rate(mp->clk); } -#endif + set_params(mp, pd); netif_set_real_num_tx_queues(dev, mp->txq_count); netif_set_real_num_rx_queues(dev, mp->rxq_count); @@ -2889,12 +2892,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev) return 0; out: -#if defined(CONFIG_HAVE_CLK) - if (!IS_ERR(mp->clk)) { + if (!IS_ERR(mp->clk)) clk_disable_unprepare(mp->clk); - clk_put(mp->clk); - } -#endif free_netdev(dev); return err; @@ -2909,12 +2908,8 @@ static int mv643xx_eth_remove(struct platform_device *pdev) phy_detach(mp->phy); cancel_work_sync(&mp->tx_timeout_task); -#if defined(CONFIG_HAVE_CLK) - if (!IS_ERR(mp->clk)) { + if (!IS_ERR(mp->clk)) clk_disable_unprepare(mp->clk); - clk_put(mp->clk); - } -#endif free_netdev(mp->dev); -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation [not found] ` <1365672574-31123-1-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2013-04-11 9:29 ` [PATCH 1/2] net: mv643xx_eth: add shared clk and cleanup existing clk handling Sebastian Hesselbarth @ 2013-04-11 20:20 ` David Miller 1 sibling, 0 replies; 5+ messages in thread From: David Miller @ 2013-04-11 20:20 UTC (permalink / raw) To: sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w Cc: andrew-g2DYL2Zd6BY, jason-NLaQJdtUoK4Be96aLqz0jA, sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8, linux-doc-u79uwXL29TY76Z2rM5mHXA, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, linux-kernel-u79uwXL29TY76Z2rM5mHXA, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, paulus-eUNUBHrolfbYtjvyW6yDsg, netdev-u79uwXL29TY76Z2rM5mHXA, linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ, florian-p3rKhJxN3npAfugRpC6u6w, buytenh-OLH4Qvv75CYX/NnBR394Jw From: Sebastian Hesselbarth <sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Date: Thu, 11 Apr 2013 11:29:32 +0200 > With introduction of common clock framework and the ability to provide > gated clocks, mv643xx_eth required calls to get and enable these clock > gates on some platforms. Back then, common clock framework api wasn't > safe for architectures without support for common clocks. This has > changed now and there are also managed (devm_) counterparts for clock > related functions. > > The second patch in this series, also converts kzalloc to devm_kzalloc > where applicable. > > Both patches have been sent to the corresponding mailing lists as > individual patches before. To get the order required to apply them right, > this patch set combines both patches into one set. Both applied to net-next, thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] net: mv643xx_eth: use managed devm_kzalloc 2013-04-11 9:29 [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation Sebastian Hesselbarth [not found] ` <1365672574-31123-1-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2013-04-11 9:29 ` Sebastian Hesselbarth 2013-04-11 9:32 ` [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation Florian Fainelli 2 siblings, 0 replies; 5+ messages in thread From: Sebastian Hesselbarth @ 2013-04-11 9:29 UTC (permalink / raw) To: Sebastian Hesselbarth Cc: Grant Likely, Rob Herring, Rob Landley, Lennert Buytenhek, Andrew Lunn, Jason Cooper, Florian Fainelli, Sergei Shtylyov, Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev, devicetree-discuss, linux-doc, linux-kernel, netdev This patch moves shared private data kzalloc to managed devm_kzalloc and cleans now unneccessary kfree and error handling. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> --- Changes from v1: - replaced EADDRNOTAVAIL with ENOMEM on failing ioremap (Reported by Sergei Shtylyov) Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Rob Herring <rob.herring@calxeda.com> Cc: Rob Landley <rob@landley.net> Cc: Lennert Buytenhek <buytenh@wantstofly.org> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Jason Cooper <jason@lakedaemon.net> Cc: Florian Fainelli <florian@openwrt.org> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: linuxppc-dev@lists.ozlabs.org Cc: devicetree-discuss@lists.ozlabs.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org --- drivers/net/ethernet/marvell/mv643xx_eth.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index bbe6104..305038f 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -2547,25 +2547,22 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) struct mv643xx_eth_shared_private *msp; const struct mbus_dram_target_info *dram; struct resource *res; - int ret; if (!mv643xx_eth_version_printed++) pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n", mv643xx_eth_driver_version); - ret = -EINVAL; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) - goto out; + return -EINVAL; - ret = -ENOMEM; - msp = kzalloc(sizeof(*msp), GFP_KERNEL); + msp = devm_kzalloc(&pdev->dev, sizeof(*msp), GFP_KERNEL); if (msp == NULL) - goto out; + return -ENOMEM; msp->base = ioremap(res->start, resource_size(res)); if (msp->base == NULL) - goto out_free; + return -ENOMEM; msp->clk = devm_clk_get(&pdev->dev, NULL); if (!IS_ERR(msp->clk)) @@ -2585,11 +2582,6 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) platform_set_drvdata(pdev, msp); return 0; - -out_free: - kfree(msp); -out: - return ret; } static int mv643xx_eth_shared_remove(struct platform_device *pdev) @@ -2599,7 +2591,6 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev) iounmap(msp->base); if (!IS_ERR(msp->clk)) clk_disable_unprepare(msp->clk); - kfree(msp); return 0; } -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation 2013-04-11 9:29 [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation Sebastian Hesselbarth [not found] ` <1365672574-31123-1-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2013-04-11 9:29 ` [PATCH v2 2/2] net: mv643xx_eth: use managed devm_kzalloc Sebastian Hesselbarth @ 2013-04-11 9:32 ` Florian Fainelli 2 siblings, 0 replies; 5+ messages in thread From: Florian Fainelli @ 2013-04-11 9:32 UTC (permalink / raw) To: Sebastian Hesselbarth Cc: Grant Likely, Rob Herring, Rob Landley, Lennert Buytenhek, Andrew Lunn, Jason Cooper, Sergei Shtylyov, Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev, devicetree-discuss, linux-doc, linux-kernel, netdev Le 04/11/13 11:29, Sebastian Hesselbarth a écrit : > With introduction of common clock framework and the ability to provide > gated clocks, mv643xx_eth required calls to get and enable these clock > gates on some platforms. Back then, common clock framework api wasn't > safe for architectures without support for common clocks. This has > changed now and there are also managed (devm_) counterparts for clock > related functions. > > The second patch in this series, also converts kzalloc to devm_kzalloc > where applicable. > > Both patches have been sent to the corresponding mailing lists as > individual patches before. To get the order required to apply them right, > this patch set combines both patches into one set. > > Sebastian Hesselbarth (2): > net: mv643xx_eth: add shared clk and cleanup existing clk handling > net: mv643xx_eth: use managed devm_kzalloc Looks good, thanks Sebastian! Acked-by: Florian Fainelli <florian@openwrt.org> -- Florian ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-04-11 20:20 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-04-11 9:29 [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation Sebastian Hesselbarth [not found] ` <1365672574-31123-1-git-send-email-sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2013-04-11 9:29 ` [PATCH 1/2] net: mv643xx_eth: add shared clk and cleanup existing clk handling Sebastian Hesselbarth 2013-04-11 20:20 ` [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation David Miller 2013-04-11 9:29 ` [PATCH v2 2/2] net: mv643xx_eth: use managed devm_kzalloc Sebastian Hesselbarth 2013-04-11 9:32 ` [PATCH 0/2] net: mv643xx_eth: use managed clk and allocation Florian Fainelli
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).