diff options
author | Gordon Ross <gordon.w.ross@gmail.com> | 2017-04-22 13:04:07 -0400 |
---|---|---|
committer | Gordon Ross <gordon.w.ross@gmail.com> | 2017-04-23 21:47:32 -0400 |
commit | 8f53f39d7b3b29e37ddb926cc6beb426c4e61a37 (patch) | |
tree | 69d068536e2f9b2c6b188619c6fe567300fdf514 | |
parent | e49fc716c30eed65a727e91bbccacaf8745743df (diff) | |
download | illumos-gfx-drm-8f53f39d7b3b29e37ddb926cc6beb426c4e61a37.tar.gz |
8096 Want libdrm-2.4.75
Reviewed by: Ken Mays <maybird1776@yahoo.com>
Reviewed by: Aurélien Larcher <aurelien.larcher@gmail.com>
22 files changed, 582 insertions, 628 deletions
diff --git a/usr/src/Makefile.master b/usr/src/Makefile.master index bdffa0a..fb862de 100644 --- a/usr/src/Makefile.master +++ b/usr/src/Makefile.master @@ -367,8 +367,9 @@ XESS= -xs XSTRCONST= -xstrconst # -# turn warnings into errors (C) -CERRWARN = -errtags=yes -errwarn=%all +# illumos gate would turn warnings into errors (C) here. +# In this gate, we do that only in usr/src/uts +CERRWARN = -errtags=yes # -errwarn=%all CERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT CERRWARN += -erroff=E_STATEMENT_NOT_REACHED diff --git a/usr/src/cmd/drm-tests/Run_all.sh b/usr/src/cmd/drm-tests/Run_all.sh index 6bc01b2..5239766 100644 --- a/usr/src/cmd/drm-tests/Run_all.sh +++ b/usr/src/cmd/drm-tests/Run_all.sh @@ -31,14 +31,7 @@ # Leaving out random (takes a while) # Also updatedraw (broken at the moment) -TESTS="dristat drmdevice drmstat - drmsl hash - openclose - getversion - getclient - getstats - setversion - name_from_fd" +TESTS="drmdevice dristat drmstat drmsl hash" run_all() { for f in $TESTS ; do diff --git a/usr/src/cmd/drm-tests/misc1/Makefile.com b/usr/src/cmd/drm-tests/misc1/Makefile.com index 3c1ec06..635e1f3 100644 --- a/usr/src/cmd/drm-tests/misc1/Makefile.com +++ b/usr/src/cmd/drm-tests/misc1/Makefile.com @@ -14,12 +14,10 @@ # PROG= \ - dristat \ - drmdevice \ - drmstat \ drmsl \ hash \ - random + random \ + drmdevice include ../../Makefile.drm diff --git a/usr/src/cmd/drm-tests/misc1/amd64/Makefile b/usr/src/cmd/drm-tests/misc1/amd64/Makefile index b18f446..f0a0a87 100644 --- a/usr/src/cmd/drm-tests/misc1/amd64/Makefile +++ b/usr/src/cmd/drm-tests/misc1/amd64/Makefile @@ -1,4 +1,4 @@ include ../Makefile.com include $(SRC)/cmd/Makefile.cmd.64 -install: all $(ROOTCMD64) +install: $(ROOTCMD64) diff --git a/usr/src/cmd/drm-tests/misc1/i386/Makefile b/usr/src/cmd/drm-tests/misc1/i386/Makefile index 197a49e..e3aabe8 100644 --- a/usr/src/cmd/drm-tests/misc1/i386/Makefile +++ b/usr/src/cmd/drm-tests/misc1/i386/Makefile @@ -1,3 +1,3 @@ include ../Makefile.com -install: all $(ROOTCMD) +install: $(ROOTCMD) diff --git a/usr/src/cmd/drm-tests/misc2/Makefile.com b/usr/src/cmd/drm-tests/misc2/Makefile.com index a6a24dd..d715175 100644 --- a/usr/src/cmd/drm-tests/misc2/Makefile.com +++ b/usr/src/cmd/drm-tests/misc2/Makefile.com @@ -14,18 +14,8 @@ # PROG= \ - openclose \ - getversion \ - getclient \ - getstats \ - setversion \ - updatedraw \ - name_from_fd \ getsundev -# All programs here require this devinfo object. -DEVOBJ=drmtest_sun.o - include ../../Makefile.drm SRCDIR= $(LIBDRM_CMN_DIR)/tests @@ -45,17 +35,17 @@ all: $(PROG) lint: clean: - $(RM) $(PROG:%=%.o) $(DEVOBJ) + $(RM) $(PROG:%=%.o) -% : $(SRCDIR)/%.c $(DEVOBJ) +% : $(SRCDIR)/%.c $(COMPILE.c) -o $@.o $< - $(LINK.c) -o $@ $@.o $(DEVOBJ) $(LDLIBS) + $(LINK.c) -o $@ $@.o $(LDLIBS) %.o : ../common/%.c $(COMPILE.c) -o $@ -c $< getsundev : getsundev.o - $(LINK.c) -o $@ $@.o $(DEVOBJ) $(LDLIBS) + $(LINK.c) -o $@ $@.o $(LDLIBS) .KEEP_STATE: diff --git a/usr/src/cmd/drm-tests/misc2/amd64/Makefile b/usr/src/cmd/drm-tests/misc2/amd64/Makefile index 2f29a7f..a4564e8 100644 --- a/usr/src/cmd/drm-tests/misc2/amd64/Makefile +++ b/usr/src/cmd/drm-tests/misc2/amd64/Makefile @@ -3,4 +3,4 @@ include $(SRC)/cmd/Makefile.cmd.64 LDLIBS += $(LDLIBS64) -install: all $(ROOTCMD64) +install: $(ROOTCMD64) diff --git a/usr/src/cmd/drm-tests/misc2/common/drmtest_sun.c b/usr/src/cmd/drm-tests/misc2/common/drmtest_sun.c deleted file mode 100644 index caf5d31..0000000 --- a/usr/src/cmd/drm-tests/misc2/common/drmtest_sun.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright © 2007 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - * Authors: - * Eric Anholt <eric@anholt.net> - * - */ - -/* - * Copyright 2016 Gordon W. Ross - */ - -/* - * Helper functions for libdrm/tests. See: - * drm_open_any() - * getclient.c - * getstats.c - * getversion.c - * openclose.c - * drm_open_any_master() - * setversion.c - * updatedraw.c - * - * This module replaces libdrm/tests/drmtest.c - * which needs the linux "udev" interfaces. - * Here we use libdevinfo.h instead via these - * private interfaces in libdrm: - * _sun_drm_find_device() - * _sun_drm_get_pci_info() - */ - -#include <string.h> -#include <fcntl.h> -#include <fnmatch.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include "drmtest.h" - -#include <libdevinfo.h> - -static int is_master(int fd) -{ - drm_client_t client; - int ret; - - /* Check that we're the only opener and authed. */ - client.idx = 0; - ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client); - assert (ret == 0); - if (!client.auth) - return 0; - client.idx = 1; - ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client); - if (ret != -1 || errno != EINVAL) - return 0; - - return 1; -} - -/* - * Open the first DRM device matching the criteria - */ -int drm_open_matching(const char *pci_glob, int flags) -{ - char *path = NULL; - int i, ret; - int fd = -1; - - /* - * If our glob patter matches all, let's skip - * getting the PCI info etc. - */ - if (strcmp(pci_glob, "*:*") == 0) - pci_glob = NULL; - - /* Could also start at the offset for some device type. */ - for (i = 0; i < DRM_MAX_MINOR; i++) { - free(path); - ret = _sun_drm_find_device(i, &path); - if (ret != 0) - continue; - - if (pci_glob != NULL) { - drmPciDeviceInfo pcii; - char pci_str[32]; - ret = _sun_drm_get_pci_info(path, &pcii); - if (ret != 0) - continue; - snprintf(pci_str, sizeof (pci_str), - "%x:%x", pcii.vendor_id, pcii.device_id); - if (fnmatch(pci_glob, pci_str, 0) != 0) - continue; - } - - fd = open(path, O_RDWR); - if (fd < 0) - continue; - - if ((flags & DRM_TEST_MASTER) && !is_master(fd)) { - close(fd); - fd = -1; - continue; - } - - break; - } - - free(path); - - return fd; -} - -int drm_open_any(void) -{ - int fd = drm_open_matching("*:*", 0); - - if (fd < 0) { - fprintf(stderr, "failed to open any drm device\n"); - exit(0); - } - - return fd; -} - -/** - * Open the first DRM device we can find where we end up being the master. - */ -int drm_open_any_master(void) -{ - int fd = drm_open_matching("*:*", DRM_TEST_MASTER); - - if (fd < 0) { - fprintf(stderr, "failed to open any drm device\n"); - exit(0); - } - - return fd; - -} diff --git a/usr/src/cmd/drm-tests/misc2/common/getsundev.c b/usr/src/cmd/drm-tests/misc2/common/getsundev.c index 12be92f..a948b97 100644 --- a/usr/src/cmd/drm-tests/misc2/common/getsundev.c +++ b/usr/src/cmd/drm-tests/misc2/common/getsundev.c @@ -43,7 +43,8 @@ #include "xf86drm.h" -int main(int argc, char **argv) +int +main(int argc, char **argv) { drmPciBusInfo pci_bus; drmPciDeviceInfo pci_dev; @@ -68,39 +69,32 @@ int main(int argc, char **argv) printf("Found device: %s\n", path); } - ret = _sun_drmParseSubsystemType(maj, min); - if (ret != DRM_BUS_PCI) { - printf("FAIL: _sun_drmParseSubsystemType(%d, %d) -> %d\n", - maj, min, ret); - failures++; - } - - ret = _sun_drmParsePciBusInfo(maj, min, &pci_bus); + ret = _sun_drm_get_pci_bus_info(path, &pci_bus); if (ret) { - printf("FAIL: _sun_drmParsePciBusInfo(%d, %d, &) -> %d\n", - maj, min, ret); + printf("FAIL: _sun_drm_get_pci_bus_info(%d, %d, &) -> %d\n", + maj, min, ret); failures++; } else { printf("PCI bus info: dom=%d bus=%d dev=%d func=%d\n", - pci_bus.domain, - pci_bus.bus, - pci_bus.dev, - pci_bus.func); + pci_bus.domain, + pci_bus.bus, + pci_bus.dev, + pci_bus.func); } - ret = _sun_drmParsePciDeviceInfo(path, &pci_dev); + ret = _sun_drm_get_pci_dev_info(path, &pci_dev); if (ret) { - printf("FAIL: _sun_drmParsePciDeviceInfo(\"%s\", &) -> %d\n", - path, ret); + printf("FAIL: _sun_drm_get_pci_dev_info(\"%s\", &) -> %d\n", + path, ret); failures++; } else { printf("PCI device info: ven=%x dev=%x " - "subven=%x subdev=%x rev=%x\n", - pci_dev.vendor_id, - pci_dev.device_id, - pci_dev.subvendor_id, - pci_dev.subdevice_id, - pci_dev.revision_id); + "subven=%x subdev=%x rev=%x\n", + pci_dev.vendor_id, + pci_dev.device_id, + pci_dev.subvendor_id, + pci_dev.subdevice_id, + pci_dev.revision_id); } fd = open(path, O_RDWR); @@ -110,7 +104,7 @@ int main(int argc, char **argv) return (1); } - path2 = _sun_drmGetMinorNameForFD(fd, 0); + path2 = drmGetPrimaryDeviceNameFromFd(fd); if (path2 == NULL) { ret = errno; printf("FAIL: open(%s) -> %d\n", path, ret); diff --git a/usr/src/cmd/drm-tests/misc2/i386/Makefile b/usr/src/cmd/drm-tests/misc2/i386/Makefile index e72ca97..8158a7d 100644 --- a/usr/src/cmd/drm-tests/misc2/i386/Makefile +++ b/usr/src/cmd/drm-tests/misc2/i386/Makefile @@ -2,4 +2,4 @@ include ../Makefile.com LDLIBS += $(LDLIBS32) -install: all $(ROOTCMD) +install: $(ROOTCMD) diff --git a/usr/src/common/libdrm/Check-patches b/usr/src/common/libdrm/Check-patches index 89f2ba2..02a212e 100644 --- a/usr/src/common/libdrm/Check-patches +++ b/usr/src/common/libdrm/Check-patches @@ -52,8 +52,8 @@ # One big patch might be easier than all this... # but for now the patches are split up as shown below. -ref=libdrm-2.4.74-ref -dir=libdrm-2.4.74 +ref=libdrm-2.4.75-ref +dir=libdrm-2.4.75 # You make this directory by hand. Not doing this automatically # because I want to make srue you to know it's being written into. diff --git a/usr/src/common/libdrm/Makefile b/usr/src/common/libdrm/Makefile index 79af234..d34093d 100644 --- a/usr/src/common/libdrm/Makefile +++ b/usr/src/common/libdrm/Makefile @@ -21,13 +21,14 @@ include $(SRC)/Makefile.master FETCH= $(SRC)/tools/userland-fetch -# See also: ./Makefile.drm LIBDRM_VERS -LIBDRM_VERS=2.4.74 +# See also: ./Makefile.drm LIBDRM_VERS and ./Check-patches +# PLEASE RUN Check-patches after updating! +LIBDRM_VERS=2.4.75 LIBDRM_DIR=libdrm-$(LIBDRM_VERS) LIBDRM_ARCHIVE=$(LIBDRM_DIR).tar.bz2 LIBDRM_URL=http://dri.freedesktop.org/libdrm/$(LIBDRM_ARCHIVE) -LIBDRM_HASH=sha256:d80dd5a76c401f4c8756dcccd999c63d7e0a3bad258d96a829055cfd86ef840b +LIBDRM_HASH=sha256:2d5a500eef412cc287d12268eed79d571e262d4957a2ec9258073f305985054f def all install install_h: .patched check diff --git a/usr/src/common/libdrm/Makefile.drm b/usr/src/common/libdrm/Makefile.drm index 6631c6d..0afa6ce 100644 --- a/usr/src/common/libdrm/Makefile.drm +++ b/usr/src/common/libdrm/Makefile.drm @@ -16,7 +16,7 @@ # This make include is used in $SRC/lib/libdrm/* # # See also: ./Makefile LIBDRM_VERS, ./Check-patches -LIBDRM_VERS=2.4.74 +LIBDRM_VERS=2.4.75 LIBDRM_CMN_DIR=$(SRC)/common/libdrm/libdrm-$(LIBDRM_VERS) diff --git a/usr/src/common/libdrm/patches/incl-drm-i915-drm-h.patch b/usr/src/common/libdrm/patches/incl-drm-i915-drm-h.patch index 42aa184..8c65353 100644 --- a/usr/src/common/libdrm/patches/incl-drm-i915-drm-h.patch +++ b/usr/src/common/libdrm/patches/incl-drm-i915-drm-h.patch @@ -25,10 +25,10 @@ # or other dealings in this Software without prior written authorization # of the copyright holder. -diff ... b/include/drm/i915_drm.h ---- a/include/drm/i915_drm.h -+++ b/include/drm/i915_drm.h -@@ -100,6 +100,7 @@ +diff ... libdrm-2.4.75/include/drm/i915_drm.h +--- libdrm-2.4.75-ref/include/drm/i915_drm.h Fri Jan 27 20:15:16 2017 ++++ libdrm-2.4.75/include/drm/i915_drm.h Fri Apr 21 21:31:17 2017 +@@ -128,6 +128,7 @@ int pf_current_page; /* which buffer is being displayed? */ int perf_boxes; /* performance boxes to be displayed */ int width, height; /* screen size in pixels */ @@ -36,7 +36,7 @@ diff ... b/include/drm/i915_drm.h drm_handle_t front_handle; int front_offset; -@@ -139,6 +140,8 @@ +@@ -167,6 +168,8 @@ int pipeB_w; int pipeB_h; @@ -45,7 +45,7 @@ diff ... b/include/drm/i915_drm.h /* fill out some space for old userspace triple buffer */ drm_handle_t unused_handle; __u32 unused1, unused2, unused3; -@@ -235,11 +238,14 @@ +@@ -265,11 +268,14 @@ #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) #define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP) #define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t) @@ -63,7 +63,7 @@ diff ... b/include/drm/i915_drm.h #define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t) #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t) #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t) -@@ -296,6 +302,15 @@ +@@ -328,6 +334,15 @@ struct drm_clip_rect *cliprects; /* pointer to userspace cliprects */ } drm_i915_batchbuffer_t; @@ -79,7 +79,7 @@ diff ... b/include/drm/i915_drm.h /* As above, but pass a pointer to userspace buffer which can be * validated by the kernel prior to sending to hardware. */ -@@ -308,6 +323,15 @@ +@@ -340,6 +355,15 @@ struct drm_clip_rect *cliprects; /* pointer to userspace cliprects */ } drm_i915_cmdbuffer_t; @@ -95,7 +95,7 @@ diff ... b/include/drm/i915_drm.h /* Userspace can request & wait on irq's: */ typedef struct drm_i915_irq_emit { -@@ -314,6 +338,10 @@ +@@ -346,6 +370,10 @@ int *irq_seq; } drm_i915_irq_emit_t; @@ -106,7 +106,7 @@ diff ... b/include/drm/i915_drm.h typedef struct drm_i915_irq_wait { int irq_seq; } drm_i915_irq_wait_t; -@@ -369,6 +397,11 @@ +@@ -421,6 +449,11 @@ int *value; } drm_i915_getparam_t; @@ -118,7 +118,7 @@ diff ... b/include/drm/i915_drm.h /* Ioctl to set kernel params: */ #define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1 -@@ -392,6 +425,13 @@ +@@ -444,6 +477,13 @@ int *region_offset; /* offset from start of fb or agp */ } drm_i915_mem_alloc_t; diff --git a/usr/src/common/libdrm/patches/intel-drm.patch b/usr/src/common/libdrm/patches/intel-drm.patch index 47fa4d3..1124cc3 100644 --- a/usr/src/common/libdrm/patches/intel-drm.patch +++ b/usr/src/common/libdrm/patches/intel-drm.patch @@ -1,7 +1,7 @@ -diff ... libdrm-2.4.74/intel/intel_bufmgr_gem.c ---- libdrm-2.4.74-ref/intel/intel_bufmgr_gem.c Tue Nov 29 06:15:10 2016 -+++ libdrm-2.4.74/intel/intel_bufmgr_gem.c Sat Dec 31 18:30:23 2016 -@@ -3363,6 +3363,16 @@ +diff ... libdrm-2.4.75/intel/intel_bufmgr_gem.c +--- libdrm-2.4.75-ref/intel/intel_bufmgr_gem.c Fri Jan 27 20:15:16 2017 ++++ libdrm-2.4.75/intel/intel_bufmgr_gem.c Fri Apr 21 21:31:17 2017 +@@ -3445,6 +3445,16 @@ static pthread_mutex_t bufmgr_list_mutex = PTHREAD_MUTEX_INITIALIZER; static drmMMListHead bufmgr_list = { &bufmgr_list, &bufmgr_list }; @@ -18,7 +18,7 @@ diff ... libdrm-2.4.74/intel/intel_bufmgr_gem.c static drm_intel_bufmgr_gem * drm_intel_bufmgr_gem_find(int fd) { -@@ -3369,7 +3379,8 @@ +@@ -3451,7 +3461,8 @@ drm_intel_bufmgr_gem *bufmgr_gem; DRMLISTFOREACHENTRY(bufmgr_gem, &bufmgr_list, managers) { @@ -28,9 +28,9 @@ diff ... libdrm-2.4.74/intel/intel_bufmgr_gem.c atomic_inc(&bufmgr_gem->refcount); return bufmgr_gem; } -diff ... libdrm-2.4.74/intel/intel_decode.c ---- libdrm-2.4.74-ref/intel/intel_decode.c Tue Nov 29 06:15:10 2016 -+++ libdrm-2.4.74/intel/intel_decode.c Sat Dec 31 18:30:23 2016 +diff ... libdrm-2.4.75/intel/intel_decode.c +--- libdrm-2.4.75-ref/intel/intel_decode.c Mon Dec 12 21:45:20 2016 ++++ libdrm-2.4.75/intel/intel_decode.c Fri Apr 21 21:31:17 2017 @@ -402,6 +402,7 @@ format = "1555"; break; diff --git a/usr/src/common/libdrm/patches/xf86drm-c.patch b/usr/src/common/libdrm/patches/xf86drm-c.patch index 93dcd86..87dffc9 100644 --- a/usr/src/common/libdrm/patches/xf86drm-c.patch +++ b/usr/src/common/libdrm/patches/xf86drm-c.patch @@ -1,6 +1,6 @@ -diff ... libdrm-2.4.74/xf86drm.c ---- libdrm-2.4.74-ref/xf86drm.c Tue Nov 29 06:15:10 2016 -+++ libdrm-2.4.74/xf86drm.c Sat Dec 31 19:13:57 2016 +diff ... libdrm-2.4.75/xf86drm.c +--- libdrm-2.4.75-ref/xf86drm.c Fri Jan 27 20:15:16 2017 ++++ libdrm-2.4.75/xf86drm.c Sat Apr 22 13:29:51 2017 @@ -98,6 +98,11 @@ #endif #endif /* __OpenBSD__ */ @@ -13,7 +13,7 @@ diff ... libdrm-2.4.74/xf86drm.c #ifndef DRM_MAJOR #define DRM_MAJOR 226 /* Linux */ #endif -@@ -349,9 +354,14 @@ +@@ -365,9 +370,14 @@ if (stat(DRM_DIR_NAME, &st)) { if (!isroot) return DRM_ERR_NOT_ROOT; @@ -28,7 +28,7 @@ diff ... libdrm-2.4.74/xf86drm.c } /* Check if the device node exists and create it if necessary. */ -@@ -358,8 +368,13 @@ +@@ -374,8 +384,13 @@ if (stat(buf, &st)) { if (!isroot) return DRM_ERR_NOT_ROOT; @@ -42,7 +42,7 @@ diff ... libdrm-2.4.74/xf86drm.c } if (drm_server_info && drm_server_info->get_perms) { -@@ -405,6 +420,10 @@ +@@ -421,6 +436,10 @@ if (st.st_rdev != dev) { if (!isroot) return DRM_ERR_NOT_ROOT; @@ -53,7 +53,7 @@ diff ... libdrm-2.4.74/xf86drm.c remove(buf); mknod(buf, S_IFCHR | devmode, dev); if (drm_server_info && drm_server_info->get_perms) { -@@ -411,6 +430,7 @@ +@@ -427,6 +446,7 @@ chown_check_return(buf, user, group); chmod(buf, devmode); } @@ -61,7 +61,7 @@ diff ... libdrm-2.4.74/xf86drm.c } fd = open(buf, O_RDWR, 0); drmMsg("drmOpenDevice: open result is %d, (%s)\n", -@@ -532,6 +552,7 @@ +@@ -548,6 +568,7 @@ } } @@ -69,7 +69,7 @@ diff ... libdrm-2.4.74/xf86drm.c static const char *drmGetMinorName(int type) { switch (type) { -@@ -545,6 +566,7 @@ +@@ -561,6 +582,7 @@ return NULL; } } @@ -77,7 +77,7 @@ diff ... libdrm-2.4.74/xf86drm.c /** * Open the device by bus ID. -@@ -1108,7 +1130,7 @@ +@@ -1124,7 +1146,7 @@ drm_map_t map; memclear(map); @@ -86,7 +86,7 @@ diff ... libdrm-2.4.74/xf86drm.c if(drmIoctl(fd, DRM_IOCTL_RM_MAP, &map)) return -errno; -@@ -2696,6 +2718,15 @@ +@@ -2712,6 +2734,15 @@ fstat(fd, &sbuf); d = sbuf.st_rdev; @@ -102,82 +102,94 @@ diff ... libdrm-2.4.74/xf86drm.c for (i = 0; i < DRM_MAX_MINOR; i++) { snprintf(name, sizeof name, DRM_DEV_NAME, DRM_DIR_NAME, i); if (stat(name, &sbuf) == 0 && sbuf.st_rdev == d) -@@ -2761,6 +2792,10 @@ - return 0; - } - -+#ifdef __sun /* OS-dependent */ -+#define drmGetMinorNameForFD(fd, t) \ -+ _sun_drmGetMinorNameForFD(fd, t) -+#else /* __sun */ - static char *drmGetMinorNameForFD(int fd, int type) - { - #ifdef __linux__ -@@ -2822,6 +2857,7 @@ - #endif - return NULL; - } -+#endif /* __sun */ - - char *drmGetPrimaryDeviceNameFromFd(int fd) - { -@@ -2833,6 +2869,10 @@ - return drmGetMinorNameForFD(fd, DRM_NODE_RENDER); - } - -+#ifdef __sun /* OS-dependent */ -+#define drmParseSubsystemType(ma, mi) \ -+ _sun_drmParseSubsystemType(ma, mi) -+#else /* __sun */ - static int drmParseSubsystemType(int maj, int min) - { - #ifdef __linux__ -@@ -2859,7 +2899,12 @@ +@@ -2833,6 +2864,25 @@ + + out_close_dir: + closedir(sysdir); ++#elif defined(__sun) /* illumos, OSol */ ++ struct stat sbuf; ++ char *path = NULL; ++ int err, maj, min; ++ ++ if (fstat(fd, &sbuf)) ++ return (NULL); ++ ++ maj = major(sbuf.st_rdev); ++ min = minor(sbuf.st_rdev); ++ ++ if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) ++ return (NULL); ++ ++ /* Walk devices tree looking for this minor */ ++ err = _sun_drm_find_device(min, &path); ++ if (err == 0) ++ return (path); ++ /* else ... (ret NULL at endif) */ + #else + struct stat sbuf; + char buf[PATH_MAX + 1]; +@@ -2962,6 +3012,20 @@ return -EINVAL; - #endif - } -+#endif /* __sun */ - -+#ifdef __sun /* OS-dependent */ -+#define drmParsePciBusInfo(ma, mi, inf) \ -+ _sun_drmParsePciBusInfo(ma, mi, inf) -+#else /* __sun */ - static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) - { - #ifdef __linux__ -@@ -2901,6 +2946,7 @@ + #elif defined(__OpenBSD__) + return DRM_BUS_PCI; ++#elif defined(__sun) /* illumos, OSol */ ++ char *path = NULL; ++ int ret; ++ ++ if (maj != DRM_MAJOR) ++ return -EINVAL; ++ ++ ret = _sun_drm_find_device(min, &path); ++ if (ret != 0) ++ return (ret); ++ ++ ret = _sun_drm_get_subsystem(path); ++ free(path); ++ return (ret); + #else + #warning "Missing implementation of drmParseSubsystemType" return -EINVAL; - #endif - } -+#endif /* __sun */ - - static int drmCompareBusInfo(drmDevicePtr a, drmDevicePtr b) - { -@@ -2946,6 +2992,10 @@ - 3 /* length of the node number */; - } +@@ -3017,6 +3081,21 @@ + info->func = pinfo.func; -+#ifdef __sun /* OS-dependent */ -+#define drmParsePciDeviceInfo(name, dip) \ -+ _sun_drmParsePciDeviceInfo(name, dip) -+#else /* __sun */ - static int drmParsePciDeviceInfo(const char *d_name, - drmPciDeviceInfoPtr device) - { -@@ -2976,6 +3026,7 @@ + return 0; ++#elif defined(__sun) /* illumos, OSol */ ++ char *path = NULL; ++ int err; ++ ++ if (maj != DRM_MAJOR) ++ return -EINVAL; ++ ++ err = _sun_drm_find_device(min, &path); ++ if (err != 0) ++ return (err); ++ ++ err = _sun_drm_get_pci_bus_info(path, info); ++ free(path); ++ ++ return err; + #else + #warning "Missing implementation of drmParsePciBusInfo" return -EINVAL; - #endif - } -+#endif /* __sun */ - - void drmFreeDevice(drmDevicePtr *device) - { -@@ -3349,6 +3400,8 @@ +@@ -3182,6 +3261,21 @@ + device->subdevice_id = pinfo.subdevice_id; - fclose(f); - return device_name; -+#elif defined(__sun) -+ return(_sun_drmGetMinorNameForFD(fd, -1)); + return 0; ++#elif defined(__sun) /* illumos, OSol */ ++ char *path = NULL; ++ int err; ++ ++ if (maj != DRM_MAJOR) ++ return -EINVAL; ++ ++ err = _sun_drm_find_device(min, &path); ++ if (err != 0) ++ return (err); ++ ++ err = _sun_drm_get_pci_dev_info(path, device); ++ free(path); ++ ++ return err; #else - #warning "Missing implementation of drmGetDeviceNameFromFd2" - return NULL; + #warning "Missing implementation of drmParsePciDeviceInfo" + return -EINVAL; diff --git a/usr/src/common/libdrm/patches/xf86drm-h.patch b/usr/src/common/libdrm/patches/xf86drm-h.patch index 3bba940..443439d 100644 --- a/usr/src/common/libdrm/patches/xf86drm-h.patch +++ b/usr/src/common/libdrm/patches/xf86drm-h.patch @@ -25,9 +25,9 @@ # or other dealings in this Software without prior written authorization # of the copyright holder. -diff ... libdrm-2.4.74/xf86drm.h ---- libdrm-2.4.74-ref/xf86drm.h Tue Nov 29 06:15:10 2016 -+++ libdrm-2.4.74/xf86drm.h Sat Dec 31 19:13:17 2016 +diff ... libdrm-2.4.75/xf86drm.h +--- libdrm-2.4.75-ref/xf86drm.h Fri Jan 27 20:15:16 2017 ++++ libdrm-2.4.75/xf86drm.h Sat Apr 22 12:58:07 2017 @@ -472,6 +472,17 @@ #endif /* architecture */ #endif /* __GNUC__ >= 2 */ @@ -46,19 +46,16 @@ diff ... libdrm-2.4.74/xf86drm.h #ifndef DRM_CAS #define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */ #endif -@@ -801,6 +812,17 @@ - extern int drmGetDevices(drmDevicePtr devices[], int max_devices); - extern void drmFreeDevices(drmDevicePtr devices[], int count); +@@ -844,6 +855,14 @@ + extern int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device); + extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_devices); +#ifdef __sun +extern int _sun_drm_get_major(void); -+extern char * _sun_drmGetMinorNameForFD(int fd, int type); -+extern int _sun_drmParseSubsystemType(int maj, int min); -+extern int _sun_drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info); -+extern int _sun_drmParsePciDeviceInfo(const char *d_name, -+ drmPciDeviceInfoPtr device); +extern int _sun_drm_find_device(int min, char **pathp); -+extern int _sun_drm_get_pci_info(char *path, drmPciDeviceInfo *pcii); ++extern int _sun_drm_get_subsystem(char *path); ++extern int _sun_drm_get_pci_bus_info(char *path, drmPciBusInfo *bus); ++extern int _sun_drm_get_pci_dev_info(char *path, drmPciDeviceInfo *dev); +#endif /* __sun */ + #if defined(__cplusplus) diff --git a/usr/src/lib/libdrm/Makefile.com b/usr/src/lib/libdrm/Makefile.com index c8aa409..708e32f 100644 --- a/usr/src/lib/libdrm/Makefile.com +++ b/usr/src/lib/libdrm/Makefile.com @@ -31,7 +31,7 @@ VERS= .2 # See common/libdrm/libdrm-*/Makefile.in am__objects OBJECTS= xf86drm.o xf86drmHash.o \ xf86drmRandom.o xf86drmSL.o xf86drmMode.o \ - sun_xf86drm.o sun_devinfo.o + sun_devinfo.o include ../../Makefile.lib include $(SRC)/common/libdrm/Makefile.drm diff --git a/usr/src/lib/libdrm/common/sun_devinfo.c b/usr/src/lib/libdrm/common/sun_devinfo.c index 9509b73..67ae462 100644 --- a/usr/src/lib/libdrm/common/sun_devinfo.c +++ b/usr/src/lib/libdrm/common/sun_devinfo.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ /* - * Copyright 2016 Gordon W. Ross + * Copyright 2017 Gordon W. Ross */ /* @@ -81,70 +81,42 @@ struct search_args { int s_minor; }; -static int find_dev(di_node_t, void *); -static int find_minor(di_node_t, di_minor_t, struct search_args *); - static int _sun_drm_major; /* cache */ -int _sun_drm_get_major(void) +/* + * Search callback function called for each minor node under + * some device that was found to be of possible interest. + * Return non-zero if match found. + */ +static int +find_minor(di_node_t node, di_minor_t minor, struct search_args *sargs) { - struct stat sbuf; - dev_t dev = 0; - char *path; - int i, ret; + char *path; + dev_t devt; + int ret; - if (_sun_drm_major != 0) - return (_sun_drm_major); + devt = di_minor_devt(minor); - for (i = 0; i < DRM_MAX_MINOR; i++) { - ret = _sun_drm_find_device(i, &path); - if (ret != 0) - continue; - ret = stat(path, &sbuf); - free(path); - if (ret != 0) - continue; - if (!S_ISCHR(sbuf.st_mode)) - continue; - dev = major(sbuf.st_rdev); - if (dev != 0) { - _sun_drm_major = dev; - return (dev); - } - } + /* Does the caller want a specific minor number? */ + if (sargs->s_minor >= 0 && + sargs->s_minor != minor(devt)) + return (0); /* - * No devices found? No way to return errors here, - * so just return an impossible value, and let - * later calls like open fail. + * get device minor node path + * Note: allocates path */ - return (MAXMAJ32); -} - -int -_sun_drm_find_device(int min, char **pathp) -{ - struct search_args sargs; - di_node_t root_node; - - root_node = di_init("/", DINFOCPYALL); - if (root_node == DI_NODE_NIL) - return (-errno); - - memset(&sargs, 0, sizeof (sargs)); - - di_walk_node(root_node, DI_WALK_CLDFIRST, &sargs, find_dev); - di_fini(root_node); - - if (sargs.s_path == NULL) - return (-ENOENT); + if ((path = di_devfs_minor_path(minor)) == NULL) + return (0); + ret = asprintf(&sargs->s_path, "/devices%s", path); + di_devfs_path_free(path); - if (pathp != NULL) - *pathp = sargs.s_path; - else - free(sargs.s_path); + if (ret < 0) { + free(sargs->s_path); + return (0); + } - return (0); + return (1); } /* @@ -186,42 +158,134 @@ find_dev(di_node_t node, void *vargs) } /* - * Search function called for each minor node under some device - * that was found to be of likely interest above. - * Return non-zero if match found. + * Helper function for xf86drm.c + * drmGetMinorNameForFD() + * drmParseSubsystemType() + * drmParsePciBusInfo() + * drmParsePciDeviceInfo() + * + * Given a device minor number, find the /devices path. + * Returns malloc'ed memory at *pathp, caller frees. */ -static int -find_minor(di_node_t node, di_minor_t minor, struct search_args *sargs) +int +_sun_drm_find_device(int min, char **pathp) { - char *path; - dev_t devt; - int ret; + struct search_args sargs; + di_node_t root_node; - devt = di_minor_devt(minor); + root_node = di_init("/", DINFOCPYALL); + if (root_node == DI_NODE_NIL) + return (-errno); - /* Does the caller want a specific minor number? */ - if (sargs->s_minor >= 0 && - sargs->s_minor != minor(devt)) - return (0); + memset(&sargs, 0, sizeof (sargs)); + + di_walk_node(root_node, DI_WALK_CLDFIRST, &sargs, find_dev); + di_fini(root_node); + + if (sargs.s_path == NULL) + return (-ENOENT); + + if (pathp != NULL) + *pathp = sargs.s_path; + else + free(sargs.s_path); + + return (0); +} + +/* + * Helper function for DRM_MAJOR in xf86drm.c + * Return the major number assigned to the drm driver. + */ +int +_sun_drm_get_major(void) +{ + struct stat sbuf; + dev_t dev = 0; + char *path; + int i, ret; + + if (_sun_drm_major != 0) + return (_sun_drm_major); + + for (i = 0; i < DRM_MAX_MINOR; i++) { + ret = _sun_drm_find_device(i, &path); + if (ret != 0) + continue; + ret = stat(path, &sbuf); + free(path); + if (ret != 0) + continue; + if (!S_ISCHR(sbuf.st_mode)) + continue; + dev = major(sbuf.st_rdev); + if (dev != 0) { + _sun_drm_major = dev; + return (dev); + } + } /* - * get device minor node path - * Note: allocates path + * No devices found? No way to return errors here, + * so just return an impossible value, and let + * later calls like open fail. */ - if ((path = di_devfs_minor_path(minor)) == NULL) - return (0); - ret = asprintf(&sargs->s_path, "/devices%s", path); - di_devfs_path_free(path); + return (MAXMAJ32); +} - if (ret < 0) { - free(sargs->s_path); - return (0); - } +/* + * Helper function for drmParseSubsystemType() + * Returns one of: DRM_BUS_PCI, ... or -EINVAL. + * Our only driver implementations currently + * are on PCI. Others todo. + */ +int +_sun_drm_get_subsystem(char *path) +{ + char *p; + int err; + + p = path; + if (strncmp(p, "/devices/", 9) == 0) + p += 8; + if (strncmp(p, "/pci", 4) == 0) + err = DRM_BUS_PCI; + else + err = -EINVAL; - return (1); + return (err); } /* + * Helper function for drmParsePciBusInfo() + * + * Get PCI bus info for the give device path. + */ +int +_sun_drm_get_pci_bus_info(char *path, drmPciBusInfo *info) +{ + int n, bus, slot, unit; + + /* Skip the /devices prefix, if present. */ + if (strncmp(path, "/devices/", 9) == 0) + path += 8; /* the next slash */ + + n = sscanf(path, "/pci@%d,%d/display@%d:", + &bus, &slot, &unit); + if (n != 3) + return (-EINVAL); + + info->domain = 0; + info->bus = bus; + info->dev = slot; + info->func = unit; + + return (0); +} + +/* + * Helper function for drmParsePciDeviceInfo() + * * Get PCI data for the give device path. * * Note path given is a full minor under /devices i.e. @@ -230,7 +294,7 @@ find_minor(di_node_t node, di_minor_t minor, struct search_args *sargs) * /pci@0,0/display@2 */ int -_sun_drm_get_pci_info(char *path, drmPciDeviceInfo *pcii) +_sun_drm_get_pci_dev_info(char *path, drmPciDeviceInfo *pcii) { char pathbuf[MAXPATHLEN]; di_node_t node; @@ -252,35 +316,35 @@ _sun_drm_get_pci_info(char *path, drmPciDeviceInfo *pcii) */ node = di_init(pathbuf, DINFOCPYALL); if (node == DI_NODE_NIL) - return -EINVAL; + return (-EINVAL); /* * Get the various PCI properties. * Only the first two are required. */ - memset(pcii, 0, sizeof(*pcii)); + memset(pcii, 0, sizeof (*pcii)); if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, - "vendor-id", &propval) > 0) + "vendor-id", &propval) > 0) pcii->vendor_id = (uint16_t)*propval; else goto out; if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, - "device-id", &propval) > 0) + "device-id", &propval) > 0) pcii->device_id = (uint16_t)*propval; else goto out; if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, - "subsystem-vendor-id", &propval) > 0) + "subsystem-vendor-id", &propval) > 0) pcii->subvendor_id = (uint16_t)*propval; if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, - "subsystem-id", &propval) > 0) + "subsystem-id", &propval) > 0) pcii->subdevice_id = (uint16_t)*propval; if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, - "revision-id", &propval) > 0) + "revision-id", &propval) > 0) pcii->revision_id = (uint16_t)*propval; ret = 0; diff --git a/usr/src/lib/libdrm/common/sun_xf86drm.c b/usr/src/lib/libdrm/common/sun_xf86drm.c deleted file mode 100644 index 5387bce..0000000 --- a/usr/src/lib/libdrm/common/sun_xf86drm.c +++ /dev/null @@ -1,176 +0,0 @@ -/** - * \file xf86drm.c - * User-level interface to DRM device - * - * \author Rickard E. (Rik) Faith <faith@valinux.com> - * \author Kevin E. Martin <martin@valinux.com> - */ - -/* - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* - * OS-dependent versions of several functions found in: - * libdrm/xf86drm.c (mostly where those need "udev") - * Here we use libdevinfo.h instead via these - * private interfaces in libdrm: - * _sun_drm_find_device() - * _sun_drm_get_pci_info() - * - * See sun_devinfo.c - */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <stddef.h> -#include <fcntl.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/mkdev.h> - -#include "xf86drm.h" - -/* Device majors are dynamic. */ -#define DRM_MAJOR (_sun_drm_get_major()) - -char *_sun_drmGetMinorNameForFD(int fd, int type) -{ - char *path = NULL; - struct stat sbuf; - int err, maj, min; - - if (fstat(fd, &sbuf)) - return NULL; - - maj = major(sbuf.st_rdev); - min = minor(sbuf.st_rdev); - - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) - return NULL; - - /* Walk devices looking for this minor */ - err = _sun_drm_find_device(min, &path); - if (err != 0) - return (NULL); - - return (path); -} - -int _sun_drmParseSubsystemType(int maj, int min) -{ - char *path = NULL; - char *p; - int ret; - - if (maj != DRM_MAJOR) - return -EINVAL; - - ret = _sun_drm_find_device(min, &path); - if (ret != 0) - return (ret); - - p = path; - if (strncmp(p, "/devices", 8) == 0) - p += 8; - - if (strncmp(p, "/pci@", 5) == 0) - ret = DRM_BUS_PCI; - else - ret = -EINVAL; - free(path); - - return (ret); -} - -int _sun_drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) -{ - char *path = NULL; - int bus, slot, unit; - int n, ret; - - if (maj != DRM_MAJOR) - return -EINVAL; - - ret = _sun_drm_find_device(min, &path); - if (ret != 0) - return (ret); - - n = sscanf(path, "/devices/pci@%d,%d/display@%d:", - &bus, &slot, &unit); - free(path); - if (n != 3) - return -EINVAL; - - info->domain = 0; - info->bus = bus; - info->dev = slot; - info->func = unit; - - return 0; -} - -/* - * Given d_name as some name under /dev, - * find the /devices path and then get the - * PCI properties for that device. - */ -int _sun_drmParsePciDeviceInfo(const char *d_name, - drmPciDeviceInfo *pcii) -{ - struct stat sbuf; - int err, maj, min; - char dev_path[256]; - char *path = NULL; - - if (d_name[0] == '/') - strlcpy(dev_path, d_name, sizeof (dev_path)); - else - snprintf(dev_path, sizeof (dev_path), - DRM_DIR_NAME "/%s", d_name); - if (stat(dev_path, &sbuf)) - return -errno; - - maj = major(sbuf.st_rdev); - min = minor(sbuf.st_rdev); - if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) - return -EINVAL; - - /* Get the /devices path */ - err = _sun_drm_find_device(min, &path); - if (err != 0) - return err; - - err = _sun_drm_get_pci_info(path, pcii); - free(path); - - return err; -} - -/* - * XXX: todo - int drmCheckModesettingSupported() - */ diff --git a/usr/src/pkg/manifests/system-test-libdrm.mf b/usr/src/pkg/manifests/system-test-libdrm.mf index 3dcc70d..2d01a07 100644 --- a/usr/src/pkg/manifests/system-test-libdrm.mf +++ b/usr/src/pkg/manifests/system-test-libdrm.mf @@ -22,57 +22,39 @@ set name=info.classification \ set name=variant.arch value=$(ARCH) dir path=opt/drm-tests dir path=opt/drm-tests/$(ARCH64) -file path=opt/drm-tests/$(ARCH64)/dristat file path=opt/drm-tests/$(ARCH64)/drmdevice file path=opt/drm-tests/$(ARCH64)/drmsl -file path=opt/drm-tests/$(ARCH64)/drmstat file path=opt/drm-tests/$(ARCH64)/exynos_fimg2d_event file path=opt/drm-tests/$(ARCH64)/exynos_fimg2d_perf file path=opt/drm-tests/$(ARCH64)/exynos_fimg2d_test -file path=opt/drm-tests/$(ARCH64)/getclient -file path=opt/drm-tests/$(ARCH64)/getstats file path=opt/drm-tests/$(ARCH64)/getsundev -file path=opt/drm-tests/$(ARCH64)/getversion file path=opt/drm-tests/$(ARCH64)/hash file path=opt/drm-tests/$(ARCH64)/kms-steal-crtc file path=opt/drm-tests/$(ARCH64)/kms-universal-planes file path=opt/drm-tests/$(ARCH64)/kmstest file path=opt/drm-tests/$(ARCH64)/modeprint file path=opt/drm-tests/$(ARCH64)/modetest -file path=opt/drm-tests/$(ARCH64)/name_from_fd -file path=opt/drm-tests/$(ARCH64)/openclose file path=opt/drm-tests/$(ARCH64)/proptest file path=opt/drm-tests/$(ARCH64)/radeon_ttm file path=opt/drm-tests/$(ARCH64)/random -file path=opt/drm-tests/$(ARCH64)/setversion file path=opt/drm-tests/$(ARCH64)/tegra_openclose -file path=opt/drm-tests/$(ARCH64)/updatedraw file path=opt/drm-tests/$(ARCH64)/vbltest file path=opt/drm-tests/Run_all.sh -file path=opt/drm-tests/dristat file path=opt/drm-tests/drmdevice file path=opt/drm-tests/drmsl -file path=opt/drm-tests/drmstat file path=opt/drm-tests/exynos_fimg2d_event file path=opt/drm-tests/exynos_fimg2d_perf file path=opt/drm-tests/exynos_fimg2d_test -file path=opt/drm-tests/getclient -file path=opt/drm-tests/getstats file path=opt/drm-tests/getsundev -file path=opt/drm-tests/getversion file path=opt/drm-tests/hash file path=opt/drm-tests/kms-steal-crtc file path=opt/drm-tests/kms-universal-planes file path=opt/drm-tests/kmstest file path=opt/drm-tests/modeprint file path=opt/drm-tests/modetest -file path=opt/drm-tests/name_from_fd -file path=opt/drm-tests/openclose file path=opt/drm-tests/proptest file path=opt/drm-tests/radeon_ttm file path=opt/drm-tests/random -file path=opt/drm-tests/setversion file path=opt/drm-tests/tegra_openclose -file path=opt/drm-tests/updatedraw file path=opt/drm-tests/vbltest depend fmri=pkg:/x11/library/libdrm type=require diff --git a/usr/src/uts/common/drm/i915_drm.h b/usr/src/uts/common/drm/i915_drm.h index 5a6bdb4..b406ce8 100644 --- a/usr/src/uts/common/drm/i915_drm.h +++ b/usr/src/uts/common/drm/i915_drm.h @@ -29,6 +29,10 @@ #include "drm.h" +#if defined(__cplusplus) +extern "C" { +#endif + /* Please note that modifications to all structs defined here are * subject to backwards-compatibility constraints. */ @@ -58,6 +62,30 @@ #define I915_ERROR_UEVENT "ERROR" #define I915_RESET_UEVENT "RESET" +/* + * MOCS indexes used for GPU surfaces, defining the cacheability of the + * surface data and the coherency for this data wrt. CPU vs. GPU accesses. + */ +enum i915_mocs_table_index { + /* + * Not cached anywhere, coherency between CPU and GPU accesses is + * guaranteed. + */ + I915_MOCS_UNCACHED, + /* + * Cacheability and coherency controlled by the kernel automatically + * based on the DRM_I915_GEM_SET_CACHING IOCTL setting and the current + * usage of the surface (used for display scanout or not). + */ + I915_MOCS_PTE, + /* + * Cached in all GPU caches available on the platform. + * Coherency between CPU and GPU accesses to the surface is not + * guaranteed without extra synchronization. + */ + I915_MOCS_CACHED, +}; + /* Each region is a minimum of 16k, and there are at most 255 of them. */ #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use @@ -221,6 +249,7 @@ typedef struct _drm_i915_sarea { #define DRM_I915_OVERLAY_PUT_IMAGE 0x27 #define DRM_I915_OVERLAY_ATTRS 0x28 #define DRM_I915_GEM_EXECBUFFER2 0x29 +#define DRM_I915_GEM_EXECBUFFER2_WR DRM_I915_GEM_EXECBUFFER2 #define DRM_I915_GET_SPRITE_COLORKEY 0x2a #define DRM_I915_SET_SPRITE_COLORKEY 0x2b #define DRM_I915_GEM_WAIT 0x2c @@ -233,6 +262,7 @@ typedef struct _drm_i915_sarea { #define DRM_I915_GEM_USERPTR 0x33 #define DRM_I915_GEM_CONTEXT_GETPARAM 0x34 #define DRM_I915_GEM_CONTEXT_SETPARAM 0x35 +#define DRM_I915_PERF_OPEN 0x36 #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) @@ -257,6 +287,7 @@ typedef struct _drm_i915_sarea { #define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init) #define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer) #define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2) +#define DRM_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2_WR, struct drm_i915_gem_execbuffer2) #define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin) #define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin) #define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy) @@ -289,6 +320,7 @@ typedef struct _drm_i915_sarea { #define DRM_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr) #define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param) #define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param) +#define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param) /* Allow drivers to submit batchbuffers directly to hardware, relying * on the security mechanisms provided by hardware. @@ -385,8 +417,28 @@ typedef struct drm_i915_irq_wait { #define I915_PARAM_HAS_GPU_RESET 35 #define I915_PARAM_HAS_RESOURCE_STREAMER 36 #define I915_PARAM_HAS_EXEC_SOFTPIN 37 -#define I915_PARAM_HAS_POOLED_EU 38 -#define I915_PARAM_MIN_EU_IN_POOL 39 +#define I915_PARAM_HAS_POOLED_EU 38 +#define I915_PARAM_MIN_EU_IN_POOL 39 +#define I915_PARAM_MMAP_GTT_VERSION 40 + +/* Query whether DRM_I915_GEM_EXECBUFFER2 supports user defined execution + * priorities and the driver will attempt to execute batches in priority order. + */ +#define I915_PARAM_HAS_SCHEDULER 41 +#define I915_PARAM_HUC_STATUS 42 + +/* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of + * synchronisation with implicit fencing on individual objects. + * See EXEC_OBJECT_ASYNC. + */ +#define I915_PARAM_HAS_EXEC_ASYNC 43 + +/* Query whether DRM_I915_GEM_EXECBUFFER2 supports explicit fence support - + * both being able to pass in a sync_file fd to wait upon before executing, + * and being able to return a new sync_file fd that is signaled when the + * current request is complete. See I915_EXEC_FENCE_IN and I915_EXEC_FENCE_OUT. + */ +#define I915_PARAM_HAS_EXEC_FENCE 44 typedef struct drm_i915_getparam { __s32 param; @@ -734,15 +786,41 @@ struct drm_i915_gem_exec_object2 { */ __u64 offset; -#define EXEC_OBJECT_NEEDS_FENCE (1<<0) -#define EXEC_OBJECT_NEEDS_GTT (1<<1) -#define EXEC_OBJECT_WRITE (1<<2) +#define EXEC_OBJECT_NEEDS_FENCE (1<<0) +#define EXEC_OBJECT_NEEDS_GTT (1<<1) +#define EXEC_OBJECT_WRITE (1<<2) #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3) -#define EXEC_OBJECT_PINNED (1<<4) -#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_PINNED<<1) +#define EXEC_OBJECT_PINNED (1<<4) +#define EXEC_OBJECT_PAD_TO_SIZE (1<<5) +/* The kernel implicitly tracks GPU activity on all GEM objects, and + * synchronises operations with outstanding rendering. This includes + * rendering on other devices if exported via dma-buf. However, sometimes + * this tracking is too coarse and the user knows better. For example, + * if the object is split into non-overlapping ranges shared between different + * clients or engines (i.e. suballocating objects), the implicit tracking + * by kernel assumes that each operation affects the whole object rather + * than an individual range, causing needless synchronisation between clients. + * The kernel will also forgo any CPU cache flushes prior to rendering from + * the object as the client is expected to be also handling such domain + * tracking. + * + * The kernel maintains the implicit tracking in order to manage resources + * used by the GPU - this flag only disables the synchronisation prior to + * rendering with this object in this execbuf. + * + * Opting out of implicit synhronisation requires the user to do its own + * explicit tracking to avoid rendering corruption. See, for example, + * I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously. + */ +#define EXEC_OBJECT_ASYNC (1<<6) +/* All remaining bits are MBZ and RESERVED FOR FUTURE USE */ +#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_ASYNC<<1) __u64 flags; - __u64 rsvd1; + union { + __u64 rsvd1; + __u64 pad_to_size; + }; __u64 rsvd2; }; @@ -826,7 +904,32 @@ struct drm_i915_gem_execbuffer2 { */ #define I915_EXEC_RESOURCE_STREAMER (1<<15) -#define __I915_EXEC_UNKNOWN_FLAGS -(I915_EXEC_RESOURCE_STREAMER<<1) +/* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent + * a sync_file fd to wait upon (in a nonblocking manner) prior to executing + * the batch. + * + * Returns -EINVAL if the sync_file fd cannot be found. + */ +#define I915_EXEC_FENCE_IN (1<<16) + +/* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd + * in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given + * to the caller, and it should be close() after use. (The fd is a regular + * file descriptor and will be cleaned up on process termination. It holds + * a reference to the request, but nothing else.) + * + * The sync_file fd can be combined with other sync_file and passed either + * to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip + * will only occur after this request completes), or to other devices. + * + * Using I915_EXEC_FENCE_OUT requires use of + * DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written + * back to userspace. Failure to do so will cause the out-fence to always + * be reported as zero, and the real fence fd to be leaked. + */ +#define I915_EXEC_FENCE_OUT (1<<17) + +#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_OUT<<1)) #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff) #define i915_execbuffer2_set_context_id(eb2, context) \ @@ -862,7 +965,16 @@ struct drm_i915_gem_busy { * having flushed any pending activity), and a non-zero return that * the object is still in-flight on the GPU. (The GPU has not yet * signaled completion for all pending requests that reference the - * object.) + * object.) An object is guaranteed to become idle eventually (so + * long as no new GPU commands are executed upon it). Due to the + * asynchronous nature of the hardware, an object reported + * as busy may become idle before the ioctl is completed. + * + * Furthermore, if the object is busy, which engine is busy is only + * provided as a guide. There are race conditions which prevent the + * report of which engines are busy from being always accurate. + * However, the converse is not true. If the object is idle, the + * result of the ioctl, that all engines are idle, is accurate. * * The returned dword is split into two fields to indicate both * the engines on which the object is being read, and the @@ -885,6 +997,11 @@ struct drm_i915_gem_busy { * execution engines, e.g. multiple media engines, which are * mapped to the same identifier in the EXECBUFFER2 ioctl and * so are not separately reported for busyness. + * + * Caveat emptor: + * Only the boolean result of this query is reliable; that is whether + * the object is idle or busy. The report of which engines are busy + * should be only used as a heuristic. */ __u32 busy; }; @@ -933,6 +1050,7 @@ struct drm_i915_gem_caching { #define I915_TILING_NONE 0 #define I915_TILING_X 1 #define I915_TILING_Y 2 +#define I915_TILING_LAST I915_TILING_Y #define I915_BIT_6_SWIZZLE_NONE 0 #define I915_BIT_6_SWIZZLE_9 1 @@ -1209,7 +1327,145 @@ struct drm_i915_gem_context_param { #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1 #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2 #define I915_CONTEXT_PARAM_GTT_SIZE 0x3 +#define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4 +#define I915_CONTEXT_PARAM_BANNABLE 0x5 __u64 value; }; +enum drm_i915_oa_format { + I915_OA_FORMAT_A13 = 1, + I915_OA_FORMAT_A29, + I915_OA_FORMAT_A13_B8_C8, + I915_OA_FORMAT_B4_C8, + I915_OA_FORMAT_A45_B8_C8, + I915_OA_FORMAT_B4_C8_A16, + I915_OA_FORMAT_C4_B8, + + I915_OA_FORMAT_MAX /* non-ABI */ +}; + +enum drm_i915_perf_property_id { + /** + * Open the stream for a specific context handle (as used with + * execbuffer2). A stream opened for a specific context this way + * won't typically require root privileges. + */ + DRM_I915_PERF_PROP_CTX_HANDLE = 1, + + /** + * A value of 1 requests the inclusion of raw OA unit reports as + * part of stream samples. + */ + DRM_I915_PERF_PROP_SAMPLE_OA, + + /** + * The value specifies which set of OA unit metrics should be + * be configured, defining the contents of any OA unit reports. + */ + DRM_I915_PERF_PROP_OA_METRICS_SET, + + /** + * The value specifies the size and layout of OA unit reports. + */ + DRM_I915_PERF_PROP_OA_FORMAT, + + /** + * Specifying this property implicitly requests periodic OA unit + * sampling and (at least on Haswell) the sampling frequency is derived + * from this exponent as follows: + * + * 80ns * 2^(period_exponent + 1) + */ + DRM_I915_PERF_PROP_OA_EXPONENT, + + DRM_I915_PERF_PROP_MAX /* non-ABI */ +}; + +struct drm_i915_perf_open_param { + __u32 flags; +#define I915_PERF_FLAG_FD_CLOEXEC (1<<0) +#define I915_PERF_FLAG_FD_NONBLOCK (1<<1) +#define I915_PERF_FLAG_DISABLED (1<<2) + + /** The number of u64 (id, value) pairs */ + __u32 num_properties; + + /** + * Pointer to array of u64 (id, value) pairs configuring the stream + * to open. + */ + __u64 properties_ptr; +}; + +/** + * Enable data capture for a stream that was either opened in a disabled state + * via I915_PERF_FLAG_DISABLED or was later disabled via + * I915_PERF_IOCTL_DISABLE. + * + * It is intended to be cheaper to disable and enable a stream than it may be + * to close and re-open a stream with the same configuration. + * + * It's undefined whether any pending data for the stream will be lost. + */ +#define I915_PERF_IOCTL_ENABLE _IO('i', 0x0) + +/** + * Disable data capture for a stream. + * + * It is an error to try and read a stream that is disabled. + */ +#define I915_PERF_IOCTL_DISABLE _IO('i', 0x1) + +/** + * Common to all i915 perf records + */ +struct drm_i915_perf_record_header { + __u32 type; + __u16 pad; + __u16 size; +}; + +enum drm_i915_perf_record_type { + + /** + * Samples are the work horse record type whose contents are extensible + * and defined when opening an i915 perf stream based on the given + * properties. + * + * Boolean properties following the naming convention + * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in + * every sample. + * + * The order of these sample properties given by userspace has no + * affect on the ordering of data within a sample. The order is + * documented here. + * + * struct { + * struct drm_i915_perf_record_header header; + * + * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA + * }; + */ + DRM_I915_PERF_RECORD_SAMPLE = 1, + + /* + * Indicates that one or more OA reports were not written by the + * hardware. This can happen for example if an MI_REPORT_PERF_COUNT + * command collides with periodic sampling - which would be more likely + * at higher sampling frequencies. + */ + DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2, + + /** + * An error occurred that resulted in all pending OA reports being lost. + */ + DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3, + + DRM_I915_PERF_RECORD_MAX /* non-ABI */ +}; + +#if defined(__cplusplus) +} +#endif + #endif /* _I915_DRM_H_ */ |