summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorVignesh R <vigneshr@ti.com>2016-08-17 15:22:36 +0530
committerMark Brown <broonie@kernel.org>2016-08-17 12:24:01 +0100
commitb1b8153cf0aeeb7ae6d4f012b8beb2dcfc92c68a (patch)
treeb9fb07d7e31ff24bc7fb47138129548750d9612f /drivers
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
downloadtalos-op-linux-b1b8153cf0aeeb7ae6d4f012b8beb2dcfc92c68a.tar.gz
talos-op-linux-b1b8153cf0aeeb7ae6d4f012b8beb2dcfc92c68a.zip
spi: Add support to handle kmap'd buffers in spi_map_buf()
JFFS2 FS might sometime provide kmap'd buffers as destination buffers to read data from flash. Update spi_map_buf() function to generate sg_list for such buffers, so that SPI controllers drivers can use DMA to read data into such buffers. Signed-off-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/spi.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 51ad42fad567..2a5dd22efa34 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -37,6 +37,7 @@
#include <linux/kthread.h>
#include <linux/ioport.h>
#include <linux/acpi.h>
+#include <linux/highmem.h>
#define CREATE_TRACE_POINTS
#include <trace/events/spi.h>
@@ -709,6 +710,13 @@ static int spi_map_buf(struct spi_master *master, struct device *dev,
{
const bool vmalloced_buf = is_vmalloc_addr(buf);
unsigned int max_seg_size = dma_get_max_seg_size(dev);
+#ifdef CONFIG_HIGHMEM
+ const bool kmap_buf = ((unsigned long)buf >= PKMAP_BASE &&
+ (unsigned long)buf < (PKMAP_BASE +
+ (LAST_PKMAP * PAGE_SIZE)));
+#else
+ const bool kmap_buf = false;
+#endif
int desc_len;
int sgs;
struct page *vm_page;
@@ -716,7 +724,7 @@ static int spi_map_buf(struct spi_master *master, struct device *dev,
size_t min;
int i, ret;
- if (vmalloced_buf) {
+ if (vmalloced_buf || kmap_buf) {
desc_len = min_t(int, max_seg_size, PAGE_SIZE);
sgs = DIV_ROUND_UP(len + offset_in_page(buf), desc_len);
} else if (virt_addr_valid(buf)) {
@@ -732,10 +740,13 @@ static int spi_map_buf(struct spi_master *master, struct device *dev,
for (i = 0; i < sgs; i++) {
- if (vmalloced_buf) {
+ if (vmalloced_buf || kmap_buf) {
min = min_t(size_t,
len, desc_len - offset_in_page(buf));
- vm_page = vmalloc_to_page(buf);
+ if (vmalloced_buf)
+ vm_page = vmalloc_to_page(buf);
+ else
+ vm_page = kmap_to_page(buf);
if (!vm_page) {
sg_free_table(sgt);
return -ENOMEM;
OpenPOWER on IntegriCloud