Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b8070d1 authored by Thierry Reding's avatar Thierry Reding
Browse files

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: default avatarThierry Reding <treding@nvidia.com>
parent 6df633d0
Loading
Loading
Loading
Loading
+18 −8
Original line number Diff line number Diff line
@@ -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);
+20 −8
Original line number Diff line number Diff line
@@ -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;
}

@@ -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);
}
+7 −6
Original line number Diff line number Diff line
@@ -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);
@@ -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;
}

+2 −0
Original line number Diff line number Diff line
@@ -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);
	}
+7 −7
Original line number Diff line number Diff line
@@ -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:
@@ -207,7 +206,6 @@ static void host1x_debug_show_channel_cdma(struct host1x *host,
				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");
}

Loading