Skip to contentSkip to conversation

Support for Tegra 2D hardware

PATCH Superseded Terje Bergstrom 1 participant 10 messages Mar 8, 2013

Subsystems (6)

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

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

Changes in this version:
* Rebased on latest tegradrm
* Renamed tegradrm's host1x to host1x_drm
* Indentation and line split fixed to follow tegradrm convention
* Pointers to platform_device replaced with pointers to device
* Added host1x allocator, and wired it in
* Debug spew code fixed to access mem handles from host1x_job
* CDMA code doesn't keep the mem handles anymore
* Push buffer ops have been made generic code
* Removed the pin_array optimization in host1x_job to simplify code
* Large number of smaller changes

The driver implements an allocator using the DRM CMA helper. Each buffer is assigned an ops structure to operate on it. In future the DRM CMA helper will be replaced with an own allocator to implement IOMMU support.

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 http://http.download.nvidia.com/tegra-public-appnotes/host1x.html
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.

The changes to add support to libdrm are in [email protected]:linux-host1x/libdrm-host1x.git

Arto Merilainen (2):
gpu: host1x: drm: Rename host1x to host1x_drm
gpu: host1x: drm: Add CMA ops for host1x driver

Terje Bergstrom (7):
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
drm: tegra: Add gr2d device

 drivers/gpu/Makefile                           |    1 +
 drivers/gpu/drm/Kconfig                        |    2 -
 drivers/gpu/drm/Makefile                       |    1 -
 drivers/gpu/drm/tegra/Makefile                 |    7 -
 drivers/gpu/drm/tegra/drm.c                    |  217 --------
 drivers/gpu/drm/tegra/host1x.c                 |  327 ------------
 drivers/gpu/host1x/Kconfig                     |   23 +
 drivers/gpu/host1x/Makefile                    |   21 +
 drivers/gpu/host1x/cdma.c                      |  491 ++++++++++++++++++
 drivers/gpu/host1x/cdma.h                      |  102 ++++
 drivers/gpu/host1x/channel.c                   |  120 +++++
 drivers/gpu/host1x/channel.h                   |   52 ++
 drivers/gpu/host1x/debug.c                     |  210 ++++++++
 drivers/gpu/host1x/debug.h                     |   51 ++
 drivers/gpu/host1x/dev.c                       |  248 +++++++++
 drivers/gpu/host1x/dev.h                       |  317 ++++++++++++
 drivers/gpu/{drm/tegra => host1x/drm}/Kconfig  |    2 +-
 drivers/gpu/host1x/drm/cma.c                   |   87 ++++
 drivers/gpu/host1x/drm/cma.h                   |   26 +
 drivers/gpu/{drm/tegra => host1x/drm}/dc.c     |    5 +-
 drivers/gpu/{drm/tegra => host1x/drm}/dc.h     |    0
 drivers/gpu/host1x/drm/drm.c                   |  661 ++++++++++++++++++++++++
 drivers/gpu/{drm/tegra => host1x/drm}/drm.h    |   51 +-
 drivers/gpu/{drm/tegra => host1x/drm}/fb.c     |    6 +-
 drivers/gpu/host1x/drm/gr2d.c                  |  325 ++++++++++++
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c   |    5 +-
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h   |    0
 drivers/gpu/{drm/tegra => host1x/drm}/output.c |    0
 drivers/gpu/{drm/tegra => host1x/drm}/rgb.c    |    0
 drivers/gpu/host1x/host1x.h                    |   29 ++
 drivers/gpu/host1x/host1x_client.h             |   35 ++
 drivers/gpu/host1x/hw/Makefile                 |    6 +
 drivers/gpu/host1x/hw/cdma_hw.c                |  327 ++++++++++++
 drivers/gpu/host1x/hw/channel_hw.c             |  167 ++++++
 drivers/gpu/host1x/hw/debug_hw.c               |  322 ++++++++++++
 drivers/gpu/host1x/hw/host1x01.c               |   42 ++
 drivers/gpu/host1x/hw/host1x01.h               |   25 +
 drivers/gpu/host1x/hw/host1x01_hardware.h      |  143 +++++
 drivers/gpu/host1x/hw/hw_host1x01_channel.h    |  120 +++++
 drivers/gpu/host1x/hw/hw_host1x01_sync.h       |  243 +++++++++
 drivers/gpu/host1x/hw/hw_host1x01_uclass.h     |  174 +++++++
 drivers/gpu/host1x/hw/intr_hw.c                |  143 +++++
 drivers/gpu/host1x/hw/syncpt_hw.c              |  114 ++++
 drivers/gpu/host1x/intr.c                      |  354 +++++++++++++
 drivers/gpu/host1x/intr.h                      |  102 ++++
 drivers/gpu/host1x/job.c                       |  598 +++++++++++++++++++++
 drivers/gpu/host1x/job.h                       |  158 ++++++
 drivers/gpu/host1x/memmgr.c                    |   82 +++
 drivers/gpu/host1x/memmgr.h                    |   64 +++
 drivers/gpu/host1x/syncpt.c                    |  387 ++++++++++++++
 drivers/gpu/host1x/syncpt.h                    |  165 ++++++
 drivers/video/Kconfig                          |    2 +
 include/drm/tegra_drm.h                        |  131 +++++
 include/trace/events/host1x.h                  |  272 ++++++++++
 54 files changed, 6987 insertions(+), 576 deletions(-)
 delete mode 100644 drivers/gpu/drm/tegra/Makefile
 delete mode 100644 drivers/gpu/drm/tegra/drm.c
 delete mode 100644 drivers/gpu/drm/tegra/host1x.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/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
 rename drivers/gpu/{drm/tegra => host1x/drm}/Kconfig (94%)
 create mode 100644 drivers/gpu/host1x/drm/cma.c
 create mode 100644 drivers/gpu/host1x/drm/cma.h
 rename drivers/gpu/{drm/tegra => host1x/drm}/dc.c (99%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/dc.h (100%)
 create mode 100644 drivers/gpu/host1x/drm/drm.c
 rename drivers/gpu/{drm/tegra => host1x/drm}/drm.h (82%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/fb.c (89%)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 rename drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c (99%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/output.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/rgb.c (100%)
 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/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
#1 lore raw

PATCH v6 1/9 gpu: host1x: Add host1x driver

Add host1x, the driver for host1x and its client unit 2D. The Tegra host1x module is the DMA engine for register access to Tegra's graphics- and multimedia-related modules. The modules served by host1x are referred to as clients. host1x includes some other functionality, such as synchronization.

---
 drivers/gpu/Makefile                      |    1 +
 drivers/gpu/host1x/Kconfig                |    9 ++
 drivers/gpu/host1x/Makefile               |    8 ++
 drivers/gpu/host1x/dev.c                  |  155 +++++++++++++++++++++
 drivers/gpu/host1x/dev.h                  |  104 ++++++++++++++
 drivers/gpu/host1x/hw/Makefile            |    6 +
 drivers/gpu/host1x/hw/host1x01.c          |   33 +++++
 drivers/gpu/host1x/hw/host1x01.h          |   25 ++++
 drivers/gpu/host1x/hw/host1x01_hardware.h |   27 ++++
 drivers/gpu/host1x/hw/hw_host1x01_sync.h  |   74 ++++++++++
 drivers/gpu/host1x/hw/syncpt_hw.c         |  102 ++++++++++++++
 drivers/gpu/host1x/syncpt.c               |  212 +++++++++++++++++++++++++++++
 drivers/gpu/host1x/syncpt.h               |  147 ++++++++++++++++++++
 drivers/video/Kconfig                     |    2 +
 include/trace/events/host1x.h             |   61 +++++++++
 15 files changed, 966 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 30879df..d8a22c2 100644
@@ -1 +1,2 @@
 obj-y			+= drm/ vga/
+obj-$(CONFIG_TEGRA_HOST1X)	+= host1x/
drivers/gpu/host1x/Kconfig new file +9 -0
new file mode 100644
index 0000000..c01c450
@@ -0,0 +1,9 @@
+config TEGRA_HOST1X
+	tristate "NVIDIA Tegra host1x driver"
+	help
+	  Driver for the NVIDIA Tegra host1x hardware.
+
+	  The Tegra host1x module is the DMA engine for register access to
+	  Tegra's graphics- and multimedia-related modules. The modules served
+	  by host1x are referred to as clients. host1x includes some other
+	  functionality, such as synchronization.
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 +155 -0

155 lines not on this page · raw message

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

104 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 +33 -0
new file mode 100644
index 0000000..612b457
@@ -0,0 +1,33 @@
+/*
+ * 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 hw specification */
+#include "hw/host1x01.h"
+#include "hw/host1x01_hardware.h"
+
+/* include code */
+#include "hw/syncpt_hw.c"
+
+#include "dev.h"
+
+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..2706b67
@@ -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 *host);
+
+#endif /* HOST1X_HOST1X01_H_ */
drivers/gpu/host1x/hw/host1x01_hardware.h new file +27 -0
new file mode 100644
index 0000000..8cecbee
@@ -0,0 +1,27 @@
+/*
+ * 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 +74 -0

74 lines not on this page · raw message

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

102 lines not on this page · raw message

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

212 lines not on this page · raw message

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

147 lines not on this page · raw message

drivers/video/Kconfig +2 -0
index 4c1546f..3e0e3f0 100644
@@ -21,6 +21,8 @@ source "drivers/gpu/vga/Kconfig"
 
 source "drivers/gpu/drm/Kconfig"
 
+source "drivers/gpu/host1x/Kconfig"
+
 config VGASTATE
        tristate
        default n
include/trace/events/host1x.h new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v6 2/9 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                 |   12 ++
 drivers/gpu/host1x/dev.h                 |   51 +++++
 drivers/gpu/host1x/hw/host1x01.c         |    2 +
 drivers/gpu/host1x/hw/hw_host1x01_sync.h |   42 ++++
 drivers/gpu/host1x/hw/intr_hw.c          |  143 +++++++++++++
 drivers/gpu/host1x/intr.c                |  328 ++++++++++++++++++++++++++++++
 drivers/gpu/host1x/intr.h                |   96 +++++++++
 drivers/gpu/host1x/syncpt.c              |  159 +++++++++++++++
 drivers/gpu/host1x/syncpt.h              |   14 +-
 10 files changed, 847 insertions(+), 1 deletion(-)
 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 +12 -0
index d95a9b2..4421e28 100644
@@ -28,6 +28,7 @@
 #include <trace/events/host1x.h>
 
 #include "dev.h"
+#include "intr.h"
 #include "hw/host1x01.h"
 
 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
@@ -127,12 +128,23 @@ static int host1x_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	err = host1x_intr_init(host, syncpt_irq);
+	if (err) {
+		dev_err(dev, "failed to init irq");
+		goto fail_deinit_syncpt;
+	}
+
 	return 0;
+
+fail_deinit_syncpt:
+	host1x_syncpt_deinit(host);
+	return err;
 }
 
 static int __exit host1x_remove(struct platform_device *pdev)
 {
 	struct host1x *host = platform_get_drvdata(pdev);
+	host1x_intr_deinit(host);
 	host1x_syncpt_deinit(host);
 	clk_disable_unprepare(host->clk);
 	return 0;
drivers/gpu/host1x/dev.h +51 -0

74 lines not on this page · raw message

drivers/gpu/host1x/hw/host1x01.c +2 -0
index 612b457..f5c35fa 100644
@@ -21,6 +21,7 @@
 #include "hw/host1x01_hardware.h"
 
 /* include code */
+#include "hw/intr_hw.c"
 #include "hw/syncpt_hw.c"
 
 #include "dev.h"
@@ -28,6 +29,7 @@
 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

48 lines not on this page · raw message

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

143 lines not on this page · raw message

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

328 lines not on this page · raw message

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

96 lines not on this page · raw message

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

171 lines not on this page · raw message

drivers/gpu/host1x/syncpt.h +13 -1
index 119ccd5..17c1616 100644
@@ -19,9 +19,11 @@
 #ifndef __HOST1X_SYNCPT_H
 #define __HOST1X_SYNCPT_H
 
+#include <linux/atomic.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/atomic.h>
+
+#include "intr.h"
 
 struct host1x;
 
@@ -34,6 +36,9 @@ struct host1x_syncpt {
 	int client_managed;
 	struct host1x *host;
 	struct device *dev;
+
+	/* interrupt data */
+	struct host1x_syncpt_intr intr;
 };
 
 /* Initialize sync point array  */
@@ -113,6 +118,9 @@ void host1x_syncpt_cpu_incr(struct host1x_syncpt *sp);
 /* Load current value from hardware to the shadow register. */
 u32 host1x_syncpt_load(struct host1x_syncpt *sp);
 
+/* Check if the given syncpoint value has already passed */
+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 *host);
 
@@ -128,6 +136,10 @@ void host1x_syncpt_incr(struct host1x_syncpt *sp);
 /* Indicate future operations by incrementing the sync point max. */
 u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs);
 
+/* 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
#3 lore raw

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

---
 drivers/gpu/host1x/Kconfig                  |   12 +
 drivers/gpu/host1x/Makefile                 |    4 +
 drivers/gpu/host1x/cdma.c                   |  486 ++++++++++++++++++++++
 drivers/gpu/host1x/cdma.h                   |  102 +++++
 drivers/gpu/host1x/channel.c                |  120 ++++++
 drivers/gpu/host1x/channel.h                |   52 +++
 drivers/gpu/host1x/dev.c                    |   17 +
 drivers/gpu/host1x/dev.h                    |  114 +++++
 drivers/gpu/host1x/host1x.h                 |   28 ++
 drivers/gpu/host1x/hw/cdma_hw.c             |  324 +++++++++++++++
 drivers/gpu/host1x/hw/channel_hw.c          |  142 +++++++
 drivers/gpu/host1x/hw/host1x01.c            |    5 +
 drivers/gpu/host1x/hw/host1x01_hardware.h   |  116 ++++++
 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           |   11 +
 drivers/gpu/host1x/intr.c                   |   28 +-
 drivers/gpu/host1x/intr.h                   |    6 +
 drivers/gpu/host1x/job.c                    |  598 +++++++++++++++++++++++++++
 drivers/gpu/host1x/job.h                    |  158 +++++++
 drivers/gpu/host1x/memmgr.c                 |   82 ++++
 drivers/gpu/host1x/memmgr.h                 |   64 +++
 drivers/gpu/host1x/syncpt.c                 |   11 +
 drivers/gpu/host1x/syncpt.h                 |    6 +
 include/trace/events/host1x.h               |  211 ++++++++++
 26 files changed, 2978 insertions(+), 1 deletion(-)
 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/host1x.h
 create mode 100644 drivers/gpu/host1x/hw/cdma_hw.c
 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 +12 -0
index c01c450..00f0859 100644
@@ -7,3 +7,15 @@ config TEGRA_HOST1X
 	  Tegra's graphics- and multimedia-related modules. The modules served
 	  by host1x are referred to as clients. host1x includes some other
 	  functionality, such as synchronization.
+
+if TEGRA_HOST1X
+
+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 +4 -0
index 5ef47ff..7278bf3 100644
@@ -4,6 +4,10 @@ host1x-y = \
 	syncpt.o \
 	dev.o \
 	intr.o \
+	cdma.o \
+	channel.o \
+	job.o \
+	memmgr.o \
 	hw/host1x01.o
 
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/cdma.c new file +486 -0

486 lines not on this page · raw message

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

102 lines not on this page · raw message

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

120 lines not on this page · raw message

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

52 lines not on this page · raw message

drivers/gpu/host1x/dev.c +17 -0
index 4421e28..bedd37b 100644
@@ -29,6 +29,7 @@
 
 #include "dev.h"
 #include "intr.h"
+#include "channel.h"
 #include "hw/host1x01.h"
 
 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
@@ -45,6 +46,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 const struct host1x_info host1x01_info = {
 	.nb_channels	= 8,
 	.nb_pts		= 32,
@@ -116,6 +127,12 @@ static int host1x_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	err = host1x_channel_list_init(host);
+	if (err) {
+		dev_err(dev, "failed to init channel");
+		return err;
+	}
+
 	err = clk_prepare_enable(host->clk);
 	if (err < 0) {
 		dev_err(dev, "failed to enable clock\n");
drivers/gpu/host1x/dev.h +114 -0

141 lines not on this page · raw message

drivers/gpu/host1x/host1x.h new file +28 -0
new file mode 100644
index 0000000..bca6563
@@ -0,0 +1,28 @@
+/*
+ * 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 {
+	HOST1X_CLASS_HOST1X	= 0x1
+};
+
+#endif
drivers/gpu/host1x/hw/cdma_hw.c new file +324 -0

324 lines not on this page · raw message

drivers/gpu/host1x/hw/channel_hw.c new file +142 -0

142 lines not on this page · raw message

drivers/gpu/host1x/hw/host1x01.c +5 -0
index f5c35fa..013ff38 100644
@@ -21,6 +21,8 @@
 #include "hw/host1x01_hardware.h"
 
 /* include code */
+#include "hw/cdma_hw.c"
+#include "hw/channel_hw.c"
 #include "hw/intr_hw.c"
 #include "hw/syncpt_hw.c"
 
@@ -28,6 +30,9 @@
 
 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 +116 -0

122 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 eea0bb0..8f2a246 100644
@@ -77,6 +77,18 @@ static inline u32 host1x_sync_syncpt_thresh_int_enable_cpu0_r(unsigned int id)
 }
 #define HOST1X_SYNC_SYNCPT_THRESH_INT_ENABLE_CPU0(id) \
 	host1x_sync_syncpt_thresh_int_enable_cpu0_r(id)
+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 +11 -0
index 885b257..2c1f4af 100644
@@ -93,10 +93,21 @@ 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(
+		HOST1X_SYNCPT_RESERVED, 0);
+
+	*((u32 *)patch_addr) = override;
+	return 0;
+}
+
 static const struct host1x_syncpt_ops host1x_syncpt_ops = {
 	.restore = syncpt_restore,
 	.restore_wait_base = syncpt_restore_wait_base,
 	.load_wait_base = syncpt_read_wait_base,
 	.load = syncpt_load,
 	.cpu_incr = syncpt_cpu_incr,
+	.patch_wait = syncpt_patch_wait,
 };
drivers/gpu/host1x/intr.c +27 -1
index b1b5a80..2491bf8 100644
@@ -21,6 +21,8 @@
 #include <linux/slab.h>
 #include <linux/irq.h>
 
+#include <trace/events/host1x.h>
+#include "channel.h"
 #include "dev.h"
 #include "intr.h"
 
@@ -66,7 +68,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)
@@ -74,6 +76,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);
@@ -94,6 +107,18 @@ static void reset_threshold_interrupt(struct host1x *host,
 	host1x_hw_intr_enable_syncpt_intr(host, id);
 }
 
+static void action_submit_complete(struct host1x_waitlist *waiter)
+{
+	struct host1x_channel *channel = waiter->data;
+
+	host1x_cdma_update(&channel->cdma);
+
+	/*  Add nr_completed to trace */
+	trace_host1x_channel_submit_complete(dev_name(channel->dev),
+					     waiter->count, waiter->thresh);
+
+}
+
 static void action_wakeup(struct host1x_waitlist *waiter)
 {
 	wait_queue_head_t *wq = waiter->data;
@@ -109,6 +134,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 a3f06ab..2b8adf0 100644
@@ -26,6 +26,12 @@ struct host1x;
 
 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 +598 -0

598 lines not on this page · raw message

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

158 lines not on this page · raw message

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

82 lines not on this page · raw message

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

64 lines not on this page · raw message

drivers/gpu/host1x/syncpt.c +11 -0
index a8613eb..ac172dc 100644
@@ -300,6 +300,12 @@ bool host1x_syncpt_is_expired(struct host1x_syncpt *sp, u32 thresh)
 		return (s32)(current_val - thresh) >= 0;
 }
 
+/* remove a wait pointed to by patch_addr */
+int host1x_syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr)
+{
+	return host1x_hw_syncpt_patch_wait(sp->host, sp, patch_addr);
+}
+
 int host1x_syncpt_init(struct host1x *host)
 {
 	struct host1x_syncpt *syncpt;
@@ -319,6 +325,11 @@ int host1x_syncpt_init(struct host1x *host)
 
 	host1x_syncpt_restore(host);
 
+	/* Allocate sync point to use for clearing waits for expired fences */
+	host->nop_sp = _host1x_syncpt_alloc(host, NULL, 0);
+	if (!host->nop_sp)
+		return -ENOMEM;
+
 	return 0;
 }
 
drivers/gpu/host1x/syncpt.h +6 -0
index 17c1616..c998061 100644
@@ -27,6 +27,9 @@
 
 struct host1x;
 
+/* Reserved for replacing an expired wait with a NOP */
+#define HOST1X_SYNCPT_RESERVED			0
+
 struct host1x_syncpt {
 	int id;
 	atomic_t min_val;
@@ -146,6 +149,9 @@ static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp)
 	return sp->id < host1x_syncpt_nb_pts(sp->host);
 }
 
+/* Patch a wait by replacing it with a wait for syncpt 0 value 0 */
+int host1x_syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr);
+
 /* Return id of the sync point */
 u32 host1x_syncpt_id(struct host1x_syncpt *sp);
 
include/trace/events/host1x.h +211 -0

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

#4 lore raw

PATCH v6 4/9 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                   |    5 +
 drivers/gpu/host1x/debug.c                  |  210 +++++++++++++++++
 drivers/gpu/host1x/debug.h                  |   51 +++++
 drivers/gpu/host1x/dev.c                    |    3 +
 drivers/gpu/host1x/dev.h                    |   42 ++++
 drivers/gpu/host1x/hw/cdma_hw.c             |    3 +
 drivers/gpu/host1x/hw/channel_hw.c          |   27 ++-
 drivers/gpu/host1x/hw/debug_hw.c            |  322 +++++++++++++++++++++++++++
 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/hw_host1x01_uclass.h  |    6 +
 drivers/gpu/host1x/hw/syncpt_hw.c           |    1 +
 drivers/gpu/host1x/syncpt.c                 |    5 +
 15 files changed, 810 insertions(+), 1 deletion(-)
 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 7278bf3..dfc6f35 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 +5 -0
index a45bb94..f3167bf 100644
@@ -29,6 +29,7 @@
 #include "cdma.h"
 #include "channel.h"
 #include "dev.h"
+#include "debug.h"
 #include "job.h"
 #include "memmgr.h"
 
@@ -438,6 +439,10 @@ void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2)
 	struct push_buffer *pb = &cdma->push_buffer;
 	u32 slots_free = cdma->slots_free;
 
+	if (host1x_debug_trace_cmdbuf)
+		trace_host1x_cdma_push(dev_name(cdma_to_channel(cdma)->dev),
+				       op1, op2);
+
 	if (slots_free == 0) {
 		host1x_hw_cdma_flush(host1x, cdma);
 		slots_free = host1x_cdma_wait_locked(cdma,
drivers/gpu/host1x/debug.c new file +210 -0

210 lines not on this page · raw message

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

51 lines not on this page · raw message

drivers/gpu/host1x/dev.c +3 -0
index bedd37b..d7c6e3e 100644
@@ -30,6 +30,7 @@
 #include "dev.h"
 #include "intr.h"
 #include "channel.h"
+#include "debug.h"
 #include "hw/host1x01.h"
 
 void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
@@ -151,6 +152,8 @@ static int host1x_probe(struct platform_device *pdev)
 		goto fail_deinit_syncpt;
 	}
 
+	host1x_debug_init(host);
+
 	return 0;
 
 fail_deinit_syncpt:
drivers/gpu/host1x/dev.h +42 -0

70 lines not on this page · raw message

drivers/gpu/host1x/hw/cdma_hw.c +3 -0
index e5f23a9..5d48803 100644
@@ -23,6 +23,7 @@
 #include "cdma.h"
 #include "channel.h"
 #include "dev.h"
+#include "debug.h"
 #include "memmgr.h"
 
 /*
@@ -244,6 +245,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.client) {
drivers/gpu/host1x/hw/channel_hw.c +26 -1
index fc0dbda..3f28539 100644
@@ -28,6 +28,31 @@
 #define HOST1X_CHANNEL_SIZE 16384
 #define TRACE_MAX_LENGTH 128U
 
+static void trace_write_gather(struct host1x_cdma *cdma,
+			       struct host1x_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(
+				dev_name(cdma_to_channel(cdma)->dev),
+				(u32)ref, min(words - i, TRACE_MAX_LENGTH),
+				offset + i * sizeof(u32), mem);
+		}
+		host1x_memmgr_munmap(ref, mem);
+	}
+}
+
 static void submit_gathers(struct host1x_job *job)
 {
 	struct host1x_cdma *cdma = &job->channel->cdma;
@@ -37,6 +62,7 @@ static void submit_gathers(struct host1x_job *job)
 		struct host1x_job_gather *g = &job->gathers[i];
 		u32 op1 = host1x_opcode_gather(g->words);
 		u32 op2 = g->mem_base + g->offset;
+		trace_write_gather(cdma, g->mem_id, g->offset, op1 & 0xffff);
 		host1x_cdma_push(cdma, op1, op2);
 	}
 }
@@ -50,7 +76,6 @@ static int channel_submit(struct host1x_job *job)
 	u32 syncval;
 	int err;
 	struct host1x_waitlist *completed_waiter = NULL;
-
 	sp = host1x_get_host(job->channel->dev)->syncpt + job->syncpt_id;
 	trace_host1x_channel_submit(dev_name(ch->dev),
 				    job->num_gathers, job->num_relocs,
drivers/gpu/host1x/hw/debug_hw.c new file +322 -0

322 lines not on this page · raw message

drivers/gpu/host1x/hw/host1x01.c +2 -0
index 013ff38..a14e91c 100644
@@ -23,6 +23,7 @@
 /* include code */
 #include "hw/cdma_hw.c"
 #include "hw/channel_hw.c"
+#include "hw/debug_hw.c"
 #include "hw/intr_hw.c"
 #include "hw/syncpt_hw.c"
 
@@ -35,6 +36,7 @@ int host1x01_init(struct host1x *host)
 	host->cdma_pb_op = &host1x_pushbuffer_ops;
 	host->syncpt_op = &host1x_syncpt_ops;
 	host->intr_op = &host1x_intr_ops;
+	host->debug_op = &host1x_debug_ops;
 
 	return 0;
 }
drivers/gpu/host1x/hw/hw_host1x01_channel.h +18 -0
index 9ba1332..b4bc7ca 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(void)
 }
 #define HOST1X_CHANNEL_DMACTRL_DMASTOP \
 	host1x_channel_dmactrl_dmastop()
+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(void)
 {
 	return 1 << 1;
drivers/gpu/host1x/hw/hw_host1x01_sync.h +115 -0

131 lines not on this page · raw message

drivers/gpu/host1x/hw/hw_host1x01_uclass.h +6 -0
index 7af6609..42f3ce1 100644
@@ -87,6 +87,12 @@ static inline u32 host1x_uclass_wait_syncpt_thresh_f(u32 v)
 }
 #define HOST1X_UCLASS_WAIT_SYNCPT_THRESH_F(v) \
 	host1x_uclass_wait_syncpt_thresh_f(v)
+static inline u32 host1x_uclass_wait_syncpt_base_r(void)
+{
+	return 0x9;
+}
+#define HOST1X_UCLASS_WAIT_SYNCPT_BASE \
+	host1x_uclass_wait_syncpt_base_r()
 static inline u32 host1x_uclass_wait_syncpt_base_indx_f(u32 v)
 {
 	return (v & 0xff) << 24;
drivers/gpu/host1x/hw/syncpt_hw.c +1 -0
index 2c1f4af..6117499 100644
@@ -86,6 +86,7 @@ static void syncpt_cpu_incr(struct host1x_syncpt *sp)
 	    host1x_syncpt_idle(sp)) {
 		dev_err(host->dev, "Trying to increment syncpoint id %d beyond max\n",
 			sp->id);
+		host1x_debug_dump(sp->host);
 		return;
 	}
 	host1x_sync_writel(host, BIT_MASK(sp->id),
drivers/gpu/host1x/syncpt.c +5 -0
index ac172dc..7390af8 100644
@@ -25,6 +25,7 @@
 #include "syncpt.h"
 #include "dev.h"
 #include "intr.h"
+#include "debug.h"
 
 #define SYNCPT_CHECK_PERIOD (2 * HZ)
 #define MAX_STUCK_CHECK_COUNT 15
@@ -231,6 +232,10 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
 				"%s: syncpoint id %d (%s) stuck waiting %d, timeout=%ld\n",
 				 current->comm, sp->id, sp->name,
 				 thresh, timeout);
+
+			host1x_debug_dump_syncpts(sp->host);
+			if (check_count == MAX_STUCK_CHECK_COUNT)
+				host1x_debug_dump(sp->host);
 			check_count++;
 		}
 	}
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v6 5/9 drm: tegra: Move drm to live under host1x

In reply to Terje Bergstrom

Make drm part of host1x driver.

---
 drivers/gpu/drm/Kconfig                        |    2 --
 drivers/gpu/drm/Makefile                       |    1 -
 drivers/gpu/drm/tegra/Makefile                 |    7 -------
 drivers/gpu/host1x/Kconfig                     |    2 ++
 drivers/gpu/host1x/Makefile                    |    5 +++++
 drivers/gpu/{drm/tegra => host1x/drm}/Kconfig  |    0
 drivers/gpu/{drm/tegra => host1x/drm}/dc.c     |    0
 drivers/gpu/{drm/tegra => host1x/drm}/dc.h     |    0
 drivers/gpu/{drm/tegra => host1x/drm}/drm.c    |    0
 drivers/gpu/{drm/tegra => host1x/drm}/drm.h    |    6 +++---
 drivers/gpu/{drm/tegra => host1x/drm}/fb.c     |    0
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c   |    0
 drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h   |    0
 drivers/gpu/{drm/tegra => host1x/drm}/host1x.c |    0
 drivers/gpu/{drm/tegra => host1x/drm}/output.c |    0
 drivers/gpu/{drm/tegra => host1x/drm}/rgb.c    |    0
 16 files changed, 10 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/gpu/drm/tegra/Makefile
 rename drivers/gpu/{drm/tegra => host1x/drm}/Kconfig (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/dc.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/dc.h (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/drm.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/drm.h (98%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/fb.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/hdmi.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/hdmi.h (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/host1x.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/output.c (100%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/rgb.c (100%)
drivers/gpu/drm/Kconfig +0 -2
index 1e82882..9031bb7 100644
@@ -215,8 +215,6 @@ source "drivers/gpu/drm/cirrus/Kconfig"
 
 source "drivers/gpu/drm/shmobile/Kconfig"
 
-source "drivers/gpu/drm/tegra/Kconfig"
-
 source "drivers/gpu/drm/omapdrm/Kconfig"
 
 source "drivers/gpu/drm/tilcdc/Kconfig"
drivers/gpu/drm/Makefile +0 -1
index 0d59b24..847b830 100644
@@ -49,7 +49,6 @@ 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-$(CONFIG_DRM_OMAP)	+= omapdrm/
 obj-$(CONFIG_DRM_TILCDC)	+= tilcdc/
 obj-y			+= i2c/
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/host1x/Kconfig +2 -0
index 00f0859..ee3af1e 100644
@@ -18,4 +18,6 @@ config TEGRA_HOST1X_FIREWALL
 
 	  If unsure, choose Y.
 
+source "drivers/gpu/host1x/drm/Kconfig"
+
 endif
drivers/gpu/host1x/Makefile +5 -0
index dfc6f35..db4dc25 100644
@@ -11,4 +11,9 @@ host1x-y = \
 	memmgr.o \
 	hw/host1x01.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/output.o drm/rgb.o drm/hdmi.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/drm/Kconfig renamed from drivers/gpu/drm/tegra/Kconfig +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/Kconfig
rename to drivers/gpu/host1x/drm/Kconfig
drivers/gpu/host1x/drm/dc.c renamed from drivers/gpu/drm/tegra/dc.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/dc.c
rename to drivers/gpu/host1x/drm/dc.c
drivers/gpu/host1x/drm/dc.h renamed from drivers/gpu/drm/tegra/dc.h +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/dc.h
rename to drivers/gpu/host1x/drm/dc.h
drivers/gpu/host1x/drm/drm.c renamed from drivers/gpu/drm/tegra/drm.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/drm.c
rename to drivers/gpu/host1x/drm/drm.c
drivers/gpu/host1x/drm/drm.h renamed from drivers/gpu/drm/tegra/drm.h +3 -3
similarity index 98%
rename from drivers/gpu/drm/tegra/drm.h
rename to drivers/gpu/host1x/drm/drm.h
index 6dd75a2..a6c011d 100644
@@ -7,8 +7,8 @@
  * published by the Free Software Foundation.
  */
 
-#ifndef TEGRA_DRM_H
-#define TEGRA_DRM_H 1
+#ifndef HOST1X_DRM_H
+#define HOST1X_DRM_H 1
 
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
@@ -234,4 +234,4 @@ extern struct platform_driver tegra_hdmi_driver;
 extern struct platform_driver tegra_dc_driver;
 extern struct drm_driver tegra_drm_driver;
 
-#endif /* TEGRA_DRM_H */
+#endif /* HOST1X_DRM_H */
drivers/gpu/host1x/drm/fb.c renamed from drivers/gpu/drm/tegra/fb.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/fb.c
rename to drivers/gpu/host1x/drm/fb.c
drivers/gpu/host1x/drm/hdmi.c renamed from drivers/gpu/drm/tegra/hdmi.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/hdmi.c
rename to drivers/gpu/host1x/drm/hdmi.c
drivers/gpu/host1x/drm/hdmi.h renamed from drivers/gpu/drm/tegra/hdmi.h +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/hdmi.h
rename to drivers/gpu/host1x/drm/hdmi.h
drivers/gpu/host1x/drm/host1x.c renamed from drivers/gpu/drm/tegra/host1x.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/host1x.c
rename to drivers/gpu/host1x/drm/host1x.c
drivers/gpu/host1x/drm/output.c renamed from drivers/gpu/drm/tegra/output.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/output.c
rename to drivers/gpu/host1x/drm/output.c
drivers/gpu/host1x/drm/rgb.c renamed from drivers/gpu/drm/tegra/rgb.c +0 -0
similarity index 100%
rename from drivers/gpu/drm/tegra/rgb.c
rename to drivers/gpu/host1x/drm/rgb.c
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v6 6/9 gpu: host1x: drm: Rename host1x to host1x_drm

In reply to Terje Bergstrom

From: Arto Merilainen <[email protected]>

Both host1x and drm drivers have host1x structures. This patch renames the host1x structure under drm to follow name host1x_drm.

---
 drivers/gpu/host1x/drm/dc.c     |    4 ++--
 drivers/gpu/host1x/drm/drm.c    |    4 ++--
 drivers/gpu/host1x/drm/drm.h    |   14 +++++++-------
 drivers/gpu/host1x/drm/fb.c     |    6 +++---
 drivers/gpu/host1x/drm/hdmi.c   |    4 ++--
 drivers/gpu/host1x/drm/host1x.c |   22 ++++++++++++----------
 6 files changed, 28 insertions(+), 26 deletions(-)
drivers/gpu/host1x/drm/dc.c +2 -2
index de94707..d1f6609 100644
@@ -1097,7 +1097,7 @@ 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_drm *host1x = dev_get_drvdata(pdev->dev.parent);
 	struct resource *regs;
 	struct tegra_dc *dc;
 	int err;
@@ -1160,7 +1160,7 @@ 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_drm *host1x = dev_get_drvdata(pdev->dev.parent);
 	struct tegra_dc *dc = platform_get_drvdata(pdev);
 	int err;
 
drivers/gpu/host1x/drm/drm.c +2 -2
index 9d452df..6c59bcd 100644
@@ -26,7 +26,7 @@
 static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 {
 	struct device *dev = drm->dev;
-	struct host1x *host1x;
+	struct host1x_drm *host1x;
 	int err;
 
 	host1x = dev_get_drvdata(dev);
@@ -69,7 +69,7 @@ static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
 
 static void tegra_drm_lastclose(struct drm_device *drm)
 {
-	struct host1x *host1x = drm->dev_private;
+	struct host1x_drm *host1x = drm->dev_private;
 
 	drm_fbdev_cma_restore_mode(host1x->fbdev);
 }
drivers/gpu/host1x/drm/drm.h +7 -7
index a6c011d..7fedb6c 100644
@@ -18,7 +18,7 @@
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_fixed.h>
 
-struct host1x {
+struct host1x_drm {
 	struct drm_device *drm;
 	struct device *dev;
 	void __iomem *regs;
@@ -44,7 +44,7 @@ struct host1x_client_ops {
 };
 
 struct host1x_client {
-	struct host1x *host1x;
+	struct host1x_drm *host1x;
 	struct device *dev;
 
 	const struct host1x_client_ops *ops;
@@ -52,12 +52,12 @@ struct host1x_client {
 	struct list_head list;
 };
 
-extern int host1x_drm_init(struct host1x *host1x, struct drm_device *drm);
-extern int host1x_drm_exit(struct host1x *host1x);
+extern int host1x_drm_init(struct host1x_drm *host1x, struct drm_device *drm);
+extern int host1x_drm_exit(struct host1x_drm *host1x);
 
-extern int host1x_register_client(struct host1x *host1x,
+extern int host1x_register_client(struct host1x_drm *host1x,
 				  struct host1x_client *client);
-extern int host1x_unregister_client(struct host1x *host1x,
+extern int host1x_unregister_client(struct host1x_drm *host1x,
 				    struct host1x_client *client);
 
 struct tegra_output;
@@ -66,7 +66,7 @@ struct tegra_dc {
 	struct host1x_client client;
 	spinlock_t lock;
 
-	struct host1x *host1x;
+	struct host1x_drm *host1x;
 	struct device *dev;
 
 	struct drm_crtc base;
drivers/gpu/host1x/drm/fb.c +3 -3
index 0391495..6ed885a 100644
@@ -11,7 +11,7 @@
 
 static void tegra_drm_fb_output_poll_changed(struct drm_device *drm)
 {
-	struct host1x *host1x = drm->dev_private;
+	struct host1x_drm *host1x = drm->dev_private;
 
 	drm_fbdev_cma_hotplug_event(host1x->fbdev);
 }
@@ -23,7 +23,7 @@ static const struct drm_mode_config_funcs tegra_drm_mode_funcs = {
 
 int tegra_drm_fb_init(struct drm_device *drm)
 {
-	struct host1x *host1x = drm->dev_private;
+	struct host1x_drm *host1x = drm->dev_private;
 	struct drm_fbdev_cma *fbdev;
 
 	drm->mode_config.min_width = 0;
@@ -46,7 +46,7 @@ int tegra_drm_fb_init(struct drm_device *drm)
 
 void tegra_drm_fb_exit(struct drm_device *drm)
 {
-	struct host1x *host1x = drm->dev_private;
+	struct host1x_drm *host1x = drm->dev_private;
 
 	drm_fbdev_cma_fini(host1x->fbdev);
 }
drivers/gpu/host1x/drm/hdmi.c +2 -2
index bb747f6..f438f80 100644
@@ -1189,7 +1189,7 @@ 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_drm *host1x = dev_get_drvdata(pdev->dev.parent);
 	struct tegra_hdmi *hdmi;
 	struct resource *regs;
 	int err;
@@ -1278,7 +1278,7 @@ 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_drm *host1x = dev_get_drvdata(pdev->dev.parent);
 	struct tegra_hdmi *hdmi = platform_get_drvdata(pdev);
 	int err;
 
drivers/gpu/host1x/drm/host1x.c +12 -10
index 92e25a7..c3d8ee5 100644
@@ -21,7 +21,8 @@ struct host1x_drm_client {
 	struct list_head list;
 };
 
-static int host1x_add_drm_client(struct host1x *host1x, struct device_node *np)
+static int host1x_add_drm_client(struct host1x_drm *host1x,
+				 struct device_node *np)
 {
 	struct host1x_drm_client *client;
 
@@ -37,7 +38,7 @@ static int host1x_add_drm_client(struct host1x *host1x, struct device_node *np)
 	return 0;
 }
 
-static int host1x_activate_drm_client(struct host1x *host1x,
+static int host1x_activate_drm_client(struct host1x_drm *host1x,
 				      struct host1x_drm_client *drm,
 				      struct host1x_client *client)
 {
@@ -50,7 +51,7 @@ static int host1x_activate_drm_client(struct host1x *host1x,
 	return 0;
 }
 
-static int host1x_remove_drm_client(struct host1x *host1x,
+static int host1x_remove_drm_client(struct host1x_drm *host1x,
 				    struct host1x_drm_client *client)
 {
 	mutex_lock(&host1x->drm_clients_lock);
@@ -63,7 +64,7 @@ static int host1x_remove_drm_client(struct host1x *host1x,
 	return 0;
 }
 
-static int host1x_parse_dt(struct host1x *host1x)
+static int host1x_parse_dt(struct host1x_drm *host1x)
 {
 	static const char * const compat[] = {
 		"nvidia,tegra20-dc",
@@ -92,7 +93,7 @@ static int host1x_parse_dt(struct host1x *host1x)
 
 static int tegra_host1x_probe(struct platform_device *pdev)
 {
-	struct host1x *host1x;
+	struct host1x_drm *host1x;
 	struct resource *regs;
 	int err;
 
@@ -156,14 +157,14 @@ err:
 
 static int tegra_host1x_remove(struct platform_device *pdev)
 {
-	struct host1x *host1x = platform_get_drvdata(pdev);
+	struct host1x_drm *host1x = platform_get_drvdata(pdev);
 
 	clk_disable_unprepare(host1x->clk);
 
 	return 0;
 }
 
-int host1x_drm_init(struct host1x *host1x, struct drm_device *drm)
+int host1x_drm_init(struct host1x_drm *host1x, struct drm_device *drm)
 {
 	struct host1x_client *client;
 
@@ -186,7 +187,7 @@ int host1x_drm_init(struct host1x *host1x, struct drm_device *drm)
 	return 0;
 }
 
-int host1x_drm_exit(struct host1x *host1x)
+int host1x_drm_exit(struct host1x_drm *host1x)
 {
 	struct platform_device *pdev = to_platform_device(host1x->dev);
 	struct host1x_client *client;
@@ -216,7 +217,8 @@ int host1x_drm_exit(struct host1x *host1x)
 	return 0;
 }
 
-int host1x_register_client(struct host1x *host1x, struct host1x_client *client)
+int host1x_register_client(struct host1x_drm *host1x,
+			   struct host1x_client *client)
 {
 	struct host1x_drm_client *drm, *tmp;
 	int err;
@@ -244,7 +246,7 @@ int host1x_register_client(struct host1x *host1x, struct host1x_client *client)
 	return 0;
 }
 
-int host1x_unregister_client(struct host1x *host1x,
+int host1x_unregister_client(struct host1x_drm *host1x,
 			     struct host1x_client *client)
 {
 	struct host1x_drm_client *drm, *tmp;
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v6 7/9 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        |    5 +-
 drivers/gpu/host1x/drm/drm.c       |  217 +++++++++++++++++++++++-
 drivers/gpu/host1x/drm/drm.h       |    3 -
 drivers/gpu/host1x/drm/hdmi.c      |    5 +-
 drivers/gpu/host1x/drm/host1x.c    |  329 ------------------------------------
 drivers/gpu/host1x/host1x_client.h |   35 ++++
 10 files changed, 318 insertions(+), 344 deletions(-)
 delete mode 100644 drivers/gpu/host1x/drm/host1x.c
 create mode 100644 drivers/gpu/host1x/host1x_client.h
drivers/gpu/host1x/Makefile +1 -1
index db4dc25..ad39fef 100644
@@ -14,6 +14,6 @@ host1x-y = \
 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

83 lines not on this page · raw message

drivers/gpu/host1x/dev.h +6 -0
index 3542c00..e74ed4a 100644
@@ -125,6 +125,8 @@ struct host1x {
 	unsigned int num_allocated_channels;
 
 	struct dentry *debugfs;
+
+	void *drm_data;
 };
 
 static inline struct host1x *host1x_get_host(struct device *dev)
@@ -308,4 +310,8 @@ static inline void host1x_hw_show_mlocks(struct host1x *host, struct output *o)
 	host->debug_op->show_mlocks(host, o);
 }
 
+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 c92955d..8fb6545 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 +3 -2
index d1f6609..29a79b6 100644
@@ -16,6 +16,7 @@
 
 #include "drm.h"
 #include "dc.h"
+#include "host1x_client.h"
 
 struct tegra_plane {
 	struct drm_plane base;
@@ -1097,7 +1098,7 @@ static const struct host1x_client_ops dc_client_ops = {
 
 static int tegra_dc_probe(struct platform_device *pdev)
 {
-	struct host1x_drm *host1x = dev_get_drvdata(pdev->dev.parent);
+	struct host1x_drm *host1x = host1x_get_drm_data(pdev->dev.parent);
 	struct resource *regs;
 	struct tegra_dc *dc;
 	int err;
@@ -1160,7 +1161,7 @@ static int tegra_dc_probe(struct platform_device *pdev)
 
 static int tegra_dc_remove(struct platform_device *pdev)
 {
-	struct host1x_drm *host1x = dev_get_drvdata(pdev->dev.parent);
+	struct host1x_drm *host1x = host1x_get_drm_data(pdev->dev.parent);
 	struct tegra_dc *dc = platform_get_drvdata(pdev);
 	int err;
 
drivers/gpu/host1x/drm/drm.c +213 -4

240 lines not on this page · raw message

drivers/gpu/host1x/drm/drm.h +0 -3
index 7fedb6c..0b8738f 100644
@@ -229,9 +229,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 +3 -2
index f438f80..01097da 100644
@@ -22,6 +22,7 @@
 #include "hdmi.h"
 #include "drm.h"
 #include "dc.h"
+#include "host1x_client.h"
 
 struct tegra_hdmi {
 	struct host1x_client client;
@@ -1189,7 +1190,7 @@ static const struct host1x_client_ops hdmi_client_ops = {
 
 static int tegra_hdmi_probe(struct platform_device *pdev)
 {
-	struct host1x_drm *host1x = dev_get_drvdata(pdev->dev.parent);
+	struct host1x_drm *host1x = host1x_get_drm_data(pdev->dev.parent);
 	struct tegra_hdmi *hdmi;
 	struct resource *regs;
 	int err;
@@ -1278,7 +1279,7 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
 
 static int tegra_hdmi_remove(struct platform_device *pdev)
 {
-	struct host1x_drm *host1x = dev_get_drvdata(pdev->dev.parent);
+	struct host1x_drm *host1x = host1x_get_drm_data(pdev->dev.parent);
 	struct tegra_hdmi *hdmi = platform_get_drvdata(pdev);
 	int err;
 
drivers/gpu/host1x/drm/host1x.c deleted +0 -329

329 lines not on this page · raw message

drivers/gpu/host1x/host1x_client.h new file +35 -0
new file mode 100644
index 0000000..9b85f10
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 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_CLIENT_H
+#define HOST1X_CLIENT_H
+
+struct device;
+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 device *dev, void *data);
+void *host1x_get_drm_data(struct device *dev);
+
+#endif
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v6 8/9 gpu: host1x: drm: Add CMA ops for host1x driver

In reply to Terje Bergstrom

From: Arto Merilainen <[email protected]>

This patch adds CMA memory operations for host1x driver. This allows usage of CMA buffers inside host1x driver.

---
 drivers/gpu/host1x/Makefile  |    1 +
 drivers/gpu/host1x/drm/cma.c |   87 ++++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/host1x/drm/cma.h |   26 +++++++++++++
 3 files changed, 114 insertions(+)
 create mode 100644 drivers/gpu/host1x/drm/cma.c
 create mode 100644 drivers/gpu/host1x/drm/cma.h
drivers/gpu/host1x/Makefile +1 -0
index ad39fef..d1d7e35 100644
@@ -16,4 +16,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/cma.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/drm/cma.c new file +87 -0

87 lines not on this page · raw message

drivers/gpu/host1x/drm/cma.h new file +26 -0
new file mode 100644
index 0000000..06aa0ba
@@ -0,0 +1,26 @@
+/*
+ * Tegra host1x cma memory manager
+ *
+ * Copyright (c) 2012-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_CMA_H
+#define __HOST1X_CMA_H
+
+#include "memmgr.h"
+
+extern const struct host1x_mem_op host1x_cma_ops;
+
+#endif
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v6 9/9 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  |  239 +++++++++++++++++++++++++++++-
 drivers/gpu/host1x/drm/drm.h  |   28 +++-
 drivers/gpu/host1x/drm/gr2d.c |  325 +++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/host1x/host1x.h   |    3 +-
 include/drm/tegra_drm.h       |  131 +++++++++++++++++
 7 files changed, 730 insertions(+), 4 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 include/drm/tegra_drm.h
drivers/gpu/host1x/Makefile +1 -0
index d1d7e35..d90168f 100644
@@ -17,4 +17,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/cma.o
+host1x-$(CONFIG_DRM_TEGRA) += drm/gr2d.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/dev.c +7 -0
index 6af8081..0091632 100644
@@ -211,11 +211,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_DRM_TEGRA
+unregister_hdmi:
+	platform_driver_unregister(&tegra_hdmi_driver);
 unregister_dc:
 	platform_driver_unregister(&tegra_dc_driver);
 unregister_host1x:
@@ -228,6 +234,7 @@ module_init(tegra_host1x_init);
 static void __exit tegra_host1x_exit(void)
 {
 #ifdef CONFIG_DRM_TEGRA
+	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 +237 -2

297 lines not on this page · raw message

drivers/gpu/host1x/drm/drm.h +27 -1
index 0b8738f..6a8d7e3 100644
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2012 Avionic Design GmbH
- * Copyright (C) 2012 NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (C) 2012-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 version 2 as
@@ -17,6 +17,9 @@
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_fixed.h>
+#include <drm/tegra_drm.h>
+
+#include "host1x.h"
 
 struct host1x_drm {
 	struct drm_device *drm;
@@ -38,9 +41,26 @@ struct host1x_drm {
 
 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 *client,
+			struct host1x_drm_context *context);
+	void (*close_channel)(struct host1x_drm_context *context);
+	int (*submit)(struct host1x_drm_context *context,
+			struct tegra_drm_submit_args *args,
+			struct drm_device *drm,
+			struct drm_file *file_priv);
+};
+
+struct host1x_drm_file {
+	struct list_head contexts;
 };
 
 struct host1x_client {
@@ -49,6 +69,12 @@ struct host1x_client {
 
 	const struct host1x_client_ops *ops;
 
+	enum host1x_class class;
+	struct host1x_channel *channel;
+
+	struct host1x_syncpt **syncpts;
+	unsigned int num_syncpts;
+
 	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/host1x.h +2 -1
index bca6563..128cc9e 100644
@@ -22,7 +22,8 @@
 #define __LINUX_HOST1X_H
 
 enum host1x_class {
-	HOST1X_CLASS_HOST1X	= 0x1
+	HOST1X_CLASS_HOST1X	= 0x1,
+	HOST1X_CLASS_GR2D	= 0x51
 };
 
 #endif
include/drm/tegra_drm.h new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
1.7.9.5