Support for Tegra 2D hardware
Subsystems (7)
v3 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.
The third version has too many changes to list all of them. Here are highlights:
* Renamed to host1x, and moved to drivers/gpu/host1x
* Greatly simplified the inner workings between physical and logical driver
* Does not use AUXDATA for passing data to driver
* Runtime power management removed - will replace with runtime PM later
* IOCTLs padded and use __64 for passing pointers
* DMABUF support removed, replaced with GEM CMA support
* host1x driver validates command streams and copies them to kernel owned buffer
* Generic interrupt support removed - only syncpt irq remains
* Sync points are allocated now dynamically
* IO register space handling rewritten to use helper functions
* Other numerous fixes and simplifications to code
Some of the issues left open:
* Register definitions still use static inline. There has been a debate about code style versus ability to use compiler type checking and code coverage analysis. There was no conclusion, so I left it as was.
* tegradrm has a global variable. Plan was to hide that behind a virtual device, and use that as DRM root device. That plan went bad once the FB CMA helper used the device for trying to allocate memory.
host1x is the driver that controls host1x hardware. It supports host1x command channels, synchronization, and memory management. It is sectioned into logical driver under drivers/gpu/host1x and physical driver under drivers/host1x/hw. The physical driver is compiled with the hardware headers of the particular host1x version.
The hardware units are described (briefly) in the Tegra2 TRM. Wiki page https://gitorious.org/linux-tegra-drm/pages/Host1xIntroduction
also contains a short description of the functionality.
The patch set removes responsibility of host1x from tegradrm. At the same time, it moves all drm related infrastructure in drivers/gpu/drm/tegra/host1x.c to drm.c.
The patch set adds 2D driver to tegradrm, which uses host1x for communicating with host1x to access sync points and channels. We expect to use the same infrastructure for other host1x clients, so we have kept host1x and tegradrm separate.
The patch set also adds user space API to tegradrm for accessing host1x and 2D. The user space parts are sent at the same time as these patches.
Arto Merilainen (1):
drm: tegra: Remove redundant host1x
Terje Bergstrom (6):
gpu: host1x: Add host1x driver
gpu: host1x: Add syncpoint wait and interrupts
gpu: host1x: Add channel support
gpu: host1x: Add debug support
ARM: tegra: Add board data and 2D clocks
drm: tegra: Add gr2d device
arch/arm/mach-tegra/board-dt-tegra20.c | 1 + arch/arm/mach-tegra/board-dt-tegra30.c | 1 + arch/arm/mach-tegra/tegra20_clocks_data.c | 2 +- arch/arm/mach-tegra/tegra30_clocks_data.c | 1 + drivers/gpu/Makefile | 1 + drivers/gpu/drm/tegra/Kconfig | 2 +- drivers/gpu/drm/tegra/Makefile | 2 +- drivers/gpu/drm/tegra/dc.c | 20 +- drivers/gpu/drm/tegra/drm.c | 428 ++++++++++++++++++- drivers/gpu/drm/tegra/drm.h | 67 ++- drivers/gpu/drm/tegra/fb.c | 17 +- drivers/gpu/drm/tegra/gr2d.c | 300 +++++++++++++ drivers/gpu/drm/tegra/hdmi.c | 24 +- drivers/gpu/drm/tegra/host1x.c | 325 -------------- drivers/gpu/host1x/Kconfig | 28 ++ drivers/gpu/host1x/Makefile | 16 + drivers/gpu/host1x/cdma.c | 475 ++++++++++++++++++++ drivers/gpu/host1x/cdma.h | 107 +++++ drivers/gpu/host1x/channel.c | 137 ++++++ drivers/gpu/host1x/channel.h | 64 +++ drivers/gpu/host1x/cma.c | 116 +++++ drivers/gpu/host1x/cma.h | 43 ++ drivers/gpu/host1x/debug.c | 207 +++++++++ drivers/gpu/host1x/debug.h | 49 +++ drivers/gpu/host1x/dev.c | 242 +++++++++++ drivers/gpu/host1x/dev.h | 165 +++++++ drivers/gpu/host1x/hw/Makefile | 6 + drivers/gpu/host1x/hw/cdma_hw.c | 480 +++++++++++++++++++++ drivers/gpu/host1x/hw/cdma_hw.h | 37 ++ drivers/gpu/host1x/hw/channel_hw.c | 147 +++++++ drivers/gpu/host1x/hw/debug_hw.c | 399 +++++++++++++++++ drivers/gpu/host1x/hw/host1x01.c | 46 ++ drivers/gpu/host1x/hw/host1x01.h | 25 ++ drivers/gpu/host1x/hw/host1x01_hardware.h | 150 +++++++ drivers/gpu/host1x/hw/hw_host1x01_channel.h | 98 +++++ drivers/gpu/host1x/hw/hw_host1x01_sync.h | 179 ++++++++ drivers/gpu/host1x/hw/hw_host1x01_uclass.h | 130 ++++++ drivers/gpu/host1x/hw/intr_hw.c | 175 ++++++++ drivers/gpu/host1x/hw/syncpt_hw.c | 157 +++++++ drivers/gpu/host1x/intr.c | 377 ++++++++++++++++ drivers/gpu/host1x/intr.h | 106 +++++ drivers/gpu/host1x/job.c | 618 +++++++++++++++++++++++++++ drivers/gpu/host1x/memmgr.c | 174 ++++++++ drivers/gpu/host1x/memmgr.h | 53 +++ drivers/gpu/host1x/syncpt.c | 397 +++++++++++++++++ drivers/gpu/host1x/syncpt.h | 134 ++++++ drivers/video/Kconfig | 2 + include/drm/tegra_drm.h | 131 ++++++ include/linux/host1x.h | 215 ++++++++++ include/trace/events/host1x.h | 296 +++++++++++++ 50 files changed, 6980 insertions(+), 392 deletions(-) create mode 100644 drivers/gpu/drm/tegra/gr2d.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/cma.c create mode 100644 drivers/gpu/host1x/cma.h create mode 100644 drivers/gpu/host1x/debug.c create mode 100644 drivers/gpu/host1x/debug.h create mode 100644 drivers/gpu/host1x/dev.c create mode 100644 drivers/gpu/host1x/dev.h create mode 100644 drivers/gpu/host1x/hw/Makefile create mode 100644 drivers/gpu/host1x/hw/cdma_hw.c create mode 100644 drivers/gpu/host1x/hw/cdma_hw.h create mode 100644 drivers/gpu/host1x/hw/channel_hw.c create mode 100644 drivers/gpu/host1x/hw/debug_hw.c create mode 100644 drivers/gpu/host1x/hw/host1x01.c create mode 100644 drivers/gpu/host1x/hw/host1x01.h create mode 100644 drivers/gpu/host1x/hw/host1x01_hardware.h create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_channel.h create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_sync.h create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_uclass.h create mode 100644 drivers/gpu/host1x/hw/intr_hw.c create mode 100644 drivers/gpu/host1x/hw/syncpt_hw.c create mode 100644 drivers/gpu/host1x/intr.c create mode 100644 drivers/gpu/host1x/intr.h create mode 100644 drivers/gpu/host1x/job.c create mode 100644 drivers/gpu/host1x/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/linux/host1x.h create mode 100644 include/trace/events/host1x.h
Signature · 1 line
1.7.9.5
PATCH v3 1/7 gpu: host1x: Add host1x driver
Add host1x, the driver for host1x and its client unit 2D.
--- drivers/gpu/Makefile | 1 + drivers/gpu/host1x/Kconfig | 6 + drivers/gpu/host1x/Makefile | 8 + drivers/gpu/host1x/dev.c | 182 +++++++++++++++++++++++ drivers/gpu/host1x/dev.h | 79 ++++++++++ drivers/gpu/host1x/hw/Makefile | 6 + drivers/gpu/host1x/hw/host1x01.c | 36 +++++ drivers/gpu/host1x/hw/host1x01.h | 25 ++++ drivers/gpu/host1x/hw/host1x01_hardware.h | 26 ++++ drivers/gpu/host1x/hw/hw_host1x01_sync.h | 66 +++++++++ drivers/gpu/host1x/hw/syncpt_hw.c | 146 +++++++++++++++++++ drivers/gpu/host1x/syncpt.c | 227 +++++++++++++++++++++++++++++ drivers/gpu/host1x/syncpt.h | 128 ++++++++++++++++ drivers/video/Kconfig | 2 + include/linux/host1x.h | 41 ++++++ include/trace/events/host1x.h | 61 ++++++++ 16 files changed, 1040 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/linux/host1x.h create mode 100644 include/trace/events/host1x.h
drivers/gpu/Makefile +1 -0
@@ -1 +1,2 @@ +obj-$(CONFIG_TEGRA_HOST1X) += host1x/ obj-y += drm/ vga/ stub/
drivers/gpu/host1x/Kconfig new file +6 -0
@@ -0,0 +1,6 @@ +config TEGRA_HOST1X + tristate "Tegra host1x driver" + help + Driver for the Tegra host1x hardware. + + Required for enabling tegradrm.
drivers/gpu/host1x/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +ccflags-y = -Idrivers/gpu/host1x + +host1x-objs = \ + syncpt.o \ + dev.o + +obj-$(CONFIG_TEGRA_HOST1X) += hw/ +obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/dev.c new file +182 -0
182 lines not on this page · raw message
drivers/gpu/host1x/dev.h new file +79 -0
79 lines not on this page · raw message
drivers/gpu/host1x/hw/Makefile new file +6 -0
@@ -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 +36 -0
@@ -0,0 +1,36 @@ +/* +* Host1x init for T20 and T30 Architecture Chips +* +* Copyright (c) 2011-2012, NVIDIA Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <linux/init.h> +#include <linux/clk.h> +#include <linux/of.h> +#include <linux/of_platform.h> +#include <linux/host1x.h> + +#include "hw/host1x01.h" +#include "dev.h" +#include "hw/host1x01_hardware.h" + +#include "hw/syncpt_hw.c" + +int host1x01_init (struct host1x *host) +{ + host->syncpt_op = host1x_syncpt_ops; + +return 0 ; +}
drivers/gpu/host1x/hw/host1x01.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Host1x init for T20 and T30 Architecture Chips +* +* Copyright (c) 2011-2012, NVIDIA Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef HOST1X_HOST1X01_H +#define HOST1X_HOST1X01_H + +struct host1x ; + +int host1x01_init (struct host1x *); + +#endif /* HOST1X_HOST1X01_H_ */
drivers/gpu/host1x/hw/host1x01_hardware.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Tegra host1x Register Offsets for Tegra20 and Tegra30 +* +* Copyright (c) 2010-2012 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 +66 -0
66 lines not on this page · raw message
drivers/gpu/host1x/hw/syncpt_hw.c new file +146 -0
146 lines not on this page · raw message
drivers/gpu/host1x/syncpt.c new file +227 -0
227 lines not on this page · raw message
drivers/gpu/host1x/syncpt.h new file +128 -0
128 lines not on this page · raw message
drivers/video/Kconfig +2 -0
@@ -19,6 +19,8 @@ source "drivers/char/agp/Kconfig" source "drivers/gpu/vga/Kconfig" +source "drivers/gpu/host1x/Kconfig" + source "drivers/gpu/drm/Kconfig" source "drivers/gpu/stub/Kconfig"
include/linux/host1x.h new file +41 -0
41 lines not on this page · raw message
include/trace/events/host1x.h new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v3 2/7 gpu: host1x: Add syncpoint wait and interrupts
In reply to Terje BergstromAdd support for sync point interrupts, and sync point wait. Sync point wait used interrupts for unblocking wait.
--- drivers/gpu/host1x/Makefile | 3 +- drivers/gpu/host1x/dev.c | 44 ++++ drivers/gpu/host1x/dev.h | 15 ++ drivers/gpu/host1x/hw/host1x01.c | 2 + drivers/gpu/host1x/hw/hw_host1x01_sync.h | 30 ++- drivers/gpu/host1x/hw/intr_hw.c | 175 +++++++++++++++ drivers/gpu/host1x/intr.c | 350 ++++++++++++++++++++++++++++++ drivers/gpu/host1x/intr.h | 100 +++++++++ drivers/gpu/host1x/syncpt.c | 161 ++++++++++++++ drivers/gpu/host1x/syncpt.h | 4 + include/linux/host1x.h | 1 + 11 files changed, 883 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/host1x/hw/intr_hw.c create mode 100644 drivers/gpu/host1x/intr.c create mode 100644 drivers/gpu/host1x/intr.h
drivers/gpu/host1x/Makefile +2 -1
@@ -2,7 +2,8 @@ ccflags-y = -Idrivers/gpu/host1x host1x-objs = \ syncpt.o \ - dev.o + dev.o \ + intr.o obj-$(CONFIG_TEGRA_HOST1X) += hw/ obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/dev.c +44 -0
94 lines not on this page · raw message
drivers/gpu/host1x/dev.h +15 -0
@@ -20,6 +20,7 @@#include <linux/host1x.h> #include "syncpt.h" +#include "intr.h" struct host1x ;struct host1x_syncpt ;
@@ -36,6 +37,18 @@ struct host1x_syncpt_ops {const char * (*name)(struct host1x_syncpt *); }; +struct host1x_intr_ops { +void (*init_host_sync)(struct host1x_intr *); +void (*set_host_clocks_per_usec)( +struct host1x_intr *,u32 clocks); +void (*set_syncpt_threshold)( +struct host1x_intr *,u32 id,u32 thresh); +void (*enable_syncpt_intr)(struct host1x_intr *,u32 id); +void (*disable_syncpt_intr)(struct host1x_intr *,u32 id); +void (*disable_all_syncpt_intrs)(struct host1x_intr *); +int (*free_syncpt_irq)(struct host1x_intr *); +}; +struct host1x_device_info {int nb_channels;/* host1x: num channels supported */ int nb_pts;/* host1x: num syncpoints supported */
@@ -48,6 +61,7 @@ struct host1x_device_info {struct host1x {void __iomem *regs;struct host1x_syncpt *syncpt; +struct host1x_intr intr;struct platform_device *dev;atomic_t clientid;struct host1x_device_info info;
@@ -57,6 +71,7 @@ struct host1x {const char *soc_name;struct host1x_syncpt_ops syncpt_op; +struct host1x_intr_ops intr_op;struct dentry *debugfs; };
drivers/gpu/host1x/hw/host1x01.c +2 -0
@@ -27,10 +27,12 @@#include "hw/host1x01_hardware.h" #include "hw/syncpt_hw.c" +#include "hw/intr_hw.c" int host1x01_init (struct host1x *host) { host->syncpt_op = host1x_syncpt_ops; + host->intr_op = host1x_intr_ops;return 0 ; }
drivers/gpu/host1x/hw/hw_host1x01_sync.h +29 -1
@@ -51,10 +51,38 @@#ifndef __hw_host1x_sync_h__#define __hw_host1x_sync_h__ +static inline u32 host1x_sync_syncpt_thresh_cpu0_int_status_r (void ) +{ +return 0x40 ; +} +static inline u32 host1x_sync_syncpt_thresh_int_disable_r (void ) +{ +return 0x60 ; +} +static inline u32 host1x_sync_syncpt_thresh_int_enable_cpu0_r (void ) +{ +return 0x68 ; +} +static inline u32 host1x_sync_usec_clk_r (void ) +{ +return 0x1a4 ; +} +static inline u32 host1x_sync_ctxsw_timeout_cfg_r (void ) +{ +return 0x1a8 ; +} +static inline u32 host1x_sync_ip_busy_timeout_r (void ) +{ +return 0x1bc ; +}static inline u32 host1x_sync_syncpt_0_r (void ) {return 0x400 ; } +static inline u32 host1x_sync_syncpt_int_thresh_0_r (void ) +{ +return 0x500 ; +}static inline u32 host1x_sync_syncpt_base_0_r (void ) {return 0x600 ;
@@ -63,4 +91,4 @@ static inline u32 host1x_sync_syncpt_cpu_incr_r(void) {return 0x700 ; } -#endif /* __hw_host1x_host1x_h__ */ +#endif /* __hw_host1x_sync_h__ */
drivers/gpu/host1x/hw/intr_hw.c new file +175 -0
175 lines not on this page · raw message
drivers/gpu/host1x/intr.c new file +350 -0
350 lines not on this page · raw message
drivers/gpu/host1x/intr.h new file +100 -0
100 lines not on this page · raw message
drivers/gpu/host1x/syncpt.c +161 -0
173 lines not on this page · raw message
drivers/gpu/host1x/syncpt.h +4 -0
@@ -106,6 +106,7 @@ struct host1x_syncpt *host1x_syncpt_get(struct host1x *dev, u32 id);void host1x_syncpt_cpu_incr (struct host1x_syncpt *sp);u32 host1x_syncpt_load_min (struct host1x_syncpt *sp); +bool host1x_syncpt_is_expired (struct host1x_syncpt *sp,u32 thresh);void host1x_syncpt_save (struct host1x *dev);
@@ -117,6 +118,9 @@ u32 host1x_syncpt_read_wait_base(struct host1x_syncpt *sp);void host1x_syncpt_incr (struct host1x_syncpt *sp);u32 host1x_syncpt_incr_max (struct host1x_syncpt *sp,u32 incrs); +int host1x_syncpt_wait (struct host1x_syncpt *sp,u32 thresh, +long timeout,u32 *value); +void host1x_syncpt_debug (struct host1x_syncpt *sp);static inline int host1x_syncpt_is_valid (struct host1x_syncpt *sp)
include/linux/host1x.h +1 -0
@@ -33,6 +33,7 @@ struct host1x_syncpt;u32 host1x_syncpt_id (struct host1x_syncpt *sp);void host1x_syncpt_incr_byid (u32 id);u32 host1x_syncpt_read_byid (u32 id); +int host1x_syncpt_wait_byid (u32 id,u32 thresh,long timeout,u32 *value);struct host1x_syncpt *host1x_syncpt_alloc (struct platform_device *pdev,int client_managed);
Signature · 1 line
1.7.9.5
PATCH v3 3/7 gpu: host1x: Add channel support
In reply to Terje BergstromAdd support for host1x client modules, and host1x channels to submit work to the clients. The work is submitted in GEM CMA buffers, so this patch adds support for them.
--- drivers/gpu/host1x/Kconfig | 24 +- drivers/gpu/host1x/Makefile | 8 +- drivers/gpu/host1x/cdma.c | 438 +++++++++++++++++++ drivers/gpu/host1x/cdma.h | 107 +++++ drivers/gpu/host1x/channel.c | 137 ++++++ drivers/gpu/host1x/channel.h | 64 +++ drivers/gpu/host1x/cma.c | 116 +++++ drivers/gpu/host1x/cma.h | 43 ++ drivers/gpu/host1x/dev.c | 13 + drivers/gpu/host1x/dev.h | 54 +++ drivers/gpu/host1x/hw/cdma_hw.c | 477 +++++++++++++++++++++ drivers/gpu/host1x/hw/cdma_hw.h | 37 ++ drivers/gpu/host1x/hw/channel_hw.c | 147 +++++++ drivers/gpu/host1x/hw/host1x01.c | 6 + drivers/gpu/host1x/hw/host1x01_hardware.h | 124 ++++++ drivers/gpu/host1x/hw/hw_host1x01_channel.h | 86 ++++ drivers/gpu/host1x/hw/hw_host1x01_sync.h | 8 + drivers/gpu/host1x/hw/hw_host1x01_uclass.h | 130 ++++++ drivers/gpu/host1x/hw/syncpt_hw.c | 10 + drivers/gpu/host1x/intr.c | 29 +- drivers/gpu/host1x/intr.h | 6 + drivers/gpu/host1x/job.c | 618 +++++++++++++++++++++++++++ drivers/gpu/host1x/memmgr.c | 174 ++++++++ drivers/gpu/host1x/memmgr.h | 53 +++ drivers/gpu/host1x/syncpt.c | 6 + drivers/gpu/host1x/syncpt.h | 2 + include/linux/host1x.h | 173 ++++++++ include/trace/events/host1x.h | 235 ++++++++++ 28 files changed, 3322 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/host1x/cdma.c create mode 100644 drivers/gpu/host1x/cdma.h create mode 100644 drivers/gpu/host1x/channel.c create mode 100644 drivers/gpu/host1x/channel.h create mode 100644 drivers/gpu/host1x/cma.c create mode 100644 drivers/gpu/host1x/cma.h create mode 100644 drivers/gpu/host1x/hw/cdma_hw.c create mode 100644 drivers/gpu/host1x/hw/cdma_hw.h create mode 100644 drivers/gpu/host1x/hw/channel_hw.c create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_channel.h create mode 100644 drivers/gpu/host1x/hw/hw_host1x01_uclass.h create mode 100644 drivers/gpu/host1x/job.c create mode 100644 drivers/gpu/host1x/memmgr.c create mode 100644 drivers/gpu/host1x/memmgr.h
drivers/gpu/host1x/Kconfig +23 -1
@@ -3,4 +3,26 @@ config TEGRA_HOST1X help Driver for the Tegra host1x hardware. - Required for enabling tegradrm. + Required for enabling tegradrm and 2D acceleration. + +if TEGRA_HOST1X + +config TEGRA_HOST1X_CMA + bool "Support DRM CMA buffers" + depends on DRM + select DRM_GEM_CMA_HELPER + select DRM_KMS_CMA_HELPER + help + Say yes if you wish to use DRM CMA buffers. + + If unsure, choose Y. + +config TEGRA_HOST1X_FIREWALL + bool "Enable HOST1X security firewall" + default y + help + Say yes if kernel should protect command streams from tampering. + + If unsure, choose Y. + +endif
drivers/gpu/host1x/Makefile +7 -1
@@ -3,7 +3,13 @@ ccflags-y = -Idrivers/gpu/host1x host1x-objs = \ syncpt.o \ dev.o \ - intr.o + intr.o \ + cdma.o \ + intr.o \ + channel.o \ + job.o \ + memmgr.o +obj-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o obj-$(CONFIG_TEGRA_HOST1X) += hw/ obj-$(CONFIG_TEGRA_HOST1X) += host1x.o
drivers/gpu/host1x/cdma.c new file +438 -0
438 lines not on this page · raw message
drivers/gpu/host1x/cdma.h new file +107 -0
107 lines not on this page · raw message
drivers/gpu/host1x/channel.c new file +137 -0
137 lines not on this page · raw message
drivers/gpu/host1x/channel.h new file +64 -0
64 lines not on this page · raw message
drivers/gpu/host1x/cma.c new file +116 -0
116 lines not on this page · raw message
drivers/gpu/host1x/cma.h new file +43 -0
43 lines not on this page · raw message
drivers/gpu/host1x/dev.c +13 -0
@@ -26,6 +26,7 @@#include <linux/io.h> #include "dev.h" #include "intr.h" +#include "channel.h" #include "hw/host1x01.h" #define CREATE_TRACE_POINTS
@@ -76,6 +77,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 int host1x_alloc_resources (struct host1x *host) { host->intr.syncpt = devm_kzalloc(&host->dev->dev,
@@ -184,6 +195,8 @@ static int host1x_probe(struct platform_device *dev)host1x_syncpt_reset (host); +host1x_channel_list_init (host); +host1x_intr_start (&host->intr,clk_get_rate (host->clk)); host1x = host;
drivers/gpu/host1x/dev.h +54 -0
81 lines not on this page · raw message
drivers/gpu/host1x/hw/cdma_hw.c new file +477 -0
477 lines not on this page · raw message
drivers/gpu/host1x/hw/cdma_hw.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Tegra host1x Command DMA +* +* Copyright (c) 2011-2012, NVIDIA Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __HOST1X_CDMA_H +#define __HOST1X_CDMA_H + +/* +* Size of the sync queue. If it is too small, we won't be able to queue up +* many command buffers. If it is too large, we waste memory. +*/ +#define HOST1X_SYNC_QUEUE_SIZE 512 + +/* +* Number of gathers we allow to be queued up per channel. Must be a +* power of two. Currently sized such that pushbuffer is 4KB (512*8B). +*/ +#define HOST1X_GATHER_QUEUE_SIZE 512 + +/* 8 bytes per slot. (This number does not include the final RESTART.) */ +#define PUSH_BUFFER_SIZE (HOST1X_GATHER_QUEUE_SIZE * 8) + +#endif
drivers/gpu/host1x/hw/channel_hw.c new file +147 -0
147 lines not on this page · raw message
drivers/gpu/host1x/hw/host1x01.c +6 -0
@@ -24,13 +24,19 @@#include "hw/host1x01.h" #include "dev.h" +#include "channel.h" #include "hw/host1x01_hardware.h" +#include "hw/channel_hw.c" +#include "hw/cdma_hw.c" #include "hw/syncpt_hw.c" #include "hw/intr_hw.c" int host1x01_init (struct host1x *host) { + host->channel_op = host1x_channel_ops; + host->cdma_op = host1x_cdma_ops; + host->cdma_pb_op = host1x_pushbuffer_ops; host->syncpt_op = host1x_syncpt_ops; host->intr_op = host1x_intr_ops;
drivers/gpu/host1x/hw/host1x01_hardware.h +124 -0
130 lines not on this page · raw message
drivers/gpu/host1x/hw/hw_host1x01_channel.h new file +86 -0
86 lines not on this page · raw message
drivers/gpu/host1x/hw/hw_host1x01_sync.h +8 -0
@@ -63,6 +63,14 @@ static inline u32 host1x_sync_syncpt_thresh_int_enable_cpu0_r(void) {return 0x68 ; } +static inline u32 host1x_sync_cmdproc_stop_r (void ) +{ +return 0xac ; +} +static inline u32 host1x_sync_ch_teardown_r (void ) +{ +return 0xb0 ; +}static inline u32 host1x_sync_usec_clk_r (void ) {return 0x1a4 ;
drivers/gpu/host1x/hw/hw_host1x01_uclass.h new file +130 -0
130 lines not on this page · raw message
drivers/gpu/host1x/hw/syncpt_hw.c +10 -0
@@ -97,6 +97,15 @@ static void syncpt_cpu_incr(struct host1x_syncpt *sp)wmb (); } +/* remove a wait pointed to by patch_addr */ +static int syncpt_patch_wait (struct host1x_syncpt *sp,void *patch_addr) +{ +u32 override =host1x_class_host_wait_syncpt ( +NVSYNCPT_GRAPHICS_HOST ,0 ); +__raw_writel (override, patch_addr); +return 0 ; +} +static const char *syncpt_name (struct host1x_syncpt *sp) {struct host1x_device_info *info = &sp->dev->info;
@@ -141,6 +150,7 @@ static const struct host1x_syncpt_ops host1x_syncpt_ops = { .read_wait_base = syncpt_read_wait_base, .load_min = syncpt_load_min, .cpu_incr = syncpt_cpu_incr, + .patch_wait = syncpt_patch_wait, .debug = syncpt_debug, .name = syncpt_name, };
drivers/gpu/host1x/intr.c +28 -1
@@ -20,6 +20,8 @@#include <linux/interrupt.h> #include <linux/slab.h> #include <linux/irq.h> +#include <trace/events/host1x.h> +#include "channel.h" #include "dev.h" /* Wait list management */
@@ -74,7 +76,7 @@ static void remove_completed_waiters(struct list_head *head, u32 sync, struct list_head completed[HOST1X_INTR_ACTION_COUNT]) {struct list_head *dest; -struct host1x_waitlist *waiter, *next; +struct host1x_waitlist *waiter, *next, *prev;list_for_each_entry_safe (waiter, next, head, list) {if ((s32)(waiter->thresh - sync) >0 )
@@ -82,6 +84,17 @@ static void remove_completed_waiters(struct list_head *head, u32 sync, dest = completed + waiter->action; +/* consolidate submit cleanups */ +if (waiter->action ==HOST1X_INTR_ACTION_SUBMIT_COMPLETE + && !list_empty (dest)) { + prev =list_entry (dest->prev, + struct host1x_waitlist, list); +if (prev->data == waiter->data) { + prev->count++; + dest =NULL ; + } + } +/* PENDING->REMOVED or CANCELLED->HANDLED */ if (atomic_inc_return (&waiter->state) ==WLS_HANDLED || !dest) {list_del (&waiter->list);
@@ -104,6 +117,19 @@ void reset_threshold_interrupt(struct host1x_intr *intr, host1x->intr_op.enable_syncpt_intr (intr, id); } +static void action_submit_complete (struct host1x_waitlist *waiter) +{ +struct host1x_channel *channel = waiter->data; +int nr_completed = waiter->count; + +host1x_cdma_update (&channel->cdma); + +/* Add nr_completed to trace */ +trace_host1x_channel_submit_complete (channel->dev->name, + nr_completed, waiter->thresh); + +} +static void action_wakeup (struct host1x_waitlist *waiter) {wait_queue_head_t *wq = waiter->data;
@@ -121,6 +147,7 @@ static void action_wakeup_interruptible(struct host1x_waitlist *waiter)typedef void (*action_handler )(struct host1x_waitlist *waiter);static action_handler action_handlers[HOST1X_INTR_ACTION_COUNT ] = { + action_submit_complete, action_wakeup, action_wakeup_interruptible, };
drivers/gpu/host1x/intr.h +6 -0
@@ -28,6 +28,12 @@ struct host1x_channel;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 +618 -0
618 lines not on this page · raw message
drivers/gpu/host1x/memmgr.c new file +174 -0
174 lines not on this page · raw message
drivers/gpu/host1x/memmgr.h new file +53 -0
17 lines not on this page · raw message
include/linux/host1x.h +173 -0
173 lines not on this page · raw message
include/trace/events/host1x.h +235 -0
235 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.
PATCH v3 4/7 gpu: host1x: Add debug support
In reply to Terje BergstromAdd 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 | 37 +++ drivers/gpu/host1x/debug.c | 207 ++++++++++++++ drivers/gpu/host1x/debug.h | 49 ++++ drivers/gpu/host1x/dev.c | 3 + drivers/gpu/host1x/dev.h | 17 ++ drivers/gpu/host1x/hw/cdma_hw.c | 3 + drivers/gpu/host1x/hw/debug_hw.c | 399 +++++++++++++++++++++++++++ drivers/gpu/host1x/hw/host1x01.c | 2 + drivers/gpu/host1x/hw/hw_host1x01_channel.h | 12 + drivers/gpu/host1x/hw/hw_host1x01_sync.h | 77 ++++++ drivers/gpu/host1x/hw/syncpt_hw.c | 1 + drivers/gpu/host1x/syncpt.c | 3 + 13 files changed, 811 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
@@ -8,6 +8,7 @@ host1x-objs = \ intr.o \ channel.o \ job.o \ + debug.o \ memmgr.o obj-$(CONFIG_TEGRA_HOST1X_CMA) += cma.o
drivers/gpu/host1x/cdma.c +37 -0
@@ -19,6 +19,7 @@#include "cdma.h" #include "channel.h" #include "dev.h" +#include "debug.h" #include "memmgr.h" #include <asm/cacheflush.h>
@@ -369,12 +370,45 @@ int host1x_cdma_begin(struct host1x_cdma *cdma, struct host1x_job *job)return 0 ; } +static void trace_write_gather (struct host1x_cdma *cdma, +struct mem_handle *ref, +u32 offset,u32 words) +{ +void *mem =NULL ; + +if (host1x_debug_trace_cmdbuf) { + mem =host1x_memmgr_mmap (ref); +if (IS_ERR_OR_NULL (mem)) + mem =NULL ; + }; + +if (mem) { +u32 i; +/* +* Write in batches of 128 as there seems to be a limit +* of how much you can output to ftrace at once. +*/ +for (i =0 ; i < words; i +=TRACE_MAX_LENGTH ) { +trace_host1x_cdma_push_gather ( +cdma_to_channel (cdma)->dev->name, + (u32 )ref, +min (words - i,TRACE_MAX_LENGTH ), + offset + i *sizeof (u32), + mem); + } +host1x_memmgr_munmap (ref, mem); + } +} +/* * Push two words into a push buffer slot * Blocks as necessary if the push buffer is full. */ void host1x_cdma_push (struct host1x_cdma *cdma,u32 op1,u32 op2) { +if (host1x_debug_trace_cmdbuf) +trace_host1x_cdma_push (cdma_to_channel (cdma)->dev->name, + op1, op2);host1x_cdma_push_gather (cdma,NULL ,0 , op1, op2); }
@@ -390,6 +424,9 @@ void host1x_cdma_push_gather(struct host1x_cdma *cdma,u32 slots_free = cdma->slots_free;struct push_buffer *pb = &cdma->push_buffer; +if (handle) +trace_write_gather (cdma, handle, offset, op1 &0xffff ); +if (slots_free ==0 ) { host1x->cdma_op.kick (cdma); slots_free = host1x_cdma_wait_locked(cdma,
drivers/gpu/host1x/debug.c new file +207 -0
207 lines not on this page · raw message
drivers/gpu/host1x/debug.h new file +49 -0
49 lines not on this page · raw message
drivers/gpu/host1x/dev.c +3 -0
@@ -27,6 +27,7 @@#include "dev.h" #include "intr.h" #include "channel.h" +#include "debug.h" #include "hw/host1x01.h" #define CREATE_TRACE_POINTS
@@ -199,6 +200,8 @@ static int host1x_probe(struct platform_device *dev)host1x_intr_start (&host->intr,clk_get_rate (host->clk)); +host1x_debug_init (host); + host1x = host;dev_info (&dev->dev,"initialized\n" );
drivers/gpu/host1x/dev.h +17 -0
@@ -33,6 +33,7 @@ struct push_buffer;struct dentry ;struct mem_handle ;struct platform_device ; +struct output ;struct host1x_channel_ops {const char *soc_name;
@@ -72,6 +73,21 @@ struct host1x_pushbuffer_ops {u32 (*putptr)(struct push_buffer *); }; +struct host1x_debug_ops { +void (*debug_init)(struct dentry *de); +void (*show_channel_cdma)(struct host1x *, +struct host1x_channel *, +struct output *, +int chid); +void (*show_channel_fifo)(struct host1x *, +struct host1x_channel *, +struct output *, +int chid); +void (*show_mlocks)(struct host1x *m, +struct output *o); + +}; +struct host1x_syncpt_ops {void (*reset)(struct host1x_syncpt *);void (*reset_wait_base)(struct host1x_syncpt *);
@@ -119,6 +135,7 @@ struct host1x {struct host1x_channel_ops channel_op;struct host1x_cdma_ops cdma_op;struct host1x_pushbuffer_ops cdma_pb_op; +struct host1x_debug_ops debug_op;struct host1x_syncpt_ops syncpt_op;struct host1x_intr_ops intr_op;
drivers/gpu/host1x/hw/cdma_hw.c +3 -0
@@ -22,6 +22,7 @@#include "cdma.h" #include "channel.h" #include "dev.h" +#include "debug.h" #include "memmgr.h" #include "cdma_hw.h"
@@ -409,6 +410,8 @@ static void cdma_timeout_handler(struct work_struct *work) host1x =cdma_to_host1x (cdma); ch =cdma_to_channel (cdma); +host1x_debug_dump (cdma_to_host1x (cdma)); +mutex_lock (&cdma->lock);if (!cdma->timeout.clientid) {
drivers/gpu/host1x/hw/debug_hw.c new file +399 -0
399 lines not on this page · raw message
drivers/gpu/host1x/hw/host1x01.c +2 -0
@@ -29,6 +29,7 @@#include "hw/channel_hw.c" #include "hw/cdma_hw.c" +#include "hw/debug_hw.c" #include "hw/syncpt_hw.c" #include "hw/intr_hw.c"
@@ -37,6 +38,7 @@ int host1x01_init(struct host1x *host) host->channel_op = host1x_channel_ops; host->cdma_op = host1x_cdma_ops; host->cdma_pb_op = host1x_pushbuffer_ops; + host->debug_op = host1x_debug_ops; host->syncpt_op = host1x_syncpt_ops; host->intr_op = host1x_intr_ops;
drivers/gpu/host1x/hw/hw_host1x01_channel.h +12 -0
@@ -51,6 +51,14 @@#ifndef __hw_host1x_channel_host1x_h__#define __hw_host1x_channel_host1x_h__ +static inline u32 host1x_channel_fifostat_r (void ) +{ +return 0x0 ; +} +static inline u32 host1x_channel_fifostat_cfempty_v (u32 r) +{ +return (r >>10 ) &0x1 ; +}static inline u32 host1x_channel_dmastart_r (void ) {return 0x14 ;
@@ -75,6 +83,10 @@ static inline u32 host1x_channel_dmactrl_dmastop_f(u32 v) {return (v &0x1 ) <<0 ; } +static inline u32 host1x_channel_dmactrl_dmastop_v (u32 r) +{ +return (r >>0 ) &0x1 ; +}static inline u32 host1x_channel_dmactrl_dmagetrst_f (u32 v) {return (v &0x1 ) <<1 ;
drivers/gpu/host1x/hw/hw_host1x01_sync.h +77 -0
93 lines not on this page · raw message
drivers/gpu/host1x/hw/syncpt_hw.c +1 -0
@@ -90,6 +90,7 @@ static void syncpt_cpu_incr(struct host1x_syncpt *sp)dev_err (&dev->dev->dev,"Trying to increment syncpoint id %d beyond max\n" , sp->id); +host1x_debug_dump (sp->dev);return ; } host1x_sync_writel(dev, BIT_MASK(sp->id),
drivers/gpu/host1x/syncpt.c +3 -0
@@ -23,6 +23,7 @@#include "syncpt.h" #include "dev.h" #include "intr.h" +#include "debug.h" #include <trace/events/host1x.h> #define MAX_SYNCPT_LENGTH 5
@@ -219,6 +220,8 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, current->comm, sp->id, sp->name, thresh, timeout); sp->dev->syncpt_op.debug (sp); +if (check_count ==MAX_STUCK_CHECK_COUNT ) +host1x_debug_dump (sp->dev); check_count++; } }
Signature · 1 line
1.7.9.5
Re: [PATCHv3 4/7] gpu: host1x: Add debug support
Quoted 2 lines · Terje Bergstrom
Add support for host1x debugging. Adds debugfs entries, and dumps channel state to UART in case of stuck job.
trivial note:
[]
drivers/gpu/host1x/debug.h
Quoted 1 line
drivers/gpu/host1x/debug.h +0
-0
[]
Quoted 1 line
+void
host1x_debug_output(struct output *o, const char *fmt, ...);
This should be marked __printf(2, 3)
so the compiler verifies format and argument types.
Re: [PATCHv3 4/7] gpu: host1x: Add debug support
Quoted 6 lines · Joe Perches
Quoted 2 lines · Terje Bergstrom
Add support for host1x debugging. Adds debugfs entries, and dumps channel state to UART in case of stuck job.
trivial note:
Quoted 8 lines
[]
drivers/gpu/host1x/debug.h
Quoted 1 line
drivers/gpu/host1x/debug.h +0
-0[]
Quoted 1 line
+void
host1x_debug_output(struct output *o, const char *fmt, ...);This should be marked
__printf(2, 3)
so the compiler verifies format and argument types.
Thanks, I didn't know of this "trick". I'll apply it in the next version.
Considering the amount of feedback I've received from the patches, they must be top notch quality!
Terje
Re: [PATCHv3 4/7] gpu: host1x: Add debug support
Quoted 2 lines · Terje Bergström
Considering the amount of feedback I've received from the patches, they must be top notch quality!
Maybe.
Maybe no one else has the hardware.
PATCH v3 5/7 drm: tegra: Remove redundant host1x
In reply to Terje BergstromFrom: Arto Merilainen <[email protected]>
This patch removes the redundant host1x driver from tegradrm and makes necessary bindings to the separate host driver.
The infrastructure for drm client lists is merged to drm.c.
The patch simplifies driver initialization; The original driver had two lists for registered devices (clients and drm_active). The clients list included references to all registered devices whereas the drm_active list included only the devices that the tegradrm driver itself supported. host1x is separated into a driver of its own and hence there should be no need to support registration of external drivers. Therefore, only the drm_active list is reserved. Removal of the list also simplifies the driver unregistration.
--- drivers/gpu/drm/tegra/Kconfig | 2 +- drivers/gpu/drm/tegra/Makefile | 2 +- drivers/gpu/drm/tegra/dc.c | 20 ++- drivers/gpu/drm/tegra/drm.c | 217 +++++++++++++++++++++++++-- drivers/gpu/drm/tegra/drm.h | 38 ++--- drivers/gpu/drm/tegra/fb.c | 17 ++- drivers/gpu/drm/tegra/hdmi.c | 24 ++- drivers/gpu/drm/tegra/host1x.c | 325 ---------------------------------------- include/drm/tegra_drm.h | 20 +++ 9 files changed, 275 insertions(+), 390 deletions(-) delete mode 100644 drivers/gpu/drm/tegra/host1x.c create mode 100644 include/drm/tegra_drm.h
drivers/gpu/drm/tegra/Kconfig +1 -1
@@ -1,6 +1,6 @@ config DRM_TEGRA tristate "NVIDIA Tegra DRM" - depends on DRM && OF && ARCH_TEGRA + depends on DRM && OF && ARCH_TEGRA && TEGRA_HOST1X select DRM_KMS_HELPER select DRM_GEM_CMA_HELPER select DRM_KMS_CMA_HELPER
drivers/gpu/drm/tegra/Makefile +1 -1
@@ -1,7 +1,7 @@ ccflags-y := -Iinclude/drm ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG -tegra-drm-y := drm.o fb.o dc.o host1x.o +tegra-drm-y := drm.o fb.o dc.o tegra-drm-y += output.o rgb.o hdmi.o obj-$(CONFIG_DRM_TEGRA) += tegra-drm.o
drivers/gpu/drm/tegra/dc.c +9 -11
@@ -673,10 +673,10 @@ static int tegra_dc_debugfs_exit(struct tegra_dc *dc)return 0 ; } -static int tegra_dc_drm_init (struct host1x_client *client, +static int tegra_dc_drm_init (struct tegra_drm_client *client,struct drm_device *drm) { -struct tegra_dc *dc =host1x_client_to_dc (client); +struct tegra_dc *dc =tegra_drm_client_to_dc (client);int err; dc->pipe = drm->mode_config.num_crtc;
@@ -708,9 +708,9 @@ static int tegra_dc_drm_init(struct host1x_client *client,return 0 ; } -static int tegra_dc_drm_exit (struct host1x_client *client) +static int tegra_dc_drm_exit (struct tegra_drm_client *client) { -struct tegra_dc *dc =host1x_client_to_dc (client); +struct tegra_dc *dc =tegra_drm_client_to_dc (client);int err;devm_free_irq (dc->dev, dc->irq, dc);
@@ -730,14 +730,13 @@ static int tegra_dc_drm_exit(struct host1x_client *client)return 0 ; } -static const struct host1x_client_ops dc_client_ops = { +static const struct tegra_drm_client_ops dc_client_ops = { .drm_init = tegra_dc_drm_init, .drm_exit = tegra_dc_drm_exit, };static int tegra_dc_probe (struct platform_device *pdev) { -struct host1x *host1x =dev_get_drvdata (pdev->dev.parent);struct resource *regs;struct tegra_dc *dc;int err;
@@ -787,9 +786,9 @@ static int tegra_dc_probe(struct platform_device *pdev)return err; } - err =host1x_register_client (host1x, &dc->client); + err =tegra_drm_register_client (&dc->client);if (err <0 ) { -dev_err (&pdev->dev,"failed to register host1x client: %d\n" , +dev_err (&pdev->dev,"failed to register tegra drm client: %d\n" , err);return err; }
@@ -801,13 +800,12 @@ 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 tegra_dc *dc =platform_get_drvdata (pdev);int err; - err =host1x_unregister_client (host1x, &dc->client); + err =tegra_drm_unregister_client (&dc->client);if (err <0 ) { -dev_err (&pdev->dev,"failed to unregister host1x client: %d\n" , +dev_err (&pdev->dev,"failed to unregister tegra_drm client: %d\n" , err);return err; }
drivers/gpu/drm/tegra/drm.c +207 -10
255 lines not on this page · raw message
drivers/gpu/drm/tegra/drm.h +15 -23
@@ -17,6 +17,7 @@#include <drm/drm_gem_cma_helper.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_fixed.h> +#include <drm/tegra_drm.h> struct tegra_framebuffer {struct drm_framebuffer base;
@@ -28,13 +29,9 @@ static inline struct tegra_framebuffer *to_tegra_fb(struct drm_framebuffer *fb) return container_of(fb, struct tegra_framebuffer, base); } -struct host1x { +struct tegradrm {struct drm_device *drm;struct device *dev; -void __iomem *regs; -struct clk *clk; -int syncpt; -int irq;struct mutex drm_clients_lock;struct list_head drm_clients;
@@ -47,36 +44,30 @@ struct host1x {struct tegra_framebuffer fb; }; -struct host1x_client ; +struct tegra_drm_client ; -struct host1x_client_ops { -int (*drm_init)(struct host1x_client *client,struct drm_device *drm); -int (*drm_exit)(struct host1x_client *client); +struct tegra_drm_client_ops { +int (*drm_init)(struct tegra_drm_client *,struct drm_device *); +int (*drm_exit)(struct tegra_drm_client *); }; -struct host1x_client { -struct host1x *host1x; +struct tegra_drm_client {struct device *dev; -const struct host1x_client_ops *ops; +const struct tegra_drm_client_ops *ops;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_register_client (struct host1x *host1x, -struct host1x_client *client); -extern int host1x_unregister_client (struct host1x *host1x, -struct host1x_client *client); +extern int tegra_drm_register_client (struct tegra_drm_client *client); +extern int tegra_drm_unregister_client (struct tegra_drm_client *client);struct tegra_output ;struct tegra_dc { -struct host1x_client client; +struct tegra_drm_client client; -struct host1x *host1x;struct device *dev;struct drm_crtc base;
@@ -96,7 +87,8 @@ struct tegra_dc {struct dentry *debugfs; }; -static inline struct tegra_dc *host1x_client_to_dc (struct host1x_client *client) +static inline struct tegra_dc *tegra_drm_client_to_dc ( +struct tegra_drm_client *client) { return container_of(client, struct tegra_dc, client); }
@@ -225,8 +217,8 @@ extern struct vm_operations_struct tegra_gem_vm_ops;/* from fb.c */ extern int tegra_drm_fb_init (struct drm_device *drm);extern void tegra_drm_fb_exit (struct drm_device *drm); +extern void tegra_drm_fb_restore (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;
drivers/gpu/drm/tegra/fb.c +11 -6
@@ -11,9 +11,9 @@static void tegra_drm_fb_output_poll_changed (struct drm_device *drm) { -struct host1x *host1x = drm->dev_private; +struct tegradrm *tegradrm = drm->dev_private; -drm_fbdev_cma_hotplug_event (host1x->fbdev); +drm_fbdev_cma_hotplug_event (tegradrm->fbdev); }static const struct drm_mode_config_funcs tegra_drm_mode_funcs = {
@@ -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 tegradrm *tegradrm = drm->dev_private;struct drm_fbdev_cma *fbdev; drm->mode_config.min_width =0 ;
@@ -43,14 +43,19 @@ int tegra_drm_fb_init(struct drm_device *drm)drm_fbdev_cma_restore_mode (fbdev);#endif - host1x->fbdev = fbdev; + tegradrm->fbdev = fbdev;return 0 ; }void tegra_drm_fb_exit (struct drm_device *drm) { -struct host1x *host1x = drm->dev_private; +struct tegradrm *tegradrm = drm->dev_private; +drm_fbdev_cma_fini (tegradrm->fbdev); +} -drm_fbdev_cma_fini (host1x->fbdev); +void tegra_drm_fb_restore (struct drm_device *drm) +{ +struct tegradrm *tegradrm = drm->dev_private; +drm_fbdev_cma_restore_mode (tegradrm->fbdev); }
drivers/gpu/drm/tegra/hdmi.c +11 -13
@@ -22,7 +22,7 @@#include "dc.h" struct tegra_hdmi { -struct host1x_client client; +struct tegra_drm_client client;struct tegra_output output;struct device *dev;
@@ -46,7 +46,7 @@ struct tegra_hdmi { };static inline struct tegra_hdmi * -host1x_client_to_hdmi (struct host1x_client *client) +tegra_drm_client_to_hdmi (struct tegra_drm_client *client) { return container_of(client, struct tegra_hdmi, client); }
@@ -1152,10 +1152,10 @@ static int tegra_hdmi_debugfs_exit(struct tegra_hdmi *hdmi)return 0 ; } -static int tegra_hdmi_drm_init (struct host1x_client *client, +static int tegra_hdmi_drm_init (struct tegra_drm_client *client,struct drm_device *drm) { -struct tegra_hdmi *hdmi =host1x_client_to_hdmi (client); +struct tegra_hdmi *hdmi =tegra_drm_client_to_hdmi (client);int err; hdmi->output.type =TEGRA_OUTPUT_HDMI ;
@@ -1177,9 +1177,9 @@ static int tegra_hdmi_drm_init(struct host1x_client *client,return 0 ; } -static int tegra_hdmi_drm_exit (struct host1x_client *client) +static int tegra_hdmi_drm_exit (struct tegra_drm_client *client) { -struct tegra_hdmi *hdmi =host1x_client_to_hdmi (client); +struct tegra_hdmi *hdmi =tegra_drm_client_to_hdmi (client);int err;if (IS_ENABLED (CONFIG_DEBUG_FS )) {
@@ -1204,14 +1204,13 @@ static int tegra_hdmi_drm_exit(struct host1x_client *client)return 0 ; } -static const struct host1x_client_ops hdmi_client_ops = { +static const struct tegra_drm_client_ops hdmi_client_ops = { .drm_init = tegra_hdmi_drm_init, .drm_exit = tegra_hdmi_drm_exit, };static int tegra_hdmi_probe (struct platform_device *pdev) { -struct host1x *host1x =dev_get_drvdata (pdev->dev.parent);struct tegra_hdmi *hdmi;struct resource *regs;int err;
@@ -1286,9 +1285,9 @@ static int tegra_hdmi_probe(struct platform_device *pdev)INIT_LIST_HEAD (&hdmi->client.list); hdmi->client.dev = &pdev->dev; - err =host1x_register_client (host1x, &hdmi->client); + err =tegra_drm_register_client (&hdmi->client);if (err <0 ) { -dev_err (&pdev->dev,"failed to register host1x client: %d\n" , +dev_err (&pdev->dev,"failed to register tegra drm client: %d\n" , err);return err; }
@@ -1300,13 +1299,12 @@ 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 tegra_hdmi *hdmi =platform_get_drvdata (pdev);int err; - err =host1x_unregister_client (host1x, &hdmi->client); + err =tegra_drm_unregister_client (&hdmi->client);if (err <0 ) { -dev_err (&pdev->dev,"failed to unregister host1x client: %d\n" , +dev_err (&pdev->dev,"failed to unregister tegra drm client: %d\n" , err);return err; }
drivers/gpu/drm/tegra/host1x.c deleted +0 -325
325 lines not on this page · raw message
include/drm/tegra_drm.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. +* +* 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 _TEGRA_DRM_H_ +#define _TEGRA_DRM_H_ + +#endif
Signature · 1 line
1.7.9.5
PATCH v3 6/7 ARM: tegra: Add board data and 2D clocks
In reply to Terje BergstromAdd a driver alias gr2d for Tegra 2D device, and assign a duplicate of 2D clock to that driver alias.
--- arch/arm/mach-tegra/board-dt-tegra20.c | 1 + arch/arm/mach-tegra/board-dt-tegra30.c | 1 + arch/arm/mach-tegra/tegra20_clocks_data.c | 2 +- arch/arm/mach-tegra/tegra30_clocks_data.c | 1 + 4 files changed, 4 insertions(+), 1 deletion(-)
arch/arm/mach-tegra/board-dt-tegra20.c +1 -0
@@ -95,6 +95,7 @@ struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {OF_DEV_AUXDATA ("nvidia,tegra20-slink" ,0x7000D800 ,"spi_tegra.2" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra20-slink" ,0x7000DA00 ,"spi_tegra.3" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra20-host1x" ,0x50000000 ,"host1x" ,NULL ), +OF_DEV_AUXDATA ("nvidia,tegra20-gr2d" ,0x54140000 ,"gr2d" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra20-dc" ,0x54200000 ,"tegradc.0" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra20-dc" ,0x54240000 ,"tegradc.1" ,NULL ), OF_DEV_AUXDATA("nvidia,tegra20-hdmi", 0x54280000, "hdmi", NULL),
arch/arm/mach-tegra/board-dt-tegra30.c +1 -0
@@ -58,6 +58,7 @@ struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = {OF_DEV_AUXDATA ("nvidia,tegra30-slink" ,0x7000DC00 ,"spi_tegra.4" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra30-slink" ,0x7000DE00 ,"spi_tegra.5" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra30-host1x" ,0x50000000 ,"host1x" ,NULL ), +OF_DEV_AUXDATA ("nvidia,tegra30-gr2d" ,0x54140000 ,"gr2d" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra30-dc" ,0x54200000 ,"tegradc.0" ,NULL ),OF_DEV_AUXDATA ("nvidia,tegra30-dc" ,0x54240000 ,"tegradc.1" ,NULL ), OF_DEV_AUXDATA("nvidia,tegra30-hdmi", 0x54280000, "hdmi", NULL),
arch/arm/mach-tegra/tegra20_clocks_data.c +1 -1
@@ -1041,7 +1041,7 @@ static struct clk_duplicate tegra_clk_duplicates[] = {CLK_DUPLICATE ("usbd" ,"utmip-pad" ,NULL ),CLK_DUPLICATE ("usbd" ,"tegra-ehci.0" ,NULL ),CLK_DUPLICATE ("usbd" ,"tegra-otg" ,NULL ), -CLK_DUPLICATE ("2d" ,"tegra_grhost" ,"gr2d" ), +CLK_DUPLICATE ("2d" ,"gr2d" ,"gr2d" ),CLK_DUPLICATE ("3d" ,"tegra_grhost" ,"gr3d" ),CLK_DUPLICATE ("epp" ,"tegra_grhost" ,"epp" ), CLK_DUPLICATE("mpe", "tegra_grhost", "mpe"),
arch/arm/mach-tegra/tegra30_clocks_data.c +1 -0
@@ -1338,6 +1338,7 @@ struct clk_duplicate tegra_clk_duplicates[] = {CLK_DUPLICATE ("pll_p" ,"tegradc.0" ,"parent" ),CLK_DUPLICATE ("pll_p" ,"tegradc.1" ,"parent" ),CLK_DUPLICATE ("pll_d2_out0" ,"hdmi" ,"parent" ), + CLK_DUPLICATE("2d", "gr2d", "gr2d"), }; struct clk *tegra_ptr_clks[] = {
Signature · 1 line
1.7.9.5
PATCH v3 7/7 drm: tegra: Add gr2d device
In reply to Terje BergstromAdd client driver for 2D device.
--- drivers/gpu/drm/tegra/Makefile | 2 +- drivers/gpu/drm/tegra/drm.c | 211 +++++++++++++++++++++++++++- drivers/gpu/drm/tegra/drm.h | 29 ++++ drivers/gpu/drm/tegra/gr2d.c | 300 ++++++++++++++++++++++++++++++++++++++++ include/drm/tegra_drm.h | 111 +++++++++++++++ 5 files changed, 651 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/tegra/gr2d.c
drivers/gpu/drm/tegra/Makefile +1 -1
@@ -1,7 +1,7 @@ ccflags-y := -Iinclude/drm ccflags-$(CONFIG_DRM_TEGRA_DEBUG) += -DDEBUG -tegra-drm-y := drm.o fb.o dc.o +tegra-drm-y := drm.o fb.o dc.o gr2d.o tegra-drm-y += output.o rgb.o hdmi.o obj-$(CONFIG_DRM_TEGRA) += tegra-drm.o
drivers/gpu/drm/tegra/drm.c +210 -1
251 lines not on this page · raw message
drivers/gpu/drm/tegra/drm.h +29 -0
@@ -46,16 +46,44 @@ struct tegradrm {struct tegra_drm_client ; +struct tegra_drm_context { +struct tegra_drm_client *client; +struct host1x_channel *channel; +struct list_head list; +}; +struct tegra_drm_client_ops {int (*drm_init)(struct tegra_drm_client *,struct drm_device *);int (*drm_exit)(struct tegra_drm_client *); +int (*open_channel)(struct tegra_drm_client *, +struct tegra_drm_context *); +void (*close_channel)(struct tegra_drm_context *); +u32 (*get_syncpoint)(struct tegra_drm_context *,int index); +int (*submit)(struct tegra_drm_context *, +struct tegra_drm_submit_args *, +struct drm_device *, +struct drm_file *); +}; + + +struct tegra_drm_fpriv { +struct list_head contexts; }; +static inline struct tegra_drm_fpriv * +tegra_drm_fpriv (struct drm_file *file_priv) +{ +return file_priv ? file_priv->driver_priv :NULL ; +} +struct tegra_drm_client {struct device *dev;const struct tegra_drm_client_ops *ops; +u32 class; +struct host1x_channel *channel; +struct list_head list; };
@@ -221,6 +249,7 @@ extern void tegra_drm_fb_restore(struct drm_device *drm);extern struct platform_driver tegra_hdmi_driver;extern struct platform_driver tegra_dc_driver; +extern struct platform_driver tegra_gr2d_driver;extern struct drm_driver tegra_drm_driver;#endif /* TEGRA_DRM_H */
drivers/gpu/drm/tegra/gr2d.c new file +300 -0
300 lines not on this page · raw message
include/drm/tegra_drm.h +111 -0
115 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Hi Terje,
Am Donnerstag, den 13.12.2012, 16:04 +0200 schrieb Terje Bergstrom:
Quoted 13 lines
This set of patches adds support for Tegra20 and Tegra30 host1x and 2D. It is based on linux-next.
The third version has too many changes to list all of them. Here are highlights:
* Renamed to host1x, and moved todrivers/gpu/host1x
* Greatly simplified the inner workings between physical and logical driver
* Does not use AUXDATA for passing data to driver
* Runtime power management removed - will replace with runtime PM later
* IOCTLs padded and use __64 for passing pointers
* DMABUF support removed, replaced with GEM CMA support
You are still doing the allocation the IMHO wrong way around. I thought we agreed to do all the allocations in host1x, which obviously means not using the cma_gem_helpers anymore, but introducing a new native host1x object to back GEM/V4L/whatever objects. IMHO the current approach is a clear layering violation and makes proper IOMMU support a lot harder. It would also allow to get rid of all the indirections and ifdefs in host1x memmgr, as host1x would only have to deal with it's native objects.
All the complexity of converting host1x to GEM objects should be located in tegradrm and not be scattered between different modules.
Did you leave this out on purpose in this version of the patchset?
Quoted 7 lines
* host1x driver validates command streams and copies them to kernel owned buffer
* Generic interrupt support removed - only syncpt irq remains
* Sync points are allocated now dynamically
* IO register space handling rewritten to use helper functions
* Other numerous fixes and simplifications to code
Quoted 9 lines
Some of the issues left open:
* Register definitions still use static inline. There has been a debate about code style versus ability to use compiler type checking and code coverage analysis. There was no conclusion, so I left it as was.
* tegradrm has a global variable. Plan was to hide that behind a virtual device, and use that as DRM root device. That plan went bad once the FB CMA helper used the device for trying to allocate memory.
See above, we should get rid of the helpers and do all allocations within host1x.
Regards,
Lucas
Quoted 8 lines · Lucas Stach
You are still doing the allocation the IMHO wrong way around. I thought we agreed to do all the allocations in host1x, which obviously means not using the
cma_gem_helpersanymore, but introducing a new native host1x object to back GEM/V4L/whatever objects. IMHO the current approach is a clear layering violation and makes proper IOMMU support a lot harder. It would also allow to get rid of all the indirections and ifdefs in host1x memmgr, as host1x would only have to deal with it's native objects.
Quoted 4 lines
All the complexity of converting host1x to GEM objects should be located in tegradrm and not be scattered between different modules.
Did you leave this out on purpose in this version of the patchset?
Forgot to mention that, as IOMMU and consequently the "proper" allocation support was planned as a follow-up. I wanted to keep the scope of this set as small as possible.
The plan we agreed on still holds.
Terje
Quoted 6 lines
Quoted 4 lines
* tegradrm has a global variable. Plan was to hide that behind a virtual device, and use that as DRM root device. That plan went bad once the FB CMA helper used the device for trying to allocate memory.
See above, we should get rid of the helpers and do all allocations within host1x.
I noticed that IOMMU and not using the CMA FB helper is now exynos managed to do this.
Terje