<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/mmc/host, branch linux-3.10.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>mmc: sdhci: Do not disable interrupts while waiting for clock</title>
<updated>2017-06-20T12:04:35+00:00</updated>
<author>
<name>Adrian Hunter</name>
<email>adrian.hunter@intel.com</email>
</author>
<published>2017-03-20T17:50:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=ecf229c3de27f918fede7409aaf4cbde471ecb27'/>
<id>ecf229c3de27f918fede7409aaf4cbde471ecb27</id>
<content type='text'>
commit e2ebfb2142acefecc2496e71360f50d25726040b upstream.

Disabling interrupts for even a millisecond can cause problems for some
devices. That can happen when sdhci changes clock frequency because it
waits for the clock to become stable under a spin lock.

The spin lock is not necessary here. Anything that is racing with changes
to the I/O state is already broken. The mmc core already provides
synchronization via "claiming" the host.

Although the spin lock probably should be removed from the code paths that
lead to this point, such a patch would touch too much code to be suitable
for stable trees. Consequently, for this patch, just drop the spin lock
while waiting.

Signed-off-by: Adrian Hunter &lt;adrian.hunter@intel.com&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Tested-by: Ludovic Desroches &lt;ludovic.desroches@microchip.com&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit e2ebfb2142acefecc2496e71360f50d25726040b upstream.

Disabling interrupts for even a millisecond can cause problems for some
devices. That can happen when sdhci changes clock frequency because it
waits for the clock to become stable under a spin lock.

The spin lock is not necessary here. Anything that is racing with changes
to the I/O state is already broken. The mmc core already provides
synchronization via "claiming" the host.

Although the spin lock probably should be removed from the code paths that
lead to this point, such a patch would touch too much code to be suitable
for stable trees. Consequently, for this patch, just drop the spin lock
while waiting.

Signed-off-by: Adrian Hunter &lt;adrian.hunter@intel.com&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Tested-by: Ludovic Desroches &lt;ludovic.desroches@microchip.com&gt;
Signed-off-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mmc: ushc: fix NULL-deref at probe</title>
<updated>2017-06-07T22:47:05+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2017-03-13T12:40:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=e32d76a4d5e7d4fe3bf50c248a16163a5d1847c4'/>
<id>e32d76a4d5e7d4fe3bf50c248a16163a5d1847c4</id>
<content type='text'>
commit 181302dc7239add8ab1449c23ecab193f52ee6ab upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer should a malicious device lack endpoints.

Fixes: 53f3a9e26ed5 ("mmc: USB SD Host Controller (USHC) driver")
Cc: David Vrabel &lt;david.vrabel@csr.com&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 181302dc7239add8ab1449c23ecab193f52ee6ab upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer should a malicious device lack endpoints.

Fixes: 53f3a9e26ed5 ("mmc: USB SD Host Controller (USHC) driver")
Cc: David Vrabel &lt;david.vrabel@csr.com&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mmc: mxs-mmc: Fix additional cycles after transmission stop</title>
<updated>2017-06-07T22:46:56+00:00</updated>
<author>
<name>Stefan Wahren</name>
<email>stefan.wahren@i2se.com</email>
</author>
<published>2017-01-05T19:24:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=8bc899e505b6b346acbd6b116abb9a183af64bfc'/>
<id>8bc899e505b6b346acbd6b116abb9a183af64bfc</id>
<content type='text'>
commit 01167c7b9cbf099c69fe411a228e4e9c7104e123 upstream.

According to the code the intention is to append 8 SCK cycles
instead of 4 at end of a MMC_STOP_TRANSMISSION command. But this
will never happened because it's an AC command not an ADTC command.
So fix this by moving the statement into the right function.

Signed-off-by: Stefan Wahren &lt;stefan.wahren@i2se.com&gt;
Fixes: e4243f13d10e (mmc: mxs-mmc: add mmc host driver for i.MX23/28)
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 01167c7b9cbf099c69fe411a228e4e9c7104e123 upstream.

According to the code the intention is to append 8 SCK cycles
instead of 4 at end of a MMC_STOP_TRANSMISSION command. But this
will never happened because it's an AC command not an ADTC command.
So fix this by moving the statement into the right function.

Signed-off-by: Stefan Wahren &lt;stefan.wahren@i2se.com&gt;
Fixes: e4243f13d10e (mmc: mxs-mmc: add mmc host driver for i.MX23/28)
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mmc: mxs: Initialize the spinlock prior to using it</title>
<updated>2017-02-10T10:04:01+00:00</updated>
<author>
<name>Fabio Estevam</name>
<email>fabio.estevam@nxp.com</email>
</author>
<published>2016-11-05T19:45:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=0d9dddc0b582237e0e8afa19f83a3844fa9a846e'/>
<id>0d9dddc0b582237e0e8afa19f83a3844fa9a846e</id>
<content type='text'>
commit f91346e8b5f46aaf12f1df26e87140584ffd1b3f upstream.

An interrupt may occur right after devm_request_irq() is called and
prior to the spinlock initialization, leading to a kernel oops,
as the interrupt handler uses the spinlock.

In order to prevent this problem, move the spinlock initialization
prior to requesting the interrupts.

Fixes: e4243f13d10e (mmc: mxs-mmc: add mmc host driver for i.MX23/28)
Signed-off-by: Fabio Estevam &lt;fabio.estevam@nxp.com&gt;
Reviewed-by: Marek Vasut &lt;marex@denx.de&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit f91346e8b5f46aaf12f1df26e87140584ffd1b3f upstream.

An interrupt may occur right after devm_request_irq() is called and
prior to the spinlock initialization, leading to a kernel oops,
as the interrupt handler uses the spinlock.

In order to prevent this problem, move the spinlock initialization
prior to requesting the interrupts.

Fixes: e4243f13d10e (mmc: mxs-mmc: add mmc host driver for i.MX23/28)
Signed-off-by: Fabio Estevam &lt;fabio.estevam@nxp.com&gt;
Reviewed-by: Marek Vasut &lt;marex@denx.de&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Willy Tarreau &lt;w@1wt.eu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>mmc: mmci: fix an ages old detection error</title>
<updated>2016-03-03T23:06:23+00:00</updated>
<author>
<name>Linus Walleij</name>
<email>linus.walleij@linaro.org</email>
</author>
<published>2016-01-04T01:21:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=bf64271c53bfc54deeebf7ffa69d2df03ae58cf5'/>
<id>bf64271c53bfc54deeebf7ffa69d2df03ae58cf5</id>
<content type='text'>
commit 0bcb7efdff63564e80fe84dd36a9fbdfbf6697a4 upstream.

commit 4956e10903fd ("ARM: 6244/1: mmci: add variant data and default
MCICLOCK support") added variant data for ARM, U300 and Ux500 variants.
The Nomadik NHK8815/8820 variant was erroneously labeled as a U300
variant, and when the proper Nomadik variant was later introduced in
commit 34fd421349ff ("ARM: 7378/1: mmci: add support for the Nomadik MMCI
variant") this was not fixes. Let's say this fixes the latter commit as
there was no proper Nomadik support until then.

Fixes: 34fd421349ff ("ARM: 7378/1: mmci: add support for the Nomadik...")
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 0bcb7efdff63564e80fe84dd36a9fbdfbf6697a4 upstream.

commit 4956e10903fd ("ARM: 6244/1: mmci: add variant data and default
MCICLOCK support") added variant data for ARM, U300 and Ux500 variants.
The Nomadik NHK8815/8820 variant was erroneously labeled as a U300
variant, and when the proper Nomadik variant was later introduced in
commit 34fd421349ff ("ARM: 7378/1: mmci: add support for the Nomadik MMCI
variant") this was not fixes. Let's say this fixes the latter commit as
there was no proper Nomadik support until then.

Fixes: 34fd421349ff ("ARM: 7378/1: mmci: add support for the Nomadik...")
Signed-off-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>mmc: sdhci-pxav3: fix platform_data is not initialized</title>
<updated>2015-08-10T19:20:30+00:00</updated>
<author>
<name>Jingju Hou</name>
<email>houjingj@marvell.com</email>
</author>
<published>2015-07-23T09:56:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=4713a3a3be8e81eddf2b4ab552e913b0a1cfaddf'/>
<id>4713a3a3be8e81eddf2b4ab552e913b0a1cfaddf</id>
<content type='text'>
commit 9cd76049f0d90ae241f5ad80e311489824527000 upstream.

pdev-&gt;dev.platform_data is not initialized if match is true in function
sdhci_pxav3_probe. Just local variable pdata is assigned the return value
from function pxav3_get_mmc_pdata().

static int sdhci_pxav3_probe(struct platform_device *pdev) {

    struct sdhci_pxa_platdata *pdata = pdev-&gt;dev.platform_data;
    ...
    if (match) {
		ret = mmc_of_parse(host-&gt;mmc);
		if (ret)
			goto err_of_parse;
		sdhci_get_of_property(pdev);
		pdata = pxav3_get_mmc_pdata(dev);
     }
     ...
}

Signed-off-by: Jingju Hou &lt;houjingj@marvell.com&gt;
Fixes: b650352dd3df("mmc: sdhci-pxa: Add device tree support")
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 9cd76049f0d90ae241f5ad80e311489824527000 upstream.

pdev-&gt;dev.platform_data is not initialized if match is true in function
sdhci_pxav3_probe. Just local variable pdata is assigned the return value
from function pxav3_get_mmc_pdata().

static int sdhci_pxav3_probe(struct platform_device *pdev) {

    struct sdhci_pxa_platdata *pdata = pdev-&gt;dev.platform_data;
    ...
    if (match) {
		ret = mmc_of_parse(host-&gt;mmc);
		if (ret)
			goto err_of_parse;
		sdhci_get_of_property(pdev);
		pdata = pxav3_get_mmc_pdata(dev);
     }
     ...
}

Signed-off-by: Jingju Hou &lt;houjingj@marvell.com&gt;
Fixes: b650352dd3df("mmc: sdhci-pxa: Add device tree support")
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>mmc: sdhci-esdhc: Make 8BIT bus work</title>
<updated>2015-08-10T19:20:30+00:00</updated>
<author>
<name>Joakim Tjernlund</name>
<email>Joakim.Tjernlund@transmode.se</email>
</author>
<published>2015-07-22T14:44:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=04c6708522d382d8961214ceceed2052647f70c2'/>
<id>04c6708522d382d8961214ceceed2052647f70c2</id>
<content type='text'>
commit 8e91125ff3f57f15c6568e2a6d32743b3f7815e4 upstream.

Support for 8BIT bus with was added some time ago to sdhci-esdhc but
then missed to remove the 8BIT from the reserved bit mask which made
8BIT non functional.

Fixes: 66b50a00992d ("mmc: esdhc: Add support for 8-bit bus width and..")
Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@transmode.se&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 8e91125ff3f57f15c6568e2a6d32743b3f7815e4 upstream.

Support for 8BIT bus with was added some time ago to sdhci-esdhc but
then missed to remove the 8BIT from the reserved bit mask which made
8BIT non functional.

Fixes: 66b50a00992d ("mmc: esdhc: Add support for 8-bit bus width and..")
Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@transmode.se&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>mmc: atmel-mci: fix bad variable type for clkdiv</title>
<updated>2015-06-06T06:19:57+00:00</updated>
<author>
<name>Ludovic Desroches</name>
<email>ludovic.desroches@atmel.com</email>
</author>
<published>2015-05-06T13:16:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=a72719d75d8e30203d8624465215072b74be30e7'/>
<id>a72719d75d8e30203d8624465215072b74be30e7</id>
<content type='text'>
commit 60c8f783a18feb95ad967c87e9660caf09fb4700 upstream.

clkdiv is declared as an u32 but it can be set to a negative value
causing a huge divisor value. Change its type to int to avoid this case.

Signed-off-by: Ludovic Desroches &lt;ludovic.desroches@atmel.com&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 60c8f783a18feb95ad967c87e9660caf09fb4700 upstream.

clkdiv is declared as an u32 but it can be set to a negative value
causing a huge divisor value. Change its type to int to avoid this case.

Signed-off-by: Ludovic Desroches &lt;ludovic.desroches@atmel.com&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>mmc: sdhci-pxav3: fix setting of pdata-&gt;clk_delay_cycles</title>
<updated>2015-03-06T22:40:49+00:00</updated>
<author>
<name>Jisheng Zhang</name>
<email>jszhang@marvell.com</email>
</author>
<published>2015-01-28T11:54:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=5d37544fb1dedda1974bf406c0033bbbfa5944af'/>
<id>5d37544fb1dedda1974bf406c0033bbbfa5944af</id>
<content type='text'>
commit 14460dbaf7a5a0488963fdb8232ad5c8a8cca7b7 upstream.

Current code checks "clk_delay_cycles &gt; 0" to know whether the optional
"mrvl,clk_delay_cycles" is set or not. But of_property_read_u32() doesn't
touch clk_delay_cycles if the property is not set. And type of
clk_delay_cycles is u32, so we may always set pdata-&gt;clk_delay_cycles as a
random value.

This patch fix this problem by check the return value of of_property_read_u32()
to know whether the optional clk-delay-cycles is set or not.

Signed-off-by: Jisheng Zhang &lt;jszhang@marvell.com&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 14460dbaf7a5a0488963fdb8232ad5c8a8cca7b7 upstream.

Current code checks "clk_delay_cycles &gt; 0" to know whether the optional
"mrvl,clk_delay_cycles" is set or not. But of_property_read_u32() doesn't
touch clk_delay_cycles if the property is not set. And type of
clk_delay_cycles is u32, so we may always set pdata-&gt;clk_delay_cycles as a
random value.

This patch fix this problem by check the return value of of_property_read_u32()
to know whether the optional clk-delay-cycles is set or not.

Signed-off-by: Jisheng Zhang &lt;jszhang@marvell.com&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>mmc: sdhci: Fix sleep in atomic after inserting SD card</title>
<updated>2015-01-27T15:52:33+00:00</updated>
<author>
<name>Krzysztof Kozlowski</name>
<email>k.kozlowski@samsung.com</email>
</author>
<published>2015-01-05T09:50:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=34a322c73ac589947e5daf84375da23e1babd657'/>
<id>34a322c73ac589947e5daf84375da23e1babd657</id>
<content type='text'>
commit 2836766a9d0bd02c66073f8dd44796e6cc23848d upstream.

Sleep in atomic context happened on Trats2 board after inserting or
removing SD card because mmc_gpio_get_cd() was called under spin lock.

Fix this by moving card detection earlier, before acquiring spin lock.
The mmc_gpio_get_cd() call does not have to be protected by spin lock
because it does not access any sdhci internal data.
The sdhci_do_get_cd() call access host flags (SDHCI_DEVICE_DEAD). After
moving it out side of spin lock it could theoretically race with driver
removal but still there is no actual protection against manual card
eject.

Dmesg after inserting SD card:
[   41.663414] BUG: sleeping function called from invalid context at drivers/gpio/gpiolib.c:1511
[   41.670469] in_atomic(): 1, irqs_disabled(): 128, pid: 30, name: kworker/u8:1
[   41.677580] INFO: lockdep is turned off.
[   41.681486] irq event stamp: 61972
[   41.684872] hardirqs last  enabled at (61971): [&lt;c0490ee0&gt;] _raw_spin_unlock_irq+0x24/0x5c
[   41.693118] hardirqs last disabled at (61972): [&lt;c04907ac&gt;] _raw_spin_lock_irq+0x18/0x54
[   41.701190] softirqs last  enabled at (61648): [&lt;c0026fd4&gt;] __do_softirq+0x234/0x2c8
[   41.708914] softirqs last disabled at (61631): [&lt;c00273a0&gt;] irq_exit+0xd0/0x114
[   41.716206] Preemption disabled at:[&lt;  (null)&gt;]   (null)
[   41.721500]
[   41.722985] CPU: 3 PID: 30 Comm: kworker/u8:1 Tainted: G        W      3.18.0-rc5-next-20141121 #883
[   41.732111] Workqueue: kmmcd mmc_rescan
[   41.735945] [&lt;c0014d2c&gt;] (unwind_backtrace) from [&lt;c0011c80&gt;] (show_stack+0x10/0x14)
[   41.743661] [&lt;c0011c80&gt;] (show_stack) from [&lt;c0489d14&gt;] (dump_stack+0x70/0xbc)
[   41.750867] [&lt;c0489d14&gt;] (dump_stack) from [&lt;c0228b74&gt;] (gpiod_get_raw_value_cansleep+0x18/0x30)
[   41.759628] [&lt;c0228b74&gt;] (gpiod_get_raw_value_cansleep) from [&lt;c03646e8&gt;] (mmc_gpio_get_cd+0x38/0x58)
[   41.768821] [&lt;c03646e8&gt;] (mmc_gpio_get_cd) from [&lt;c036d378&gt;] (sdhci_request+0x50/0x1a4)
[   41.776808] [&lt;c036d378&gt;] (sdhci_request) from [&lt;c0357934&gt;] (mmc_start_request+0x138/0x268)
[   41.785051] [&lt;c0357934&gt;] (mmc_start_request) from [&lt;c0357cc8&gt;] (mmc_wait_for_req+0x58/0x1a0)
[   41.793469] [&lt;c0357cc8&gt;] (mmc_wait_for_req) from [&lt;c0357e68&gt;] (mmc_wait_for_cmd+0x58/0x78)
[   41.801714] [&lt;c0357e68&gt;] (mmc_wait_for_cmd) from [&lt;c0361c00&gt;] (mmc_io_rw_direct_host+0x98/0x124)
[   41.810480] [&lt;c0361c00&gt;] (mmc_io_rw_direct_host) from [&lt;c03620f8&gt;] (sdio_reset+0x2c/0x64)
[   41.818641] [&lt;c03620f8&gt;] (sdio_reset) from [&lt;c035a3d8&gt;] (mmc_rescan+0x254/0x2e4)
[   41.826028] [&lt;c035a3d8&gt;] (mmc_rescan) from [&lt;c003a0e0&gt;] (process_one_work+0x180/0x3f4)
[   41.833920] [&lt;c003a0e0&gt;] (process_one_work) from [&lt;c003a3bc&gt;] (worker_thread+0x34/0x4b0)
[   41.841991] [&lt;c003a3bc&gt;] (worker_thread) from [&lt;c003fed8&gt;] (kthread+0xe4/0x104)
[   41.849285] [&lt;c003fed8&gt;] (kthread) from [&lt;c000f268&gt;] (ret_from_fork+0x14/0x2c)
[   42.038276] mmc0: new high speed SDHC card at address 1234

Signed-off-by: Krzysztof Kozlowski &lt;k.kozlowski@samsung.com&gt;
Fixes: 94144a465dd0 ("mmc: sdhci: add get_cd() implementation")
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 2836766a9d0bd02c66073f8dd44796e6cc23848d upstream.

Sleep in atomic context happened on Trats2 board after inserting or
removing SD card because mmc_gpio_get_cd() was called under spin lock.

Fix this by moving card detection earlier, before acquiring spin lock.
The mmc_gpio_get_cd() call does not have to be protected by spin lock
because it does not access any sdhci internal data.
The sdhci_do_get_cd() call access host flags (SDHCI_DEVICE_DEAD). After
moving it out side of spin lock it could theoretically race with driver
removal but still there is no actual protection against manual card
eject.

Dmesg after inserting SD card:
[   41.663414] BUG: sleeping function called from invalid context at drivers/gpio/gpiolib.c:1511
[   41.670469] in_atomic(): 1, irqs_disabled(): 128, pid: 30, name: kworker/u8:1
[   41.677580] INFO: lockdep is turned off.
[   41.681486] irq event stamp: 61972
[   41.684872] hardirqs last  enabled at (61971): [&lt;c0490ee0&gt;] _raw_spin_unlock_irq+0x24/0x5c
[   41.693118] hardirqs last disabled at (61972): [&lt;c04907ac&gt;] _raw_spin_lock_irq+0x18/0x54
[   41.701190] softirqs last  enabled at (61648): [&lt;c0026fd4&gt;] __do_softirq+0x234/0x2c8
[   41.708914] softirqs last disabled at (61631): [&lt;c00273a0&gt;] irq_exit+0xd0/0x114
[   41.716206] Preemption disabled at:[&lt;  (null)&gt;]   (null)
[   41.721500]
[   41.722985] CPU: 3 PID: 30 Comm: kworker/u8:1 Tainted: G        W      3.18.0-rc5-next-20141121 #883
[   41.732111] Workqueue: kmmcd mmc_rescan
[   41.735945] [&lt;c0014d2c&gt;] (unwind_backtrace) from [&lt;c0011c80&gt;] (show_stack+0x10/0x14)
[   41.743661] [&lt;c0011c80&gt;] (show_stack) from [&lt;c0489d14&gt;] (dump_stack+0x70/0xbc)
[   41.750867] [&lt;c0489d14&gt;] (dump_stack) from [&lt;c0228b74&gt;] (gpiod_get_raw_value_cansleep+0x18/0x30)
[   41.759628] [&lt;c0228b74&gt;] (gpiod_get_raw_value_cansleep) from [&lt;c03646e8&gt;] (mmc_gpio_get_cd+0x38/0x58)
[   41.768821] [&lt;c03646e8&gt;] (mmc_gpio_get_cd) from [&lt;c036d378&gt;] (sdhci_request+0x50/0x1a4)
[   41.776808] [&lt;c036d378&gt;] (sdhci_request) from [&lt;c0357934&gt;] (mmc_start_request+0x138/0x268)
[   41.785051] [&lt;c0357934&gt;] (mmc_start_request) from [&lt;c0357cc8&gt;] (mmc_wait_for_req+0x58/0x1a0)
[   41.793469] [&lt;c0357cc8&gt;] (mmc_wait_for_req) from [&lt;c0357e68&gt;] (mmc_wait_for_cmd+0x58/0x78)
[   41.801714] [&lt;c0357e68&gt;] (mmc_wait_for_cmd) from [&lt;c0361c00&gt;] (mmc_io_rw_direct_host+0x98/0x124)
[   41.810480] [&lt;c0361c00&gt;] (mmc_io_rw_direct_host) from [&lt;c03620f8&gt;] (sdio_reset+0x2c/0x64)
[   41.818641] [&lt;c03620f8&gt;] (sdio_reset) from [&lt;c035a3d8&gt;] (mmc_rescan+0x254/0x2e4)
[   41.826028] [&lt;c035a3d8&gt;] (mmc_rescan) from [&lt;c003a0e0&gt;] (process_one_work+0x180/0x3f4)
[   41.833920] [&lt;c003a0e0&gt;] (process_one_work) from [&lt;c003a3bc&gt;] (worker_thread+0x34/0x4b0)
[   41.841991] [&lt;c003a3bc&gt;] (worker_thread) from [&lt;c003fed8&gt;] (kthread+0xe4/0x104)
[   41.849285] [&lt;c003fed8&gt;] (kthread) from [&lt;c000f268&gt;] (ret_from_fork+0x14/0x2c)
[   42.038276] mmc0: new high speed SDHC card at address 1234

Signed-off-by: Krzysztof Kozlowski &lt;k.kozlowski@samsung.com&gt;
Fixes: 94144a465dd0 ("mmc: sdhci: add get_cd() implementation")
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
</feed>
