Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpu: host1x: Whitespace cleanup for readability

Insert a number of blank lines in places where they increase readability
of the code. Also collapse various variable declarations to shorten some
functions and finally rewrite some code for readability.

Signed-off-by: Thierry Reding <treding@nvidia.com>

+92 -43
+18 -8
drivers/gpu/host1x/cdma.c
··· 134 134 enum cdma_event event) 135 135 { 136 136 for (;;) { 137 + struct push_buffer *pb = &cdma->push_buffer; 137 138 unsigned int space; 138 139 139 - if (event == CDMA_EVENT_SYNC_QUEUE_EMPTY) 140 + switch (event) { 141 + case CDMA_EVENT_SYNC_QUEUE_EMPTY: 140 142 space = list_empty(&cdma->sync_queue) ? 1 : 0; 141 - else if (event == CDMA_EVENT_PUSH_BUFFER_SPACE) { 142 - struct push_buffer *pb = &cdma->push_buffer; 143 + break; 144 + 145 + case CDMA_EVENT_PUSH_BUFFER_SPACE: 143 146 space = host1x_pushbuffer_space(pb); 144 - } else { 147 + break; 148 + 149 + default: 145 150 WARN_ON(1); 146 151 return -EINVAL; 147 152 } ··· 164 159 mutex_lock(&cdma->lock); 165 160 continue; 166 161 } 162 + 167 163 cdma->event = event; 168 164 169 165 mutex_unlock(&cdma->lock); 170 166 down(&cdma->sem); 171 167 mutex_lock(&cdma->lock); 172 168 } 169 + 173 170 return 0; 174 171 } 175 172 ··· 241 234 /* Start timer on next pending syncpt */ 242 235 if (job->timeout) 243 236 cdma_start_timer_locked(cdma, job); 237 + 244 238 break; 245 239 } 246 240 ··· 257 249 struct push_buffer *pb = &cdma->push_buffer; 258 250 259 251 host1x_pushbuffer_pop(pb, job->num_slots); 252 + 260 253 if (cdma->event == CDMA_EVENT_PUSH_BUFFER_SPACE) 261 254 signal = true; 262 255 } ··· 279 270 void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma, 280 271 struct device *dev) 281 272 { 282 - u32 restart_addr; 283 - u32 syncpt_incrs; 284 - struct host1x_job *job = NULL; 285 - u32 syncpt_val; 286 273 struct host1x *host1x = cdma_to_host1x(cdma); 274 + u32 restart_addr, syncpt_incrs, syncpt_val; 275 + struct host1x_job *job = NULL; 287 276 288 277 syncpt_val = host1x_syncpt_load(cdma->timeout.syncpt); 289 278 ··· 385 378 err = host1x_pushbuffer_init(&cdma->push_buffer); 386 379 if (err) 387 380 return err; 381 + 388 382 return 0; 389 383 } 390 384 ··· 430 422 } 431 423 } 432 424 } 425 + 433 426 if (!cdma->running) 434 427 host1x_hw_cdma_start(host1x, cdma); 435 428 ··· 461 452 slots_free = host1x_cdma_wait_locked(cdma, 462 453 CDMA_EVENT_PUSH_BUFFER_SPACE); 463 454 } 455 + 464 456 cdma->slots_free = slots_free - 1; 465 457 cdma->slots_used++; 466 458 host1x_pushbuffer_push(pb, op1, op2);
+20 -8
drivers/gpu/host1x/debug.c
··· 39 39 va_start(args, fmt); 40 40 len = vsnprintf(o->buf, sizeof(o->buf), fmt, args); 41 41 va_end(args); 42 + 42 43 o->fn(o->ctx, o->buf, len); 43 44 } 44 45 ··· 49 48 struct output *o = data; 50 49 51 50 mutex_lock(&ch->reflock); 51 + 52 52 if (ch->refcount) { 53 53 mutex_lock(&ch->cdma.lock); 54 + 54 55 if (show_fifo) 55 56 host1x_hw_show_channel_fifo(m, ch, o); 57 + 56 58 host1x_hw_show_channel_cdma(m, ch, o); 57 59 mutex_unlock(&ch->cdma.lock); 58 60 } 61 + 59 62 mutex_unlock(&ch->reflock); 60 63 61 64 return 0; ··· 70 65 unsigned int i; 71 66 72 67 host1x_debug_output(o, "---- syncpts ----\n"); 68 + 73 69 for (i = 0; i < host1x_syncpt_nb_pts(m); i++) { 74 70 u32 max = host1x_syncpt_read_max(m->syncpt + i); 75 71 u32 min = host1x_syncpt_load(m->syncpt + i); ··· 124 118 .fn = write_to_seqfile, 125 119 .ctx = s 126 120 }; 121 + 127 122 show_all(s->private, &o); 123 + 128 124 return 0; 129 125 } 130 126 ··· 136 128 .fn = write_to_seqfile, 137 129 .ctx = s 138 130 }; 131 + 139 132 show_all_no_fifo(s->private, &o); 133 + 140 134 return 0; 141 135 } 142 136 ··· 148 138 } 149 139 150 140 static const struct file_operations host1x_debug_all_fops = { 151 - .open = host1x_debug_open_all, 152 - .read = seq_read, 153 - .llseek = seq_lseek, 154 - .release = single_release, 141 + .open = host1x_debug_open_all, 142 + .read = seq_read, 143 + .llseek = seq_lseek, 144 + .release = single_release, 155 145 }; 156 146 157 147 static int host1x_debug_open(struct inode *inode, struct file *file) ··· 160 150 } 161 151 162 152 static const struct file_operations host1x_debug_fops = { 163 - .open = host1x_debug_open, 164 - .read = seq_read, 165 - .llseek = seq_lseek, 166 - .release = single_release, 153 + .open = host1x_debug_open, 154 + .read = seq_read, 155 + .llseek = seq_lseek, 156 + .release = single_release, 167 157 }; 168 158 169 159 static void host1x_debugfs_init(struct host1x *host1x) ··· 215 205 struct output o = { 216 206 .fn = write_to_printk 217 207 }; 208 + 218 209 show_all(host1x, &o); 219 210 } 220 211 ··· 224 213 struct output o = { 225 214 .fn = write_to_printk 226 215 }; 216 + 227 217 show_syncpts(host1x, &o); 228 218 }
+7 -7
drivers/gpu/host1x/dev.c
··· 63 63 } 64 64 65 65 static const struct host1x_info host1x01_info = { 66 - .nb_channels = 8, 67 - .nb_pts = 32, 68 - .nb_mlocks = 16, 69 - .nb_bases = 8, 70 - .init = host1x01_init, 71 - .sync_offset = 0x3000, 72 - .dma_mask = DMA_BIT_MASK(32), 66 + .nb_channels = 8, 67 + .nb_pts = 32, 68 + .nb_mlocks = 16, 69 + .nb_bases = 8, 70 + .init = host1x01_init, 71 + .sync_offset = 0x3000, 72 + .dma_mask = DMA_BIT_MASK(32), 73 73 }; 74 74 75 75 static const struct host1x_info host1x02_info = {
+7 -6
drivers/gpu/host1x/hw/cdma_hw.c
··· 58 58 &pb->phys, getptr); 59 59 getptr = (getptr + 8) & (pb->size_bytes - 1); 60 60 } 61 + 61 62 wmb(); 62 63 } 63 64 ··· 163 162 struct host1x_channel *ch = cdma_to_channel(cdma); 164 163 165 164 mutex_lock(&cdma->lock); 165 + 166 166 if (cdma->running) { 167 167 host1x_cdma_wait_locked(cdma, CDMA_EVENT_SYNC_QUEUE_EMPTY); 168 168 host1x_ch_writel(ch, HOST1X_CHANNEL_DMACTRL_DMASTOP, 169 169 HOST1X_CHANNEL_DMACTRL); 170 170 cdma->running = false; 171 171 } 172 + 172 173 mutex_unlock(&cdma->lock); 173 174 } 174 175 ··· 234 231 */ 235 232 static void cdma_timeout_handler(struct work_struct *work) 236 233 { 234 + u32 prev_cmdproc, cmdproc_stop, syncpt_val; 237 235 struct host1x_cdma *cdma; 238 236 struct host1x *host1x; 239 237 struct host1x_channel *ch; 240 - 241 - u32 syncpt_val; 242 - 243 - u32 prev_cmdproc, cmdproc_stop; 244 238 245 239 cdma = container_of(to_delayed_work(work), struct host1x_cdma, 246 240 timeout.wq); ··· 278 278 } 279 279 280 280 dev_warn(host1x->dev, "%s: timeout: %u (%s), HW thresh %d, done %d\n", 281 - __func__, cdma->timeout.syncpt->id, cdma->timeout.syncpt->name, 282 - syncpt_val, cdma->timeout.syncpt_val); 281 + __func__, cdma->timeout.syncpt->id, cdma->timeout.syncpt->name, 282 + syncpt_val, cdma->timeout.syncpt_val); 283 283 284 284 /* stop HW, resetting channel/module */ 285 285 host1x_hw_cdma_freeze(host1x, cdma); ··· 306 306 { 307 307 if (cdma->timeout.initialized) 308 308 cancel_delayed_work(&cdma->timeout.wq); 309 + 309 310 cdma->timeout.initialized = false; 310 311 } 311 312
+2
drivers/gpu/host1x/hw/channel_hw.c
··· 46 46 */ 47 47 for (i = 0; i < words; i += TRACE_MAX_LENGTH) { 48 48 u32 num_words = min(words - i, TRACE_MAX_LENGTH); 49 + 49 50 offset += i * sizeof(u32); 50 51 51 52 trace_host1x_cdma_push_gather(dev_name(dev), bo, ··· 67 66 struct host1x_job_gather *g = &job->gathers[i]; 68 67 u32 op1 = host1x_opcode_gather(g->words); 69 68 u32 op2 = g->base + g->offset; 69 + 70 70 trace_write_gather(cdma, g->bo, g->offset, op1 & 0xffff); 71 71 host1x_cdma_push(cdma, op1, op2); 72 72 }
+7 -7
drivers/gpu/host1x/hw/debug_hw.c
··· 40 40 41 41 static unsigned int show_channel_command(struct output *o, u32 val) 42 42 { 43 - unsigned mask; 44 - unsigned subop; 43 + unsigned int mask, subop; 45 44 46 45 switch (val >> 28) { 47 46 case HOST1X_OPCODE_SETCLASS: ··· 199 200 200 201 if (HOST1X_SYNC_CBSTAT_CBCLASS_V(cbstat) == HOST1X_CLASS_HOST1X && 201 202 HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) == 202 - HOST1X_UCLASS_WAIT_SYNCPT) 203 + HOST1X_UCLASS_WAIT_SYNCPT) 203 204 host1x_debug_output(o, "waiting on syncpt %d val %d\n", 204 205 cbread >> 24, cbread & 0xffffff); 205 206 else if (HOST1X_SYNC_CBSTAT_CBCLASS_V(cbstat) == 206 - HOST1X_CLASS_HOST1X && 207 - HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) == 208 - HOST1X_UCLASS_WAIT_SYNCPT_BASE) { 209 - 207 + HOST1X_CLASS_HOST1X && 208 + HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) == 209 + HOST1X_UCLASS_WAIT_SYNCPT_BASE) { 210 210 base = (cbread >> 16) & 0xff; 211 211 baseval = 212 212 host1x_sync_readl(host, HOST1X_SYNC_SYNCPT_BASE(base)); ··· 291 293 unsigned int i; 292 294 293 295 host1x_debug_output(o, "---- mlocks ----\n"); 296 + 294 297 for (i = 0; i < host1x_syncpt_nb_mlocks(host); i++) { 295 298 u32 owner = 296 299 host1x_sync_readl(host, HOST1X_SYNC_MLOCK_OWNER(i)); ··· 303 304 else 304 305 host1x_debug_output(o, "%u: unlocked\n", i); 305 306 } 307 + 306 308 host1x_debug_output(o, "\n"); 307 309 } 308 310
+4 -2
drivers/gpu/host1x/hw/intr_hw.c
··· 72 72 } 73 73 } 74 74 75 - static int _host1x_intr_init_host_sync(struct host1x *host, u32 cpm, 76 - void (*syncpt_thresh_work)(struct work_struct *)) 75 + static int 76 + _host1x_intr_init_host_sync(struct host1x *host, u32 cpm, 77 + void (*syncpt_thresh_work)(struct work_struct *)) 77 78 { 78 79 unsigned int i; 79 80 int err; ··· 138 137 139 138 for (i = 0; i < host->info->nb_pts; i++) 140 139 cancel_work_sync(&host->syncpt[i].intr.work); 140 + 141 141 return 0; 142 142 } 143 143
+3 -2
drivers/gpu/host1x/hw/syncpt_hw.c
··· 88 88 if (!host1x_syncpt_client_managed(sp) && 89 89 host1x_syncpt_idle(sp)) 90 90 return -EINVAL; 91 + 91 92 host1x_sync_writel(host, BIT_MASK(sp->id), 92 93 HOST1X_SYNC_SYNCPT_CPU_INCR(reg_offset)); 93 94 wmb(); ··· 99 98 /* remove a wait pointed to by patch_addr */ 100 99 static int syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr) 101 100 { 102 - u32 override = host1x_class_host_wait_syncpt( 103 - HOST1X_SYNCPT_RESERVED, 0); 101 + u32 override = host1x_class_host_wait_syncpt(HOST1X_SYNCPT_RESERVED, 0); 104 102 105 103 *((u32 *)patch_addr) = override; 104 + 106 105 return 0; 107 106 } 108 107
+2 -1
drivers/gpu/host1x/job.c
··· 577 577 host1x_bo_unpin(unpin->bo, unpin->sgt); 578 578 host1x_bo_put(unpin->bo); 579 579 } 580 + 580 581 job->num_unpins = 0; 581 582 582 583 if (job->gather_copy_size) 583 584 dma_free_wc(job->channel->dev, job->gather_copy_size, 584 - job->gather_copy_mapped, job->gather_copy); 585 + job->gather_copy_mapped, job->gather_copy); 585 586 } 586 587 EXPORT_SYMBOL(host1x_job_unpin); 587 588
+22 -2
drivers/gpu/host1x/syncpt.c
··· 114 114 115 115 for (i = 0; i < host1x_syncpt_nb_pts(host); i++) 116 116 host1x_hw_syncpt_restore(host, sp_base + i); 117 + 117 118 for (i = 0; i < host1x_syncpt_nb_bases(host); i++) 118 119 host1x_hw_syncpt_restore_wait_base(host, sp_base + i); 120 + 119 121 wmb(); 120 122 } 121 123 ··· 183 181 static bool syncpt_load_min_is_expired(struct host1x_syncpt *sp, u32 thresh) 184 182 { 185 183 host1x_hw_syncpt_load(sp->host, sp); 184 + 186 185 return host1x_syncpt_is_expired(sp, thresh); 187 186 } 188 187 ··· 191 188 * Main entrypoint for syncpoint value waits. 192 189 */ 193 190 int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout, 194 - u32 *value) 191 + u32 *value) 195 192 { 196 193 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); 197 194 void *ref; ··· 206 203 if (host1x_syncpt_is_expired(sp, thresh)) { 207 204 if (value) 208 205 *value = host1x_syncpt_load(sp); 206 + 209 207 return 0; 210 208 } 211 209 ··· 215 211 if (host1x_syncpt_is_expired(sp, thresh)) { 216 212 if (value) 217 213 *value = val; 214 + 218 215 goto done; 219 216 } 220 217 ··· 246 241 /* wait for the syncpoint, or timeout, or signal */ 247 242 while (timeout) { 248 243 long check = min_t(long, SYNCPT_CHECK_PERIOD, timeout); 249 - int remain = wait_event_interruptible_timeout(wq, 244 + int remain; 245 + 246 + remain = wait_event_interruptible_timeout(wq, 250 247 syncpt_load_min_is_expired(sp, thresh), 251 248 check); 252 249 if (remain > 0 || host1x_syncpt_is_expired(sp, thresh)) { 253 250 if (value) 254 251 *value = host1x_syncpt_load(sp); 252 + 255 253 err = 0; 254 + 256 255 break; 257 256 } 257 + 258 258 if (remain < 0) { 259 259 err = remain; 260 260 break; 261 261 } 262 + 262 263 timeout -= check; 264 + 263 265 if (timeout && check_count <= MAX_STUCK_CHECK_COUNT) { 264 266 dev_warn(sp->host->dev, 265 267 "%s: syncpoint id %u (%s) stuck waiting %d, timeout=%ld\n", ··· 274 262 thresh, timeout); 275 263 276 264 host1x_debug_dump_syncpts(sp->host); 265 + 277 266 if (check_count == MAX_STUCK_CHECK_COUNT) 278 267 host1x_debug_dump(sp->host); 268 + 279 269 check_count++; 280 270 } 281 271 } 272 + 282 273 host1x_intr_put_ref(sp->host, sp->id, ref); 283 274 284 275 done: ··· 298 283 u32 future_val; 299 284 300 285 smp_rmb(); 286 + 301 287 current_val = (u32)atomic_read(&sp->min_val); 302 288 future_val = (u32)atomic_read(&sp->max_val); 303 289 ··· 397 381 unsigned long flags) 398 382 { 399 383 struct host1x *host = dev_get_drvdata(dev->parent); 384 + 400 385 return host1x_syncpt_alloc(host, dev, flags); 401 386 } 402 387 EXPORT_SYMBOL(host1x_syncpt_request); ··· 432 415 u32 host1x_syncpt_read_max(struct host1x_syncpt *sp) 433 416 { 434 417 smp_rmb(); 418 + 435 419 return (u32)atomic_read(&sp->max_val); 436 420 } 437 421 EXPORT_SYMBOL(host1x_syncpt_read_max); ··· 443 425 u32 host1x_syncpt_read_min(struct host1x_syncpt *sp) 444 426 { 445 427 smp_rmb(); 428 + 446 429 return (u32)atomic_read(&sp->min_val); 447 430 } 448 431 EXPORT_SYMBOL(host1x_syncpt_read_min); ··· 473 454 { 474 455 if (host->info->nb_pts < id) 475 456 return NULL; 457 + 476 458 return host->syncpt + id; 477 459 } 478 460 EXPORT_SYMBOL(host1x_syncpt_get);