Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 9 commits
  • 14 files changed
  • 0 commit comments
  • 4 contributors
Commits on Apr 01, 2012
Jordan Crouse base: genlock: Check for instances where handle is NULL
Check for the possibility of NULL handles passed into the
in-kernel API functions and return error where appropriate.
There is a non-zero chance that the private_data will be
cleared while the FD is still active, so check in the ioctl()
function as well.

(cherry picked from commit a73ed097420c53451e843ae61d9aadc8fefabc94)

Change-Id: If481b98a6a2ab01ab788c23bffe9df7ab8bc6aee
CRs-fixed: 332835
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

Conflicts:

	drivers/base/genlock.c
63a01a5
@Juansheng Juansheng pmem: respect PMEM_DEBUG config db971e7
Anshuman Dani msm: kgsl: Make sure kmemleak tool does not report incorrect mem leak.
Certain memory allocations are not properly tracked by kmemleak tool,
which makes it to incorrectly detect memory leak. Notify the tool by using
kmemleak_not_leak() to ignore the memory allocation so that incorrect leaks
report are avoided.

CRs-Fixed: 334294
Signed-off-by: Anshuman Dani <adani@codeaurora.org>
(cherry picked from commit eecd52061a50325db02d2396bfd455b306a04f34)

Change-Id: If2c955f95c650a73a04aca01977dc7ac13319878
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
7ab64e1
Jordan Crouse msm: kgsl: Do not BUG in GPU recovery if a valid context can't be found
Don't BUG() if we can't find a valid context to recover to; just fail and
go into a zombie state. This usually happens after a first hang goes bad
and the system keeps hanging while trying to find its way. The problem with
a BUG() in this case is that the system goes down and we can't recover the
snapshot or other debug information.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit a400d8da2d5464a47b3fe19b96a3bb04af82114e)

Change-Id: I68581017f6e78a866a6d91033f980ecd06d96360
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
3d9b990
@Juansheng Juansheng net: pppox: add stub PX_PROTO_PPTP macro to be compatible with newer …
…kernel headers
a537560
@Juansheng Juansheng clean ION, enable IOMMU support bdfc131
@Juansheng Juansheng clean up ION definition 15a3602
@Juansheng Juansheng codes clean up again 79fede4
Commits on Apr 03, 2012
@ac1965 Merge remote-tracking branch 'lordclockan/ICS_CAMERA2' into ICS-AUFS_…
…CAMERA2
ace30d6
View
133 arch/arm/mach-msm/include/mach/iommu.h
@@ -0,0 +1,133 @@
+/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#ifndef MSM_IOMMU_H
+#define MSM_IOMMU_H
+
+#include <linux/interrupt.h>
+#include <linux/clk.h>
+#include <mach/socinfo.h>
+
+extern pgprot_t pgprot_kernel;
+
+/* Domain attributes */
+#define MSM_IOMMU_DOMAIN_PT_CACHEABLE 0x1
+
+/* Mask for the cache policy attribute */
+#define MSM_IOMMU_CP_MASK 0x03
+
+/* Maximum number of Machine IDs that we are allowing to be mapped to the same
+ * context bank. The number of MIDs mapped to the same CB does not affect
+ * performance, but there is a practical limit on how many distinct MIDs may
+ * be present. These mappings are typically determined at design time and are
+ * not expected to change at run time.
+ */
+#define MAX_NUM_MIDS 32
+
+/**
+ * struct msm_iommu_dev - a single IOMMU hardware instance
+ * name Human-readable name given to this IOMMU HW instance
+ * ncb Number of context banks present on this IOMMU HW instance
+ */
+struct msm_iommu_dev {
+ const char *name;
+ int ncb;
+};
+
+/**
+ * struct msm_iommu_ctx_dev - an IOMMU context bank instance
+ * name Human-readable name given to this context bank
+ * num Index of this context bank within the hardware
+ * mids List of Machine IDs that are to be mapped into this context
+ * bank, terminated by -1. The MID is a set of signals on the
+ * AXI bus that identifies the function associated with a specific
+ * memory request. (See ARM spec).
+ */
+struct msm_iommu_ctx_dev {
+ const char *name;
+ int num;
+ int mids[MAX_NUM_MIDS];
+};
+
+
+/**
+ * struct msm_iommu_drvdata - A single IOMMU hardware instance
+ * @base: IOMMU config port base address (VA)
+ * @ncb The number of contexts on this IOMMU
+ * @irq: Interrupt number
+ * @clk: The bus clock for this IOMMU hardware instance
+ * @pclk: The clock for the IOMMU bus interconnect
+ *
+ * A msm_iommu_drvdata holds the global driver data about a single piece
+ * of an IOMMU hardware instance.
+ */
+struct msm_iommu_drvdata {
+ void __iomem *base;
+ int irq;
+ int ncb;
+ struct clk *clk;
+ struct clk *pclk;
+ const char *name;
+};
+
+/**
+ * struct msm_iommu_ctx_drvdata - an IOMMU context bank instance
+ * @num: Hardware context number of this context
+ * @pdev: Platform device associated wit this HW instance
+ * @attached_elm: List element for domains to track which devices are
+ * attached to them
+ *
+ * A msm_iommu_ctx_drvdata holds the driver data for a single context bank
+ * within each IOMMU hardware instance
+ */
+struct msm_iommu_ctx_drvdata {
+ int num;
+ struct platform_device *pdev;
+ struct list_head attached_elm;
+};
+
+/*
+ * Interrupt handler for the IOMMU context fault interrupt. Hooking the
+ * interrupt is not supported in the API yet, but this will print an error
+ * message and dump useful IOMMU registers.
+ */
+irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id);
+
+#ifdef CONFIG_MSM_IOMMU
+/*
+ * Look up an IOMMU context device by its context name. NULL if none found.
+ * Useful for testing and drivers that do not yet fully have IOMMU stuff in
+ * their platform devices.
+ */
+struct device *msm_iommu_get_ctx(const char *ctx_name);
+#else
+static inline struct device *msm_iommu_get_ctx(const char *ctx_name)
+{
+ return NULL;
+}
+#endif
+
+#endif
+
+static inline int msm_soc_version_supports_iommu(void)
+{
+ if (cpu_is_msm8960() &&
+ SOCINFO_VERSION_MAJOR(socinfo_get_version()) < 2)
+ return 0;
+
+ if (cpu_is_msm8x60() &&
+ (SOCINFO_VERSION_MAJOR(socinfo_get_version()) != 2 ||
+ SOCINFO_VERSION_MINOR(socinfo_get_version()) < 1)) {
+ return 0;
+ }
+ return 1;
+}
View
35 drivers/base/genlock.c
@@ -1,5 +1,4 @@
-/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
- * Copyright (C) 2011 Sony Ericsson Mobile Communications AB.
+/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -112,6 +111,11 @@ struct genlock *genlock_create_lock(struct genlock_handle *handle)
{
struct genlock *lock;
+ if (IS_ERR_OR_NULL(handle)) {
+ GENLOCK_LOG_ERR("Invalid handle\n");
+ return ERR_PTR(-EINVAL);
+ }
+
if (handle->lock != NULL) {
GENLOCK_LOG_ERR("Handle already has a lock attached\n");
return ERR_PTR(-EINVAL);
@@ -179,6 +183,11 @@ struct genlock *genlock_attach_lock(struct genlock_handle *handle, int fd)
struct file *file;
struct genlock *lock;
+ if (IS_ERR_OR_NULL(handle)) {
+ GENLOCK_LOG_ERR("Invalid handle\n");
+ return ERR_PTR(-EINVAL);
+ }
+
if (handle->lock != NULL) {
GENLOCK_LOG_ERR("Handle already has a lock attached\n");
return ERR_PTR(-EINVAL);
@@ -394,9 +403,17 @@ static int _genlock_lock(struct genlock *lock, struct genlock_handle *handle,
int genlock_lock(struct genlock_handle *handle, int op, int flags,
uint32_t timeout)
{
- struct genlock *lock = handle->lock;
+ struct genlock *lock;
+
int ret = 0;
+ if (IS_ERR_OR_NULL(handle)) {
+ GENLOCK_LOG_ERR("Invalid handle\n");
+ return -EINVAL;
+ }
+
+ lock = handle->lock;
+
if (lock == NULL) {
GENLOCK_LOG_ERR("Handle does not have a lock attached\n");
return -EINVAL;
@@ -428,11 +445,18 @@ EXPORT_SYMBOL(genlock_lock);
int genlock_wait(struct genlock_handle *handle, uint32_t timeout)
{
- struct genlock *lock = handle->lock;
+ struct genlock *lock;
unsigned long irqflags;
int ret = 0;
unsigned long ticks = msecs_to_jiffies(timeout);
+ if (IS_ERR_OR_NULL(handle)) {
+ GENLOCK_LOG_ERR("Invalid handle\n");
+ return -EINVAL;
+ }
+
+ lock = handle->lock;
+
if (lock == NULL) {
GENLOCK_LOG_ERR("Handle does not have a lock attached\n");
return -EINVAL;
@@ -585,6 +609,9 @@ static long genlock_dev_ioctl(struct file *filep, unsigned int cmd,
struct genlock *lock;
int ret;
+ if (IS_ERR_OR_NULL(handle))
+ return -EINVAL;
+
switch (cmd) {
case GENLOCK_IOC_NEW: {
lock = genlock_create_lock(handle);
View
1 drivers/gpu/msm/Makefile
@@ -8,6 +8,7 @@ msm_kgsl_core-y = \
kgsl_pwrscale.o \
kgsl_mmu.o \
kgsl_gpummu.o \
+ kgsl_iommu.o \
kgsl_snapshot.o
msm_kgsl_core-$(CONFIG_DEBUG_FS) += kgsl_debugfs.o
View
16 drivers/gpu/msm/adreno_ringbuffer.c
@@ -750,8 +750,20 @@ int adreno_ringbuffer_extract(struct adreno_ringbuffer *rb,
kgsl_sharedmem_readl(&rb->buffer_desc, &value, rb_rptr);
rb_rptr = adreno_ringbuffer_inc_wrapped(rb_rptr,
rb->buffer_desc.size);
- BUG_ON((copy_rb_contents == 0) &&
- (value == cur_context));
+
+ /*
+ * If other context switches were already lost and
+ * and the current context is the one that is hanging,
+ * then we cannot recover. Print an error message
+ * and leave.
+ */
+
+ if ((copy_rb_contents == 0) && (value == cur_context)) {
+ KGSL_DRV_ERR(device, "GPU recovery could not "
+ "find the previous context\n");
+ return -EINVAL;
+ }
+
/*
* If we were copying the commands and got to this point
* then we need to remove the 3 commands that appear
View
3 drivers/gpu/msm/kgsl.h
@@ -123,8 +123,7 @@ struct kgsl_memdesc {
#define KGSL_MEM_ENTRY_PMEM 1
#define KGSL_MEM_ENTRY_ASHMEM 2
#define KGSL_MEM_ENTRY_USER 3
-#define KGSL_MEM_ENTRY_ION 4
-#define KGSL_MEM_ENTRY_MAX 5
+#define KGSL_MEM_ENTRY_MAX 4
struct kgsl_mem_entry {
struct kref refcount;
View
23 drivers/gpu/msm/kgsl_mmu.c
@@ -16,6 +16,7 @@
#include <linux/genalloc.h>
#include <linux/slab.h>
#include <linux/sched.h>
+#include <linux/iommu.h>
#include "kgsl.h"
#include "kgsl_mmu.h"
@@ -314,7 +315,14 @@ int kgsl_mmu_init(struct kgsl_device *device)
mmu->device = device;
- mmu->mmu_ops = &gpummu_ops;
+ if (KGSL_MMU_TYPE_NONE == kgsl_mmu_type) {
+ dev_info(device->dev, "|%s| MMU type set for device is "
+ "NOMMU\n", __func__);
+ return 0;
+ } else if (KGSL_MMU_TYPE_GPU == kgsl_mmu_type)
+ mmu->mmu_ops = &gpummu_ops;
+ else if (KGSL_MMU_TYPE_IOMMU == kgsl_mmu_type)
+ mmu->mmu_ops = &iommu_ops;
return mmu->mmu_ops->mmu_init(device);
}
@@ -410,7 +418,10 @@ static struct kgsl_pagetable *kgsl_mmu_createpagetableobject(
goto err_pool;
}
- pagetable->pt_ops = &gpummu_pt_ops;
+ if (KGSL_MMU_TYPE_GPU == kgsl_mmu_type)
+ pagetable->pt_ops = &gpummu_pt_ops;
+ else if (KGSL_MMU_TYPE_IOMMU == kgsl_mmu_type)
+ pagetable->pt_ops = &iommu_pt_ops;
pagetable->priv = pagetable->pt_ops->mmu_create_pagetable();
if (!pagetable->priv)
@@ -701,6 +712,12 @@ EXPORT_SYMBOL(kgsl_mmu_get_mmutype);
void kgsl_mmu_set_mmutype(char *mmutype)
{
- kgsl_mmu_type = KGSL_MMU_TYPE_GPU;
+ kgsl_mmu_type = iommu_found() ? KGSL_MMU_TYPE_IOMMU : KGSL_MMU_TYPE_GPU;
+ if (mmutype && !strncmp(mmutype, "gpummu", 6))
+ kgsl_mmu_type = KGSL_MMU_TYPE_GPU;
+ if (iommu_found() && mmutype && !strncmp(mmutype, "iommu", 5))
+ kgsl_mmu_type = KGSL_MMU_TYPE_IOMMU;
+ if (mmutype && !strncmp(mmutype, "nommu", 5))
+ kgsl_mmu_type = KGSL_MMU_TYPE_NONE;
}
EXPORT_SYMBOL(kgsl_mmu_set_mmutype);
View
9 drivers/gpu/msm/kgsl_sharedmem.c
@@ -13,6 +13,8 @@
#include <linux/vmalloc.h>
#include <linux/memory_alloc.h>
#include <asm/cacheflush.h>
+#include <linux/slab.h>
+#include <linux/kmemleak.h>
#include "kgsl.h"
#include "kgsl_sharedmem.h"
@@ -149,9 +151,6 @@ static struct mem_entry_stats mem_stats[] = {
MEM_ENTRY_STAT(KGSL_MEM_ENTRY_ASHMEM, ashmem),
#endif
MEM_ENTRY_STAT(KGSL_MEM_ENTRY_USER, user),
-#ifdef CONFIG_ION
- MEM_ENTRY_STAT(KGSL_MEM_ENTRY_USER, ion),
-#endif
};
void
@@ -427,6 +426,8 @@ _kgsl_sharedmem_vmalloc(struct kgsl_memdesc *memdesc,
goto done;
}
+ kmemleak_not_leak(memdesc->sg);
+
memdesc->sglen = sglen;
sg_init_table(memdesc->sg, sglen);
@@ -499,6 +500,8 @@ kgsl_sharedmem_vmalloc_user(struct kgsl_memdesc *memdesc,
return -ENOMEM;
}
+ kmemleak_not_leak(ptr);
+
protflags = GSL_PT_PAGE_RV;
if (!(flags & KGSL_MEMFLAGS_GPUREADONLY))
protflags |= GSL_PT_PAGE_WV;
View
4 drivers/gpu/msm/kgsl_sharedmem.h
@@ -17,6 +17,8 @@
#include <linux/dma-mapping.h>
#include <linux/vmalloc.h>
#include "kgsl_mmu.h"
+#include <linux/slab.h>
+#include <linux/kmemleak.h>
struct kgsl_device;
struct kgsl_process_private;
@@ -86,6 +88,8 @@ memdesc_sg_phys(struct kgsl_memdesc *memdesc,
if (memdesc->sg == NULL)
return -ENOMEM;
+ kmemleak_not_leak(memdesc->sg);
+
memdesc->sglen = 1;
sg_init_table(memdesc->sg, 1);
sg_set_page(&memdesc->sg[0], page, size, 0);
View
2 drivers/misc/pmem_qcom.c
@@ -50,7 +50,7 @@
#ifdef CONFIG_ANDROID_PMEM_DEBUG
#define PMEM_DEBUG 1
#else
-#define PMEM_DEBUG 1
+#define PMEM_DEBUG 0
#endif
#define SYSTEM_ALLOC_RETRY 10
View
2 include/linux/if_pppolac.h
@@ -21,8 +21,6 @@
#include <linux/socket.h>
#include <linux/types.h>
-#define PX_PROTO_OLAC 2
-
struct sockaddr_pppolac {
sa_family_t sa_family; /* AF_PPPOX */
unsigned int sa_protocol; /* PX_PROTO_OLAC */
View
2 include/linux/if_pppopns.h
@@ -21,8 +21,6 @@
#include <linux/socket.h>
#include <linux/types.h>
-#define PX_PROTO_OPNS 3
-
struct sockaddr_pppopns {
sa_family_t sa_family; /* AF_PPPOX */
unsigned int sa_protocol; /* PX_PROTO_OPNS */
View
7 include/linux/if_pppox.h
@@ -53,9 +53,10 @@ struct pppoe_addr{
*/
#define PX_PROTO_OE 0 /* Currently just PPPoE */
#define PX_PROTO_OL2TP 1 /* Now L2TP also */
-#define PX_PROTO_OLAC 2
-#define PX_PROTO_OPNS 3
-#define PX_MAX_PROTO 4
+#define PX_PROTO_PPTP 2
+#define PX_PROTO_OLAC 3
+#define PX_PROTO_OPNS 4
+#define PX_MAX_PROTO 5
struct sockaddr_pppox {
sa_family_t sa_family; /* address family, AF_PPPOX */
View
38 include/linux/iommu.h
@@ -19,6 +19,10 @@
#ifndef __LINUX_IOMMU_H
#define __LINUX_IOMMU_H
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/scatterlist.h>
+
#define IOMMU_READ (1)
#define IOMMU_WRITE (2)
#define IOMMU_CACHE (4) /* DMA cache coherency */
@@ -30,9 +34,10 @@ struct iommu_domain {
};
#define IOMMU_CAP_CACHE_COHERENCY 0x1
+#define IOMMU_CAP_INTR_REMAP 0x2 /* isolates device intrs */
struct iommu_ops {
- int (*domain_init)(struct iommu_domain *domain);
+ int (*domain_init)(struct iommu_domain *domain, int flags);
void (*domain_destroy)(struct iommu_domain *domain);
int (*attach_dev)(struct iommu_domain *domain, struct device *dev);
void (*detach_dev)(struct iommu_domain *domain, struct device *dev);
@@ -40,17 +45,22 @@ struct iommu_ops {
phys_addr_t paddr, int gfp_order, int prot);
int (*unmap)(struct iommu_domain *domain, unsigned long iova,
int gfp_order);
+ int (*map_range)(struct iommu_domain *domain, unsigned int iova,
+ struct scatterlist *sg, unsigned int len, int prot);
+ int (*unmap_range)(struct iommu_domain *domain, unsigned int iova,
+ unsigned int len);
phys_addr_t (*iova_to_phys)(struct iommu_domain *domain,
unsigned long iova);
int (*domain_has_cap)(struct iommu_domain *domain,
unsigned long cap);
+ phys_addr_t (*get_pt_base_addr)(struct iommu_domain *domain);
};
#ifdef CONFIG_IOMMU_API
extern void register_iommu(struct iommu_ops *ops);
extern bool iommu_found(void);
-extern struct iommu_domain *iommu_domain_alloc(void);
+extern struct iommu_domain *iommu_domain_alloc(int flags);
extern void iommu_domain_free(struct iommu_domain *domain);
extern int iommu_attach_device(struct iommu_domain *domain,
struct device *dev);
@@ -60,10 +70,15 @@ extern int iommu_map(struct iommu_domain *domain, unsigned long iova,
phys_addr_t paddr, int gfp_order, int prot);
extern int iommu_unmap(struct iommu_domain *domain, unsigned long iova,
int gfp_order);
+extern int iommu_map_range(struct iommu_domain *domain, unsigned int iova,
+ struct scatterlist *sg, unsigned int len, int prot);
+extern int iommu_unmap_range(struct iommu_domain *domain, unsigned int iova,
+ unsigned int len);
extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain,
unsigned long iova);
extern int iommu_domain_has_cap(struct iommu_domain *domain,
unsigned long cap);
+extern phys_addr_t iommu_get_pt_base_addr(struct iommu_domain *domain);
#else /* CONFIG_IOMMU_API */
@@ -76,7 +91,7 @@ static inline bool iommu_found(void)
return false;
}
-static inline struct iommu_domain *iommu_domain_alloc(void)
+static inline struct iommu_domain *iommu_domain_alloc(int flags)
{
return NULL;
}
@@ -108,6 +123,19 @@ static inline int iommu_unmap(struct iommu_domain *domain, unsigned long iova,
return -ENODEV;
}
+static inline int iommu_map_range(struct iommu_domain *domain,
+ unsigned int iova, struct scatterlist *sg,
+ unsigned int len, int prot)
+{
+ return -ENODEV;
+}
+
+static inline int iommu_unmap_range(struct iommu_domain *domain,
+ unsigned int iova, unsigned int len)
+{
+ return -ENODEV;
+}
+
static inline phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain,
unsigned long iova)
{
@@ -120,6 +148,10 @@ static inline int domain_has_cap(struct iommu_domain *domain,
return 0;
}
+static inline phys_addr_t iommu_get_pt_base_addr(struct iommu_domain *domain)
+{
+ return 0;
+}
#endif /* CONFIG_IOMMU_API */
#endif /* __LINUX_IOMMU_H */
View
3 include/linux/msm_kgsl.h
@@ -51,8 +51,7 @@ enum kgsl_user_mem_type {
KGSL_USER_MEM_TYPE_PMEM = 0x00000000,
KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001,
KGSL_USER_MEM_TYPE_ADDR = 0x00000002,
- KGSL_USER_MEM_TYPE_ION = 0x00000003,
- KGSL_USER_MEM_TYPE_MAX = 0x00000004,
+ KGSL_USER_MEM_TYPE_MAX = 0x00000003,
};
struct kgsl_devinfo {

No commit comments for this range

Something went wrong with that request. Please try again.