Merge tag 'dmaengine-5.2-rc1' of git://git.infradead.org/users/vkoul/slave-dma
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 9 May 2019 15:51:45 +0000 (08:51 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 9 May 2019 15:51:45 +0000 (08:51 -0700)
Pull dmaengine updates from Vinod Koul:

 - Updates to stm32 dma residue calculations

 - Interleave dma capability to axi-dmac and support for ZynqMP arch

 - Rework of channel assignment for rcar dma

 - Debugfs for pl330 driver

 - Support for Tegra186/Tegra194, refactoring for new chips and support
   for pause/resume

 - Updates to axi-dmac, bcm2835, fsl-edma, idma64, imx-sdma, rcar-dmac,
   stm32-dma etc

 - dev_get_drvdata() updates on few drivers

* tag 'dmaengine-5.2-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (34 commits)
  dmaengine: tegra210-adma: restore channel status
  dmaengine: tegra210-dma: free dma controller in remove()
  dmaengine: tegra210-adma: add pause/resume support
  dmaengine: tegra210-adma: add support for Tegra186/Tegra194
  Documentation: DT: Add compatibility binding for Tegra186
  dmaengine: tegra210-adma: prepare for supporting newer Tegra chips
  dmaengine: at_xdmac: remove a stray bottom half unlock
  dmaengine: fsl-edma: Adjust indentation
  dmaengine: fsl-edma: Fix typo in Vybrid name
  dmaengine: stm32-dma: fix residue calculation in stm32-dma
  dmaengine: nbpfaxi: Use dev_get_drvdata()
  dmaengine: bcm-sba-raid: Use dev_get_drvdata()
  dmaengine: stm32-dma: Fix unsigned variable compared with zero
  dmaengine: stm32-dma: use platform_get_irq()
  dmaengine: rcar-dmac: Update copyright information
  dmaengine: imx-sdma: Only check ratio on parts that support 1:1
  dmaengine: xgene-dma: fix spelling mistake "descripto" -> "descriptor"
  dmaengine: idma64: Move driver name to the header
  dmaengine: bcm2835: Drop duplicate capability setting.
  dmaengine: pl330: _stop: clear interrupt status
  ...

1  2 
drivers/dma/bcm2835-dma.c
drivers/dma/sh/rcar-dmac.c
drivers/spi/spi-pxa2xx.c

index 54093ffd0aefa8a7c3a40f887958c61b2222d03c,e38b19dd2895ee5b3447415abfcbfcc52bb1fa24..8101ff2f05c1c326f67c4214a2bd93f73ce9c158
@@@ -671,7 -671,7 +671,7 @@@ static struct dma_async_tx_descriptor *
        d = bcm2835_dma_create_cb_chain(chan, direction, false,
                                        info, extra,
                                        frames, src, dst, 0, 0,
 -                                      GFP_KERNEL);
 +                                      GFP_NOWAIT);
        if (!d)
                return NULL;
  
@@@ -891,7 -891,6 +891,6 @@@ static int bcm2835_dma_probe(struct pla
        dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
        dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask);
        dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask);
-       dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
        dma_cap_set(DMA_MEMCPY, od->ddev.cap_mask);
        od->ddev.device_alloc_chan_resources = bcm2835_dma_alloc_chan_resources;
        od->ddev.device_free_chan_resources = bcm2835_dma_free_chan_resources;
index e2a5398f89b51129345fbb076710083ef24f9188,580ca1454fe8cf2778f6391c7dfcd3837770165b..33ab1b607e2b0f5cc136bad35f17c006d3e6ac2b
@@@ -1,8 -1,8 +1,8 @@@
  // SPDX-License-Identifier: GPL-2.0
  /*
-  * Renesas R-Car Gen2 DMA Controller Driver
+  * Renesas R-Car Gen2/Gen3 DMA Controller Driver
   *
-  * Copyright (C) 2014 Renesas Electronics Inc.
+  * Copyright (C) 2014-2019 Renesas Electronics Inc.
   *
   * Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
   */
@@@ -1282,9 -1282,6 +1282,9 @@@ static unsigned int rcar_dmac_chan_get_
        enum dma_status status;
        unsigned int residue = 0;
        unsigned int dptr = 0;
 +      unsigned int chcrb;
 +      unsigned int tcrb;
 +      unsigned int i;
  
        if (!desc)
                return 0;
                return 0;
        }
  
 +      /*
 +       * We need to read two registers.
 +       * Make sure the control register does not skip to next chunk
 +       * while reading the counter.
 +       * Trying it 3 times should be enough: Initial read, retry, retry
 +       * for the paranoid.
 +       */
 +      for (i = 0; i < 3; i++) {
 +              chcrb = rcar_dmac_chan_read(chan, RCAR_DMACHCRB) &
 +                                          RCAR_DMACHCRB_DPTR_MASK;
 +              tcrb = rcar_dmac_chan_read(chan, RCAR_DMATCRB);
 +              /* Still the same? */
 +              if (chcrb == (rcar_dmac_chan_read(chan, RCAR_DMACHCRB) &
 +                            RCAR_DMACHCRB_DPTR_MASK))
 +                      break;
 +      }
 +      WARN_ONCE(i >= 3, "residue might be not continuous!");
 +
        /*
         * In descriptor mode the descriptor running pointer is not maintained
         * by the interrupt handler, find the running descriptor from the
         * mode just use the running descriptor pointer.
         */
        if (desc->hwdescs.use) {
 -              dptr = (rcar_dmac_chan_read(chan, RCAR_DMACHCRB) &
 -                      RCAR_DMACHCRB_DPTR_MASK) >> RCAR_DMACHCRB_DPTR_SHIFT;
 +              dptr = chcrb >> RCAR_DMACHCRB_DPTR_SHIFT;
                if (dptr == 0)
                        dptr = desc->nchunks;
                dptr--;
        }
  
        /* Add the residue for the current chunk. */
 -      residue += rcar_dmac_chan_read(chan, RCAR_DMATCRB) << desc->xfer_shift;
 +      residue += tcrb << desc->xfer_shift;
  
        return residue;
  }
@@@ -1388,7 -1368,6 +1388,7 @@@ static enum dma_status rcar_dmac_tx_sta
        enum dma_status status;
        unsigned long flags;
        unsigned int residue;
 +      bool cyclic;
  
        status = dma_cookie_status(chan, cookie, txstate);
        if (status == DMA_COMPLETE || !txstate)
  
        spin_lock_irqsave(&rchan->lock, flags);
        residue = rcar_dmac_chan_get_residue(rchan, cookie);
 +      cyclic = rchan->desc.running ? rchan->desc.running->cyclic : false;
        spin_unlock_irqrestore(&rchan->lock, flags);
  
        /* if there's no residue, the cookie is complete */
 -      if (!residue)
 +      if (!residue && !cyclic)
                return DMA_COMPLETE;
  
        dma_set_residue(txstate, residue);
diff --combined drivers/spi/spi-pxa2xx.c
index e59c8b27b1559c88828b795fe23be16bf60019ce,5ea70f7d12e757b4d4f517076c770116affa04d7..298a0bec29d105c5b2fa169f2812ec94b6947d35
@@@ -884,14 -884,10 +884,14 @@@ static unsigned int ssp_get_clk_div(str
  
        rate = min_t(int, ssp_clk, rate);
  
 +      /*
 +       * Calculate the divisor for the SCR (Serial Clock Rate), avoiding
 +       * that the SSP transmission rate can be greater than the device rate
 +       */
        if (ssp->type == PXA25x_SSP || ssp->type == CE4100_SSP)
 -              return (ssp_clk / (2 * rate) - 1) & 0xff;
 +              return (DIV_ROUND_UP(ssp_clk, 2 * rate) - 1) & 0xff;
        else
 -              return (ssp_clk / rate - 1) & 0xfff;
 +              return (DIV_ROUND_UP(ssp_clk, rate) - 1)  & 0xfff;
  }
  
  static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data,
@@@ -929,7 -925,7 +929,7 @@@ static int pxa2xx_spi_transfer_one(stru
  {
        struct driver_data *drv_data = spi_controller_get_devdata(controller);
        struct spi_message *message = controller->cur_msg;
 -      struct chip_data *chip = spi_get_ctldata(message->spi);
 +      struct chip_data *chip = spi_get_ctldata(spi);
        u32 dma_thresh = chip->dma_threshold;
        u32 dma_burst = chip->dma_burst_size;
        u32 change_mask = pxa2xx_spi_get_ssrc1_change_mask(drv_data);
                /* reject already-mapped transfers; PIO won't always work */
                if (message->is_dma_mapped
                                || transfer->rx_dma || transfer->tx_dma) {
 -                      dev_err(&drv_data->pdev->dev,
 +                      dev_err(&spi->dev,
                                "Mapped transfer length of %u is greater than %d\n",
                                transfer->len, MAX_DMA_LEN);
                        return -EINVAL;
                }
  
                /* warn ... we force this to PIO mode */
 -              dev_warn_ratelimited(&message->spi->dev,
 +              dev_warn_ratelimited(&spi->dev,
                                     "DMA disabled for transfer length %ld greater than %d\n",
                                     (long)transfer->len, MAX_DMA_LEN);
        }
  
        /* Setup the transfer state based on the type of transfer */
        if (pxa2xx_spi_flush(drv_data) == 0) {
 -              dev_err(&drv_data->pdev->dev, "Flush failed\n");
 +              dev_err(&spi->dev, "Flush failed\n");
                return -EIO;
        }
        drv_data->n_bytes = chip->n_bytes;
         */
        if (chip->enable_dma) {
                if (pxa2xx_spi_set_dma_burst_and_threshold(chip,
 -                                              message->spi,
 +                                              spi,
                                                bits, &dma_burst,
                                                &dma_thresh))
 -                      dev_warn_ratelimited(&message->spi->dev,
 +                      dev_warn_ratelimited(&spi->dev,
                                             "DMA burst size reduced to match bits_per_word\n");
        }
  
        dma_mapped = controller->can_dma &&
 -                   controller->can_dma(controller, message->spi, transfer) &&
 +                   controller->can_dma(controller, spi, transfer) &&
                     controller->cur_msg_mapped;
        if (dma_mapped) {
  
        /* NOTE:  PXA25x_SSP _could_ use external clocking ... */
        cr0 = pxa2xx_configure_sscr0(drv_data, clk_div, bits);
        if (!pxa25x_ssp_comp(drv_data))
 -              dev_dbg(&message->spi->dev, "%u Hz actual, %s\n",
 +              dev_dbg(&spi->dev, "%u Hz actual, %s\n",
                        controller->max_speed_hz
                                / (1 + ((cr0 & SSCR0_SCR(0xfff)) >> 8)),
                        dma_mapped ? "DMA" : "PIO");
        else
 -              dev_dbg(&message->spi->dev, "%u Hz actual, %s\n",
 +              dev_dbg(&spi->dev, "%u Hz actual, %s\n",
                        controller->max_speed_hz / 2
                                / (1 + ((cr0 & SSCR0_SCR(0x0ff)) >> 8)),
                        dma_mapped ? "DMA" : "PIO");
@@@ -1337,9 -1333,6 +1337,9 @@@ static int setup(struct spi_device *spi
                        dev_warn(&spi->dev,
                                 "in setup: DMA burst size reduced to match bits_per_word\n");
                }
 +              dev_dbg(&spi->dev,
 +                      "in setup: DMA burst size set to %u\n",
 +                      chip->dma_burst_size);
        }
  
        switch (drv_data->ssp_type) {
@@@ -1458,10 -1451,6 +1458,10 @@@ static const struct pci_device_id pxa2x
        { PCI_VDEVICE(INTEL, 0xa32a), LPSS_CNL_SSP },
        { PCI_VDEVICE(INTEL, 0xa32b), LPSS_CNL_SSP },
        { PCI_VDEVICE(INTEL, 0xa37b), LPSS_CNL_SSP },
 +      /* CML-LP */
 +      { PCI_VDEVICE(INTEL, 0x02aa), LPSS_CNL_SSP },
 +      { PCI_VDEVICE(INTEL, 0x02ab), LPSS_CNL_SSP },
 +      { PCI_VDEVICE(INTEL, 0x02fb), LPSS_CNL_SSP },
        { },
  };
  
@@@ -1498,12 -1487,7 +1498,7 @@@ static int pxa2xx_spi_get_port_id(struc
  
  static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param)
  {
-       struct device *dev = param;
-       if (dev != chan->device->dev->parent)
-               return false;
-       return true;
+       return param == chan->device->dev;
  }
  
  #endif /* CONFIG_PCI */
@@@ -1575,7 -1559,6 +1570,7 @@@ pxa2xx_spi_init_pdata(struct platform_d
        pdata->is_slave = of_property_read_bool(pdev->dev.of_node, "spi-slave");
        pdata->num_chipselect = 1;
        pdata->enable_dma = true;
 +      pdata->dma_burst_size = 1;
  
        return pdata;
  }
@@@ -1704,7 -1687,7 +1699,7 @@@ static int pxa2xx_spi_probe(struct plat
        if (platform_info->enable_dma) {
                status = pxa2xx_spi_dma_setup(drv_data);
                if (status) {
 -                      dev_dbg(dev, "no DMA channels available, using PIO\n");
 +                      dev_warn(dev, "no DMA channels available, using PIO\n");
                        platform_info->enable_dma = false;
                } else {
                        controller->can_dma = pxa2xx_spi_can_dma;
@@@ -1965,5 -1948,3 +1960,5 @@@ static void __exit pxa2xx_spi_exit(void
        platform_driver_unregister(&driver);
  }
  module_exit(pxa2xx_spi_exit);
 +
 +MODULE_SOFTDEP("pre: dw_dmac");