Skip to contentSkip to conversation

Support for Tegra 2D hardware

PATCH Superseded Terje Bergstrom 3 participants 14 messages Jan 15, 2013 – Jan 16, 2013

Subsystems (8)

v5 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v5 cover Support for Tegra 2D hardware

This set of patches adds support for Tegra20 and Tegra30 host1x and 2D. It is based on linux-next-20130114.

The fifth version merges DRM and host1x drivers into one driver. This allowed moving include/linux/host1x.h back into the driver and removed the need for a dummy platform device. This version also uses the code from tegradrm driver almost as is, so there are a lot less actual code changes.

This patch set does not have the host1x allocator, but it uses CMA helpers for memory management.

host1x is the driver that controls host1x hardware. It supports host1x command channels, synchronization, and memory management. It is sectioned into logical driver under drivers/gpu/host1x and physical driver under drivers/host1x/hw. The physical driver is compiled with the hardware headers of the particular host1x version.

The hardware units are described (briefly) in the Tegra2 TRM. Wiki page https://gitorious.org/linux-tegra-drm/pages/Host1xIntroduction
also contains a short description of the functionality.

The patch set merges tegradrm into host1x and adds 2D driver, which uses host1x channels and sync points. The patch set also adds user space API to tegradrm for accessing host1x and 2D.

Terje Bergstrom (8):
gpu: host1x: Add host1x driver
gpu: host1x: Add syncpoint wait and interrupts
gpu: host1x: Add channel support
gpu: host1x: Add debug support
drm: tegra: Move drm to live under host1x
gpu: host1x: Remove second host1x driver
ARM: tegra: Add board data and 2D clocks
drm: tegra: Add gr2d device

 arch/arm/mach-tegra/board-dt-tegra20.c      |    1 +
 arch/arm/mach-tegra/board-dt-tegra30.c      |    1 +
 arch/arm/mach-tegra/tegra20_clocks_data.c   |    2 +-
 arch/arm/mach-tegra/tegra30_clocks_data.c   |    1 +
 drivers/gpu/Makefile                        |    1 +
 drivers/gpu/drm/Kconfig                     |    2 -
 drivers/gpu/drm/Makefile                    |    1 -
 drivers/gpu/drm/tegra/Kconfig               |   23 -
 drivers/gpu/drm/tegra/Makefile              |    7 -
 drivers/gpu/drm/tegra/dc.c                  |  833 -----------------
 drivers/gpu/drm/tegra/dc.h                  |  388 --------
 drivers/gpu/drm/tegra/drm.c                 |  115 ---
 drivers/gpu/drm/tegra/drm.h                 |  216 -----
 drivers/gpu/drm/tegra/fb.c                  |   56 --
 drivers/gpu/drm/tegra/hdmi.c                | 1321 --------------------------
 drivers/gpu/drm/tegra/hdmi.h                |  575 ------------
 drivers/gpu/drm/tegra/host1x.c              |  327 -------
 drivers/gpu/drm/tegra/output.c              |  272 ------
 drivers/gpu/drm/tegra/rgb.c                 |  228 -----
 drivers/gpu/host1x/Kconfig                  |   32 +
 drivers/gpu/host1x/Makefile                 |   22 +
 drivers/gpu/host1x/cdma.c                   |  473 ++++++++++
 drivers/gpu/host1x/cdma.h                   |  107 +++
 drivers/gpu/host1x/channel.c                |  140 +++
 drivers/gpu/host1x/channel.h                |   58 ++
 drivers/gpu/host1x/cma.c                    |  116 +++
 drivers/gpu/host1x/cma.h                    |   43 +
 drivers/gpu/host1x/debug.c                  |  215 +++++
 drivers/gpu/host1x/debug.h                  |   50 +
 drivers/gpu/host1x/dev.c                    |  251 +++++
 drivers/gpu/host1x/dev.h                    |  170 ++++
 drivers/gpu/host1x/drm/Kconfig              |   23 +
 drivers/gpu/host1x/drm/dc.c                 |  836 +++++++++++++++++
 drivers/gpu/host1x/drm/dc.h                 |  388 ++++++++
 drivers/gpu/host1x/drm/drm.c                |  548 +++++++++++
 drivers/gpu/host1x/drm/drm.h                |  241 +++++
 drivers/gpu/host1x/drm/fb.c                 |   56 ++
 drivers/gpu/host1x/drm/gr2d.c               |  325 +++++++
 drivers/gpu/host1x/drm/hdmi.c               | 1324 +++++++++++++++++++++++++++
 drivers/gpu/host1x/drm/hdmi.h               |  575 ++++++++++++
 drivers/gpu/host1x/drm/host1x.c             |  327 +++++++
 drivers/gpu/host1x/drm/output.c             |  272 ++++++
 drivers/gpu/host1x/drm/rgb.c                |  228 +++++
 drivers/gpu/host1x/host1x.h                 |   29 +
 drivers/gpu/host1x/host1x_client.h          |   34 +
 drivers/gpu/host1x/hw/Makefile              |    6 +
 drivers/gpu/host1x/hw/cdma_hw.c             |  478 ++++++++++
 drivers/gpu/host1x/hw/cdma_hw.h             |   37 +
 drivers/gpu/host1x/hw/channel_hw.c          |  148 +++
 drivers/gpu/host1x/hw/debug_hw.c            |  400 ++++++++
 drivers/gpu/host1x/hw/host1x01.c            |   45 +
 drivers/gpu/host1x/hw/host1x01.h            |   25 +
 drivers/gpu/host1x/hw/host1x01_hardware.h   |  150 +++
 drivers/gpu/host1x/hw/hw_host1x01_channel.h |  120 +++
 drivers/gpu/host1x/hw/hw_host1x01_sync.h    |  241 +++++
 drivers/gpu/host1x/hw/hw_host1x01_uclass.h  |  168 ++++
 drivers/gpu/host1x/hw/intr_hw.c             |  178 ++++
 drivers/gpu/host1x/hw/syncpt_hw.c           |  157 ++++
 drivers/gpu/host1x/intr.c                   |  383 ++++++++
 drivers/gpu/host1x/intr.h                   |  109 +++
 drivers/gpu/host1x/job.c                    |  612 +++++++++++++
 drivers/gpu/host1x/job.h                    |  164 ++++
 drivers/gpu/host1x/memmgr.c                 |  173 ++++
 drivers/gpu/host1x/memmgr.h                 |   72 ++
 drivers/gpu/host1x/syncpt.c                 |  399 ++++++++
 drivers/gpu/host1x/syncpt.h                 |  165 ++++
 drivers/video/Kconfig                       |    2 +
 include/drm/tegra_drm.h                     |  131 +++
 include/trace/events/host1x.h               |  272 ++++++
 69 files changed, 11523 insertions(+), 4365 deletions(-)
 delete mode 100644 drivers/gpu/drm/tegra/Kconfig
 delete mode 100644 drivers/gpu/drm/tegra/Makefile
 delete mode 100644 drivers/gpu/drm/tegra/dc.c
 delete mode 100644 drivers/gpu/drm/tegra/dc.h
 delete mode 100644 drivers/gpu/drm/tegra/drm.c
 delete mode 100644 drivers/gpu/drm/tegra/drm.h
 delete mode 100644 drivers/gpu/drm/tegra/fb.c
 delete mode 100644 drivers/gpu/drm/tegra/hdmi.c
 delete mode 100644 drivers/gpu/drm/tegra/hdmi.h
 delete mode 100644 drivers/gpu/drm/tegra/host1x.c
 delete mode 100644 drivers/gpu/drm/tegra/output.c
 delete mode 100644 drivers/gpu/drm/tegra/rgb.c
 create mode 100644 drivers/gpu/host1x/Kconfig
 create mode 100644 drivers/gpu/host1x/Makefile
 create mode 100644 drivers/gpu/host1x/cdma.c
 create mode 100644 drivers/gpu/host1x/cdma.h
 create mode 100644 drivers/gpu/host1x/channel.c
 create mode 100644 drivers/gpu/host1x/channel.h
 create mode 100644 drivers/gpu/host1x/cma.c
 create mode 100644 drivers/gpu/host1x/cma.h
 create mode 100644 drivers/gpu/host1x/debug.c
 create mode 100644 drivers/gpu/host1x/debug.h
 create mode 100644 drivers/gpu/host1x/dev.c
 create mode 100644 drivers/gpu/host1x/dev.h
 create mode 100644 drivers/gpu/host1x/drm/Kconfig
 create mode 100644 drivers/gpu/host1x/drm/dc.c
 create mode 100644 drivers/gpu/host1x/drm/dc.h
 create mode 100644 drivers/gpu/host1x/drm/drm.c
 create mode 100644 drivers/gpu/host1x/drm/drm.h
 create mode 100644 drivers/gpu/host1x/drm/fb.c
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 drivers/gpu/host1x/drm/hdmi.c
 create mode 100644 drivers/gpu/host1x/drm/hdmi.h
 create mode 100644 drivers/gpu/host1x/drm/host1x.c
 create mode 100644 drivers/gpu/host1x/drm/output.c
 create mode 100644 drivers/gpu/host1x/drm/rgb.c
 create mode 100644 drivers/gpu/host1x/host1x.h
 create mode 100644 drivers/gpu/host1x/host1x_client.h
 create mode 100644 drivers/gpu/host1x/hw/Makefile
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.c
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.h
 create mode 100644 drivers/gpu/host1x/hw/channel_hw.c
 create mode 100644 drivers/gpu/host1x/hw/debug_hw.c
 create mode 100644 drivers/gpu/host1x/hw/host1x01.c
 create mode 100644 drivers/gpu/host1x/hw/host1x01.h
 create mode 100644 drivers/gpu/host1x/hw/host1x01_hardware.h
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_channel.h
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_sync.h
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_uclass.h
 create mode 100644 drivers/gpu/host1x/hw/intr_hw.c
 create mode 100644 drivers/gpu/host1x/hw/syncpt_hw.c
 create mode 100644 drivers/gpu/host1x/intr.c
 create mode 100644 drivers/gpu/host1x/intr.h
 create mode 100644 drivers/gpu/host1x/job.c
 create mode 100644 drivers/gpu/host1x/job.h
 create mode 100644 drivers/gpu/host1x/memmgr.c
 create mode 100644 drivers/gpu/host1x/memmgr.h
 create mode 100644 drivers/gpu/host1x/syncpt.c
 create mode 100644 drivers/gpu/host1x/syncpt.h
 create mode 100644 include/drm/tegra_drm.h
 create mode 100644 include/trace/events/host1x.h
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v5 5/8 drm: tegra: Move drm to live under host1x

Make drm part of host1x driver.

---
 drivers/gpu/drm/Kconfig            |    2 -
 drivers/gpu/drm/Makefile           |    1 -
 drivers/gpu/drm/tegra/Kconfig      |   23 -
 drivers/gpu/drm/tegra/Makefile     |    7 -
 drivers/gpu/drm/tegra/dc.c         |  833 -----------------------
 drivers/gpu/drm/tegra/dc.h         |  388 -----------
 drivers/gpu/drm/tegra/drm.c        |  115 ----
 drivers/gpu/drm/tegra/drm.h        |  216 ------
 drivers/gpu/drm/tegra/fb.c         |   56 --
 drivers/gpu/drm/tegra/hdmi.c       | 1321 ------------------------------------
 drivers/gpu/drm/tegra/hdmi.h       |  575 ----------------
 drivers/gpu/drm/tegra/host1x.c     |  327 ---------
 drivers/gpu/drm/tegra/output.c     |  272 --------
 drivers/gpu/drm/tegra/rgb.c        |  228 -------
 drivers/gpu/host1x/Kconfig         |    3 +
 drivers/gpu/host1x/Makefile        |    6 +
 drivers/gpu/host1x/drm/Kconfig     |   23 +
 drivers/gpu/host1x/drm/dc.c        |  833 +++++++++++++++++++++++
 drivers/gpu/host1x/drm/dc.h        |  388 +++++++++++
 drivers/gpu/host1x/drm/drm.c       |  115 ++++
 drivers/gpu/host1x/drm/drm.h       |  216 ++++++
 drivers/gpu/host1x/drm/fb.c        |   56 ++
 drivers/gpu/host1x/drm/hdmi.c      | 1321 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/host1x/drm/hdmi.h      |  575 ++++++++++++++++
 drivers/gpu/host1x/drm/host1x.c    |  327 +++++++++
 drivers/gpu/host1x/drm/output.c    |  272 ++++++++
 drivers/gpu/host1x/drm/rgb.c       |  228 +++++++
 drivers/gpu/host1x/host1x_client.h |   25 +
 28 files changed, 4388 insertions(+), 4364 deletions(-)
 delete mode 100644 drivers/gpu/drm/tegra/Kconfig
 delete mode 100644 drivers/gpu/drm/tegra/Makefile
 delete mode 100644 drivers/gpu/drm/tegra/dc.c
 delete mode 100644 drivers/gpu/drm/tegra/dc.h
 delete mode 100644 drivers/gpu/drm/tegra/drm.c
 delete mode 100644 drivers/gpu/drm/tegra/drm.h
 delete mode 100644 drivers/gpu/drm/tegra/fb.c
 delete mode 100644 drivers/gpu/drm/tegra/hdmi.c
 delete mode 100644 drivers/gpu/drm/tegra/hdmi.h
 delete mode 100644 drivers/gpu/drm/tegra/host1x.c
 delete mode 100644 drivers/gpu/drm/tegra/output.c
 delete mode 100644 drivers/gpu/drm/tegra/rgb.c
 create mode 100644 drivers/gpu/host1x/drm/Kconfig
 create mode 100644 drivers/gpu/host1x/drm/dc.c
 create mode 100644 drivers/gpu/host1x/drm/dc.h
 create mode 100644 drivers/gpu/host1x/drm/drm.c
 create mode 100644 drivers/gpu/host1x/drm/drm.h
 create mode 100644 drivers/gpu/host1x/drm/fb.c
 create mode 100644 drivers/gpu/host1x/drm/hdmi.c
 create mode 100644 drivers/gpu/host1x/drm/hdmi.h
 create mode 100644 drivers/gpu/host1x/drm/host1x.c
 create mode 100644 drivers/gpu/host1x/drm/output.c
 create mode 100644 drivers/gpu/host1x/drm/rgb.c
 create mode 100644 drivers/gpu/host1x/host1x_client.h
drivers/gpu/drm/Kconfig +0 -2
index 983201b..18321b68b 100644
@@ -210,5 +210,3 @@ source "drivers/gpu/drm/mgag200/Kconfig"
 source "drivers/gpu/drm/cirrus/Kconfig"
 
 source "drivers/gpu/drm/shmobile/Kconfig"
-
-source "drivers/gpu/drm/tegra/Kconfig"
drivers/gpu/drm/Makefile +0 -1
index 6f58c81..f54c72a 100644
@@ -49,5 +49,4 @@ obj-$(CONFIG_DRM_GMA500) += gma500/
 obj-$(CONFIG_DRM_UDL) += udl/
 obj-$(CONFIG_DRM_AST) += ast/
 obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/
-obj-$(CONFIG_DRM_TEGRA) += tegra/
 obj-y			+= i2c/
drivers/gpu/drm/tegra/Kconfig deleted +0 -23
deleted file mode 100644
index be1daf7..0000000
@@ -1,23 +0,0 @@
-config DRM_TEGRA
-	tristate "NVIDIA Tegra DRM"
-	depends on DRM && OF && ARCH_TEGRA
-	select DRM_KMS_HELPER
-	select DRM_GEM_CMA_HELPER
-	select DRM_KMS_CMA_HELPER
-	select FB_CFB_FILLRECT
-	select FB_CFB_COPYAREA
-	select FB_CFB_IMAGEBLIT
-	help
-	  Choose this option if you have an NVIDIA Tegra SoC.
-
-	  To compile this driver as a module, choose M here: the module
-	  will be called tegra-drm.
-
-if DRM_TEGRA
-
-config DRM_TEGRA_DEBUG
-	bool "NVIDIA Tegra DRM debug support"
-	help
-	  Say yes here to enable debugging support.
-
-endif
drivers/gpu/drm/tegra/Makefile deleted +0 -7
deleted file mode 100644
index 80f73d1..0000000
@@ -1,7 +0,0 @@
-ccflags-y := -Iinclude/drm
-ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG
-
-tegra-drm-y := drm.o fb.o dc.o host1x.o
-tegra-drm-y += output.o rgb.o hdmi.o
-
-obj-$(CONFIG_DRM_TEGRA) += tegra-drm.o
drivers/gpu/drm/tegra/dc.c deleted +0 -833

833 lines not on this page · raw message

drivers/gpu/drm/tegra/dc.h deleted +0 -388

388 lines not on this page · raw message

drivers/gpu/drm/tegra/drm.c deleted +0 -115

115 lines not on this page · raw message

drivers/gpu/drm/tegra/drm.h deleted +0 -216

216 lines not on this page · raw message

drivers/gpu/drm/tegra/fb.c deleted +0 -56

56 lines not on this page · raw message

drivers/gpu/drm/tegra/hdmi.c deleted +0 -1321

1,321 lines not on this page · raw message

drivers/gpu/drm/tegra/hdmi.h deleted +0 -575

31 lines not on this page · raw message

drivers/gpu/drm/tegra/host1x.c deleted +0 -327

327 lines not on this page · raw message

drivers/gpu/drm/tegra/output.c deleted +0 -272

272 lines not on this page · raw message

drivers/gpu/drm/tegra/rgb.c deleted +0 -228

228 lines not on this page · raw message

drivers/gpu/host1x/Kconfig +3 -0
index 57680a6..558b660 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/host1x/Makefile +6 -0
index 697d49a..ffc8bf1 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/host1x/drm/Kconfig new file +23 -0
new file mode 100644
index 0000000..be1daf7

Lines of this file are not shown. View the raw message.

drivers/gpu/host1x/drm/dc.c new file +833 -0

833 lines not on this page · raw message

drivers/gpu/host1x/drm/dc.h new file +388 -0

388 lines not on this page · raw message

drivers/gpu/host1x/drm/drm.c new file +115 -0

115 lines not on this page · raw message

drivers/gpu/host1x/drm/drm.h new file +216 -0

216 lines not on this page · raw message

drivers/gpu/host1x/drm/fb.c new file +56 -0

56 lines not on this page · raw message

drivers/gpu/host1x/drm/hdmi.c new file +1321 -0

1,321 lines not on this page · raw message

drivers/gpu/host1x/drm/hdmi.h new file +575 -0

575 lines not on this page · raw message

drivers/gpu/host1x/drm/host1x.c new file +327 -0

327 lines not on this page · raw message

drivers/gpu/host1x/drm/output.c new file +272 -0

272 lines not on this page · raw message

drivers/gpu/host1x/drm/rgb.c new file +228 -0

228 lines not on this page · raw message

drivers/gpu/host1x/host1x_client.h new file +25 -0
new file mode 100644
index 0000000..fdd2920

Lines of this file are not shown. View the raw message.

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

Signature · 1 line
1.7.9.5

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

#1 lore raw

PATCH v5 1/8 gpu: host1x: Add host1x driver

In reply to Terje Bergstrom

Add host1x, the driver for host1x and its client unit 2D.

---
 drivers/gpu/Makefile                      |    1 +
 drivers/gpu/host1x/Kconfig                |    6 +
 drivers/gpu/host1x/Makefile               |    8 ++
 drivers/gpu/host1x/dev.c                  |  161 +++++++++++++++++++++
 drivers/gpu/host1x/dev.h                  |   73 ++++++++++
 drivers/gpu/host1x/hw/Makefile            |    6 +
 drivers/gpu/host1x/hw/host1x01.c          |   35 +++++
 drivers/gpu/host1x/hw/host1x01.h          |   25 ++++
 drivers/gpu/host1x/hw/host1x01_hardware.h |   26 ++++
 drivers/gpu/host1x/hw/hw_host1x01_sync.h  |   72 ++++++++++
 drivers/gpu/host1x/hw/syncpt_hw.c         |  146 +++++++++++++++++++
 drivers/gpu/host1x/syncpt.c               |  217 +++++++++++++++++++++++++++++
 drivers/gpu/host1x/syncpt.h               |  153 ++++++++++++++++++++
 drivers/video/Kconfig                     |    2 +
 include/trace/events/host1x.h             |   61 ++++++++
 15 files changed, 992 insertions(+)
 create mode 100644 drivers/gpu/host1x/Kconfig
 create mode 100644 drivers/gpu/host1x/Makefile
 create mode 100644 drivers/gpu/host1x/dev.c
 create mode 100644 drivers/gpu/host1x/dev.h
 create mode 100644 drivers/gpu/host1x/hw/Makefile
 create mode 100644 drivers/gpu/host1x/hw/host1x01.c
 create mode 100644 drivers/gpu/host1x/hw/host1x01.h
 create mode 100644 drivers/gpu/host1x/hw/host1x01_hardware.h
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_sync.h
 create mode 100644 drivers/gpu/host1x/hw/syncpt_hw.c
 create mode 100644 drivers/gpu/host1x/syncpt.c
 create mode 100644 drivers/gpu/host1x/syncpt.h
 create mode 100644 include/trace/events/host1x.h
drivers/gpu/Makefile +1 -0
index cc92778..7e227097 100644
@@ -1 +1,2 @@
 obj-y			+= drm/ vga/ stub/
+obj-$(CONFIG_TEGRA_HOST1X)	+= host1x/
drivers/gpu/host1x/Kconfig new file +6 -0
new file mode 100644
index 0000000..e89fb2b
@@ -0,0 +1,6 @@
+config TEGRA_HOST1X
+	tristate "Tegra host1x driver"
+	help
+	  Driver for the Tegra host1x hardware.
+
+	  Required for enabling tegradrm.
drivers/gpu/host1x/Makefile new file +8 -0
new file mode 100644
index 0000000..363e6ab
@@ -0,0 +1,8 @@
+ccflags-y = -Idrivers/gpu/host1x
+
+host1x-y = \
+	syncpt.o \
+	dev.o \
+	hw/host1x01.o
+
+obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/dev.c new file +161 -0

161 lines not on this page · raw message

drivers/gpu/host1x/dev.h new file +73 -0

73 lines not on this page · raw message

drivers/gpu/host1x/hw/Makefile new file +6 -0
new file mode 100644
index 0000000..9b50863
@@ -0,0 +1,6 @@
+ccflags-y = -Idrivers/gpu/host1x
+
+host1x-hw-objs  = \
+	host1x01.o
+
+obj-$(CONFIG_TEGRA_HOST1X) += host1x-hw.o
drivers/gpu/host1x/hw/host1x01.c new file +35 -0
new file mode 100644
index 0000000..ea6e604
@@ -0,0 +1,35 @@
+/*
+ * Host1x init for T20 and T30 Architecture Chips
+ *
+ * Copyright (c) 2011-2013, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+#include "hw/host1x01.h"
+#include "dev.h"
+#include "hw/host1x01_hardware.h"
+
+#include "hw/syncpt_hw.c"
+
+int host1x01_init(struct host1x *host)
+{
+	host->syncpt_op = host1x_syncpt_ops;
+
+	return 0;
+}
drivers/gpu/host1x/hw/host1x01.h new file +25 -0
new file mode 100644
index 0000000..6ec30051
@@ -0,0 +1,25 @@
+/*
+ * Host1x init for T20 and T30 Architecture Chips
+ *
+ * Copyright (c) 2011-2013, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef HOST1X_HOST1X01_H
+#define HOST1X_HOST1X01_H
+
+struct host1x;
+
+int host1x01_init(struct host1x *);
+
+#endif /* HOST1X_HOST1X01_H_ */
drivers/gpu/host1x/hw/host1x01_hardware.h new file +26 -0
new file mode 100644
index 0000000..c1d5324
@@ -0,0 +1,26 @@
+/*
+ * Tegra host1x Register Offsets for Tegra20 and Tegra30
+ *
+ * Copyright (c) 2010-2013 NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __HOST1X_HOST1X01_HARDWARE_H
+#define __HOST1X_HOST1X01_HARDWARE_H
+
+#include <linux/types.h>
+#include <linux/bitops.h>
+#include "hw_host1x01_sync.h"
+
+#endif
drivers/gpu/host1x/hw/hw_host1x01_sync.h new file +72 -0

72 lines not on this page · raw message

drivers/gpu/host1x/hw/syncpt_hw.c new file +146 -0

146 lines not on this page · raw message

drivers/gpu/host1x/syncpt.c new file +217 -0

217 lines not on this page · raw message

drivers/gpu/host1x/syncpt.h new file +153 -0

153 lines not on this page · raw message

drivers/video/Kconfig +2 -0
index e7068c5..776ddba 100644
@@ -21,6 +21,8 @@ source "drivers/gpu/vga/Kconfig"
 
 source "drivers/gpu/drm/Kconfig"
 
+source "drivers/gpu/host1x/Kconfig"
+
 source "drivers/gpu/stub/Kconfig"
 
 config VGASTATE
include/trace/events/host1x.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#12 lore raw

PATCH v5 8/8 drm: tegra: Add gr2d device

In reply to Terje Bergstrom

Add client driver for 2D device, and IOCTLs to pass work to host1x channel for 2D.

Also adds functions that can be called to access sync points from DRM.

---
 drivers/gpu/host1x/Makefile   |    1 +
 drivers/gpu/host1x/dev.c      |    7 +
 drivers/gpu/host1x/drm/drm.c  |  226 +++++++++++++++++++++++++++-
 drivers/gpu/host1x/drm/drm.h  |   28 ++++
 drivers/gpu/host1x/drm/gr2d.c |  325 +++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/host1x/syncpt.c   |    5 +
 drivers/gpu/host1x/syncpt.h   |    3 +
 include/drm/tegra_drm.h       |  131 +++++++++++++++++
 8 files changed, 725 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 include/drm/tegra_drm.h
drivers/gpu/host1x/Makefile +1 -0
index c35ee19..c2120ad 100644
@@ -18,4 +18,5 @@ ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG
 
 host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o
 host1x-$(CONFIG_DRM_TEGRA) += drm/output.o drm/rgb.o drm/hdmi.o
+host1x-$(CONFIG_DRM_TEGRA) += drm/gr2d.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/dev.c +7 -0
index 17ee01c..40d9938 100644
@@ -214,11 +214,17 @@ static int __init tegra_host1x_init(void)
 	err = platform_driver_register(&tegra_hdmi_driver);
 	if (err < 0)
 		goto unregister_dc;
+
+	err = platform_driver_register(&tegra_gr2d_driver);
+	if (err < 0)
+		goto unregister_hdmi;
 #endif
 
 	return 0;
 
 #ifdef CONFIG_TEGRA_DRM
+unregister_hdmi:
+	platform_driver_unregister(&tegra_hdmi_driver);
 unregister_dc:
 	platform_driver_unregister(&tegra_dc_driver);
 unregister_host1x:
@@ -231,6 +237,7 @@ module_init(tegra_host1x_init);
 static void __exit tegra_host1x_exit(void)
 {
 #ifdef CONFIG_TEGRA_DRM
+	platform_driver_unregister(&tegra_gr2d_driver);
 	platform_driver_unregister(&tegra_hdmi_driver);
 	platform_driver_unregister(&tegra_dc_driver);
 #endif
drivers/gpu/host1x/drm/drm.c +225 -1

262 lines not on this page · raw message

drivers/gpu/host1x/drm/drm.h +28 -0
index e7101d5..dc4c128 100644
@@ -17,6 +17,7 @@
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_fixed.h>
+#include <drm/tegra_drm.h>
 
 struct tegra_framebuffer {
 	struct drm_framebuffer base;
@@ -49,17 +50,44 @@ struct host1x {
 
 struct host1x_client;
 
+struct host1x_drm_context {
+	struct host1x_client *client;
+	struct host1x_channel *channel;
+	struct list_head list;
+};
+
 struct host1x_client_ops {
 	int (*drm_init)(struct host1x_client *client, struct drm_device *drm);
 	int (*drm_exit)(struct host1x_client *client);
+	int (*open_channel)(struct host1x_client *,
+			struct host1x_drm_context *);
+	void (*close_channel)(struct host1x_drm_context *);
+	u32 (*get_syncpoint)(struct host1x_drm_context *, int index);
+	int (*submit)(struct host1x_drm_context *,
+			struct tegra_drm_submit_args *,
+			struct drm_device *,
+			struct drm_file *);
+};
+
+struct host1x_drm_fpriv {
+	struct list_head contexts;
 };
 
+static inline struct host1x_drm_fpriv *
+host1x_drm_fpriv(struct drm_file *file_priv)
+{
+	return file_priv ? file_priv->driver_priv : NULL;
+}
+
 struct host1x_client {
 	struct host1x *host1x;
 	struct device *dev;
 
 	const struct host1x_client_ops *ops;
 
+	u32 class;
+	struct host1x_channel *channel;
+
 	struct list_head list;
 };
 
drivers/gpu/host1x/drm/gr2d.c new file +325 -0

325 lines not on this page · raw message

drivers/gpu/host1x/syncpt.c +5 -0
index 191f65f..ccaaece 100644
@@ -392,3 +392,8 @@ struct host1x_syncpt *host1x_syncpt_get(struct host1x *dev, u32 id)
 {
 	return dev->syncpt + id;
 }
+
+struct host1x_syncpt *host1x_syncpt_get_bydev(struct device *dev, u32 id)
+{
+	return host1x_syncpt_get(dev_get_drvdata(dev), id);
+}
drivers/gpu/host1x/syncpt.h +3 -0
index 255a3a3..d15d4c5 100644
@@ -110,6 +110,9 @@ static inline bool host1x_syncpt_min_eq_max(struct host1x_syncpt *sp)
 /* Return pointer to struct denoting sync point id. */
 struct host1x_syncpt *host1x_syncpt_get(struct host1x *dev, u32 id);
 
+/* Return pointer to struct denoting sync point id, when given client pdev. */
+struct host1x_syncpt *host1x_syncpt_get_bydev(struct device *dev, u32 id);
+
 /* Request incrementing a sync point. */
 void host1x_syncpt_cpu_incr(struct host1x_syncpt *sp);
 
include/drm/tegra_drm.h new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v5 3/8 gpu: host1x: Add channel support

In reply to Terje Bergstrom

Add support for host1x client modules, and host1x channels to submit work to the clients. The work is submitted in GEM CMA buffers, so this patch adds support for them.

---
 drivers/gpu/host1x/Kconfig                  |   25 +-
 drivers/gpu/host1x/Makefile                 |    5 +
 drivers/gpu/host1x/cdma.c                   |  439 +++++++++++++++++++
 drivers/gpu/host1x/cdma.h                   |  107 +++++
 drivers/gpu/host1x/channel.c                |  140 ++++++
 drivers/gpu/host1x/channel.h                |   58 +++
 drivers/gpu/host1x/cma.c                    |  116 +++++
 drivers/gpu/host1x/cma.h                    |   43 ++
 drivers/gpu/host1x/dev.c                    |   13 +
 drivers/gpu/host1x/dev.h                    |   59 +++
 drivers/gpu/host1x/host1x.h                 |   29 ++
 drivers/gpu/host1x/hw/cdma_hw.c             |  475 +++++++++++++++++++++
 drivers/gpu/host1x/hw/cdma_hw.h             |   37 ++
 drivers/gpu/host1x/hw/channel_hw.c          |  148 +++++++
 drivers/gpu/host1x/hw/host1x01.c            |    6 +
 drivers/gpu/host1x/hw/host1x01_hardware.h   |  124 ++++++
 drivers/gpu/host1x/hw/hw_host1x01_channel.h |  102 +++++
 drivers/gpu/host1x/hw/hw_host1x01_sync.h    |   12 +
 drivers/gpu/host1x/hw/hw_host1x01_uclass.h  |  168 ++++++++
 drivers/gpu/host1x/hw/syncpt_hw.c           |   10 +
 drivers/gpu/host1x/intr.c                   |   29 +-
 drivers/gpu/host1x/intr.h                   |    6 +
 drivers/gpu/host1x/job.c                    |  612 +++++++++++++++++++++++++++
 drivers/gpu/host1x/job.h                    |  164 +++++++
 drivers/gpu/host1x/memmgr.c                 |  173 ++++++++
 drivers/gpu/host1x/memmgr.h                 |   72 ++++
 drivers/gpu/host1x/syncpt.c                 |   11 +
 drivers/gpu/host1x/syncpt.h                 |    4 +
 include/trace/events/host1x.h               |  211 +++++++++
 29 files changed, 3396 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/host1x/cdma.c
 create mode 100644 drivers/gpu/host1x/cdma.h
 create mode 100644 drivers/gpu/host1x/channel.c
 create mode 100644 drivers/gpu/host1x/channel.h
 create mode 100644 drivers/gpu/host1x/cma.c
 create mode 100644 drivers/gpu/host1x/cma.h
 create mode 100644 drivers/gpu/host1x/host1x.h
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.c
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.h
 create mode 100644 drivers/gpu/host1x/hw/channel_hw.c
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_channel.h
 create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_uclass.h
 create mode 100644 drivers/gpu/host1x/job.c
 create mode 100644 drivers/gpu/host1x/job.h
 create mode 100644 drivers/gpu/host1x/memmgr.c
 create mode 100644 drivers/gpu/host1x/memmgr.h
drivers/gpu/host1x/Kconfig +24 -1
index e89fb2b..57680a6 100644
@@ -3,4 +3,27 @@ config TEGRA_HOST1X
 	help
 	  Driver for the Tegra host1x hardware.
 
-	  Required for enabling tegradrm.
+	  Required for enabling tegradrm and 2D acceleration.
+
+if TEGRA_HOST1X
+
+config TEGRA_HOST1X_CMA
+	bool "Support DRM CMA buffers"
+	depends on DRM
+	default y
+	select DRM_GEM_CMA_HELPER
+	select DRM_KMS_CMA_HELPER
+	help
+	  Say yes if you wish to use DRM CMA buffers.
+
+	  If unsure, choose Y.
+
+config TEGRA_HOST1X_FIREWALL
+	bool "Enable HOST1X security firewall"
+	default y
+	help
+	  Say yes if kernel should protect command streams from tampering.
+
+	  If unsure, choose Y.
+
+endif
drivers/gpu/host1x/Makefile +5 -0
index 5ef47ff..cdd87c8 100644
@@ -4,6 +4,11 @@ host1x-y = \
 	syncpt.o \
 	dev.o \
 	intr.o \
+	cdma.o \
+	channel.o \
+	job.o \
+	memmgr.o \
 	hw/host1x01.o
 
+host1x-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/cdma.c new file +439 -0

439 lines not on this page · raw message

drivers/gpu/host1x/cdma.h new file +107 -0

107 lines not on this page · raw message

drivers/gpu/host1x/channel.c new file +140 -0

140 lines not on this page · raw message

drivers/gpu/host1x/channel.h new file +58 -0

58 lines not on this page · raw message

drivers/gpu/host1x/cma.c new file +116 -0

116 lines not on this page · raw message

drivers/gpu/host1x/cma.h new file +43 -0

43 lines not on this page · raw message

drivers/gpu/host1x/dev.c +13 -0
index 7f9f389..80311ca 100644
@@ -25,6 +25,7 @@
 #include <linux/io.h>
 #include "dev.h"
 #include "intr.h"
+#include "channel.h"
 #include "hw/host1x01.h"
 
 #define CREATE_TRACE_POINTS
@@ -46,6 +47,16 @@ u32 host1x_sync_readl(struct host1x *host1x, u32 r)
 	return readl(sync_regs + r);
 }
 
+void host1x_ch_writel(struct host1x_channel *ch, u32 v, u32 r)
+{
+	writel(v, ch->regs + r);
+}
+
+u32 host1x_ch_readl(struct host1x_channel *ch, u32 r)
+{
+	return readl(ch->regs + r);
+}
+
 static struct host1x_device_info host1x_info = {
 	.nb_channels	= 8,
 	.nb_pts		= 32,
@@ -135,6 +146,8 @@ static int host1x_probe(struct platform_device *dev)
 
 	host1x_syncpt_reset(host);
 
+	host1x_channel_list_init(host);
+
 	host1x_intr_start(&host->intr, clk_get_rate(host->clk));
 
 	dev_info(&dev->dev, "initialized\n");
drivers/gpu/host1x/dev.h +59 -0

84 lines not on this page · raw message

drivers/gpu/host1x/host1x.h new file +29 -0
new file mode 100644
index 0000000..ded0660
@@ -0,0 +1,29 @@
+/*
+ * Tegra host1x driver
+ *
+ * Copyright (c) 2009-2013, NVIDIA Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __LINUX_HOST1X_H
+#define __LINUX_HOST1X_H
+
+enum host1x_class {
+	NV_HOST1X_CLASS_ID		= 0x1,
+	NV_GRAPHICS_2D_CLASS_ID		= 0x51,
+};
+
+#endif
drivers/gpu/host1x/hw/cdma_hw.c new file +475 -0

475 lines not on this page · raw message

drivers/gpu/host1x/hw/cdma_hw.h new file +37 -0
new file mode 100644
index 0000000..80a085a
@@ -0,0 +1,37 @@
+/*
+ * Tegra host1x Command DMA
+ *
+ * Copyright (c) 2011-2013, NVIDIA Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __HOST1X_CDMA_HW_H
+#define __HOST1X_CDMA_HW_H
+
+/*
+ * Size of the sync queue. If it is too small, we won't be able to queue up
+ * many command buffers. If it is too large, we waste memory.
+ */
+#define HOST1X_SYNC_QUEUE_SIZE 512
+
+/*
+ * Number of gathers we allow to be queued up per channel. Must be a
+ * power of two. Currently sized such that pushbuffer is 4KB (512*8B).
+ */
+#define HOST1X_GATHER_QUEUE_SIZE 512
+
+/* 8 bytes per slot. (This number does not include the final RESTART.) */
+#define PUSH_BUFFER_SIZE (HOST1X_GATHER_QUEUE_SIZE * 8)
+
+#endif
drivers/gpu/host1x/hw/channel_hw.c new file +148 -0

148 lines not on this page · raw message

drivers/gpu/host1x/hw/host1x01.c +6 -0
index 3d633a3..7569a1e 100644
@@ -23,13 +23,19 @@
 
 #include "hw/host1x01.h"
 #include "dev.h"
+#include "channel.h"
 #include "hw/host1x01_hardware.h"
 
+#include "hw/channel_hw.c"
+#include "hw/cdma_hw.c"
 #include "hw/syncpt_hw.c"
 #include "hw/intr_hw.c"
 
 int host1x01_init(struct host1x *host)
 {
+	host->channel_op = host1x_channel_ops;
+	host->cdma_op = host1x_cdma_ops;
+	host->cdma_pb_op = host1x_pushbuffer_ops;
 	host->syncpt_op = host1x_syncpt_ops;
 	host->intr_op = host1x_intr_ops;
 
drivers/gpu/host1x/hw/host1x01_hardware.h +124 -0

130 lines not on this page · raw message

drivers/gpu/host1x/hw/hw_host1x01_channel.h new file +102 -0

102 lines not on this page · raw message

drivers/gpu/host1x/hw/hw_host1x01_sync.h +12 -0
index 5da9afb..3073d37 100644
@@ -69,6 +69,18 @@ static inline u32 host1x_sync_syncpt_thresh_int_enable_cpu0_r(void)
 }
 #define HOST1X_SYNC_SYNCPT_THRESH_INT_ENABLE_CPU0 \
 	host1x_sync_syncpt_thresh_int_enable_cpu0_r()
+static inline u32 host1x_sync_cmdproc_stop_r(void)
+{
+	return 0xac;
+}
+#define HOST1X_SYNC_CMDPROC_STOP \
+	host1x_sync_cmdproc_stop_r()
+static inline u32 host1x_sync_ch_teardown_r(void)
+{
+	return 0xb0;
+}
+#define HOST1X_SYNC_CH_TEARDOWN \
+	host1x_sync_ch_teardown_r()
 static inline u32 host1x_sync_usec_clk_r(void)
 {
 	return 0x1a4;
drivers/gpu/host1x/hw/hw_host1x01_uclass.h new file +168 -0

168 lines not on this page · raw message

drivers/gpu/host1x/hw/syncpt_hw.c +10 -0
index 16e3ada..ba48cee 100644
@@ -97,6 +97,15 @@ static void syncpt_cpu_incr(struct host1x_syncpt *sp)
 	wmb();
 }
 
+/* remove a wait pointed to by patch_addr */
+static int syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr)
+{
+	u32 override = host1x_class_host_wait_syncpt(
+			NVSYNCPT_GRAPHICS_HOST, 0);
+	__raw_writel(override, patch_addr);
+	return 0;
+}
+
 static const char *syncpt_name(struct host1x_syncpt *sp)
 {
 	struct host1x_device_info *info = &sp->dev->info;
@@ -141,6 +150,7 @@ static const struct host1x_syncpt_ops host1x_syncpt_ops = {
 	.read_wait_base = syncpt_read_wait_base,
 	.load_min = syncpt_load_min,
 	.cpu_incr = syncpt_cpu_incr,
+	.patch_wait = syncpt_patch_wait,
 	.debug = syncpt_debug,
 	.name = syncpt_name,
 };
drivers/gpu/host1x/intr.c +28 -1
index 26099b8..9d0b5f1 100644
@@ -20,6 +20,8 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/irq.h>
+#include <trace/events/host1x.h>
+#include "channel.h"
 #include "dev.h"
 
 /* Wait list management */
@@ -74,7 +76,7 @@ static void remove_completed_waiters(struct list_head *head, u32 sync,
 			struct list_head completed[HOST1X_INTR_ACTION_COUNT])
 {
 	struct list_head *dest;
-	struct host1x_waitlist *waiter, *next;
+	struct host1x_waitlist *waiter, *next, *prev;
 
 	list_for_each_entry_safe(waiter, next, head, list) {
 		if ((s32)(waiter->thresh - sync) > 0)
@@ -82,6 +84,17 @@ static void remove_completed_waiters(struct list_head *head, u32 sync,
 
 		dest = completed + waiter->action;
 
+		/* consolidate submit cleanups */
+		if (waiter->action == HOST1X_INTR_ACTION_SUBMIT_COMPLETE
+			&& !list_empty(dest)) {
+			prev = list_entry(dest->prev,
+					struct host1x_waitlist, list);
+			if (prev->data == waiter->data) {
+				prev->count++;
+				dest = NULL;
+			}
+		}
+
 		/* PENDING->REMOVED or CANCELLED->HANDLED */
 		if (atomic_inc_return(&waiter->state) == WLS_HANDLED || !dest) {
 			list_del(&waiter->list);
@@ -104,6 +117,19 @@ static void reset_threshold_interrupt(struct host1x_intr *intr,
 	host1x->intr_op.enable_syncpt_intr(intr, id);
 }
 
+static void action_submit_complete(struct host1x_waitlist *waiter)
+{
+	struct host1x_channel *channel = waiter->data;
+	int nr_completed = waiter->count;
+
+	host1x_cdma_update(&channel->cdma);
+
+	/*  Add nr_completed to trace */
+	trace_host1x_channel_submit_complete(channel->dev->name,
+			nr_completed, waiter->thresh);
+
+}
+
 static void action_wakeup(struct host1x_waitlist *waiter)
 {
 	wait_queue_head_t *wq = waiter->data;
@@ -121,6 +147,7 @@ static void action_wakeup_interruptible(struct host1x_waitlist *waiter)
 typedef void (*action_handler)(struct host1x_waitlist *waiter);
 
 static action_handler action_handlers[HOST1X_INTR_ACTION_COUNT] = {
+	action_submit_complete,
 	action_wakeup,
 	action_wakeup_interruptible,
 };
drivers/gpu/host1x/intr.h +6 -0
index 679a7b4..979b929 100644
@@ -24,6 +24,12 @@
 
 enum host1x_intr_action {
 	/*
+	 * Perform cleanup after a submit has completed.
+	 * 'data' points to a channel
+	 */
+	HOST1X_INTR_ACTION_SUBMIT_COMPLETE = 0,
+
+	/*
 	 * Wake up a  task.
 	 * 'data' points to a wait_queue_head_t
 	 */
drivers/gpu/host1x/job.c new file +612 -0

612 lines not on this page · raw message

drivers/gpu/host1x/job.h new file +164 -0

112 lines not on this page · raw message

drivers/gpu/host1x/memmgr.c new file +173 -0

173 lines not on this page · raw message

drivers/gpu/host1x/memmgr.h new file +72 -0

72 lines not on this page · raw message

drivers/gpu/host1x/syncpt.c +11 -0
index 32e2b42..f21c688 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/host1x/syncpt.h +4 -0
index b46d044..255a3a3 100644

Lines of this file are not shown. View the raw message.

include/trace/events/host1x.h +211 -0

211 lines not on this page · raw message

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

Signature · 1 line
1.7.9.5

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

#7 lore raw

PATCH v5 7/8 ARM: tegra: Add board data and 2D clocks

In reply to Terje Bergstrom

Add a driver alias gr2d for Tegra 2D device, and assign a duplicate of 2D clock to that driver alias.

---
 arch/arm/mach-tegra/board-dt-tegra20.c    |    1 +
 arch/arm/mach-tegra/board-dt-tegra30.c    |    1 +
 arch/arm/mach-tegra/tegra20_clocks_data.c |    2 +-
 arch/arm/mach-tegra/tegra30_clocks_data.c |    1 +
 4 files changed, 4 insertions(+), 1 deletion(-)
arch/arm/mach-tegra/board-dt-tegra20.c +1 -0
index 171ba3c..9fcc800 100644
@@ -96,6 +96,7 @@ static struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {
 	OF_DEV_AUXDATA("nvidia,tegra20-slink", 0x7000D800, "spi_tegra.2", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra20-slink", 0x7000DA00, "spi_tegra.3", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra20-host1x", 0x50000000, "host1x", NULL),
+	OF_DEV_AUXDATA("nvidia,tegra20-gr2d", 0x54140000, "gr2d", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra20-dc", 0x54200000, "tegradc.0", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra20-dc", 0x54240000, "tegradc.1", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra20-hdmi", 0x54280000, "hdmi", NULL),
arch/arm/mach-tegra/board-dt-tegra30.c +1 -0
index cfe5fc0..0b4a1f0 100644
@@ -59,6 +59,7 @@ static struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = {
 	OF_DEV_AUXDATA("nvidia,tegra30-slink", 0x7000DC00, "spi_tegra.4", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra30-slink", 0x7000DE00, "spi_tegra.5", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra30-host1x", 0x50000000, "host1x", NULL),
+	OF_DEV_AUXDATA("nvidia,tegra30-gr2d", 0x54140000, "gr2d", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra30-dc", 0x54200000, "tegradc.0", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra30-dc", 0x54240000, "tegradc.1", NULL),
 	OF_DEV_AUXDATA("nvidia,tegra30-hdmi", 0x54280000, "hdmi", NULL),
arch/arm/mach-tegra/tegra20_clocks_data.c +1 -1
index a23a073..15d440a 100644
@@ -1041,7 +1041,7 @@ static struct clk_duplicate tegra_clk_duplicates[] = {
 	CLK_DUPLICATE("usbd",	"utmip-pad",	NULL),
 	CLK_DUPLICATE("usbd",	"tegra-ehci.0",	NULL),
 	CLK_DUPLICATE("usbd",	"tegra-otg",	NULL),
-	CLK_DUPLICATE("2d",	"tegra_grhost",	"gr2d"),
+	CLK_DUPLICATE("2d",	"gr2d",	"gr2d"),
 	CLK_DUPLICATE("3d",	"tegra_grhost",	"gr3d"),
 	CLK_DUPLICATE("epp",	"tegra_grhost",	"epp"),
 	CLK_DUPLICATE("mpe",	"tegra_grhost",	"mpe"),
arch/arm/mach-tegra/tegra30_clocks_data.c +1 -0
index 741d264..5c4b7b7 100644
@@ -1338,6 +1338,7 @@ static struct clk_duplicate tegra_clk_duplicates[] = {
 	CLK_DUPLICATE("pll_p", "tegradc.0", "parent"),
 	CLK_DUPLICATE("pll_p", "tegradc.1", "parent"),
 	CLK_DUPLICATE("pll_d2_out0", "hdmi", "parent"),
+	CLK_DUPLICATE("2d", "gr2d", "gr2d"),
 };
 
 static struct clk *tegra_ptr_clks[] = {
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v5 6/8 gpu: host1x: Remove second host1x driver

In reply to Terje Bergstrom

Remove second host1x driver, and bind tegra-drm to the new host1x driver. The logic to parse device tree and track clients is moved to drm.c.

---
 drivers/gpu/host1x/Makefile        |    2 +-
 drivers/gpu/host1x/dev.c           |   58 +++++++++-
 drivers/gpu/host1x/dev.h           |    6 +
 drivers/gpu/host1x/drm/Kconfig     |    2 +-
 drivers/gpu/host1x/drm/dc.c        |    7 +-
 drivers/gpu/host1x/drm/drm.c       |  213 +++++++++++++++++++++++++++++++++++-
 drivers/gpu/host1x/drm/drm.h       |    3 -
 drivers/gpu/host1x/drm/hdmi.c      |    7 +-
 drivers/gpu/host1x/host1x_client.h |    9 ++
 9 files changed, 294 insertions(+), 13 deletions(-)
drivers/gpu/host1x/Makefile +1 -1
index ffc8bf1..c35ee19 100644
@@ -16,6 +16,6 @@ host1x-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o
 ccflags-y += -Iinclude/drm
 ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG
 
-host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o drm/host1x.o
+host1x-$(CONFIG_DRM_TEGRA) += drm/drm.o drm/fb.o drm/dc.o
 host1x-$(CONFIG_DRM_TEGRA) += drm/output.o drm/rgb.o drm/hdmi.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/dev.c +56 -2

89 lines not on this page · raw message

drivers/gpu/host1x/dev.h +6 -0
index 467a92e..ff3a365 100644
@@ -142,6 +142,8 @@ struct host1x {
 	int allocated_channels;
 
 	struct dentry *debugfs;
+
+	void *drm_data;
 };
 
 static inline
@@ -161,4 +163,8 @@ u32 host1x_sync_readl(struct host1x *host1x, u32 r);
 void host1x_ch_writel(struct host1x_channel *ch, u32 r, u32 v);
 u32 host1x_ch_readl(struct host1x_channel *ch, u32 r);
 
+extern struct platform_driver tegra_hdmi_driver;
+extern struct platform_driver tegra_dc_driver;
+extern struct platform_driver tegra_gr2d_driver;
+
 #endif
drivers/gpu/host1x/drm/Kconfig +1 -1
index be1daf7..7db9b3a 100644
@@ -1,5 +1,5 @@
 config DRM_TEGRA
-	tristate "NVIDIA Tegra DRM"
+	bool "NVIDIA Tegra DRM"
 	depends on DRM && OF && ARCH_TEGRA
 	select DRM_KMS_HELPER
 	select DRM_GEM_CMA_HELPER
drivers/gpu/host1x/drm/dc.c +5 -2
index 656b2e3..ac31e96 100644
@@ -17,6 +17,7 @@
 
 #include "drm.h"
 #include "dc.h"
+#include "host1x_client.h"
 
 struct tegra_dc_window {
 	fixed20_12 x;
@@ -736,7 +737,8 @@ static const struct host1x_client_ops dc_client_ops = {
 
 static int tegra_dc_probe(struct platform_device *pdev)
 {
-	struct host1x *host1x = dev_get_drvdata(pdev->dev.parent);
+	struct host1x *host1x =
+		host1x_get_drm_data(to_platform_device(pdev->dev.parent));
 	struct resource *regs;
 	struct tegra_dc *dc;
 	int err;
@@ -800,7 +802,8 @@ static int tegra_dc_probe(struct platform_device *pdev)
 
 static int tegra_dc_remove(struct platform_device *pdev)
 {
-	struct host1x *host1x = dev_get_drvdata(pdev->dev.parent);
+	struct host1x *host1x =
+		host1x_get_drm_data(to_platform_device(pdev->dev.parent));
 	struct tegra_dc *dc = platform_get_drvdata(pdev);
 	int err;
 
drivers/gpu/host1x/drm/drm.c +211 -2

230 lines not on this page · raw message

drivers/gpu/host1x/drm/drm.h +0 -3
index e68b4ac..e7101d5 100644
@@ -208,9 +208,6 @@ extern int tegra_output_exit(struct tegra_output *output);
 extern int tegra_drm_fb_init(struct drm_device *drm);
 extern void tegra_drm_fb_exit(struct drm_device *drm);
 
-extern struct platform_driver tegra_host1x_driver;
-extern struct platform_driver tegra_hdmi_driver;
-extern struct platform_driver tegra_dc_driver;
 extern struct drm_driver tegra_drm_driver;
 
 #endif /* HOST1X_DRM_H */
drivers/gpu/host1x/drm/hdmi.c +5 -2
index e060c7e..2f1e7b4 100644
@@ -20,6 +20,7 @@
 #include "hdmi.h"
 #include "drm.h"
 #include "dc.h"
+#include "host1x_client.h"
 
 struct tegra_hdmi {
 	struct host1x_client client;
@@ -1198,7 +1199,8 @@ static const struct host1x_client_ops hdmi_client_ops = {
 
 static int tegra_hdmi_probe(struct platform_device *pdev)
 {
-	struct host1x *host1x = dev_get_drvdata(pdev->dev.parent);
+	struct host1x *host1x =
+		host1x_get_drm_data(to_platform_device(pdev->dev.parent));
 	struct tegra_hdmi *hdmi;
 	struct resource *regs;
 	int err;
@@ -1287,7 +1289,8 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
 
 static int tegra_hdmi_remove(struct platform_device *pdev)
 {
-	struct host1x *host1x = dev_get_drvdata(pdev->dev.parent);
+	struct host1x *host1x =
+		host1x_get_drm_data(to_platform_device(pdev->dev.parent));
 	struct tegra_hdmi *hdmi = platform_get_drvdata(pdev);
 	int err;
 
drivers/gpu/host1x/host1x_client.h +9 -0
index fdd2920..938df7e 100644
@@ -19,6 +19,15 @@
 
 struct platform_device;
 
+#ifdef CONFIG_DRM_TEGRA
+int host1x_drm_alloc(struct platform_device *pdev);
+#else
+static inline int host1x_drm_alloc(struct platform_device *pdev)
+{
+	return 0;
+}
+#endif
+
 void host1x_set_drm_data(struct platform_device *pdev, void *data);
 void *host1x_get_drm_data(struct platform_device *pdev);
 
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v5 4/8 gpu: host1x: Add debug support

In reply to Terje Bergstrom

Add support for host1x debugging. Adds debugfs entries, and dumps channel state to UART in case of stuck job.

---
 drivers/gpu/host1x/Makefile                 |    1 +
 drivers/gpu/host1x/cdma.c                   |   34 +++
 drivers/gpu/host1x/debug.c                  |  215 ++++++++++++++
 drivers/gpu/host1x/debug.h                  |   50 ++++
 drivers/gpu/host1x/dev.c                    |    3 +
 drivers/gpu/host1x/dev.h                    |   17 ++
 drivers/gpu/host1x/hw/cdma_hw.c             |    3 +
 drivers/gpu/host1x/hw/debug_hw.c            |  400 +++++++++++++++++++++++++++
 drivers/gpu/host1x/hw/host1x01.c            |    2 +
 drivers/gpu/host1x/hw/hw_host1x01_channel.h |   18 ++
 drivers/gpu/host1x/hw/hw_host1x01_sync.h    |  115 ++++++++
 drivers/gpu/host1x/hw/syncpt_hw.c           |    1 +
 drivers/gpu/host1x/syncpt.c                 |    3 +
 13 files changed, 862 insertions(+)
 create mode 100644 drivers/gpu/host1x/debug.c
 create mode 100644 drivers/gpu/host1x/debug.h
 create mode 100644 drivers/gpu/host1x/hw/debug_hw.c
drivers/gpu/host1x/Makefile +1 -0
index cdd87c8..697d49a 100644
@@ -7,6 +7,7 @@ host1x-y = \
 	cdma.o \
 	channel.o \
 	job.o \
+	debug.o \
 	memmgr.o \
 	hw/host1x01.o
 
drivers/gpu/host1x/cdma.c +34 -0
index d6a38d2..12dd46c 100644
@@ -19,6 +19,7 @@
 #include "cdma.h"
 #include "channel.h"
 #include "dev.h"
+#include "debug.h"
 #include "memmgr.h"
 #include "job.h"
 #include <asm/cacheflush.h>
@@ -370,12 +371,42 @@ int host1x_cdma_begin(struct host1x_cdma *cdma, struct host1x_job *job)
 	return 0;
 }
 
+static void trace_write_gather(struct host1x_cdma *cdma,
+		struct mem_handle *ref,
+		u32 offset, u32 words)
+{
+	void *mem = NULL;
+
+	if (host1x_debug_trace_cmdbuf)
+		mem = host1x_memmgr_mmap(ref);
+
+	if (mem) {
+		u32 i;
+		/*
+		 * Write in batches of 128 as there seems to be a limit
+		 * of how much you can output to ftrace at once.
+		 */
+		for (i = 0; i < words; i += TRACE_MAX_LENGTH) {
+			trace_host1x_cdma_push_gather(
+				cdma_to_channel(cdma)->dev->name,
+				(u32)ref,
+				min(words - i, TRACE_MAX_LENGTH),
+				offset + i * sizeof(u32),
+				mem);
+		}
+		host1x_memmgr_munmap(ref, mem);
+	}
+}
+
 /*
  * Push two words into a push buffer slot
  * Blocks as necessary if the push buffer is full.
  */
 void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2)
 {
+	if (host1x_debug_trace_cmdbuf)
+		trace_host1x_cdma_push(cdma_to_channel(cdma)->dev->name,
+				op1, op2);
 	host1x_cdma_push_gather(cdma, NULL, 0, op1, op2);
 }
 
@@ -391,6 +422,9 @@ void host1x_cdma_push_gather(struct host1x_cdma *cdma,
 	u32 slots_free = cdma->slots_free;
 	struct push_buffer *pb = &cdma->push_buffer;
 
+	if (handle)
+		trace_write_gather(cdma, handle, offset, op1 & 0xffff);
+
 	if (slots_free == 0) {
 		host1x->cdma_op.kick(cdma);
 		slots_free = host1x_cdma_wait_locked(cdma,
drivers/gpu/host1x/debug.c new file +215 -0

215 lines not on this page · raw message

drivers/gpu/host1x/debug.h new file +50 -0

50 lines not on this page · raw message

drivers/gpu/host1x/dev.c +3 -0
index 80311ca..5aa7d28 100644
@@ -26,6 +26,7 @@
 #include "dev.h"
 #include "intr.h"
 #include "channel.h"
+#include "debug.h"
 #include "hw/host1x01.h"
 
 #define CREATE_TRACE_POINTS
@@ -150,6 +151,8 @@ static int host1x_probe(struct platform_device *dev)
 
 	host1x_intr_start(&host->intr, clk_get_rate(host->clk));
 
+	host1x_debug_init(host);
+
 	dev_info(&dev->dev, "initialized\n");
 
 	return 0;
drivers/gpu/host1x/dev.h +17 -0
index 2fefa78..467a92e 100644
@@ -33,6 +33,7 @@ struct push_buffer;
 struct dentry;
 struct mem_handle;
 struct platform_device;
+struct output;
 
 struct host1x_channel_ops {
 	int (*init)(struct host1x_channel *,
@@ -71,6 +72,21 @@ struct host1x_pushbuffer_ops {
 	u32 (*putptr)(struct push_buffer *);
 };
 
+struct host1x_debug_ops {
+	void (*debug_init)(struct dentry *de);
+	void (*show_channel_cdma)(struct host1x *,
+				  struct host1x_channel *,
+				  struct output *,
+				  int chid);
+	void (*show_channel_fifo)(struct host1x *,
+				  struct host1x_channel *,
+				  struct output *,
+				  int chid);
+	void (*show_mlocks)(struct host1x *m,
+			    struct output *o);
+
+};
+
 struct host1x_syncpt_ops {
 	void (*reset)(struct host1x_syncpt *);
 	void (*reset_wait_base)(struct host1x_syncpt *);
@@ -117,6 +133,7 @@ struct host1x {
 	struct host1x_channel_ops channel_op;
 	struct host1x_cdma_ops cdma_op;
 	struct host1x_pushbuffer_ops cdma_pb_op;
+	struct host1x_debug_ops debug_op;
 	struct host1x_syncpt_ops syncpt_op;
 	struct host1x_intr_ops intr_op;
 
drivers/gpu/host1x/hw/cdma_hw.c +3 -0
index 7a44418..2228246 100644
@@ -22,6 +22,7 @@
 #include "cdma.h"
 #include "channel.h"
 #include "dev.h"
+#include "debug.h"
 #include "memmgr.h"
 
 #include "cdma_hw.h"
@@ -407,6 +408,8 @@ static void cdma_timeout_handler(struct work_struct *work)
 	host1x = cdma_to_host1x(cdma);
 	ch = cdma_to_channel(cdma);
 
+	host1x_debug_dump(cdma_to_host1x(cdma));
+
 	mutex_lock(&cdma->lock);
 
 	if (!cdma->timeout.clientid) {
drivers/gpu/host1x/hw/debug_hw.c new file +400 -0

400 lines not on this page · raw message

drivers/gpu/host1x/hw/host1x01.c +2 -0
index 7569a1e..1bc1552 100644
@@ -28,6 +28,7 @@
 
 #include "hw/channel_hw.c"
 #include "hw/cdma_hw.c"
+#include "hw/debug_hw.c"
 #include "hw/syncpt_hw.c"
 #include "hw/intr_hw.c"
 
@@ -36,6 +37,7 @@ int host1x01_init(struct host1x *host)
 	host->channel_op = host1x_channel_ops;
 	host->cdma_op = host1x_cdma_ops;
 	host->cdma_pb_op = host1x_pushbuffer_ops;
+	host->debug_op = host1x_debug_ops;
 	host->syncpt_op = host1x_syncpt_ops;
 	host->intr_op = host1x_intr_ops;
 
drivers/gpu/host1x/hw/hw_host1x01_channel.h +18 -0
index dad4fee..79bcd5a 100644
@@ -51,6 +51,18 @@
 #ifndef __hw_host1x_channel_host1x_h__
 #define __hw_host1x_channel_host1x_h__
 
+static inline u32 host1x_channel_fifostat_r(void)
+{
+	return 0x0;
+}
+#define HOST1X_CHANNEL_FIFOSTAT \
+	host1x_channel_fifostat_r()
+static inline u32 host1x_channel_fifostat_cfempty_v(u32 r)
+{
+	return (r >> 10) & 0x1;
+}
+#define HOST1X_CHANNEL_FIFOSTAT_CFEMPTY_V(r) \
+	host1x_channel_fifostat_cfempty_v(r)
 static inline u32 host1x_channel_dmastart_r(void)
 {
 	return 0x14;
@@ -87,6 +99,12 @@ static inline u32 host1x_channel_dmactrl_dmastop_f(u32 v)
 }
 #define HOST1X_CHANNEL_DMACTRL_DMASTOP_F(v) \
 	host1x_channel_dmactrl_dmastop_f(v)
+static inline u32 host1x_channel_dmactrl_dmastop_v(u32 r)
+{
+	return (r >> 0) & 0x1;
+}
+#define HOST1X_CHANNEL_DMACTRL_DMASTOP_V(r) \
+	host1x_channel_dmactrl_dmastop_v(r)
 static inline u32 host1x_channel_dmactrl_dmagetrst_f(u32 v)
 {
 	return (v & 0x1) << 1;
drivers/gpu/host1x/hw/hw_host1x01_sync.h +115 -0

131 lines not on this page · raw message

drivers/gpu/host1x/hw/syncpt_hw.c +1 -0
index ba48cee..c64c3b0 100644
@@ -90,6 +90,7 @@ static void syncpt_cpu_incr(struct host1x_syncpt *sp)
 		dev_err(&dev->dev->dev,
 			"Trying to increment syncpoint id %d beyond max\n",
 			sp->id);
+		host1x_debug_dump(sp->dev);
 		return;
 	}
 	host1x_sync_writel(dev, BIT_MASK(sp->id),
drivers/gpu/host1x/syncpt.c +3 -0
index f21c688..191f65f 100644
@@ -23,6 +23,7 @@
 #include "syncpt.h"
 #include "dev.h"
 #include "intr.h"
+#include "debug.h"
 #include <trace/events/host1x.h>
 
 #define MAX_SYNCPT_LENGTH	5
@@ -211,6 +212,8 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp,
 				 current->comm, sp->id, sp->name,
 				 thresh, timeout);
 			sp->dev->syncpt_op.debug(sp);
+			if (check_count == MAX_STUCK_CHECK_COUNT)
+				host1x_debug_dump(sp->dev);
 			check_count++;
 		}
 	}
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v5 2/8 gpu: host1x: Add syncpoint wait and interrupts

In reply to Terje Bergstrom

Add support for sync point interrupts, and sync point wait. Sync point wait used interrupts for unblocking wait.

---
 drivers/gpu/host1x/Makefile              |    1 +
 drivers/gpu/host1x/dev.c                 |   21 +-
 drivers/gpu/host1x/dev.h                 |   17 +-
 drivers/gpu/host1x/hw/host1x01.c         |    2 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h |   42 ++++
 drivers/gpu/host1x/hw/intr_hw.c          |  178 +++++++++++++++
 drivers/gpu/host1x/intr.c                |  356 ++++++++++++++++++++++++++++++
 drivers/gpu/host1x/intr.h                |  103 +++++++++
 drivers/gpu/host1x/syncpt.c              |  163 ++++++++++++++
 drivers/gpu/host1x/syncpt.h              |    5 +
 10 files changed, 883 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/host1x/hw/intr_hw.c
 create mode 100644 drivers/gpu/host1x/intr.c
 create mode 100644 drivers/gpu/host1x/intr.h
drivers/gpu/host1x/Makefile +1 -0
index 363e6ab..5ef47ff 100644
@@ -3,6 +3,7 @@ ccflags-y = -Idrivers/gpu/host1x
 host1x-y = \
 	syncpt.o \
 	dev.o \
+	intr.o \
 	hw/host1x01.o
 
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/dev.c +17 -4
index cd2b1ef..7f9f389 100644
@@ -24,6 +24,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include "dev.h"
+#include "intr.h"
 #include "hw/host1x01.h"
 
 #define CREATE_TRACE_POINTS
@@ -95,7 +96,6 @@ static int host1x_probe(struct platform_device *dev)
 
 	/* set common host1x device data */
 	platform_set_drvdata(dev, host);
-
 	host->regs = devm_request_and_ioremap(&dev->dev, regs);
 	if (!host->regs) {
 		dev_err(&dev->dev, "failed to remap host registers\n");
@@ -109,28 +109,40 @@ static int host1x_probe(struct platform_device *dev)
 	}
 
 	err = host1x_syncpt_init(host);
-	if (err)
+	if (err) {
+		dev_err(&dev->dev, "failed to init sync points");
 		return err;
+	}
+
+	err = host1x_intr_init(&host->intr, syncpt_irq);
+	if (err) {
+		dev_err(&dev->dev, "failed to init irq");
+		goto fail_deinit_syncpt;
+	}
 
 	host->clk = devm_clk_get(&dev->dev, NULL);
 	if (IS_ERR(host->clk)) {
 		dev_err(&dev->dev, "failed to get clock\n");
 		err = PTR_ERR(host->clk);
-		goto fail_deinit_syncpt;
+		goto fail_deinit_intr;
 	}
 
 	err = clk_prepare_enable(host->clk);
 	if (err < 0) {
 		dev_err(&dev->dev, "failed to enable clock\n");
-		goto fail_deinit_syncpt;
+		goto fail_deinit_intr;
 	}
 
 	host1x_syncpt_reset(host);
 
+	host1x_intr_start(&host->intr, clk_get_rate(host->clk));
+
 	dev_info(&dev->dev, "initialized\n");
 
 	return 0;
 
+fail_deinit_intr:
+	host1x_intr_deinit(&host->intr);
 fail_deinit_syncpt:
 	host1x_syncpt_deinit(host);
 	return err;
@@ -139,6 +151,7 @@ fail_deinit_syncpt:
 static int __exit host1x_remove(struct platform_device *dev)
 {
 	struct host1x *host = platform_get_drvdata(dev);
+	host1x_intr_deinit(&host->intr);
 	host1x_syncpt_deinit(host);
 	clk_disable_unprepare(host->clk);
 	return 0;
drivers/gpu/host1x/dev.h +16 -1
index d8f5979..8376092 100644
@@ -17,11 +17,12 @@
 #ifndef HOST1X_DEV_H
 #define HOST1X_DEV_H
 
+#include <linux/platform_device.h>
 #include "syncpt.h"
+#include "intr.h"
 
 struct host1x;
 struct host1x_syncpt;
-struct platform_device;
 
 struct host1x_syncpt_ops {
 	void (*reset)(struct host1x_syncpt *);
@@ -34,6 +35,18 @@ struct host1x_syncpt_ops {
 	const char * (*name)(struct host1x_syncpt *);
 };
 
+struct host1x_intr_ops {
+	void (*init_host_sync)(struct host1x_intr *);
+	void (*set_host_clocks_per_usec)(
+		struct host1x_intr *, u32 clocks);
+	void (*set_syncpt_threshold)(
+		struct host1x_intr *, u32 id, u32 thresh);
+	void (*enable_syncpt_intr)(struct host1x_intr *, u32 id);
+	void (*disable_syncpt_intr)(struct host1x_intr *, u32 id);
+	void (*disable_all_syncpt_intrs)(struct host1x_intr *);
+	int (*free_syncpt_irq)(struct host1x_intr *);
+};
+
 struct host1x_device_info {
 	int	nb_channels;		/* host1x: num channels supported */
 	int	nb_pts;			/* host1x: num syncpoints supported */
@@ -46,11 +59,13 @@ struct host1x_device_info {
 struct host1x {
 	void __iomem *regs;
 	struct host1x_syncpt *syncpt;
+	struct host1x_intr intr;
 	struct platform_device *dev;
 	struct host1x_device_info info;
 	struct clk *clk;
 
 	struct host1x_syncpt_ops syncpt_op;
+	struct host1x_intr_ops intr_op;
 
 	struct dentry *debugfs;
 };
drivers/gpu/host1x/hw/host1x01.c +2 -0
index ea6e604..3d633a3 100644
@@ -26,10 +26,12 @@
 #include "hw/host1x01_hardware.h"
 
 #include "hw/syncpt_hw.c"
+#include "hw/intr_hw.c"
 
 int host1x01_init(struct host1x *host)
 {
 	host->syncpt_op = host1x_syncpt_ops;
+	host->intr_op = host1x_intr_ops;
 
 	return 0;
 }
drivers/gpu/host1x/hw/hw_host1x01_sync.h +42 -0

54 lines not on this page · raw message

drivers/gpu/host1x/hw/intr_hw.c new file +178 -0

178 lines not on this page · raw message

drivers/gpu/host1x/intr.c new file +356 -0

356 lines not on this page · raw message

drivers/gpu/host1x/intr.h new file +103 -0

103 lines not on this page · raw message

drivers/gpu/host1x/syncpt.c +163 -0

178 lines not on this page · raw message

drivers/gpu/host1x/syncpt.h +5 -0
index d9b9b0a..b46d044 100644
@@ -114,6 +114,7 @@ void host1x_syncpt_cpu_incr(struct host1x_syncpt *sp);
 
 /* Load current value from hardware to the shadow register. */
 u32 host1x_syncpt_load_min(struct host1x_syncpt *sp);
+bool host1x_syncpt_is_expired(struct host1x_syncpt *sp, u32 thresh);
 
 /* Save host1x sync point state into shadow registers. */
 void host1x_syncpt_save(struct host1x *dev);
@@ -133,6 +134,10 @@ u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs);
 /* Do a debug dump of sync point values. */
 void host1x_syncpt_debug(struct host1x_syncpt *sp);
 
+/* Wait until sync point reaches a threshold value, or a timeout. */
+int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh,
+			long timeout, u32 *value);
+
 /* Check if sync point id is valid. */
 static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp)
 {
Signature · 1 line
1.7.9.5
#13 lore raw
In reply to Terje Bergstrom
Quoted 26 lines · Terje Bergstrom

This set of patches adds support for Tegra20 and Tegra30 host1x and 2D. It is based on linux-next-20130114.

The fifth version merges DRM and host1x drivers into one driver. This allowed moving include/linux/host1x.h back into the driver and removed the need for a dummy platform device. This version also uses the code from tegradrm driver almost as is, so there are a lot less actual code changes.

This patch set does not have the host1x allocator, but it uses CMA helpers for memory management.

host1x is the driver that controls host1x hardware. It supports host1x command channels, synchronization, and memory management. It is sectioned into logical driver under drivers/gpu/host1x and physical driver under drivers/host1x/hw. The physical driver is compiled with the hardware headers of the particular host1x version.

The hardware units are described (briefly) in the Tegra2 TRM. Wiki page https://gitorious.org/linux-tegra-drm/pages/Host1xIntroduction
also contains a short description of the functionality.

The patch set merges tegradrm into host1x and adds 2D driver, which uses host1x channels and sync points. The patch set also adds user space API to tegradrm for accessing host1x and 2D.

Quoted 9 lines

Terje Bergstrom (8):
gpu: host1x: Add host1x driver
gpu: host1x: Add syncpoint wait and interrupts
gpu: host1x: Add channel support
gpu: host1x: Add debug support
drm: tegra: Move drm to live under host1x
gpu: host1x: Remove second host1x driver
ARM: tegra: Add board data and 2D clocks
drm: tegra: Add gr2d device

Hi Terje,

Just by a quick glance this looks like we're getting closer. To make reviewing easier, would you mind resending patches formatted with -M so that git actually detects that tegra-drm was moved. That should make it easy to see what exactly needed to be changed besides the relocation.

Thierry

#8 lore raw

Re: [PATCHv5 7/8] ARM: tegra: Add board data and 2D clocks

In reply to Terje Bergstrom
Quoted 2 lines · Terje Bergstrom

Add a driver alias gr2d for Tegra 2D device, and assign a duplicate of 2D clock to that driver alias.

FYI on this one patch - it won't be applied to the Tegra tree until after Prashant's common clock framework changes are applied. As such, it will need some rework once those patches are applied, or perhaps won't even be relevant any more; see below.

arch/arm/mach-tegra/board-dt-tegra20.c

Quoted 3 lines
arch/arm/mach-tegra/board-dt-tegra20.c +1 -0
 
+	OF_DEV_AUXDATA("nvidia,tegra20-gr2d", 0x54140000, "gr2d", NULL),

I assume the only reason to add AUXDATA is to give the device a specific name, which will then match the driver name in the clock driver:

arch/arm/mach-tegra/board-dt-tegra20.c

Quoted 2 lines
arch/arm/mach-tegra/board-dt-tegra20.c +1 -1
-	CLK_DUPLICATE("2d",	"tegra_grhost",	"gr2d"),
+	CLK_DUPLICATE("2d",	"gr2d",	"gr2d"),

If so, this shouldn't be needed once the common clock framework patches are applied, since all device clocks will be retrieved from device tree, and hence the device name will be irrelevant; the phandle in device tree is all that will matter.

#9 lore raw

Re: [PATCHv5 7/8] ARM: tegra: Add board data and 2D clocks

Quoted 7 lines · Stephen Warren

arch/arm/mach-tegra/board-dt-tegra20.c

Quoted 3 lines
arch/arm/mach-tegra/board-dt-tegra20.c +1 -0
 
+	OF_DEV_AUXDATA("nvidia,tegra20-gr2d", 0x54140000, "gr2d", NULL),

I assume the only reason to add AUXDATA is to give the device a specific name, which will then match the driver name in the clock driver:

Quoted 7 lines

arch/arm/mach-tegra/board-dt-tegra20.c

Quoted 2 lines
arch/arm/mach-tegra/board-dt-tegra20.c +1 -1
-	CLK_DUPLICATE("2d",	"tegra_grhost",	"gr2d"),
+	CLK_DUPLICATE("2d",	"gr2d",	"gr2d"),

If so, this shouldn't be needed once the common clock framework patches are applied, since all device clocks will be retrieved from device tree, and hence the device name will be irrelevant; the phandle in device tree is all that will matter.

Yes, clock binding is the only reason for the OF_DEV_AUXDATA line. I'll need to look into Prashant's clock changes, but I assume it's going to be a trivial change to host1x patches.

Thanks for the heads-up.

Terje

#10 lore raw

Re: [PATCHv5 7/8] ARM: tegra: Add board data and 2D clocks

In reply to Stephen Warren
Quoted 8 lines · Stephen Warren
Quoted 2 lines · Terje Bergstrom

Add a driver alias gr2d for Tegra 2D device, and assign a duplicate of 2D clock to that driver alias.

FYI on this one patch - it won't be applied to the Tegra tree until after Prashant's common clock framework changes are applied. As such, it will need some rework once those patches are applied, or perhaps won't even be relevant any more; see below.

It looks like I need to just drop the patch 7(8 "ARM: tegra: Add board data and 2D clocks" and change the 2D code to access the clock without a name. Do you agree?

I'll roll this into the next patch version once I've gathered more comments.

drivers/gpu/host1x/drm/gr2d.c +1 -1
index dc7d6c6..a1c5f5c 100644
@@ -259,7 +259,7 @@ static int gr2d_probe(struct platform_device *dev)
        if (!gr2d)
                return -ENOMEM;
 
-       gr2d->clk = devm_clk_get(&dev->dev, "gr2d");
+       gr2d->clk = devm_clk_get(&dev->dev, NULL);
        if (IS_ERR(gr2d->clk)) {
                dev_err(&dev->dev, "cannot get clock\n");
                return PTR_ERR(gr2d->clk);

Terje

#11 lore raw

Re: [PATCHv5 7/8] ARM: tegra: Add board data and 2D clocks

Quoted 5 lines · Terje Bergström
Quoted 4 lines · Stephen Warren
Quoted 2 lines · Terje Bergstrom

Add a driver alias gr2d for Tegra 2D device, and assign a duplicate of 2D clock to that driver alias.

Quoted 8 lines
Quoted 4 lines

FYI on this one patch - it won't be applied to the Tegra tree until after Prashant's common clock framework changes are applied. As such, it will need some rework once those patches are applied, or perhaps won't even be relevant any more; see below.

It looks like I need to just drop the patch 7(8 "ARM: tegra: Add board data and 2D clocks" and change the 2D code to access the clock without a name. Do you agree?

That sounds right to me, yes.