From: "Mark A. Greer" <mgreer@animalcreek.com>
To: Kevin Hilman <khilman@ti.com>
Cc: "Bedia, Vaibhav" <vaibhav.bedia@ti.com>,
nsekhar@ti.com, linux-omap@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] net: davinci_emac: Add pre_open, post_stop platform callbacks
Date: Fri, 4 May 2012 11:48:00 -0700 [thread overview]
Message-ID: <20120504184800.GC28910@animalcreek.com> (raw)
In-Reply-To: <87y5p7c2v6.fsf@ti.com>
On Fri, May 04, 2012 at 09:44:45AM -0700, Kevin Hilman wrote:
> Hi Mark,
Hi Kevin.
> "Mark A. Greer" <mgreer@animalcreek.com> writes:
>
> [...]
>
> > To work around this issue, add platform data callbacks which
> > are called at the beginning of the open routine and at the
> > end of the stop routine of the davinci_emac driver. The
> > callbacks allow the platform code to issue disable_hlt() and
> > enable_hlt() calls appropriately. Calling disable_hlt()
> > prevents cpu_idle from issuing the 'wfi' instruction.
>
> OK, I'm feeling rather dumb for not thinking of this before and
> suggesting that you use pdata callbacks. But there is a better
> solution: runtime PM.
>
> I hadn't noticed before that since this driver comes from davinci, it
> uses the clock API and not runtime PM which all OMAP drivers have been
> (or are being) converted to.
>
> If we replace the clock API usage in this driver with proper runtime PM
> usage, we can make this work. Basically, clk_enable() turns into
> pm_runtime_get_sync() and clk_disable() turns into pm_runtime_put().
> With that, the OMAP PM core will get callbacks whenever the device is
> [not] needed and we can use device-specific hooks to call
> disable_hlt/enable_hlt.
>
> The only catch though is that in order for this driver to be converted
> to runtime PM and still work on davinci devices, the davinci kernel
> needs to grow runtime PM support. I belive Sekhar is already looking
> into this, and OMAP1 (mach-omap1/pm_bus.c) will be a good example of how
> to get a basic runtime PM implementation working for davinci which just
> does basic clock management.
>
> Having worked on the guts of runtime PM for OMAP, I know it pretty well
> (which is all the more embarrasing that I didn't think of suggesting it
> sooner.) So, let me know how I can help.
>
> As a quick hack to test my idea will help, you can try simply calling
> disable_hlt() after clk_enable() and enable_hlt() after clk_disable() in
> teh davinci_emac driver. That will effectively be what happens after a
> runtime PM conversion with device-specific hooks. The (not even compile
> tested) patch below does this. For starters, can you tell me if this
> results in "normal" performance on the EMAC?
No worries. I thought of pm_runtime before embarking on this patch,
actually. I explained why I did this patch anyaway in another email--
our emails crossed in the ether.
> diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
> index 174a334..c92bc28 100644
> --- a/drivers/net/ethernet/ti/davinci_emac.c
> +++ b/drivers/net/ethernet/ti/davinci_emac.c
> @@ -1909,6 +1909,7 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
> netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT);
>
> clk_enable(emac_clk);
> + disable_hlt();
>
> /* register the network device */
> SET_NETDEV_DEV(ndev, &pdev->dev);
> @@ -1929,6 +1930,7 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
>
> netdev_reg_err:
> clk_disable(emac_clk);
> + enable_hlt();
> no_irq_res:
> if (priv->txchan)
> cpdma_chan_destroy(priv->txchan);
> @@ -1979,6 +1981,7 @@ static int __devexit davinci_emac_remove(struct platform_device *pdev)
>
> clk_disable(emac_clk);
> clk_put(emac_clk);
> + enable_hlt();
>
> return 0;
> }
Yes, this works (it essentially does what my patches do except I did the
calls in open/stop instead of probe/remove :).
Mark
prev parent reply other threads:[~2012-05-04 18:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-02 23:47 [PATCH] net: davinci_emac: Add pre_open, post_stop platform callbacks Mark A. Greer
2012-05-03 10:44 ` Bedia, Vaibhav
2012-05-03 14:22 ` Kevin Hilman
2012-05-03 16:09 ` Mark A. Greer
2012-05-03 18:21 ` Bedia, Vaibhav
2012-05-03 18:46 ` Mark A. Greer
2012-05-03 19:25 ` Bedia, Vaibhav
2012-05-03 20:22 ` Ben Hutchings
2012-05-03 21:32 ` Kevin Hilman
2012-05-04 13:55 ` Bedia, Vaibhav
2012-05-04 14:31 ` Kevin Hilman
2012-05-04 18:29 ` Mark A. Greer
2012-05-04 21:02 ` Kevin Hilman
2012-05-04 21:47 ` Mark A. Greer
2012-05-04 16:35 ` Mark A. Greer
2012-05-04 16:44 ` Kevin Hilman
2012-05-04 18:48 ` Mark A. Greer [this message]
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=20120504184800.GC28910@animalcreek.com \
--to=mgreer@animalcreek.com \
--cc=khilman@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=nsekhar@ti.com \
--cc=vaibhav.bedia@ti.com \
/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