From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
To: linux-samsung-soc@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org, emil.l.velikov@gmail.com,
inki.dae@samsung.com,
Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Subject: [PATCH v2 7/9] exynos/fimg2d: make g2d_add_cmd() less heavy
Date: Tue, 8 Sep 2015 17:22:32 +0200 [thread overview]
Message-ID: <1441725754-27555-8-git-send-email-tjakobi@math.uni-bielefeld.de> (raw)
In-Reply-To: <1441725754-27555-1-git-send-email-tjakobi@math.uni-bielefeld.de>
The function currently checks for each added command
if an overflow of the corresponding command buffers
occurs, but none of the callers ever checks the
return value.
Since all callers are now converted to use
g2d_check_space() simplify the function.
(1) The overflow checks become asserts, so they're only
active for debug builds. This is fine since
g2d_add_cmd() is not part of the public API.
(2) Switch the return value to void.
(3) Explicitly state that the caller has to check
buffer space before calling g2d_add_cmd().
Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
---
exynos/exynos_fimg2d.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index fbc77a3..5873fe7 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <assert.h>
#include <sys/mman.h>
#include <linux/stddef.h>
@@ -172,8 +173,11 @@ static int g2d_validate_blending_op(
* @ctx: a pointer to g2d_context structure.
* @cmd: command data.
* @value: value data.
+ *
+ * The caller has to make sure that the commands buffers have enough space
+ * left to hold the command. Use g2d_check_space() to ensure this.
*/
-static int g2d_add_cmd(struct g2d_context *ctx, unsigned long cmd,
+static void g2d_add_cmd(struct g2d_context *ctx, unsigned long cmd,
unsigned long value)
{
switch (cmd & ~(G2D_BUF_USERPTR)) {
@@ -183,28 +187,20 @@ static int g2d_add_cmd(struct g2d_context *ctx, unsigned long cmd,
case DST_PLANE2_BASE_ADDR_REG:
case PAT_BASE_ADDR_REG:
case MASK_BASE_ADDR_REG:
- if (ctx->cmd_buf_nr >= G2D_MAX_GEM_CMD_NR) {
- fprintf(stderr, "Overflow cmd_gem size.\n");
- return -EINVAL;
- }
+ assert(ctx->cmd_buf_nr < G2D_MAX_GEM_CMD_NR);
ctx->cmd_buf[ctx->cmd_buf_nr].offset = cmd;
ctx->cmd_buf[ctx->cmd_buf_nr].data = value;
ctx->cmd_buf_nr++;
break;
default:
- if (ctx->cmd_nr >= G2D_MAX_CMD_NR) {
- fprintf(stderr, "Overflow cmd size.\n");
- return -EINVAL;
- }
+ assert(ctx->cmd_nr < G2D_MAX_CMD_NR);
ctx->cmd[ctx->cmd_nr].offset = cmd;
ctx->cmd[ctx->cmd_nr].data = value;
ctx->cmd_nr++;
break;
}
-
- return 0;
}
/*
--
2.0.5
next prev parent reply other threads:[~2015-09-08 15:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-08 15:22 [PATCH v2 0/9] drm/exynos: rewrite fimg2d error handling Tobias Jakobi
2015-09-08 15:22 ` [PATCH v2 1/9] exynos/fimg2d: fix empty buffer handling in g2d_flush() Tobias Jakobi
2015-09-08 15:22 ` [PATCH v2 2/9] exynos/fimg2d: simplify base address submission in g2d_scale_and_blend() Tobias Jakobi
2015-09-08 15:22 ` [PATCH v2 3/9] exynos/fimg2d: add g2d_check_space() Tobias Jakobi
2015-09-08 15:22 ` [PATCH v2 4/9] exynos/fimg2d: add g2d_validate_xyz() functions Tobias Jakobi
2015-09-08 15:22 ` [PATCH v2 5/9] exynos/fimg2d: remove default case from g2d_get_blend_op() Tobias Jakobi
2015-09-08 15:22 ` [PATCH v2 6/9] exynos/fimg2d: remove superfluous initialization of g2d_point_val Tobias Jakobi
2015-09-08 15:22 ` Tobias Jakobi [this message]
2015-09-08 15:22 ` [PATCH v2 8/9] exynos/fimg2d: add message prefix Tobias Jakobi
2015-09-08 15:22 ` [PATCH v2 9/9] exynos/fimg2d: remove g2d_context from public header Tobias Jakobi
2015-09-21 16:36 ` [PATCH v2 0/9] drm/exynos: rewrite fimg2d error handling Emil Velikov
2015-09-21 17:46 ` Tobias Jakobi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441725754-27555-8-git-send-email-tjakobi@math.uni-bielefeld.de \
--to=tjakobi@math.uni-bielefeld.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
--cc=inki.dae@samsung.com \
--cc=linux-samsung-soc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.