<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/rtc/rtc-m41t80.c, branch linux-4.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-4.16.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-4.16.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2018-05-25T14:46:20Z</updated>
<entry>
<title>rtc: m41t80: fix race conditions</title>
<updated>2018-05-25T14:46:20Z</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2018-02-25T20:14:31Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=4bd8a5978ff44a26ee8e42c47b35eb2fee820d3d'/>
<id>urn:sha1:4bd8a5978ff44a26ee8e42c47b35eb2fee820d3d</id>
<content type='text'>
[ Upstream commit 10d0c768cc6d581523d673b9d1b54213f8a5eb24 ]

The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler, leading to:

Unable to handle kernel NULL pointer dereference at virtual address 0000017c
pgd = a38a2f9b
[0000017c] *pgd=00000000
Internal error: Oops: 5 [#1] ARM
Modules linked in:
CPU: 0 PID: 613 Comm: irq/48-m41t80 Not tainted 4.16.0-rc1+ #42
Hardware name: Atmel SAMA5
PC is at mutex_lock+0x14/0x38
LR is at m41t80_handle_irq+0x1c/0x9c
pc : [&lt;c06e864c&gt;]    lr : [&lt;c04b70f0&gt;]    psr: 20000013
sp : dec73f30  ip : 00000000  fp : dec56d98
r10: df437cf0  r9 : c0a03008  r8 : c0145ffc
r7 : df5c4300  r6 : dec568d0  r5 : df593000  r4 : 0000017c
r3 : df592800  r2 : 60000013  r1 : df593000  r0 : 0000017c
Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c53c7d  Table: 20004059  DAC: 00000051
Process irq/48-m41t80 (pid: 613, stack limit = 0xb52d091e)
Stack: (0xdec73f30 to 0xdec74000)
3f20:                                     dec56840 df5c4300 00000001 df5c4300
3f40: c0145ffc c0146018 dec56840 ffffe000 00000001 c0146290 dec567c0 00000000
3f60: c0146084 ed7c9a62 c014615c dec56d80 dec567c0 00000000 dec72000 dec56840
3f80: c014615c c012ffc0 dec72000 dec567c0 c012fe80 00000000 00000000 00000000
3fa0: 00000000 00000000 00000000 c01010e8 00000000 00000000 00000000 00000000
3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 29282726 2d2c2b2a
[&lt;c06e864c&gt;] (mutex_lock) from [&lt;c04b70f0&gt;] (m41t80_handle_irq+0x1c/0x9c)
[&lt;c04b70f0&gt;] (m41t80_handle_irq) from [&lt;c0146018&gt;] (irq_thread_fn+0x1c/0x54)
[&lt;c0146018&gt;] (irq_thread_fn) from [&lt;c0146290&gt;] (irq_thread+0x134/0x1c0)
[&lt;c0146290&gt;] (irq_thread) from [&lt;c012ffc0&gt;] (kthread+0x140/0x148)
[&lt;c012ffc0&gt;] (kthread) from [&lt;c01010e8&gt;] (ret_from_fork+0x14/0x2c)
Exception stack(0xdec73fb0 to 0xdec73ff8)
3fa0:                                     00000000 00000000 00000000 00000000
3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
Code: e3c33d7f e3c3303f f5d0f000 e593300c (e1901f9f)
---[ end trace 22b027302eb7c604 ]---
genirq: exiting task "irq/48-m41t80" (613) is an active IRQ thread (irq 48)

Also, there is another possible race condition. The probe function is not
allowed to fail after the RTC is registered because the following may
happen:

CPU0:                                CPU1:
sys_load_module()
 do_init_module()
  do_one_initcall()
   cmos_do_probe()
    rtc_device_register()
     __register_chrdev()
     cdev-&gt;owner = struct module*
                                     open("/dev/rtc0")
    rtc_device_unregister()
  module_put()
  free_module()
   module_free(mod-&gt;module_core)
   /* struct module *module is now
      freed */
                                      chrdev_open()
                                       spin_lock(cdev_lock)
                                       cdev_get()
                                        try_module_get()
                                         module_is_live()
                                         /* dereferences already
                                            freed struct module* */

Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before requesting the IRQ and register it as late as possible.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;

Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>rtc: m41t80: remove unneeded checks from m41t80_sqw_set_rate</title>
<updated>2017-11-08T06:52:24Z</updated>
<author>
<name>Troy Kisky</name>
<email>troy.kisky@boundarydevices.com</email>
</author>
<published>2017-11-03T01:58:16Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=05a03bf260e0480bfc0db91b1fdbc2115e3f193b'/>
<id>urn:sha1:05a03bf260e0480bfc0db91b1fdbc2115e3f193b</id>
<content type='text'>
m41t80_sqw_set_rate will be called with the result from
m41t80_sqw_round_rate, so might as well make
m41t80_sqw_set_rate(n) same as
m41t80_sqw_set_rate(m41t80_sqw_round_rate(n))

As Russell King wrote[1],
"clk_round_rate() is supposed to tell you what you end up with if you
ask clk_set_rate() to set the exact same value you passed in - but
clk_round_rate() won't modify the hardware."

[1]
http://lists.infradead.org/pipermail/linux-arm-kernel/2012-January/080175.html

Signed-off-by: Troy Kisky &lt;troy.kisky@boundarydevices.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: m41t80: avoid i2c read in m41t80_sqw_is_prepared</title>
<updated>2017-11-08T06:52:24Z</updated>
<author>
<name>Troy Kisky</name>
<email>troy.kisky@boundarydevices.com</email>
</author>
<published>2017-11-03T01:58:15Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=13bb1d78f2e372ec0d9b30489ac63768240140fc'/>
<id>urn:sha1:13bb1d78f2e372ec0d9b30489ac63768240140fc</id>
<content type='text'>
This is a little more efficient and avoids the warning

 WARNING: possible circular locking dependency detected
 4.14.0-rc7-00010 #16 Not tainted
 ------------------------------------------------------
 kworker/2:1/70 is trying to acquire lock:
  (prepare_lock){+.+.}, at: [&lt;c049300c&gt;] clk_prepare_lock+0x80/0xf4

 but task is already holding lock:
  (i2c_register_adapter){+.+.}, at: [&lt;c0690b04&gt;]
		i2c_adapter_lock_bus+0x14/0x18

 which lock already depends on the new lock.

 the existing dependency chain (in reverse order) is:

 -&gt; #1 (i2c_register_adapter){+.+.}:
        rt_mutex_lock+0x44/0x5c
        i2c_adapter_lock_bus+0x14/0x18
        i2c_transfer+0xa8/0xbc
        i2c_smbus_xfer+0x20c/0x5d8
        i2c_smbus_read_byte_data+0x38/0x48
        m41t80_sqw_is_prepared+0x18/0x28

Signed-off-by: Troy Kisky &lt;troy.kisky@boundarydevices.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: m41t80: avoid i2c read in m41t80_sqw_recalc_rate</title>
<updated>2017-11-08T06:52:23Z</updated>
<author>
<name>Troy Kisky</name>
<email>troy.kisky@boundarydevices.com</email>
</author>
<published>2017-11-03T01:58:14Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=2cb90ed3de1e279dbaf23df141f54eb9fb1861e6'/>
<id>urn:sha1:2cb90ed3de1e279dbaf23df141f54eb9fb1861e6</id>
<content type='text'>
This is a little more efficient, and avoids the warning

 WARNING: possible circular locking dependency detected
 4.14.0-rc7-00007 #14 Not tainted
 ------------------------------------------------------
 alsactl/330 is trying to acquire lock:
 (prepare_lock){+.+.}, at: [&lt;c049300c&gt;] clk_prepare_lock+0x80/0xf4

 but task is already holding lock:
 (i2c_register_adapter){+.+.}, at: [&lt;c0690ae0&gt;]
		i2c_adapter_lock_bus+0x14/0x18

 which lock already depends on the new lock.

 the existing dependency chain (in reverse order) is:

 -&gt; #1 (i2c_register_adapter){+.+.}:
        rt_mutex_lock+0x44/0x5c
        i2c_adapter_lock_bus+0x14/0x18
        i2c_transfer+0xa8/0xbc
        i2c_smbus_xfer+0x20c/0x5d8
        i2c_smbus_read_byte_data+0x38/0x48
        m41t80_sqw_recalc_rate+0x24/0x58

Signed-off-by: Troy Kisky &lt;troy.kisky@boundarydevices.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: m41t80: fix m41t80_sqw_round_rate return value</title>
<updated>2017-11-08T06:52:23Z</updated>
<author>
<name>Troy Kisky</name>
<email>troy.kisky@boundarydevices.com</email>
</author>
<published>2017-11-03T01:58:13Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=c8384bb04261b9d32fe7402a6068ddaf38913b23'/>
<id>urn:sha1:c8384bb04261b9d32fe7402a6068ddaf38913b23</id>
<content type='text'>
Previously it was returning the best of
32768, 8192, 1024, 64, 2, 0

Now, best of
32768, 8192, 4096, 2048, 1024, 512, 256, 128,
64, 32, 16, 8, 4, 2, 1, 0

Signed-off-by: Troy Kisky &lt;troy.kisky@boundarydevices.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: m41t80: m41t80_sqw_set_rate should return 0 on success</title>
<updated>2017-11-08T06:52:23Z</updated>
<author>
<name>Troy Kisky</name>
<email>troy.kisky@boundarydevices.com</email>
</author>
<published>2017-11-03T01:58:12Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=de6042d2fa8afe22b76e3c68fd6e9584c9415a3b'/>
<id>urn:sha1:de6042d2fa8afe22b76e3c68fd6e9584c9415a3b</id>
<content type='text'>
Previously it was returning -EINVAL upon success.

Signed-off-by: Troy Kisky &lt;troy.kisky@boundarydevices.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: m41t80: remove debug sysfs attribute</title>
<updated>2017-08-24T09:03:34Z</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@free-electrons.com</email>
</author>
<published>2017-08-22T23:15:42Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=be8e2746462b11e92a882e45317fafcd2c0dc50b'/>
<id>urn:sha1:be8e2746462b11e92a882e45317fafcd2c0dc50b</id>
<content type='text'>
The last remaining sysfs attribute is undocumented and useless as it can
only be used to debug the driver. Remove it.

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: m41t80: enable wakealarm when "wakeup-source" is specified</title>
<updated>2017-08-24T09:03:34Z</updated>
<author>
<name>Eric Cooper</name>
<email>ecc@cmu.edu</email>
</author>
<published>2017-07-30T00:10:54Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d4473b9b778f39f0b5da870a9a96b5778861c60b'/>
<id>urn:sha1:d4473b9b778f39f0b5da870a9a96b5778861c60b</id>
<content type='text'>
Don't require an IRQ if the wakeup-source device-tree property is present.

Signed-off-by: Eric Cooper &lt;ecc@cmu.edu&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: m41t80: add clock provider support</title>
<updated>2017-05-31T07:17:04Z</updated>
<author>
<name>Gary Bisson</name>
<email>gary.bisson@boundarydevices.com</email>
</author>
<published>2017-04-25T14:45:17Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=1373e77b4f108929caa448bb23f341a4af774cad'/>
<id>urn:sha1:1373e77b4f108929caa448bb23f341a4af774cad</id>
<content type='text'>
Some devices supported by the m41t80 driver have a programmable
square-wave output signal (see M41T80_FEATURE_SQ).

This enables to use this feature as a clock provider of common
clock framework.

Signed-off-by: Gary Bisson &lt;gary.bisson@boundarydevices.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
<entry>
<title>rtc: m41t80: remove sqw sysfs entry</title>
<updated>2017-05-31T07:17:03Z</updated>
<author>
<name>Gary Bisson</name>
<email>gary.bisson@boundarydevices.com</email>
</author>
<published>2017-04-25T14:45:16Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=17e296eb35dc5b15511ffa4ef5de67e53cb5a284'/>
<id>urn:sha1:17e296eb35dc5b15511ffa4ef5de67e53cb5a284</id>
<content type='text'>
In order to use the proper clock framework to control this feature.

Signed-off-by: Gary Bisson &lt;gary.bisson@boundarydevices.com&gt;
Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@free-electrons.com&gt;
</content>
</entry>
</feed>
