Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branches 'spi/fix/au1550', 'spi/fix/davinci', 'spi/fix/doc', 'spi/fix/dw', 'spi/fix/omap-mcspi', 'spi/fix/pxa2xx', 'spi/fix/rockchip' and 'spi/fix/rspi' into spi-linus

+83 -49
+1 -1
drivers/spi/spi-au1550.c
··· 945 945 spi_bitbang_stop(&hw->bitbang); 946 946 free_irq(hw->irq, hw); 947 947 iounmap((void __iomem *)hw->regs); 948 - release_mem_region(r->start, sizeof(psc_spi_t)); 948 + release_mem_region(hw->ioarea->start, sizeof(psc_spi_t)); 949 949 950 950 if (hw->usedma) { 951 951 au1550_spi_dma_rxtmp_free(hw);
+8 -8
drivers/spi/spi-davinci.c
··· 417 417 flags, dev_name(&spi->dev)); 418 418 internal_cs = false; 419 419 } 420 - } 421 420 422 - if (retval) { 423 - dev_err(&spi->dev, "GPIO %d setup failed (%d)\n", 424 - spi->cs_gpio, retval); 425 - return retval; 426 - } 421 + if (retval) { 422 + dev_err(&spi->dev, "GPIO %d setup failed (%d)\n", 423 + spi->cs_gpio, retval); 424 + return retval; 425 + } 427 426 428 - if (internal_cs) 429 - set_io_bits(dspi->base + SPIPC0, 1 << spi->chip_select); 427 + if (internal_cs) 428 + set_io_bits(dspi->base + SPIPC0, 1 << spi->chip_select); 429 + } 430 430 431 431 if (spi->mode & SPI_READY) 432 432 set_io_bits(dspi->base + SPIPC0, SPIPC0_SPIENA_MASK);
+2
drivers/spi/spi-dw-pci.c
··· 62 62 if (ret) 63 63 return ret; 64 64 65 + dws->regs = pcim_iomap_table(pdev)[pci_bar]; 66 + 65 67 dws->bus_num = 0; 66 68 dws->num_cs = 4; 67 69 dws->irq = pdev->irq;
+1 -1
drivers/spi/spi-dw.c
··· 271 271 transfer_list); 272 272 273 273 if (!last_transfer->cs_change) 274 - spi_chip_sel(dws, dws->cur_msg->spi, 0); 274 + spi_chip_sel(dws, msg->spi, 0); 275 275 276 276 spi_finalize_current_message(dws->master); 277 277 }
+2 -1
drivers/spi/spi-omap2-mcspi.c
··· 329 329 disable_fifo: 330 330 if (t->rx_buf != NULL) 331 331 chconf &= ~OMAP2_MCSPI_CHCONF_FFER; 332 - else 332 + 333 + if (t->tx_buf != NULL) 333 334 chconf &= ~OMAP2_MCSPI_CHCONF_FFET; 334 335 335 336 mcspi_write_chconf0(spi, chconf);
+1
drivers/spi/spi-pxa2xx.c
··· 1074 1074 { "INT3430", 0 }, 1075 1075 { "INT3431", 0 }, 1076 1076 { "80860F0E", 0 }, 1077 + { "8086228E", 0 }, 1077 1078 { }, 1078 1079 }; 1079 1080 MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match);
+2 -2
drivers/spi/spi-rockchip.c
··· 499 499 } 500 500 501 501 /* div doesn't support odd number */ 502 - div = rs->max_freq / rs->speed; 502 + div = max_t(u32, rs->max_freq / rs->speed, 1); 503 503 div = (div + 1) & 0xfffe; 504 504 505 505 spi_enable_chip(rs, 0); ··· 678 678 rs->dma_tx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_TXDR); 679 679 rs->dma_rx.addr = (dma_addr_t)(mem->start + ROCKCHIP_SPI_RXDR); 680 680 rs->dma_tx.direction = DMA_MEM_TO_DEV; 681 - rs->dma_tx.direction = DMA_DEV_TO_MEM; 681 + rs->dma_rx.direction = DMA_DEV_TO_MEM; 682 682 683 683 master->can_dma = rockchip_spi_can_dma; 684 684 master->dma_tx = rs->dma_tx.ch;
+58 -36
drivers/spi/spi-rspi.c
··· 472 472 dma_cookie_t cookie; 473 473 int ret; 474 474 475 - if (tx) { 476 - desc_tx = dmaengine_prep_slave_sg(rspi->master->dma_tx, 477 - tx->sgl, tx->nents, DMA_TO_DEVICE, 478 - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 479 - if (!desc_tx) 480 - goto no_dma; 481 - 482 - irq_mask |= SPCR_SPTIE; 483 - } 475 + /* First prepare and submit the DMA request(s), as this may fail */ 484 476 if (rx) { 485 477 desc_rx = dmaengine_prep_slave_sg(rspi->master->dma_rx, 486 478 rx->sgl, rx->nents, DMA_FROM_DEVICE, 487 479 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 488 - if (!desc_rx) 489 - goto no_dma; 480 + if (!desc_rx) { 481 + ret = -EAGAIN; 482 + goto no_dma_rx; 483 + } 484 + 485 + desc_rx->callback = rspi_dma_complete; 486 + desc_rx->callback_param = rspi; 487 + cookie = dmaengine_submit(desc_rx); 488 + if (dma_submit_error(cookie)) { 489 + ret = cookie; 490 + goto no_dma_rx; 491 + } 490 492 491 493 irq_mask |= SPCR_SPRIE; 494 + } 495 + 496 + if (tx) { 497 + desc_tx = dmaengine_prep_slave_sg(rspi->master->dma_tx, 498 + tx->sgl, tx->nents, DMA_TO_DEVICE, 499 + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 500 + if (!desc_tx) { 501 + ret = -EAGAIN; 502 + goto no_dma_tx; 503 + } 504 + 505 + if (rx) { 506 + /* No callback */ 507 + desc_tx->callback = NULL; 508 + } else { 509 + desc_tx->callback = rspi_dma_complete; 510 + desc_tx->callback_param = rspi; 511 + } 512 + cookie = dmaengine_submit(desc_tx); 513 + if (dma_submit_error(cookie)) { 514 + ret = cookie; 515 + goto no_dma_tx; 516 + } 517 + 518 + irq_mask |= SPCR_SPTIE; 492 519 } 493 520 494 521 /* ··· 530 503 rspi_enable_irq(rspi, irq_mask); 531 504 rspi->dma_callbacked = 0; 532 505 533 - if (rx) { 534 - desc_rx->callback = rspi_dma_complete; 535 - desc_rx->callback_param = rspi; 536 - cookie = dmaengine_submit(desc_rx); 537 - if (dma_submit_error(cookie)) 538 - return cookie; 506 + /* Now start DMA */ 507 + if (rx) 539 508 dma_async_issue_pending(rspi->master->dma_rx); 540 - } 541 - if (tx) { 542 - if (rx) { 543 - /* No callback */ 544 - desc_tx->callback = NULL; 545 - } else { 546 - desc_tx->callback = rspi_dma_complete; 547 - desc_tx->callback_param = rspi; 548 - } 549 - cookie = dmaengine_submit(desc_tx); 550 - if (dma_submit_error(cookie)) 551 - return cookie; 509 + if (tx) 552 510 dma_async_issue_pending(rspi->master->dma_tx); 553 - } 554 511 555 512 ret = wait_event_interruptible_timeout(rspi->wait, 556 513 rspi->dma_callbacked, HZ); 557 514 if (ret > 0 && rspi->dma_callbacked) 558 515 ret = 0; 559 - else if (!ret) 516 + else if (!ret) { 517 + dev_err(&rspi->master->dev, "DMA timeout\n"); 560 518 ret = -ETIMEDOUT; 519 + if (tx) 520 + dmaengine_terminate_all(rspi->master->dma_tx); 521 + if (rx) 522 + dmaengine_terminate_all(rspi->master->dma_rx); 523 + } 561 524 562 525 rspi_disable_irq(rspi, irq_mask); 563 526 ··· 558 541 559 542 return ret; 560 543 561 - no_dma: 562 - pr_warn_once("%s %s: DMA not available, falling back to PIO\n", 563 - dev_driver_string(&rspi->master->dev), 564 - dev_name(&rspi->master->dev)); 565 - return -EAGAIN; 544 + no_dma_tx: 545 + if (rx) 546 + dmaengine_terminate_all(rspi->master->dma_rx); 547 + no_dma_rx: 548 + if (ret == -EAGAIN) { 549 + pr_warn_once("%s %s: DMA not available, falling back to PIO\n", 550 + dev_driver_string(&rspi->master->dev), 551 + dev_name(&rspi->master->dev)); 552 + } 553 + return ret; 566 554 } 567 555 568 556 static void rspi_receive_init(const struct rspi_data *rspi)
+1
drivers/spi/spi.c
··· 848 848 849 849 /** 850 850 * spi_finalize_current_transfer - report completion of a transfer 851 + * @master: the master reporting completion 851 852 * 852 853 * Called by SPI drivers using the core transfer_one_message() 853 854 * implementation to notify it that the current interrupt driven
+7
include/linux/spi/spi.h
··· 253 253 * the device whose settings are being modified. 254 254 * @transfer: adds a message to the controller's transfer queue. 255 255 * @cleanup: frees controller-specific state 256 + * @can_dma: determine whether this master supports DMA 256 257 * @queued: whether this master is providing an internal message queue 257 258 * @kworker: thread struct for message pump 258 259 * @kworker_task: pointer to task for message pump kworker thread ··· 263 262 * @cur_msg: the currently in-flight message 264 263 * @cur_msg_prepared: spi_prepare_message was called for the currently 265 264 * in-flight message 265 + * @cur_msg_mapped: message has been mapped for DMA 266 266 * @xfer_completion: used by core transfer_one_message() 267 267 * @busy: message pump is busy 268 268 * @running: message pump is running ··· 301 299 * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS 302 300 * number. Any individual value may be -ENOENT for CS lines that 303 301 * are not GPIOs (driven by the SPI controller itself). 302 + * @dma_tx: DMA transmit channel 303 + * @dma_rx: DMA receive channel 304 + * @dummy_rx: dummy receive buffer for full-duplex devices 305 + * @dummy_tx: dummy transmit buffer for full-duplex devices 304 306 * 305 307 * Each SPI master controller can communicate with one or more @spi_device 306 308 * children. These make a small bus, sharing MOSI, MISO and SCK signals ··· 638 632 * addresses for each transfer buffer 639 633 * @complete: called to report transaction completions 640 634 * @context: the argument to complete() when it's called 635 + * @frame_length: the total number of bytes in the message 641 636 * @actual_length: the total number of bytes that were transferred in all 642 637 * successful segments 643 638 * @status: zero for success, else negative errno