<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/spi, branch v3.14.39</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>spi: trigger trace event for message-done before mesg-&gt;complete</title>
<updated>2015-04-13T12:03:03+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@pengutronix.de</email>
</author>
<published>2015-03-18T10:27:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4172dbbeb2d36551ac94ede5959000100d2bada1'/>
<id>4172dbbeb2d36551ac94ede5959000100d2bada1</id>
<content type='text'>
commit 391949b6f02121371e3d7d9082c6d17fd9853034 upstream.

With spidev the mesg-&gt;complete callback points to spidev_complete.
Calling this unblocks spidev_sync and so spidev_sync_write finishes. As
the struct spi_message just read is a local variable in
spidev_sync_write and recording the trace event accesses this message
the recording is better done first. The same can happen for
spidev_sync_read.

This fixes an oops observed on a 3.14-rt system with spidev activity
after

	echo 1 &gt; /sys/kernel/debug/tracing/events/spi/enable

 .

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.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 391949b6f02121371e3d7d9082c6d17fd9853034 upstream.

With spidev the mesg-&gt;complete callback points to spidev_complete.
Calling this unblocks spidev_sync and so spidev_sync_write finishes. As
the struct spi_message just read is a local variable in
spidev_sync_write and recording the trace event accesses this message
the recording is better done first. The same can happen for
spidev_sync_read.

This fixes an oops observed on a 3.14-rt system with spidev activity
after

	echo 1 &gt; /sys/kernel/debug/tracing/events/spi/enable

 .

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@pengutronix.de&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>spi: pl022: Fix race in giveback() leading to driver lock-up</title>
<updated>2015-03-26T14:06:54+00:00</updated>
<author>
<name>Alexander Sverdlin</name>
<email>alexander.sverdlin@nokia.com</email>
</author>
<published>2015-02-27T15:30:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e62c360b26b8f8bb2e88db4cfc95fa10d3503cd6'/>
<id>e62c360b26b8f8bb2e88db4cfc95fa10d3503cd6</id>
<content type='text'>
commit cd6fa8d2ca53cac3226fdcffcf763be390abae32 upstream.

Commit fd316941c ("spi/pl022: disable port when unused") introduced a race,
which leads to possible driver lock up (easily reproducible on SMP).

The problem happens in giveback() function where the completion of the transfer
is signalled to SPI subsystem and then the HW SPI controller is disabled. Another
transfer might be setup in between, which brings driver in locked-up state.

Exact event sequence on SMP:

core0                                   core1

                                        =&gt; pump_transfers()
                                        /* message-&gt;state == STATE_DONE */
                                          =&gt; giveback()
                                            =&gt; spi_finalize_current_message()

=&gt; pl022_unprepare_transfer_hardware()
=&gt; pl022_transfer_one_message
  =&gt; flush()
  =&gt; do_interrupt_dma_transfer()
    =&gt; set_up_next_transfer()
    /* Enable SSP, turn on interrupts */
    writew((readw(SSP_CR1(pl022-&gt;virtbase)) |
           SSP_CR1_MASK_SSE), SSP_CR1(pl022-&gt;virtbase));

...

=&gt; pl022_interrupt_handler()
  =&gt; readwriter()

                                        /* disable the SPI/SSP operation */
                                        =&gt; writew((readw(SSP_CR1(pl022-&gt;virtbase)) &amp;
                                                  (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022-&gt;virtbase));

Lockup! SPI controller is disabled and the data will never be received. Whole
SPI subsystem is waiting for transfer ACK and blocked.

So, only signal transfer completion after disabling the controller.

Fixes: fd316941c (spi/pl022: disable port when unused)
Signed-off-by: Alexander Sverdlin &lt;alexander.sverdlin@nokia.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.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 cd6fa8d2ca53cac3226fdcffcf763be390abae32 upstream.

Commit fd316941c ("spi/pl022: disable port when unused") introduced a race,
which leads to possible driver lock up (easily reproducible on SMP).

The problem happens in giveback() function where the completion of the transfer
is signalled to SPI subsystem and then the HW SPI controller is disabled. Another
transfer might be setup in between, which brings driver in locked-up state.

Exact event sequence on SMP:

core0                                   core1

                                        =&gt; pump_transfers()
                                        /* message-&gt;state == STATE_DONE */
                                          =&gt; giveback()
                                            =&gt; spi_finalize_current_message()

=&gt; pl022_unprepare_transfer_hardware()
=&gt; pl022_transfer_one_message
  =&gt; flush()
  =&gt; do_interrupt_dma_transfer()
    =&gt; set_up_next_transfer()
    /* Enable SSP, turn on interrupts */
    writew((readw(SSP_CR1(pl022-&gt;virtbase)) |
           SSP_CR1_MASK_SSE), SSP_CR1(pl022-&gt;virtbase));

...

=&gt; pl022_interrupt_handler()
  =&gt; readwriter()

                                        /* disable the SPI/SSP operation */
                                        =&gt; writew((readw(SSP_CR1(pl022-&gt;virtbase)) &amp;
                                                  (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022-&gt;virtbase));

Lockup! SPI controller is disabled and the data will never be received. Whole
SPI subsystem is waiting for transfer ACK and blocked.

So, only signal transfer completion after disabling the controller.

Fixes: fd316941c (spi/pl022: disable port when unused)
Signed-off-by: Alexander Sverdlin &lt;alexander.sverdlin@nokia.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>spi: atmel: Fix interrupt setup for PDC transfers</title>
<updated>2015-03-26T14:06:54+00:00</updated>
<author>
<name>Torsten Fleischer</name>
<email>torfl6749@gmail.com</email>
</author>
<published>2015-02-24T15:32:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ddae55303da59a56c05ec39c1a4789775f591363'/>
<id>ddae55303da59a56c05ec39c1a4789775f591363</id>
<content type='text'>
commit 76e1d14b316d6f501ebc001e7a5d86b24ce5b615 upstream.

Additionally to the current DMA transfer the PDC allows to set up a next DMA
transfer. This is useful for larger SPI transfers.

The driver currently waits for ENDRX as end of the transfer. But ENDRX is set
when the current DMA transfer is done (RCR = 0), i.e. it doesn't include the
next DMA transfer.
Thus a subsequent SPI transfer could be started although there is currently a
transfer in progress. This can cause invalid accesses to the SPI slave devices
and to SPI transfer errors.

This issue has been observed on a hardware with a M25P128 SPI NOR flash.

So instead of ENDRX we should wait for RXBUFF. This flag is set if there is
no more DMA transfer in progress (RCR = RNCR = 0).

Signed-off-by: Torsten Fleischer &lt;torfl6749@gmail.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.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 76e1d14b316d6f501ebc001e7a5d86b24ce5b615 upstream.

Additionally to the current DMA transfer the PDC allows to set up a next DMA
transfer. This is useful for larger SPI transfers.

The driver currently waits for ENDRX as end of the transfer. But ENDRX is set
when the current DMA transfer is done (RCR = 0), i.e. it doesn't include the
next DMA transfer.
Thus a subsequent SPI transfer could be started although there is currently a
transfer in progress. This can cause invalid accesses to the SPI slave devices
and to SPI transfer errors.

This issue has been observed on a hardware with a M25P128 SPI NOR flash.

So instead of ENDRX we should wait for RXBUFF. This flag is set if there is
no more DMA transfer in progress (RCR = RNCR = 0).

Signed-off-by: Torsten Fleischer &lt;torfl6749@gmail.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>spi/pxa2xx: Clear cur_chip pointer before starting next message</title>
<updated>2015-02-06T06:35:50+00:00</updated>
<author>
<name>Mika Westerberg</name>
<email>mika.westerberg@linux.intel.com</email>
</author>
<published>2014-12-29T08:33:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=03c5a83d8c13cf8d182290cb8771dab3a943cc35'/>
<id>03c5a83d8c13cf8d182290cb8771dab3a943cc35</id>
<content type='text'>
commit c957e8f084e0d21febcd6b8a0ea9631eccc92f36 upstream.

Once the current message is finished, the driver notifies SPI core about
this by calling spi_finalize_current_message(). This function queues next
message to be transferred. If there are more messages in the queue, it is
possible that the driver is asked to transfer the next message at this
point.

When spi_finalize_current_message() returns the driver clears the
drv_data-&gt;cur_chip pointer to NULL. The problem is that if the driver
already started the next message clearing drv_data-&gt;cur_chip will cause
NULL pointer dereference which crashes the kernel like:

 BUG: unable to handle kernel NULL pointer dereference at 0000000000000048
 IP: [&lt;ffffffffa0022bc8&gt;] cs_deassert+0x18/0x70 [spi_pxa2xx_platform]
 PGD 78bb8067 PUD 37712067 PMD 0
 Oops: 0000 [#1] SMP
 Modules linked in:
 CPU: 1 PID: 11 Comm: ksoftirqd/1 Tainted: G           O   3.18.0-rc4-mjo #5
 Hardware name: Intel Corp. VALLEYVIEW B3 PLATFORM/NOTEBOOK, BIOS MNW2CRB1.X64.0071.R30.1408131301 08/13/2014
 task: ffff880077f9f290 ti: ffff88007a820000 task.ti: ffff88007a820000
 RIP: 0010:[&lt;ffffffffa0022bc8&gt;]  [&lt;ffffffffa0022bc8&gt;] cs_deassert+0x18/0x70 [spi_pxa2xx_platform]
 RSP: 0018:ffff88007a823d08  EFLAGS: 00010202
 RAX: 0000000000000008 RBX: ffff8800379a4430 RCX: 0000000000000026
 RDX: 0000000000000000 RSI: 0000000000000246 RDI: ffff8800379a4430
 RBP: ffff88007a823d18 R08: 00000000ffffffff R09: 000000007a9bc65a
 R10: 000000000000028f R11: 0000000000000005 R12: ffff880070123e98
 R13: ffff880070123de8 R14: 0000000000000100 R15: ffffc90004888000
 FS:  0000000000000000(0000) GS:ffff880079a80000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
 CR2: 0000000000000048 CR3: 000000007029b000 CR4: 00000000001007e0
 Stack:
  ffff88007a823d58 ffff8800379a4430 ffff88007a823d48 ffffffffa0022c89
  0000000000000000 ffff8800379a4430 0000000000000000 0000000000000006
  ffff88007a823da8 ffffffffa0023be0 ffff88007a823dd8 ffffffff81076204
 Call Trace:
  [&lt;ffffffffa0022c89&gt;] giveback+0x69/0xa0 [spi_pxa2xx_platform]
  [&lt;ffffffffa0023be0&gt;] pump_transfers+0x710/0x740 [spi_pxa2xx_platform]
  [&lt;ffffffff81076204&gt;] ? pick_next_task_fair+0x744/0x830
  [&lt;ffffffff81049679&gt;] tasklet_action+0xa9/0xe0
  [&lt;ffffffff81049a0e&gt;] __do_softirq+0xee/0x280
  [&lt;ffffffff81049bc0&gt;] run_ksoftirqd+0x20/0x40
  [&lt;ffffffff810646df&gt;] smpboot_thread_fn+0xff/0x1b0
  [&lt;ffffffff810645e0&gt;] ? SyS_setgroups+0x150/0x150
  [&lt;ffffffff81060f9d&gt;] kthread+0xcd/0xf0
  [&lt;ffffffff81060ed0&gt;] ? kthread_create_on_node+0x180/0x180
  [&lt;ffffffff8187a82c&gt;] ret_from_fork+0x7c/0xb0

Fix this by clearing drv_data-&gt;cur_chip before we call spi_finalize_current_message().

Reported-by: Martin Oldfield &lt;m@mjoldfield.com&gt;
Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Acked-by: Robert Jarzmik &lt;robert.jarzmik@free.fr&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.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 c957e8f084e0d21febcd6b8a0ea9631eccc92f36 upstream.

Once the current message is finished, the driver notifies SPI core about
this by calling spi_finalize_current_message(). This function queues next
message to be transferred. If there are more messages in the queue, it is
possible that the driver is asked to transfer the next message at this
point.

When spi_finalize_current_message() returns the driver clears the
drv_data-&gt;cur_chip pointer to NULL. The problem is that if the driver
already started the next message clearing drv_data-&gt;cur_chip will cause
NULL pointer dereference which crashes the kernel like:

 BUG: unable to handle kernel NULL pointer dereference at 0000000000000048
 IP: [&lt;ffffffffa0022bc8&gt;] cs_deassert+0x18/0x70 [spi_pxa2xx_platform]
 PGD 78bb8067 PUD 37712067 PMD 0
 Oops: 0000 [#1] SMP
 Modules linked in:
 CPU: 1 PID: 11 Comm: ksoftirqd/1 Tainted: G           O   3.18.0-rc4-mjo #5
 Hardware name: Intel Corp. VALLEYVIEW B3 PLATFORM/NOTEBOOK, BIOS MNW2CRB1.X64.0071.R30.1408131301 08/13/2014
 task: ffff880077f9f290 ti: ffff88007a820000 task.ti: ffff88007a820000
 RIP: 0010:[&lt;ffffffffa0022bc8&gt;]  [&lt;ffffffffa0022bc8&gt;] cs_deassert+0x18/0x70 [spi_pxa2xx_platform]
 RSP: 0018:ffff88007a823d08  EFLAGS: 00010202
 RAX: 0000000000000008 RBX: ffff8800379a4430 RCX: 0000000000000026
 RDX: 0000000000000000 RSI: 0000000000000246 RDI: ffff8800379a4430
 RBP: ffff88007a823d18 R08: 00000000ffffffff R09: 000000007a9bc65a
 R10: 000000000000028f R11: 0000000000000005 R12: ffff880070123e98
 R13: ffff880070123de8 R14: 0000000000000100 R15: ffffc90004888000
 FS:  0000000000000000(0000) GS:ffff880079a80000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
 CR2: 0000000000000048 CR3: 000000007029b000 CR4: 00000000001007e0
 Stack:
  ffff88007a823d58 ffff8800379a4430 ffff88007a823d48 ffffffffa0022c89
  0000000000000000 ffff8800379a4430 0000000000000000 0000000000000006
  ffff88007a823da8 ffffffffa0023be0 ffff88007a823dd8 ffffffff81076204
 Call Trace:
  [&lt;ffffffffa0022c89&gt;] giveback+0x69/0xa0 [spi_pxa2xx_platform]
  [&lt;ffffffffa0023be0&gt;] pump_transfers+0x710/0x740 [spi_pxa2xx_platform]
  [&lt;ffffffff81076204&gt;] ? pick_next_task_fair+0x744/0x830
  [&lt;ffffffff81049679&gt;] tasklet_action+0xa9/0xe0
  [&lt;ffffffff81049a0e&gt;] __do_softirq+0xee/0x280
  [&lt;ffffffff81049bc0&gt;] run_ksoftirqd+0x20/0x40
  [&lt;ffffffff810646df&gt;] smpboot_thread_fn+0xff/0x1b0
  [&lt;ffffffff810645e0&gt;] ? SyS_setgroups+0x150/0x150
  [&lt;ffffffff81060f9d&gt;] kthread+0xcd/0xf0
  [&lt;ffffffff81060ed0&gt;] ? kthread_create_on_node+0x180/0x180
  [&lt;ffffffff8187a82c&gt;] ret_from_fork+0x7c/0xb0

Fix this by clearing drv_data-&gt;cur_chip before we call spi_finalize_current_message().

Reported-by: Martin Oldfield &lt;m@mjoldfield.com&gt;
Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Acked-by: Robert Jarzmik &lt;robert.jarzmik@free.fr&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>spi: dw-mid: fix FIFO size</title>
<updated>2015-02-06T06:35:48+00:00</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2015-01-02T15:48:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8d1ac9b68cab13300424179059db0a7056ca456f'/>
<id>8d1ac9b68cab13300424179059db0a7056ca456f</id>
<content type='text'>
commit 67bf9cda4b498b8cea4a40be67a470afe57d2e88 upstream.

The FIFO size is 40 accordingly to the specifications, but this means 0x40,
i.e. 64 bytes. This patch fixes the typo and enables FIFO size autodetection
for Intel MID devices.

Fixes: 7063c0d942a1 (spi/dw_spi: add DMA support)
Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.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 67bf9cda4b498b8cea4a40be67a470afe57d2e88 upstream.

The FIFO size is 40 accordingly to the specifications, but this means 0x40,
i.e. 64 bytes. This patch fixes the typo and enables FIFO size autodetection
for Intel MID devices.

Fixes: 7063c0d942a1 (spi/dw_spi: add DMA support)
Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>spi: fsl: Fix problem with multi message transfers</title>
<updated>2015-01-16T14:59:34+00:00</updated>
<author>
<name>Stefan Roese</name>
<email>sr@denx.de</email>
</author>
<published>2014-01-31T12:44:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2937d5ac11c421a02f276295f388994027bbe607'/>
<id>2937d5ac11c421a02f276295f388994027bbe607</id>
<content type='text'>
commit 4302a59629f7a0bd70fd1605d2b558597517372a upstream.

When used via spidev with more than one messages to tranfer via
SPI_IOC_MESSAGE the current implementation would return with
-EINVAL, since bits_per_word and speed_hz are set in all
transfer structs. And in the 2nd loop status will stay at
-EINVAL as its not overwritten again via fsl_spi_setup_transfer().

This patch changes this behavious by first checking if one of
the messages uses different settings. If this is the case
the function will return with -EINVAL. If not, the messages
are transferred correctly.

Signed-off-by: Stefan Roese &lt;sr@denx.de&gt;
Signed-off-by: Mark Brown &lt;broonie@linaro.org&gt;
Cc: Esben Haabendal &lt;esbenhaabendal@gmail.com&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 4302a59629f7a0bd70fd1605d2b558597517372a upstream.

When used via spidev with more than one messages to tranfer via
SPI_IOC_MESSAGE the current implementation would return with
-EINVAL, since bits_per_word and speed_hz are set in all
transfer structs. And in the 2nd loop status will stay at
-EINVAL as its not overwritten again via fsl_spi_setup_transfer().

This patch changes this behavious by first checking if one of
the messages uses different settings. If this is the case
the function will return with -EINVAL. If not, the messages
are transferred correctly.

Signed-off-by: Stefan Roese &lt;sr@denx.de&gt;
Signed-off-by: Mark Brown &lt;broonie@linaro.org&gt;
Cc: Esben Haabendal &lt;esbenhaabendal@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>spi: dw: Fix dynamic speed change.</title>
<updated>2014-12-06T23:55:38+00:00</updated>
<author>
<name>Thor Thayer</name>
<email>tthayer@opensource.altera.com</email>
</author>
<published>2014-11-06T19:54:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=46c6d8959b29007aff9a2ab45b8936768526d775'/>
<id>46c6d8959b29007aff9a2ab45b8936768526d775</id>
<content type='text'>
commit 0a8727e69778683495058852f783eeda141a754e upstream.

An IOCTL call that calls spi_setup() and then dw_spi_setup() will
overwrite the persisted last transfer speed. On each transfer, the
SPI speed is compared to the last transfer speed to determine if the
clock divider registers need to be updated (did the speed change?).
This bug was observed with the spidev driver using spi-config to
update the max transfer speed.

This fix: Don't overwrite the persisted last transaction clock speed
when updating the SPI parameters in dw_spi_setup(). On the next
transaction, the new speed won't match the persisted last speed
and the hardware registers will be updated.
On initialization, the persisted last transaction clock
speed will be 0 but will be updated after the first SPI
transaction.

Move zeroed clock divider check into clock change test because
chip-&gt;clk_div is zero on startup and would cause a divide-by-zero
error. The calculation was wrong as well (can't support odd #).

Reported-by: Vlastimil Setka &lt;setka@vsis.cz&gt;
Signed-off-by: Vlastimil Setka &lt;setka@vsis.cz&gt;
Signed-off-by: Thor Thayer &lt;tthayer@opensource.altera.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.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 0a8727e69778683495058852f783eeda141a754e upstream.

An IOCTL call that calls spi_setup() and then dw_spi_setup() will
overwrite the persisted last transfer speed. On each transfer, the
SPI speed is compared to the last transfer speed to determine if the
clock divider registers need to be updated (did the speed change?).
This bug was observed with the spidev driver using spi-config to
update the max transfer speed.

This fix: Don't overwrite the persisted last transaction clock speed
when updating the SPI parameters in dw_spi_setup(). On the next
transaction, the new speed won't match the persisted last speed
and the hardware registers will be updated.
On initialization, the persisted last transaction clock
speed will be 0 but will be updated after the first SPI
transaction.

Move zeroed clock divider check into clock change test because
chip-&gt;clk_div is zero on startup and would cause a divide-by-zero
error. The calculation was wrong as well (can't support odd #).

Reported-by: Vlastimil Setka &lt;setka@vsis.cz&gt;
Signed-off-by: Vlastimil Setka &lt;setka@vsis.cz&gt;
Signed-off-by: Thor Thayer &lt;tthayer@opensource.altera.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>spi: pxa2xx: toggle clocks on suspend if not disabled by runtime PM</title>
<updated>2014-11-14T17:00:05+00:00</updated>
<author>
<name>Dmitry Eremin-Solenikov</name>
<email>dbaryshkov@gmail.com</email>
</author>
<published>2014-11-06T11:08:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b8edc5dc0ae741cba4b094b220cf8721db5192ec'/>
<id>b8edc5dc0ae741cba4b094b220cf8721db5192ec</id>
<content type='text'>
commit 2b9375b91bef65b837bed61a05fb387159b38ddf upstream.

If PM_RUNTIME is enabled, it is easy to trigger the following backtrace
on pxa2xx hosts:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at /home/lumag/linux/arch/arm/mach-pxa/clock.c:35 clk_disable+0xa0/0xa8()
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 3.17.0-00007-g1b3d2ee-dirty #104
[&lt;c000de68&gt;] (unwind_backtrace) from [&lt;c000c078&gt;] (show_stack+0x10/0x14)
[&lt;c000c078&gt;] (show_stack) from [&lt;c001d75c&gt;] (warn_slowpath_common+0x6c/0x8c)
[&lt;c001d75c&gt;] (warn_slowpath_common) from [&lt;c001d818&gt;] (warn_slowpath_null+0x1c/0x24)
[&lt;c001d818&gt;] (warn_slowpath_null) from [&lt;c0015e80&gt;] (clk_disable+0xa0/0xa8)
[&lt;c0015e80&gt;] (clk_disable) from [&lt;c02507f8&gt;] (pxa2xx_spi_suspend+0x2c/0x34)
[&lt;c02507f8&gt;] (pxa2xx_spi_suspend) from [&lt;c0200360&gt;] (platform_pm_suspend+0x2c/0x54)
[&lt;c0200360&gt;] (platform_pm_suspend) from [&lt;c0207fec&gt;] (dpm_run_callback.isra.14+0x2c/0x74)
[&lt;c0207fec&gt;] (dpm_run_callback.isra.14) from [&lt;c0209254&gt;] (__device_suspend+0x120/0x2f8)
[&lt;c0209254&gt;] (__device_suspend) from [&lt;c0209a94&gt;] (dpm_suspend+0x50/0x208)
[&lt;c0209a94&gt;] (dpm_suspend) from [&lt;c00455ac&gt;] (suspend_devices_and_enter+0x8c/0x3a0)
[&lt;c00455ac&gt;] (suspend_devices_and_enter) from [&lt;c0045ad4&gt;] (pm_suspend+0x214/0x2a8)
[&lt;c0045ad4&gt;] (pm_suspend) from [&lt;c04b5c34&gt;] (test_suspend+0x14c/0x1dc)
[&lt;c04b5c34&gt;] (test_suspend) from [&lt;c000880c&gt;] (do_one_initcall+0x8c/0x1fc)
[&lt;c000880c&gt;] (do_one_initcall) from [&lt;c04aecfc&gt;] (kernel_init_freeable+0xf4/0x1b4)
[&lt;c04aecfc&gt;] (kernel_init_freeable) from [&lt;c0378078&gt;] (kernel_init+0x8/0xec)
[&lt;c0378078&gt;] (kernel_init) from [&lt;c0009590&gt;] (ret_from_fork+0x14/0x24)
---[ end trace 46524156d8faa4f6 ]---

This happens because suspend function tries to disable a clock that is
already disabled by runtime_suspend callback. Add if
(!pm_runtime_suspended()) checks to suspend/resume path.

Fixes: 7d94a505858 (spi/pxa2xx: add support for runtime PM)
Signed-off-by: Dmitry Eremin-Solenikov &lt;dbaryshkov@gmail.com&gt;
Reported-by: Andrea Adami &lt;andrea.adami@gmail.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.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 2b9375b91bef65b837bed61a05fb387159b38ddf upstream.

If PM_RUNTIME is enabled, it is easy to trigger the following backtrace
on pxa2xx hosts:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at /home/lumag/linux/arch/arm/mach-pxa/clock.c:35 clk_disable+0xa0/0xa8()
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 3.17.0-00007-g1b3d2ee-dirty #104
[&lt;c000de68&gt;] (unwind_backtrace) from [&lt;c000c078&gt;] (show_stack+0x10/0x14)
[&lt;c000c078&gt;] (show_stack) from [&lt;c001d75c&gt;] (warn_slowpath_common+0x6c/0x8c)
[&lt;c001d75c&gt;] (warn_slowpath_common) from [&lt;c001d818&gt;] (warn_slowpath_null+0x1c/0x24)
[&lt;c001d818&gt;] (warn_slowpath_null) from [&lt;c0015e80&gt;] (clk_disable+0xa0/0xa8)
[&lt;c0015e80&gt;] (clk_disable) from [&lt;c02507f8&gt;] (pxa2xx_spi_suspend+0x2c/0x34)
[&lt;c02507f8&gt;] (pxa2xx_spi_suspend) from [&lt;c0200360&gt;] (platform_pm_suspend+0x2c/0x54)
[&lt;c0200360&gt;] (platform_pm_suspend) from [&lt;c0207fec&gt;] (dpm_run_callback.isra.14+0x2c/0x74)
[&lt;c0207fec&gt;] (dpm_run_callback.isra.14) from [&lt;c0209254&gt;] (__device_suspend+0x120/0x2f8)
[&lt;c0209254&gt;] (__device_suspend) from [&lt;c0209a94&gt;] (dpm_suspend+0x50/0x208)
[&lt;c0209a94&gt;] (dpm_suspend) from [&lt;c00455ac&gt;] (suspend_devices_and_enter+0x8c/0x3a0)
[&lt;c00455ac&gt;] (suspend_devices_and_enter) from [&lt;c0045ad4&gt;] (pm_suspend+0x214/0x2a8)
[&lt;c0045ad4&gt;] (pm_suspend) from [&lt;c04b5c34&gt;] (test_suspend+0x14c/0x1dc)
[&lt;c04b5c34&gt;] (test_suspend) from [&lt;c000880c&gt;] (do_one_initcall+0x8c/0x1fc)
[&lt;c000880c&gt;] (do_one_initcall) from [&lt;c04aecfc&gt;] (kernel_init_freeable+0xf4/0x1b4)
[&lt;c04aecfc&gt;] (kernel_init_freeable) from [&lt;c0378078&gt;] (kernel_init+0x8/0xec)
[&lt;c0378078&gt;] (kernel_init) from [&lt;c0009590&gt;] (ret_from_fork+0x14/0x24)
---[ end trace 46524156d8faa4f6 ]---

This happens because suspend function tries to disable a clock that is
already disabled by runtime_suspend callback. Add if
(!pm_runtime_suspended()) checks to suspend/resume path.

Fixes: 7d94a505858 (spi/pxa2xx: add support for runtime PM)
Signed-off-by: Dmitry Eremin-Solenikov &lt;dbaryshkov@gmail.com&gt;
Reported-by: Andrea Adami &lt;andrea.adami@gmail.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>spi: fsl-dspi: Fix CTAR selection</title>
<updated>2014-11-14T17:00:05+00:00</updated>
<author>
<name>Alexander Stein</name>
<email>alexander.stein@systec-electronic.com</email>
</author>
<published>2014-11-04T08:20:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8421b7744ec88ef1055ca793277e824d3cca9d12'/>
<id>8421b7744ec88ef1055ca793277e824d3cca9d12</id>
<content type='text'>
commit 5cc7b04740effa5cc0af53f434134b5859d58b73 upstream.

There are only 4 CTAR registers (CTAR0 - CTAR3) so we can only use the
lower 2 bits of the chip select to select a CTAR register.
SPI_PUSHR_CTAS used the lower 3 bits which would result in wrong bit values
if the chip selects 4/5 are used. For those chip selects SPI_CTAR even
calculated offsets of non-existing registers.

Signed-off-by: Alexander Stein &lt;alexander.stein@systec-electronic.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.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 5cc7b04740effa5cc0af53f434134b5859d58b73 upstream.

There are only 4 CTAR registers (CTAR0 - CTAR3) so we can only use the
lower 2 bits of the chip select to select a CTAR register.
SPI_PUSHR_CTAS used the lower 3 bits which would result in wrong bit values
if the chip selects 4/5 are used. For those chip selects SPI_CTAR even
calculated offsets of non-existing registers.

Signed-off-by: Alexander Stein &lt;alexander.stein@systec-electronic.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>spi: pl022: Fix incorrect dma_unmap_sg</title>
<updated>2014-11-14T17:00:04+00:00</updated>
<author>
<name>Ray Jui</name>
<email>rjui@broadcom.com</email>
</author>
<published>2014-10-09T18:44:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fab420531d95f384ad52a905936753e6162f9f14'/>
<id>fab420531d95f384ad52a905936753e6162f9f14</id>
<content type='text'>
commit 3ffa6158f002e096d28ede71be4e0ee8ab20baa2 upstream.

When mapped RX DMA entries are unmapped in an error condition when DMA
is firstly configured in the driver, the number of TX DMA entries was
passed in, which is incorrect

Signed-off-by: Ray Jui &lt;rjui@broadcom.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.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 3ffa6158f002e096d28ede71be4e0ee8ab20baa2 upstream.

When mapped RX DMA entries are unmapped in an error condition when DMA
is firstly configured in the driver, the number of TX DMA entries was
passed in, which is incorrect

Signed-off-by: Ray Jui &lt;rjui@broadcom.com&gt;
Signed-off-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

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