aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2006-11-25 14:09:28 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-11-25 16:28:33 -0500
commitd728b1e69fd5829ec2ab2434381e5a268d4f684a (patch)
treee11b3dea35247074628f04f5441e4a458bdbd86b /drivers
parent2601a46474db2dcbc08ee690e56f08a10abe65cb (diff)
[PATCH] rtc class locking bugfixes
I got a lockdep warning when running "rtctest" so I though it'd be good to see what was up. - The warning was for rtc->irq_task_lock, gotten from rtc_update_irq() by irq handlerss ... but in a handful of other cases, grabbed without blocking IRQs. - Some callers to rtc_update_irq() were not ensuring IRQs were blocked, yet the routine expects that; make sure all callers block IRQs. It would appear that RTC API tests haven't been part of anyone's kernel regression test suite recently, at least not with lockdep running. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rtc/interface.c15
-rw-r--r--drivers/rtc/rtc-at91.c3
-rw-r--r--drivers/rtc/rtc-dev.c12
-rw-r--r--drivers/rtc/rtc-ds1553.c3
-rw-r--r--drivers/rtc/rtc-test.c2
5 files changed, 24 insertions, 11 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 4783ec68fb3c..6f11f6dfdd9d 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -145,6 +145,13 @@ int rtc_set_alarm(struct class_device *class_dev, struct rtc_wkalrm *alarm)
145} 145}
146EXPORT_SYMBOL_GPL(rtc_set_alarm); 146EXPORT_SYMBOL_GPL(rtc_set_alarm);
147 147
148/**
149 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs
150 * @class_dev: the rtc's class device
151 * @num: how many irqs are being reported (usually one)
152 * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF
153 * Context: in_interrupt(), irqs blocked
154 */
148void rtc_update_irq(struct class_device *class_dev, 155void rtc_update_irq(struct class_device *class_dev,
149 unsigned long num, unsigned long events) 156 unsigned long num, unsigned long events)
150{ 157{
@@ -201,12 +208,12 @@ int rtc_irq_register(struct class_device *class_dev, struct rtc_task *task)
201 if (task == NULL || task->func == NULL) 208 if (task == NULL || task->func == NULL)
202 return -EINVAL; 209 return -EINVAL;
203 210
204 spin_lock(&rtc->irq_task_lock); 211 spin_lock_irq(&rtc->irq_task_lock);
205 if (rtc->irq_task == NULL) { 212 if (rtc->irq_task == NULL) {
206 rtc->irq_task = task; 213 rtc->irq_task = task;
207 retval = 0; 214 retval = 0;
208 } 215 }
209 spin_unlock(&rtc->irq_task_lock); 216 spin_unlock_irq(&rtc->irq_task_lock);
210 217
211 return retval; 218 return retval;
212} 219}
@@ -216,10 +223,10 @@ void rtc_irq_unregister(struct class_device *class_dev, struct rtc_task *task)
216{ 223{
217 struct rtc_device *rtc = to_rtc_device(class_dev); 224 struct rtc_device *rtc = to_rtc_device(class_dev);
218 225
219 spin_lock(&rtc->irq_task_lock); 226 spin_lock_irq(&rtc->irq_task_lock);
220 if (rtc->irq_task == task) 227 if (rtc->irq_task == task)
221 rtc->irq_task = NULL; 228 rtc->irq_task = NULL;
222 spin_unlock(&rtc->irq_task_lock); 229 spin_unlock_irq(&rtc->irq_task_lock);
223} 230}
224EXPORT_SYMBOL_GPL(rtc_irq_unregister); 231EXPORT_SYMBOL_GPL(rtc_irq_unregister);
225 232
diff --git a/drivers/rtc/rtc-at91.c b/drivers/rtc/rtc-at91.c
index bd61e99540a3..5c8addcaf1fb 100644
--- a/drivers/rtc/rtc-at91.c
+++ b/drivers/rtc/rtc-at91.c
@@ -292,7 +292,8 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
292 AT91_RTC_CALEV); 292 AT91_RTC_CALEV);
293 293
294 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, 294 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt,
295 IRQF_SHARED, "at91_rtc", pdev); 295 IRQF_DISABLED | IRQF_SHARED,
296 "at91_rtc", pdev);
296 if (ret) { 297 if (ret) {
297 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n", 298 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n",
298 AT91_ID_SYS); 299 AT91_ID_SYS);
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 3109865e8d73..814b9e1873f5 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -61,7 +61,9 @@ static void rtc_uie_task(void *data)
61 int err; 61 int err;
62 62
63 err = rtc_read_time(&rtc->class_dev, &tm); 63 err = rtc_read_time(&rtc->class_dev, &tm);
64 spin_lock_irq(&rtc->irq_lock); 64
65 local_irq_disable();
66 spin_lock(&rtc->irq_lock);
65 if (rtc->stop_uie_polling || err) { 67 if (rtc->stop_uie_polling || err) {
66 rtc->uie_task_active = 0; 68 rtc->uie_task_active = 0;
67 } else if (rtc->oldsecs != tm.tm_sec) { 69 } else if (rtc->oldsecs != tm.tm_sec) {
@@ -74,11 +76,11 @@ static void rtc_uie_task(void *data)
74 } else if (schedule_work(&rtc->uie_task) == 0) { 76 } else if (schedule_work(&rtc->uie_task) == 0) {
75 rtc->uie_task_active = 0; 77 rtc->uie_task_active = 0;
76 } 78 }
77 spin_unlock_irq(&rtc->irq_lock); 79 spin_unlock(&rtc->irq_lock);
78 if (num) 80 if (num)
79 rtc_update_irq(&rtc->class_dev, num, RTC_UF | RTC_IRQF); 81 rtc_update_irq(&rtc->class_dev, num, RTC_UF | RTC_IRQF);
82 local_irq_enable();
80} 83}
81
82static void rtc_uie_timer(unsigned long data) 84static void rtc_uie_timer(unsigned long data)
83{ 85{
84 struct rtc_device *rtc = (struct rtc_device *)data; 86 struct rtc_device *rtc = (struct rtc_device *)data;
@@ -238,10 +240,10 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
238 240
239 /* avoid conflicting IRQ users */ 241 /* avoid conflicting IRQ users */
240 if (cmd == RTC_PIE_ON || cmd == RTC_PIE_OFF || cmd == RTC_IRQP_SET) { 242 if (cmd == RTC_PIE_ON || cmd == RTC_PIE_OFF || cmd == RTC_IRQP_SET) {
241 spin_lock(&rtc->irq_task_lock); 243 spin_lock_irq(&rtc->irq_task_lock);
242 if (rtc->irq_task) 244 if (rtc->irq_task)
243 err = -EBUSY; 245 err = -EBUSY;
244 spin_unlock(&rtc->irq_task_lock); 246 spin_unlock_irq(&rtc->irq_task_lock);
245 247
246 if (err < 0) 248 if (err < 0)
247 return err; 249 return err;
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index 78552e6e76aa..001eb1123a65 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -340,7 +340,8 @@ static int __init ds1553_rtc_probe(struct platform_device *pdev)
340 340
341 if (pdata->irq >= 0) { 341 if (pdata->irq >= 0) {
342 writeb(0, ioaddr + RTC_INTERRUPTS); 342 writeb(0, ioaddr + RTC_INTERRUPTS);
343 if (request_irq(pdata->irq, ds1553_rtc_interrupt, IRQF_SHARED, 343 if (request_irq(pdata->irq, ds1553_rtc_interrupt,
344 IRQF_DISABLED | IRQF_SHARED,
344 pdev->name, pdev) < 0) { 345 pdev->name, pdev) < 0) {
345 dev_warn(&pdev->dev, "interrupt not available.\n"); 346 dev_warn(&pdev->dev, "interrupt not available.\n");
346 pdata->irq = -1; 347 pdata->irq = -1;
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index bc4bd24508a2..6ef9c62d5032 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -99,6 +99,7 @@ static ssize_t test_irq_store(struct device *dev,
99 struct rtc_device *rtc = platform_get_drvdata(plat_dev); 99 struct rtc_device *rtc = platform_get_drvdata(plat_dev);
100 100
101 retval = count; 101 retval = count;
102 local_irq_disable();
102 if (strncmp(buf, "tick", 4) == 0) 103 if (strncmp(buf, "tick", 4) == 0)
103 rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF); 104 rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF);
104 else if (strncmp(buf, "alarm", 5) == 0) 105 else if (strncmp(buf, "alarm", 5) == 0)
@@ -107,6 +108,7 @@ static ssize_t test_irq_store(struct device *dev,
107 rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF); 108 rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF);
108 else 109 else
109 retval = -EINVAL; 110 retval = -EINVAL;
111 local_irq_enable();
110 112
111 return retval; 113 return retval;
112} 114}