[PATCH 7/9] drm/vc4: Add support for drawing 3D frames.

2015-12-02 Thread Emil Velikov
Hi Eric,

On 1 December 2015 at 20:35, Eric Anholt  wrote:
> The user submission is basically a pointer to a command list and a
> pointer to uniforms.  We copy those in to the kernel, validate and
> relocate them, and store the result in a GPU BO which we queue for
> execution.
>
> Signed-off-by: Eric Anholt 
> ---
>  drivers/gpu/drm/vc4/Makefile   |   7 +
>  drivers/gpu/drm/vc4/vc4_drv.c  |  15 +-
>  drivers/gpu/drm/vc4/vc4_drv.h  | 192 +++
>  drivers/gpu/drm/vc4/vc4_gem.c  | 640 ++
>  drivers/gpu/drm/vc4/vc4_irq.c  | 210 
>  drivers/gpu/drm/vc4/vc4_packet.h   | 399 ++
>  drivers/gpu/drm/vc4/vc4_render_cl.c| 631 ++
>  drivers/gpu/drm/vc4/vc4_trace.h|  63 +++
>  drivers/gpu/drm/vc4/vc4_trace_points.c |  14 +
>  drivers/gpu/drm/vc4/vc4_v3d.c  |  37 ++
>  drivers/gpu/drm/vc4/vc4_validate.c | 955 
> +
>  include/uapi/drm/vc4_drm.h | 141 +
>  12 files changed, 3303 insertions(+), 1 deletion(-)

Am I assuming correct that the above are the exact same ones copied in
mesa (and used only then simulator is used) ? In the short term
keeping the two in sync would be fine, although wondering if you have
plans to reshuffle things in the long term ?

Thanks
Emil


[PATCH 7/9] drm/vc4: Add support for drawing 3D frames.

2015-12-02 Thread Eric Anholt
Emil Velikov  writes:

> Hi Eric,
>
> On 1 December 2015 at 20:35, Eric Anholt  wrote:
>> The user submission is basically a pointer to a command list and a
>> pointer to uniforms.  We copy those in to the kernel, validate and
>> relocate them, and store the result in a GPU BO which we queue for
>> execution.
>>
>> Signed-off-by: Eric Anholt 
>> ---
>>  drivers/gpu/drm/vc4/Makefile   |   7 +
>>  drivers/gpu/drm/vc4/vc4_drv.c  |  15 +-
>>  drivers/gpu/drm/vc4/vc4_drv.h  | 192 +++
>>  drivers/gpu/drm/vc4/vc4_gem.c  | 640 ++
>>  drivers/gpu/drm/vc4/vc4_irq.c  | 210 
>>  drivers/gpu/drm/vc4/vc4_packet.h   | 399 ++
>>  drivers/gpu/drm/vc4/vc4_render_cl.c| 631 ++
>>  drivers/gpu/drm/vc4/vc4_trace.h|  63 +++
>>  drivers/gpu/drm/vc4/vc4_trace_points.c |  14 +
>>  drivers/gpu/drm/vc4/vc4_v3d.c  |  37 ++
>>  drivers/gpu/drm/vc4/vc4_validate.c | 955 
>> +
>>  include/uapi/drm/vc4_drm.h | 141 +
>>  12 files changed, 3303 insertions(+), 1 deletion(-)
>
> Am I assuming correct that the above are the exact same ones copied in
> mesa (and used only then simulator is used) ? In the short term
> keeping the two in sync would be fine, although wondering if you have
> plans to reshuffle things in the long term ?

This code is not exactly synced with Mesa, but I do sync between them on
a regular basis.  The in-Mesa copy is secondary, and just a way for me
to get testing done faster (in the simulation environment with gdb) than
I can in the kernel with printfs.
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: 



[PATCH 7/9] drm/vc4: Add support for drawing 3D frames.

2015-12-01 Thread Eric Anholt
The user submission is basically a pointer to a command list and a
pointer to uniforms.  We copy those in to the kernel, validate and
relocate them, and store the result in a GPU BO which we queue for
execution.

Signed-off-by: Eric Anholt 
---
 drivers/gpu/drm/vc4/Makefile   |   7 +
 drivers/gpu/drm/vc4/vc4_drv.c  |  15 +-
 drivers/gpu/drm/vc4/vc4_drv.h  | 192 +++
 drivers/gpu/drm/vc4/vc4_gem.c  | 640 ++
 drivers/gpu/drm/vc4/vc4_irq.c  | 210 
 drivers/gpu/drm/vc4/vc4_packet.h   | 399 ++
 drivers/gpu/drm/vc4/vc4_render_cl.c| 631 ++
 drivers/gpu/drm/vc4/vc4_trace.h|  63 +++
 drivers/gpu/drm/vc4/vc4_trace_points.c |  14 +
 drivers/gpu/drm/vc4/vc4_v3d.c  |  37 ++
 drivers/gpu/drm/vc4/vc4_validate.c | 955 +
 include/uapi/drm/vc4_drm.h | 141 +
 12 files changed, 3303 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/vc4/vc4_gem.c
 create mode 100644 drivers/gpu/drm/vc4/vc4_irq.c
 create mode 100644 drivers/gpu/drm/vc4/vc4_packet.h
 create mode 100644 drivers/gpu/drm/vc4/vc4_render_cl.c
 create mode 100644 drivers/gpu/drm/vc4/vc4_trace.h
 create mode 100644 drivers/gpu/drm/vc4/vc4_trace_points.c
 create mode 100644 drivers/gpu/drm/vc4/vc4_validate.c

diff --git a/drivers/gpu/drm/vc4/Makefile b/drivers/gpu/drm/vc4/Makefile
index e87a6f2..4c6a99f 100644
--- a/drivers/gpu/drm/vc4/Makefile
+++ b/drivers/gpu/drm/vc4/Makefile
@@ -8,12 +8,19 @@ vc4-y := \
vc4_crtc.o \
vc4_drv.o \
vc4_kms.o \
+   vc4_gem.o \
vc4_hdmi.o \
vc4_hvs.o \
+   vc4_irq.o \
vc4_plane.o \
+   vc4_render_cl.o \
+   vc4_trace_points.o \
vc4_v3d.o \
+   vc4_validate.o \
vc4_validate_shaders.o

 vc4-$(CONFIG_DEBUG_FS) += vc4_debugfs.o

 obj-$(CONFIG_DRM_VC4)  += vc4.o
+
+CFLAGS_vc4_trace_points.o := -I$(src)
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index db58d74..2cfee59 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -74,6 +74,9 @@ static const struct file_operations vc4_drm_fops = {
 };

 static const struct drm_ioctl_desc vc4_drm_ioctls[] = {
+   DRM_IOCTL_DEF_DRV(VC4_SUBMIT_CL, vc4_submit_cl_ioctl, 0),
+   DRM_IOCTL_DEF_DRV(VC4_WAIT_SEQNO, vc4_wait_seqno_ioctl, 0),
+   DRM_IOCTL_DEF_DRV(VC4_WAIT_BO, vc4_wait_bo_ioctl, 0),
DRM_IOCTL_DEF_DRV(VC4_CREATE_BO, vc4_create_bo_ioctl, 0),
DRM_IOCTL_DEF_DRV(VC4_MMAP_BO, vc4_mmap_bo_ioctl, 0),
DRM_IOCTL_DEF_DRV(VC4_CREATE_SHADER_BO, vc4_create_shader_bo_ioctl, 0),
@@ -83,10 +86,16 @@ static struct drm_driver vc4_drm_driver = {
.driver_features = (DRIVER_MODESET |
DRIVER_ATOMIC |
DRIVER_GEM |
+   DRIVER_HAVE_IRQ |
DRIVER_PRIME),
.lastclose = vc4_lastclose,
.preclose = vc4_drm_preclose,

+   .irq_handler = vc4_irq,
+   .irq_preinstall = vc4_irq_preinstall,
+   .irq_postinstall = vc4_irq_postinstall,
+   .irq_uninstall = vc4_irq_uninstall,
+
.enable_vblank = vc4_enable_vblank,
.disable_vblank = vc4_disable_vblank,
.get_vblank_counter = drm_vblank_count,
@@ -181,9 +190,11 @@ static int vc4_drm_bind(struct device *dev)
if (ret)
goto unref;

+   vc4_gem_init(drm);
+
ret = component_bind_all(dev, drm);
if (ret)
-   goto unref;
+   goto gem_destroy;

ret = drm_dev_register(drm, 0);
if (ret < 0)
@@ -207,6 +218,8 @@ unregister:
drm_dev_unregister(drm);
 unbind_all:
component_unbind_all(dev, drm);
+gem_destroy:
+   vc4_gem_destroy(drm);
 unref:
drm_dev_unref(drm);
vc4_bo_cache_destroy(drm);
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 8945463..a3dbfee 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -49,6 +49,48 @@ struct vc4_dev {

/* Protects bo_cache and the BO stats. */
struct mutex bo_lock;
+
+   /* Sequence number for the last job queued in job_list.
+* Starts at 0 (no jobs emitted).
+*/
+   uint64_t emit_seqno;
+
+   /* Sequence number for the last completed job on the GPU.
+* Starts at 0 (no jobs completed).
+*/
+   uint64_t finished_seqno;
+
+   /* List of all struct vc4_exec_info for jobs to be executed.
+* The first job in the list is the one currently programmed
+* into ct0ca/ct1ca for execution.
+*/
+   struct list_head job_list;
+   /* List of the finished vc4_exec_infos waiting to be freed by
+* job_done_work.
+*/
+   struct list_head job_done_list;
+   /* Spinlock used to synchronize the job_list and seqno
+* accesses between the IRQ handler