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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'spi-v3.17-rc3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi bugfixes from Mark Brown:
"A smattering of bug fixes for the SPI subsystem, all in driver code
which has seen active work recently and none of them with any great
global impact.

There's also a new ACPI ID for the pxa2xx driver which required no
code changes and the addition of kerneldoc for some structure fields
that were missing it and generating warnings during documentation
builds as a result"

* tag 'spi-v3.17-rc3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
spi: sh-msiof: Fix transmit-only DMA transfers
spi/rockchip: Avoid accidentally turning off the clock
spi: dw: fix kernel crash due to NULL pointer dereference
spi: dw-pci: fix bug when regs left uninitialized
spi: davinci: fix SPI_NO_CS functionality
spi/rockchip: fixup incorrect dma direction setting
spi/pxa2xx: Add ACPI ID for Intel Braswell
spi: spi-au1550: fix build failure
spi: rspi: Fix leaking of unused DMA descriptors
spi: sh-msiof: Fix leaking of unused DMA descriptors
spi: Add missing kerneldoc bits
spi/omap-mcspi: Fix the spi task hangs waiting dma_rx

+126 -87
+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)
+43 -38
drivers/spi/spi-sh-msiof.c
··· 636 636 dma_cookie_t cookie; 637 637 int ret; 638 638 639 + /* First prepare and submit the DMA request(s), as this may fail */ 640 + if (rx) { 641 + ier_bits |= IER_RDREQE | IER_RDMAE; 642 + desc_rx = dmaengine_prep_slave_single(p->master->dma_rx, 643 + p->rx_dma_addr, len, DMA_FROM_DEVICE, 644 + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 645 + if (!desc_rx) { 646 + ret = -EAGAIN; 647 + goto no_dma_rx; 648 + } 649 + 650 + desc_rx->callback = sh_msiof_dma_complete; 651 + desc_rx->callback_param = p; 652 + cookie = dmaengine_submit(desc_rx); 653 + if (dma_submit_error(cookie)) { 654 + ret = cookie; 655 + goto no_dma_rx; 656 + } 657 + } 658 + 639 659 if (tx) { 640 660 ier_bits |= IER_TDREQE | IER_TDMAE; 641 661 dma_sync_single_for_device(p->master->dma_tx->device->dev, ··· 663 643 desc_tx = dmaengine_prep_slave_single(p->master->dma_tx, 664 644 p->tx_dma_addr, len, DMA_TO_DEVICE, 665 645 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 666 - if (!desc_tx) 667 - return -EAGAIN; 668 - } 646 + if (!desc_tx) { 647 + ret = -EAGAIN; 648 + goto no_dma_tx; 649 + } 669 650 670 - if (rx) { 671 - ier_bits |= IER_RDREQE | IER_RDMAE; 672 - desc_rx = dmaengine_prep_slave_single(p->master->dma_rx, 673 - p->rx_dma_addr, len, DMA_FROM_DEVICE, 674 - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 675 - if (!desc_rx) 676 - return -EAGAIN; 651 + if (rx) { 652 + /* No callback */ 653 + desc_tx->callback = NULL; 654 + } else { 655 + desc_tx->callback = sh_msiof_dma_complete; 656 + desc_tx->callback_param = p; 657 + } 658 + cookie = dmaengine_submit(desc_tx); 659 + if (dma_submit_error(cookie)) { 660 + ret = cookie; 661 + goto no_dma_tx; 662 + } 677 663 } 678 664 679 665 /* 1 stage FIFO watermarks for DMA */ ··· 692 666 693 667 reinit_completion(&p->done); 694 668 695 - if (rx) { 696 - desc_rx->callback = sh_msiof_dma_complete; 697 - desc_rx->callback_param = p; 698 - cookie = dmaengine_submit(desc_rx); 699 - if (dma_submit_error(cookie)) { 700 - ret = cookie; 701 - goto stop_ier; 702 - } 669 + /* Now start DMA */ 670 + if (rx) 703 671 dma_async_issue_pending(p->master->dma_rx); 704 - } 705 - 706 - if (tx) { 707 - if (rx) { 708 - /* No callback */ 709 - desc_tx->callback = NULL; 710 - } else { 711 - desc_tx->callback = sh_msiof_dma_complete; 712 - desc_tx->callback_param = p; 713 - } 714 - cookie = dmaengine_submit(desc_tx); 715 - if (dma_submit_error(cookie)) { 716 - ret = cookie; 717 - goto stop_rx; 718 - } 672 + if (tx) 719 673 dma_async_issue_pending(p->master->dma_tx); 720 - } 721 674 722 675 ret = sh_msiof_spi_start(p, rx); 723 676 if (ret) { 724 677 dev_err(&p->pdev->dev, "failed to start hardware\n"); 725 - goto stop_tx; 678 + goto stop_dma; 726 679 } 727 680 728 681 /* wait for tx fifo to be emptied / rx fifo to be filled */ ··· 731 726 stop_reset: 732 727 sh_msiof_reset_str(p); 733 728 sh_msiof_spi_stop(p, rx); 734 - stop_tx: 729 + stop_dma: 735 730 if (tx) 736 731 dmaengine_terminate_all(p->master->dma_tx); 737 - stop_rx: 732 + no_dma_tx: 738 733 if (rx) 739 734 dmaengine_terminate_all(p->master->dma_rx); 740 - stop_ier: 741 735 sh_msiof_write(p, IER, 0); 736 + no_dma_rx: 742 737 return ret; 743 738 } 744 739
+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