Skip to contentSkip to conversation

V3D DRM driver

PATCH In review Eric Anholt 3 participants 6 messages Apr 30, 2018 – May 2, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 cover V3D DRM driver

This is a resend of the V3D driver for the DT binding nitpicks.

Eric Anholt (2):
dt-bindings: Add a new binding for Broadcom V3D 3.x and newer GPUs. drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+

 .../devicetree/bindings/gpu/brcm,bcm-v3d.txt  |  28 +
 Documentation/gpu/drivers.rst                 |   1 +
 MAINTAINERS                                   |   8 +
 drivers/gpu/drm/Kconfig                       |   2 +
 drivers/gpu/drm/Makefile                      |   1 +
 drivers/gpu/drm/v3d/Kconfig                   |   9 +
 drivers/gpu/drm/v3d/Makefile                  |  18 +
 drivers/gpu/drm/v3d/v3d_bo.c                  | 379 ++++++++++
 drivers/gpu/drm/v3d/v3d_debugfs.c             | 191 +++++
 drivers/gpu/drm/v3d/v3d_drv.c                 | 371 ++++++++++
 drivers/gpu/drm/v3d/v3d_drv.h                 | 294 ++++++++
 drivers/gpu/drm/v3d/v3d_fence.c               |  58 ++
 drivers/gpu/drm/v3d/v3d_gem.c                 | 663 ++++++++++++++++++
 drivers/gpu/drm/v3d/v3d_irq.c                 | 206 ++++++
 drivers/gpu/drm/v3d/v3d_mmu.c                 | 122 ++++
 drivers/gpu/drm/v3d/v3d_regs.h                | 295 ++++++++
 drivers/gpu/drm/v3d/v3d_sched.c               | 228 ++++++
 drivers/gpu/drm/v3d/v3d_trace.h               |  82 +++
 drivers/gpu/drm/v3d/v3d_trace_points.c        |   9 +
 include/uapi/drm/v3d_drm.h                    | 191 +++++
 20 files changed, 3156 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.txt
 create mode 100644 drivers/gpu/drm/v3d/Kconfig
 create mode 100644 drivers/gpu/drm/v3d/Makefile
 create mode 100644 drivers/gpu/drm/v3d/v3d_bo.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_debugfs.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_drv.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_drv.h
 create mode 100644 drivers/gpu/drm/v3d/v3d_fence.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_gem.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_irq.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_mmu.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_regs.h
 create mode 100644 drivers/gpu/drm/v3d/v3d_sched.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_trace.h
 create mode 100644 drivers/gpu/drm/v3d/v3d_trace_points.c
 create mode 100644 include/uapi/drm/v3d_drm.h
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v3 1/2 dt-bindings: Add a new binding for Broadcom V3D 3.x and newer GPUs.

These OpenGL ES GPUs are present in the 7268 and 7278 set top box chips.

v2: no changes
v3: move to gpu/, fix typo

---
 .../devicetree/bindings/gpu/brcm,bcm-v3d.txt  | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.txt
Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.txt new file +28 -0
new file mode 100644
index 000000000000..c907aa8dd755
@@ -0,0 +1,28 @@
+Broadcom V3D GPU
+
+Only the Broadcom V3D 3.x and newer GPUs are covered by this binding.
+For V3D 2.x, see brcm,bcm-vc4.txt.
+
+Required properties:
+- compatible:	Should be "brcm,7268-v3d" or "brcm,7278-v3d"
+- reg:		Physical base addresses and lengths of the register areas
+- reg-names:	Names for the register areas.  The "hub", "bridge", and "core0"
+		  register areas are always required.  The "gca" register area
+		  is required if the GCA cache controller is present.
+- interrupts:	The interrupt numbers.  The first interrupt is for the hub,
+		  while the following interrupts are for the cores.
+		  See bindings/interrupt-controller/interrupts.txt
+
+Optional properties:
+- clocks:	The core clock the unit runs on
+
+v3d {
+	compatible = "brcm,7268-v3d";
+	reg = <0xf1204000 0x100>,
+	      <0xf1200000 0x4000>,
+	      <0xf1208000 0x4000>,
+	      <0xf1204100 0x100>;
+	reg-names = "bridge", "hub", "core0", "gca";
+	interrupts = <0 78 4>,
+		     <0 77 4>;
+};
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH v3 2/2 drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+

In reply to Eric Anholt

This driver will be used to support Mesa on the Broadcom 7268 and 7278 platforms.

V3D 3.3 introduces an MMU, which means we no longer need CMA or vc4's complicated CL/shader validation scheme. This massively changes the GEM behavior, so I've forked off to a new driver.

v2: Mark SUBMIT_CL as needing DRM_AUTH. coccinelle fixes from kbuild
test robot. Drop personal git link from MAINTAINERS. Don't double-map dma-buf imported BOs. Add kerneldoc about needing MMU eviction. Drop prime vmap/unmap stubs. Delay mmap offset setup to mmap time. Use drm_dev_init instead of _alloc. Use ktime_get() for wait_bo timeouts. Drop drm_can_sleep() usage, since we don't modeset. Switch page tables back to WC (debug change to coherent had slipped in). Switch drm_gem_object_unreference_unlocked() to drm_gem_object_put_unlocked(). Simplify overflow mem handling by not sharing overflow mem between jobs.
v3: no changes

---
 Documentation/gpu/drivers.rst          |   1 +
 MAINTAINERS                            |   8 +
 drivers/gpu/drm/Kconfig                |   2 +
 drivers/gpu/drm/Makefile               |   1 +
 drivers/gpu/drm/v3d/Kconfig            |   9 +
 drivers/gpu/drm/v3d/Makefile           |  18 +
 drivers/gpu/drm/v3d/v3d_bo.c           | 379 ++++++++++++++
 drivers/gpu/drm/v3d/v3d_debugfs.c      | 191 +++++++
 drivers/gpu/drm/v3d/v3d_drv.c          | 371 ++++++++++++++
 drivers/gpu/drm/v3d/v3d_drv.h          | 294 +++++++++++
 drivers/gpu/drm/v3d/v3d_fence.c        |  58 +++
 drivers/gpu/drm/v3d/v3d_gem.c          | 663 +++++++++++++++++++++++++
 drivers/gpu/drm/v3d/v3d_irq.c          | 206 ++++++++
 drivers/gpu/drm/v3d/v3d_mmu.c          | 122 +++++
 drivers/gpu/drm/v3d/v3d_regs.h         | 295 +++++++++++
 drivers/gpu/drm/v3d/v3d_sched.c        | 228 +++++++++
 drivers/gpu/drm/v3d/v3d_trace.h        |  82 +++
 drivers/gpu/drm/v3d/v3d_trace_points.c |   9 +
 include/uapi/drm/v3d_drm.h             | 191 +++++++
 19 files changed, 3128 insertions(+)
 create mode 100644 drivers/gpu/drm/v3d/Kconfig
 create mode 100644 drivers/gpu/drm/v3d/Makefile
 create mode 100644 drivers/gpu/drm/v3d/v3d_bo.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_debugfs.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_drv.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_drv.h
 create mode 100644 drivers/gpu/drm/v3d/v3d_fence.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_gem.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_irq.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_mmu.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_regs.h
 create mode 100644 drivers/gpu/drm/v3d/v3d_sched.c
 create mode 100644 drivers/gpu/drm/v3d/v3d_trace.h
 create mode 100644 drivers/gpu/drm/v3d/v3d_trace_points.c
 create mode 100644 include/uapi/drm/v3d_drm.h
Documentation/gpu/drivers.rst +1 -0
index d3ab6abae838..f982558fc25d 100644
@@ -10,6 +10,7 @@ GPU Driver Documentation
    tegra
    tinydrm
    tve200
+   v3d
    vc4
    bridge/dw-hdmi
    xen-front
MAINTAINERS +8 -0
index bca3c32fb141..46c49c02d87b 100644
@@ -4795,6 +4795,14 @@ S:	Maintained
 F:	drivers/gpu/drm/omapdrm/
 F:	Documentation/devicetree/bindings/display/ti/
 
+DRM DRIVERS FOR V3D
+M:	Eric Anholt <[email protected]>
+S:	Supported
+F:	drivers/gpu/drm/v3d/
+F:	include/uapi/drm/v3d_drm.h
+F:	Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt
+T:	git git://anongit.freedesktop.org/drm/drm-misc
+
 DRM DRIVERS FOR VC4
 M:	Eric Anholt <[email protected]>
 T:	git git://github.com/anholt/linux
drivers/gpu/drm/Kconfig +2 -0
index 757825ac60df..1c73a455fdb1 100644
@@ -267,6 +267,8 @@ source "drivers/gpu/drm/amd/amdkfd/Kconfig"
 
 source "drivers/gpu/drm/imx/Kconfig"
 
+source "drivers/gpu/drm/v3d/Kconfig"
+
 source "drivers/gpu/drm/vc4/Kconfig"
 
 source "drivers/gpu/drm/etnaviv/Kconfig"
drivers/gpu/drm/Makefile +1 -0
index 9d66657ea117..7a401edd8761 100644
@@ -61,6 +61,7 @@ obj-$(CONFIG_DRM_MGA)	+= mga/
 obj-$(CONFIG_DRM_I810)	+= i810/
 obj-$(CONFIG_DRM_I915)	+= i915/
 obj-$(CONFIG_DRM_MGAG200) += mgag200/
+obj-$(CONFIG_DRM_V3D)  += v3d/
 obj-$(CONFIG_DRM_VC4)  += vc4/
 obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/
 obj-$(CONFIG_DRM_SIS)   += sis/
drivers/gpu/drm/v3d/Kconfig new file +9 -0
new file mode 100644
index 000000000000..a0c0259355bd
@@ -0,0 +1,9 @@
+config DRM_V3D
+	tristate "Broadcom V3D 3.x and newer"
+	depends on ARCH_BCM || ARCH_BCMSTB || COMPILE_TEST
+	depends on DRM
+	depends on COMMON_CLK
+	select DRM_SCHED
+	help
+	  Choose this option if you have a system that has a Broadcom
+	  V3D 3.x or newer GPU, such as BCM7268.
drivers/gpu/drm/v3d/Makefile new file +18 -0
new file mode 100644
index 000000000000..34446e1de64f
@@ -0,0 +1,18 @@
+# Please keep these build lists sorted!
+
+# core driver code
+v3d-y := \
+	v3d_bo.o \
+	v3d_drv.o \
+	v3d_fence.o \
+	v3d_gem.o \
+	v3d_irq.o \
+	v3d_mmu.o \
+	v3d_trace_points.o \
+	v3d_sched.o
+
+v3d-$(CONFIG_DEBUG_FS) += v3d_debugfs.o
+
+obj-$(CONFIG_DRM_V3D)  += v3d.o
+
+CFLAGS_v3d_trace_points.o := -I$(src)
drivers/gpu/drm/v3d/v3d_bo.c new file +379 -0

379 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_debugfs.c new file +191 -0

191 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_drv.c new file +371 -0

371 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_drv.h new file +294 -0

294 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_fence.c new file +58 -0

58 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_gem.c new file +663 -0

663 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_irq.c new file +206 -0

206 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_mmu.c new file +122 -0

122 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_regs.h new file +295 -0

295 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_sched.c new file +228 -0

228 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_trace.h new file +82 -0

82 lines not on this page · raw message

drivers/gpu/drm/v3d/v3d_trace_points.c new file +9 -0
new file mode 100644
index 000000000000..482922d7c7e1
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (C) 2015 Broadcom */
+
+#include "v3d_drv.h"
+
+#ifndef __CHECKER__
+#define CREATE_TRACE_POINTS
+#include "v3d_trace.h"
+#endif
include/uapi/drm/v3d_drm.h new file +191 -0

39 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
2.17.0


_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Part of the diff is not shown here. View the raw message.

maintainer Reviewed-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] dt-bindings: Add a new binding for Broadcom V3D 3.x and newer GPUs.

In reply to Eric Anholt
Quoted 11 lines · Eric Anholt

These OpenGL ES GPUs are present in the 7268 and 7278 set top box chips.

v2: no changes
v3: move to gpu/, fix typo

---
 .../devicetree/bindings/gpu/brcm,bcm-v3d.txt  | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.txt

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

PATCH 1/1 v3d: fixup for submit alignment and check for zero flags in other ioctls.

In reply to Eric Anholt

---

airlied + danvet: this is the last change I think we need before I can merge v3d with your acks. Sending as a diff so you don't have to look at the whole thing again. Look good?

 drivers/gpu/drm/v3d/v3d_bo.c  | 10 ++++++++++
 drivers/gpu/drm/v3d/v3d_gem.c |  5 +++++
 include/uapi/drm/v3d_drm.h    |  3 +++
 3 files changed, 18 insertions(+)
drivers/gpu/drm/v3d/v3d_bo.c +10 -0
index 2be4e8b71604..7b1e2a549a71 100644
@@ -325,6 +325,11 @@ int v3d_create_bo_ioctl(struct drm_device *dev, void *data,
 	struct v3d_bo *bo = NULL;
 	int ret;
 
+	if (args->flags != 0) {
+		DRM_INFO("unknown create_bo flags: %d\n", args->flags);
+		return -EINVAL;
+	}
+
 	bo = v3d_bo_create(dev, file_priv, PAGE_ALIGN(args->size));
 	if (IS_ERR(bo))
 		return PTR_ERR(bo);
@@ -344,6 +349,11 @@ int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data,
 	struct drm_gem_object *gem_obj;
 	int ret;
 
+	if (args->flags != 0) {
+		DRM_INFO("unknown mmap_bo flags: %d\n", args->flags);
+		return -EINVAL;
+	}
+
 	gem_obj = drm_gem_object_lookup(file_priv, args->handle);
 	if (!gem_obj) {
 		DRM_DEBUG("Failed to look up GEM BO %d\n", args->handle);
drivers/gpu/drm/v3d/v3d_gem.c +5 -0
index fa39a1e35263..b513f9189caf 100644
@@ -503,6 +503,11 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
 	struct drm_syncobj *sync_out;
 	int ret = 0;
 
+	if (args->pad != 0) {
+		DRM_INFO("pad must be zero: %d\n", args->pad);
+		return -EINVAL;
+	}
+
 	exec = kcalloc(1, sizeof(*exec), GFP_KERNEL);
 	if (!exec)
 		return -ENOMEM;
include/uapi/drm/v3d_drm.h +3 -0
index 201a07645bdd..7b6627783608 100644
@@ -101,6 +101,9 @@ struct drm_v3d_submit_cl {
 
 	/* Number of BO handles passed in (size is that times 4). */
 	__u32 bo_handle_count;
+
+	/* Pad, must be zero-filled. */
+	__u32 pad;
 };
 
 /**
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Re: [PATCH] v3d: fixup for submit alignment and check for zero flags in other ioctls.

Quoted 6 lines · Eric Anholt

---

airlied + danvet: this is the last change I think we need before I can merge v3d with your acks. Sending as a diff so you don't have to look at the whole thing again. Look good?

Hm I thought I've checked all your ioctl and made sure you're checking for 0 everywhere ... I guess I was blind. Anyway, lgtm, ack still holds. -Daniel

Quoted 67 lines
 drivers/gpu/drm/v3d/v3d_bo.c  | 10 ++++++++++
 drivers/gpu/drm/v3d/v3d_gem.c |  5 +++++
 include/uapi/drm/v3d_drm.h    |  3 +++
 3 files changed, 18 insertions(+)
drivers/gpu/drm/v3d/v3d_bo.c +10 -0
index 2be4e8b71604..7b1e2a549a71 100644
@@ -325,6 +325,11 @@ int v3d_create_bo_ioctl(struct drm_device *dev, void *data,
 	struct v3d_bo *bo = NULL;
 	int ret;
 
+	if (args->flags != 0) {
+		DRM_INFO("unknown create_bo flags: %d\n", args->flags);
+		return -EINVAL;
+	}
+
 	bo = v3d_bo_create(dev, file_priv, PAGE_ALIGN(args->size));
 	if (IS_ERR(bo))
 		return PTR_ERR(bo);
@@ -344,6 +349,11 @@ int v3d_mmap_bo_ioctl(struct drm_device *dev, void *data,
 	struct drm_gem_object *gem_obj;
 	int ret;
 
+	if (args->flags != 0) {
+		DRM_INFO("unknown mmap_bo flags: %d\n", args->flags);
+		return -EINVAL;
+	}
+
 	gem_obj = drm_gem_object_lookup(file_priv, args->handle);
 	if (!gem_obj) {
 		DRM_DEBUG("Failed to look up GEM BO %d\n", args->handle);
drivers/gpu/drm/v3d/v3d_gem.c +5 -0
index fa39a1e35263..b513f9189caf 100644
@@ -503,6 +503,11 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
 	struct drm_syncobj *sync_out;
 	int ret = 0;
 
+	if (args->pad != 0) {
+		DRM_INFO("pad must be zero: %d\n", args->pad);
+		return -EINVAL;
+	}
+
 	exec = kcalloc(1, sizeof(*exec), GFP_KERNEL);
 	if (!exec)
 		return -ENOMEM;
include/uapi/drm/v3d_drm.h +3 -0
index 201a07645bdd..7b6627783608 100644
@@ -101,6 +101,9 @@ struct drm_v3d_submit_cl {
 
 	/* Number of BO handles passed in (size is that times 4). */
 	__u32 bo_handle_count;
+
+	/* Pad, must be zero-filled. */
+	__u32 pad;
 };
 
 /**
Signature · 1 line
2.17.0
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch