]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
dmaengine: idma64: Use actual device for DMA transfers
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 18 Mar 2019 15:39:30 +0000 (18:39 +0300)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838824
[ Upstream commit 5ba846b1ee0792f5a596b9b0b86d6e8cdebfab06 ]

Intel IOMMU, when enabled, tries to find the domain of the device,
assuming it's a PCI one, during DMA operations, such as mapping or
unmapping. Since we are splitting the actual PCI device to couple of
children via MFD framework (see drivers/mfd/intel-lpss.c for details),
the DMA device appears to be a platform one, and thus not an actual one
that performs DMA. In a such situation IOMMU can't find or allocate
a proper domain for its operations. As a result, all DMA operations are
failed.

In order to fix this, supply parent of the platform device
to the DMA engine framework and fix filter functions accordingly.

We may rely on the fact that parent is a real PCI device, because no
other configuration is present in the wild.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [for tty parts]
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/dma/idma64.c
drivers/dma/idma64.h
drivers/spi/spi-pxa2xx.c
drivers/tty/serial/8250/8250_dw.c

index 1953e57505f4b4493d3d55bbfec102fdb4ede615..f17a4c7a1781d96df3638d11532aa05f35c54638 100644 (file)
@@ -589,7 +589,7 @@ static int idma64_probe(struct idma64_chip *chip)
        idma64->dma.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
        idma64->dma.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
 
-       idma64->dma.dev = chip->dev;
+       idma64->dma.dev = chip->sysdev;
 
        dma_set_max_seg_size(idma64->dma.dev, IDMA64C_CTLH_BLOCK_TS_MASK);
 
@@ -629,6 +629,7 @@ static int idma64_platform_probe(struct platform_device *pdev)
 {
        struct idma64_chip *chip;
        struct device *dev = &pdev->dev;
+       struct device *sysdev = dev->parent;
        struct resource *mem;
        int ret;
 
@@ -645,11 +646,12 @@ static int idma64_platform_probe(struct platform_device *pdev)
        if (IS_ERR(chip->regs))
                return PTR_ERR(chip->regs);
 
-       ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
+       ret = dma_coerce_mask_and_coherent(sysdev, DMA_BIT_MASK(64));
        if (ret)
                return ret;
 
        chip->dev = dev;
+       chip->sysdev = sysdev;
 
        ret = idma64_probe(chip);
        if (ret)
index 6b816878e5e7a79d9e4fb14f982e3aa21e3e34a2..baa32e1425de31dcfbf88f8ea10d0002a5fe3e13 100644 (file)
@@ -216,12 +216,14 @@ static inline void idma64_writel(struct idma64 *idma64, int offset, u32 value)
 /**
  * struct idma64_chip - representation of iDMA 64-bit controller hardware
  * @dev:               struct device of the DMA controller
+ * @sysdev:            struct device of the physical device that does DMA
  * @irq:               irq line
  * @regs:              memory mapped I/O space
  * @idma64:            struct idma64 that is filed by idma64_probe()
  */
 struct idma64_chip {
        struct device   *dev;
+       struct device   *sysdev;
        int             irq;
        void __iomem    *regs;
        struct idma64   *idma64;
index efdae686a761902e2bbd5226fba5faff37d9df33..9bf3e5f945c7503e15592de808ba2a6afa3100c6 100644 (file)
@@ -1505,12 +1505,7 @@ static const struct pci_device_id pxa2xx_spi_pci_compound_match[] = {
 
 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;
 }
 
 static struct pxa2xx_spi_master *
index 8ea6e33f72d289022731370704ea143f29bdcc1b..0672829e56224093fe975c2e864b6bfa7b8f45ef 100644 (file)
@@ -311,7 +311,7 @@ static bool dw8250_fallback_dma_filter(struct dma_chan *chan, void *param)
 
 static bool dw8250_idma_filter(struct dma_chan *chan, void *param)
 {
-       return param == chan->device->dev->parent;
+       return param == chan->device->dev;
 }
 
 static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
@@ -352,7 +352,7 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
                }
        }
 
-       /* Platforms with iDMA */
+       /* Platforms with iDMA 64-bit */
        if (platform_get_resource_byname(to_platform_device(p->dev),
                                         IORESOURCE_MEM, "lpss_priv")) {
                data->dma.rx_param = p->dev->parent;