<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/gpio, branch v3.2.68</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>gpio: sysfs: fix memory leak in gpiod_sysfs_set_active_low</title>
<updated>2015-03-06T00:39:18+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-01-26T11:02:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4a5233cccf2599f8ae122ae6327cb2a2dce8c429'/>
<id>4a5233cccf2599f8ae122ae6327cb2a2dce8c429</id>
<content type='text'>
commit 49d2ca84e433dab854c7a866bc6add09cfab682d upstream.

Fix memory leak in the gpio sysfs interface due to failure to drop
reference to device returned by class_find_device when setting the
gpio-line polarity.

Fixes: 0769746183ca ("gpiolib: add support for changing value polarity
in sysfs")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 49d2ca84e433dab854c7a866bc6add09cfab682d upstream.

Fix memory leak in the gpio sysfs interface due to failure to drop
reference to device returned by class_find_device when setting the
gpio-line polarity.

Fixes: 0769746183ca ("gpiolib: add support for changing value polarity
in sysfs")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: sysfs: fix memory leak in gpiod_export_link</title>
<updated>2015-03-06T00:39:18+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-01-26T11:02:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=67cb64715f1edfa5e05812bf70913c18d065421c'/>
<id>67cb64715f1edfa5e05812bf70913c18d065421c</id>
<content type='text'>
commit 0f303db08df0df9bd0966443ad6001e63960af16 upstream.

Fix memory leak in the gpio sysfs interface due to failure to drop
reference to device returned by class_find_device when creating a link.

Fixes: a4177ee7f1a8 ("gpiolib: allow exported GPIO nodes to be named
using sysfs links")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 0f303db08df0df9bd0966443ad6001e63960af16 upstream.

Fix memory leak in the gpio sysfs interface due to failure to drop
reference to device returned by class_find_device when creating a link.

Fixes: a4177ee7f1a8 ("gpiolib: allow exported GPIO nodes to be named
using sysfs links")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: sysfs: fix gpio attribute-creation race</title>
<updated>2015-02-20T00:49:38+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-01-13T12:00:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a10ff58e82582898690f3f2328ef5ef772c2a0b1'/>
<id>a10ff58e82582898690f3f2328ef5ef772c2a0b1</id>
<content type='text'>
commit ebbeba120ab2ec6ac5f3afc1425ec6ff0b77ad6f upstream.

Fix attribute-creation race with userspace by using the default group
to create also the contingent gpio device attributes.

Fixes: d8f388d8dc8d ("gpio: sysfs interface")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2:
 - Adjust filenames, context
 - Use gpio_to_desc(), not gpiod_to_desc(), in gpio_is_visible()
 - gpio_is_visible() must return mode_t]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit ebbeba120ab2ec6ac5f3afc1425ec6ff0b77ad6f upstream.

Fix attribute-creation race with userspace by using the default group
to create also the contingent gpio device attributes.

Fixes: d8f388d8dc8d ("gpio: sysfs interface")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2:
 - Adjust filenames, context
 - Use gpio_to_desc(), not gpiod_to_desc(), in gpio_is_visible()
 - gpio_is_visible() must return mode_t]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: sysfs: fix gpio device-attribute leak</title>
<updated>2015-02-20T00:49:38+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-01-13T12:00:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=91111b535d9d2b7927b59639e738d395a9f835c0'/>
<id>91111b535d9d2b7927b59639e738d395a9f835c0</id>
<content type='text'>
commit 0915e6feb38de8d3601819992a5bd050201a56fa upstream.

The gpio device attributes were never destroyed when the gpio was
unexported (or on export failures).

Use device_create_with_groups() to create the default device attributes
of the gpio class device. Note that this also fixes the
attribute-creation race with userspace for these attributes.

Remove contingent attributes in export error path and on unexport.

Fixes: d8f388d8dc8d ("gpio: sysfs interface")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2: adjust filename, context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 0915e6feb38de8d3601819992a5bd050201a56fa upstream.

The gpio device attributes were never destroyed when the gpio was
unexported (or on export failures).

Use device_create_with_groups() to create the default device attributes
of the gpio class device. Note that this also fixes the
attribute-creation race with userspace for these attributes.

Remove contingent attributes in export error path and on unexport.

Fixes: d8f388d8dc8d ("gpio: sysfs interface")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2: adjust filename, context]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix circular locking dependency (3.3-rc2)</title>
<updated>2015-02-20T00:49:37+00:00</updated>
<author>
<name>Ming Lei</name>
<email>tom.leiming@gmail.com</email>
</author>
<published>2012-02-13T14:53:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2465975fd5538c4cc17778e9622cbffbd2f0b109'/>
<id>2465975fd5538c4cc17778e9622cbffbd2f0b109</id>
<content type='text'>
commit 864533ceb6db336dead389577c102a8b792a121a upstream.

Hi,

On Wed, Feb 8, 2012 at 8:41 PM, Felipe Balbi &lt;balbi@ti.com&gt; wrote:
&gt; Hi guys,
&gt;
&gt; I have just triggered the folllowing:
&gt;
&gt; [   84.860321] ======================================================
&gt; [   84.860321] [ INFO: possible circular locking dependency detected ]
&gt; [   84.860321] 3.3.0-rc2-00026-ge4e8a39 #474 Not tainted
&gt; [   84.860321] -------------------------------------------------------
&gt; [   84.860321] bash/949 is trying to acquire lock:
&gt; [   84.860321]  (sysfs_lock){+.+.+.}, at: [&lt;c0275358&gt;] gpio_value_store+0x24/0xcc
&gt; [   84.860321]
&gt; [   84.860321] but task is already holding lock:
&gt; [   84.860321]  (s_active#22){++++.+}, at: [&lt;c016996c&gt;] sysfs_write_file+0xdc/0x184
&gt; [   84.911468]
&gt; [   84.911468] which lock already depends on the new lock.
&gt; [   84.911468]
&gt; [   84.920043]
&gt; [   84.920043] the existing dependency chain (in reverse order) is:
&gt; [   84.920043]
&gt; [   84.927886] -&gt; #1 (s_active#22){++++.+}:
&gt; [   84.927886]        [&lt;c008f640&gt;] check_prevs_add+0xdc/0x150
&gt; [   84.927886]        [&lt;c008fc18&gt;] validate_chain.clone.24+0x564/0x694
&gt; [   84.927886]        [&lt;c0090cdc&gt;] __lock_acquire+0x49c/0x980
&gt; [   84.951660]        [&lt;c0091838&gt;] lock_acquire+0x98/0x100
&gt; [   84.951660]        [&lt;c016a8e8&gt;] sysfs_deactivate+0xb0/0x100
&gt; [   84.962982]        [&lt;c016b1b4&gt;] sysfs_addrm_finish+0x2c/0x6c
&gt; [   84.962982]        [&lt;c016b8bc&gt;] sysfs_remove_dir+0x84/0x98
&gt; [   84.962982]        [&lt;c02590d8&gt;] kobject_del+0x10/0x78
&gt; [   84.974670]        [&lt;c02c29e8&gt;] device_del+0x140/0x170
&gt; [   84.974670]        [&lt;c02c2a24&gt;] device_unregister+0xc/0x18
&gt; [   84.985382]        [&lt;c0276894&gt;] gpio_unexport+0xbc/0xdc
&gt; [   84.985382]        [&lt;c02768c8&gt;] gpio_free+0x14/0xfc
&gt; [   85.001708]        [&lt;c0276a28&gt;] unexport_store+0x78/0x8c
&gt; [   85.001708]        [&lt;c02c5af8&gt;] class_attr_store+0x18/0x24
&gt; [   85.007293]        [&lt;c0169990&gt;] sysfs_write_file+0x100/0x184
&gt; [   85.018981]        [&lt;c0109d48&gt;] vfs_write+0xb4/0x148
&gt; [   85.018981]        [&lt;c0109fd0&gt;] sys_write+0x40/0x70
&gt; [   85.018981]        [&lt;c0013cc0&gt;] ret_fast_syscall+0x0/0x3c
&gt; [   85.035003]
&gt; [   85.035003] -&gt; #0 (sysfs_lock){+.+.+.}:
&gt; [   85.035003]        [&lt;c008f54c&gt;] check_prev_add+0x680/0x698
&gt; [   85.035003]        [&lt;c008f640&gt;] check_prevs_add+0xdc/0x150
&gt; [   85.052093]        [&lt;c008fc18&gt;] validate_chain.clone.24+0x564/0x694
&gt; [   85.052093]        [&lt;c0090cdc&gt;] __lock_acquire+0x49c/0x980
&gt; [   85.052093]        [&lt;c0091838&gt;] lock_acquire+0x98/0x100
&gt; [   85.069885]        [&lt;c047e280&gt;] mutex_lock_nested+0x3c/0x2f4
&gt; [   85.069885]        [&lt;c0275358&gt;] gpio_value_store+0x24/0xcc
&gt; [   85.069885]        [&lt;c02c18dc&gt;] dev_attr_store+0x18/0x24
&gt; [   85.087158]        [&lt;c0169990&gt;] sysfs_write_file+0x100/0x184
&gt; [   85.087158]        [&lt;c0109d48&gt;] vfs_write+0xb4/0x148
&gt; [   85.098297]        [&lt;c0109fd0&gt;] sys_write+0x40/0x70
&gt; [   85.098297]        [&lt;c0013cc0&gt;] ret_fast_syscall+0x0/0x3c
&gt; [   85.109069]
&gt; [   85.109069] other info that might help us debug this:
&gt; [   85.109069]
&gt; [   85.117462]  Possible unsafe locking scenario:
&gt; [   85.117462]
&gt; [   85.117462]        CPU0                    CPU1
&gt; [   85.128417]        ----                    ----
&gt; [   85.128417]   lock(s_active#22);
&gt; [   85.128417]                                lock(sysfs_lock);
&gt; [   85.128417]                                lock(s_active#22);
&gt; [   85.142486]   lock(sysfs_lock);
&gt; [   85.151794]
&gt; [   85.151794]  *** DEADLOCK ***
&gt; [   85.151794]
&gt; [   85.151794] 2 locks held by bash/949:
&gt; [   85.158020]  #0:  (&amp;buffer-&gt;mutex){+.+.+.}, at: [&lt;c01698b8&gt;] sysfs_write_file+0x28/0x184
&gt; [   85.170349]  #1:  (s_active#22){++++.+}, at: [&lt;c016996c&gt;] sysfs_write_file+0xdc/0x184
&gt; [   85.170349]
&gt; [   85.178588] stack backtrace:
&gt; [   85.178588] [&lt;c001b824&gt;] (unwind_backtrace+0x0/0xf0) from [&lt;c008de64&gt;] (print_circular_bug+0x100/0x114)
&gt; [   85.193023] [&lt;c008de64&gt;] (print_circular_bug+0x100/0x114) from [&lt;c008f54c&gt;] (check_prev_add+0x680/0x698)
&gt; [   85.193023] [&lt;c008f54c&gt;] (check_prev_add+0x680/0x698) from [&lt;c008f640&gt;] (check_prevs_add+0xdc/0x150)
&gt; [   85.212524] [&lt;c008f640&gt;] (check_prevs_add+0xdc/0x150) from [&lt;c008fc18&gt;] (validate_chain.clone.24+0x564/0x694)
&gt; [   85.212524] [&lt;c008fc18&gt;] (validate_chain.clone.24+0x564/0x694) from [&lt;c0090cdc&gt;] (__lock_acquire+0x49c/0x980)
&gt; [   85.233306] [&lt;c0090cdc&gt;] (__lock_acquire+0x49c/0x980) from [&lt;c0091838&gt;] (lock_acquire+0x98/0x100)
&gt; [   85.233306] [&lt;c0091838&gt;] (lock_acquire+0x98/0x100) from [&lt;c047e280&gt;] (mutex_lock_nested+0x3c/0x2f4)
&gt; [   85.242614] [&lt;c047e280&gt;] (mutex_lock_nested+0x3c/0x2f4) from [&lt;c0275358&gt;] (gpio_value_store+0x24/0xcc)
&gt; [   85.261840] [&lt;c0275358&gt;] (gpio_value_store+0x24/0xcc) from [&lt;c02c18dc&gt;] (dev_attr_store+0x18/0x24)
&gt; [   85.261840] [&lt;c02c18dc&gt;] (dev_attr_store+0x18/0x24) from [&lt;c0169990&gt;] (sysfs_write_file+0x100/0x184)
&gt; [   85.271240] [&lt;c0169990&gt;] (sysfs_write_file+0x100/0x184) from [&lt;c0109d48&gt;] (vfs_write+0xb4/0x148)
&gt; [   85.290008] [&lt;c0109d48&gt;] (vfs_write+0xb4/0x148) from [&lt;c0109fd0&gt;] (sys_write+0x40/0x70)
&gt; [   85.298400] [&lt;c0109fd0&gt;] (sys_write+0x40/0x70) from [&lt;c0013cc0&gt;] (ret_fast_syscall+0x0/0x3c)
&gt; -bash: echo: write error: Operation not permitted
&gt;
&gt; the way to trigger is:
&gt;
&gt; root@legolas:~# cd /sys/class/gpio/
&gt; root@legolas:/sys/class/gpio# echo 2 &gt; export
&gt; root@legolas:/sys/class/gpio# echo 2 &gt; unexport
&gt; root@legolas:/sys/class/gpio# echo 2 &gt; export
&gt; root@legolas:/sys/class/gpio# cd gpio2/
&gt; root@legolas:/sys/class/gpio/gpio2# echo 1 &gt; value

Looks 'sysfs_lock' needn't to be held for unregister, so the patch below may
fix the problem.

Acked-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Grant Likely &lt;grant.likely@secretlab.ca&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 864533ceb6db336dead389577c102a8b792a121a upstream.

Hi,

On Wed, Feb 8, 2012 at 8:41 PM, Felipe Balbi &lt;balbi@ti.com&gt; wrote:
&gt; Hi guys,
&gt;
&gt; I have just triggered the folllowing:
&gt;
&gt; [   84.860321] ======================================================
&gt; [   84.860321] [ INFO: possible circular locking dependency detected ]
&gt; [   84.860321] 3.3.0-rc2-00026-ge4e8a39 #474 Not tainted
&gt; [   84.860321] -------------------------------------------------------
&gt; [   84.860321] bash/949 is trying to acquire lock:
&gt; [   84.860321]  (sysfs_lock){+.+.+.}, at: [&lt;c0275358&gt;] gpio_value_store+0x24/0xcc
&gt; [   84.860321]
&gt; [   84.860321] but task is already holding lock:
&gt; [   84.860321]  (s_active#22){++++.+}, at: [&lt;c016996c&gt;] sysfs_write_file+0xdc/0x184
&gt; [   84.911468]
&gt; [   84.911468] which lock already depends on the new lock.
&gt; [   84.911468]
&gt; [   84.920043]
&gt; [   84.920043] the existing dependency chain (in reverse order) is:
&gt; [   84.920043]
&gt; [   84.927886] -&gt; #1 (s_active#22){++++.+}:
&gt; [   84.927886]        [&lt;c008f640&gt;] check_prevs_add+0xdc/0x150
&gt; [   84.927886]        [&lt;c008fc18&gt;] validate_chain.clone.24+0x564/0x694
&gt; [   84.927886]        [&lt;c0090cdc&gt;] __lock_acquire+0x49c/0x980
&gt; [   84.951660]        [&lt;c0091838&gt;] lock_acquire+0x98/0x100
&gt; [   84.951660]        [&lt;c016a8e8&gt;] sysfs_deactivate+0xb0/0x100
&gt; [   84.962982]        [&lt;c016b1b4&gt;] sysfs_addrm_finish+0x2c/0x6c
&gt; [   84.962982]        [&lt;c016b8bc&gt;] sysfs_remove_dir+0x84/0x98
&gt; [   84.962982]        [&lt;c02590d8&gt;] kobject_del+0x10/0x78
&gt; [   84.974670]        [&lt;c02c29e8&gt;] device_del+0x140/0x170
&gt; [   84.974670]        [&lt;c02c2a24&gt;] device_unregister+0xc/0x18
&gt; [   84.985382]        [&lt;c0276894&gt;] gpio_unexport+0xbc/0xdc
&gt; [   84.985382]        [&lt;c02768c8&gt;] gpio_free+0x14/0xfc
&gt; [   85.001708]        [&lt;c0276a28&gt;] unexport_store+0x78/0x8c
&gt; [   85.001708]        [&lt;c02c5af8&gt;] class_attr_store+0x18/0x24
&gt; [   85.007293]        [&lt;c0169990&gt;] sysfs_write_file+0x100/0x184
&gt; [   85.018981]        [&lt;c0109d48&gt;] vfs_write+0xb4/0x148
&gt; [   85.018981]        [&lt;c0109fd0&gt;] sys_write+0x40/0x70
&gt; [   85.018981]        [&lt;c0013cc0&gt;] ret_fast_syscall+0x0/0x3c
&gt; [   85.035003]
&gt; [   85.035003] -&gt; #0 (sysfs_lock){+.+.+.}:
&gt; [   85.035003]        [&lt;c008f54c&gt;] check_prev_add+0x680/0x698
&gt; [   85.035003]        [&lt;c008f640&gt;] check_prevs_add+0xdc/0x150
&gt; [   85.052093]        [&lt;c008fc18&gt;] validate_chain.clone.24+0x564/0x694
&gt; [   85.052093]        [&lt;c0090cdc&gt;] __lock_acquire+0x49c/0x980
&gt; [   85.052093]        [&lt;c0091838&gt;] lock_acquire+0x98/0x100
&gt; [   85.069885]        [&lt;c047e280&gt;] mutex_lock_nested+0x3c/0x2f4
&gt; [   85.069885]        [&lt;c0275358&gt;] gpio_value_store+0x24/0xcc
&gt; [   85.069885]        [&lt;c02c18dc&gt;] dev_attr_store+0x18/0x24
&gt; [   85.087158]        [&lt;c0169990&gt;] sysfs_write_file+0x100/0x184
&gt; [   85.087158]        [&lt;c0109d48&gt;] vfs_write+0xb4/0x148
&gt; [   85.098297]        [&lt;c0109fd0&gt;] sys_write+0x40/0x70
&gt; [   85.098297]        [&lt;c0013cc0&gt;] ret_fast_syscall+0x0/0x3c
&gt; [   85.109069]
&gt; [   85.109069] other info that might help us debug this:
&gt; [   85.109069]
&gt; [   85.117462]  Possible unsafe locking scenario:
&gt; [   85.117462]
&gt; [   85.117462]        CPU0                    CPU1
&gt; [   85.128417]        ----                    ----
&gt; [   85.128417]   lock(s_active#22);
&gt; [   85.128417]                                lock(sysfs_lock);
&gt; [   85.128417]                                lock(s_active#22);
&gt; [   85.142486]   lock(sysfs_lock);
&gt; [   85.151794]
&gt; [   85.151794]  *** DEADLOCK ***
&gt; [   85.151794]
&gt; [   85.151794] 2 locks held by bash/949:
&gt; [   85.158020]  #0:  (&amp;buffer-&gt;mutex){+.+.+.}, at: [&lt;c01698b8&gt;] sysfs_write_file+0x28/0x184
&gt; [   85.170349]  #1:  (s_active#22){++++.+}, at: [&lt;c016996c&gt;] sysfs_write_file+0xdc/0x184
&gt; [   85.170349]
&gt; [   85.178588] stack backtrace:
&gt; [   85.178588] [&lt;c001b824&gt;] (unwind_backtrace+0x0/0xf0) from [&lt;c008de64&gt;] (print_circular_bug+0x100/0x114)
&gt; [   85.193023] [&lt;c008de64&gt;] (print_circular_bug+0x100/0x114) from [&lt;c008f54c&gt;] (check_prev_add+0x680/0x698)
&gt; [   85.193023] [&lt;c008f54c&gt;] (check_prev_add+0x680/0x698) from [&lt;c008f640&gt;] (check_prevs_add+0xdc/0x150)
&gt; [   85.212524] [&lt;c008f640&gt;] (check_prevs_add+0xdc/0x150) from [&lt;c008fc18&gt;] (validate_chain.clone.24+0x564/0x694)
&gt; [   85.212524] [&lt;c008fc18&gt;] (validate_chain.clone.24+0x564/0x694) from [&lt;c0090cdc&gt;] (__lock_acquire+0x49c/0x980)
&gt; [   85.233306] [&lt;c0090cdc&gt;] (__lock_acquire+0x49c/0x980) from [&lt;c0091838&gt;] (lock_acquire+0x98/0x100)
&gt; [   85.233306] [&lt;c0091838&gt;] (lock_acquire+0x98/0x100) from [&lt;c047e280&gt;] (mutex_lock_nested+0x3c/0x2f4)
&gt; [   85.242614] [&lt;c047e280&gt;] (mutex_lock_nested+0x3c/0x2f4) from [&lt;c0275358&gt;] (gpio_value_store+0x24/0xcc)
&gt; [   85.261840] [&lt;c0275358&gt;] (gpio_value_store+0x24/0xcc) from [&lt;c02c18dc&gt;] (dev_attr_store+0x18/0x24)
&gt; [   85.261840] [&lt;c02c18dc&gt;] (dev_attr_store+0x18/0x24) from [&lt;c0169990&gt;] (sysfs_write_file+0x100/0x184)
&gt; [   85.271240] [&lt;c0169990&gt;] (sysfs_write_file+0x100/0x184) from [&lt;c0109d48&gt;] (vfs_write+0xb4/0x148)
&gt; [   85.290008] [&lt;c0109d48&gt;] (vfs_write+0xb4/0x148) from [&lt;c0109fd0&gt;] (sys_write+0x40/0x70)
&gt; [   85.298400] [&lt;c0109fd0&gt;] (sys_write+0x40/0x70) from [&lt;c0013cc0&gt;] (ret_fast_syscall+0x0/0x3c)
&gt; -bash: echo: write error: Operation not permitted
&gt;
&gt; the way to trigger is:
&gt;
&gt; root@legolas:~# cd /sys/class/gpio/
&gt; root@legolas:/sys/class/gpio# echo 2 &gt; export
&gt; root@legolas:/sys/class/gpio# echo 2 &gt; unexport
&gt; root@legolas:/sys/class/gpio# echo 2 &gt; export
&gt; root@legolas:/sys/class/gpio# cd gpio2/
&gt; root@legolas:/sys/class/gpio/gpio2# echo 1 &gt; value

Looks 'sysfs_lock' needn't to be held for unregister, so the patch below may
fix the problem.

Acked-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Grant Likely &lt;grant.likely@secretlab.ca&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpiolib: Refactor gpio_export</title>
<updated>2015-02-20T00:49:37+00:00</updated>
<author>
<name>Ryan Mallon</name>
<email>rmallon@gmail.com</email>
</author>
<published>2012-10-22T00:39:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0bebb361e467ab9d9a790523fede2f32272444d9'/>
<id>0bebb361e467ab9d9a790523fede2f32272444d9</id>
<content type='text'>
commit fc4e2514995d9cd7f3e1a67098ce65d72acf8ec7 upstream.

The gpio_export function uses nested if statements and the status
variable to handle the failure cases. This makes the function logic
difficult to follow. Refactor the code to abort immediately on failure
using goto. This makes the code slightly longer, but significantly
reduces the nesting and number of split lines and makes the code easier
to read.

Signed-off-by: Ryan Mallon &lt;rmallon@gmail.com&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit fc4e2514995d9cd7f3e1a67098ce65d72acf8ec7 upstream.

The gpio_export function uses nested if statements and the status
variable to handle the failure cases. This makes the function logic
difficult to follow. Refactor the code to abort immediately on failure
using goto. This makes the code slightly longer, but significantly
reduces the nesting and number of split lines and makes the code easier
to read.

Signed-off-by: Ryan Mallon &lt;rmallon@gmail.com&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: sysfs: fix gpio-chip device-attribute leak</title>
<updated>2015-02-20T00:49:37+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-01-13T12:00:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=6f7c3121580136cfcdfb07cf9d3f6f81d78d39dc'/>
<id>6f7c3121580136cfcdfb07cf9d3f6f81d78d39dc</id>
<content type='text'>
commit 121b6a79955a3a3fd7bbb9b8cb88d5b9dad6283d upstream.

The gpio-chip device attributes were never destroyed when the device was
removed.

Fix by using device_create_with_groups() to create the device attributes
of the chip class device.

Note that this also fixes the attribute-creation race with userspace.

Fixes: d8f388d8dc8d ("gpio: sysfs interface")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 121b6a79955a3a3fd7bbb9b8cb88d5b9dad6283d upstream.

The gpio-chip device attributes were never destroyed when the device was
removed.

Fix by using device_create_with_groups() to create the device attributes
of the chip class device.

Note that this also fixes the attribute-creation race with userspace.

Fixes: d8f388d8dc8d ("gpio: sysfs interface")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: fix memory and reference leaks in gpiochip_add error path</title>
<updated>2015-02-20T00:49:37+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2015-01-12T16:12:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=d0411190377b3276a1fd573e6ef3802acbb899ea'/>
<id>d0411190377b3276a1fd573e6ef3802acbb899ea</id>
<content type='text'>
commit 5539b3c938d64a60cb1fc442ac3ce9263d52de0c upstream.

Memory allocated and references taken by of_gpiochip_add and
acpi_gpiochip_add were never released on errors in gpiochip_add (e.g.
failure to find free gpio range).

Fixes: 391c970c0dd1 ("of/gpio: add default of_xlate function if device
has a node pointer")
Fixes: 664e3e5ac64c ("gpio / ACPI: register to ACPI events
automatically")

Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2:
 - Move call to of_gpiochip_add() into conditional section rather
   than rearranging gotos and labels which are in different places
   here
 - There's no ACPI support]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 5539b3c938d64a60cb1fc442ac3ce9263d52de0c upstream.

Memory allocated and references taken by of_gpiochip_add and
acpi_gpiochip_add were never released on errors in gpiochip_add (e.g.
failure to find free gpio range).

Fixes: 391c970c0dd1 ("of/gpio: add default of_xlate function if device
has a node pointer")
Fixes: 664e3e5ac64c ("gpio / ACPI: register to ACPI events
automatically")

Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
[bwh: Backported to 3.2:
 - Move call to of_gpiochip_add() into conditional section rather
   than rearranging gotos and labels which are in different places
   here
 - There's no ACPI support]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: mxs: Allow for recursive enable_irq_wake() call</title>
<updated>2014-04-30T15:23:23+00:00</updated>
<author>
<name>Marek Vasut</name>
<email>marex@denx.de</email>
</author>
<published>2014-03-24T02:38:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4f86b545ffcdea19ea644920e84d644cf2e6b1e8'/>
<id>4f86b545ffcdea19ea644920e84d644cf2e6b1e8</id>
<content type='text'>
commit a585f87c863e4e1d496459d382b802bf5ebe3717 upstream.

The scenario here is that someone calls enable_irq_wake() from somewhere
in the code. This will result in the lockdep producing a backtrace as can
be seen below. In my case, this problem is triggered when using the wl1271
(TI WlCore) driver found in drivers/net/wireless/ti/ .

The problem cause is rather obvious from the backtrace, but let's outline
the dependency. enable_irq_wake() grabs the IRQ buslock in irq_set_irq_wake(),
which in turns calls mxs_gpio_set_wake_irq() . But mxs_gpio_set_wake_irq()
calls enable_irq_wake() again on the one-level-higher IRQ , thus it tries to
grab the IRQ buslock again in irq_set_irq_wake() . Because the spinlock in
irq_set_irq_wake()-&gt;irq_get_desc_buslock()-&gt;__irq_get_desc_lock() is not
marked as recursive, lockdep will spew the stuff below.

We know we can safely re-enter the lock, so use IRQ_GC_INIT_NESTED_LOCK to
fix the spew.

 =============================================
 [ INFO: possible recursive locking detected ]
 3.10.33-00012-gf06b763-dirty #61 Not tainted
 ---------------------------------------------
 kworker/0:1/18 is trying to acquire lock:
  (&amp;irq_desc_lock_class){-.-...}, at: [&lt;c00685f0&gt;] __irq_get_desc_lock+0x48/0x88

 but task is already holding lock:
  (&amp;irq_desc_lock_class){-.-...}, at: [&lt;c00685f0&gt;] __irq_get_desc_lock+0x48/0x88

 other info that might help us debug this:
  Possible unsafe locking scenario:

        CPU0
        ----
   lock(&amp;irq_desc_lock_class);
   lock(&amp;irq_desc_lock_class);

  *** DEADLOCK ***

  May be due to missing lock nesting notation

 3 locks held by kworker/0:1/18:
  #0:  (events){.+.+.+}, at: [&lt;c0036308&gt;] process_one_work+0x134/0x4a4
  #1:  ((&amp;fw_work-&gt;work)){+.+.+.}, at: [&lt;c0036308&gt;] process_one_work+0x134/0x4a4
  #2:  (&amp;irq_desc_lock_class){-.-...}, at: [&lt;c00685f0&gt;] __irq_get_desc_lock+0x48/0x88

 stack backtrace:
 CPU: 0 PID: 18 Comm: kworker/0:1 Not tainted 3.10.33-00012-gf06b763-dirty #61
 Workqueue: events request_firmware_work_func
 [&lt;c0013eb4&gt;] (unwind_backtrace+0x0/0xf0) from [&lt;c0011c74&gt;] (show_stack+0x10/0x14)
 [&lt;c0011c74&gt;] (show_stack+0x10/0x14) from [&lt;c005bb08&gt;] (__lock_acquire+0x140c/0x1a64)
 [&lt;c005bb08&gt;] (__lock_acquire+0x140c/0x1a64) from [&lt;c005c6a8&gt;] (lock_acquire+0x9c/0x104)
 [&lt;c005c6a8&gt;] (lock_acquire+0x9c/0x104) from [&lt;c051d5a4&gt;] (_raw_spin_lock_irqsave+0x44/0x58)
 [&lt;c051d5a4&gt;] (_raw_spin_lock_irqsave+0x44/0x58) from [&lt;c00685f0&gt;] (__irq_get_desc_lock+0x48/0x88)
 [&lt;c00685f0&gt;] (__irq_get_desc_lock+0x48/0x88) from [&lt;c0068e78&gt;] (irq_set_irq_wake+0x20/0xf4)
 [&lt;c0068e78&gt;] (irq_set_irq_wake+0x20/0xf4) from [&lt;c027260c&gt;] (mxs_gpio_set_wake_irq+0x1c/0x24)
 [&lt;c027260c&gt;] (mxs_gpio_set_wake_irq+0x1c/0x24) from [&lt;c0068cf4&gt;] (set_irq_wake_real+0x30/0x44)
 [&lt;c0068cf4&gt;] (set_irq_wake_real+0x30/0x44) from [&lt;c0068ee4&gt;] (irq_set_irq_wake+0x8c/0xf4)
 [&lt;c0068ee4&gt;] (irq_set_irq_wake+0x8c/0xf4) from [&lt;c0310748&gt;] (wlcore_nvs_cb+0x10c/0x97c)
 [&lt;c0310748&gt;] (wlcore_nvs_cb+0x10c/0x97c) from [&lt;c02be5e8&gt;] (request_firmware_work_func+0x38/0x58)
 [&lt;c02be5e8&gt;] (request_firmware_work_func+0x38/0x58) from [&lt;c0036394&gt;] (process_one_work+0x1c0/0x4a4)
 [&lt;c0036394&gt;] (process_one_work+0x1c0/0x4a4) from [&lt;c0036a4c&gt;] (worker_thread+0x138/0x394)
 [&lt;c0036a4c&gt;] (worker_thread+0x138/0x394) from [&lt;c003cb74&gt;] (kthread+0xa4/0xb0)
 [&lt;c003cb74&gt;] (kthread+0xa4/0xb0) from [&lt;c000ee00&gt;] (ret_from_fork+0x14/0x34)
 wlcore: loaded

Signed-off-by: Marek Vasut &lt;marex@denx.de&gt;
Acked-by: Shawn Guo &lt;shawn.guo@linaro.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit a585f87c863e4e1d496459d382b802bf5ebe3717 upstream.

The scenario here is that someone calls enable_irq_wake() from somewhere
in the code. This will result in the lockdep producing a backtrace as can
be seen below. In my case, this problem is triggered when using the wl1271
(TI WlCore) driver found in drivers/net/wireless/ti/ .

The problem cause is rather obvious from the backtrace, but let's outline
the dependency. enable_irq_wake() grabs the IRQ buslock in irq_set_irq_wake(),
which in turns calls mxs_gpio_set_wake_irq() . But mxs_gpio_set_wake_irq()
calls enable_irq_wake() again on the one-level-higher IRQ , thus it tries to
grab the IRQ buslock again in irq_set_irq_wake() . Because the spinlock in
irq_set_irq_wake()-&gt;irq_get_desc_buslock()-&gt;__irq_get_desc_lock() is not
marked as recursive, lockdep will spew the stuff below.

We know we can safely re-enter the lock, so use IRQ_GC_INIT_NESTED_LOCK to
fix the spew.

 =============================================
 [ INFO: possible recursive locking detected ]
 3.10.33-00012-gf06b763-dirty #61 Not tainted
 ---------------------------------------------
 kworker/0:1/18 is trying to acquire lock:
  (&amp;irq_desc_lock_class){-.-...}, at: [&lt;c00685f0&gt;] __irq_get_desc_lock+0x48/0x88

 but task is already holding lock:
  (&amp;irq_desc_lock_class){-.-...}, at: [&lt;c00685f0&gt;] __irq_get_desc_lock+0x48/0x88

 other info that might help us debug this:
  Possible unsafe locking scenario:

        CPU0
        ----
   lock(&amp;irq_desc_lock_class);
   lock(&amp;irq_desc_lock_class);

  *** DEADLOCK ***

  May be due to missing lock nesting notation

 3 locks held by kworker/0:1/18:
  #0:  (events){.+.+.+}, at: [&lt;c0036308&gt;] process_one_work+0x134/0x4a4
  #1:  ((&amp;fw_work-&gt;work)){+.+.+.}, at: [&lt;c0036308&gt;] process_one_work+0x134/0x4a4
  #2:  (&amp;irq_desc_lock_class){-.-...}, at: [&lt;c00685f0&gt;] __irq_get_desc_lock+0x48/0x88

 stack backtrace:
 CPU: 0 PID: 18 Comm: kworker/0:1 Not tainted 3.10.33-00012-gf06b763-dirty #61
 Workqueue: events request_firmware_work_func
 [&lt;c0013eb4&gt;] (unwind_backtrace+0x0/0xf0) from [&lt;c0011c74&gt;] (show_stack+0x10/0x14)
 [&lt;c0011c74&gt;] (show_stack+0x10/0x14) from [&lt;c005bb08&gt;] (__lock_acquire+0x140c/0x1a64)
 [&lt;c005bb08&gt;] (__lock_acquire+0x140c/0x1a64) from [&lt;c005c6a8&gt;] (lock_acquire+0x9c/0x104)
 [&lt;c005c6a8&gt;] (lock_acquire+0x9c/0x104) from [&lt;c051d5a4&gt;] (_raw_spin_lock_irqsave+0x44/0x58)
 [&lt;c051d5a4&gt;] (_raw_spin_lock_irqsave+0x44/0x58) from [&lt;c00685f0&gt;] (__irq_get_desc_lock+0x48/0x88)
 [&lt;c00685f0&gt;] (__irq_get_desc_lock+0x48/0x88) from [&lt;c0068e78&gt;] (irq_set_irq_wake+0x20/0xf4)
 [&lt;c0068e78&gt;] (irq_set_irq_wake+0x20/0xf4) from [&lt;c027260c&gt;] (mxs_gpio_set_wake_irq+0x1c/0x24)
 [&lt;c027260c&gt;] (mxs_gpio_set_wake_irq+0x1c/0x24) from [&lt;c0068cf4&gt;] (set_irq_wake_real+0x30/0x44)
 [&lt;c0068cf4&gt;] (set_irq_wake_real+0x30/0x44) from [&lt;c0068ee4&gt;] (irq_set_irq_wake+0x8c/0xf4)
 [&lt;c0068ee4&gt;] (irq_set_irq_wake+0x8c/0xf4) from [&lt;c0310748&gt;] (wlcore_nvs_cb+0x10c/0x97c)
 [&lt;c0310748&gt;] (wlcore_nvs_cb+0x10c/0x97c) from [&lt;c02be5e8&gt;] (request_firmware_work_func+0x38/0x58)
 [&lt;c02be5e8&gt;] (request_firmware_work_func+0x38/0x58) from [&lt;c0036394&gt;] (process_one_work+0x1c0/0x4a4)
 [&lt;c0036394&gt;] (process_one_work+0x1c0/0x4a4) from [&lt;c0036a4c&gt;] (worker_thread+0x138/0x394)
 [&lt;c0036a4c&gt;] (worker_thread+0x138/0x394) from [&lt;c003cb74&gt;] (kthread+0xa4/0xb0)
 [&lt;c003cb74&gt;] (kthread+0xa4/0xb0) from [&lt;c000ee00&gt;] (ret_from_fork+0x14/0x34)
 wlcore: loaded

Signed-off-by: Marek Vasut &lt;marex@denx.de&gt;
Acked-by: Shawn Guo &lt;shawn.guo@linaro.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: msm: Fix irq mask/unmask by writing bits instead of numbers</title>
<updated>2014-02-15T19:20:13+00:00</updated>
<author>
<name>Stephen Boyd</name>
<email>sboyd@codeaurora.org</email>
</author>
<published>2013-12-10T23:19:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=50226b9992e79d43579b92650ecbfdbc1479980c'/>
<id>50226b9992e79d43579b92650ecbfdbc1479980c</id>
<content type='text'>
commit 4cc629b7a20945ce35628179180329b6bc9e552b upstream.

We should be writing bits here but instead we're writing the
numbers that correspond to the bits we want to write. Fix it by
wrapping the numbers in the BIT() macro. This fixes gpios acting
as interrupts.

Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 4cc629b7a20945ce35628179180329b6bc9e552b upstream.

We should be writing bits here but instead we're writing the
numbers that correspond to the bits we want to write. Fix it by
wrapping the numbers in the BIT() macro. This fixes gpios acting
as interrupts.

Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</pre>
</div>
</content>
</entry>
</feed>
