From: Alessandro Zummo <a.zummo@towertech.it>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: Tejun Heo <tj@kernel.org>, Greg KH <greg@kroah.com>,
rtc-linux@googlegroups.com, LKML <linux-kernel@vger.kernel.org>
Subject: Re: kernfs/rtc: circular dependency between kernfs and ops_lock
Date: Mon, 31 Mar 2014 11:46:27 +0200 [thread overview]
Message-ID: <20140331114627.5e1a4609@linux.lan.towertech.it> (raw)
In-Reply-To: <53384080.9020502@oracle.com>
On Sun, 30 Mar 2014 12:04:16 -0400
Sasha Levin <sasha.levin@oracle.com> wrote:
> > Look good, thanks!
>
> Or not...
>
> Hit it again during overnight fuzzing:
>
I think this is a different bug, please try this.
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index cae212f..2c77d8e 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -712,6 +712,20 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
}
}
+ spin_lock_irq(&rtc_lock);
+ rtc_control = CMOS_READ(RTC_CONTROL);
+ spin_unlock_irq(&rtc_lock);
+
+ /* FIXME:
+ * <asm-generic/rtc.h> doesn't know 12-hour mode either.
+ */
+ if (is_valid_irq(rtc_irq) && !(rtc_control & RTC_24H)) {
+ dev_warn(dev, "only 24-hr supported\n");
+ retval = -ENXIO;
+ goto cleanup0;
+ }
+
+
cmos_rtc.dev = dev;
dev_set_drvdata(dev, &cmos_rtc);
@@ -739,49 +753,49 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
/* disable irqs */
cmos_irq_disable(&cmos_rtc, RTC_PIE | RTC_AIE | RTC_UIE);
- rtc_control = CMOS_READ(RTC_CONTROL);
-
spin_unlock_irq(&rtc_lock);
- /* FIXME:
- * <asm-generic/rtc.h> doesn't know 12-hour mode either.
- */
- if (is_valid_irq(rtc_irq) && !(rtc_control & RTC_24H)) {
- dev_warn(dev, "only 24-hr supported\n");
- retval = -ENXIO;
- goto cleanup1;
- }
-
if (is_valid_irq(rtc_irq)) {
- irq_handler_t rtc_cmos_int_handler;
+
+ irq_handler_t rtc_cmos_int_handler = NULL;
if (is_hpet_enabled()) {
- rtc_cmos_int_handler = hpet_rtc_interrupt;
+
retval = hpet_register_irq_handler(cmos_interrupt);
if (retval) {
dev_warn(dev, "hpet_register_irq_handler "
" failed in rtc_init().");
- goto cleanup1;
+ } else {
+ rtc_cmos_int_handler = hpet_rtc_interrupt;
}
- } else
+ } else {
rtc_cmos_int_handler = cmos_interrupt;
+ }
- retval = request_irq(rtc_irq, rtc_cmos_int_handler,
- 0, dev_name(&cmos_rtc.rtc->dev),
- cmos_rtc.rtc);
- if (retval < 0) {
- dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
- goto cleanup1;
+ if (rtc_cmos_int_handler) {
+ retval = request_irq(rtc_irq, rtc_cmos_int_handler,
+ 0, dev_name(&cmos_rtc.rtc->dev),
+ cmos_rtc.rtc);
+ if (retval < 0) {
+
+ dev_err(dev, "IRQ %d is already in use\n", rtc_irq);
+
+ cmos_rtc.irq = -1;
+
+ if (is_hpet_enabled()) {
+ hpet_unregister_irq_handler(cmos_interrupt);
+ }
+ }
}
}
+
hpet_rtc_timer_init();
/* export at least the first block of NVRAM */
nvram.size = address_space - NVRAM_OFFSET;
retval = sysfs_create_bin_file(&dev->kobj, &nvram);
if (retval < 0) {
- dev_dbg(dev, "can't create nvram file? %d\n", retval);
- goto cleanup2;
+ dev_err(dev, "can't create nvram file? %d\n", retval);
}
dev_info(dev, "%s%s, %zd bytes nvram%s\n",
@@ -795,12 +809,6 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
return 0;
-cleanup2:
- if (is_valid_irq(rtc_irq))
- free_irq(rtc_irq, cmos_rtc.rtc);
-cleanup1:
- cmos_rtc.dev = NULL;
- rtc_device_unregister(cmos_rtc.rtc);
cleanup0:
release_region(ports->start, resource_size(ports));
return retval;
@@ -823,8 +831,12 @@ static void __exit cmos_do_remove(struct device *dev)
sysfs_remove_bin_file(&dev->kobj, &nvram);
if (is_valid_irq(cmos->irq)) {
+
free_irq(cmos->irq, cmos->rtc);
- hpet_unregister_irq_handler(cmos_interrupt);
+
+ if (is_hpet_enabled()) {
+ hpet_unregister_irq_handler(cmos_interrupt);
+ }
}
rtc_device_unregister(cmos->rtc);
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
next prev parent reply other threads:[~2014-03-31 9:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-22 17:51 kernfs/rtc: circular dependency between kernfs and ops_lock Sasha Levin
2014-02-22 20:52 ` Tejun Heo
2014-02-24 11:04 ` Alessandro Zummo
2014-03-25 21:52 ` Sasha Levin
2014-03-25 22:39 ` Alessandro Zummo
2014-03-26 0:19 ` Sasha Levin
2014-03-30 0:28 ` Sasha Levin
2014-03-30 16:04 ` Sasha Levin
2014-03-31 9:46 ` Alessandro Zummo [this message]
2014-03-31 9:52 ` Lars-Peter Clausen
2014-03-31 10:43 ` Alessandro Zummo
2014-03-31 11:07 ` Lars-Peter Clausen
2014-03-31 12:03 ` Alessandro Zummo
2014-03-31 12:19 ` Lars-Peter Clausen
2014-04-02 22:51 ` Sasha Levin
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=20140331114627.5e1a4609@linux.lan.towertech.it \
--to=a.zummo@towertech.it \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
--cc=sasha.levin@oracle.com \
--cc=tj@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.