Lucille Sylvester | 51b764d | 2011-12-15 16:51:52 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2002,2007-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 13 | #include <linux/uaccess.h> |
| 14 | #include <linux/vmalloc.h> |
| 15 | #include <linux/ioctl.h> |
| 16 | #include <linux/sched.h> |
| 17 | |
| 18 | #include <mach/socinfo.h> |
| 19 | |
| 20 | #include "kgsl.h" |
| 21 | #include "kgsl_pwrscale.h" |
| 22 | #include "kgsl_cffdump.h" |
| 23 | #include "kgsl_sharedmem.h" |
| 24 | |
| 25 | #include "adreno.h" |
| 26 | #include "adreno_pm4types.h" |
| 27 | #include "adreno_debugfs.h" |
| 28 | #include "adreno_postmortem.h" |
| 29 | |
Jeremy Gebben | eebc461 | 2011-08-31 10:15:21 -0700 | [diff] [blame] | 30 | #include "a2xx_reg.h" |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 31 | #include "a3xx_reg.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 32 | |
| 33 | #define DRIVER_VERSION_MAJOR 3 |
| 34 | #define DRIVER_VERSION_MINOR 1 |
| 35 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 36 | /* Adreno MH arbiter config*/ |
| 37 | #define ADRENO_CFG_MHARB \ |
| 38 | (0x10 \ |
| 39 | | (0 << MH_ARBITER_CONFIG__SAME_PAGE_GRANULARITY__SHIFT) \ |
| 40 | | (1 << MH_ARBITER_CONFIG__L1_ARB_ENABLE__SHIFT) \ |
| 41 | | (1 << MH_ARBITER_CONFIG__L1_ARB_HOLD_ENABLE__SHIFT) \ |
| 42 | | (0 << MH_ARBITER_CONFIG__L2_ARB_CONTROL__SHIFT) \ |
| 43 | | (1 << MH_ARBITER_CONFIG__PAGE_SIZE__SHIFT) \ |
| 44 | | (1 << MH_ARBITER_CONFIG__TC_REORDER_ENABLE__SHIFT) \ |
| 45 | | (1 << MH_ARBITER_CONFIG__TC_ARB_HOLD_ENABLE__SHIFT) \ |
| 46 | | (0 << MH_ARBITER_CONFIG__IN_FLIGHT_LIMIT_ENABLE__SHIFT) \ |
| 47 | | (0x8 << MH_ARBITER_CONFIG__IN_FLIGHT_LIMIT__SHIFT) \ |
| 48 | | (1 << MH_ARBITER_CONFIG__CP_CLNT_ENABLE__SHIFT) \ |
| 49 | | (1 << MH_ARBITER_CONFIG__VGT_CLNT_ENABLE__SHIFT) \ |
| 50 | | (1 << MH_ARBITER_CONFIG__TC_CLNT_ENABLE__SHIFT) \ |
| 51 | | (1 << MH_ARBITER_CONFIG__RB_CLNT_ENABLE__SHIFT) \ |
| 52 | | (1 << MH_ARBITER_CONFIG__PA_CLNT_ENABLE__SHIFT)) |
| 53 | |
| 54 | #define ADRENO_MMU_CONFIG \ |
| 55 | (0x01 \ |
| 56 | | (MMU_CONFIG << MH_MMU_CONFIG__RB_W_CLNT_BEHAVIOR__SHIFT) \ |
| 57 | | (MMU_CONFIG << MH_MMU_CONFIG__CP_W_CLNT_BEHAVIOR__SHIFT) \ |
| 58 | | (MMU_CONFIG << MH_MMU_CONFIG__CP_R0_CLNT_BEHAVIOR__SHIFT) \ |
| 59 | | (MMU_CONFIG << MH_MMU_CONFIG__CP_R1_CLNT_BEHAVIOR__SHIFT) \ |
| 60 | | (MMU_CONFIG << MH_MMU_CONFIG__CP_R2_CLNT_BEHAVIOR__SHIFT) \ |
| 61 | | (MMU_CONFIG << MH_MMU_CONFIG__CP_R3_CLNT_BEHAVIOR__SHIFT) \ |
| 62 | | (MMU_CONFIG << MH_MMU_CONFIG__CP_R4_CLNT_BEHAVIOR__SHIFT) \ |
| 63 | | (MMU_CONFIG << MH_MMU_CONFIG__VGT_R0_CLNT_BEHAVIOR__SHIFT) \ |
| 64 | | (MMU_CONFIG << MH_MMU_CONFIG__VGT_R1_CLNT_BEHAVIOR__SHIFT) \ |
| 65 | | (MMU_CONFIG << MH_MMU_CONFIG__TC_R_CLNT_BEHAVIOR__SHIFT) \ |
| 66 | | (MMU_CONFIG << MH_MMU_CONFIG__PA_W_CLNT_BEHAVIOR__SHIFT)) |
| 67 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 68 | static const struct kgsl_functable adreno_functable; |
| 69 | |
| 70 | static struct adreno_device device_3d0 = { |
| 71 | .dev = { |
| 72 | .name = DEVICE_3D0_NAME, |
| 73 | .id = KGSL_DEVICE_3D0, |
| 74 | .ver_major = DRIVER_VERSION_MAJOR, |
| 75 | .ver_minor = DRIVER_VERSION_MINOR, |
Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 76 | .mh = { |
| 77 | .mharb = ADRENO_CFG_MHARB, |
| 78 | /* Remove 1k boundary check in z470 to avoid a GPU |
| 79 | * hang. Notice that this solution won't work if |
| 80 | * both EBI and SMI are used |
| 81 | */ |
| 82 | .mh_intf_cfg1 = 0x00032f07, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 83 | /* turn off memory protection unit by setting |
| 84 | acceptable physical address range to include |
| 85 | all pages. */ |
| 86 | .mpu_base = 0x00000000, |
| 87 | .mpu_range = 0xFFFFF000, |
| 88 | }, |
Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 89 | .mmu = { |
| 90 | .config = ADRENO_MMU_CONFIG, |
| 91 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 92 | .pwrctrl = { |
| 93 | .regulator_name = "fs_gfx3d", |
| 94 | .irq_name = KGSL_3D0_IRQ, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 95 | }, |
| 96 | .mutex = __MUTEX_INITIALIZER(device_3d0.dev.mutex), |
| 97 | .state = KGSL_STATE_INIT, |
| 98 | .active_cnt = 0, |
| 99 | .iomemname = KGSL_3D0_REG_MEMORY, |
| 100 | .ftbl = &adreno_functable, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 101 | #ifdef CONFIG_HAS_EARLYSUSPEND |
Jordan Crouse | 9f73921 | 2011-07-28 08:37:57 -0600 | [diff] [blame] | 102 | .display_off = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 103 | .level = EARLY_SUSPEND_LEVEL_STOP_DRAWING, |
| 104 | .suspend = kgsl_early_suspend_driver, |
| 105 | .resume = kgsl_late_resume_driver, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 106 | }, |
Jordan Crouse | 9f73921 | 2011-07-28 08:37:57 -0600 | [diff] [blame] | 107 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 108 | }, |
| 109 | .gmemspace = { |
| 110 | .gpu_base = 0, |
| 111 | .sizebytes = SZ_256K, |
| 112 | }, |
| 113 | .pfp_fw = NULL, |
| 114 | .pm4_fw = NULL, |
Jordan Crouse | 95b3327 | 2011-11-11 14:50:12 -0700 | [diff] [blame] | 115 | .wait_timeout = 10000, /* in milliseconds */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 116 | }; |
| 117 | |
Jordan Crouse | 95b3327 | 2011-11-11 14:50:12 -0700 | [diff] [blame] | 118 | |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 119 | /* |
| 120 | * This is the master list of all GPU cores that are supported by this |
| 121 | * driver. |
| 122 | */ |
| 123 | |
| 124 | #define ANY_ID (~0) |
| 125 | |
| 126 | static const struct { |
| 127 | enum adreno_gpurev gpurev; |
Jeremy Gebben | e2e61d4 | 2011-09-27 15:45:41 -0600 | [diff] [blame] | 128 | unsigned int core, major, minor, patchid; |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 129 | const char *pm4fw; |
| 130 | const char *pfpfw; |
| 131 | struct adreno_gpudev *gpudev; |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 132 | unsigned int istore_size; |
| 133 | unsigned int pix_shader_start; |
Jordan Crouse | c6b3a99 | 2012-02-04 10:23:51 -0700 | [diff] [blame] | 134 | unsigned int instruction_size; /* Size of an instruction in dwords */ |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 135 | } adreno_gpulist[] = { |
Jeremy Gebben | e2e61d4 | 2011-09-27 15:45:41 -0600 | [diff] [blame] | 136 | { ADRENO_REV_A200, 0, 2, ANY_ID, ANY_ID, |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 137 | "yamato_pm4.fw", "yamato_pfp.fw", &adreno_a2xx_gpudev, |
Jordan Crouse | c6b3a99 | 2012-02-04 10:23:51 -0700 | [diff] [blame] | 138 | 512, 384, 3}, |
Ranjhith Kalisamy | 938e00f | 2012-02-17 14:39:47 +0530 | [diff] [blame] | 139 | { ADRENO_REV_A203, 0, 1, 1, ANY_ID, |
| 140 | "yamato_pm4.fw", "yamato_pfp.fw", &adreno_a2xx_gpudev, |
| 141 | 512, 384, 3}, |
Jeremy Gebben | e2e61d4 | 2011-09-27 15:45:41 -0600 | [diff] [blame] | 142 | { ADRENO_REV_A205, 0, 1, 0, ANY_ID, |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 143 | "yamato_pm4.fw", "yamato_pfp.fw", &adreno_a2xx_gpudev, |
Jordan Crouse | c6b3a99 | 2012-02-04 10:23:51 -0700 | [diff] [blame] | 144 | 512, 384, 3}, |
Jeremy Gebben | e2e61d4 | 2011-09-27 15:45:41 -0600 | [diff] [blame] | 145 | { ADRENO_REV_A220, 2, 1, ANY_ID, ANY_ID, |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 146 | "leia_pm4_470.fw", "leia_pfp_470.fw", &adreno_a2xx_gpudev, |
Jordan Crouse | c6b3a99 | 2012-02-04 10:23:51 -0700 | [diff] [blame] | 147 | 512, 384, 3}, |
Jeremy Gebben | e2e61d4 | 2011-09-27 15:45:41 -0600 | [diff] [blame] | 148 | /* |
| 149 | * patchlevel 5 (8960v2) needs special pm4 firmware to work around |
| 150 | * a hardware problem. |
| 151 | */ |
| 152 | { ADRENO_REV_A225, 2, 2, 0, 5, |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 153 | "a225p5_pm4.fw", "a225_pfp.fw", &adreno_a2xx_gpudev, |
Jordan Crouse | c6b3a99 | 2012-02-04 10:23:51 -0700 | [diff] [blame] | 154 | 1536, 768, 3 }, |
Carter Cooper | f27ec72 | 2011-11-17 15:20:38 -0700 | [diff] [blame] | 155 | { ADRENO_REV_A225, 2, 2, 0, 6, |
| 156 | "a225_pm4.fw", "a225_pfp.fw", &adreno_a2xx_gpudev, |
Jordan Crouse | c6b3a99 | 2012-02-04 10:23:51 -0700 | [diff] [blame] | 157 | 1536, 768, 3 }, |
Jeremy Gebben | e2e61d4 | 2011-09-27 15:45:41 -0600 | [diff] [blame] | 158 | { ADRENO_REV_A225, 2, 2, ANY_ID, ANY_ID, |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 159 | "a225_pm4.fw", "a225_pfp.fw", &adreno_a2xx_gpudev, |
Jordan Crouse | c6b3a99 | 2012-02-04 10:23:51 -0700 | [diff] [blame] | 160 | 1536, 768, 3 }, |
| 161 | /* A3XX doesn't use the pix_shader_start */ |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 162 | { ADRENO_REV_A320, 3, 1, ANY_ID, ANY_ID, |
Jordan Crouse | c6b3a99 | 2012-02-04 10:23:51 -0700 | [diff] [blame] | 163 | "a300_pm4.fw", "a300_pfp.fw", &adreno_a3xx_gpudev, |
| 164 | 512, 0, 2 }, |
| 165 | |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 166 | }; |
| 167 | |
Jordan Crouse | 9f73921 | 2011-07-28 08:37:57 -0600 | [diff] [blame] | 168 | static irqreturn_t adreno_isr(int irq, void *data) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 169 | { |
Jordan Crouse | a78c917 | 2011-07-11 13:14:09 -0600 | [diff] [blame] | 170 | irqreturn_t result; |
| 171 | struct kgsl_device *device = data; |
| 172 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 173 | |
Jordan Crouse | a78c917 | 2011-07-11 13:14:09 -0600 | [diff] [blame] | 174 | result = adreno_dev->gpudev->irq_handler(adreno_dev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 175 | |
| 176 | if (device->requested_state == KGSL_STATE_NONE) { |
| 177 | if (device->pwrctrl.nap_allowed == true) { |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 178 | kgsl_pwrctrl_request_state(device, KGSL_STATE_NAP); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 179 | queue_work(device->work_queue, &device->idle_check_ws); |
| 180 | } else if (device->pwrscale.policy != NULL) { |
| 181 | queue_work(device->work_queue, &device->idle_check_ws); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | /* Reset the time-out in our idle timer */ |
Tarun Karra | 6875576 | 2012-01-12 16:07:09 -0800 | [diff] [blame] | 186 | mod_timer_pending(&device->idle_timer, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 187 | jiffies + device->pwrctrl.interval_timeout); |
| 188 | return result; |
| 189 | } |
| 190 | |
Jordan Crouse | 9f73921 | 2011-07-28 08:37:57 -0600 | [diff] [blame] | 191 | static void adreno_cleanup_pt(struct kgsl_device *device, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 192 | struct kgsl_pagetable *pagetable) |
| 193 | { |
| 194 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 195 | struct adreno_ringbuffer *rb = &adreno_dev->ringbuffer; |
| 196 | |
| 197 | kgsl_mmu_unmap(pagetable, &rb->buffer_desc); |
| 198 | |
| 199 | kgsl_mmu_unmap(pagetable, &rb->memptrs_desc); |
| 200 | |
| 201 | kgsl_mmu_unmap(pagetable, &device->memstore); |
| 202 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 203 | kgsl_mmu_unmap(pagetable, &device->mmu.setstate_memory); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | static int adreno_setup_pt(struct kgsl_device *device, |
| 207 | struct kgsl_pagetable *pagetable) |
| 208 | { |
| 209 | int result = 0; |
| 210 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 211 | struct adreno_ringbuffer *rb = &adreno_dev->ringbuffer; |
| 212 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 213 | result = kgsl_mmu_map_global(pagetable, &rb->buffer_desc, |
| 214 | GSL_PT_PAGE_RV); |
| 215 | if (result) |
| 216 | goto error; |
| 217 | |
| 218 | result = kgsl_mmu_map_global(pagetable, &rb->memptrs_desc, |
| 219 | GSL_PT_PAGE_RV | GSL_PT_PAGE_WV); |
| 220 | if (result) |
| 221 | goto unmap_buffer_desc; |
| 222 | |
| 223 | result = kgsl_mmu_map_global(pagetable, &device->memstore, |
| 224 | GSL_PT_PAGE_RV | GSL_PT_PAGE_WV); |
| 225 | if (result) |
| 226 | goto unmap_memptrs_desc; |
| 227 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 228 | result = kgsl_mmu_map_global(pagetable, &device->mmu.setstate_memory, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 229 | GSL_PT_PAGE_RV | GSL_PT_PAGE_WV); |
| 230 | if (result) |
| 231 | goto unmap_memstore_desc; |
| 232 | |
| 233 | return result; |
| 234 | |
| 235 | unmap_memstore_desc: |
| 236 | kgsl_mmu_unmap(pagetable, &device->memstore); |
| 237 | |
| 238 | unmap_memptrs_desc: |
| 239 | kgsl_mmu_unmap(pagetable, &rb->memptrs_desc); |
| 240 | |
| 241 | unmap_buffer_desc: |
| 242 | kgsl_mmu_unmap(pagetable, &rb->buffer_desc); |
| 243 | |
| 244 | error: |
| 245 | return result; |
| 246 | } |
| 247 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 248 | static void adreno_setstate(struct kgsl_device *device, |
| 249 | uint32_t flags) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 250 | { |
| 251 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 252 | unsigned int link[32]; |
| 253 | unsigned int *cmds = &link[0]; |
| 254 | int sizedwords = 0; |
| 255 | unsigned int mh_mmu_invalidate = 0x00000003; /*invalidate all and tc */ |
| 256 | |
Jeremy Gebben | a3d07a4 | 2011-10-17 12:08:16 -0600 | [diff] [blame] | 257 | /* |
Jordan Crouse | e3f80ea | 2012-02-04 14:22:36 -0700 | [diff] [blame] | 258 | * A3XX doesn't support the fast path (the registers don't even exist) |
| 259 | * so just bail out early |
| 260 | */ |
| 261 | |
| 262 | if (adreno_is_a3xx(adreno_dev)) { |
| 263 | kgsl_mmu_device_setstate(device, flags); |
| 264 | return; |
| 265 | } |
| 266 | |
| 267 | /* |
Jeremy Gebben | a3d07a4 | 2011-10-17 12:08:16 -0600 | [diff] [blame] | 268 | * If possible, then set the state via the command stream to avoid |
| 269 | * a CPU idle. Otherwise, use the default setstate which uses register |
| 270 | * writes For CFF dump we must idle and use the registers so that it is |
| 271 | * easier to filter out the mmu accesses from the dump |
| 272 | */ |
| 273 | if (!kgsl_cff_dump_enable && adreno_dev->drawctxt_active) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 274 | if (flags & KGSL_MMUFLAGS_PTUPDATE) { |
| 275 | /* wait for graphics pipe to be idle */ |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 276 | *cmds++ = cp_type3_packet(CP_WAIT_FOR_IDLE, 1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 277 | *cmds++ = 0x00000000; |
| 278 | |
| 279 | /* set page table base */ |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 280 | *cmds++ = cp_type0_packet(MH_MMU_PT_BASE, 1); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 281 | *cmds++ = kgsl_pt_get_base_addr( |
| 282 | device->mmu.hwpagetable); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 283 | sizedwords += 4; |
| 284 | } |
| 285 | |
| 286 | if (flags & KGSL_MMUFLAGS_TLBFLUSH) { |
| 287 | if (!(flags & KGSL_MMUFLAGS_PTUPDATE)) { |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 288 | *cmds++ = cp_type3_packet(CP_WAIT_FOR_IDLE, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 289 | 1); |
| 290 | *cmds++ = 0x00000000; |
| 291 | sizedwords += 2; |
| 292 | } |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 293 | *cmds++ = cp_type0_packet(MH_MMU_INVALIDATE, 1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 294 | *cmds++ = mh_mmu_invalidate; |
| 295 | sizedwords += 2; |
| 296 | } |
| 297 | |
| 298 | if (flags & KGSL_MMUFLAGS_PTUPDATE && |
Jeremy Gebben | 5bb7ece | 2011-08-02 11:04:48 -0600 | [diff] [blame] | 299 | adreno_is_a20x(adreno_dev)) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 300 | /* HW workaround: to resolve MMU page fault interrupts |
| 301 | * caused by the VGT.It prevents the CP PFP from filling |
| 302 | * the VGT DMA request fifo too early,thereby ensuring |
| 303 | * that the VGT will not fetch vertex/bin data until |
| 304 | * after the page table base register has been updated. |
| 305 | * |
| 306 | * Two null DRAW_INDX_BIN packets are inserted right |
| 307 | * after the page table base update, followed by a |
| 308 | * wait for idle. The null packets will fill up the |
| 309 | * VGT DMA request fifo and prevent any further |
| 310 | * vertex/bin updates from occurring until the wait |
| 311 | * has finished. */ |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 312 | *cmds++ = cp_type3_packet(CP_SET_CONSTANT, 2); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 313 | *cmds++ = (0x4 << 16) | |
| 314 | (REG_PA_SU_SC_MODE_CNTL - 0x2000); |
| 315 | *cmds++ = 0; /* disable faceness generation */ |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 316 | *cmds++ = cp_type3_packet(CP_SET_BIN_BASE_OFFSET, 1); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 317 | *cmds++ = device->mmu.setstate_memory.gpuaddr; |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 318 | *cmds++ = cp_type3_packet(CP_DRAW_INDX_BIN, 6); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 319 | *cmds++ = 0; /* viz query info */ |
| 320 | *cmds++ = 0x0003C004; /* draw indicator */ |
| 321 | *cmds++ = 0; /* bin base */ |
| 322 | *cmds++ = 3; /* bin size */ |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 323 | *cmds++ = |
| 324 | device->mmu.setstate_memory.gpuaddr; /* dma base */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 325 | *cmds++ = 6; /* dma size */ |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 326 | *cmds++ = cp_type3_packet(CP_DRAW_INDX_BIN, 6); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 327 | *cmds++ = 0; /* viz query info */ |
| 328 | *cmds++ = 0x0003C004; /* draw indicator */ |
| 329 | *cmds++ = 0; /* bin base */ |
| 330 | *cmds++ = 3; /* bin size */ |
| 331 | /* dma base */ |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 332 | *cmds++ = device->mmu.setstate_memory.gpuaddr; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 333 | *cmds++ = 6; /* dma size */ |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 334 | *cmds++ = cp_type3_packet(CP_WAIT_FOR_IDLE, 1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 335 | *cmds++ = 0x00000000; |
| 336 | sizedwords += 21; |
| 337 | } |
| 338 | |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 339 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 340 | if (flags & (KGSL_MMUFLAGS_PTUPDATE | KGSL_MMUFLAGS_TLBFLUSH)) { |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 341 | *cmds++ = cp_type3_packet(CP_INVALIDATE_STATE, 1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 342 | *cmds++ = 0x7fff; /* invalidate all base pointers */ |
| 343 | sizedwords += 2; |
| 344 | } |
| 345 | |
| 346 | adreno_ringbuffer_issuecmds(device, KGSL_CMD_FLAGS_PMODE, |
| 347 | &link[0], sizedwords); |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 348 | } else { |
| 349 | kgsl_mmu_device_setstate(device, flags); |
| 350 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | static unsigned int |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 354 | a3xx_getchipid(struct kgsl_device *device) |
| 355 | { |
| 356 | unsigned int chipid = 0; |
| 357 | unsigned int coreid, majorid, minorid, patchid; |
| 358 | unsigned int version; |
| 359 | |
| 360 | adreno_regread(device, A3XX_RBBM_HW_VERSION, &version); |
| 361 | |
| 362 | coreid = 0x03; |
| 363 | |
| 364 | /* Version might not be set - if it isn't, assume this is 320 */ |
| 365 | if (version) |
| 366 | majorid = version & 0x0F; |
| 367 | else |
| 368 | majorid = 1; |
| 369 | |
| 370 | minorid = (version >> 4) & 0xFFF; |
| 371 | patchid = 0; |
| 372 | |
| 373 | chipid = (coreid << 24) | (majorid << 16) | (minorid << 8) | patchid; |
| 374 | |
| 375 | return chipid; |
| 376 | } |
| 377 | |
| 378 | static unsigned int |
| 379 | a2xx_getchipid(struct kgsl_device *device) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 380 | { |
| 381 | unsigned int chipid = 0; |
| 382 | unsigned int coreid, majorid, minorid, patchid, revid; |
Carter Cooper | f27ec72 | 2011-11-17 15:20:38 -0700 | [diff] [blame] | 383 | uint32_t soc_platform_version = socinfo_get_version(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 384 | |
| 385 | adreno_regread(device, REG_RBBM_PERIPHID1, &coreid); |
| 386 | adreno_regread(device, REG_RBBM_PERIPHID2, &majorid); |
| 387 | adreno_regread(device, REG_RBBM_PATCH_RELEASE, &revid); |
| 388 | |
| 389 | /* |
| 390 | * adreno 22x gpus are indicated by coreid 2, |
| 391 | * but REG_RBBM_PERIPHID1 always contains 0 for this field |
| 392 | */ |
Stepan Moskovchenko | 8eea9cf | 2011-10-25 14:45:42 -0700 | [diff] [blame] | 393 | if (cpu_is_msm8960() || cpu_is_msm8x60() || cpu_is_msm8930()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 394 | chipid = 2 << 24; |
| 395 | else |
| 396 | chipid = (coreid & 0xF) << 24; |
| 397 | |
| 398 | chipid |= ((majorid >> 4) & 0xF) << 16; |
| 399 | |
| 400 | minorid = ((revid >> 0) & 0xFF); |
| 401 | |
| 402 | patchid = ((revid >> 16) & 0xFF); |
| 403 | |
| 404 | /* 8x50 returns 0 for patch release, but it should be 1 */ |
Carter Cooper | f27ec72 | 2011-11-17 15:20:38 -0700 | [diff] [blame] | 405 | /* 8960v3 returns 5 for patch release, but it should be 6 */ |
Ranjhith Kalisamy | 938e00f | 2012-02-17 14:39:47 +0530 | [diff] [blame] | 406 | /* 8x25 returns 0 for minor id, but it should be 1 */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 407 | if (cpu_is_qsd8x50()) |
| 408 | patchid = 1; |
Carter Cooper | f27ec72 | 2011-11-17 15:20:38 -0700 | [diff] [blame] | 409 | else if (cpu_is_msm8960() && |
| 410 | SOCINFO_VERSION_MAJOR(soc_platform_version) == 3) |
| 411 | patchid = 6; |
Ranjhith Kalisamy | 938e00f | 2012-02-17 14:39:47 +0530 | [diff] [blame] | 412 | else if (cpu_is_msm8625() && minorid == 0) |
| 413 | minorid = 1; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 414 | |
| 415 | chipid |= (minorid << 8) | patchid; |
| 416 | |
| 417 | return chipid; |
| 418 | } |
| 419 | |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 420 | static unsigned int |
| 421 | adreno_getchipid(struct kgsl_device *device) |
| 422 | { |
| 423 | if (cpu_is_apq8064()) |
| 424 | return a3xx_getchipid(device); |
| 425 | else |
| 426 | return a2xx_getchipid(device); |
| 427 | } |
| 428 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 429 | static inline bool _rev_match(unsigned int id, unsigned int entry) |
| 430 | { |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 431 | return (entry == ANY_ID || entry == id); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 432 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 433 | |
| 434 | static void |
| 435 | adreno_identify_gpu(struct adreno_device *adreno_dev) |
| 436 | { |
Jeremy Gebben | e2e61d4 | 2011-09-27 15:45:41 -0600 | [diff] [blame] | 437 | unsigned int i, core, major, minor, patchid; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 438 | |
| 439 | adreno_dev->chip_id = adreno_getchipid(&adreno_dev->dev); |
| 440 | |
| 441 | core = (adreno_dev->chip_id >> 24) & 0xff; |
| 442 | major = (adreno_dev->chip_id >> 16) & 0xff; |
| 443 | minor = (adreno_dev->chip_id >> 8) & 0xff; |
Jeremy Gebben | e2e61d4 | 2011-09-27 15:45:41 -0600 | [diff] [blame] | 444 | patchid = (adreno_dev->chip_id & 0xff); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 445 | |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 446 | for (i = 0; i < ARRAY_SIZE(adreno_gpulist); i++) { |
| 447 | if (core == adreno_gpulist[i].core && |
| 448 | _rev_match(major, adreno_gpulist[i].major) && |
Jeremy Gebben | e2e61d4 | 2011-09-27 15:45:41 -0600 | [diff] [blame] | 449 | _rev_match(minor, adreno_gpulist[i].minor) && |
| 450 | _rev_match(patchid, adreno_gpulist[i].patchid)) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 451 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 452 | } |
| 453 | |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 454 | if (i == ARRAY_SIZE(adreno_gpulist)) { |
| 455 | adreno_dev->gpurev = ADRENO_REV_UNKNOWN; |
| 456 | return; |
| 457 | } |
| 458 | |
| 459 | adreno_dev->gpurev = adreno_gpulist[i].gpurev; |
| 460 | adreno_dev->gpudev = adreno_gpulist[i].gpudev; |
| 461 | adreno_dev->pfp_fwfile = adreno_gpulist[i].pfpfw; |
| 462 | adreno_dev->pm4_fwfile = adreno_gpulist[i].pm4fw; |
Jeremy Gebben | ddf6b57 | 2011-09-09 13:39:49 -0700 | [diff] [blame] | 463 | adreno_dev->istore_size = adreno_gpulist[i].istore_size; |
| 464 | adreno_dev->pix_shader_start = adreno_gpulist[i].pix_shader_start; |
Jordan Crouse | 55d98fd | 2012-02-04 10:23:51 -0700 | [diff] [blame] | 465 | adreno_dev->instruction_size = adreno_gpulist[i].instruction_size; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | static int __devinit |
| 469 | adreno_probe(struct platform_device *pdev) |
| 470 | { |
| 471 | struct kgsl_device *device; |
| 472 | struct adreno_device *adreno_dev; |
| 473 | int status = -EINVAL; |
| 474 | |
| 475 | device = (struct kgsl_device *)pdev->id_entry->driver_data; |
| 476 | adreno_dev = ADRENO_DEVICE(device); |
| 477 | device->parentdev = &pdev->dev; |
| 478 | |
| 479 | init_completion(&device->recovery_gate); |
| 480 | |
| 481 | status = adreno_ringbuffer_init(device); |
| 482 | if (status != 0) |
| 483 | goto error; |
| 484 | |
| 485 | status = kgsl_device_platform_probe(device, adreno_isr); |
| 486 | if (status) |
| 487 | goto error_close_rb; |
| 488 | |
| 489 | adreno_debugfs_init(device); |
| 490 | |
| 491 | kgsl_pwrscale_init(device); |
| 492 | kgsl_pwrscale_attach_policy(device, ADRENO_DEFAULT_PWRSCALE_POLICY); |
| 493 | |
| 494 | device->flags &= ~KGSL_FLAGS_SOFT_RESET; |
| 495 | return 0; |
| 496 | |
| 497 | error_close_rb: |
| 498 | adreno_ringbuffer_close(&adreno_dev->ringbuffer); |
| 499 | error: |
| 500 | device->parentdev = NULL; |
| 501 | return status; |
| 502 | } |
| 503 | |
| 504 | static int __devexit adreno_remove(struct platform_device *pdev) |
| 505 | { |
| 506 | struct kgsl_device *device; |
| 507 | struct adreno_device *adreno_dev; |
| 508 | |
| 509 | device = (struct kgsl_device *)pdev->id_entry->driver_data; |
| 510 | adreno_dev = ADRENO_DEVICE(device); |
| 511 | |
| 512 | kgsl_pwrscale_detach_policy(device); |
| 513 | kgsl_pwrscale_close(device); |
| 514 | |
| 515 | adreno_ringbuffer_close(&adreno_dev->ringbuffer); |
| 516 | kgsl_device_platform_remove(device); |
| 517 | |
| 518 | return 0; |
| 519 | } |
| 520 | |
| 521 | static int adreno_start(struct kgsl_device *device, unsigned int init_ram) |
| 522 | { |
| 523 | int status = -EINVAL; |
| 524 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 525 | |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 526 | kgsl_pwrctrl_set_state(device, KGSL_STATE_INIT); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 527 | |
| 528 | /* Power up the device */ |
| 529 | kgsl_pwrctrl_enable(device); |
| 530 | |
| 531 | /* Identify the specific GPU */ |
| 532 | adreno_identify_gpu(adreno_dev); |
| 533 | |
Jordan Crouse | 505df9c | 2011-07-28 08:37:59 -0600 | [diff] [blame] | 534 | if (adreno_dev->gpurev == ADRENO_REV_UNKNOWN) { |
| 535 | KGSL_DRV_ERR(device, "Unknown chip ID %x\n", |
| 536 | adreno_dev->chip_id); |
| 537 | goto error_clk_off; |
| 538 | } |
| 539 | |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 540 | /* Set up the MMU */ |
| 541 | if (adreno_is_a2xx(adreno_dev)) { |
Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 542 | /* |
| 543 | * the MH_CLNT_INTF_CTRL_CONFIG registers aren't present |
| 544 | * on older gpus |
| 545 | */ |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 546 | if (adreno_is_a20x(adreno_dev)) { |
| 547 | device->mh.mh_intf_cfg1 = 0; |
| 548 | device->mh.mh_intf_cfg2 = 0; |
| 549 | } |
| 550 | |
| 551 | kgsl_mh_start(device); |
Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 552 | } |
| 553 | |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 554 | status = kgsl_mmu_start(device); |
| 555 | if (status) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 556 | goto error_clk_off; |
| 557 | |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 558 | /* Start the GPU */ |
| 559 | adreno_dev->gpudev->start(adreno_dev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 560 | |
| 561 | kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_ON); |
Jeremy Gebben | b7bc955 | 2012-01-09 13:32:49 -0700 | [diff] [blame] | 562 | device->ftbl->irqctrl(device, 1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 563 | |
| 564 | status = adreno_ringbuffer_start(&adreno_dev->ringbuffer, init_ram); |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 565 | if (status == 0) { |
| 566 | mod_timer(&device->idle_timer, jiffies + FIRST_TIMEOUT); |
| 567 | return 0; |
| 568 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 569 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 570 | kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_OFF); |
Jeremy Gebben | 4e8aada | 2011-07-12 10:07:47 -0600 | [diff] [blame] | 571 | kgsl_mmu_stop(device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 572 | error_clk_off: |
| 573 | kgsl_pwrctrl_disable(device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 574 | |
| 575 | return status; |
| 576 | } |
| 577 | |
| 578 | static int adreno_stop(struct kgsl_device *device) |
| 579 | { |
| 580 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 581 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 582 | adreno_dev->drawctxt_active = NULL; |
| 583 | |
| 584 | adreno_ringbuffer_stop(&adreno_dev->ringbuffer); |
| 585 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 586 | kgsl_mmu_stop(device); |
| 587 | |
Jeremy Gebben | b7bc955 | 2012-01-09 13:32:49 -0700 | [diff] [blame] | 588 | device->ftbl->irqctrl(device, 0); |
Ranjhith Kalisamy | ce75b0c | 2012-02-01 19:31:23 +0530 | [diff] [blame] | 589 | kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_OFF); |
Suman Tatiraju | 4a32c65 | 2012-02-17 11:59:05 -0800 | [diff] [blame] | 590 | del_timer_sync(&device->idle_timer); |
Lucille Sylvester | 844b1c8 | 2011-08-29 15:26:06 -0600 | [diff] [blame] | 591 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 592 | /* Power down the device */ |
| 593 | kgsl_pwrctrl_disable(device); |
| 594 | |
| 595 | return 0; |
| 596 | } |
| 597 | |
| 598 | static int |
| 599 | adreno_recover_hang(struct kgsl_device *device) |
| 600 | { |
| 601 | int ret; |
| 602 | unsigned int *rb_buffer; |
| 603 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 604 | struct adreno_ringbuffer *rb = &adreno_dev->ringbuffer; |
| 605 | unsigned int timestamp; |
| 606 | unsigned int num_rb_contents; |
| 607 | unsigned int bad_context; |
| 608 | unsigned int reftimestamp; |
| 609 | unsigned int enable_ts; |
| 610 | unsigned int soptimestamp; |
| 611 | unsigned int eoptimestamp; |
| 612 | struct adreno_context *drawctxt; |
Shubhraprakash Das | 2dfe5dd | 2012-02-10 13:49:53 -0700 | [diff] [blame] | 613 | struct kgsl_context *context; |
| 614 | int next = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 615 | |
| 616 | KGSL_DRV_ERR(device, "Starting recovery from 3D GPU hang....\n"); |
| 617 | rb_buffer = vmalloc(rb->buffer_desc.size); |
| 618 | if (!rb_buffer) { |
| 619 | KGSL_MEM_ERR(device, |
| 620 | "Failed to allocate memory for recovery: %x\n", |
| 621 | rb->buffer_desc.size); |
| 622 | return -ENOMEM; |
| 623 | } |
| 624 | /* Extract valid contents from rb which can stil be executed after |
| 625 | * hang */ |
| 626 | ret = adreno_ringbuffer_extract(rb, rb_buffer, &num_rb_contents); |
| 627 | if (ret) |
| 628 | goto done; |
| 629 | timestamp = rb->timestamp; |
| 630 | KGSL_DRV_ERR(device, "Last issued timestamp: %x\n", timestamp); |
| 631 | kgsl_sharedmem_readl(&device->memstore, &bad_context, |
| 632 | KGSL_DEVICE_MEMSTORE_OFFSET(current_context)); |
| 633 | kgsl_sharedmem_readl(&device->memstore, &reftimestamp, |
| 634 | KGSL_DEVICE_MEMSTORE_OFFSET(ref_wait_ts)); |
| 635 | kgsl_sharedmem_readl(&device->memstore, &enable_ts, |
| 636 | KGSL_DEVICE_MEMSTORE_OFFSET(ts_cmp_enable)); |
| 637 | kgsl_sharedmem_readl(&device->memstore, &soptimestamp, |
| 638 | KGSL_DEVICE_MEMSTORE_OFFSET(soptimestamp)); |
| 639 | kgsl_sharedmem_readl(&device->memstore, &eoptimestamp, |
| 640 | KGSL_DEVICE_MEMSTORE_OFFSET(eoptimestamp)); |
| 641 | /* Make sure memory is synchronized before restarting the GPU */ |
| 642 | mb(); |
| 643 | KGSL_CTXT_ERR(device, |
| 644 | "Context that caused a GPU hang: %x\n", bad_context); |
| 645 | /* restart device */ |
| 646 | ret = adreno_stop(device); |
| 647 | if (ret) |
| 648 | goto done; |
| 649 | ret = adreno_start(device, true); |
| 650 | if (ret) |
| 651 | goto done; |
| 652 | KGSL_DRV_ERR(device, "Device has been restarted after hang\n"); |
| 653 | /* Restore timestamp states */ |
| 654 | kgsl_sharedmem_writel(&device->memstore, |
| 655 | KGSL_DEVICE_MEMSTORE_OFFSET(soptimestamp), |
| 656 | soptimestamp); |
| 657 | kgsl_sharedmem_writel(&device->memstore, |
| 658 | KGSL_DEVICE_MEMSTORE_OFFSET(eoptimestamp), |
| 659 | eoptimestamp); |
| 660 | kgsl_sharedmem_writel(&device->memstore, |
| 661 | KGSL_DEVICE_MEMSTORE_OFFSET(soptimestamp), |
| 662 | soptimestamp); |
| 663 | if (num_rb_contents) { |
| 664 | kgsl_sharedmem_writel(&device->memstore, |
| 665 | KGSL_DEVICE_MEMSTORE_OFFSET(ref_wait_ts), |
| 666 | reftimestamp); |
| 667 | kgsl_sharedmem_writel(&device->memstore, |
| 668 | KGSL_DEVICE_MEMSTORE_OFFSET(ts_cmp_enable), |
| 669 | enable_ts); |
| 670 | } |
| 671 | /* Make sure all writes are posted before the GPU reads them */ |
| 672 | wmb(); |
| 673 | /* Mark the invalid context so no more commands are accepted from |
| 674 | * that context */ |
| 675 | |
| 676 | drawctxt = (struct adreno_context *) bad_context; |
| 677 | |
| 678 | KGSL_CTXT_ERR(device, |
| 679 | "Context that caused a GPU hang: %x\n", bad_context); |
| 680 | |
| 681 | drawctxt->flags |= CTXT_FLAGS_GPU_HANG; |
| 682 | |
Shubhraprakash Das | 2dfe5dd | 2012-02-10 13:49:53 -0700 | [diff] [blame] | 683 | /* |
| 684 | * Set the reset status of all contexts to |
| 685 | * INNOCENT_CONTEXT_RESET_EXT except for the bad context |
| 686 | * since thats the guilty party |
| 687 | */ |
| 688 | while ((context = idr_get_next(&device->context_idr, &next))) { |
| 689 | if (KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT != |
| 690 | context->reset_status) { |
| 691 | if (context->devctxt != drawctxt) |
| 692 | context->reset_status = |
| 693 | KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT; |
| 694 | else |
| 695 | context->reset_status = |
| 696 | KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT; |
| 697 | } |
| 698 | next = next + 1; |
| 699 | } |
| 700 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 701 | /* Restore valid commands in ringbuffer */ |
| 702 | adreno_ringbuffer_restore(rb, rb_buffer, num_rb_contents); |
| 703 | rb->timestamp = timestamp; |
| 704 | done: |
| 705 | vfree(rb_buffer); |
| 706 | return ret; |
| 707 | } |
| 708 | |
| 709 | static int |
| 710 | adreno_dump_and_recover(struct kgsl_device *device) |
| 711 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 712 | int result = -ETIMEDOUT; |
| 713 | |
| 714 | if (device->state == KGSL_STATE_HUNG) |
| 715 | goto done; |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 716 | if (device->state == KGSL_STATE_DUMP_AND_RECOVER) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 717 | mutex_unlock(&device->mutex); |
| 718 | wait_for_completion(&device->recovery_gate); |
| 719 | mutex_lock(&device->mutex); |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 720 | if (device->state != KGSL_STATE_HUNG) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 721 | result = 0; |
| 722 | } else { |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 723 | kgsl_pwrctrl_set_state(device, KGSL_STATE_DUMP_AND_RECOVER); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 724 | INIT_COMPLETION(device->recovery_gate); |
Jordan Crouse | 156cfbc | 2012-01-24 09:32:04 -0700 | [diff] [blame] | 725 | /* Detected a hang */ |
| 726 | |
| 727 | |
| 728 | /* |
| 729 | * Trigger an automatic dump of the state to |
| 730 | * the console |
| 731 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 732 | adreno_postmortem_dump(device, 0); |
Jordan Crouse | 156cfbc | 2012-01-24 09:32:04 -0700 | [diff] [blame] | 733 | |
| 734 | /* |
| 735 | * Make a GPU snapshot. For now, do it after the PM dump so we |
| 736 | * can at least be sure the PM dump will work as it always has |
| 737 | */ |
| 738 | kgsl_device_snapshot(device, 1); |
| 739 | |
Jeremy Gebben | 388c297 | 2011-12-16 09:05:07 -0700 | [diff] [blame] | 740 | result = adreno_recover_hang(device); |
| 741 | if (result) |
| 742 | kgsl_pwrctrl_set_state(device, KGSL_STATE_HUNG); |
| 743 | else |
| 744 | kgsl_pwrctrl_set_state(device, KGSL_STATE_ACTIVE); |
| 745 | complete_all(&device->recovery_gate); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 746 | } |
| 747 | done: |
| 748 | return result; |
| 749 | } |
| 750 | |
| 751 | static int adreno_getproperty(struct kgsl_device *device, |
| 752 | enum kgsl_property_type type, |
| 753 | void *value, |
| 754 | unsigned int sizebytes) |
| 755 | { |
| 756 | int status = -EINVAL; |
| 757 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 758 | |
| 759 | switch (type) { |
| 760 | case KGSL_PROP_DEVICE_INFO: |
| 761 | { |
| 762 | struct kgsl_devinfo devinfo; |
| 763 | |
| 764 | if (sizebytes != sizeof(devinfo)) { |
| 765 | status = -EINVAL; |
| 766 | break; |
| 767 | } |
| 768 | |
| 769 | memset(&devinfo, 0, sizeof(devinfo)); |
| 770 | devinfo.device_id = device->id+1; |
| 771 | devinfo.chip_id = adreno_dev->chip_id; |
| 772 | devinfo.mmu_enabled = kgsl_mmu_enabled(); |
| 773 | devinfo.gpu_id = adreno_dev->gpurev; |
| 774 | devinfo.gmem_gpubaseaddr = adreno_dev->gmemspace. |
| 775 | gpu_base; |
| 776 | devinfo.gmem_sizebytes = adreno_dev->gmemspace. |
| 777 | sizebytes; |
| 778 | |
| 779 | if (copy_to_user(value, &devinfo, sizeof(devinfo)) != |
| 780 | 0) { |
| 781 | status = -EFAULT; |
| 782 | break; |
| 783 | } |
| 784 | status = 0; |
| 785 | } |
| 786 | break; |
| 787 | case KGSL_PROP_DEVICE_SHADOW: |
| 788 | { |
| 789 | struct kgsl_shadowprop shadowprop; |
| 790 | |
| 791 | if (sizebytes != sizeof(shadowprop)) { |
| 792 | status = -EINVAL; |
| 793 | break; |
| 794 | } |
| 795 | memset(&shadowprop, 0, sizeof(shadowprop)); |
| 796 | if (device->memstore.hostptr) { |
| 797 | /*NOTE: with mmu enabled, gpuaddr doesn't mean |
| 798 | * anything to mmap(). |
| 799 | */ |
| 800 | shadowprop.gpuaddr = device->memstore.physaddr; |
| 801 | shadowprop.size = device->memstore.size; |
| 802 | /* GSL needs this to be set, even if it |
| 803 | appears to be meaningless */ |
| 804 | shadowprop.flags = KGSL_FLAGS_INITIALIZED; |
| 805 | } |
| 806 | if (copy_to_user(value, &shadowprop, |
| 807 | sizeof(shadowprop))) { |
| 808 | status = -EFAULT; |
| 809 | break; |
| 810 | } |
| 811 | status = 0; |
| 812 | } |
| 813 | break; |
| 814 | case KGSL_PROP_MMU_ENABLE: |
| 815 | { |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 816 | int mmu_prop = kgsl_mmu_enabled(); |
| 817 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 818 | if (sizebytes != sizeof(int)) { |
| 819 | status = -EINVAL; |
| 820 | break; |
| 821 | } |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 822 | if (copy_to_user(value, &mmu_prop, sizeof(mmu_prop))) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 823 | status = -EFAULT; |
| 824 | break; |
| 825 | } |
| 826 | status = 0; |
| 827 | } |
| 828 | break; |
| 829 | case KGSL_PROP_INTERRUPT_WAITS: |
| 830 | { |
| 831 | int int_waits = 1; |
| 832 | if (sizebytes != sizeof(int)) { |
| 833 | status = -EINVAL; |
| 834 | break; |
| 835 | } |
| 836 | if (copy_to_user(value, &int_waits, sizeof(int))) { |
| 837 | status = -EFAULT; |
| 838 | break; |
| 839 | } |
| 840 | status = 0; |
| 841 | } |
| 842 | break; |
| 843 | default: |
| 844 | status = -EINVAL; |
| 845 | } |
| 846 | |
| 847 | return status; |
| 848 | } |
| 849 | |
Lynus Vaz | 06a9a90 | 2011-10-04 19:25:33 +0530 | [diff] [blame] | 850 | static inline void adreno_poke(struct kgsl_device *device) |
| 851 | { |
| 852 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 853 | adreno_regwrite(device, REG_CP_RB_WPTR, adreno_dev->ringbuffer.wptr); |
| 854 | } |
| 855 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 856 | /* Caller must hold the device mutex. */ |
| 857 | int adreno_idle(struct kgsl_device *device, unsigned int timeout) |
| 858 | { |
| 859 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 860 | struct adreno_ringbuffer *rb = &adreno_dev->ringbuffer; |
| 861 | unsigned int rbbm_status; |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 862 | unsigned long wait_timeout = |
| 863 | msecs_to_jiffies(adreno_dev->wait_timeout); |
Lynus Vaz | 284d104 | 2012-01-31 16:32:31 +0530 | [diff] [blame] | 864 | unsigned long wait_time; |
| 865 | unsigned long wait_time_part; |
| 866 | unsigned int msecs; |
| 867 | unsigned int msecs_first; |
| 868 | unsigned int msecs_part; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 869 | |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 870 | kgsl_cffdump_regpoll(device->id, |
| 871 | adreno_dev->gpudev->reg_rbbm_status << 2, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 872 | 0x00000000, 0x80000000); |
| 873 | /* first, wait until the CP has consumed all the commands in |
| 874 | * the ring buffer |
| 875 | */ |
| 876 | retry: |
| 877 | if (rb->flags & KGSL_FLAGS_STARTED) { |
Lynus Vaz | 284d104 | 2012-01-31 16:32:31 +0530 | [diff] [blame] | 878 | msecs = adreno_dev->wait_timeout; |
| 879 | msecs_first = (msecs <= 100) ? ((msecs + 4) / 5) : 100; |
| 880 | msecs_part = (msecs - msecs_first + 3) / 4; |
| 881 | wait_time = jiffies + wait_timeout; |
| 882 | wait_time_part = jiffies + msecs_to_jiffies(msecs_first); |
Jeremy Gebben | f859454 | 2012-01-13 12:27:21 -0700 | [diff] [blame] | 883 | adreno_poke(device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 884 | do { |
Lynus Vaz | 284d104 | 2012-01-31 16:32:31 +0530 | [diff] [blame] | 885 | if (time_after(jiffies, wait_time_part)) { |
| 886 | adreno_poke(device); |
| 887 | wait_time_part = jiffies + |
| 888 | msecs_to_jiffies(msecs_part); |
| 889 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 890 | GSL_RB_GET_READPTR(rb, &rb->rptr); |
| 891 | if (time_after(jiffies, wait_time)) { |
| 892 | KGSL_DRV_ERR(device, "rptr: %x, wptr: %x\n", |
| 893 | rb->rptr, rb->wptr); |
| 894 | goto err; |
| 895 | } |
| 896 | } while (rb->rptr != rb->wptr); |
| 897 | } |
| 898 | |
| 899 | /* now, wait for the GPU to finish its operations */ |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 900 | wait_time = jiffies + wait_timeout; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 901 | while (time_before(jiffies, wait_time)) { |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 902 | adreno_regread(device, adreno_dev->gpudev->reg_rbbm_status, |
| 903 | &rbbm_status); |
| 904 | if (adreno_is_a2xx(adreno_dev)) { |
| 905 | if (rbbm_status == 0x110) |
| 906 | return 0; |
| 907 | } else { |
| 908 | if (!(rbbm_status & 0x80000000)) |
| 909 | return 0; |
| 910 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 911 | } |
| 912 | |
| 913 | err: |
| 914 | KGSL_DRV_ERR(device, "spun too long waiting for RB to idle\n"); |
| 915 | if (!adreno_dump_and_recover(device)) { |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 916 | wait_time = jiffies + wait_timeout; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 917 | goto retry; |
| 918 | } |
| 919 | return -ETIMEDOUT; |
| 920 | } |
| 921 | |
| 922 | static unsigned int adreno_isidle(struct kgsl_device *device) |
| 923 | { |
| 924 | int status = false; |
| 925 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 926 | struct adreno_ringbuffer *rb = &adreno_dev->ringbuffer; |
| 927 | unsigned int rbbm_status; |
| 928 | |
Lucille Sylvester | 51b764d | 2011-12-15 16:51:52 -0700 | [diff] [blame] | 929 | WARN_ON(device->state == KGSL_STATE_INIT); |
| 930 | /* If the device isn't active, don't force it on. */ |
| 931 | if (device->state == KGSL_STATE_ACTIVE) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 932 | /* Is the ring buffer is empty? */ |
| 933 | GSL_RB_GET_READPTR(rb, &rb->rptr); |
| 934 | if (!device->active_cnt && (rb->rptr == rb->wptr)) { |
| 935 | /* Is the core idle? */ |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 936 | adreno_regread(device, |
| 937 | adreno_dev->gpudev->reg_rbbm_status, |
| 938 | &rbbm_status); |
| 939 | |
| 940 | if (adreno_is_a2xx(adreno_dev)) { |
| 941 | if (rbbm_status == 0x110) |
| 942 | status = true; |
| 943 | } else { |
| 944 | if (!(rbbm_status & 0x80000000)) |
| 945 | status = true; |
| 946 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 947 | } |
| 948 | } else { |
Jeremy Gebben | aeb2387 | 2011-12-13 15:58:24 -0700 | [diff] [blame] | 949 | status = true; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 950 | } |
| 951 | return status; |
| 952 | } |
| 953 | |
| 954 | /* Caller must hold the device mutex. */ |
| 955 | static int adreno_suspend_context(struct kgsl_device *device) |
| 956 | { |
| 957 | int status = 0; |
| 958 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 959 | |
| 960 | /* switch to NULL ctxt */ |
| 961 | if (adreno_dev->drawctxt_active != NULL) { |
| 962 | adreno_drawctxt_switch(adreno_dev, NULL, 0); |
| 963 | status = adreno_idle(device, KGSL_TIMEOUT_DEFAULT); |
| 964 | } |
| 965 | |
| 966 | return status; |
| 967 | } |
| 968 | |
Jeremy Gebben | 16e80fa | 2011-11-30 15:56:29 -0700 | [diff] [blame] | 969 | const struct kgsl_memdesc *adreno_find_region(struct kgsl_device *device, |
| 970 | unsigned int pt_base, |
| 971 | unsigned int gpuaddr, |
| 972 | unsigned int size) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 973 | { |
Jeremy Gebben | 16e80fa | 2011-11-30 15:56:29 -0700 | [diff] [blame] | 974 | struct kgsl_memdesc *result = NULL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 975 | struct kgsl_mem_entry *entry; |
| 976 | struct kgsl_process_private *priv; |
| 977 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 978 | struct adreno_ringbuffer *ringbuffer = &adreno_dev->ringbuffer; |
Jeremy Gebben | faabed7 | 2011-11-18 10:03:36 -0700 | [diff] [blame] | 979 | struct kgsl_context *context; |
| 980 | int next = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 981 | |
Jeremy Gebben | 16e80fa | 2011-11-30 15:56:29 -0700 | [diff] [blame] | 982 | if (kgsl_gpuaddr_in_memdesc(&ringbuffer->buffer_desc, gpuaddr, size)) |
| 983 | return &ringbuffer->buffer_desc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 984 | |
Jeremy Gebben | 16e80fa | 2011-11-30 15:56:29 -0700 | [diff] [blame] | 985 | if (kgsl_gpuaddr_in_memdesc(&ringbuffer->memptrs_desc, gpuaddr, size)) |
| 986 | return &ringbuffer->memptrs_desc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 987 | |
Jeremy Gebben | 16e80fa | 2011-11-30 15:56:29 -0700 | [diff] [blame] | 988 | if (kgsl_gpuaddr_in_memdesc(&device->memstore, gpuaddr, size)) |
| 989 | return &device->memstore; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 990 | |
| 991 | mutex_lock(&kgsl_driver.process_mutex); |
| 992 | list_for_each_entry(priv, &kgsl_driver.process_list, list) { |
Shubhraprakash Das | 767fdda | 2011-08-15 15:49:45 -0600 | [diff] [blame] | 993 | if (!kgsl_mmu_pt_equal(priv->pagetable, pt_base)) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 994 | continue; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 995 | spin_lock(&priv->mem_lock); |
| 996 | entry = kgsl_sharedmem_find_region(priv, gpuaddr, |
| 997 | sizeof(unsigned int)); |
| 998 | if (entry) { |
Jeremy Gebben | 16e80fa | 2011-11-30 15:56:29 -0700 | [diff] [blame] | 999 | result = &entry->memdesc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1000 | spin_unlock(&priv->mem_lock); |
| 1001 | mutex_unlock(&kgsl_driver.process_mutex); |
| 1002 | return result; |
| 1003 | } |
| 1004 | spin_unlock(&priv->mem_lock); |
| 1005 | } |
| 1006 | mutex_unlock(&kgsl_driver.process_mutex); |
| 1007 | |
Jeremy Gebben | faabed7 | 2011-11-18 10:03:36 -0700 | [diff] [blame] | 1008 | while (1) { |
| 1009 | struct adreno_context *adreno_context = NULL; |
Jeremy Gebben | faabed7 | 2011-11-18 10:03:36 -0700 | [diff] [blame] | 1010 | context = idr_get_next(&device->context_idr, &next); |
| 1011 | if (context == NULL) |
| 1012 | break; |
| 1013 | |
| 1014 | adreno_context = (struct adreno_context *)context->devctxt; |
| 1015 | |
Jeremy Gebben | 775d48b | 2011-12-12 17:10:19 -0700 | [diff] [blame] | 1016 | if (kgsl_mmu_pt_equal(adreno_context->pagetable, pt_base)) { |
| 1017 | struct kgsl_memdesc *desc; |
Jeremy Gebben | faabed7 | 2011-11-18 10:03:36 -0700 | [diff] [blame] | 1018 | |
Jeremy Gebben | 775d48b | 2011-12-12 17:10:19 -0700 | [diff] [blame] | 1019 | desc = &adreno_context->gpustate; |
| 1020 | if (kgsl_gpuaddr_in_memdesc(desc, gpuaddr, size)) { |
| 1021 | result = desc; |
| 1022 | return result; |
| 1023 | } |
Jeremy Gebben | faabed7 | 2011-11-18 10:03:36 -0700 | [diff] [blame] | 1024 | |
Jeremy Gebben | 775d48b | 2011-12-12 17:10:19 -0700 | [diff] [blame] | 1025 | desc = &adreno_context->context_gmem_shadow.gmemshadow; |
| 1026 | if (kgsl_gpuaddr_in_memdesc(desc, gpuaddr, size)) { |
| 1027 | result = desc; |
| 1028 | return result; |
| 1029 | } |
| 1030 | } |
Jeremy Gebben | faabed7 | 2011-11-18 10:03:36 -0700 | [diff] [blame] | 1031 | next = next + 1; |
| 1032 | } |
| 1033 | |
| 1034 | return NULL; |
Jeremy Gebben | 16e80fa | 2011-11-30 15:56:29 -0700 | [diff] [blame] | 1035 | |
| 1036 | } |
| 1037 | |
| 1038 | uint8_t *adreno_convertaddr(struct kgsl_device *device, unsigned int pt_base, |
| 1039 | unsigned int gpuaddr, unsigned int size) |
| 1040 | { |
| 1041 | const struct kgsl_memdesc *memdesc; |
| 1042 | |
| 1043 | memdesc = adreno_find_region(device, pt_base, gpuaddr, size); |
| 1044 | |
| 1045 | return memdesc ? kgsl_gpuaddr_to_vaddr(memdesc, gpuaddr) : NULL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | void adreno_regread(struct kgsl_device *device, unsigned int offsetwords, |
| 1049 | unsigned int *value) |
| 1050 | { |
| 1051 | unsigned int *reg; |
| 1052 | BUG_ON(offsetwords*sizeof(uint32_t) >= device->regspace.sizebytes); |
| 1053 | reg = (unsigned int *)(device->regspace.mmio_virt_base |
| 1054 | + (offsetwords << 2)); |
| 1055 | |
| 1056 | if (!in_interrupt()) |
| 1057 | kgsl_pre_hwaccess(device); |
| 1058 | |
| 1059 | /*ensure this read finishes before the next one. |
| 1060 | * i.e. act like normal readl() */ |
| 1061 | *value = __raw_readl(reg); |
| 1062 | rmb(); |
| 1063 | } |
| 1064 | |
| 1065 | void adreno_regwrite(struct kgsl_device *device, unsigned int offsetwords, |
| 1066 | unsigned int value) |
| 1067 | { |
| 1068 | unsigned int *reg; |
| 1069 | |
| 1070 | BUG_ON(offsetwords*sizeof(uint32_t) >= device->regspace.sizebytes); |
| 1071 | |
| 1072 | if (!in_interrupt()) |
| 1073 | kgsl_pre_hwaccess(device); |
| 1074 | |
| 1075 | kgsl_cffdump_regwrite(device->id, offsetwords << 2, value); |
| 1076 | reg = (unsigned int *)(device->regspace.mmio_virt_base |
| 1077 | + (offsetwords << 2)); |
| 1078 | |
| 1079 | /*ensure previous writes post before this one, |
| 1080 | * i.e. act like normal writel() */ |
| 1081 | wmb(); |
| 1082 | __raw_writel(value, reg); |
| 1083 | } |
| 1084 | |
| 1085 | static int kgsl_check_interrupt_timestamp(struct kgsl_device *device, |
| 1086 | unsigned int timestamp) |
| 1087 | { |
| 1088 | int status; |
| 1089 | unsigned int ref_ts, enableflag; |
| 1090 | |
| 1091 | status = kgsl_check_timestamp(device, timestamp); |
| 1092 | if (!status) { |
| 1093 | mutex_lock(&device->mutex); |
| 1094 | kgsl_sharedmem_readl(&device->memstore, &enableflag, |
| 1095 | KGSL_DEVICE_MEMSTORE_OFFSET(ts_cmp_enable)); |
| 1096 | mb(); |
| 1097 | |
| 1098 | if (enableflag) { |
| 1099 | kgsl_sharedmem_readl(&device->memstore, &ref_ts, |
| 1100 | KGSL_DEVICE_MEMSTORE_OFFSET(ref_wait_ts)); |
| 1101 | mb(); |
Jordan Crouse | e6239dd | 2011-11-17 13:39:21 -0700 | [diff] [blame] | 1102 | if (timestamp_cmp(ref_ts, timestamp) >= 0) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1103 | kgsl_sharedmem_writel(&device->memstore, |
| 1104 | KGSL_DEVICE_MEMSTORE_OFFSET(ref_wait_ts), |
| 1105 | timestamp); |
| 1106 | wmb(); |
| 1107 | } |
| 1108 | } else { |
| 1109 | unsigned int cmds[2]; |
| 1110 | kgsl_sharedmem_writel(&device->memstore, |
| 1111 | KGSL_DEVICE_MEMSTORE_OFFSET(ref_wait_ts), |
| 1112 | timestamp); |
| 1113 | enableflag = 1; |
| 1114 | kgsl_sharedmem_writel(&device->memstore, |
| 1115 | KGSL_DEVICE_MEMSTORE_OFFSET(ts_cmp_enable), |
| 1116 | enableflag); |
| 1117 | wmb(); |
| 1118 | /* submit a dummy packet so that even if all |
| 1119 | * commands upto timestamp get executed we will still |
| 1120 | * get an interrupt */ |
Jordan Crouse | 084427d | 2011-07-28 08:37:58 -0600 | [diff] [blame] | 1121 | cmds[0] = cp_type3_packet(CP_NOP, 1); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1122 | cmds[1] = 0; |
Jordan Crouse | e0ea762 | 2012-01-24 09:32:04 -0700 | [diff] [blame] | 1123 | adreno_ringbuffer_issuecmds(device, KGSL_CMD_FLAGS_NONE, |
| 1124 | &cmds[0], 2); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1125 | } |
| 1126 | mutex_unlock(&device->mutex); |
| 1127 | } |
| 1128 | |
| 1129 | return status; |
| 1130 | } |
| 1131 | |
| 1132 | /* |
Lucille Sylvester | 02e4629 | 2011-09-21 14:59:17 -0600 | [diff] [blame] | 1133 | wait_event_interruptible_timeout checks for the exit condition before |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1134 | placing a process in wait q. For conditional interrupts we expect the |
| 1135 | process to already be in its wait q when its exit condition checking |
| 1136 | function is called. |
| 1137 | */ |
Lucille Sylvester | 02e4629 | 2011-09-21 14:59:17 -0600 | [diff] [blame] | 1138 | #define kgsl_wait_event_interruptible_timeout(wq, condition, timeout, io)\ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1139 | ({ \ |
| 1140 | long __ret = timeout; \ |
Lucille Sylvester | 02e4629 | 2011-09-21 14:59:17 -0600 | [diff] [blame] | 1141 | if (io) \ |
| 1142 | __wait_io_event_interruptible_timeout(wq, condition, __ret);\ |
| 1143 | else \ |
| 1144 | __wait_event_interruptible_timeout(wq, condition, __ret);\ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1145 | __ret; \ |
| 1146 | }) |
| 1147 | |
| 1148 | /* MUST be called with the device mutex held */ |
| 1149 | static int adreno_waittimestamp(struct kgsl_device *device, |
| 1150 | unsigned int timestamp, |
| 1151 | unsigned int msecs) |
| 1152 | { |
| 1153 | long status = 0; |
Lucille Sylvester | 02e4629 | 2011-09-21 14:59:17 -0600 | [diff] [blame] | 1154 | uint io = 1; |
Lucille Sylvester | 596d4c2 | 2011-10-19 18:04:01 -0600 | [diff] [blame] | 1155 | static uint io_cnt; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1156 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
Lucille Sylvester | 02e4629 | 2011-09-21 14:59:17 -0600 | [diff] [blame] | 1157 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
Lynus Vaz | 06a9a90 | 2011-10-04 19:25:33 +0530 | [diff] [blame] | 1158 | int retries; |
| 1159 | unsigned int msecs_first; |
| 1160 | unsigned int msecs_part; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1161 | |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 1162 | /* Don't wait forever, set a max value for now */ |
| 1163 | if (msecs == -1) |
| 1164 | msecs = adreno_dev->wait_timeout; |
| 1165 | |
Jordan Crouse | e6239dd | 2011-11-17 13:39:21 -0700 | [diff] [blame] | 1166 | if (timestamp_cmp(timestamp, adreno_dev->ringbuffer.timestamp) > 0) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1167 | KGSL_DRV_ERR(device, "Cannot wait for invalid ts: %x, " |
| 1168 | "rb->timestamp: %x\n", |
| 1169 | timestamp, adreno_dev->ringbuffer.timestamp); |
| 1170 | status = -EINVAL; |
| 1171 | goto done; |
| 1172 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1173 | |
Lynus Vaz | 06a9a90 | 2011-10-04 19:25:33 +0530 | [diff] [blame] | 1174 | /* Keep the first timeout as 100msecs before rewriting |
| 1175 | * the WPTR. Less visible impact if the WPTR has not |
| 1176 | * been updated properly. |
| 1177 | */ |
| 1178 | msecs_first = (msecs <= 100) ? ((msecs + 4) / 5) : 100; |
| 1179 | msecs_part = (msecs - msecs_first + 3) / 4; |
| 1180 | for (retries = 0; retries < 5; retries++) { |
Jeremy Gebben | 6390483 | 2012-02-07 16:10:55 -0700 | [diff] [blame] | 1181 | if (kgsl_check_timestamp(device, timestamp)) { |
| 1182 | /* if the timestamp happens while we're not |
| 1183 | * waiting, there's a chance that an interrupt |
| 1184 | * will not be generated and thus the timestamp |
| 1185 | * work needs to be queued. |
Lynus Vaz | 06a9a90 | 2011-10-04 19:25:33 +0530 | [diff] [blame] | 1186 | */ |
Jeremy Gebben | 6390483 | 2012-02-07 16:10:55 -0700 | [diff] [blame] | 1187 | queue_work(device->work_queue, &device->ts_expired_ws); |
| 1188 | status = 0; |
| 1189 | goto done; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1190 | } |
Jeremy Gebben | 6390483 | 2012-02-07 16:10:55 -0700 | [diff] [blame] | 1191 | adreno_poke(device); |
| 1192 | io_cnt = (io_cnt + 1) % 100; |
| 1193 | if (io_cnt < |
| 1194 | pwr->pwrlevels[pwr->active_pwrlevel].io_fraction) |
| 1195 | io = 0; |
| 1196 | mutex_unlock(&device->mutex); |
| 1197 | /* We need to make sure that the process is |
| 1198 | * placed in wait-q before its condition is called |
| 1199 | */ |
| 1200 | status = kgsl_wait_event_interruptible_timeout( |
| 1201 | device->wait_queue, |
| 1202 | kgsl_check_interrupt_timestamp(device, |
| 1203 | timestamp), |
| 1204 | msecs_to_jiffies(retries ? |
| 1205 | msecs_part : msecs_first), io); |
| 1206 | mutex_lock(&device->mutex); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1207 | |
Jeremy Gebben | 6390483 | 2012-02-07 16:10:55 -0700 | [diff] [blame] | 1208 | if (status > 0) { |
| 1209 | /*completed before the wait finished */ |
| 1210 | status = 0; |
| 1211 | goto done; |
| 1212 | } else if (status < 0) { |
| 1213 | /*an error occurred*/ |
| 1214 | goto done; |
| 1215 | } |
| 1216 | /*this wait timed out*/ |
| 1217 | } |
| 1218 | status = -ETIMEDOUT; |
| 1219 | KGSL_DRV_ERR(device, |
| 1220 | "Device hang detected while waiting for timestamp: %x," |
| 1221 | "last submitted(rb->timestamp): %x, wptr: %x\n", |
| 1222 | timestamp, adreno_dev->ringbuffer.timestamp, |
| 1223 | adreno_dev->ringbuffer.wptr); |
| 1224 | if (!adreno_dump_and_recover(device)) { |
| 1225 | /* wait for idle after recovery as the |
| 1226 | * timestamp that this process wanted |
| 1227 | * to wait on may be invalid */ |
| 1228 | if (!adreno_idle(device, KGSL_TIMEOUT_DEFAULT)) |
| 1229 | status = 0; |
| 1230 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1231 | done: |
| 1232 | return (int)status; |
| 1233 | } |
| 1234 | |
| 1235 | static unsigned int adreno_readtimestamp(struct kgsl_device *device, |
| 1236 | enum kgsl_timestamp_type type) |
| 1237 | { |
| 1238 | unsigned int timestamp = 0; |
| 1239 | |
| 1240 | if (type == KGSL_TIMESTAMP_CONSUMED) |
| 1241 | adreno_regread(device, REG_CP_TIMESTAMP, ×tamp); |
| 1242 | else if (type == KGSL_TIMESTAMP_RETIRED) |
| 1243 | kgsl_sharedmem_readl(&device->memstore, ×tamp, |
| 1244 | KGSL_DEVICE_MEMSTORE_OFFSET(eoptimestamp)); |
| 1245 | rmb(); |
| 1246 | |
| 1247 | return timestamp; |
| 1248 | } |
| 1249 | |
| 1250 | static long adreno_ioctl(struct kgsl_device_private *dev_priv, |
| 1251 | unsigned int cmd, void *data) |
| 1252 | { |
| 1253 | int result = 0; |
| 1254 | struct kgsl_drawctxt_set_bin_base_offset *binbase; |
| 1255 | struct kgsl_context *context; |
| 1256 | |
| 1257 | switch (cmd) { |
| 1258 | case IOCTL_KGSL_DRAWCTXT_SET_BIN_BASE_OFFSET: |
| 1259 | binbase = data; |
| 1260 | |
| 1261 | context = kgsl_find_context(dev_priv, binbase->drawctxt_id); |
| 1262 | if (context) { |
| 1263 | adreno_drawctxt_set_bin_base_offset( |
| 1264 | dev_priv->device, context, binbase->offset); |
| 1265 | } else { |
| 1266 | result = -EINVAL; |
| 1267 | KGSL_DRV_ERR(dev_priv->device, |
| 1268 | "invalid drawctxt drawctxt_id %d " |
| 1269 | "device_id=%d\n", |
| 1270 | binbase->drawctxt_id, dev_priv->device->id); |
| 1271 | } |
| 1272 | break; |
| 1273 | |
| 1274 | default: |
| 1275 | KGSL_DRV_INFO(dev_priv->device, |
| 1276 | "invalid ioctl code %08x\n", cmd); |
Jeremy Gebben | c15b461 | 2012-01-09 09:44:11 -0700 | [diff] [blame^] | 1277 | result = -ENOIOCTLCMD; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1278 | break; |
| 1279 | } |
| 1280 | return result; |
| 1281 | |
| 1282 | } |
| 1283 | |
| 1284 | static inline s64 adreno_ticks_to_us(u32 ticks, u32 gpu_freq) |
| 1285 | { |
| 1286 | gpu_freq /= 1000000; |
| 1287 | return ticks / gpu_freq; |
| 1288 | } |
| 1289 | |
| 1290 | static void adreno_power_stats(struct kgsl_device *device, |
| 1291 | struct kgsl_power_stats *stats) |
| 1292 | { |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 1293 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1294 | struct kgsl_pwrctrl *pwr = &device->pwrctrl; |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 1295 | unsigned int cycles; |
| 1296 | |
| 1297 | /* Get the busy cycles counted since the counter was last reset */ |
| 1298 | /* Calling this function also resets and restarts the counter */ |
| 1299 | |
| 1300 | cycles = adreno_dev->gpudev->busy_cycles(adreno_dev); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1301 | |
| 1302 | /* In order to calculate idle you have to have run the algorithm * |
| 1303 | * at least once to get a start time. */ |
| 1304 | if (pwr->time != 0) { |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 1305 | s64 tmp = ktime_to_us(ktime_get()); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1306 | stats->total_time = tmp - pwr->time; |
| 1307 | pwr->time = tmp; |
Jordan Crouse | b4d31bd | 2012-02-01 22:11:12 -0700 | [diff] [blame] | 1308 | stats->busy_time = adreno_ticks_to_us(cycles, device->pwrctrl. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1309 | pwrlevels[device->pwrctrl.active_pwrlevel]. |
| 1310 | gpu_freq); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1311 | } else { |
| 1312 | stats->total_time = 0; |
| 1313 | stats->busy_time = 0; |
| 1314 | pwr->time = ktime_to_us(ktime_get()); |
| 1315 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1316 | } |
| 1317 | |
| 1318 | void adreno_irqctrl(struct kgsl_device *device, int state) |
| 1319 | { |
Jordan Crouse | a78c917 | 2011-07-11 13:14:09 -0600 | [diff] [blame] | 1320 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 1321 | adreno_dev->gpudev->irq_control(adreno_dev, state); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1322 | } |
| 1323 | |
Jordan Crouse | a0758f2 | 2011-12-07 11:19:22 -0700 | [diff] [blame] | 1324 | static unsigned int adreno_gpuid(struct kgsl_device *device) |
| 1325 | { |
| 1326 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 1327 | |
| 1328 | /* Standard KGSL gpuid format: |
| 1329 | * top word is 0x0002 for 2D or 0x0003 for 3D |
| 1330 | * Bottom word is core specific identifer |
| 1331 | */ |
| 1332 | |
| 1333 | return (0x0003 << 16) | ((int) adreno_dev->gpurev); |
| 1334 | } |
| 1335 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1336 | static const struct kgsl_functable adreno_functable = { |
| 1337 | /* Mandatory functions */ |
| 1338 | .regread = adreno_regread, |
| 1339 | .regwrite = adreno_regwrite, |
| 1340 | .idle = adreno_idle, |
| 1341 | .isidle = adreno_isidle, |
| 1342 | .suspend_context = adreno_suspend_context, |
| 1343 | .start = adreno_start, |
| 1344 | .stop = adreno_stop, |
| 1345 | .getproperty = adreno_getproperty, |
| 1346 | .waittimestamp = adreno_waittimestamp, |
| 1347 | .readtimestamp = adreno_readtimestamp, |
| 1348 | .issueibcmds = adreno_ringbuffer_issueibcmds, |
| 1349 | .ioctl = adreno_ioctl, |
| 1350 | .setup_pt = adreno_setup_pt, |
| 1351 | .cleanup_pt = adreno_cleanup_pt, |
| 1352 | .power_stats = adreno_power_stats, |
| 1353 | .irqctrl = adreno_irqctrl, |
Jordan Crouse | a0758f2 | 2011-12-07 11:19:22 -0700 | [diff] [blame] | 1354 | .gpuid = adreno_gpuid, |
Jordan Crouse | 156cfbc | 2012-01-24 09:32:04 -0700 | [diff] [blame] | 1355 | .snapshot = adreno_snapshot, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1356 | /* Optional functions */ |
| 1357 | .setstate = adreno_setstate, |
| 1358 | .drawctxt_create = adreno_drawctxt_create, |
| 1359 | .drawctxt_destroy = adreno_drawctxt_destroy, |
| 1360 | }; |
| 1361 | |
| 1362 | static struct platform_device_id adreno_id_table[] = { |
| 1363 | { DEVICE_3D0_NAME, (kernel_ulong_t)&device_3d0.dev, }, |
| 1364 | { }, |
| 1365 | }; |
| 1366 | MODULE_DEVICE_TABLE(platform, adreno_id_table); |
| 1367 | |
| 1368 | static struct platform_driver adreno_platform_driver = { |
| 1369 | .probe = adreno_probe, |
| 1370 | .remove = __devexit_p(adreno_remove), |
| 1371 | .suspend = kgsl_suspend_driver, |
| 1372 | .resume = kgsl_resume_driver, |
| 1373 | .id_table = adreno_id_table, |
| 1374 | .driver = { |
| 1375 | .owner = THIS_MODULE, |
| 1376 | .name = DEVICE_3D_NAME, |
| 1377 | .pm = &kgsl_pm_ops, |
| 1378 | } |
| 1379 | }; |
| 1380 | |
| 1381 | static int __init kgsl_3d_init(void) |
| 1382 | { |
| 1383 | return platform_driver_register(&adreno_platform_driver); |
| 1384 | } |
| 1385 | |
| 1386 | static void __exit kgsl_3d_exit(void) |
| 1387 | { |
| 1388 | platform_driver_unregister(&adreno_platform_driver); |
| 1389 | } |
| 1390 | |
| 1391 | module_init(kgsl_3d_init); |
| 1392 | module_exit(kgsl_3d_exit); |
| 1393 | |
| 1394 | MODULE_DESCRIPTION("3D Graphics driver"); |
| 1395 | MODULE_VERSION("1.2"); |
| 1396 | MODULE_LICENSE("GPL v2"); |
| 1397 | MODULE_ALIAS("platform:kgsl_3d"); |