gpu: host1x: Whitespace cleanup for readability
authorThierry Reding <treding@nvidia.com>
Thu, 23 Jun 2016 09:35:50 +0000 (11:35 +0200)
committerThierry Reding <treding@nvidia.com>
Thu, 23 Jun 2016 09:59:30 +0000 (11:59 +0200)
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>
drivers/gpu/host1x/cdma.c
drivers/gpu/host1x/debug.c
drivers/gpu/host1x/dev.c
drivers/gpu/host1x/hw/cdma_hw.c
drivers/gpu/host1x/hw/channel_hw.c
drivers/gpu/host1x/hw/debug_hw.c
drivers/gpu/host1x/hw/intr_hw.c
drivers/gpu/host1x/hw/syncpt_hw.c
drivers/gpu/host1x/job.c
drivers/gpu/host1x/syncpt.c

index b83b0a04d9c594bbb01d612e6fab42d858dffa40..c5d82a8a2ec9c2498bf9e7ed96823cb14db8afae 100644 (file)
@@ -134,14 +134,19 @@ unsigned int host1x_cdma_wait_locked(struct host1x_cdma *cdma,
                                     enum cdma_event event)
 {
        for (;;) {
+               struct push_buffer *pb = &cdma->push_buffer;
                unsigned int space;
 
-               if (event == CDMA_EVENT_SYNC_QUEUE_EMPTY)
+               switch (event) {
+               case CDMA_EVENT_SYNC_QUEUE_EMPTY:
                        space = list_empty(&cdma->sync_queue) ? 1 : 0;
-               else if (event == CDMA_EVENT_PUSH_BUFFER_SPACE) {
-                       struct push_buffer *pb = &cdma->push_buffer;
+                       break;
+
+               case CDMA_EVENT_PUSH_BUFFER_SPACE:
                        space = host1x_pushbuffer_space(pb);
-               } else {
+                       break;
+
+               default:
                        WARN_ON(1);
                        return -EINVAL;
                }
@@ -159,12 +164,14 @@ unsigned int host1x_cdma_wait_locked(struct host1x_cdma *cdma,
                        mutex_lock(&cdma->lock);
                        continue;
                }
+
                cdma->event = event;
 
                mutex_unlock(&cdma->lock);
                down(&cdma->sem);
                mutex_lock(&cdma->lock);
        }
+
        return 0;
 }
 
@@ -234,6 +241,7 @@ static void update_cdma_locked(struct host1x_cdma *cdma)
                        /* Start timer on next pending syncpt */
                        if (job->timeout)
                                cdma_start_timer_locked(cdma, job);
+
                        break;
                }
 
@@ -249,6 +257,7 @@ static void update_cdma_locked(struct host1x_cdma *cdma)
                        struct push_buffer *pb = &cdma->push_buffer;
 
                        host1x_pushbuffer_pop(pb, job->num_slots);
+
                        if (cdma->event == CDMA_EVENT_PUSH_BUFFER_SPACE)
                                signal = true;
                }
@@ -270,11 +279,9 @@ static void update_cdma_locked(struct host1x_cdma *cdma)
 void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma,
                                   struct device *dev)
 {
-       u32 restart_addr;
-       u32 syncpt_incrs;
-       struct host1x_job *job = NULL;
-       u32 syncpt_val;
        struct host1x *host1x = cdma_to_host1x(cdma);
+       u32 restart_addr, syncpt_incrs, syncpt_val;
+       struct host1x_job *job = NULL;
 
        syncpt_val = host1x_syncpt_load(cdma->timeout.syncpt);
 
@@ -378,6 +385,7 @@ int host1x_cdma_init(struct host1x_cdma *cdma)
        err = host1x_pushbuffer_init(&cdma->push_buffer);
        if (err)
                return err;
+
        return 0;
 }
 
@@ -422,6 +430,7 @@ int host1x_cdma_begin(struct host1x_cdma *cdma, struct host1x_job *job)
                        }
                }
        }
+
        if (!cdma->running)
                host1x_hw_cdma_start(host1x, cdma);
 
@@ -452,6 +461,7 @@ void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2)
                slots_free = host1x_cdma_wait_locked(cdma,
                                                CDMA_EVENT_PUSH_BUFFER_SPACE);
        }
+
        cdma->slots_free = slots_free - 1;
        cdma->slots_used++;
        host1x_pushbuffer_push(pb, op1, op2);
index 7bb86b92ff096dd3f29b77e1437fa932aaa1d7ec..d9330fcc62ad5c88a6090e1c07eb0a8115019402 100644 (file)
@@ -39,6 +39,7 @@ void host1x_debug_output(struct output *o, const char *fmt, ...)
        va_start(args, fmt);
        len = vsnprintf(o->buf, sizeof(o->buf), fmt, args);
        va_end(args);
+
        o->fn(o->ctx, o->buf, len);
 }
 
@@ -48,13 +49,17 @@ static int show_channels(struct host1x_channel *ch, void *data, bool show_fifo)
        struct output *o = data;
 
        mutex_lock(&ch->reflock);
+
        if (ch->refcount) {
                mutex_lock(&ch->cdma.lock);
+
                if (show_fifo)
                        host1x_hw_show_channel_fifo(m, ch, o);
+
                host1x_hw_show_channel_cdma(m, ch, o);
                mutex_unlock(&ch->cdma.lock);
        }
+
        mutex_unlock(&ch->reflock);
 
        return 0;
@@ -65,6 +70,7 @@ static void show_syncpts(struct host1x *m, struct output *o)
        unsigned int i;
 
        host1x_debug_output(o, "---- syncpts ----\n");
+
        for (i = 0; i < host1x_syncpt_nb_pts(m); i++) {
                u32 max = host1x_syncpt_read_max(m->syncpt + i);
                u32 min = host1x_syncpt_load(m->syncpt + i);
@@ -118,7 +124,9 @@ static int host1x_debug_show_all(struct seq_file *s, void *unused)
                .fn = write_to_seqfile,
                .ctx = s
        };
+
        show_all(s->private, &o);
+
        return 0;
 }
 
@@ -128,7 +136,9 @@ static int host1x_debug_show(struct seq_file *s, void *unused)
                .fn = write_to_seqfile,
                .ctx = s
        };
+
        show_all_no_fifo(s->private, &o);
+
        return 0;
 }
 
@@ -138,10 +148,10 @@ static int host1x_debug_open_all(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations host1x_debug_all_fops = {
-       .open           = host1x_debug_open_all,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
+       .open = host1x_debug_open_all,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
 };
 
 static int host1x_debug_open(struct inode *inode, struct file *file)
@@ -150,10 +160,10 @@ static int host1x_debug_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations host1x_debug_fops = {
-       .open           = host1x_debug_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
+       .open = host1x_debug_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
 };
 
 static void host1x_debugfs_init(struct host1x *host1x)
@@ -205,6 +215,7 @@ void host1x_debug_dump(struct host1x *host1x)
        struct output o = {
                .fn = write_to_printk
        };
+
        show_all(host1x, &o);
 }
 
@@ -213,5 +224,6 @@ void host1x_debug_dump_syncpts(struct host1x *host1x)
        struct output o = {
                .fn = write_to_printk
        };
+
        show_syncpts(host1x, &o);
 }
index 320caf99cff49752060ea24de62b0070cb9b0336..a62317af76ad7b8b90593c2fda904a102e360701 100644 (file)
@@ -63,13 +63,13 @@ u32 host1x_ch_readl(struct host1x_channel *ch, u32 r)
 }
 
 static const struct host1x_info host1x01_info = {
-       .nb_channels    = 8,
-       .nb_pts         = 32,
-       .nb_mlocks      = 16,
-       .nb_bases       = 8,
-       .init           = host1x01_init,
-       .sync_offset    = 0x3000,
-       .dma_mask       = DMA_BIT_MASK(32),
+       .nb_channels = 8,
+       .nb_pts = 32,
+       .nb_mlocks = 16,
+       .nb_bases = 8,
+       .init = host1x01_init,
+       .sync_offset = 0x3000,
+       .dma_mask = DMA_BIT_MASK(32),
 };
 
 static const struct host1x_info host1x02_info = {
index e0db00613bca9834dd87b977ccd917f73f1b2385..5c39f1b111f7294a3a8d5f847723a252a61e13e8 100644 (file)
@@ -58,6 +58,7 @@ static void cdma_timeout_cpu_incr(struct host1x_cdma *cdma, u32 getptr,
                        &pb->phys, getptr);
                getptr = (getptr + 8) & (pb->size_bytes - 1);
        }
+
        wmb();
 }
 
@@ -162,12 +163,14 @@ static void cdma_stop(struct host1x_cdma *cdma)
        struct host1x_channel *ch = cdma_to_channel(cdma);
 
        mutex_lock(&cdma->lock);
+
        if (cdma->running) {
                host1x_cdma_wait_locked(cdma, CDMA_EVENT_SYNC_QUEUE_EMPTY);
                host1x_ch_writel(ch, HOST1X_CHANNEL_DMACTRL_DMASTOP,
                                 HOST1X_CHANNEL_DMACTRL);
                cdma->running = false;
        }
+
        mutex_unlock(&cdma->lock);
 }
 
@@ -231,14 +234,11 @@ static void cdma_resume(struct host1x_cdma *cdma, u32 getptr)
  */
 static void cdma_timeout_handler(struct work_struct *work)
 {
+       u32 prev_cmdproc, cmdproc_stop, syncpt_val;
        struct host1x_cdma *cdma;
        struct host1x *host1x;
        struct host1x_channel *ch;
 
-       u32 syncpt_val;
-
-       u32 prev_cmdproc, cmdproc_stop;
-
        cdma = container_of(to_delayed_work(work), struct host1x_cdma,
                            timeout.wq);
        host1x = cdma_to_host1x(cdma);
@@ -278,8 +278,8 @@ static void cdma_timeout_handler(struct work_struct *work)
        }
 
        dev_warn(host1x->dev, "%s: timeout: %u (%s), HW thresh %d, done %d\n",
-               __func__, cdma->timeout.syncpt->id, cdma->timeout.syncpt->name,
-               syncpt_val, cdma->timeout.syncpt_val);
+                __func__, cdma->timeout.syncpt->id, cdma->timeout.syncpt->name,
+                syncpt_val, cdma->timeout.syncpt_val);
 
        /* stop HW, resetting channel/module */
        host1x_hw_cdma_freeze(host1x, cdma);
@@ -306,6 +306,7 @@ static void cdma_timeout_destroy(struct host1x_cdma *cdma)
 {
        if (cdma->timeout.initialized)
                cancel_delayed_work(&cdma->timeout.wq);
+
        cdma->timeout.initialized = false;
 }
 
index f359b7ec5e3ceddce83a76798ba286a3f74b972c..5e8df78b7acd82acbd2539671c167527fc512828 100644 (file)
@@ -46,6 +46,7 @@ static void trace_write_gather(struct host1x_cdma *cdma, struct host1x_bo *bo,
                 */
                for (i = 0; i < words; i += TRACE_MAX_LENGTH) {
                        u32 num_words = min(words - i, TRACE_MAX_LENGTH);
+
                        offset += i * sizeof(u32);
 
                        trace_host1x_cdma_push_gather(dev_name(dev), bo,
@@ -66,6 +67,7 @@ static void submit_gathers(struct host1x_job *job)
                struct host1x_job_gather *g = &job->gathers[i];
                u32 op1 = host1x_opcode_gather(g->words);
                u32 op2 = g->base + g->offset;
+
                trace_write_gather(cdma, g->bo, g->offset, op1 & 0xffff);
                host1x_cdma_push(cdma, op1, op2);
        }
index d2c96dd630ea4712bf570823c680b2213897105b..7a4a3286e4a7c284e17e4940a846143730f2ad2d 100644 (file)
@@ -40,8 +40,7 @@ enum {
 
 static unsigned int show_channel_command(struct output *o, u32 val)
 {
-       unsigned mask;
-       unsigned subop;
+       unsigned int mask, subop;
 
        switch (val >> 28) {
        case HOST1X_OPCODE_SETCLASS:
@@ -200,14 +199,13 @@ static void host1x_debug_show_channel_cdma(struct host1x *host,
 
        if (HOST1X_SYNC_CBSTAT_CBCLASS_V(cbstat) == HOST1X_CLASS_HOST1X &&
            HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) ==
-           HOST1X_UCLASS_WAIT_SYNCPT)
+                       HOST1X_UCLASS_WAIT_SYNCPT)
                host1x_debug_output(o, "waiting on syncpt %d val %d\n",
                                    cbread >> 24, cbread & 0xffffff);
        else if (HOST1X_SYNC_CBSTAT_CBCLASS_V(cbstat) ==
-          HOST1X_CLASS_HOST1X &&
-          HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) ==
-          HOST1X_UCLASS_WAIT_SYNCPT_BASE) {
-
+                               HOST1X_CLASS_HOST1X &&
+                HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) ==
+                               HOST1X_UCLASS_WAIT_SYNCPT_BASE) {
                base = (cbread >> 16) & 0xff;
                baseval =
                        host1x_sync_readl(host, HOST1X_SYNC_SYNCPT_BASE(base));
@@ -293,6 +291,7 @@ static void host1x_debug_show_mlocks(struct host1x *host, struct output *o)
        unsigned int i;
 
        host1x_debug_output(o, "---- mlocks ----\n");
+
        for (i = 0; i < host1x_syncpt_nb_mlocks(host); i++) {
                u32 owner =
                        host1x_sync_readl(host, HOST1X_SYNC_MLOCK_OWNER(i));
@@ -304,6 +303,7 @@ static void host1x_debug_show_mlocks(struct host1x *host, struct output *o)
                else
                        host1x_debug_output(o, "%u: unlocked\n", i);
        }
+
        host1x_debug_output(o, "\n");
 }
 
index f50c68957c12e6c41376e4251c0bd3069d89ec11..dacb8009a605860a3153f1b2b00cf514007fb07b 100644 (file)
@@ -72,8 +72,9 @@ static void _host1x_intr_disable_all_syncpt_intrs(struct host1x *host)
        }
 }
 
-static int _host1x_intr_init_host_sync(struct host1x *host, u32 cpm,
-       void (*syncpt_thresh_work)(struct work_struct *))
+static int
+_host1x_intr_init_host_sync(struct host1x *host, u32 cpm,
+                           void (*syncpt_thresh_work)(struct work_struct *))
 {
        unsigned int i;
        int err;
@@ -137,6 +138,7 @@ static int _host1x_free_syncpt_irq(struct host1x *host)
 
        for (i = 0; i < host->info->nb_pts; i++)
                cancel_work_sync(&host->syncpt[i].intr.work);
+
        return 0;
 }
 
index 310f24fcd2619da071532e03b325fb1734646390..c93f74fcce72cf4a22ce98fc1a277a7e480d937f 100644 (file)
@@ -88,6 +88,7 @@ static int syncpt_cpu_incr(struct host1x_syncpt *sp)
        if (!host1x_syncpt_client_managed(sp) &&
            host1x_syncpt_idle(sp))
                return -EINVAL;
+
        host1x_sync_writel(host, BIT_MASK(sp->id),
                           HOST1X_SYNC_SYNCPT_CPU_INCR(reg_offset));
        wmb();
@@ -98,10 +99,10 @@ static int syncpt_cpu_incr(struct host1x_syncpt *sp)
 /* remove a wait pointed to by patch_addr */
 static int syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr)
 {
-       u32 override = host1x_class_host_wait_syncpt(
-               HOST1X_SYNCPT_RESERVED, 0);
+       u32 override = host1x_class_host_wait_syncpt(HOST1X_SYNCPT_RESERVED, 0);
 
        *((u32 *)patch_addr) = override;
+
        return 0;
 }
 
index 1bff367f8830c2108c38c1916e72b16620746aa9..a91b7c4a6110f8b0bfe74589e32a226fefe7f341 100644 (file)
@@ -577,11 +577,12 @@ void host1x_job_unpin(struct host1x_job *job)
                host1x_bo_unpin(unpin->bo, unpin->sgt);
                host1x_bo_put(unpin->bo);
        }
+
        job->num_unpins = 0;
 
        if (job->gather_copy_size)
                dma_free_wc(job->channel->dev, job->gather_copy_size,
-                           job->gather_copy_mapped, job->gather_copy);
+                           job->gather_copy_mapped, job->gather_copy);
 }
 EXPORT_SYMBOL(host1x_job_unpin);
 
index 7c4848f4ce5933a57114771be02c433ba6234de1..73b43c25b04b3b1c50aaed7061de60037dfe4d9f 100644 (file)
@@ -114,8 +114,10 @@ void host1x_syncpt_restore(struct host1x *host)
 
        for (i = 0; i < host1x_syncpt_nb_pts(host); i++)
                host1x_hw_syncpt_restore(host, sp_base + i);
+
        for (i = 0; i < host1x_syncpt_nb_bases(host); i++)
                host1x_hw_syncpt_restore_wait_base(host, sp_base + i);
+
        wmb();
 }
 
@@ -181,6 +183,7 @@ EXPORT_SYMBOL(host1x_syncpt_incr);
 static bool syncpt_load_min_is_expired(struct host1x_syncpt *sp, u32 thresh)
 {
        host1x_hw_syncpt_load(sp->host, sp);
+
        return host1x_syncpt_is_expired(sp, thresh);
 }
 
@@ -188,7 +191,7 @@ static bool syncpt_load_min_is_expired(struct host1x_syncpt *sp, u32 thresh)
  * Main entrypoint for syncpoint value waits.
  */
 int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
-                       u32 *value)
+                      u32 *value)
 {
        DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
        void *ref;
@@ -203,6 +206,7 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
        if (host1x_syncpt_is_expired(sp, thresh)) {
                if (value)
                        *value = host1x_syncpt_load(sp);
+
                return 0;
        }
 
@@ -211,6 +215,7 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
        if (host1x_syncpt_is_expired(sp, thresh)) {
                if (value)
                        *value = val;
+
                goto done;
        }
 
@@ -241,20 +246,27 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
        /* wait for the syncpoint, or timeout, or signal */
        while (timeout) {
                long check = min_t(long, SYNCPT_CHECK_PERIOD, timeout);
-               int remain = wait_event_interruptible_timeout(wq,
+               int remain;
+
+               remain = wait_event_interruptible_timeout(wq,
                                syncpt_load_min_is_expired(sp, thresh),
                                check);
                if (remain > 0 || host1x_syncpt_is_expired(sp, thresh)) {
                        if (value)
                                *value = host1x_syncpt_load(sp);
+
                        err = 0;
+
                        break;
                }
+
                if (remain < 0) {
                        err = remain;
                        break;
                }
+
                timeout -= check;
+
                if (timeout && check_count <= MAX_STUCK_CHECK_COUNT) {
                        dev_warn(sp->host->dev,
                                "%s: syncpoint id %u (%s) stuck waiting %d, timeout=%ld\n",
@@ -262,11 +274,14 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
                                 thresh, timeout);
 
                        host1x_debug_dump_syncpts(sp->host);
+
                        if (check_count == MAX_STUCK_CHECK_COUNT)
                                host1x_debug_dump(sp->host);
+
                        check_count++;
                }
        }
+
        host1x_intr_put_ref(sp->host, sp->id, ref);
 
 done:
@@ -283,6 +298,7 @@ bool host1x_syncpt_is_expired(struct host1x_syncpt *sp, u32 thresh)
        u32 future_val;
 
        smp_rmb();
+
        current_val = (u32)atomic_read(&sp->min_val);
        future_val = (u32)atomic_read(&sp->max_val);
 
@@ -381,6 +397,7 @@ struct host1x_syncpt *host1x_syncpt_request(struct device *dev,
                                            unsigned long flags)
 {
        struct host1x *host = dev_get_drvdata(dev->parent);
+
        return host1x_syncpt_alloc(host, dev, flags);
 }
 EXPORT_SYMBOL(host1x_syncpt_request);
@@ -415,6 +432,7 @@ void host1x_syncpt_deinit(struct host1x *host)
 u32 host1x_syncpt_read_max(struct host1x_syncpt *sp)
 {
        smp_rmb();
+
        return (u32)atomic_read(&sp->max_val);
 }
 EXPORT_SYMBOL(host1x_syncpt_read_max);
@@ -425,6 +443,7 @@ EXPORT_SYMBOL(host1x_syncpt_read_max);
 u32 host1x_syncpt_read_min(struct host1x_syncpt *sp)
 {
        smp_rmb();
+
        return (u32)atomic_read(&sp->min_val);
 }
 EXPORT_SYMBOL(host1x_syncpt_read_min);
@@ -454,6 +473,7 @@ struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, unsigned int id)
 {
        if (host->info->nb_pts < id)
                return NULL;
+
        return host->syncpt + id;
 }
 EXPORT_SYMBOL(host1x_syncpt_get);