drm/etnaviv: extend etnaviv_gpu_cmdbuf_new(..) with nr_pmrs
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Sun, 24 Sep 2017 13:15:24 +0000 (15:15 +0200)
committerLucas Stach <l.stach@pengutronix.de>
Tue, 10 Oct 2017 09:45:43 +0000 (11:45 +0200)
This commits extends etnaviv_gpu_cmdbuf_new(..) to define the number
of struct etnaviv_perfmon elements gets used.

Changes from v1 -> v2:
- make use of goto as requested by Lucas

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.c
drivers/gpu/drm/etnaviv/etnaviv_cmdbuf.h
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.c

index 633e0f07cbac175df737e62113a6a351219ef899..66ac79558bbd4e2d8afb6f83f9d9949d7e93c2c5 100644 (file)
@@ -19,6 +19,7 @@
 #include "etnaviv_cmdbuf.h"
 #include "etnaviv_gpu.h"
 #include "etnaviv_mmu.h"
+#include "etnaviv_perfmon.h"
 
 #define SUBALLOC_SIZE          SZ_256K
 #define SUBALLOC_GRANULE       SZ_4K
@@ -87,9 +88,10 @@ void etnaviv_cmdbuf_suballoc_destroy(struct etnaviv_cmdbuf_suballoc *suballoc)
 
 struct etnaviv_cmdbuf *
 etnaviv_cmdbuf_new(struct etnaviv_cmdbuf_suballoc *suballoc, u32 size,
-                  size_t nr_bos)
+                  size_t nr_bos, size_t nr_pmrs)
 {
        struct etnaviv_cmdbuf *cmdbuf;
+       struct etnaviv_perfmon_request *pmrs;
        size_t sz = size_vstruct(nr_bos, sizeof(cmdbuf->bo_map[0]),
                                 sizeof(*cmdbuf));
        int granule_offs, order, ret;
@@ -98,6 +100,12 @@ etnaviv_cmdbuf_new(struct etnaviv_cmdbuf_suballoc *suballoc, u32 size,
        if (!cmdbuf)
                return NULL;
 
+       sz = sizeof(*pmrs) * nr_pmrs;
+       pmrs = kzalloc(sz, GFP_KERNEL);
+       if (!pmrs)
+               goto out_free_cmdbuf;
+
+       cmdbuf->pmrs = pmrs;
        cmdbuf->suballoc = suballoc;
        cmdbuf->size = size;
 
@@ -124,6 +132,10 @@ retry:
        cmdbuf->vaddr = suballoc->vaddr + cmdbuf->suballoc_offset;
 
        return cmdbuf;
+
+out_free_cmdbuf:
+       kfree(cmdbuf);
+       return NULL;
 }
 
 void etnaviv_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf)
@@ -139,6 +151,7 @@ void etnaviv_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf)
        suballoc->free_space = 1;
        mutex_unlock(&suballoc->lock);
        wake_up_all(&suballoc->free_event);
+       kfree(cmdbuf->pmrs);
        kfree(cmdbuf);
 }
 
index 1b549f0d59a0a35baf426cc3e14e050b9e2a0b69..b6348b9f2a9ddb9959dd51dc310e86f1be4d53e8 100644 (file)
@@ -53,7 +53,7 @@ void etnaviv_cmdbuf_suballoc_destroy(struct etnaviv_cmdbuf_suballoc *suballoc);
 
 struct etnaviv_cmdbuf *
 etnaviv_cmdbuf_new(struct etnaviv_cmdbuf_suballoc *suballoc, u32 size,
-                  size_t nr_bos);
+                  size_t nr_bos, size_t nr_pmrs);
 void etnaviv_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf);
 
 u32 etnaviv_cmdbuf_get_va(struct etnaviv_cmdbuf *buf);
index 026ef4e02f85cab130586c5c0b8c9b97bd0101bb..41abdfc7cb0090abec727476d9c966e2f9354550 100644 (file)
@@ -350,7 +350,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
        stream = kvmalloc_array(1, args->stream_size, GFP_KERNEL);
        cmdbuf = etnaviv_cmdbuf_new(gpu->cmdbuf_suballoc,
                                    ALIGN(args->stream_size, 8) + 8,
-                                   args->nr_bos);
+                                   args->nr_bos, 0);
        if (!bos || !relocs || !stream || !cmdbuf) {
                ret = -ENOMEM;
                goto err_submit_cmds;
index 8d961bc238d4faa69687ef74f958c28ee354a63f..7b61071af0def74e77ab7ab0bda45a252116718a 100644 (file)
@@ -726,7 +726,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
        }
 
        /* Create buffer: */
-       gpu->buffer = etnaviv_cmdbuf_new(gpu->cmdbuf_suballoc, PAGE_SIZE, 0);
+       gpu->buffer = etnaviv_cmdbuf_new(gpu->cmdbuf_suballoc, PAGE_SIZE, 0, 0);
        if (!gpu->buffer) {
                ret = -ENOMEM;
                dev_err(gpu->dev, "could not create command buffer\n");