summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'spi-v4.5' of ↵Linus Torvalds2016-01-131-2/+30
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi Pull spi updates from Mark Brown: "A quiet release for SPI, not even many driver updates: - Add a dummy loopback driver for use in exercising framework features during development. - Move the test utilities to tools/ and add support for transferring data to and from a file instead of stdin and stdout to spidev_test. - Support for Mediatek MT2701 and Renesas AG5 deices" * tag 'spi-v4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (69 commits) spi: loopback: fix typo in MODULE_PARM_DESC spi: sun4i: Prevent chip-select from being activated twice before a transfer spi: loopback-test: spi_check_rx_ranges can get always done spi: loopback-test: rename method spi_test_fill_tx to spi_test_fill_pattern spi: loopback-test: write rx pattern also when running without tx_buf spi: fsl-espi: expose maximum transfer size limit spi: expose master transfer size limitation. spi: zynq: use to_platform_device() spi: cadence: use to_platform_device() spi: mediatek: Add spi support for mt2701 IC spi: mediatek: merge all identical compat to mtk_common_compat spi: mtk: Add bindings for mediatek MT2701 soc platform spi: mediatek: Prevent overflows in FIFO transfers spi: s3c64xx: Remove unused platform_device_id entries spi: use to_spi_device spi: dw: Use SPI_TMOD_TR rather than magic const 0 to set tmode spi: imx: defer spi initialization, if DMA engine is spi: imx: return error from dma channel request spi: imx: enable loopback only for ECSPI controller family spi: imx: fix loopback mode setup after controller reset ...
| *-. Merge remote-tracking branches 'spi/topic/overlay', 'spi/topic/pxa2xx', ↵Mark Brown2016-01-111-0/+29
| |\ \ | | | | | | | | | | | | 'spi/topic/s3c64xx', 'spi/topic/sh-msiof' and 'spi/topic/spidev' into spi-next
| | * | spi: Mark instantiated device nodes with OF_POPULATEGeert Uytterhoeven2015-12-011-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mark (and unmark) device nodes with the POPULATE flag as appropriate. This is required to avoid multi probing when enabling and populating SPI buses in DT overlays. Based on commit 4f001fd30145a6a8 ("i2c: Mark instantiated device nodes with OF_POPULATE"). Suggested-by: Mark Brown <broonie@kernel.org> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org>
| | * | spi: Uninline spi_unregister_device()Geert Uytterhoeven2015-12-011-0/+14
| | |/ | | | | | | | | | | | | | | | | | | | | | Uninline spi_unregister_device() in preparation of adding more code to it. Add kerneldoc documentation while we're at it. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | Merge remote-tracking branch 'spi/topic/core' into spi-nextMark Brown2016-01-111-2/+1
| |\ \
| | * | spi: use to_spi_deviceGeliang Tang2015-12-231-2/+1
| | |/ | | | | | | | | | | | | | | | | | | Use to_spi_device() instead of open-coding it. Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | | ACPI / spi: attach GPIO IRQ from ACPI description to SPI deviceChristophe RICARD2016-01-011-0/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | spi->irq was ignoring GpioInt property setting it to -1. acpi_dev_gpio_irq_get returns and configure the slave IRQ according to the ACPI slave node description. It is now inline with devicetree behavior. Acked-by: Mark Brown <broonie@kernel.org> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
* | Merge remote-tracking branch 'spi/fix/core' into spi-linusMark Brown2015-12-161-1/+1
|\ \
| * | spi: fix parent-device reference leakJohan Hovold2015-12-161-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | Fix parent-device reference leak due to SPI-core taking an unnecessary reference to the parent when allocating the master structure, a reference that was never released. Note that driver core takes its own reference to the parent when the master device is registered. Fixes: 49dce689ad4e ("spi doesn't need class_device") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
| |
| \
*-. \ Merge remote-tracking branches 'spi/fix/bcm63xx', 'spi/fix/doc', ↵Mark Brown2015-11-301-0/+1
|\ \ \ | | |/ | |/| | | | 'spi/fix/mediatek' and 'spi/fix/pl022' into spi-linus
| | * spi: Add missing kerneldoc description for parameterThierry Reding2015-11-101-0/+1
| |/ | | | | | | | | | | | | | | | | | | Commit ca5d24854210 ("spi: Add THIS_MODULE to spi_driver in SPI core") adds the new __spi_register_driver() function, but keeps the kerneldoc for the spi_register_driver() function in place and forgets to add the description for the new owner parameter. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | spi: bugfix: spi_message.transfer_length does not get resetMartin Sperl2015-11-271-0/+1
|/ | | | | | | | | | When submitting an identical spi_message multiple times via spi_sync the spi_message.frame_length does not get reset to 0 in __spi_validate before adding up all spi_transfer.len resulting in frame_length > actual_length on all but the first spi_sync call. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'spi/topic/omap-100k', ↵Mark Brown2015-11-041-3/+4
|\ \ | | | | | | | | | 'spi/topic/omap-uwire', 'spi/topic/owner', 'spi/topic/pxa' and 'spi/topic/pxa2xx' into spi-next
| | * spi: Add THIS_MODULE to spi_driver in SPI coreAndrew F. Davis2015-10-281-3/+4
| |/ | | | | | | | | | | | | | | | | Add spi_register_driver helper macro that adds THIS_MODULE to spi_driver for the registering driver. We rename and modify the existing spi_register_driver to enable this. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | Merge remote-tracking branch 'spi/topic/doc' into spi-nextMark Brown2015-11-041-9/+93
|\ \
| * | spi: fix kernel-doc warnings about missing return desc in spi.cJavier Martinez Canillas2015-10-241-9/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building docs with make htmldocs, warnings about not having a description for the return value are reported, i.e: warning: No description found for return value of 'spi_register_driver' Fix these by following the kernel-doc conventions explained in Documentation/kernel-doc-nano-HOWTO.txt. Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | |
| | \
| *-. \ Merge branches 'topic/core' and 'topic/stats' of ↵Mark Brown2015-10-241-8/+76
| |\ \ \ | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-doc
| | | * | spi: add transfer histogram statistics via sysfsMartin Sperl2015-09-191-0/+61
| | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | report transfer sizes as a histogram via the following files: /sys/class/spi_master/spi*/statistics/transfer_bytes_histo_* /sys/class/spi_master/spi*/spi*.*/statistics/transfer_bytes_histo_* Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* | | | Merge remote-tracking branch 'spi/topic/core' into spi-nextMark Brown2015-11-041-8/+15
|\ \ \ \ | | |/ / | |/| |
| * | | spi: core: use gpio_is_valid() helperAndy Shevchenko2015-10-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Check if GPIO pin is valid by API helper function. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | | spi: core: propagate return code of __spi_validate_bits_per_word()Andy Shevchenko2015-10-161-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Propagate the actual return code of __spi_validate_bits_per_word() in spi_setup(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | | spi: Map SPI OF client IRQ at probe timeJon Hunter2015-10-121-4/+10
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the IRQs for SPI client devices, registered via device-tree, are mapped when the client devices are registered. If the corresponding irq-chip has not been probed yet, then the probing of the client device will fail and will not be retried. Resolve this by mapping the IRQ at probe time and allow the probe to be deferred if the IRQ is not yet available. If of_irq_get() returns an error that is not -EPROBE_DEFER, then assume that the SPI client does not have an IRQ and set the IRQ number to zero (which is equivalent to irq_of_parse_and_map()). This is based on some inputs from Thierry Reding <treding@nvidia.com>. Cc: Thierry Reding <treding@nvidia.com> Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com> Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | | Merge remote-tracking branch 'spi/fix/core' into spi-linusMark Brown2015-11-041-2/+2
|\ \ \ | |_|/ |/| |
| * | spi: Setup the master controller driver before setting the chipselectFranklin S Cooper Jr2015-10-281-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | SPI controllers may need to be properly setup before chip selects can be used. Therefore, wait until the spi controller has a chance to perform their setup procedure before trying to use the chip select. This also insures that the chip selects pins are in a good state before asseting them which otherwise may cause confusion. Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com> Tested-by: Grygorii Strashko <grygorii.strashko@ti.com> Tested-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* | Merge tag 'v4.3-rc1' into spi-fix-docMark Brown2015-09-161-18/+217
|\ \ | |/ | | | | Linux 4.3-rc1
| *---. Merge remote-tracking branches 'spi/topic/s3c64xx', 'spi/topic/sg', ↵Mark Brown2015-08-311-6/+178
| |\ \ \ | | | | | | | | | | | | | | | 'spi/topic/sh-msiof', 'spi/topic/spidev' and 'spi/topic/stats' into spi-next
| | | | * spi: expose spi_master and spi_device statistics via sysfsMartin Sperl2015-07-071-3/+165
| | | |/ | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | per spi-master statistics accessible as: /sys/class/spi_master/spi*/statistics/* per spi-device statistics accessible via: /sys/class/spi_master/spi*/spi*.*/statistics/* The following statistics are exposed as separate "files" inside these directories: * messages number of spi_messages * transfers number of spi_transfers * bytes number of bytes transferred * bytes_rx number of bytes transmitted * bytes_tx number of bytes received * errors number of errors encounterd * timedout number of messages that have timed out * spi_async number of spi_messages submitted using spi_async * spi_sync number of spi_messages submitted using spi_sync * spi_sync_immediate number of spi_messages submitted using spi_sync, that are handled immediately without a context switch to the spi_pump worker-thread Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | * spi: Fix per-page mapping of unaligned vmalloc-ed bufferAndrew Gabbasov2015-07-071-3/+13
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | spi_map_buf() processes mapping of vmalloc-ed buffers in a special way, making mapping of every page separately. However, if the buffer is not aligned to page boundary (e.g. sub-array in a vmalloc-ed array), it fills the scatter table with page-size unaligned pieces, that cross page boundaries. This is incorrect and can, for example, cause memory corruption and various crashes when working with ubifs on spi-nor chips (though those drivers are themselves buggy in that they should be providing DMAable memory to the SPI framework). Fix this by using proper scatter table size and intra-page buffer lengths, so that the whole buffer splits into separate scatter table entries on page boundaries. Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | Merge remote-tracking branch 'spi/topic/dma' into spi-nextMark Brown2015-08-311-4/+18
| |\ \
| | * | spi: support spi without dma channel to use can_dma()Leilk Liu2015-07-241-4/+18
| | |/ | | | | | | | | | | | | | | | | | | | | | For spi without dma channel and use can_dma(), it can use master->dev for struct device. Signed-off-by: Leilk Liu <leilk.liu@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | spi: check bits_per_word in spi_setupStefan Brüns2015-08-261-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows drivers for devices connected via SPI to check if the controller supports a given bits_per_word value during setup. Currently any BPW value is accepted durings setup, and transfers are rejected later. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | spi: Fall back to master maximum speed if no slave speed specifiedMark Brown2015-08-211-0/+2
| |/ | | | | | | | | | | | | | | If a slave appears with no maximum transfer speed specified fall back to using the maximum for the master instead. It's questionable if we should let slaves do this but let's be defensive. Signed-off-by: Mark Brown <broonie@kernel.org>
* | spi: Fix documentation of spi_alloc_master()Guenter Roeck2015-09-061-2/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | Actually, spi_master_put() after spi_alloc_master() must _not_ be followed by kfree(). The memory is already freed with the call to spi_master_put() through spi_master_class, which registers a release function. Calling both spi_master_put() and kfree() results in often nasty (and delayed) crashes elsewhere in the kernel, often in the networking stack. This reverts commit eb4af0f5349235df2e4a5057a72fc8962d00308a. Link to patch and concerns: https://lkml.org/lkml/2012/9/3/269 or http://lkml.iu.edu/hypermail/linux/kernel/1209.0/00790.html Alexey Klimov: This revert becomes valid after 94c69f765f1b4a658d96905ec59928e3e3e07e6a when spi-imx.c has been fixed and there is no need to call kfree() so comment for spi_alloc_master() should be fixed. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
* spi: restore rx/tx_buf in case of unset CONFIG_HAS_DMAMartin Sperl2015-06-021-12/+22
| | | | | | | | | | | | | | The case where spi_master sets the flags SPI_MASTER_MUST_RX/TX while CONFIG_HAS_DMA is unset (which is unlikley) together with a driver that reuses spi_messages with rx/tx_buff set to NULL, can result in: * data disclosure over the SPI (for tx_buf == NULL) * memory corruption (for rx_buf == NULL) This happenes when dummy_rx/dummy_tx are changing address due to krealloc or free and an allocation of the memory by a different part of the kernel. Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org>
* spi: fix race freeing dummy_tx/rx before it is unmappedMartin Sperl2015-05-111-5/+6
| | | | | | | | | | | | | | | | | | | | Fix a race (with some kernel configurations) where a queued master->pump_messages runs and frees dummy_tx/rx before spi_unmap_msg is running (or is finished). This results in the following messages: BUG: Bad page state in process page:db7ba030 count:0 mapcount:0 mapping: (null) index:0x0 flags: 0x200(arch_1) page dumped because: PAGE_FLAGS_CHECK_AT_PREP flag set ... Reported-by: Noralf Trønnes <noralf@tronnes.org> Suggested-by: Noralf Trønnes <noralf@tronnes.org> Tested-by: Noralf Trønnes <noralf@tronnes.org> Signed-off-by: Martin Sperl <kernel@martin.sperl.org> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
* spi: check tx_buf and rx_buf in spi_unmap_msgRobin Gong2015-04-161-0/+9
| | | | | | | | | | | | | Some spi device drivers use the same tx_buf and rx_buf repeatly for better performance such as driver/input/touchsreen/ads7846.c, but spi core grab tx_buf /rx_buf of transfer and set them as dummy_tx/dummy_rx once they are NULL. Thus, in the second time the tx_buf/rx_buf will be replaced by dummy_tx/dummy_rx and the data which produced by the last tx or rx may be wrongly sent to the device or handled by the upper level protocol. This patch just keep the orignal value of tx_buf/rx_buf if they are NULL after this transfer processed. Signed-off-by: Robin Gong <b38343@freescale.com> Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'spi/topic/omap-100k', ↵Mark Brown2015-04-111-114/+0
|\ \ | | | | | | | | | 'spi/topic/omap-uwire', 'spi/topic/pl022', 'spi/topic/pm' and 'spi/topic/pxa2xx' into spi-next
| | * spi: Remove support for legacy PMLars-Peter Clausen2015-03-081-114/+0
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | All SPI drivers have been converted from legacy suspend/resume callbacks to dev_pm_ops. So we can finally remove support for legacy PM from the SPI core. Since there aren't any special bus specific things to do during suspend/resume and since the PM core will automatically fallback directly to using the device's PM ops if no bus PM ops are specified there is no need to have any special SPI bus PM ops. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
| |
| \
| \
| \
*---. \ Merge remote-tracking branches 'spi/topic/blackfin', 'spi/topic/cadence', ↵Mark Brown2015-04-111-1/+1
|\ \ \ \ | | |_|/ | |/| | | | | | 'spi/topic/dw' and 'spi/topic/err' into spi-next
| | | * spi: Make master->handle_err() callback optional to avoid crashesGeert Uytterhoeven2015-04-071-1/+1
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a driver doesn't implement the master->handle_err() callback and an SPI transfer fails, the kernel will crash with a NULL pointer dereference: Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0003000 [00000000] *pgd=80000040004003, *pmd=00000000 Internal error: Oops: 80000206 [#1] SMP ARM Modules linked in: CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.0.0-rc7-koelsch-05861-g1fc9fdd4add4f783 #1046 Hardware name: Generic R8A7791 (Flattened Device Tree) task: eec359c0 ti: eec54000 task.ti: eec54000 PC is at 0x0 LR is at spi_transfer_one_message+0x1cc/0x1f0 Make the master->handle_err() callback optional to avoid the crash. Also fix a spelling mistake in the callback documentation while we're at it. Fixes: b716c4ffc6a2b0bf ("spi: introduce master->handle_err() callback") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org>
| | |
| \ \
| \ \
| \ \
*---. \ \ Merge remote-tracking branches 'spi/topic/atmel', 'spi/topic/bcm2385', ↵Mark Brown2015-04-111-0/+3
|\ \ \ \ \ | | |_|/ / | |/| | / | | | |/ | | |/| 'spi/topic/bcm2835', 'spi/topic/bcm53xx' and 'spi/topic/bitbang' into spi-next
| | * | spi: introduce master->handle_err() callbackAndy Shevchenko2015-03-061-0/+3
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | This callback would be useful to handle an error that occurs in the generic implementation of transfer_one_message(). The good candidate for this is to drain FIFO and / or to terminate DMA transfers when timeout happened. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | | Merge remote-tracking branch 'spi/topic/core' into spi-nextMark Brown2015-04-111-2/+2
|\ \ \
| * | | spi: of: do explicitly request modules for of-registered devicesDmitry Torokhov2015-03-251-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Trying to register an SPI device asynchronously (via async_schedule() call) results in an ugly complaint from request_module() warning about potential deadlock (because request_module tries to wait for async works to complete, the caller is also an async work in this case). While we could try to switch to using request_module_nowait(), other buses, as well as SPI itself when not using device tree, do not try to load modules explicitly, but rather rely on the standard infrastructure (such as udev) to execute module loading. There is no reason why SPI OF-described devices should be treated differently. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * | | spi: Ensure that CS line is in non-active state after spi_setup()Ivan T. Ivanov2015-03-161-0/+2
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | Some devices samples state of the chip select signal during power up and act differently based on this state, so SPI core should ensure that CS line is driven in non-active state after spi_setup(). Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | | spi: trigger trace event for message-done before mesg->completeUwe Kleine-König2015-03-181-2/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With spidev the mesg->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 > /sys/kernel/debug/tracing/events/spi/enable . Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
| |
| \
*-. \ Merge remote-tracking branches 'spi/topic/img-spfi', 'spi/topic/imx', ↵Mark Brown2015-02-081-21/+93
|\ \ \ | | |/ | |/| | | | 'spi/topic/inline', 'spi/topic/meson' and 'spi/topic/mxs' into spi-next
| | * spi: Only idle the message pump in the worker kthreadMark Brown2014-12-111-6/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to avoid the situation where the kthread is waiting for another context to make the hardware idle let the message pump know if it's being called from the worker thread context and if it isn't then defer to the worker thread instead of idling the hardware immediately. This will ensure that if this situation happens we block rather than busy waiting. Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: Pump transfers inside calling context for spi_sync()Mark Brown2014-12-111-8/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we are using the standard SPI message pump (which all drivers should be transitioning over to) then special case the message enqueue and instead of starting the worker thread to push messages to the hardware do so in the context of the caller if the controller is idle. This avoids a context switch in the common case where the controller has a single user in a single thread, for short PIO transfers there may be no need to context switch away from the calling context to complete the transfer. The code is a bit more complex than is desirable in part due to the need to handle drivers not using the standard queue and in part due to handling the various combinations of bus locking and asynchronous submission in interrupt context. It is still suboptimal since it will still wake the message pump for each transfer in order to schedule idling of the hardware and if multiple contexts are using the controller simultaneously a caller may end up pumping a message for some random other thread rather than for itself, and if the thread ends up deferring due to another context idling the hardware then it will just busy wait. It can, however, have the benefit of aggregating power up and down of the hardware when a caller performs a series of transfers back to back without any need for the use of spi_async(). Signed-off-by: Mark Brown <broonie@kernel.org>
| | * spi: Check to see if the device is processing a message before we idleMark Brown2014-12-111-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cur_msg is updated under the queue lock and holds the message we are currently processing. Since currently we only ever do removals in the pump kthread it doesn't matter in what order we do things but we want to be able to push things out from the submitting thread so pull the check to see if we're currently handling a message before we check to see if the queue is idle. Signed-off-by: Mark Brown <broonie@kernel.org>
OpenPOWER on IntegriCloud