Skip to contentSkip to conversation

Support for Tegra 2D hardware

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

Subsystems (6)

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v8 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-20130322 with RTC fixes applied.

Changes in this version:
* Own version of framebuffer driver due to move to own allocator
* Thanks to Thierry Reding for help
* Miscellaneous variable name, whitespace and IOCTL interface cleanups
* Bug fixes:
* Validator enabled again
* Added new class 2D strechblit
* Dropped patch "Support CMA object preallocation"

Changes in version 7:
* host1x memory data structures refactored
* Some "nvhost" leftovers renamed to host1x

Changes in version 6:
* 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 dma mapping API. Each buffer is assigned an ops structure to operate on it.

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 memory manager and fb

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/fb.c                     |   52 --
 drivers/gpu/drm/tegra/host1x.c                 |  327 ------------
 drivers/gpu/host1x/Kconfig                     |   23 +
 drivers/gpu/host1x/Makefile                    |   20 +
 drivers/gpu/host1x/cdma.c                      |  491 ++++++++++++++++++
 drivers/gpu/host1x/cdma.h                      |  100 ++++
 drivers/gpu/host1x/channel.c                   |  126 +++++
 drivers/gpu/host1x/channel.h                   |   52 ++
 drivers/gpu/host1x/debug.c                     |  210 ++++++++
 drivers/gpu/host1x/debug.h                     |   51 ++
 drivers/gpu/host1x/dev.c                       |  246 +++++++++
 drivers/gpu/host1x/dev.h                       |  308 ++++++++++++
 drivers/gpu/{drm/tegra => host1x/drm}/Kconfig  |   19 +-
 drivers/gpu/{drm/tegra => host1x/drm}/dc.c     |   26 +-
 drivers/gpu/{drm/tegra => host1x/drm}/dc.h     |    0
 drivers/gpu/host1x/drm/drm.c                   |  641 ++++++++++++++++++++++++
 drivers/gpu/{drm/tegra => host1x/drm}/drm.h    |   68 ++-
 drivers/gpu/host1x/drm/fb.c                    |  374 ++++++++++++++
 drivers/gpu/host1x/drm/gem.c                   |  270 ++++++++++
 drivers/gpu/host1x/drm/gem.h                   |   59 +++
 drivers/gpu/host1x/drm/gr2d.c                  |  340 +++++++++++++
 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                    |   30 ++
 drivers/gpu/host1x/host1x_bo.h                 |   87 ++++
 drivers/gpu/host1x/host1x_client.h             |   35 ++
 drivers/gpu/host1x/hw/Makefile                 |    6 +
 drivers/gpu/host1x/hw/cdma_hw.c                |  326 ++++++++++++
 drivers/gpu/host1x/hw/channel_hw.c             |  168 +++++++
 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                       |  603 ++++++++++++++++++++++
 drivers/gpu/host1x/job.h                       |  167 ++++++
 drivers/gpu/host1x/syncpt.c                    |  387 ++++++++++++++
 drivers/gpu/host1x/syncpt.h                    |  165 ++++++
 drivers/video/Kconfig                          |    2 +
 include/trace/events/host1x.h                  |  272 ++++++++++
 include/uapi/drm/tegra_drm.h                   |  136 +++++
 54 files changed, 7559 insertions(+), 643 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/fb.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 (56%)
 rename drivers/gpu/{drm/tegra => host1x/drm}/dc.c (98%)
 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 (77%)
 create mode 100644 drivers/gpu/host1x/drm/fb.c
 create mode 100644 drivers/gpu/host1x/drm/gem.c
 create mode 100644 drivers/gpu/host1x/drm/gem.h
 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_bo.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/syncpt.c
 create mode 100644 drivers/gpu/host1x/syncpt.h
 create mode 100644 include/trace/events/host1x.h
 create mode 100644 include/uapi/drm/tegra_drm.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v8 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                  |  153 +++++++++++++++++++++
 drivers/gpu/host1x/dev.h                  |   96 +++++++++++++
 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, 956 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 +153 -0

153 lines not on this page · raw message

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

96 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 0181a87..3e67c6a 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 v8 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              |   12 ++
 10 files changed, 846 insertions(+)
 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 0d6002c..b967f6e 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)
@@ -123,13 +124,24 @@ static int host1x_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	err = host1x_intr_init(host, syncpt_irq);
+	if (err) {
+		dev_err(&pdev->dev, "failed to initialize interrupts\n");
+		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);
 
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 +12 -0
index efa2b6e..17c1616 100644
@@ -23,6 +23,8 @@
 #include <linux/kernel.h>
 #include <linux/sched.h>
 
+#include "intr.h"
+
 struct host1x;
 
 struct host1x_syncpt {
@@ -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 v8 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                 |    3 +
 drivers/gpu/host1x/cdma.c                   |  487 +++++++++++++++++++++
 drivers/gpu/host1x/cdma.h                   |  100 +++++
 drivers/gpu/host1x/channel.c                |  126 ++++++
 drivers/gpu/host1x/channel.h                |   52 +++
 drivers/gpu/host1x/dev.c                    |   17 +
 drivers/gpu/host1x/dev.h                    |  113 +++++
 drivers/gpu/host1x/host1x.h                 |   28 ++
 drivers/gpu/host1x/host1x_bo.h              |   87 ++++
 drivers/gpu/host1x/hw/cdma_hw.c             |  324 ++++++++++++++
 drivers/gpu/host1x/hw/channel_hw.c          |  143 +++++++
 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                    |  603 +++++++++++++++++++++++++++
 drivers/gpu/host1x/job.h                    |  167 ++++++++
 drivers/gpu/host1x/syncpt.c                 |   11 +
 drivers/gpu/host1x/syncpt.h                 |    6 +
 include/trace/events/host1x.h               |  211 ++++++++++
 25 files changed, 2937 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/host1x_bo.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
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 +3 -0
index 5ef47ff..06a995b 100644
@@ -4,6 +4,9 @@ host1x-y = \
 	syncpt.o \
 	dev.o \
 	intr.o \
+	cdma.o \
+	channel.o \
+	job.o \
 	hw/host1x01.o
 
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/cdma.c new file +487 -0

487 lines not on this page · raw message

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

100 lines not on this page · raw message

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

126 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 b967f6e..4e522c5 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,
@@ -112,6 +123,12 @@ static int host1x_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	err = host1x_channel_list_init(host);
+	if (err) {
+		dev_err(&pdev->dev, "failed to initialize channel list\n");
+		return err;
+	}
+
 	err = clk_prepare_enable(host->clk);
 	if (err < 0) {
 		dev_err(&pdev->dev, "failed to enable clock\n");
drivers/gpu/host1x/dev.h +113 -0

138 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/host1x_bo.h new file +87 -0

87 lines not on this page · raw message

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 +143 -0

143 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 +603 -0

603 lines not on this page · raw message

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

167 lines not on this page · raw message

drivers/gpu/host1x/syncpt.c +11 -0
index 07fad14..7e77e63 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

127 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 v8 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                   |    4 +
 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             |    2 +
 drivers/gpu/host1x/hw/channel_hw.c          |   25 +++
 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, 807 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 06a995b..49fd580 100644
@@ -7,6 +7,7 @@ host1x-y = \
 	cdma.o \
 	channel.o \
 	job.o \
+	debug.o \
 	hw/host1x01.o
 
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/cdma.c +4 -0
index 33935de..de72172 100644
@@ -439,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 4e522c5..9689724 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)
@@ -147,6 +148,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 +2 -0
index 4eb22ef..590b69d 100644
@@ -244,6 +244,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 +25 -0
index 5137a56..ee19962 100644
@@ -29,6 +29,30 @@
 #define HOST1X_CHANNEL_SIZE 16384
 #define TRACE_MAX_LENGTH 128U
 
+static void trace_write_gather(struct host1x_cdma *cdma, struct host1x_bo *bo,
+			       u32 offset, u32 words)
+{
+	void *mem = NULL;
+
+	if (host1x_debug_trace_cmdbuf)
+		mem = host1x_bo_mmap(bo);
+
+	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)bo, min(words - i, TRACE_MAX_LENGTH),
+				offset + i * sizeof(u32), mem);
+		}
+		host1x_bo_munmap(bo, mem);
+	}
+}
+
 static void submit_gathers(struct host1x_job *job)
 {
 	struct host1x_cdma *cdma = &job->channel->cdma;
@@ -38,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->base + g->offset;
+		trace_write_gather(cdma, g->bo, g->offset, op1 & 0xffff);
 		host1x_cdma_push(cdma, op1, op2);
 	}
 }
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 7e77e63..4b49345 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 v8 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 49fd580..4761e8a 100644
@@ -10,4 +10,9 @@ host1x-y = \
 	debug.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 v8 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 v8 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       |  214 ++++++++++++++++++++++-
 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, 317 insertions(+), 342 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 4761e8a..9a6fc76 100644
@@ -13,6 +13,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 4d16fe9..a1607d6 100644
@@ -124,6 +124,8 @@ struct host1x {
 	unsigned int num_allocated_channels;
 
 	struct dentry *debugfs;
+
+	void *drm_data;
 };
 
 void host1x_sync_writel(struct host1x *host1x, u32 r, u32 v);
@@ -299,4 +301,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 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 +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 +212 -2

231 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 v8 8/9 gpu: host1x: drm: Add memory manager and fb

In reply to Terje Bergstrom

From: Arto Merilainen <[email protected]>

This patch introduces a memory manager for tegra drm and moves existing parts to use it. As cma framebuffer helpers can no more be used, this patch adds also a separate framebuffer driver for tegra.

---
 drivers/gpu/host1x/Makefile    |    1 +
 drivers/gpu/host1x/drm/Kconfig |    8 +-
 drivers/gpu/host1x/drm/dc.c    |   23 +--
 drivers/gpu/host1x/drm/drm.c   |   17 +-
 drivers/gpu/host1x/drm/drm.h   |   18 ++-
 drivers/gpu/host1x/drm/fb.c    |  338 +++++++++++++++++++++++++++++++++++++++-
 drivers/gpu/host1x/drm/gem.c   |  270 ++++++++++++++++++++++++++++++++
 drivers/gpu/host1x/drm/gem.h   |   59 +++++++
 8 files changed, 700 insertions(+), 34 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gem.c
 create mode 100644 drivers/gpu/host1x/drm/gem.h
drivers/gpu/host1x/Makefile +1 -0
index 9a6fc76..3768dbc 100644
@@ -15,4 +15,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/gem.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/drm/Kconfig +3 -5
index 7db9b3a..f743540 100644
@@ -2,11 +2,9 @@ config DRM_TEGRA
 	bool "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
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
 	help
 	  Choose this option if you have an NVIDIA Tegra SoC.
 
drivers/gpu/host1x/drm/dc.c +12 -11
index 29a79b6..85ea616 100644
@@ -14,9 +14,10 @@
 #include <linux/platform_device.h>
 #include <linux/clk/tegra.h>
 
-#include "drm.h"
-#include "dc.h"
 #include "host1x_client.h"
+#include "dc.h"
+#include "drm.h"
+#include "gem.h"
 
 struct tegra_plane {
 	struct drm_plane base;
@@ -52,9 +53,9 @@ static int tegra_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 	window.bits_per_pixel = fb->bits_per_pixel;
 
 	for (i = 0; i < drm_format_num_planes(fb->pixel_format); i++) {
-		struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, i);
+		struct tegra_bo *bo = tegra_fb_get_plane(fb, i);
 
-		window.base[i] = gem->paddr + fb->offsets[i];
+		window.base[i] = bo->paddr + fb->offsets[i];
 
 		/*
 		 * Tegra doesn't support different strides for U and V planes
@@ -137,7 +138,7 @@ static int tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc)
 static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
 			     struct drm_framebuffer *fb)
 {
-	struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(fb, 0);
+	struct tegra_bo *bo = tegra_fb_get_plane(fb, 0);
 	unsigned long value;
 
 	tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER);
@@ -145,7 +146,7 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
 	value = fb->offsets[0] + y * fb->pitches[0] +
 		x * fb->bits_per_pixel / 8;
 
-	tegra_dc_writel(dc, gem->paddr + value, DC_WINBUF_START_ADDR);
+	tegra_dc_writel(dc, bo->paddr + value, DC_WINBUF_START_ADDR);
 	tegra_dc_writel(dc, fb->pitches[0], DC_WIN_LINE_STRIDE);
 
 	value = GENERAL_UPDATE | WIN_A_UPDATE;
@@ -187,20 +188,20 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)
 {
 	struct drm_device *drm = dc->base.dev;
 	struct drm_crtc *crtc = &dc->base;
-	struct drm_gem_cma_object *gem;
 	unsigned long flags, base;
+	struct tegra_bo *bo;
 
 	if (!dc->event)
 		return;
 
-	gem = drm_fb_cma_get_gem_obj(crtc->fb, 0);
+	bo = tegra_fb_get_plane(crtc->fb, 0);
 
 	/* check if new start address has been latched */
 	tegra_dc_writel(dc, READ_MUX, DC_CMD_STATE_ACCESS);
 	base = tegra_dc_readl(dc, DC_WINBUF_START_ADDR);
 	tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);
 
-	if (base == gem->paddr + crtc->fb->offsets[0]) {
+	if (base == bo->paddr + crtc->fb->offsets[0]) {
 		spin_lock_irqsave(&drm->event_lock, flags);
 		drm_send_vblank_event(drm, dc->pipe, dc->event);
 		drm_vblank_put(drm, dc->pipe);
@@ -570,7 +571,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
 			       struct drm_display_mode *adjusted,
 			       int x, int y, struct drm_framebuffer *old_fb)
 {
-	struct drm_gem_cma_object *gem = drm_fb_cma_get_gem_obj(crtc->fb, 0);
+	struct tegra_bo *bo = tegra_fb_get_plane(crtc->fb, 0);
 	struct tegra_dc *dc = to_tegra_dc(crtc);
 	struct tegra_dc_window window;
 	unsigned long div, value;
@@ -617,7 +618,7 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
 	window.format = tegra_dc_format(crtc->fb->pixel_format);
 	window.bits_per_pixel = crtc->fb->bits_per_pixel;
 	window.stride[0] = crtc->fb->pitches[0];
-	window.base[0] = gem->paddr;
+	window.base[0] = bo->paddr;
 
 	err = tegra_dc_setup_window(dc, 0, &window);
 	if (err < 0)
drivers/gpu/host1x/drm/drm.c +10 -7
index 901f0b4..c4e45c1 100644
@@ -15,7 +15,10 @@
 #include <asm/dma-iommu.h>
 
 #include "host1x_client.h"
+#include "dev.h"
 #include "drm.h"
+#include "gem.h"
+#include "syncpt.h"
 
 #define DRIVER_NAME "tegra"
 #define DRIVER_DESC "NVIDIA Tegra graphics"
@@ -281,7 +284,7 @@ static void tegra_drm_lastclose(struct drm_device *drm)
 {
 	struct host1x_drm *host1x = drm->dev_private;
 
-	drm_fbdev_cma_restore_mode(host1x->fbdev);
+	tegra_fbdev_restore_mode(host1x->fbdev);
 }
 
 static struct drm_ioctl_desc tegra_drm_ioctls[] = {
@@ -292,7 +295,7 @@ static const struct file_operations tegra_drm_fops = {
 	.open = drm_open,
 	.release = drm_release,
 	.unlocked_ioctl = drm_ioctl,
-	.mmap = drm_gem_cma_mmap,
+	.mmap = tegra_drm_mmap,
 	.poll = drm_poll,
 	.fasync = drm_fasync,
 	.read = drm_read,
@@ -408,11 +411,11 @@ struct drm_driver tegra_drm_driver = {
 	.debugfs_cleanup = tegra_debugfs_cleanup,
 #endif
 
-	.gem_free_object = drm_gem_cma_free_object,
-	.gem_vm_ops = &drm_gem_cma_vm_ops,
-	.dumb_create = drm_gem_cma_dumb_create,
-	.dumb_map_offset = drm_gem_cma_dumb_map_offset,
-	.dumb_destroy = drm_gem_cma_dumb_destroy,
+	.gem_free_object = tegra_bo_free_object,
+	.gem_vm_ops = &tegra_bo_vm_ops,
+	.dumb_create = tegra_bo_dumb_create,
+	.dumb_map_offset = tegra_bo_dumb_map_offset,
+	.dumb_destroy = tegra_bo_dumb_destroy,
 
 	.ioctls = tegra_drm_ioctls,
 	.num_ioctls = ARRAY_SIZE(tegra_drm_ioctls),
drivers/gpu/host1x/drm/drm.h +15 -3
index 0b8738f..3864a39 100644
@@ -14,10 +14,19 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_fb_helper.h>
-#include <drm/drm_gem_cma_helper.h>
-#include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_fixed.h>
 
+struct tegra_fb {
+	struct drm_framebuffer base;
+	struct tegra_bo **planes;
+	unsigned int num_planes;
+};
+
+struct tegra_fbdev {
+	struct drm_fb_helper base;
+	struct tegra_fb *fb;
+};
+
 struct host1x_drm {
 	struct drm_device *drm;
 	struct device *dev;
@@ -33,7 +42,7 @@ struct host1x_drm {
 	struct mutex clients_lock;
 	struct list_head clients;
 
-	struct drm_fbdev_cma *fbdev;
+	struct tegra_fbdev *fbdev;
 };
 
 struct host1x_client;
@@ -226,8 +235,11 @@ extern int tegra_output_init(struct drm_device *drm, struct tegra_output *output
 extern int tegra_output_exit(struct tegra_output *output);
 
 /* from fb.c */
+struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
+				    unsigned int index);
 extern int tegra_drm_fb_init(struct drm_device *drm);
 extern void tegra_drm_fb_exit(struct drm_device *drm);
+extern void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev);
 
 extern struct drm_driver tegra_drm_driver;
 
drivers/gpu/host1x/drm/fb.c +330 -8

372 lines not on this page · raw message

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

270 lines not on this page · raw message

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

59 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v8 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/Kconfig |    9 ++
 drivers/gpu/host1x/drm/drm.c   |  213 ++++++++++++++++++++++++-
 drivers/gpu/host1x/drm/drm.h   |   27 +++-
 drivers/gpu/host1x/drm/gr2d.c  |  340 ++++++++++++++++++++++++++++++++++++++++
 drivers/gpu/host1x/host1x.h    |    4 +-
 include/uapi/drm/tegra_drm.h   |  136 ++++++++++++++++
 8 files changed, 734 insertions(+), 3 deletions(-)
 create mode 100644 drivers/gpu/host1x/drm/gr2d.c
 create mode 100644 include/uapi/drm/tegra_drm.h
drivers/gpu/host1x/Makefile +1 -0
index 3768dbc..3b037b6 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/gem.o
+host1x-$(CONFIG_DRM_TEGRA) += drm/gr2d.o
 obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/dev.c +7 -0
index 8ce9889..28e28a2 100644
@@ -209,11 +209,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:
@@ -226,6 +232,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/Kconfig +9 -0
index f743540..6e3f567 100644
@@ -13,6 +13,15 @@ config DRM_TEGRA
 
 if DRM_TEGRA
 
+config DRM_TEGRA_STAGING
+	bool "Enable HOST1X interface"
+	depends on STAGING
+	default n
+	help
+	  Say yes if HOST1X should be available for userspace DRM users.
+
+	  If unsure, choose N.
+
 config DRM_TEGRA_DEBUG
 	bool "NVIDIA Tegra DRM debug support"
 	help
drivers/gpu/host1x/drm/drm.c +212 -1

258 lines not on this page · raw message

drivers/gpu/host1x/drm/drm.h +26 -1
index 3864a39..02ce020 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
@@ -15,6 +15,9 @@
 #include <drm/drm_edid.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_fixed.h>
+#include <uapi/drm/tegra_drm.h>
+
+#include "host1x.h"
 
 struct tegra_fb {
 	struct drm_framebuffer base;
@@ -47,9 +50,25 @@ 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 drm_tegra_submit *args, struct drm_device *drm,
+		      struct drm_file *file);
+};
+
+struct host1x_drm_file {
+	struct list_head contexts;
 };
 
 struct host1x_client {
@@ -58,6 +77,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 +340 -0

340 lines not on this page · raw message

drivers/gpu/host1x/host1x.h +3 -1
index bca6563..a2bc1e6 100644
@@ -22,7 +22,9 @@
 #define __LINUX_HOST1X_H
 
 enum host1x_class {
-	HOST1X_CLASS_HOST1X	= 0x1
+	HOST1X_CLASS_HOST1X	= 0x1,
+	HOST1X_CLASS_GR2D	= 0x51,
+	HOST1X_CLASS_GR2D_SB    = 0x52
 };
 
 #endif
include/uapi/drm/tegra_drm.h new file +136 -0

136 lines not on this page · raw message

Signature · 1 line
1.7.9.5