2007-10-16 12:27:39 +04:00
|
|
|
/*
|
|
|
|
* Intel I/OAT DMA Linux driver
|
2009-02-26 13:05:43 +03:00
|
|
|
* Copyright(c) 2007 - 2009 Intel Corporation.
|
2007-10-16 12:27:39 +04:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* The full GNU General Public License is included in this distribution in
|
|
|
|
* the file called "COPYING".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This driver supports an Intel I/OAT DMA engine, which does asynchronous
|
|
|
|
* copy operations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/interrupt.h>
|
2007-10-16 12:27:42 +04:00
|
|
|
#include <linux/dca.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/slab.h>
|
2009-07-29 01:32:12 +04:00
|
|
|
#include "dma.h"
|
2009-08-27 00:01:44 +04:00
|
|
|
#include "dma_v2.h"
|
2009-07-29 01:32:12 +04:00
|
|
|
#include "registers.h"
|
|
|
|
#include "hw.h"
|
2007-10-16 12:27:39 +04:00
|
|
|
|
2007-10-18 14:07:13 +04:00
|
|
|
MODULE_VERSION(IOAT_DMA_VERSION);
|
2009-09-09 04:42:55 +04:00
|
|
|
MODULE_LICENSE("Dual BSD/GPL");
|
2007-10-16 12:27:39 +04:00
|
|
|
MODULE_AUTHOR("Intel Corporation");
|
|
|
|
|
2012-08-25 03:36:20 +04:00
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB0 0x0e20
|
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB1 0x0e21
|
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB2 0x0e22
|
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB3 0x0e23
|
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB4 0x0e24
|
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB5 0x0e25
|
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB6 0x0e26
|
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB7 0x0e27
|
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB8 0x0e2e
|
|
|
|
#define PCI_DEVICE_ID_INTEL_IOAT_IVB9 0x0e2f
|
|
|
|
|
2007-10-16 12:27:39 +04:00
|
|
|
static struct pci_device_id ioat_pci_tbl[] = {
|
2007-11-15 03:59:51 +03:00
|
|
|
/* I/OAT v1 platforms */
|
2009-09-09 04:43:03 +04:00
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_CNB) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SCNB) },
|
|
|
|
{ PCI_VDEVICE(UNISYS, PCI_DEVICE_ID_UNISYS_DMA_DIRECTOR) },
|
2007-11-15 03:59:51 +03:00
|
|
|
|
|
|
|
/* I/OAT v2 platforms */
|
2009-09-09 04:43:03 +04:00
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB) },
|
2008-07-23 04:30:57 +04:00
|
|
|
|
|
|
|
/* I/OAT v3 platforms */
|
2009-09-09 04:43:03 +04:00
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_TBG0) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_TBG1) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_TBG2) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_TBG3) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_TBG4) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_TBG5) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_TBG6) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_TBG7) },
|
2009-09-09 04:43:01 +04:00
|
|
|
|
|
|
|
/* I/OAT v3.2 platforms */
|
2009-09-09 04:43:03 +04:00
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF0) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF1) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF2) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF3) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF4) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF5) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF6) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF7) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF8) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_JSF9) },
|
2009-09-09 04:43:01 +04:00
|
|
|
|
2011-07-23 01:04:56 +04:00
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB0) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB1) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB2) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB3) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB4) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB5) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB6) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB7) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB8) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB9) },
|
|
|
|
|
2012-08-25 03:36:20 +04:00
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB0) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB1) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB2) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB3) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB4) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB5) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB6) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB7) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB8) },
|
|
|
|
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IOAT_IVB9) },
|
|
|
|
|
2007-10-16 12:27:39 +04:00
|
|
|
{ 0, }
|
|
|
|
};
|
2009-09-09 04:43:03 +04:00
|
|
|
MODULE_DEVICE_TABLE(pci, ioat_pci_tbl);
|
2007-10-16 12:27:39 +04:00
|
|
|
|
2009-07-29 01:42:38 +04:00
|
|
|
static int __devinit ioat_pci_probe(struct pci_dev *pdev,
|
|
|
|
const struct pci_device_id *id);
|
2007-10-16 12:27:39 +04:00
|
|
|
static void __devexit ioat_remove(struct pci_dev *pdev);
|
|
|
|
|
2007-10-16 12:27:42 +04:00
|
|
|
static int ioat_dca_enabled = 1;
|
|
|
|
module_param(ioat_dca_enabled, int, 0644);
|
|
|
|
MODULE_PARM_DESC(ioat_dca_enabled, "control support of dca service (default: 1)");
|
|
|
|
|
2009-09-09 04:53:04 +04:00
|
|
|
struct kmem_cache *ioat2_cache;
|
|
|
|
|
2009-09-09 04:29:44 +04:00
|
|
|
#define DRV_NAME "ioatdma"
|
|
|
|
|
2007-10-18 14:07:12 +04:00
|
|
|
static struct pci_driver ioat_pci_driver = {
|
2009-09-09 04:29:44 +04:00
|
|
|
.name = DRV_NAME,
|
2007-10-16 12:27:39 +04:00
|
|
|
.id_table = ioat_pci_tbl,
|
2009-07-29 01:42:38 +04:00
|
|
|
.probe = ioat_pci_probe,
|
2007-10-16 12:27:39 +04:00
|
|
|
.remove = __devexit_p(ioat_remove),
|
|
|
|
};
|
|
|
|
|
2009-07-29 01:42:38 +04:00
|
|
|
static struct ioatdma_device *
|
|
|
|
alloc_ioatdma(struct pci_dev *pdev, void __iomem *iobase)
|
|
|
|
{
|
|
|
|
struct device *dev = &pdev->dev;
|
|
|
|
struct ioatdma_device *d = devm_kzalloc(dev, sizeof(*d), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!d)
|
|
|
|
return NULL;
|
|
|
|
d->pdev = pdev;
|
|
|
|
d->reg_base = iobase;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devinit ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
2007-10-16 12:27:39 +04:00
|
|
|
{
|
2009-09-09 04:29:44 +04:00
|
|
|
void __iomem * const *iomap;
|
|
|
|
struct device *dev = &pdev->dev;
|
2009-07-29 01:42:38 +04:00
|
|
|
struct ioatdma_device *device;
|
2007-10-16 12:27:39 +04:00
|
|
|
int err;
|
|
|
|
|
2009-09-09 04:29:44 +04:00
|
|
|
err = pcim_enable_device(pdev);
|
2007-10-16 12:27:39 +04:00
|
|
|
if (err)
|
2009-09-09 04:29:44 +04:00
|
|
|
return err;
|
2007-10-16 12:27:39 +04:00
|
|
|
|
2009-09-09 04:29:44 +04:00
|
|
|
err = pcim_iomap_regions(pdev, 1 << IOAT_MMIO_BAR, DRV_NAME);
|
2007-10-16 12:27:39 +04:00
|
|
|
if (err)
|
2009-09-09 04:29:44 +04:00
|
|
|
return err;
|
|
|
|
iomap = pcim_iomap_table(pdev);
|
|
|
|
if (!iomap)
|
|
|
|
return -ENOMEM;
|
2007-10-16 12:27:39 +04:00
|
|
|
|
2009-04-07 06:01:13 +04:00
|
|
|
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
|
2007-10-16 12:27:39 +04:00
|
|
|
if (err)
|
2009-04-07 06:01:15 +04:00
|
|
|
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
2007-10-16 12:27:39 +04:00
|
|
|
if (err)
|
2009-09-09 04:29:44 +04:00
|
|
|
return err;
|
2007-10-16 12:27:39 +04:00
|
|
|
|
2009-04-07 06:01:13 +04:00
|
|
|
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
|
2007-10-16 12:27:39 +04:00
|
|
|
if (err)
|
2009-04-07 06:01:15 +04:00
|
|
|
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
|
2007-10-16 12:27:39 +04:00
|
|
|
if (err)
|
2009-09-09 04:29:44 +04:00
|
|
|
return err;
|
|
|
|
|
2009-07-29 01:42:38 +04:00
|
|
|
device = alloc_ioatdma(pdev, iomap[IOAT_MMIO_BAR]);
|
|
|
|
if (!device)
|
|
|
|
return -ENOMEM;
|
2010-05-02 23:52:35 +04:00
|
|
|
pci_set_master(pdev);
|
2009-07-29 01:42:38 +04:00
|
|
|
pci_set_drvdata(pdev, device);
|
|
|
|
|
|
|
|
device->version = readb(device->reg_base + IOAT_VER_OFFSET);
|
|
|
|
if (device->version == IOAT_VER_1_2)
|
|
|
|
err = ioat1_dma_probe(device, ioat_dca_enabled);
|
|
|
|
else if (device->version == IOAT_VER_2_0)
|
|
|
|
err = ioat2_dma_probe(device, ioat_dca_enabled);
|
|
|
|
else if (device->version >= IOAT_VER_3_0)
|
|
|
|
err = ioat3_dma_probe(device, ioat_dca_enabled);
|
|
|
|
else
|
2009-09-09 04:29:44 +04:00
|
|
|
return -ENODEV;
|
2009-01-06 21:38:20 +03:00
|
|
|
|
2009-07-29 01:42:38 +04:00
|
|
|
if (err) {
|
2009-09-09 04:29:44 +04:00
|
|
|
dev_err(dev, "Intel(R) I/OAT DMA Engine init failed\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2007-10-16 12:27:39 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __devexit ioat_remove(struct pci_dev *pdev)
|
|
|
|
{
|
2009-07-29 01:42:38 +04:00
|
|
|
struct ioatdma_device *device = pci_get_drvdata(pdev);
|
|
|
|
|
|
|
|
if (!device)
|
|
|
|
return;
|
2007-10-16 12:27:39 +04:00
|
|
|
|
2009-01-06 21:38:20 +03:00
|
|
|
dev_err(&pdev->dev, "Removing dma and dca services\n");
|
|
|
|
if (device->dca) {
|
2009-09-10 17:05:58 +04:00
|
|
|
unregister_dca_provider(device->dca, &pdev->dev);
|
2009-01-06 21:38:20 +03:00
|
|
|
free_dca_provider(device->dca);
|
|
|
|
device->dca = NULL;
|
|
|
|
}
|
2009-07-29 01:42:38 +04:00
|
|
|
ioat_dma_remove(device);
|
2007-10-16 12:27:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init ioat_init_module(void)
|
|
|
|
{
|
2009-09-09 04:53:04 +04:00
|
|
|
int err;
|
|
|
|
|
2009-09-09 04:42:56 +04:00
|
|
|
pr_info("%s: Intel(R) QuickData Technology Driver %s\n",
|
|
|
|
DRV_NAME, IOAT_DMA_VERSION);
|
|
|
|
|
2009-09-09 04:53:04 +04:00
|
|
|
ioat2_cache = kmem_cache_create("ioat2", sizeof(struct ioat_ring_ent),
|
|
|
|
0, SLAB_HWCACHE_ALIGN, NULL);
|
|
|
|
if (!ioat2_cache)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
err = pci_register_driver(&ioat_pci_driver);
|
|
|
|
if (err)
|
|
|
|
kmem_cache_destroy(ioat2_cache);
|
|
|
|
|
|
|
|
return err;
|
2007-10-16 12:27:39 +04:00
|
|
|
}
|
|
|
|
module_init(ioat_init_module);
|
|
|
|
|
|
|
|
static void __exit ioat_exit_module(void)
|
|
|
|
{
|
2007-10-18 14:07:12 +04:00
|
|
|
pci_unregister_driver(&ioat_pci_driver);
|
2009-09-09 04:53:04 +04:00
|
|
|
kmem_cache_destroy(ioat2_cache);
|
2007-10-16 12:27:39 +04:00
|
|
|
}
|
|
|
|
module_exit(ioat_exit_module);
|