aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2008-07-25 22:44:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-26 15:00:03 -0400
commit8d8bb39b9eba32dd70e87fd5ad5c5dd4ba118e06 (patch)
tree64090a84f4c4466f9f30ff46c993e0cede379052 /drivers/spi
parentc485b465a031b6f9b9a51300e0ee1f86efc6db87 (diff)
dma-mapping: add the device argument to dma_mapping_error()
Add per-device dma_mapping_ops support for CONFIG_X86_64 as POWER architecture does: This enables us to cleanly fix the Calgary IOMMU issue that some devices are not behind the IOMMU (http://lkml.org/lkml/2008/5/8/423). I think that per-device dma_mapping_ops support would be also helpful for KVM people to support PCI passthrough but Andi thinks that this makes it difficult to support the PCI passthrough (see the above thread). So I CC'ed this to KVM camp. Comments are appreciated. A pointer to dma_mapping_ops to struct dev_archdata is added. If the pointer is non NULL, DMA operations in asm/dma-mapping.h use it. If it's NULL, the system-wide dma_ops pointer is used as before. If it's useful for KVM people, I plan to implement a mechanism to register a hook called when a new pci (or dma capable) device is created (it works with hot plugging). It enables IOMMUs to set up an appropriate dma_mapping_ops per device. The major obstacle is that dma_mapping_error doesn't take a pointer to the device unlike other DMA operations. So x86 can't have dma_mapping_ops per device. Note all the POWER IOMMUs use the same dma_mapping_error function so this is not a problem for POWER but x86 IOMMUs use different dma_mapping_error functions. The first patch adds the device argument to dma_mapping_error. The patch is trivial but large since it touches lots of drivers and dma-mapping.h in all the architecture. This patch: dma_mapping_error() doesn't take a pointer to the device unlike other DMA operations. So we can't have dma_mapping_ops per device. Note that POWER already has dma_mapping_ops per device but all the POWER IOMMUs use the same dma_mapping_error function. x86 IOMMUs use device argument. [akpm@linux-foundation.org: fix sge] [akpm@linux-foundation.org: fix svc_rdma] [akpm@linux-foundation.org: build fix] [akpm@linux-foundation.org: fix bnx2x] [akpm@linux-foundation.org: fix s2io] [akpm@linux-foundation.org: fix pasemi_mac] [akpm@linux-foundation.org: fix sdhci] [akpm@linux-foundation.org: build fix] [akpm@linux-foundation.org: fix sparc] [akpm@linux-foundation.org: fix ibmvscsi] Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Muli Ben-Yehuda <muli@il.ibm.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@elte.hu> Cc: Avi Kivity <avi@qumranet.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/atmel_spi.c4
-rw-r--r--drivers/spi/au1550_spi.c6
-rw-r--r--drivers/spi/omap2_mcspi.c4
-rw-r--r--drivers/spi/pxa2xx_spi.c4
-rw-r--r--drivers/spi/spi_imx.c6
5 files changed, 12 insertions, 12 deletions
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index e81d59d78910..0c7165660853 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -313,14 +313,14 @@ atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer)
313 xfer->tx_dma = dma_map_single(dev, 313 xfer->tx_dma = dma_map_single(dev,
314 (void *) xfer->tx_buf, xfer->len, 314 (void *) xfer->tx_buf, xfer->len,
315 DMA_TO_DEVICE); 315 DMA_TO_DEVICE);
316 if (dma_mapping_error(xfer->tx_dma)) 316 if (dma_mapping_error(dev, xfer->tx_dma))
317 return -ENOMEM; 317 return -ENOMEM;
318 } 318 }
319 if (xfer->rx_buf) { 319 if (xfer->rx_buf) {
320 xfer->rx_dma = dma_map_single(dev, 320 xfer->rx_dma = dma_map_single(dev,
321 xfer->rx_buf, xfer->len, 321 xfer->rx_buf, xfer->len,
322 DMA_FROM_DEVICE); 322 DMA_FROM_DEVICE);
323 if (dma_mapping_error(xfer->rx_dma)) { 323 if (dma_mapping_error(dev, xfer->rx_dma)) {
324 if (xfer->tx_buf) 324 if (xfer->tx_buf)
325 dma_unmap_single(dev, 325 dma_unmap_single(dev,
326 xfer->tx_dma, xfer->len, 326 xfer->tx_dma, xfer->len,
diff --git a/drivers/spi/au1550_spi.c b/drivers/spi/au1550_spi.c
index 9149689c79d9..87b73e0169c5 100644
--- a/drivers/spi/au1550_spi.c
+++ b/drivers/spi/au1550_spi.c
@@ -334,7 +334,7 @@ static int au1550_spi_dma_rxtmp_alloc(struct au1550_spi *hw, unsigned size)
334 hw->dma_rx_tmpbuf_size = size; 334 hw->dma_rx_tmpbuf_size = size;
335 hw->dma_rx_tmpbuf_addr = dma_map_single(hw->dev, hw->dma_rx_tmpbuf, 335 hw->dma_rx_tmpbuf_addr = dma_map_single(hw->dev, hw->dma_rx_tmpbuf,
336 size, DMA_FROM_DEVICE); 336 size, DMA_FROM_DEVICE);
337 if (dma_mapping_error(hw->dma_rx_tmpbuf_addr)) { 337 if (dma_mapping_error(hw->dev, hw->dma_rx_tmpbuf_addr)) {
338 kfree(hw->dma_rx_tmpbuf); 338 kfree(hw->dma_rx_tmpbuf);
339 hw->dma_rx_tmpbuf = 0; 339 hw->dma_rx_tmpbuf = 0;
340 hw->dma_rx_tmpbuf_size = 0; 340 hw->dma_rx_tmpbuf_size = 0;
@@ -378,7 +378,7 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
378 dma_rx_addr = dma_map_single(hw->dev, 378 dma_rx_addr = dma_map_single(hw->dev,
379 (void *)t->rx_buf, 379 (void *)t->rx_buf,
380 t->len, DMA_FROM_DEVICE); 380 t->len, DMA_FROM_DEVICE);
381 if (dma_mapping_error(dma_rx_addr)) 381 if (dma_mapping_error(hw->dev, dma_rx_addr))
382 dev_err(hw->dev, "rx dma map error\n"); 382 dev_err(hw->dev, "rx dma map error\n");
383 } 383 }
384 } else { 384 } else {
@@ -401,7 +401,7 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
401 dma_tx_addr = dma_map_single(hw->dev, 401 dma_tx_addr = dma_map_single(hw->dev,
402 (void *)t->tx_buf, 402 (void *)t->tx_buf,
403 t->len, DMA_TO_DEVICE); 403 t->len, DMA_TO_DEVICE);
404 if (dma_mapping_error(dma_tx_addr)) 404 if (dma_mapping_error(hw->dev, dma_tx_addr))
405 dev_err(hw->dev, "tx dma map error\n"); 405 dev_err(hw->dev, "tx dma map error\n");
406 } 406 }
407 } else { 407 } else {
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index b1cc148036c1..f6f987bb71ca 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -836,7 +836,7 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m)
836 if (tx_buf != NULL) { 836 if (tx_buf != NULL) {
837 t->tx_dma = dma_map_single(&spi->dev, (void *) tx_buf, 837 t->tx_dma = dma_map_single(&spi->dev, (void *) tx_buf,
838 len, DMA_TO_DEVICE); 838 len, DMA_TO_DEVICE);
839 if (dma_mapping_error(t->tx_dma)) { 839 if (dma_mapping_error(&spi->dev, t->tx_dma)) {
840 dev_dbg(&spi->dev, "dma %cX %d bytes error\n", 840 dev_dbg(&spi->dev, "dma %cX %d bytes error\n",
841 'T', len); 841 'T', len);
842 return -EINVAL; 842 return -EINVAL;
@@ -845,7 +845,7 @@ static int omap2_mcspi_transfer(struct spi_device *spi, struct spi_message *m)
845 if (rx_buf != NULL) { 845 if (rx_buf != NULL) {
846 t->rx_dma = dma_map_single(&spi->dev, rx_buf, t->len, 846 t->rx_dma = dma_map_single(&spi->dev, rx_buf, t->len,
847 DMA_FROM_DEVICE); 847 DMA_FROM_DEVICE);
848 if (dma_mapping_error(t->rx_dma)) { 848 if (dma_mapping_error(&spi->dev, t->rx_dma)) {
849 dev_dbg(&spi->dev, "dma %cX %d bytes error\n", 849 dev_dbg(&spi->dev, "dma %cX %d bytes error\n",
850 'R', len); 850 'R', len);
851 if (tx_buf != NULL) 851 if (tx_buf != NULL)
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 0c452c46ab07..067299d6d192 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -353,7 +353,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
353 drv_data->rx_dma = dma_map_single(dev, drv_data->rx, 353 drv_data->rx_dma = dma_map_single(dev, drv_data->rx,
354 drv_data->rx_map_len, 354 drv_data->rx_map_len,
355 DMA_FROM_DEVICE); 355 DMA_FROM_DEVICE);
356 if (dma_mapping_error(drv_data->rx_dma)) 356 if (dma_mapping_error(dev, drv_data->rx_dma))
357 return 0; 357 return 0;
358 358
359 /* Stream map the tx buffer */ 359 /* Stream map the tx buffer */
@@ -361,7 +361,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
361 drv_data->tx_map_len, 361 drv_data->tx_map_len,
362 DMA_TO_DEVICE); 362 DMA_TO_DEVICE);
363 363
364 if (dma_mapping_error(drv_data->tx_dma)) { 364 if (dma_mapping_error(dev, drv_data->tx_dma)) {
365 dma_unmap_single(dev, drv_data->rx_dma, 365 dma_unmap_single(dev, drv_data->rx_dma,
366 drv_data->rx_map_len, DMA_FROM_DEVICE); 366 drv_data->rx_map_len, DMA_FROM_DEVICE);
367 return 0; 367 return 0;
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 54ac7bea5f8c..6fb77fcc4971 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -491,7 +491,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
491 buf, 491 buf,
492 drv_data->tx_map_len, 492 drv_data->tx_map_len,
493 DMA_TO_DEVICE); 493 DMA_TO_DEVICE);
494 if (dma_mapping_error(drv_data->tx_dma)) 494 if (dma_mapping_error(dev, drv_data->tx_dma))
495 return -1; 495 return -1;
496 496
497 drv_data->tx_dma_needs_unmap = 1; 497 drv_data->tx_dma_needs_unmap = 1;
@@ -516,7 +516,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
516 buf, 516 buf,
517 drv_data->len, 517 drv_data->len,
518 DMA_FROM_DEVICE); 518 DMA_FROM_DEVICE);
519 if (dma_mapping_error(drv_data->rx_dma)) 519 if (dma_mapping_error(dev, drv_data->rx_dma))
520 return -1; 520 return -1;
521 drv_data->rx_dma_needs_unmap = 1; 521 drv_data->rx_dma_needs_unmap = 1;
522 } 522 }
@@ -534,7 +534,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
534 buf, 534 buf,
535 drv_data->tx_map_len, 535 drv_data->tx_map_len,
536 DMA_TO_DEVICE); 536 DMA_TO_DEVICE);
537 if (dma_mapping_error(drv_data->tx_dma)) { 537 if (dma_mapping_error(dev, drv_data->tx_dma)) {
538 if (drv_data->rx_dma) { 538 if (drv_data->rx_dma) {
539 dma_unmap_single(dev, 539 dma_unmap_single(dev,
540 drv_data->rx_dma, 540 drv_data->rx_dma,