* [rtc-linux] rtc: RV8803: BUG: scheduling while atomic @ 2016-02-03 9:31 dirk.behme 2016-02-03 11:07 ` [rtc-linux] " Alexandre Belloni 0 siblings, 1 reply; 4+ messages in thread From: dirk.behme @ 2016-02-03 9:31 UTC (permalink / raw) To: rtc-linux; +Cc: Dirk Behme, Alexandre Belloni, Oleksij Rempel [-- Attachment #1.1: Type: text/plain, Size: 7997 bytes --] Testing the RV8803 driver [1] we are getting several "BUG: scheduling while atomic" [2]. Having a quick look this might be from rv8803_set_time() holding a spinlock during the call to i2c_smbus_read_byte_data()? Any ideas? Best regards Dirk [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/rtc/rtc-rv8803.c [2] BUG: scheduling while atomic: dev_rtc_integra/309/0x00000002 Backtrace: [<80011bc8>] (dump_backtrace) from [<80011dd0>] (show_stack+0x18/0x1c) r6:00000000 r5:90431140 r4:00000000 r3:00400100 [<80011db8>] (show_stack) from [<80508bc0>] (dump_stack+0x74/0xc0) [<80508b4c>] (dump_stack) from [<805065fc>] (__schedule_bug+0x60/0x7c) r4:90431140 r3:200f0093 [<8050659c>] (__schedule_bug) from [<80509dfc>] (__schedule+0x70/0x6d8) r4:9fa90440 r3:00000000 [<80509d8c>] (__schedule) from [<8050a4fc>] (schedule+0x98/0x9c) r10:92513810 r9:807220c0 r8:00000003 r7:807220c0 r6:ffff988c r5:92513810 r4:00000001 [<8050a464>] (schedule) from [<803a0620>] (i2c_imx_bus_busy+0x7c/0x94) [<803a05a4>] (i2c_imx_bus_busy) from [<803a0ce4>] (i2c_imx_xfer+0x200/0x750) r8:00000002 r7:00000080 r6:000000a0 r5:91bcfd58 r4:807284d0 r3:00000001 [<803a0ae4>] (i2c_imx_xfer) from [<8039cd2c>] (__i2c_transfer+0x50/0x7c) r10:00000002 r9:807220c0 r8:00000002 r7:91bcfd58 r6:ffff988c r5:92513810 r4:00000000 [<8039ccdc>] (__i2c_transfer) from [<8039e138>] (i2c_transfer+0x74/0x98) r9:91bcfd73 r8:00000002 r7:00000000 r6:91bcfd58 r5:00000002 r4:92513810 [<8039e0c4>] (i2c_transfer) from [<8039e5ac>] (i2c_smbus_xfer+0x3a4/0x4f8) r6:92513810 r5:00000001 r4:91bcfdfe r3:00000000 [<8039e208>] (i2c_smbus_xfer) from [<8039eaac>] (i2c_smbus_read_byte_data+0x3c/0x4c) r10:00067674 r9:91bce000 r8:7f2b8c84 r7:90473580 r6:600f0013 r5:9196f290 r4:9196f298 [<8039ea70>] (i2c_smbus_read_byte_data) from [<7f2b83c0>] (rv8803_set_time+0xc0/0x110 [rtc_rv8803]) [<7f2b8300>] (rv8803_set_time [rtc_rv8803]) from [<8039a1a4>] (rtc_set_time+0x64/0xd8) r7:90473580 r6:91bcfe8c r5:90473400 r4:90473400 [<8039a140>] (rtc_set_time) from [<8039b264>] (rtc_dev_ioctl+0x294/0x568) r7:90473580 r6:4024700a r5:90473400 r4:00067674 [<8039afd0>] (rtc_dev_ioctl) from [<8010edfc>] (do_vfs_ioctl+0x4dc/0x598) r8:91bb8958 r7:4024700a r6:00067674 r5:91f9ef00 r4:91f9ef01 [<8010e920>] (do_vfs_ioctl) from [<8010eef4>] (SyS_ioctl+0x3c/0x64) r10:00000000 r9:91bce000 r8:0000000f r7:4024700a r6:00067674 r5:91f9ef00 r4:91f9ef01 [<8010eeb8>] (SyS_ioctl) from [<8000e0a0>] (ret_fast_syscall+0x0/0x50) r8:8000e264 r7:00000036 r6:00000064 r5:00066f90 r4:00000014 r3:00067674 BUG: scheduling while atomic: dev_rtc_integra/309/0x00000002 Workqueue: events rtc_timer_do_work Backtrace: [<80011bc8>] (dump_backtrace) from [<80011dd0>] (show_stack+0x18/0x1c) r6:00000000 r5:925e9700 r4:00000000 r3:9263c000 [<80011db8>] (show_stack) from [<80508bc0>] (dump_stack+0x74/0xc0) [<80508b4c>] (dump_stack) from [<805065fc>] (__schedule_bug+0x60/0x7c) r4:925e9700 r3:20000013 [<8050659c>] (__schedule_bug) from [<80509dfc>] (__schedule+0x70/0x6d8) r4:9fa90440 r3:00000000 [<80509d8c>] (__schedule) from [<8050a4fc>] (schedule+0x98/0x9c) r10:92513810 r9:807284d0 r8:00000003 r7:807220c0 r6:ffff98aa r5:92513810 r4:00000000 [<8050a464>] (schedule) from [<803a0620>] (i2c_imx_bus_busy+0x7c/0x94) [<803a05a4>] (i2c_imx_bus_busy) from [<803a107c>] (i2c_imx_xfer+0x598/0x750) r8:00000001 r7:92513a3c r6:00000000 r5:9263dd1c r4:00000000 r3:00000001 [<803a0ae4>] (i2c_imx_xfer) from [<8039cd2c>] (__i2c_transfer+0x50/0x7c) r10:00000002 r9:807220c0 r8:00000002 r7:9263dd08 r6:ffff98a6 r5:92513810 r4:00000000 [<8039ccdc>] (__i2c_transfer) from [<8039e138>] (i2c_transfer+0x74/0x98) r9:9263dd23 r8:00000002 r7:00000000 r6:9263dd08 r5:00000002 r4:92513810 [<8039e0c4>] (i2c_transfer) from [<8039e5ac>] (i2c_smbus_xfer+0x3a4/0x4f8) r6:92513810 r5:00000001 r4:9263ddae r3:00000000 [<8039e208>] (i2c_smbus_xfer) from [<8039eaac>] (i2c_smbus_read_byte_data+0x3c/0x4c) r10:00000000 r9:600f0113 r8:90473600 r7:9196f298 r6:925ab600 r5:9196f290 r4:00000000 [<8039ea70>] (i2c_smbus_read_byte_data) from [<7f2b80f0>] (rv8803_alarm_irq_enable+0x78/0xe4 [rtc_rv8803]) [<7f2b8078>] (rv8803_alarm_irq_enable [rtc_rv8803]) from [<80399b80>] (rtc_alarm_disable+0x30/0x34) r9:00000000 r8:90473600 r7:90473580 r6:9263de6c r5:90473400 r4:9047369c [<80399b50>] (rtc_alarm_disable) from [<8039ac74>] (rtc_timer_do_work+0xe8/0x148) [<8039ab8c>] (rtc_timer_do_work) from [<8003ba8c>] (process_one_work+0x28c/0x43c) r10:92627500 r9:00000000 r8:807794c0 r7:9fa93300 r6:9263c028 r5:9fa90040 r4:9047369c [<8003b800>] (process_one_work) from [<8003ca68>] (worker_thread+0x238/0x370) r10:9fa90054 r9:92627518 r8:9263c028 r7:9263c000 r6:9fa90040 r5:9fa90040 r4:92627500 [<8003c830>] (worker_thread) from [<800420d0>] (kthread+0xec/0x100) CPU: 0 PID: 309 Comm: dev_rtc_integra Tainted: G W 3.14.57-03945-gf331d92 #1 Backtrace: [<80011bc8>] (dump_backtrace) from [<80011dd0>] (show_stack+0x18/0x1c) r6:00000000 r5:90431140 r4:00000000 r3:00400100 [<80011db8>] (show_stack) from [<80508bc0>] (dump_stack+0x74/0xc0) [<80508b4c>] (dump_stack) from [<805065fc>] (__schedule_bug+0x60/0x7c) r4:90431140 r3:200f0113 [<8050659c>] (__schedule_bug) from [<80509dfc>] (__schedule+0x70/ [<8039a140>] (rtc_set_time) from [<8039b264>] (rtc_dev_ioctl+0x294/0x568) r7:90473580 r6:4024700a r5:90473400 r4:00067674 [<8039afd0>] (rtc_dev_ioctl) from [<8010edfc>] (do_vfs_ioctl+0x4dc/0x598) r8:91bb8958 r7:4024700a r6:00067674 r5:91b64900 r4:91b64901 [<8010e920>] (do_vfs_ioctl) from [<8010eef4>] (SyS_ioctl+0x3c/0x64) r10:00000000 r9:91bce000 r8:0000000f r7:4024700a r6:00067674 r5:91b64900 r4:91b64901 [<8010eeb8>] (SyS_ioctl) from [<8000e0a0>] (ret_fast_syscall+0x0/0x50) r8:8000e264 r7:00000036 r6:0002a3d0 r5:00000000 r4:00067674 r3:0000000c BUG: scheduling while atomic: kworker/0:1/26/0x00000002 Workqueue: events rtc_timer_do_work Backtrace: [<80011bc8>] (dump_backtrace) from [<80011dd0>] (show_stack+0x18/0x1c) r6:00000000 r5:925e9700 r4:00000000 r3:9263c000 [<80011db8>] (show_stack) from [<80508bc0>] (dump_stack+0x74/0xc0) [<80508b4c>] (dump_stack) from [<805065fc>] (__schedule_bug+0x60/0x7c) r4:925e9700 r3:200f0093 [<8050659c>] (__schedule_bug) from [<80509dfc>] (__schedule+0x70/0x6d8) r4:9fa90440 r3:00000000 [<80509d8c>] (__schedule) from [<8050a4fc>] (schedule+0x98/0x9c) r10:92513810 r9:807220c0 r8:00000003 r7:807220c0 r6:ffff98d0 r5:92513810 r4:00000001 [<8050a464>] (schedule) from [<803a0620>] (i2c_imx_bus_busy+0x7c/0x94) [<803a05a4>] (i2c_imx_bus_busy) from [<803a0ce4>] (i2c_imx_xfer+0x200/0x750) r8:00000002 r7:00000080 r6:000000a0 r5:9263dd08 r4:807284d0 r3:00000001 [<803a0ae4>] (i2c_imx_xfer) from [<8039cd2c>] (__i2c_transfer+0x50/0x7c) r10:00000002 r9:807220c0 r8:00000002 r7:9263dd08 r6:ffff98d0 r5:92513810 r4:00000000 [<8039ccdc>] (__i2c_transfer) from [<8039e138>] (i2c_transfer+0x74/0x98) r9:9263dd23 r8:00000002 r7:00000000 r6:9263dd08 r5:00000002 r4:92513810 [<8039e0c4>] (i2c_transfer) from [<8039e5ac>] (i2c_smbus_xfer+0x3a4/0x4f8) r6:92513810 r5:00000001 r4:9263ddae r3:00000000 [<8039e208>] (i2c_smbus_xfer) from [<8039eaac>] (i2c_smbus_read_byte_data+0x3c/0x4c) r10:00000000 r9:600f0013 r8:90473600 r7:9196f298 r6:925ab600 r5:9196f290 r4:00000000 [<8039ea70>] (i2c_smbus_read_byte_data) from [<7f2b80f0>] (rv8803_alarm_irq_enable+0x78/0xe4 [rtc_rv8803]) [<7f2b8078>] (rv[ 37.941914] BUG: scheduling while atomic: kworker/0:1/26/0x00000002 -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 9595 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* [rtc-linux] Re: rtc: RV8803: BUG: scheduling while atomic 2016-02-03 9:31 [rtc-linux] rtc: RV8803: BUG: scheduling while atomic dirk.behme @ 2016-02-03 11:07 ` Alexandre Belloni 2016-02-03 12:58 ` dirk.behme 0 siblings, 1 reply; 4+ messages in thread From: Alexandre Belloni @ 2016-02-03 11:07 UTC (permalink / raw) To: dirk.behme; +Cc: rtc-linux, Dirk Behme, Oleksij Rempel Hi, On 03/02/2016 at 01:31:21 -0800, dirk.behme@gmail.com wrote : > Testing the RV8803 driver [1] we are getting several "BUG: scheduling while > atomic" [2]. > > Having a quick look this might be from rv8803_set_time() holding a spinlock > during the call to i2c_smbus_read_byte_data()? > > Any ideas? > Yes, that is probably the case. As this is already a threaded irq, it can probably be changed into a mutex this would solve the issue. Can you try that? I don't have much time to do it myself right now. -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [rtc-linux] Re: rtc: RV8803: BUG: scheduling while atomic 2016-02-03 11:07 ` [rtc-linux] " Alexandre Belloni @ 2016-02-03 12:58 ` dirk.behme 2016-02-03 14:18 ` Alexandre Belloni 0 siblings, 1 reply; 4+ messages in thread From: dirk.behme @ 2016-02-03 12:58 UTC (permalink / raw) To: rtc-linux; +Cc: dirk.behme, dirk.behme, linux, alexandre.belloni [-- Attachment #1.1: Type: text/plain, Size: 6933 bytes --] On Wednesday, February 3, 2016 at 12:07:47 PM UTC+1, Alexandre Belloni wrote: > > Hi, > > On 03/02/2016 at 01:31:21 -0800, dirk....@gmail.com <javascript:> wrote : > > Testing the RV8803 driver [1] we are getting several "BUG: scheduling > while > > atomic" [2]. > > > > Having a quick look this might be from rv8803_set_time() holding a > spinlock > > during the call to i2c_smbus_read_byte_data()? > > > > Any ideas? > > > > Yes, that is probably the case. As this is already a threaded irq, it > can probably be changed into a mutex this would solve the issue. > Anything like below [1]? If you like this, we'll test it. Many thanks Dirk [1] diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c index 33c7e2a..38621ff 100644 --- a/drivers/rtc/rtc-rv8803.c +++ b/drivers/rtc/rtc-rv8803.c @@ -52,7 +52,7 @@ struct rv8803_data { struct i2c_client *client; struct rtc_device *rtc; - spinlock_t flags_lock; + struct mutex flags_lock; u8 ctrl; }; @@ -63,11 +63,11 @@ static irqreturn_t rv8803_handle_irq(int irq, void *dev_id) unsigned long events = 0; u8 flags; - spin_lock(&rv8803->flags_lock); + mutex_lock(&rv8803->flags_lock); flags = i2c_smbus_read_byte_data(client, RV8803_FLAG); if (flags <= 0) { - spin_unlock(&rv8803->flags_lock); + mutex_unlock(&rv8803->flags_lock); return IRQ_NONE; } @@ -102,7 +102,7 @@ static irqreturn_t rv8803_handle_irq(int irq, void *dev_id) rv8803->ctrl); } - spin_unlock(&rv8803->flags_lock); + mutex_unlock(&rv8803->flags_lock); return IRQ_HANDLED; } @@ -155,7 +155,6 @@ static int rv8803_set_time(struct device *dev, struct rtc_time *tm) struct rv8803_data *rv8803 = dev_get_drvdata(dev); u8 date[7]; int flags, ret; - unsigned long irqflags; if ((tm->tm_year < 100) || (tm->tm_year > 199)) return -EINVAL; @@ -173,18 +172,18 @@ static int rv8803_set_time(struct device *dev, struct rtc_time *tm) if (ret < 0) return ret; - spin_lock_irqsave(&rv8803->flags_lock, irqflags); + mutex_lock(&rv8803->flags_lock); flags = i2c_smbus_read_byte_data(rv8803->client, RV8803_FLAG); if (flags < 0) { - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); + mutex_unlock(&rv8803->flags_lock); return flags; } ret = i2c_smbus_write_byte_data(rv8803->client, RV8803_FLAG, flags & ~RV8803_FLAG_V2F); - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); + mutex_unlock(&rv8803->flags_lock); return ret; } @@ -226,7 +225,7 @@ static int rv8803_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) u8 alarmvals[3]; u8 ctrl[2]; int ret, err; - unsigned long alarm_time, irqflags; + unsigned long alarm_time; /* The alarm has no seconds, round up to nearest minute */ if (alrm->time.tm_sec) { @@ -236,11 +235,11 @@ static int rv8803_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) rtc_time_to_tm(alarm_time, &alrm->time); } - spin_lock_irqsave(&rv8803->flags_lock, irqflags); + mutex_lock(&rv8803->flags_lock); ret = i2c_smbus_read_i2c_block_data(client, RV8803_FLAG, 2, ctrl); if (ret != 2) { - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); + mutex_unlock(&rv8803->flags_lock); return ret < 0 ? ret : -EIO; } @@ -253,14 +252,14 @@ static int rv8803_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) err = i2c_smbus_write_byte_data(rv8803->client, RV8803_CTRL, rv8803->ctrl); if (err) { - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); + mutex_unlock(&rv8803->flags_lock); return err; } } ctrl[1] &= ~RV8803_FLAG_AF; err = i2c_smbus_write_byte_data(rv8803->client, RV8803_FLAG, ctrl[1]); - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); + mutex_unlock(&rv8803->flags_lock); if (err) return err; @@ -289,7 +288,6 @@ static int rv8803_alarm_irq_enable(struct device *dev, unsigned int enabled) struct i2c_client *client = to_i2c_client(dev); struct rv8803_data *rv8803 = dev_get_drvdata(dev); int ctrl, flags, err; - unsigned long irqflags; ctrl = rv8803->ctrl; @@ -305,15 +303,15 @@ static int rv8803_alarm_irq_enable(struct device *dev, unsigned int enabled) ctrl &= ~RV8803_CTRL_AIE; } - spin_lock_irqsave(&rv8803->flags_lock, irqflags); + mutex_lock(&rv8803->flags_lock); flags = i2c_smbus_read_byte_data(client, RV8803_FLAG); if (flags < 0) { - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); + mutex_unlock(&rv8803->flags_lock); return flags; } flags &= ~(RV8803_FLAG_AF | RV8803_FLAG_UF); err = i2c_smbus_write_byte_data(client, RV8803_FLAG, flags); - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); + mutex_unlock(&rv8803->flags_lock); if (err) return err; @@ -333,7 +331,6 @@ static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) struct i2c_client *client = to_i2c_client(dev); struct rv8803_data *rv8803 = dev_get_drvdata(dev); int flags, ret = 0; - unsigned long irqflags; switch (cmd) { case RTC_VL_READ: @@ -355,16 +352,16 @@ static int rv8803_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) return 0; case RTC_VL_CLR: - spin_lock_irqsave(&rv8803->flags_lock, irqflags); + mutex_lock(&rv8803->flags_lock); flags = i2c_smbus_read_byte_data(client, RV8803_FLAG); if (flags < 0) { - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); + mutex_unlock(&rv8803->flags_lock); return flags; } flags &= ~(RV8803_FLAG_V1F | RV8803_FLAG_V2F); ret = i2c_smbus_write_byte_data(client, RV8803_FLAG, flags); - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); + mutex_unlock(&rv8803->flags_lock); if (ret < 0) return ret; @@ -441,6 +438,7 @@ static int rv8803_probe(struct i2c_client *client, if (!rv8803) return -ENOMEM; + mutex_init(&rv8803->flags_lock); rv8803->client = client; i2c_set_clientdata(client, rv8803); -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 9202 bytes --] ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [rtc-linux] Re: rtc: RV8803: BUG: scheduling while atomic 2016-02-03 12:58 ` dirk.behme @ 2016-02-03 14:18 ` Alexandre Belloni 0 siblings, 0 replies; 4+ messages in thread From: Alexandre Belloni @ 2016-02-03 14:18 UTC (permalink / raw) To: dirk.behme; +Cc: rtc-linux, dirk.behme, linux On 03/02/2016 at 04:58:53 -0800, dirk.behme@gmail.com wrote : > Anything like below [1]? > > If you like this, we'll test it. > This seems ok to me. > Many thanks > > Dirk > > [1] > > diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c > index 33c7e2a..38621ff 100644 > --- a/drivers/rtc/rtc-rv8803.c > +++ b/drivers/rtc/rtc-rv8803.c > @@ -52,7 +52,7 @@ > struct rv8803_data { > struct i2c_client *client; > struct rtc_device *rtc; > - spinlock_t flags_lock; > + struct mutex flags_lock; > u8 ctrl; > }; > > @@ -63,11 +63,11 @@ static irqreturn_t rv8803_handle_irq(int irq, void > *dev_id) > unsigned long events = 0; > u8 flags; > > - spin_lock(&rv8803->flags_lock); > + mutex_lock(&rv8803->flags_lock); > > flags = i2c_smbus_read_byte_data(client, RV8803_FLAG); > if (flags <= 0) { > - spin_unlock(&rv8803->flags_lock); > + mutex_unlock(&rv8803->flags_lock); > return IRQ_NONE; > } > > @@ -102,7 +102,7 @@ static irqreturn_t rv8803_handle_irq(int irq, void > *dev_id) > rv8803->ctrl); > } > > - spin_unlock(&rv8803->flags_lock); > + mutex_unlock(&rv8803->flags_lock); > > return IRQ_HANDLED; > } > @@ -155,7 +155,6 @@ static int rv8803_set_time(struct device *dev, struct > rtc_time *tm) > struct rv8803_data *rv8803 = dev_get_drvdata(dev); > u8 date[7]; > int flags, ret; > - unsigned long irqflags; > > if ((tm->tm_year < 100) || (tm->tm_year > 199)) > return -EINVAL; > @@ -173,18 +172,18 @@ static int rv8803_set_time(struct device *dev, struct > rtc_time *tm) > if (ret < 0) > return ret; > > - spin_lock_irqsave(&rv8803->flags_lock, irqflags); > + mutex_lock(&rv8803->flags_lock); > > flags = i2c_smbus_read_byte_data(rv8803->client, RV8803_FLAG); > if (flags < 0) { > - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); > + mutex_unlock(&rv8803->flags_lock); > return flags; > } > > ret = i2c_smbus_write_byte_data(rv8803->client, RV8803_FLAG, > flags & ~RV8803_FLAG_V2F); > > - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); > + mutex_unlock(&rv8803->flags_lock); > > return ret; > } > @@ -226,7 +225,7 @@ static int rv8803_set_alarm(struct device *dev, struct > rtc_wkalrm *alrm) > u8 alarmvals[3]; > u8 ctrl[2]; > int ret, err; > - unsigned long alarm_time, irqflags; > + unsigned long alarm_time; > > /* The alarm has no seconds, round up to nearest minute */ > if (alrm->time.tm_sec) { > @@ -236,11 +235,11 @@ static int rv8803_set_alarm(struct device *dev, > struct rtc_wkalrm *alrm) > rtc_time_to_tm(alarm_time, &alrm->time); > } > > - spin_lock_irqsave(&rv8803->flags_lock, irqflags); > + mutex_lock(&rv8803->flags_lock); > > ret = i2c_smbus_read_i2c_block_data(client, RV8803_FLAG, 2, ctrl); > if (ret != 2) { > - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); > + mutex_unlock(&rv8803->flags_lock); > return ret < 0 ? ret : -EIO; > } > > @@ -253,14 +252,14 @@ static int rv8803_set_alarm(struct device *dev, > struct rtc_wkalrm *alrm) > err = i2c_smbus_write_byte_data(rv8803->client, RV8803_CTRL, > rv8803->ctrl); > if (err) { > - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); > + mutex_unlock(&rv8803->flags_lock); > return err; > } > } > > ctrl[1] &= ~RV8803_FLAG_AF; > err = i2c_smbus_write_byte_data(rv8803->client, RV8803_FLAG, ctrl[1]); > - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); > + mutex_unlock(&rv8803->flags_lock); > if (err) > return err; > > @@ -289,7 +288,6 @@ static int rv8803_alarm_irq_enable(struct device *dev, > unsigned int enabled) > struct i2c_client *client = to_i2c_client(dev); > struct rv8803_data *rv8803 = dev_get_drvdata(dev); > int ctrl, flags, err; > - unsigned long irqflags; > > ctrl = rv8803->ctrl; > > @@ -305,15 +303,15 @@ static int rv8803_alarm_irq_enable(struct device > *dev, unsigned int enabled) > ctrl &= ~RV8803_CTRL_AIE; > } > > - spin_lock_irqsave(&rv8803->flags_lock, irqflags); > + mutex_lock(&rv8803->flags_lock); > flags = i2c_smbus_read_byte_data(client, RV8803_FLAG); > if (flags < 0) { > - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); > + mutex_unlock(&rv8803->flags_lock); > return flags; > } > flags &= ~(RV8803_FLAG_AF | RV8803_FLAG_UF); > err = i2c_smbus_write_byte_data(client, RV8803_FLAG, flags); > - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); > + mutex_unlock(&rv8803->flags_lock); > if (err) > return err; > > @@ -333,7 +331,6 @@ static int rv8803_ioctl(struct device *dev, unsigned > int cmd, unsigned long arg) > struct i2c_client *client = to_i2c_client(dev); > struct rv8803_data *rv8803 = dev_get_drvdata(dev); > int flags, ret = 0; > - unsigned long irqflags; > > switch (cmd) { > case RTC_VL_READ: > @@ -355,16 +352,16 @@ static int rv8803_ioctl(struct device *dev, unsigned > int cmd, unsigned long arg) > return 0; > > case RTC_VL_CLR: > - spin_lock_irqsave(&rv8803->flags_lock, irqflags); > + mutex_lock(&rv8803->flags_lock); > flags = i2c_smbus_read_byte_data(client, RV8803_FLAG); > if (flags < 0) { > - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); > + mutex_unlock(&rv8803->flags_lock); > return flags; > } > > flags &= ~(RV8803_FLAG_V1F | RV8803_FLAG_V2F); > ret = i2c_smbus_write_byte_data(client, RV8803_FLAG, flags); > - spin_unlock_irqrestore(&rv8803->flags_lock, irqflags); > + mutex_unlock(&rv8803->flags_lock); > if (ret < 0) > return ret; > > @@ -441,6 +438,7 @@ static int rv8803_probe(struct i2c_client *client, > if (!rv8803) > return -ENOMEM; > > + mutex_init(&rv8803->flags_lock); > rv8803->client = client; > i2c_set_clientdata(client, rv8803); > > > > > -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-03 14:18 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-02-03 9:31 [rtc-linux] rtc: RV8803: BUG: scheduling while atomic dirk.behme 2016-02-03 11:07 ` [rtc-linux] " Alexandre Belloni 2016-02-03 12:58 ` dirk.behme 2016-02-03 14:18 ` Alexandre Belloni
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.