
The commita9ddb575d6
("dmaengine: dw_dmac: Enhance device tree support") introduces is_private property in uncertain understanding what does it mean. First of all, documentation defines DMA_PRIVATE capability as Documentation/crypto/async-tx-api.txt: The DMA_PRIVATE capability flag is used to tag dma devices that should not be used by the general-purpose allocator. It can be set at initialization time if it is known that a channel will always be private. Alternatively, it is set when dma_request_channel() finds an unused "public" channel. A couple caveats to note when implementing a driver and consumer: 1/ Once a channel has been privately allocated it will no longer be considered by the general-purpose allocator even after a call to dma_release_channel(). 2/ Since capabilities are specified at the device level a dma_device with multiple channels will either have all channels public, or all channels private. Documentation/driver-api/dmaengine/provider.rst: - DMA_PRIVATE The devices only supports slave transfers, and as such isn't available for async transfers. The capability had been introduced by the commit59b5ec2144
("dmaengine: introduce dma_request_channel and private channels") and some code didn't changed from that times ever. Taking into consideration above and the fact that on all known platforms Synopsys DesignWare DMA engine is attached to serve slave transfers, the DMA_PRIVATE capability must be enabled for this device unconditionally. Otherwise, as rightfully noticed in drivers/dma/at_xdmac.c: /* * Without DMA_PRIVATE the driver is not able to allocate more than * one channel, second allocation fails in private_candidate. */ because of of a caveats mentioned in above documentation excerpts. So, remove conditional around DMA_PRIVATE followed by removal leftovers. If someone wonders, DMA_PRIVATE can be not used if and only if the all channels of the DMA controller are supposed to serve memory-to-memory like operations. For example, EP93xx has two controllers, one of which can only perform memory-to-memory transfers Note, this change doesn't affect dmatest to be able to test such controllers. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (maintainer:SERIAL DRIVERS) Cc: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Vinod Koul <vkoul@kernel.org>
150 lines
3.3 KiB
C
150 lines
3.3 KiB
C
/*
|
|
* PCI driver for the Synopsys DesignWare DMA Controller
|
|
*
|
|
* Copyright (C) 2013 Intel Corporation
|
|
* Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/device.h>
|
|
|
|
#include "internal.h"
|
|
|
|
static struct dw_dma_platform_data mrfld_pdata = {
|
|
.nr_channels = 8,
|
|
.is_memcpy = true,
|
|
.is_idma32 = true,
|
|
.chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
|
|
.chan_priority = CHAN_PRIORITY_ASCENDING,
|
|
.block_size = 131071,
|
|
.nr_masters = 1,
|
|
.data_width = {4},
|
|
.multi_block = {1, 1, 1, 1, 1, 1, 1, 1},
|
|
};
|
|
|
|
static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
|
|
{
|
|
const struct dw_dma_platform_data *pdata = (void *)pid->driver_data;
|
|
struct dw_dma_chip *chip;
|
|
int ret;
|
|
|
|
ret = pcim_enable_device(pdev);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
|
|
if (ret) {
|
|
dev_err(&pdev->dev, "I/O memory remapping failed\n");
|
|
return ret;
|
|
}
|
|
|
|
pci_set_master(pdev);
|
|
pci_try_set_mwi(pdev);
|
|
|
|
ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
|
if (ret)
|
|
return ret;
|
|
|
|
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
|
|
if (!chip)
|
|
return -ENOMEM;
|
|
|
|
chip->dev = &pdev->dev;
|
|
chip->id = pdev->devfn;
|
|
chip->regs = pcim_iomap_table(pdev)[0];
|
|
chip->irq = pdev->irq;
|
|
chip->pdata = pdata;
|
|
|
|
ret = dw_dma_probe(chip);
|
|
if (ret)
|
|
return ret;
|
|
|
|
pci_set_drvdata(pdev, chip);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void dw_pci_remove(struct pci_dev *pdev)
|
|
{
|
|
struct dw_dma_chip *chip = pci_get_drvdata(pdev);
|
|
int ret;
|
|
|
|
ret = dw_dma_remove(chip);
|
|
if (ret)
|
|
dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
|
|
}
|
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
|
|
static int dw_pci_suspend_late(struct device *dev)
|
|
{
|
|
struct pci_dev *pci = to_pci_dev(dev);
|
|
struct dw_dma_chip *chip = pci_get_drvdata(pci);
|
|
|
|
return dw_dma_disable(chip);
|
|
};
|
|
|
|
static int dw_pci_resume_early(struct device *dev)
|
|
{
|
|
struct pci_dev *pci = to_pci_dev(dev);
|
|
struct dw_dma_chip *chip = pci_get_drvdata(pci);
|
|
|
|
return dw_dma_enable(chip);
|
|
};
|
|
|
|
#endif /* CONFIG_PM_SLEEP */
|
|
|
|
static const struct dev_pm_ops dw_pci_dev_pm_ops = {
|
|
SET_LATE_SYSTEM_SLEEP_PM_OPS(dw_pci_suspend_late, dw_pci_resume_early)
|
|
};
|
|
|
|
static const struct pci_device_id dw_pci_id_table[] = {
|
|
/* Medfield (GPDMA) */
|
|
{ PCI_VDEVICE(INTEL, 0x0827) },
|
|
|
|
/* BayTrail */
|
|
{ PCI_VDEVICE(INTEL, 0x0f06) },
|
|
{ PCI_VDEVICE(INTEL, 0x0f40) },
|
|
|
|
/* Merrifield iDMA 32-bit (GPDMA) */
|
|
{ PCI_VDEVICE(INTEL, 0x11a2), (kernel_ulong_t)&mrfld_pdata },
|
|
|
|
/* Braswell */
|
|
{ PCI_VDEVICE(INTEL, 0x2286) },
|
|
{ PCI_VDEVICE(INTEL, 0x22c0) },
|
|
|
|
/* Haswell */
|
|
{ PCI_VDEVICE(INTEL, 0x9c60) },
|
|
|
|
/* Broadwell */
|
|
{ PCI_VDEVICE(INTEL, 0x9ce0) },
|
|
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(pci, dw_pci_id_table);
|
|
|
|
static struct pci_driver dw_pci_driver = {
|
|
.name = "dw_dmac_pci",
|
|
.id_table = dw_pci_id_table,
|
|
.probe = dw_pci_probe,
|
|
.remove = dw_pci_remove,
|
|
.driver = {
|
|
.pm = &dw_pci_dev_pm_ops,
|
|
},
|
|
};
|
|
|
|
module_pci_driver(dw_pci_driver);
|
|
|
|
MODULE_LICENSE("GPL v2");
|
|
MODULE_DESCRIPTION("Synopsys DesignWare DMA Controller PCI driver");
|
|
MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");
|