From: Jens Rottmann <JRottmann@LiPPERTEmbedded.de>
To: Andres Salomon <dilinger@collabora.co.uk>
Cc: Jordan Crouse <jordan@cosmicpenguin.net>,
linux-geode@lists.infradead.org, linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] cs5535-mfgpt: reuse timers that have never been set up
Date: Thu, 08 Jul 2010 17:04:38 +0200 [thread overview]
Message-ID: <4C35E906.6000804@LiPPERTEmbedded.de> (raw)
In-Reply-To: <4B5D98ED.6090301@LiPPERTEmbedded.de>
cs5535-mfgpt: reuse timers that have never been set up
The MFGPT hardware may be set up only once, therefore cs5535_mfgpt_free_timer()
didn't re-set the timer's "avail" bit. However if a timer is freed before it
has actually been in use then it may be made available again.
Signed-off-by: Jens Rottmann <JRottmann@LiPPERTEmbedded.de>
---
Hi Andres,
Jens wrote:
> Andres wrote:
>> Jens wrote:
>>> cs5535_mfgpt_init() doesn't free up the timer in the error path
>>
>> Yeah, we can't really free the timer, unfortunately.
>> It actually might not be a bad idea to reverse the code so that the
>> IRQ allocation happens first, since we can clean that up if mfgpt
>> allocation fails.
>
> [...] I guess for reversing the order we'd have to split both
> cs5535_mfgpt_alloc_timer() and cs5535_mfgpt_setup_irq() into two parts [...]
> Maybe cs5535_mfgpt_free_timer() can be made more intelligent to set
> mfgpt->avail again if the hardware isn't actually in a non-reversible state
> yet [...]
As you can see I did just that. What do you think?
Cheers,
Jens
--- linux-2.6.35-rc4/drivers/misc/cs5535-mfgpt.c
+++ mfgpt_reuse_timers/drivers/misc/cs5535-mfgpt.c
@@ -211,6 +211,17 @@
*/
void cs5535_mfgpt_free_timer(struct cs5535_mfgpt_timer *timer)
{
+ unsigned long flags;
+ uint16_t val;
+
+ /* timer can be made available again only if never set up */
+ val = cs5535_mfgpt_read(timer, MFGPT_REG_SETUP);
+ if (!(val & MFGPT_SETUP_SETUP)) {
+ spin_lock_irqsave(&timer->chip->lock, flags);
+ __set_bit(timer->nr, timer->chip->avail);
+ spin_unlock_irqrestore(&timer->chip->lock, flags);
+ }
+
kfree(timer);
}
EXPORT_SYMBOL_GPL(cs5535_mfgpt_free_timer);
_
prev parent reply other threads:[~2010-07-08 15:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-12 10:14 [PATCH] geode-mfgpt: restore previous behavior for selecting IRQ Jens Rottmann
2010-01-18 15:34 ` Andres Salomon
2010-01-25 13:13 ` [PATCH] cs5535-clockevt: free timer in IRQ setup error path Jens Rottmann
2010-07-08 15:04 ` Jens Rottmann [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=4C35E906.6000804@LiPPERTEmbedded.de \
--to=jrottmann@lippertembedded.de \
--cc=dilinger@collabora.co.uk \
--cc=jordan@cosmicpenguin.net \
--cc=linux-geode@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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