Skip to contentSkip to conversation

V3D DRM driver

PATCH Superseded Eric Anholt 3 participants 6 messages Apr 24, 2018 – Apr 27, 2018

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover V3D DRM driver

Here's v2 of the driver. This is mostly handling danvet's feedback, but there are a couple of other changes:

- new core patch for prime vmap/vunmap
- kbuild test robot fixes
- overflow mem simplification (figured it out over breakfast with keithp)
- drm_gem_object_unreference_unlocked() to _put_unlocked().

Eric Anholt (3):
drm: Make the prime vmap/vunmap hooks optional.
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+

 .../bindings/display/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/drm_prime.c                   |   8 +-
 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 +++++
 21 files changed, 3162 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/display/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 v2 1/3 drm: Make the prime vmap/vunmap hooks optional.

Some drivers leave these unimplemented, so don't make them have unimplemented stubs.

---
 drivers/gpu/drm/drm_prime.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_prime.c +6 -2
index caf675e3e692..397b46b33739 100644
@@ -409,7 +409,10 @@ void *drm_gem_dmabuf_vmap(struct dma_buf *dma_buf)
 	struct drm_gem_object *obj = dma_buf->priv;
 	struct drm_device *dev = obj->dev;
 
-	return dev->driver->gem_prime_vmap(obj);
+	if (dev->driver->gem_prime_vmap)
+		return dev->driver->gem_prime_vmap(obj);
+	else
+		return NULL;
 }
 EXPORT_SYMBOL(drm_gem_dmabuf_vmap);
 
@@ -426,7 +429,8 @@ void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr)
 	struct drm_gem_object *obj = dma_buf->priv;
 	struct drm_device *dev = obj->dev;
 
-	dev->driver->gem_prime_vunmap(obj, vaddr);
+	if (dev->driver->gem_prime_vunmap)
+		dev->driver->gem_prime_vunmap(obj, vaddr);
 }
 EXPORT_SYMBOL(drm_gem_dmabuf_vunmap);
 
Signature · 6 lines
2.17.0

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

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

In reply to Eric Anholt

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

---
 .../bindings/display/brcm,bcm-v3d.txt         | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt
Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt new file +28 -0
new file mode 100644
index 000000000000..1c814714de0e
@@ -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 inerrupts 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 · 1 line
2.17.0
#5 lore raw

PATCH v2 3/3 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.

---
 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.

Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] drm: Make the prime vmap/vunmap hooks optional.

In reply to Eric Anholt
Quoted 4 lines · Eric Anholt

Some drivers leave these unimplemented, so don't make them have unimplemented stubs.

Quoted 37 lines
---
 drivers/gpu/drm/drm_prime.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_prime.c +6 -2
index caf675e3e692..397b46b33739 100644
@@ -409,7 +409,10 @@ void *drm_gem_dmabuf_vmap(struct dma_buf *dma_buf)
 	struct drm_gem_object *obj = dma_buf->priv;
 	struct drm_device *dev = obj->dev;
 
-	return dev->driver->gem_prime_vmap(obj);
+	if (dev->driver->gem_prime_vmap)
+		return dev->driver->gem_prime_vmap(obj);
+	else
+		return NULL;
 }
 EXPORT_SYMBOL(drm_gem_dmabuf_vmap);
 
@@ -426,7 +429,8 @@ void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr)
 	struct drm_gem_object *obj = dma_buf->priv;
 	struct drm_device *dev = obj->dev;
 
-	dev->driver->gem_prime_vunmap(obj, vaddr);
+	if (dev->driver->gem_prime_vunmap)
+		dev->driver->gem_prime_vunmap(obj, vaddr);
 }
 EXPORT_SYMBOL(drm_gem_dmabuf_vunmap);
 
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#4 lore raw

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

In reply to Eric Anholt
Quoted 6 lines · Eric Anholt

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

---
 .../bindings/display/brcm,bcm-v3d.txt         | 28 +++++++++++++++++++

Does this have display h/w? If not bindings/gpu/ would be more appropriate.

Quoted 12 lines
 1 file changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt
Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt new file +3 -0
new file mode 100644
index 000000000000..1c814714de0e
@@ -0,0 +1,28 @@
+Broadcom V3D GPU
+
+Only the Broadcom V3D 3.x and newer GPUs are covered by this binding.

Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt line 13

Quoted 10 lines
Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt new file +10 -0
+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 inerrupts are for the cores.

typo

Quoted 18 lines
Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt new file +15 -0
+		  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 · 1 line
2.17.0

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