* Re: [PATCH 2/6] powerpc: Define CPU_FTR_HAS_PPR
From: Michael Neuling @ 2012-11-23 4:01 UTC (permalink / raw)
To: Haren Myneni; +Cc: anton, paulus, linuxppc-dev
In-Reply-To: <1351666334.32304.13.camel@hbabu-laptop>
Heaven Myneni <haren@linux.vnet.ibm.com> wrote:
> [PATCH 2/6] powerpc: Define CPU_FTR_HAS_PPR
>
> CPU_FTR_HAS_PPR is defined for POWER7.
>
> Signed-off-by: Haren Myneni <haren@us.ibm.com>
> ---
> arch/powerpc/include/asm/cputable.h | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
> index 21a0687..12e3a1d 100644
> --- a/arch/powerpc/include/asm/cputable.h
> +++ b/arch/powerpc/include/asm/cputable.h
> @@ -171,6 +171,7 @@ extern const char *powerpc_base_platform;
> #define CPU_FTR_POPCNTD LONG_ASM_CONST(0x0800000000000000)
> #define CPU_FTR_ICSWX LONG_ASM_CONST(0x1000000000000000)
> #define CPU_FTR_VMX_COPY LONG_ASM_CONST(0x2000000000000000)
> +#define CPU_FTR_HAS_PPR LONG_ASM_CONST(0x4000000000000000)
>
> #ifndef __ASSEMBLY__
>
> @@ -400,7 +401,8 @@ extern const char *powerpc_base_platform;
> CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
> CPU_FTR_DSCR | CPU_FTR_SAO | CPU_FTR_ASYM_SMT | \
> CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
> - CPU_FTR_ICSWX | CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY)
> + CPU_FTR_ICSWX | CPU_FTR_CFAR | CPU_FTR_HVMODE | \
> + CPU_FTR_VMX_COPY | CPU_FTR_HAS_PPR)
> #define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
> CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
> CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
> @@ -422,7 +424,7 @@ extern const char *powerpc_base_platform;
> (CPU_FTRS_POWER3 | CPU_FTRS_RS64 | CPU_FTRS_POWER4 | \
> CPU_FTRS_PPC970 | CPU_FTRS_POWER5 | CPU_FTRS_POWER6 | \
> CPU_FTRS_POWER7 | CPU_FTRS_CELL | CPU_FTRS_PA6T | \
> - CPU_FTR_VSX)
> + CPU_FTR_VSX | CPU_FTR_HAS_PPR)
FYI, there is no need to add this to POSSIBLE, since you are adding it
to POWER7 anyway.
Mikey
^ permalink raw reply
* [PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue
From: Yuanquan Chen @ 2012-11-23 4:29 UTC (permalink / raw)
To: linuxppc-dev; +Cc: r61911, Yuanquan Chen
On powerpc arch, dma_ops of rescanned pci device after system's booting up won't be
initialized by system, so it will fail to execute the dma_set_mask in the device's
driver. Initialize it to solve this issue.
Signed-off-by: Yuanquan Chen <B41889@freescale.com>
---
arch/powerpc/include/asm/dma-mapping.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 7816087..22eae53 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -126,8 +126,11 @@ static inline int dma_supported(struct device *dev, u64 mask)
{
struct dma_map_ops *dma_ops = get_dma_ops(dev);
- if (unlikely(dma_ops == NULL))
- return 0;
+ if (unlikely(dma_ops == NULL)) {
+ set_dma_ops(dev, &dma_direct_ops);
+ set_dma_offset(dev, PCI_DRAM_OFFSET);
+ dma_ops = &dma_direct_ops;
+ }
if (dma_ops->dma_supported == NULL)
return 1;
return dma_ops->dma_supported(dev, mask);
--
1.7.9.5
^ permalink raw reply related
* [PATCH] powerpc/eeh: Do not invalidate PE properly
From: Gavin Shan @ 2012-11-23 7:58 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Gavin Shan
While the EEH does recovery on the specific PE that has PCI errors,
the PCI devices belonging to the PE will be removed and the PE will
be marked as invalid since we still need the information stored in
the PE. We only invalidate the PE when it doesn't have associated
EEH devices and valid child PEs. However, the code used to check
that is wrong. The patch fixes that.
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
arch/powerpc/platforms/pseries/eeh_pe.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/eeh_pe.c b/arch/powerpc/platforms/pseries/eeh_pe.c
index 44da51a..0ebbb8f 100644
--- a/arch/powerpc/platforms/pseries/eeh_pe.c
+++ b/arch/powerpc/platforms/pseries/eeh_pe.c
@@ -464,7 +464,7 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe)
if (list_empty(&pe->edevs)) {
cnt = 0;
list_for_each_entry(child, &pe->child_list, child) {
- if (!(pe->type & EEH_PE_INVALID)) {
+ if (!(child->type & EEH_PE_INVALID)) {
cnt++;
break;
}
--
1.7.5.4
^ permalink raw reply related
* [PATCH 0/2] vfio powerpc: implemented and enabled
From: Alexey Kardashevskiy @ 2012-11-23 9:03 UTC (permalink / raw)
To: Alex Williamson
Cc: kvm, Alexey Kardashevskiy, linux-kernel, Paul Mackerras,
linuxppc-dev, David Gibson
In-Reply-To: <1353435584.2234.87.camel@bling.home>
The series includes IOMMU implementation and necessary IOMMU groups initialization.
Alexey Kardashevskiy (2):
vfio powerpc: implemented IOMMU driver for VFIO
vfio powerpc: enabled on powernv platform
arch/powerpc/include/asm/iommu.h | 6 +
arch/powerpc/kernel/iommu.c | 141 +++++++++++++++++++
arch/powerpc/platforms/powernv/pci.c | 135 +++++++++++++++++++
drivers/iommu/Kconfig | 8 ++
drivers/vfio/Kconfig | 6 +
drivers/vfio/Makefile | 1 +
drivers/vfio/vfio_iommu_spapr_tce.c | 247 ++++++++++++++++++++++++++++++++++
include/linux/vfio.h | 20 +++
8 files changed, 564 insertions(+)
create mode 100644 drivers/vfio/vfio_iommu_spapr_tce.c
--
1.7.10.4
^ permalink raw reply
* [PATCH 1/2] vfio powerpc: implemented IOMMU driver for VFIO
From: Alexey Kardashevskiy @ 2012-11-23 9:03 UTC (permalink / raw)
To: Alex Williamson
Cc: kvm, Alexey Kardashevskiy, linux-kernel, Paul Mackerras,
linuxppc-dev, David Gibson
In-Reply-To: <1353661396-14374-1-git-send-email-aik@ozlabs.ru>
VFIO implements platform independent stuff such as
a PCI driver, BAR access (via read/write on a file descriptor
or direct mapping when possible) and IRQ signaling.
The platform dependent part includes IOMMU initialization
and handling. This patch implements an IOMMU driver for VFIO
which does mapping/unmapping pages for the guest IO and
provides information about DMA window (required by a POWERPC
guest).
The counterpart in QEMU is required to support this functionality.
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
drivers/vfio/Kconfig | 6 +
drivers/vfio/Makefile | 1 +
drivers/vfio/vfio_iommu_spapr_tce.c | 247 +++++++++++++++++++++++++++++++++++
include/linux/vfio.h | 20 +++
4 files changed, 274 insertions(+)
create mode 100644 drivers/vfio/vfio_iommu_spapr_tce.c
diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig
index 7cd5dec..b464687 100644
--- a/drivers/vfio/Kconfig
+++ b/drivers/vfio/Kconfig
@@ -3,10 +3,16 @@ config VFIO_IOMMU_TYPE1
depends on VFIO
default n
+config VFIO_IOMMU_SPAPR_TCE
+ tristate
+ depends on VFIO && SPAPR_TCE_IOMMU
+ default n
+
menuconfig VFIO
tristate "VFIO Non-Privileged userspace driver framework"
depends on IOMMU_API
select VFIO_IOMMU_TYPE1 if X86
+ select VFIO_IOMMU_SPAPR_TCE if PPC_POWERNV
help
VFIO provides a framework for secure userspace device drivers.
See Documentation/vfio.txt for more details.
diff --git a/drivers/vfio/Makefile b/drivers/vfio/Makefile
index 2398d4a..72bfabc 100644
--- a/drivers/vfio/Makefile
+++ b/drivers/vfio/Makefile
@@ -1,3 +1,4 @@
obj-$(CONFIG_VFIO) += vfio.o
obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o
+obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o
obj-$(CONFIG_VFIO_PCI) += pci/
diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
new file mode 100644
index 0000000..46a6298
--- /dev/null
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -0,0 +1,247 @@
+/*
+ * VFIO: IOMMU DMA mapping support for TCE on POWER
+ *
+ * Copyright (C) 2012 IBM Corp. All rights reserved.
+ * Author: Alexey Kardashevskiy <aik@ozlabs.ru>
+ *
+ * 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.
+ *
+ * Derived from original vfio_iommu_type1.c:
+ * Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+ * Author: Alex Williamson <alex.williamson@redhat.com>
+ */
+
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+#include <linux/err.h>
+#include <linux/vfio.h>
+#include <asm/iommu.h>
+
+#define DRIVER_VERSION "0.1"
+#define DRIVER_AUTHOR "aik@ozlabs.ru"
+#define DRIVER_DESC "VFIO IOMMU SPAPR TCE"
+
+static void tce_iommu_detach_group(void *iommu_data,
+ struct iommu_group *iommu_group);
+
+/*
+ * VFIO IOMMU fd for SPAPR_TCE IOMMU implementation
+ */
+
+/*
+ * The container descriptor supports only a single group per container.
+ * Required by the API as the container is not supplied with the IOMMU group
+ * at the moment of initialization.
+ */
+struct tce_container {
+ struct mutex lock;
+ struct iommu_table *tbl;
+};
+
+static void *tce_iommu_open(unsigned long arg)
+{
+ struct tce_container *container;
+
+ if (arg != VFIO_SPAPR_TCE_IOMMU) {
+ printk(KERN_ERR "tce_vfio: Wrong IOMMU type\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ container = kzalloc(sizeof(*container), GFP_KERNEL);
+ if (!container)
+ return ERR_PTR(-ENOMEM);
+
+ mutex_init(&container->lock);
+
+ return container;
+}
+
+static void tce_iommu_release(void *iommu_data)
+{
+ struct tce_container *container = iommu_data;
+
+ WARN_ON(container->tbl && !container->tbl->it_group);
+ if (container->tbl && container->tbl->it_group)
+ tce_iommu_detach_group(iommu_data, container->tbl->it_group);
+
+ mutex_destroy(&container->lock);
+
+ kfree(container);
+}
+
+static long tce_iommu_ioctl(void *iommu_data,
+ unsigned int cmd, unsigned long arg)
+{
+ struct tce_container *container = iommu_data;
+ unsigned long minsz;
+
+ switch (cmd) {
+ case VFIO_CHECK_EXTENSION: {
+ return (arg == VFIO_SPAPR_TCE_IOMMU) ? 1 : 0;
+ }
+ case VFIO_IOMMU_SPAPR_TCE_GET_INFO: {
+ struct vfio_iommu_spapr_tce_info info;
+ struct iommu_table *tbl = container->tbl;
+
+ if (WARN_ON(!tbl))
+ return -ENXIO;
+
+ minsz = offsetofend(struct vfio_iommu_spapr_tce_info,
+ dma64_window_size);
+
+ if (copy_from_user(&info, (void __user *)arg, minsz))
+ return -EFAULT;
+
+ if (info.argsz < minsz)
+ return -EINVAL;
+
+ info.dma32_window_start = tbl->it_offset << IOMMU_PAGE_SHIFT;
+ info.dma32_window_size = tbl->it_size << IOMMU_PAGE_SHIFT;
+ info.dma64_window_start = 0;
+ info.dma64_window_size = 0;
+ info.flags = 0;
+
+ if (copy_to_user((void __user *)arg, &info, minsz))
+ return -EFAULT;
+
+ return 0;
+ }
+ case VFIO_IOMMU_MAP_DMA: {
+ vfio_iommu_spapr_tce_dma_map param;
+ struct iommu_table *tbl = container->tbl;
+ enum dma_data_direction direction = DMA_NONE;
+
+ if (WARN_ON(!tbl))
+ return -ENXIO;
+
+ minsz = offsetofend(vfio_iommu_spapr_tce_dma_map, size);
+
+ if (copy_from_user(¶m, (void __user *)arg, minsz))
+ return -EFAULT;
+
+ if (param.argsz < minsz)
+ return -EINVAL;
+
+ if ((param.flags & VFIO_DMA_MAP_FLAG_READ) &&
+ (param.flags & VFIO_DMA_MAP_FLAG_WRITE)) {
+ direction = DMA_BIDIRECTIONAL;
+ } else if (param.flags & VFIO_DMA_MAP_FLAG_READ) {
+ direction = DMA_TO_DEVICE;
+ } else if (param.flags & VFIO_DMA_MAP_FLAG_WRITE) {
+ direction = DMA_FROM_DEVICE;
+ }
+
+ param.size += param.iova & ~IOMMU_PAGE_MASK;
+ param.size = _ALIGN_UP(param.size, IOMMU_PAGE_SIZE);
+
+ return iommu_put_tces(tbl, param.iova >> IOMMU_PAGE_SHIFT,
+ param.vaddr & IOMMU_PAGE_MASK, direction,
+ param.size >> IOMMU_PAGE_SHIFT);
+ }
+ case VFIO_IOMMU_UNMAP_DMA: {
+ vfio_iommu_spapr_tce_dma_unmap param;
+ struct iommu_table *tbl = container->tbl;
+
+ if (WARN_ON(!tbl))
+ return -ENXIO;
+
+ minsz = offsetofend(vfio_iommu_spapr_tce_dma_unmap, size);
+
+ if (copy_from_user(¶m, (void __user *)arg, minsz))
+ return -EFAULT;
+
+ if (param.argsz < minsz)
+ return -EINVAL;
+
+ param.size += param.iova & ~IOMMU_PAGE_MASK;
+ param.size = _ALIGN_UP(param.size, IOMMU_PAGE_SIZE);
+
+ return iommu_put_tces(tbl, param.iova >> IOMMU_PAGE_SHIFT,
+ 0, DMA_NONE, param.size >> IOMMU_PAGE_SHIFT);
+ }
+ default:
+ printk(KERN_WARNING "tce_vfio: unexpected cmd %x\n", cmd);
+ }
+
+ return -ENOTTY;
+}
+
+static int tce_iommu_attach_group(void *iommu_data,
+ struct iommu_group *iommu_group)
+{
+ struct tce_container *container = iommu_data;
+ struct iommu_table *tbl = iommu_group_get_iommudata(iommu_group);
+
+ BUG_ON(!tbl);
+ mutex_lock(&container->lock);
+ pr_debug("tce_vfio: Attaching group #%u to iommu %p\n",
+ iommu_group_id(iommu_group), iommu_group);
+ if (container->tbl) {
+ printk(KERN_WARNING "tce_vfio: Only one group per IOMMU container is allowed, existing id=%d, attaching id=%d\n",
+ iommu_group_id(container->tbl->it_group),
+ iommu_group_id(iommu_group));
+ mutex_unlock(&container->lock);
+ return -EBUSY;
+ }
+
+ container->tbl = tbl;
+ mutex_unlock(&container->lock);
+
+ return 0;
+}
+
+static void tce_iommu_detach_group(void *iommu_data,
+ struct iommu_group *iommu_group)
+{
+ struct tce_container *container = iommu_data;
+ struct iommu_table *tbl = iommu_group_get_iommudata(iommu_group);
+
+ BUG_ON(!tbl);
+ mutex_lock(&container->lock);
+ if (tbl != container->tbl) {
+ printk(KERN_WARNING "tce_vfio: detaching group #%u, expected group is #%u\n",
+ iommu_group_id(iommu_group),
+ iommu_group_id(tbl->it_group));
+ } else {
+
+ pr_debug("tce_vfio: detaching group #%u from iommu %p\n",
+ iommu_group_id(iommu_group), iommu_group);
+
+ iommu_put_tces(tbl, tbl->it_offset, 0, DMA_NONE, tbl->it_size);
+ container->tbl = NULL;
+ }
+ mutex_unlock(&container->lock);
+}
+
+const struct vfio_iommu_driver_ops tce_iommu_driver_ops = {
+ .name = "iommu-vfio-powerpc",
+ .owner = THIS_MODULE,
+ .open = tce_iommu_open,
+ .release = tce_iommu_release,
+ .ioctl = tce_iommu_ioctl,
+ .attach_group = tce_iommu_attach_group,
+ .detach_group = tce_iommu_detach_group,
+};
+
+static int __init tce_iommu_init(void)
+{
+ return vfio_register_iommu_driver(&tce_iommu_driver_ops);
+}
+
+static void __exit tce_iommu_cleanup(void)
+{
+ vfio_unregister_iommu_driver(&tce_iommu_driver_ops);
+}
+
+module_init(tce_iommu_init);
+module_exit(tce_iommu_cleanup);
+
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 0a4f180..3ecd65c 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -99,6 +99,7 @@ extern void vfio_unregister_iommu_driver(
/* Extensions */
#define VFIO_TYPE1_IOMMU 1
+#define VFIO_SPAPR_TCE_IOMMU 2
/*
* The IOCTL interface is designed for extensibility by embedding the
@@ -442,4 +443,23 @@ struct vfio_iommu_type1_dma_unmap {
#define VFIO_IOMMU_UNMAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 14)
+/* -------- Additional API for SPAPR TCE (Server POWERPC) IOMMU -------- */
+
+struct vfio_iommu_spapr_tce_info {
+ __u32 argsz;
+ __u32 flags;
+ __u32 dma32_window_start;
+ __u32 dma32_window_size;
+ __u64 dma64_window_start;
+ __u64 dma64_window_size;
+};
+
+#define VFIO_IOMMU_SPAPR_TCE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
+
+/* Reuse type1 map/unmap structs as they are the same at the moment */
+typedef struct vfio_iommu_type1_dma_map vfio_iommu_spapr_tce_dma_map;
+typedef struct vfio_iommu_type1_dma_unmap vfio_iommu_spapr_tce_dma_unmap;
+
+/* ***************************************************************** */
+
#endif /* VFIO_H */
--
1.7.10.4
^ permalink raw reply related
* [PATCH 2/2] vfio powerpc: enabled on powernv platform
From: Alexey Kardashevskiy @ 2012-11-23 9:03 UTC (permalink / raw)
To: Alex Williamson
Cc: kvm, Alexey Kardashevskiy, linux-kernel, Paul Mackerras,
linuxppc-dev, David Gibson
In-Reply-To: <1353661396-14374-1-git-send-email-aik@ozlabs.ru>
This patch initializes IOMMU groups based on the IOMMU
configuration discovered during the PCI scan on POWERNV
(POWER non virtualized) platform. The IOMMU groups are
to be used later by VFIO driver (PCI pass through).
It also implements an API for mapping/unmapping pages for
guest PCI drivers and providing DMA window properties.
This API is going to be used later by QEMU-VFIO to handle
h_put_tce hypercalls from the KVM guest.
Although this driver has been tested only on the POWERNV
platform, it should work on any platform which supports
TCE tables.
To enable VFIO on POWER, enable SPAPR_TCE_IOMMU config
option and configure VFIO as required.
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
arch/powerpc/include/asm/iommu.h | 6 ++
arch/powerpc/kernel/iommu.c | 141 ++++++++++++++++++++++++++++++++++
arch/powerpc/platforms/powernv/pci.c | 135 ++++++++++++++++++++++++++++++++
drivers/iommu/Kconfig | 8 ++
4 files changed, 290 insertions(+)
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index cbfe678..5ba66cb 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -76,6 +76,9 @@ struct iommu_table {
struct iommu_pool large_pool;
struct iommu_pool pools[IOMMU_NR_POOLS];
unsigned long *it_map; /* A simple allocation bitmap for now */
+#ifdef CONFIG_IOMMU_API
+ struct iommu_group *it_group;
+#endif
};
struct scatterlist;
@@ -147,5 +150,8 @@ static inline void iommu_restore(void)
}
#endif
+extern long iommu_put_tces(struct iommu_table *tbl, unsigned long entry, uint64_t tce,
+ enum dma_data_direction direction, unsigned long pages);
+
#endif /* __KERNEL__ */
#endif /* _ASM_IOMMU_H */
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index ff5a6ce..c8dad1f 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -44,6 +44,7 @@
#include <asm/kdump.h>
#include <asm/fadump.h>
#include <asm/vio.h>
+#include <asm/tce.h>
#define DBG(...)
@@ -856,3 +857,143 @@ void iommu_free_coherent(struct iommu_table *tbl, size_t size,
free_pages((unsigned long)vaddr, get_order(size));
}
}
+
+#ifdef CONFIG_IOMMU_API
+/*
+ * SPAPR TCE API
+ */
+static struct page *free_tce(struct iommu_table *tbl, unsigned long entry)
+{
+ struct page *page;
+ unsigned long oldtce;
+
+ oldtce = ppc_md.tce_get(tbl, entry);
+
+ if (!(oldtce & (TCE_PCI_WRITE | TCE_PCI_READ)))
+ return NULL;
+
+ page = pfn_to_page(oldtce >> PAGE_SHIFT);
+
+ WARN_ON(!page);
+ if (page && (oldtce & TCE_PCI_WRITE))
+ SetPageDirty(page);
+ ppc_md.tce_free(tbl, entry, 1);
+
+ return page;
+}
+
+static int put_tce(struct iommu_table *tbl, unsigned long entry,
+ uint64_t tce, enum dma_data_direction direction)
+{
+ int ret;
+ struct page *page = NULL;
+ unsigned long kva, offset;
+
+ /* Map new TCE */
+ offset = (tce & IOMMU_PAGE_MASK) - (tce & PAGE_MASK);
+ ret = get_user_pages_fast(tce & PAGE_MASK, 1,
+ direction != DMA_TO_DEVICE, &page);
+ if (ret < 1) {
+ printk(KERN_ERR "tce_vfio: get_user_pages_fast failed tce=%llx ioba=%lx ret=%d\n",
+ tce, entry << IOMMU_PAGE_SHIFT, ret);
+ if (!ret)
+ ret = -EFAULT;
+ return ret;
+ }
+
+ kva = (unsigned long) page_address(page);
+ kva += offset;
+
+ /* tce_build receives a virtual address */
+ entry += tbl->it_offset; /* Offset into real TCE table */
+ ret = ppc_md.tce_build(tbl, entry, 1, kva, direction, NULL);
+
+ /* tce_build() only returns non-zero for transient errors */
+ if (unlikely(ret)) {
+ printk(KERN_ERR "tce_vfio: tce_put failed on tce=%llx ioba=%lx kva=%lx ret=%d\n",
+ tce, entry << IOMMU_PAGE_SHIFT, kva, ret);
+ put_page(page);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static void tce_flush(struct iommu_table *tbl)
+{
+ /* Flush/invalidate TLB caches if necessary */
+ if (ppc_md.tce_flush)
+ ppc_md.tce_flush(tbl);
+
+ /* Make sure updates are seen by hardware */
+ mb();
+}
+
+long iommu_put_tces(struct iommu_table *tbl, unsigned long entry, uint64_t tce,
+ enum dma_data_direction direction, unsigned long pages)
+{
+ int i, ret = 0, pages_to_put = 0;
+ struct page *page;
+ struct iommu_pool *pool = get_pool(tbl, entry);
+ struct page **oldpages;
+ const int oldpagesnum = PAGE_SIZE/sizeof(*oldpages);
+
+ BUILD_BUG_ON(PAGE_SIZE < IOMMU_PAGE_SIZE);
+
+ /* Handle a single page request without allocation
+ of pages-to-release array */
+ if (pages == 1) {
+ spin_lock(&(pool->lock));
+ page = free_tce(tbl, entry);
+
+ if (direction != DMA_NONE)
+ ret = put_tce(tbl, entry, tce, direction);
+
+ tce_flush(tbl);
+
+ if (page)
+ put_page(page);
+
+ spin_unlock(&(pool->lock));
+ return ret;
+ }
+
+ /* Releasing multiple pages */
+ /* Allocate an array for pages to be released after TCE table
+ is updated */
+ oldpages = kmalloc(PAGE_SIZE, GFP_KERNEL);
+ if (!oldpages)
+ return -ENOMEM;
+
+ spin_lock(&(pool->lock));
+
+ for (i = 0; (i < pages) && !ret; ++i, ++entry, tce += IOMMU_PAGE_SIZE) {
+ page = free_tce(tbl, entry);
+ if (page) {
+ oldpages[pages_to_put] = page;
+ ++pages_to_put;
+ }
+
+ if (direction != DMA_NONE)
+ ret = put_tce(tbl, entry, tce, direction);
+
+ /* Release old pages if we reached the end of oldpages[] or
+ it is the last page or we are about to exit the loop */
+ if ((pages_to_put == oldpagesnum) || (i == pages - 1) || ret) {
+ tce_flush(tbl);
+
+ /* Release pages after removing them from TCE table */
+ while (pages_to_put) {
+ --pages_to_put;
+ put_page(oldpages[pages_to_put]);
+ }
+ }
+ }
+
+ spin_unlock(&(pool->lock));
+ kfree(oldpages);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(iommu_put_tces);
+#endif /* CONFIG_IOMMU_API */
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index 05205cf..660dcc6 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -20,6 +20,7 @@
#include <linux/irq.h>
#include <linux/io.h>
#include <linux/msi.h>
+#include <linux/iommu.h>
#include <asm/sections.h>
#include <asm/io.h>
@@ -613,3 +614,137 @@ void __init pnv_pci_init(void)
ppc_md.teardown_msi_irqs = pnv_teardown_msi_irqs;
#endif
}
+
+#ifdef CONFIG_IOMMU_API
+/*
+ * IOMMU groups support required by VFIO
+ */
+static int add_device(struct device *dev)
+{
+ struct iommu_table *tbl;
+ int ret = 0;
+
+ if (WARN_ON(dev->iommu_group)) {
+ printk(KERN_WARNING "tce_vfio: device %s is already in iommu group %d, skipping\n",
+ dev_name(dev),
+ iommu_group_id(dev->iommu_group));
+ return -EBUSY;
+ }
+
+ tbl = get_iommu_table_base(dev);
+ if (!tbl) {
+ pr_debug("tce_vfio: skipping device %s with no tbl\n",
+ dev_name(dev));
+ return 0;
+ }
+
+ pr_debug("tce_vfio: adding %s to iommu group %d\n",
+ dev_name(dev), iommu_group_id(tbl->it_group));
+
+ ret = iommu_group_add_device(tbl->it_group, dev);
+ if (ret < 0)
+ printk(KERN_ERR "tce_vfio: %s has not been added, ret=%d\n",
+ dev_name(dev), ret);
+
+ return ret;
+}
+
+static void del_device(struct device *dev)
+{
+ iommu_group_remove_device(dev);
+}
+
+static int iommu_bus_notifier(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ struct device *dev = data;
+
+ switch (action) {
+ case BUS_NOTIFY_ADD_DEVICE:
+ return add_device(dev);
+ case BUS_NOTIFY_DEL_DEVICE:
+ del_device(dev);
+ return 0;
+ default:
+ return 0;
+ }
+}
+
+static struct notifier_block tce_iommu_bus_nb = {
+ .notifier_call = iommu_bus_notifier,
+};
+
+static void group_release(void *iommu_data)
+{
+ struct iommu_table *tbl = iommu_data;
+ tbl->it_group = NULL;
+}
+
+static int __init tce_iommu_init(void)
+{
+ struct pci_dev *pdev = NULL;
+ struct iommu_table *tbl;
+ struct iommu_group *grp;
+
+ bus_register_notifier(&pci_bus_type, &tce_iommu_bus_nb);
+
+ /* Allocate and initialize IOMMU groups */
+ for_each_pci_dev(pdev) {
+ tbl = get_iommu_table_base(&pdev->dev);
+ if (!tbl)
+ continue;
+
+ /* Skip already initialized */
+ if (tbl->it_group)
+ continue;
+
+ grp = iommu_group_alloc();
+ if (IS_ERR(grp)) {
+ printk(KERN_INFO "tce_vfio: cannot create "
+ "new IOMMU group, ret=%ld\n",
+ PTR_ERR(grp));
+ return PTR_ERR(grp);
+ }
+ tbl->it_group = grp;
+ iommu_group_set_iommudata(grp, tbl, group_release);
+ }
+
+ /* Add PCI devices to VFIO groups */
+ for_each_pci_dev(pdev)
+ add_device(&pdev->dev);
+
+ return 0;
+}
+
+static void __exit tce_iommu_cleanup(void)
+{
+ struct pci_dev *pdev = NULL;
+ struct iommu_table *tbl;
+ struct iommu_group *grp = NULL;
+
+ bus_unregister_notifier(&pci_bus_type, &tce_iommu_bus_nb);
+
+ /* Delete PCI devices from VFIO groups */
+ for_each_pci_dev(pdev)
+ del_device(&pdev->dev);
+
+ /* Release VFIO groups */
+ for_each_pci_dev(pdev) {
+ tbl = get_iommu_table_base(&pdev->dev);
+ if (!tbl)
+ continue;
+ grp = tbl->it_group;
+
+ /* Skip (already) uninitialized */
+ if (!grp)
+ continue;
+
+ /* Do actual release, group_release() is expected to work */
+ iommu_group_put(grp);
+ BUG_ON(tbl->it_group);
+ }
+}
+
+module_init(tce_iommu_init);
+module_exit(tce_iommu_cleanup);
+#endif /* CONFIG_IOMMU_API */
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index 9f69b56..29d11dc 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -187,4 +187,12 @@ config EXYNOS_IOMMU_DEBUG
Say N unless you need kernel log message for IOMMU debugging
+config SPAPR_TCE_IOMMU
+ bool "sPAPR TCE IOMMU Support"
+ depends on PPC_POWERNV
+ select IOMMU_API
+ help
+ Enables bits of IOMMU API required by VFIO. The iommu_ops is
+ still not implemented.
+
endif # IOMMU_SUPPORT
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH 056/493] edac: remove use of __devexit_p
From: Borislav Petkov @ 2012-11-23 10:06 UTC (permalink / raw)
To: Greg KH
Cc: Arvind R., Mark Gross, Mauro Carvalho Chehab, Jason Uhlenkott,
Ranganathan Desikan, Bill Pemberton, Egor Martovetsky,
Doug Thompson, Olof Johansson, linux-edac, linuxppc-dev,
Tim Small
In-Reply-To: <20121122182222.GB25392@kroah.com>
On Thu, Nov 22, 2012 at 10:22:22AM -0800, Greg KH wrote:
> On Thu, Nov 22, 2012 at 02:44:51PM +0100, Borislav Petkov wrote:
> > On Mon, Nov 19, 2012 at 01:20:05PM -0500, Bill Pemberton wrote:
> > > CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
> > > needed.
> >
> > Erm, I don't understand. __devexit_p is defined also for modules not
> > only for CONFIG_HOTPLUG:
> >
> > #if defined(MODULE) || defined(CONFIG_HOTPLUG)
> > #define __devexit_p(x) x
> > #else
> > #define __devexit_p(x) NULL
> > #endif
> >
> > AFAICT, we cannot remove it yet no?
>
> If MODULE is defined, it defaults to nothing. And now that
> CONFIG_HOTPLUG is always set to Y, this always defaults to nothing.
Huh, if MODULE is defined, __devexit_p(x) evaluates to the function name
'x' itself, AFAICT.
So, if MODULE is defined and we have a reference from retained sections
to a discarded section (I'm rereading the comment over __devexit_p in
<include/linux/init.h> btw) then we'll get linker errors so we'd still
need the ifdef thing, no?
What am I missing?
Thanks.
--
Regards/Gruss,
Boris.
^ permalink raw reply
* Re: [PATCH 056/493] edac: remove use of __devexit_p
From: Greg KH @ 2012-11-23 16:40 UTC (permalink / raw)
To: Borislav Petkov
Cc: Arvind R., Mark Gross, Mauro Carvalho Chehab, Jason Uhlenkott,
Ranganathan Desikan, Bill Pemberton, Egor Martovetsky,
Doug Thompson, Olof Johansson, linux-edac, linuxppc-dev,
Tim Small
In-Reply-To: <20121123100635.GC18765@x1.alien8.de>
On Fri, Nov 23, 2012 at 11:06:35AM +0100, Borislav Petkov wrote:
> On Thu, Nov 22, 2012 at 10:22:22AM -0800, Greg KH wrote:
> > On Thu, Nov 22, 2012 at 02:44:51PM +0100, Borislav Petkov wrote:
> > > On Mon, Nov 19, 2012 at 01:20:05PM -0500, Bill Pemberton wrote:
> > > > CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
> > > > needed.
> > >
> > > Erm, I don't understand. __devexit_p is defined also for modules not
> > > only for CONFIG_HOTPLUG:
> > >
> > > #if defined(MODULE) || defined(CONFIG_HOTPLUG)
> > > #define __devexit_p(x) x
> > > #else
> > > #define __devexit_p(x) NULL
> > > #endif
> > >
> > > AFAICT, we cannot remove it yet no?
> >
> > If MODULE is defined, it defaults to nothing. And now that
> > CONFIG_HOTPLUG is always set to Y, this always defaults to nothing.
>
> Huh, if MODULE is defined, __devexit_p(x) evaluates to the function name
> 'x' itself, AFAICT.
Yes, sorry, that is what I was trying to say here, I meant "nothing" in
that the macro did not do anything, not that it was setting it to NULL.
> So, if MODULE is defined and we have a reference from retained sections
> to a discarded section (I'm rereading the comment over __devexit_p in
> <include/linux/init.h> btw) then we'll get linker errors so we'd still
> need the ifdef thing, no?
No, as there will not be any discarded sections anymore because
CONFIG_HOTPLUG is always enabled. We will just delete this whole
#if/#endif section once all users of __devexit_p() are gone from the
tree.
Does that help out?
thanks,
greg k-h
^ permalink raw reply
* [PATCH 1/9] ARM64: dma_debug: add debug_dma_mapping_error support
From: Shuah Khan @ 2012-11-23 21:31 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
Add dma-debug interface debug_dma_mapping_error() to debug drivers that fail
to check dma mapping errors on addresses returned by dma_map_single() and
dma_map_page() interfaces.
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
---
arch/arm64/include/asm/dma-mapping.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index 538f4b4..9947768 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -50,6 +50,7 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dev_addr)
static inline int dma_mapping_error(struct device *dev, dma_addr_t dev_addr)
{
struct dma_map_ops *ops = get_dma_ops(dev);
+ debug_dma_mapping_error(dev, dev_addr);
return ops->mapping_error(dev, dev_addr);
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/9] c6x: dma_debug: add debug_dma_mapping_error support
From: Shuah Khan @ 2012-11-23 21:32 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
Add dma-debug interface debug_dma_mapping_error() to debug drivers that fail
to check dma mapping errors on addresses returned by dma_map_single() and
dma_map_page() interfaces.
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
Acked-by: Mark Salter <msalter@redhat.com>
---
arch/c6x/include/asm/dma-mapping.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/c6x/include/asm/dma-mapping.h b/arch/c6x/include/asm/dma-mapping.h
index 03579fd..3c69406 100644
--- a/arch/c6x/include/asm/dma-mapping.h
+++ b/arch/c6x/include/asm/dma-mapping.h
@@ -32,6 +32,7 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
*/
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
+ debug_dma_mapping_error(dev, dma_addr);
return dma_addr == ~0;
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH 0/9] dma_debug: add debug_dma_mapping_error support to architectures that support DMA_DEBUG_API
From: Shuah Khan @ 2012-11-23 21:29 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
An earlier patch added dma mapping error debug feature to dma_debug
infrastructure. References:
https://lkml.org/lkml/2012/10/8/296
https://lkml.org/lkml/2012/11/3/219
The following series of patches adds the call to debug_dma_mapping_error() to
architecture specific dma_mapping_error() interfaces on the following
architectures that support CONFIG_DMA_API_DEBUG.
arm64
c6x
ia64
microblaze
mips
powerpc
sh
sparc
tile
arm - Change is already in Marek's dma-mapping tree[1]
https://patchwork.kernel.org/patch/1625601/
microblaze - Change is already in linux-next. Including it for completeness
linux-next commit f229605441030bcd315c21d97b25889d63ed0130
x86 - done in the first patch that added the feature.
ARM64: dma_debug: add debug_dma_mapping_error support
c6x: dma_debug: add debug_dma_mapping_error support
ia64: dma_debug: add debug_dma_mapping_error support
microblaze: dma-mapping: support debug_dma_mapping_error
mips: dma_debug: add debug_dma_mapping_error support
powerpc: dma_debug: add debug_dma_mapping_error support
sh: dma_debug: add debug_dma_mapping_error support
sparc: dma_debug: add debug_dma_mapping_error support
tile: dma_debug: add debug_dma_mapping_error support
Thanks,
-- Shuah
^ permalink raw reply
* [PATCH 8/9] sparc: dma_debug: add debug_dma_mapping_error support
From: Shuah Khan @ 2012-11-23 21:37 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
Add dma-debug interface debug_dma_mapping_error() to debug drivers that fail
to check dma mapping errors on addresses returned by dma_map_single() and
dma_map_page() interfaces.
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
Acked-by: David S. Miller <davem@davemloft.net>
---
arch/sparc/include/asm/dma-mapping.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 8493fd3..05fe53f 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -59,6 +59,7 @@ static inline void dma_free_attrs(struct device *dev, size_t size,
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
+ debug_dma_mapping_error(dev, dma_addr);
return (dma_addr == DMA_ERROR_CODE);
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH 9/9] tile: dma_debug: add debug_dma_mapping_error support
From: Shuah Khan @ 2012-11-23 21:37 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
Add dma-debug interface debug_dma_mapping_error() to debug drivers that fail
to check dma mapping errors on addresses returned by dma_map_single() and
dma_map_page() interfaces.
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
---
arch/tile/include/asm/dma-mapping.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/tile/include/asm/dma-mapping.h b/arch/tile/include/asm/dma-mapping.h
index 4b6247d..f2ff191 100644
--- a/arch/tile/include/asm/dma-mapping.h
+++ b/arch/tile/include/asm/dma-mapping.h
@@ -72,6 +72,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
static inline int
dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
+ debug_dma_mapping_error(dev, dma_addr);
return get_dma_ops(dev)->mapping_error(dev, dma_addr);
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH 5/9] mips: dma_debug: add debug_dma_mapping_error support
From: Shuah Khan @ 2012-11-23 21:34 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
Add dma-debug interface debug_dma_mapping_error() to debug drivers that fail
to check dma mapping errors on addresses returned by dma_map_single() and
dma_map_page() interfaces.
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
---
arch/mips/include/asm/dma-mapping.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index be39a12..006b43e 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -40,6 +40,8 @@ static inline int dma_supported(struct device *dev, u64 mask)
static inline int dma_mapping_error(struct device *dev, u64 mask)
{
struct dma_map_ops *ops = get_dma_ops(dev);
+
+ debug_dma_mapping_error(dev, mask);
return ops->mapping_error(dev, mask);
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH 6/9] powerpc: dma_debug: add debug_dma_mapping_error support
From: Shuah Khan @ 2012-11-23 21:35 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
Add dma-debug interface debug_dma_mapping_error() to debug drivers that fail
to check dma mapping errors on addresses returned by dma_map_single() and
dma_map_page() interfaces.
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
---
arch/powerpc/include/asm/dma-mapping.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 7816087..e27e9ad 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -172,6 +172,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
struct dma_map_ops *dma_ops = get_dma_ops(dev);
+ debug_dma_mapping_error(dev, dma_addr);
if (dma_ops->mapping_error)
return dma_ops->mapping_error(dev, dma_addr);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 4/9] microblaze: dma-mapping: support debug_dma_mapping_error
From: Shuah Khan @ 2012-11-23 21:33 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
Add support for debug_dma_mapping_error() call to avoid warning from
debug_dma_unmap() interface when it checks for mapping error checked
status. Without this patch, device driver failed to check map error
warning is generated.
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
Acked-by: Michal Simek <monstr@monstr.eu>
---
This patch is already in linux-next. Including it in this series for
completeness. linux-next commit f229605441030bcd315c21d97b25889d63ed0130
-- shuah
---
arch/microblaze/include/asm/dma-mapping.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/microblaze/include/asm/dma-mapping.h b/arch/microblaze/include/asm/dma-mapping.h
index 01d2282..46460f1 100644
--- a/arch/microblaze/include/asm/dma-mapping.h
+++ b/arch/microblaze/include/asm/dma-mapping.h
@@ -114,6 +114,8 @@ static inline void __dma_sync(unsigned long paddr,
static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
struct dma_map_ops *ops = get_dma_ops(dev);
+
+ debug_dma_mapping_error(dev, dma_addr);
if (ops->mapping_error)
return ops->mapping_error(dev, dma_addr);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 3/9] ia64: dma_debug: add debug_dma_mapping_error support
From: Shuah Khan @ 2012-11-23 21:32 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
Add dma-debug interface debug_dma_mapping_error() to debug drivers that fail
to check dma mapping errors on addresses returned by dma_map_single() and
dma_map_page() interfaces.
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
---
arch/ia64/include/asm/dma-mapping.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h
index 4f5e814..cf3ab7e 100644
--- a/arch/ia64/include/asm/dma-mapping.h
+++ b/arch/ia64/include/asm/dma-mapping.h
@@ -58,6 +58,7 @@ static inline void dma_free_attrs(struct device *dev, size_t size,
static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr)
{
struct dma_map_ops *ops = platform_dma_get_ops(dev);
+ debug_dma_mapping_error(dev, daddr);
return ops->mapping_error(dev, daddr);
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH 7/9] sh: dma_debug: add debug_dma_mapping_error support
From: Shuah Khan @ 2012-11-23 21:36 UTC (permalink / raw)
To: Joerg Roedel, a-jacquiot, fenghua.yu, catalin.marinas, lethal,
benh, ralf, tony.luck, davem, m.szyprowski, msalter, monstr,
Ming Lei
Cc: linux-mips, linux-ia64, linux-c6x-dev, linux-sh,
microblaze-uclinux, LKML, shuahkhan, sparclinux, linuxppc-dev,
linux-arm-kernel
Add dma-debug interface debug_dma_mapping_error() to debug drivers that fail
to check dma mapping errors on addresses returned by dma_map_single() and
dma_map_page() interfaces.
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
---
arch/sh/include/asm/dma-mapping.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/sh/include/asm/dma-mapping.h b/arch/sh/include/asm/dma-mapping.h
index 8bd965e..b437f2c 100644
--- a/arch/sh/include/asm/dma-mapping.h
+++ b/arch/sh/include/asm/dma-mapping.h
@@ -46,6 +46,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
{
struct dma_map_ops *ops = get_dma_ops(dev);
+ debug_dma_mapping_error(dev, dma_addr);
if (ops->mapping_error)
return ops->mapping_error(dev, dma_addr);
--
1.7.9.5
^ permalink raw reply related
* [PATCH 5/8] perf powerpc: Use uapi/unistd.h to fix build error
From: Arnaldo Carvalho de Melo @ 2012-11-24 0:20 UTC (permalink / raw)
To: Ingo Molnar
Cc: Peter Zijlstra, Robert Richter, Anton Blanchard, linux-kernel,
Arnaldo Carvalho de Melo, linuxppc-dev, Ingo Molnar,
Paul Mackerras, Sukadev Bhattiprolu
In-Reply-To: <1353716453-9693-1-git-send-email-acme@infradead.org>
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Use the 'unistd.h' from arch/powerpc/include/uapi to build the perf tool.
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: David Howells <dhowells@redhat.com>
Cc: Anton Blanchard <anton@au1.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Robert Richter <robert.richter@amd.com>
Cc: linuxppc-dev@ozlabs.org
Link: http://lkml.kernel.org/r/20121107191818.GA16211@us.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/perf.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index c50985e..e2ba8f0 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -26,7 +26,7 @@ void get_term_dimensions(struct winsize *ws);
#endif
#ifdef __powerpc__
-#include "../../arch/powerpc/include/asm/unistd.h"
+#include "../../arch/powerpc/include/uapi/asm/unistd.h"
#define rmb() asm volatile ("sync" ::: "memory")
#define cpu_relax() asm volatile ("" ::: "memory");
#define CPUINFO_PROC "cpu"
--
1.7.9.2.358.g22243
^ permalink raw reply related
* [GIT PULL 0/8] perf/urgent fixes
From: Arnaldo Carvalho de Melo @ 2012-11-24 0:20 UTC (permalink / raw)
To: Ingo Molnar
Cc: David Howells, linuxppc-dev, Paul Mackerras,
Arnaldo Carvalho de Melo, Robert Richter, x86, Xiao Guangrong,
acme, Sukadev Bhattiprolu, linux-arch, Peter Zijlstra,
Namhyung Kim, Anton Blanchard, Arnaldo Carvalho de Melo, Dong Hao,
Borislav Petkov, Runzhen Wang, Thomas Gleixner, linux-kernel,
David Ahern, Linus Torvalds
Hi Ingo,
Tested using a cross-compiler and directly on a Raspberry pi (ARM) with
raspbian.
Please consider pulling.
- Arnaldo
The following changes since commit 18423d3562f396206e0928a71177eeb2edfed077:
Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2012-11-13 18:51:51 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-urgent-for-mingo
for you to fetch changes up to 7321090f6751c9987c26a8c81c63680d16a614d7:
perf kvm: Fix building perf kvm on non x86 arches (2012-11-23 20:40:17 -0300)
----------------------------------------------------------------
perf/urgent fixes
. Don't build 'perf kvm stat" on non-x86 arches, fix from Xiao Guangrong.
. UAPI fixes to get perf building again in non-x86 arches, from David Howells.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
Merge tag 'perf-uapi-20121119' of git://git.infradead.org/users/dhowells/linux-headers into perf/urgent
David Howells (6):
x86: Export asm/{svm.h,vmx.h,perf_regs.h}
Merge branch 'x86-pre-uapi' into perf-uapi
tools: Define a Makefile function to do subdir processing
tools: Honour the O= flag when tool build called from a higher Makefile
tools: Pass the target in descend
perf: Make perf build for x86 with UAPI disintegration applied
Sukadev Bhattiprolu (1):
perf powerpc: Use uapi/unistd.h to fix build error
Xiao Guangrong (2):
perf kvm: Rename perf_kvm to perf_kvm_stat
perf kvm: Fix building perf kvm on non x86 arches
Makefile | 6 +-
arch/x86/include/asm/Kbuild | 3 +
include/linux/hw_breakpoint.h | 31 +-------
include/uapi/linux/Kbuild | 1 +
include/uapi/linux/hw_breakpoint.h | 30 ++++++++
tools/Makefile | 24 +++---
tools/perf/Makefile | 29 +++++++-
tools/perf/arch/x86/include/perf_regs.h | 2 +-
tools/perf/builtin-kvm.c | 121 +++++++++++++++++--------------
tools/perf/builtin-test.c | 2 +-
tools/perf/perf.h | 16 +---
tools/perf/util/evsel.c | 4 +-
tools/perf/util/evsel.h | 3 +-
tools/perf/util/header.h | 2 +-
tools/perf/util/parse-events-test.c | 2 +-
tools/perf/util/parse-events.c | 2 +-
tools/perf/util/parse-events.h | 2 +-
tools/perf/util/pmu.h | 2 +-
tools/perf/util/session.h | 2 +-
tools/scripts/Makefile.include | 23 +++++-
20 files changed, 181 insertions(+), 126 deletions(-)
create mode 100644 include/uapi/linux/hw_breakpoint.h
^ permalink raw reply
* Re: [PATCH 056/493] edac: remove use of __devexit_p
From: Borislav Petkov @ 2012-11-24 9:14 UTC (permalink / raw)
To: Greg KH
Cc: Arvind R., Mark Gross, Mauro Carvalho Chehab, Jason Uhlenkott,
Ranganathan Desikan, Bill Pemberton, Egor Martovetsky,
Doug Thompson, Olof Johansson, linux-edac, linuxppc-dev,
Tim Small
In-Reply-To: <20121123164024.GB5471@kroah.com>
On Fri, Nov 23, 2012 at 08:40:24AM -0800, Greg KH wrote:
> No, as there will not be any discarded sections anymore because
> CONFIG_HOTPLUG is always enabled. We will just delete this whole
> #if/#endif section once all users of __devexit_p() are gone from the
> tree.
>
> Does that help out?
Yes, I missed the fact that there won't be any discarded sections
anymore. Btw, in that case, you'd probably need to remove all those
#ifdef CONFIG_HOTPLUG
...
#endif
stanzas surrounding different places in the kernel (I see 40ish
currenty) now that HOTPLUG is def_bool y and if you haven't done so yet.
Thanks for explaining.
Btw, you can have my
Acked-by: Borislav Petkov <bp@alien8.de>
for the amd64_edac pieces.
--
Regards/Gruss,
Boris.
^ permalink raw reply
* Re: [PATCH 056/493] edac: remove use of __devexit_p
From: Greg KH @ 2012-11-24 17:59 UTC (permalink / raw)
To: Borislav Petkov
Cc: Arvind R., Mark Gross, Mauro Carvalho Chehab, Jason Uhlenkott,
Ranganathan Desikan, Bill Pemberton, Egor Martovetsky,
Doug Thompson, Olof Johansson, linux-edac, linuxppc-dev,
Tim Small
In-Reply-To: <20121124091453.GC25143@x1.alien8.de>
On Sat, Nov 24, 2012 at 10:14:53AM +0100, Borislav Petkov wrote:
> On Fri, Nov 23, 2012 at 08:40:24AM -0800, Greg KH wrote:
> > No, as there will not be any discarded sections anymore because
> > CONFIG_HOTPLUG is always enabled. We will just delete this whole
> > #if/#endif section once all users of __devexit_p() are gone from the
> > tree.
> >
> > Does that help out?
>
> Yes, I missed the fact that there won't be any discarded sections
> anymore. Btw, in that case, you'd probably need to remove all those
>
> #ifdef CONFIG_HOTPLUG
>
> ...
>
> #endif
>
> stanzas surrounding different places in the kernel (I see 40ish
> currenty) now that HOTPLUG is def_bool y and if you haven't done so yet.
That removal was done as part of this 493 patches long patchset :)
> Thanks for explaining.
>
> Btw, you can have my
>
> Acked-by: Borislav Petkov <bp@alien8.de>
>
> for the amd64_edac pieces.
Thanks, I will add it there,
greg k-h
^ permalink raw reply
* Re: [PATCH] powerpc/pci-hotplug: fix the rescanned pci device's dma_set_mask issue
From: Kumar Gala @ 2012-11-25 12:41 UTC (permalink / raw)
To: Yuanquan Chen; +Cc: linuxppc-dev, r61911
In-Reply-To: <1353644968-29469-1-git-send-email-B41889@freescale.com>
On Nov 22, 2012, at 10:29 PM, Yuanquan Chen wrote:
> On powerpc arch, dma_ops of rescanned pci device after system's =
booting up won't be
> initialized by system, so it will fail to execute the dma_set_mask in =
the device's
> driver. Initialize it to solve this issue.
>=20
> Signed-off-by: Yuanquan Chen <B41889@freescale.com>
> ---
> arch/powerpc/include/asm/dma-mapping.h | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
This is not the right way to get the dma_ops setup. You need to find =
some other point for the hotplug scenario to get the dma_ops setup.
- k
>=20
> diff --git a/arch/powerpc/include/asm/dma-mapping.h =
b/arch/powerpc/include/asm/dma-mapping.h
> index 7816087..22eae53 100644
> --- a/arch/powerpc/include/asm/dma-mapping.h
> +++ b/arch/powerpc/include/asm/dma-mapping.h
> @@ -126,8 +126,11 @@ static inline int dma_supported(struct device =
*dev, u64 mask)
> {
> struct dma_map_ops *dma_ops =3D get_dma_ops(dev);
>=20
> - if (unlikely(dma_ops =3D=3D NULL))
> - return 0;
> + if (unlikely(dma_ops =3D=3D NULL)) {
> + set_dma_ops(dev, &dma_direct_ops);
> + set_dma_offset(dev, PCI_DRAM_OFFSET);
> + dma_ops =3D &dma_direct_ops;
> + }
> if (dma_ops->dma_supported =3D=3D NULL)
> return 1;
> return dma_ops->dma_supported(dev, mask);
> --=20
> 1.7.9.5
>=20
>=20
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply
* Re: [PATCH] powerpc/mpc85xx: Change spin table to cached memory
From: Gala Kumar-B11780 @ 2012-11-25 13:01 UTC (permalink / raw)
To: sun york-R58495
Cc: Wood Scott-B07421, Tabi Timur-B04825,
<linuxppc-dev@lists.ozlabs.org>
In-Reply-To: <1348962275-24052-1-git-send-email-yorksun@freescale.com>
On Sep 29, 2012, at 6:44 PM, York Sun wrote:
> ePAPR v1.1 requires the spin table to be in cached memory. So we need
> to change the call argument of ioremap to enable cache and coherence.
> We also flush the cache after writing to spin table to keep it compatible
> with previous cache-inhibit spin table. Flushing before and after
> accessing spin table is recommended by ePAPR.
>=20
> Signed-off-by: York Sun <yorksun@freescale.com>
> Acked-by: Timur Tabi <timur@freescale.com>
> ---
> This patch applies to git://git.kernel.org/pub/scm/linux/kernel/git/galak=
/powerpc.git next branch.
>=20
> arch/powerpc/platforms/85xx/smp.c | 49 +++++++++++++++++++++++++++-----=
-----
> 1 file changed, 36 insertions(+), 13 deletions(-)
applied to next
- k=
^ permalink raw reply
* Re: [PATCH 1/2] powerpc/85xx: p1022ds: Use NULL instead of 0 for pointers
From: Kumar Gala @ 2012-11-25 13:07 UTC (permalink / raw)
To: Tushar Behera; +Cc: devicetree-discuss, linuxppc-dev, patches
In-Reply-To: <1353385912-25882-1-git-send-email-tushar.behera@linaro.org>
On Nov 19, 2012, at 10:31 PM, Tushar Behera wrote:
> The third argument for of_get_property() is a pointer, hence pass
> NULL instead of 0.
>
> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
> ---
> arch/powerpc/platforms/85xx/p1022_ds.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
applied to next
- k
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox