summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/msm/adreno.h4
-rw-r--r--drivers/gpu/msm/adreno_a3xx.c27
-rw-r--r--drivers/gpu/msm/adreno_a4xx.c5
-rw-r--r--drivers/gpu/msm/adreno_a5xx.c30
-rw-r--r--drivers/gpu/msm/adreno_iommu.c40
-rw-r--r--drivers/gpu/msm/adreno_perfcounter.c9
-rw-r--r--drivers/gpu/msm/adreno_ringbuffer.c115
-rw-r--r--drivers/gpu/msm/adreno_ringbuffer.h22
-rw-r--r--drivers/gpu/msm/adreno_snapshot.c12
9 files changed, 138 insertions, 126 deletions
diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h
index 65ec1939ad90..12220ba82bec 100644
--- a/drivers/gpu/msm/adreno.h
+++ b/drivers/gpu/msm/adreno.h
@@ -1314,7 +1314,7 @@ static inline unsigned int adreno_preempt_state(
static inline unsigned int
adreno_get_rptr(struct adreno_ringbuffer *rb)
{
- struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
if (adreno_dev->cur_rb == rb &&
adreno_preempt_state(adreno_dev,
ADRENO_DISPATCHER_PREEMPT_CLEAR))
@@ -1378,7 +1378,7 @@ static inline void adreno_set_active_ctxs_null(struct adreno_device *adreno_dev)
if (rb->drawctxt_active)
kgsl_context_put(&(rb->drawctxt_active->base));
rb->drawctxt_active = NULL;
- kgsl_sharedmem_writel(rb->device, &rb->pagetable_desc,
+ kgsl_sharedmem_writel(&adreno_dev->dev, &rb->pagetable_desc,
offsetof(struct adreno_ringbuffer_pagetable_info,
current_rb_ptname), 0);
}
diff --git a/drivers/gpu/msm/adreno_a3xx.c b/drivers/gpu/msm/adreno_a3xx.c
index 6b5e88492900..6310250e1292 100644
--- a/drivers/gpu/msm/adreno_a3xx.c
+++ b/drivers/gpu/msm/adreno_a3xx.c
@@ -1599,7 +1599,8 @@ static inline int adreno_ringbuffer_load_pfp_ucode(struct kgsl_device *device,
/**
* _ringbuffer_bootstrap_ucode() - Bootstrap GPU Ucode
- * @rb: Pointer to adreno ringbuffer
+ * @adreno_dev: Pointer to an adreno device
+ * @rb: The ringbuffer to boostrap the code into
* @load_jt: If non zero only load Jump tables
*
* Bootstrap ucode for GPU
@@ -1615,14 +1616,13 @@ static inline int adreno_ringbuffer_load_pfp_ucode(struct kgsl_device *device,
* PFP dwords from microcode to bootstrap
* PM4 size dwords from microcode to bootstrap
*/
-static int _ringbuffer_bootstrap_ucode(struct adreno_ringbuffer *rb,
- unsigned int load_jt)
+static int _ringbuffer_bootstrap_ucode(struct adreno_device *adreno_dev,
+ struct adreno_ringbuffer *rb, unsigned int load_jt)
{
+ struct kgsl_device *device = &adreno_dev->dev;
unsigned int *cmds, bootstrap_size, rb_size;
int i = 0;
int ret;
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
unsigned int pm4_size, pm4_idx, pm4_addr, pfp_size, pfp_idx, pfp_addr;
/* Only bootstrap jump tables of ucode */
@@ -1726,8 +1726,7 @@ static int _ringbuffer_bootstrap_ucode(struct adreno_ringbuffer *rb,
ret = adreno_spin_idle(device, 2000);
if (ret) {
- KGSL_DRV_ERR(rb->device,
- "microcode bootstrap failed to idle\n");
+ KGSL_DRV_ERR(device, "microcode bootstrap failed to idle\n");
kgsl_device_snapshot(device, NULL);
}
@@ -1744,7 +1743,7 @@ int a3xx_microcode_load(struct adreno_device *adreno_dev,
{
int status;
struct adreno_ringbuffer *rb = ADRENO_CURRENT_RINGBUFFER(adreno_dev);
- struct kgsl_device *device = rb->device;
+ struct kgsl_device *device = &adreno_dev->dev;
if (start_type == ADRENO_START_COLD) {
/* If bootstrapping if supported to load ucode */
@@ -1760,30 +1759,30 @@ int a3xx_microcode_load(struct adreno_device *adreno_dev,
* microcode.
*/
- status = adreno_ringbuffer_load_pm4_ucode(rb->device, 1,
+ status = adreno_ringbuffer_load_pm4_ucode(device, 1,
adreno_dev->gpucore->pm4_bstrp_size+1, 0);
if (status != 0)
return status;
- status = adreno_ringbuffer_load_pfp_ucode(rb->device, 1,
+ status = adreno_ringbuffer_load_pfp_ucode(device, 1,
adreno_dev->gpucore->pfp_bstrp_size+1, 0);
if (status != 0)
return status;
/* Bootstrap rest of the ucode here */
- status = _ringbuffer_bootstrap_ucode(rb, 0);
+ status = _ringbuffer_bootstrap_ucode(adreno_dev, rb, 0);
if (status != 0)
return status;
} else {
/* load the CP ucode using AHB writes */
- status = adreno_ringbuffer_load_pm4_ucode(rb->device, 1,
+ status = adreno_ringbuffer_load_pm4_ucode(device, 1,
adreno_dev->pm4_fw_size, 0);
if (status != 0)
return status;
/* load the prefetch parser ucode using AHB writes */
- status = adreno_ringbuffer_load_pfp_ucode(rb->device, 1,
+ status = adreno_ringbuffer_load_pfp_ucode(device, 1,
adreno_dev->pfp_fw_size, 0);
if (status != 0)
return status;
@@ -1791,7 +1790,7 @@ int a3xx_microcode_load(struct adreno_device *adreno_dev,
} else if (start_type == ADRENO_START_WARM) {
/* If bootstrapping if supported to load jump tables */
if (adreno_bootstrap_ucode(adreno_dev)) {
- status = _ringbuffer_bootstrap_ucode(rb, 1);
+ status = _ringbuffer_bootstrap_ucode(adreno_dev, rb, 1);
if (status != 0)
return status;
diff --git a/drivers/gpu/msm/adreno_a4xx.c b/drivers/gpu/msm/adreno_a4xx.c
index 99a331d7a470..9438be891377 100644
--- a/drivers/gpu/msm/adreno_a4xx.c
+++ b/drivers/gpu/msm/adreno_a4xx.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2016, The Linux Foundation. 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
@@ -250,11 +250,12 @@ static int a4xx_preemption_pre_ibsubmit(
struct kgsl_context *context, uint64_t cond_addr,
struct kgsl_memobj_node *ib)
{
+ struct kgsl_device *device = &adreno_dev->dev;
unsigned int *cmds_orig = cmds;
int exec_ib = 0;
cmds += a4xx_preemption_token(adreno_dev, rb, cmds,
- rb->device->memstore.gpuaddr +
+ device->memstore.gpuaddr +
KGSL_MEMSTORE_OFFSET(context->id, preempted));
if (ib)
diff --git a/drivers/gpu/msm/adreno_a5xx.c b/drivers/gpu/msm/adreno_a5xx.c
index 064cb38934db..1ba35d497958 100644
--- a/drivers/gpu/msm/adreno_a5xx.c
+++ b/drivers/gpu/msm/adreno_a5xx.c
@@ -220,29 +220,29 @@ static int a5xx_preemption_init(struct adreno_device *adreno_dev)
/* Allocate mem for storing preemption switch record */
FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
- ret = kgsl_allocate_global(&adreno_dev->dev,
+ ret = kgsl_allocate_global(device,
&rb->preemption_desc, A5XX_CP_CTXRECORD_SIZE_IN_BYTES,
0, KGSL_MEMDESC_PRIVILEGED);
if (ret)
return ret;
/* Initialize the context switch record here */
- kgsl_sharedmem_writel(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writel(device, &rb->preemption_desc,
PREEMPT_RECORD(magic), A5XX_CP_CTXRECORD_MAGIC_REF);
- kgsl_sharedmem_writel(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writel(device, &rb->preemption_desc,
PREEMPT_RECORD(info), 0);
- kgsl_sharedmem_writel(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writel(device, &rb->preemption_desc,
PREEMPT_RECORD(data), 0);
- kgsl_sharedmem_writel(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writel(device, &rb->preemption_desc,
PREEMPT_RECORD(cntl), 0x0800000C);
- kgsl_sharedmem_writel(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writel(device, &rb->preemption_desc,
PREEMPT_RECORD(rptr), 0);
- kgsl_sharedmem_writel(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writel(device, &rb->preemption_desc,
PREEMPT_RECORD(wptr), 0);
- kgsl_sharedmem_writeq(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writeq(device, &rb->preemption_desc,
PREEMPT_RECORD(rbase),
adreno_dev->ringbuffers[i].buffer_desc.gpuaddr);
- kgsl_sharedmem_writeq(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writeq(device, &rb->preemption_desc,
PREEMPT_RECORD(counter), addr);
addr += A5XX_CP_CTXRECORD_PREEMPTION_COUNTER_SIZE;
@@ -355,6 +355,7 @@ static int a5xx_preemption_post_ibsubmit(
struct adreno_ringbuffer *rb, unsigned int *cmds,
struct kgsl_context *context)
{
+ struct kgsl_device *device = &adreno_dev->dev;
unsigned int *cmds_orig = cmds;
unsigned int ctx_id = context ? context->id : 0;
@@ -373,7 +374,7 @@ static int a5xx_preemption_post_ibsubmit(
*cmds++ = 0;
cmds += a5xx_preemption_token(adreno_dev, rb, cmds,
- rb->device->memstore.gpuaddr +
+ device->memstore.gpuaddr +
KGSL_MEMSTORE_OFFSET(ctx_id, preempted));
return cmds - cmds_orig;
@@ -2052,11 +2053,11 @@ static void a5xx_start(struct adreno_device *adreno_dev)
iommu->smmu_info.gpuaddr);
FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
- kgsl_sharedmem_writel(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writel(device, &rb->preemption_desc,
PREEMPT_RECORD(rptr), 0);
- kgsl_sharedmem_writel(rb->device, &rb->preemption_desc,
+ kgsl_sharedmem_writel(device, &rb->preemption_desc,
PREEMPT_RECORD(wptr), 0);
- kgsl_sharedmem_writeq(rb->device, &rb->pagetable_desc,
+ kgsl_sharedmem_writeq(device, &rb->pagetable_desc,
offsetof(struct adreno_ringbuffer_pagetable_info,
ttbr0), def_ttbr0);
}
@@ -2070,9 +2071,10 @@ static int _preemption_init(
struct adreno_ringbuffer *rb, unsigned int *cmds,
struct kgsl_context *context)
{
+ struct kgsl_device *device = &adreno_dev->dev;
unsigned int *cmds_orig = cmds;
uint64_t gpuaddr = rb->preemption_desc.gpuaddr;
- uint64_t gpuaddr_token = rb->device->memstore.gpuaddr +
+ uint64_t gpuaddr_token = device->memstore.gpuaddr +
KGSL_MEMSTORE_OFFSET(0, preempted);
/* Turn CP protection OFF */
diff --git a/drivers/gpu/msm/adreno_iommu.c b/drivers/gpu/msm/adreno_iommu.c
index 02935f6ff1ec..00eebc312f4d 100644
--- a/drivers/gpu/msm/adreno_iommu.c
+++ b/drivers/gpu/msm/adreno_iommu.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002,2007-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2002,2007-2016, The Linux Foundation. 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
@@ -346,8 +346,7 @@ static unsigned int _adreno_mmu_set_pt_update_condition(
struct adreno_ringbuffer *rb,
unsigned int *cmds, unsigned int ptname)
{
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
unsigned int *cmds_orig = cmds;
/*
* write 1 to switch pt flag indicating that we need to execute the
@@ -397,8 +396,7 @@ static unsigned int _adreno_iommu_pt_update_pid_to_mem(
struct adreno_ringbuffer *rb,
unsigned int *cmds, int ptname)
{
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
unsigned int *cmds_orig = cmds;
*cmds++ = cp_mem_packet(adreno_dev, CP_MEM_WRITE, 2, 1);
@@ -431,8 +429,7 @@ static unsigned int _adreno_iommu_set_pt_v1(struct adreno_ringbuffer *rb,
unsigned int *cmds_orig,
u64 ttbr0, u32 contextidr, u32 ptname)
{
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
unsigned int *cmds = cmds_orig;
unsigned int *cond_exec_ptr;
@@ -587,12 +584,12 @@ unsigned int adreno_iommu_set_pt_generate_cmds(
unsigned int *cmds,
struct kgsl_pagetable *pt)
{
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+ struct kgsl_device *device = &adreno_dev->dev;
u64 ttbr0;
u32 contextidr;
unsigned int *cmds_orig = cmds;
- struct kgsl_iommu *iommu = adreno_dev->dev.mmu.priv;
+ struct kgsl_iommu *iommu = device->mmu.priv;
ttbr0 = kgsl_mmu_pagetable_get_ttbr0(pt);
contextidr = kgsl_mmu_pagetable_get_contextidr(pt);
@@ -638,8 +635,7 @@ unsigned int adreno_iommu_set_pt_ib(struct adreno_ringbuffer *rb,
unsigned int *cmds,
struct kgsl_pagetable *pt)
{
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
unsigned int *cmds_orig = cmds;
struct kgsl_iommu_pt *iommu_pt = pt->priv;
@@ -680,9 +676,9 @@ static unsigned int __add_curr_ctxt_cmds(struct adreno_ringbuffer *rb,
unsigned int *cmds,
struct adreno_context *drawctxt)
{
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+ struct kgsl_device *device = &adreno_dev->dev;
unsigned int *cmds_orig = cmds;
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
/* write the context identifier to memstore memory */
*cmds++ = cp_packet(adreno_dev, CP_NOP, 1);
@@ -731,8 +727,8 @@ static unsigned int __add_curr_ctxt_cmds(struct adreno_ringbuffer *rb,
static void _set_ctxt_cpu(struct adreno_ringbuffer *rb,
struct adreno_context *drawctxt)
{
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+ struct kgsl_device *device = &adreno_dev->dev;
if (rb == adreno_dev->cur_rb) {
_invalidate_uche_cpu(adreno_dev);
@@ -774,8 +770,8 @@ static int _set_ctxt_gpu(struct adreno_ringbuffer *rb,
static int _set_pagetable_cpu(struct adreno_ringbuffer *rb,
struct kgsl_pagetable *new_pt)
{
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+ struct kgsl_device *device = &adreno_dev->dev;
int result;
/* update TTBR0 only if we are updating current RB */
@@ -817,9 +813,9 @@ static int _set_pagetable_cpu(struct adreno_ringbuffer *rb,
static int _set_pagetable_gpu(struct adreno_ringbuffer *rb,
struct kgsl_pagetable *new_pt)
{
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+ struct kgsl_device *device = &adreno_dev->dev;
unsigned int *link = NULL, *cmds;
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
int result;
link = kmalloc(PAGE_SIZE, GFP_KERNEL);
@@ -924,8 +920,8 @@ int adreno_iommu_set_pt_ctx(struct adreno_ringbuffer *rb,
struct kgsl_pagetable *new_pt,
struct adreno_context *drawctxt)
{
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+ struct kgsl_device *device = &adreno_dev->dev;
struct kgsl_pagetable *cur_pt = device->mmu.defaultpagetable;
int result = 0;
int cpu_path = 0;
diff --git a/drivers/gpu/msm/adreno_perfcounter.c b/drivers/gpu/msm/adreno_perfcounter.c
index 123708e84f98..2c25b2447a09 100644
--- a/drivers/gpu/msm/adreno_perfcounter.c
+++ b/drivers/gpu/msm/adreno_perfcounter.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002,2007-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2002,2007-2016, The Linux Foundation. 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
@@ -709,6 +709,7 @@ static int _perfcounter_enable_default(struct adreno_device *adreno_dev,
struct adreno_perfcounters *counters, unsigned int group,
unsigned int counter, unsigned int countable)
{
+ struct kgsl_device *device = &adreno_dev->dev;
struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
struct adreno_perfcount_register *reg;
int i;
@@ -746,17 +747,17 @@ static int _perfcounter_enable_default(struct adreno_device *adreno_dev,
* rb[0] will not get scheduled to run
*/
if (adreno_dev->cur_rb != rb)
- adreno_dispatcher_schedule(rb->device);
+ adreno_dispatcher_schedule(device);
/* wait for the above commands submitted to complete */
ret = adreno_ringbuffer_waittimestamp(rb, rb->timestamp,
ADRENO_IDLE_TIMEOUT);
if (ret)
- KGSL_DRV_ERR(rb->device,
+ KGSL_DRV_ERR(device,
"Perfcounter %u/%u/%u start via commands failed %d\n",
group, counter, countable, ret);
} else {
/* Select the desired perfcounter */
- kgsl_regwrite(&adreno_dev->dev, reg->select, countable);
+ kgsl_regwrite(device, reg->select, countable);
}
if (!ret)
diff --git a/drivers/gpu/msm/adreno_ringbuffer.c b/drivers/gpu/msm/adreno_ringbuffer.c
index b7830c2268fd..d038762222c2 100644
--- a/drivers/gpu/msm/adreno_ringbuffer.c
+++ b/drivers/gpu/msm/adreno_ringbuffer.c
@@ -43,7 +43,7 @@
static void _cff_write_ringbuffer(struct adreno_ringbuffer *rb)
{
- struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
struct kgsl_device *device = &adreno_dev->dev;
uint64_t gpuaddr;
unsigned int *hostptr;
@@ -69,7 +69,7 @@ static void _cff_write_ringbuffer(struct adreno_ringbuffer *rb)
void adreno_ringbuffer_submit(struct adreno_ringbuffer *rb,
struct adreno_submit_time *time)
{
- struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
BUG_ON(rb->wptr == 0);
/* Write the changes to CFF if so enabled */
@@ -129,7 +129,7 @@ void adreno_ringbuffer_submit(struct adreno_ringbuffer *rb,
* Let the pwrscale policy know that new commands have
* been submitted.
*/
- kgsl_pwrscale_busy(rb->device);
+ kgsl_pwrscale_busy(&adreno_dev->dev);
adreno_writereg(adreno_dev, ADRENO_REG_CP_RB_WPTR, rb->wptr);
}
}
@@ -137,8 +137,10 @@ void adreno_ringbuffer_submit(struct adreno_ringbuffer *rb,
int adreno_ringbuffer_submit_spin(struct adreno_ringbuffer *rb,
struct adreno_submit_time *time, unsigned int timeout)
{
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+
adreno_ringbuffer_submit(rb, NULL);
- return adreno_spin_idle(rb->device, timeout);
+ return adreno_spin_idle(&adreno_dev->dev, timeout);
}
static int
@@ -153,7 +155,7 @@ adreno_ringbuffer_waitspace(struct adreno_ringbuffer *rb,
unsigned long wait_time;
unsigned long wait_timeout = msecs_to_jiffies(ADRENO_IDLE_TIMEOUT);
unsigned int rptr;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
/* if wptr ahead, fill the remaining with NOPs */
if (wptr_ahead) {
@@ -209,7 +211,7 @@ adreno_ringbuffer_waitspace(struct adreno_ringbuffer *rb,
break;
if (time_after(jiffies, wait_time)) {
- KGSL_DRV_ERR(rb->device,
+ KGSL_DRV_ERR((&adreno_dev->dev),
"Timed out waiting for freespace in RB rptr: 0x%x, wptr: 0x%x, rb id %d\n",
rptr, wptr, rb->id);
return -ETIMEDOUT;
@@ -218,7 +220,7 @@ adreno_ringbuffer_waitspace(struct adreno_ringbuffer *rb,
done:
if (wptr_ahead) {
*cmds = cp_packet(adreno_dev, CP_NOP, nopcount);
- kgsl_cffdump_write(rb->device, gpuaddr, *cmds);
+ kgsl_cffdump_write(&adreno_dev->dev, gpuaddr, *cmds);
}
return 0;
@@ -264,30 +266,32 @@ unsigned int *adreno_ringbuffer_allocspace(struct adreno_ringbuffer *rb,
/**
* _ringbuffer_setup_common() - Ringbuffer start
- * @rb: Pointer to adreno ringbuffer
+ * @adreno_dev: Pointer to an adreno_device
*
* Setup ringbuffer for GPU.
*/
-static void _ringbuffer_setup_common(struct adreno_ringbuffer *rb)
+static void _ringbuffer_setup_common(struct adreno_device *adreno_dev)
{
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
- struct adreno_ringbuffer *rb_temp;
+ struct kgsl_device *device = &adreno_dev->dev;
+ struct adreno_ringbuffer *rb;
int i;
- FOR_EACH_RINGBUFFER(adreno_dev, rb_temp, i) {
- kgsl_sharedmem_set(rb_temp->device,
- &(rb_temp->buffer_desc), 0,
+ /* Initialize all of the ringbuffers */
+ FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
+ kgsl_sharedmem_set(device, &(rb->buffer_desc), 0,
0xAA, KGSL_RB_SIZE);
- rb_temp->wptr = 0;
- rb_temp->rptr = 0;
- rb_temp->wptr_preempt_end = 0xFFFFFFFF;
- rb_temp->starve_timer_state =
+ rb->wptr = 0;
+ rb->rptr = 0;
+ rb->wptr_preempt_end = 0xFFFFFFFF;
+ rb->starve_timer_state =
ADRENO_DISPATCHER_RB_STARVE_TIMER_UNINIT;
- adreno_iommu_set_pt_generate_rb_cmds(rb_temp,
+ adreno_iommu_set_pt_generate_rb_cmds(rb,
device->mmu.defaultpagetable);
}
+ /* Continue setting up the current ringbuffer */
+ rb = ADRENO_CURRENT_RINGBUFFER(adreno_dev);
+
/*
* The size of the ringbuffer in the hardware is the log2
* representation of the size in quadwords (sizedwords / 2).
@@ -316,16 +320,15 @@ static void _ringbuffer_setup_common(struct adreno_ringbuffer *rb)
/**
* _ringbuffer_start_common() - Ringbuffer start
- * @rb: Pointer to adreno ringbuffer
+ * @adreno_dev: Pointer to an adreno device
*
* Start ringbuffer for GPU.
*/
-static int _ringbuffer_start_common(struct adreno_ringbuffer *rb)
+static int _ringbuffer_start_common(struct adreno_device *adreno_dev)
{
int status;
- struct kgsl_device *device = rb->device;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
+ struct adreno_ringbuffer *rb = ADRENO_CURRENT_RINGBUFFER(adreno_dev);
/* clear ME_HALT to start micro engine */
adreno_writereg(adreno_dev, ADRENO_REG_CP_ME_CNTL, 0);
@@ -347,16 +350,15 @@ int adreno_ringbuffer_start(struct adreno_device *adreno_dev,
unsigned int start_type)
{
int status;
- struct adreno_ringbuffer *rb = ADRENO_CURRENT_RINGBUFFER(adreno_dev);
struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
- _ringbuffer_setup_common(rb);
+ _ringbuffer_setup_common(adreno_dev);
status = gpudev->microcode_load(adreno_dev, start_type);
if (status)
return status;
- return _ringbuffer_start_common(rb);
+ return _ringbuffer_start_common(adreno_dev);
}
void adreno_ringbuffer_stop(struct adreno_device *adreno_dev)
@@ -369,12 +371,13 @@ void adreno_ringbuffer_stop(struct adreno_device *adreno_dev)
}
static int _adreno_ringbuffer_init(struct adreno_device *adreno_dev,
- struct adreno_ringbuffer *rb, int id)
+ int id)
{
+ struct kgsl_device *device = &adreno_dev->dev;
+ struct adreno_ringbuffer *rb = &adreno_dev->ringbuffers[id];
int ret;
char name[64];
- rb->device = &adreno_dev->dev;
rb->id = id;
snprintf(name, sizeof(name), "rb_events-%d", id);
@@ -387,21 +390,19 @@ static int _adreno_ringbuffer_init(struct adreno_device *adreno_dev,
* Allocate mem for storing RB pagetables and commands to
* switch pagetable
*/
- ret = kgsl_allocate_global(&adreno_dev->dev, &rb->pagetable_desc,
+ ret = kgsl_allocate_global(device, &rb->pagetable_desc,
PAGE_SIZE, 0, KGSL_MEMDESC_PRIVILEGED);
if (ret)
return ret;
- ret = kgsl_allocate_global(&adreno_dev->dev, &rb->buffer_desc,
+ return kgsl_allocate_global(device, &rb->buffer_desc,
KGSL_RB_SIZE, KGSL_MEMFLAGS_GPUREADONLY, 0);
- return ret;
}
int adreno_ringbuffer_init(struct adreno_device *adreno_dev, bool nopreempt)
{
int status = 0;
struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
- struct adreno_ringbuffer *rb;
int i;
if (nopreempt == false && ADRENO_FEATURE(adreno_dev, ADRENO_PREEMPTION))
@@ -409,11 +410,12 @@ int adreno_ringbuffer_init(struct adreno_device *adreno_dev, bool nopreempt)
else
adreno_dev->num_ringbuffers = 1;
- FOR_EACH_RINGBUFFER(adreno_dev, rb, i) {
- status = _adreno_ringbuffer_init(adreno_dev, rb, i);
- if (status)
+ for (i = 0; i < adreno_dev->num_ringbuffers; i++) {
+ status = _adreno_ringbuffer_init(adreno_dev, i);
+ if (status != 0)
break;
}
+
if (status)
adreno_ringbuffer_close(adreno_dev);
else
@@ -422,9 +424,10 @@ int adreno_ringbuffer_init(struct adreno_device *adreno_dev, bool nopreempt)
return status;
}
-static void _adreno_ringbuffer_close(struct adreno_ringbuffer *rb)
+static void _adreno_ringbuffer_close(struct adreno_device *adreno_dev,
+ struct adreno_ringbuffer *rb)
{
- struct kgsl_device *device = rb->device;
+ struct kgsl_device *device = &adreno_dev->dev;
kgsl_free_global(device, &rb->pagetable_desc);
kgsl_free_global(device, &rb->preemption_desc);
@@ -442,7 +445,7 @@ void adreno_ringbuffer_close(struct adreno_device *adreno_dev)
int i;
FOR_EACH_RINGBUFFER(adreno_dev, rb, i)
- _adreno_ringbuffer_close(rb);
+ _adreno_ringbuffer_close(adreno_dev, rb);
}
/*
@@ -502,14 +505,14 @@ adreno_ringbuffer_addcmds(struct adreno_ringbuffer *rb,
unsigned int sizedwords, uint32_t timestamp,
struct adreno_submit_time *time)
{
- struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
- struct kgsl_device *device = rb->device;
+ struct kgsl_device *device = &adreno_dev->dev;
unsigned int *ringcmds, *start;
unsigned int total_sizedwords = sizedwords;
unsigned int i;
unsigned int context_id = 0;
- uint64_t gpuaddr = rb->device->memstore.gpuaddr;
+ uint64_t gpuaddr = device->memstore.gpuaddr;
bool profile_ready;
struct adreno_context *drawctxt = rb->drawctxt_active;
struct kgsl_context *context = NULL;
@@ -1226,6 +1229,19 @@ static void adreno_ringbuffer_wait_callback(struct kgsl_device *device,
wake_up_all(&rb->ts_expire_waitq);
}
+/* check if timestamp is greater than the current rb timestamp */
+static inline int adreno_ringbuffer_check_timestamp(
+ struct adreno_ringbuffer *rb,
+ unsigned int timestamp, int type)
+{
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+ unsigned int ts;
+
+ adreno_rb_readtimestamp(&adreno_dev->dev, rb, type, &ts);
+ return (timestamp_cmp(ts, timestamp) >= 0);
+}
+
+
/**
* adreno_ringbuffer_waittimestamp() - Wait for a RB timestamp
* @rb: The ringbuffer to wait on
@@ -1236,7 +1252,8 @@ int adreno_ringbuffer_waittimestamp(struct adreno_ringbuffer *rb,
unsigned int timestamp,
unsigned int msecs)
{
- struct kgsl_device *device = rb->device;
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+ struct kgsl_device *device = &adreno_dev->dev;
int ret;
unsigned long wait_time;
@@ -1282,9 +1299,9 @@ int adreno_ringbuffer_waittimestamp(struct adreno_ringbuffer *rb,
int adreno_ringbuffer_submit_preempt_token(struct adreno_ringbuffer *rb,
struct adreno_ringbuffer *incoming_rb)
{
+ struct adreno_device *adreno_dev = ADRENO_RB_DEVICE(rb);
+ struct kgsl_device *device = &adreno_dev->dev;
unsigned int *ringcmds, *start;
- struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
- struct kgsl_device *device = &(adreno_dev->dev);
struct kgsl_iommu *iommu = device->mmu.priv;
struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
int ptname;
@@ -1300,7 +1317,7 @@ int adreno_ringbuffer_submit_preempt_token(struct adreno_ringbuffer *rb,
kgsl_sharedmem_readq(&rb->pagetable_desc, &ttbr0,
offsetof(struct adreno_ringbuffer_pagetable_info
, ttbr0));
- kgsl_sharedmem_writeq(rb->device, &iommu->smmu_info,
+ kgsl_sharedmem_writeq(device, &iommu->smmu_info,
offsetof(struct a5xx_cp_smmu_info, ttbr0),
ttbr0);
} else {
@@ -1308,7 +1325,7 @@ int adreno_ringbuffer_submit_preempt_token(struct adreno_ringbuffer *rb,
&ptname, offsetof(
struct adreno_ringbuffer_pagetable_info,
current_rb_ptname));
- pt = kgsl_mmu_get_pt_from_ptname(&(rb->device->mmu),
+ pt = kgsl_mmu_get_pt_from_ptname(&(device->mmu),
ptname);
/*
* always expect a valid pt, else pt refcounting is
@@ -1352,7 +1369,7 @@ int adreno_ringbuffer_submit_preempt_token(struct adreno_ringbuffer *rb,
*ringcmds++ = 1;
ringcmds += gpudev->preemption_token(adreno_dev, rb, ringcmds,
- rb->device->memstore.gpuaddr +
+ device->memstore.gpuaddr +
KGSL_MEMSTORE_RB_OFFSET(rb, preempted));
if ((uint)(ringcmds - start) > total_sizedwords) {
@@ -1368,7 +1385,7 @@ int adreno_ringbuffer_submit_preempt_token(struct adreno_ringbuffer *rb,
/* submit just the preempt token */
mb();
- kgsl_pwrscale_busy(rb->device);
+ kgsl_pwrscale_busy(device);
adreno_writereg(adreno_dev, ADRENO_REG_CP_RB_WPTR, rb->wptr);
return 0;
}
diff --git a/drivers/gpu/msm/adreno_ringbuffer.h b/drivers/gpu/msm/adreno_ringbuffer.h
index 7fd28f52db83..3bef6b3e6940 100644
--- a/drivers/gpu/msm/adreno_ringbuffer.h
+++ b/drivers/gpu/msm/adreno_ringbuffer.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2002,2007-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2002,2007-2016, The Linux Foundation. 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
@@ -16,6 +16,14 @@
#include "kgsl_iommu.h"
#include "adreno_dispatch.h"
+/* Given a ringbuffer, return the adreno device that owns it */
+
+#define _RB_OFFSET(_id) (offsetof(struct adreno_device, ringbuffers) + \
+ ((_id) * sizeof(struct adreno_ringbuffer)))
+
+#define ADRENO_RB_DEVICE(_rb) \
+ ((struct adreno_device *) (((void *) (_rb)) - _RB_OFFSET((_rb)->id)))
+
/* Adreno ringbuffer size in bytes */
#define KGSL_RB_SIZE (32 * 1024)
@@ -66,7 +74,6 @@ struct adreno_ringbuffer_pagetable_info {
/**
* struct adreno_ringbuffer - Definition for an adreno ringbuffer object
- * @device: KGSL device that owns the ringbuffer object
* @flags: Internal control flags for the ringbuffer
* @buffer_desc: Pointer to the ringbuffer memory descriptor
* @wptr: Local copy of the wptr offset
@@ -97,7 +104,6 @@ struct adreno_ringbuffer_pagetable_info {
* @starve_timer_state: Indicates the state of the wait.
*/
struct adreno_ringbuffer {
- struct kgsl_device *device;
uint32_t flags;
struct kgsl_memdesc buffer_desc;
unsigned int sizedwords;
@@ -213,14 +219,4 @@ static inline unsigned int adreno_ringbuffer_dec_wrapped(unsigned int val,
return (val + size - sizeof(unsigned int)) % size;
}
-/* check if timestamp is greater than the current rb timestamp */
-static inline int adreno_ringbuffer_check_timestamp(
- struct adreno_ringbuffer *rb,
- unsigned int timestamp, int type)
-{
- unsigned int ts;
- adreno_rb_readtimestamp(rb->device, rb, type, &ts);
- return (timestamp_cmp(ts, timestamp) >= 0);
-}
-
#endif /* __ADRENO_RINGBUFFER_H */
diff --git a/drivers/gpu/msm/adreno_snapshot.c b/drivers/gpu/msm/adreno_snapshot.c
index 85387889b5ce..7c7259879b74 100644
--- a/drivers/gpu/msm/adreno_snapshot.c
+++ b/drivers/gpu/msm/adreno_snapshot.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, The Linux Foundation. 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
@@ -288,15 +288,15 @@ static void dump_all_ibs(struct kgsl_device *device,
/**
* snapshot_rb_ibs() - Dump rb data and capture the IB's in the RB as well
+ * @device: Pointer to a KGSL device
* @rb: The RB to dump
* @data: Pointer to memory where the RB data is to be dumped
* @snapshot: Pointer to information about the current snapshot being taken
*/
-static void snapshot_rb_ibs(struct adreno_ringbuffer *rb,
- unsigned int *data,
- struct kgsl_snapshot *snapshot)
+static void snapshot_rb_ibs(struct kgsl_device *device,
+ struct adreno_ringbuffer *rb, unsigned int *data,
+ struct kgsl_snapshot *snapshot)
{
- struct kgsl_device *device = rb->device;
struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
unsigned int rptr, *rbptr;
uint64_t ibbase;
@@ -477,7 +477,7 @@ static size_t snapshot_rb(struct kgsl_device *device, u8 *buf,
header->id = rb->id;
if (rb == adreno_dev->cur_rb) {
- snapshot_rb_ibs(rb, data, snapshot);
+ snapshot_rb_ibs(device, rb, data, snapshot);
} else {
/* Just copy the ringbuffer, there are no active IBs */
memcpy(data, rb->buffer_desc.hostptr, KGSL_RB_SIZE);