aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2020-09-18 16:40:12 +0000
committerandroid-build-prod (mdb) <android-build-team-robot@google.com>2020-09-18 16:40:12 +0000
commit3a7efdb67779b62803ea9d8633d2a6c220115221 (patch)
tree6390f075e4badded650bf00fb9a3027ab94c8a32
parent06b698c2b81637b803c3467f57ab511d44fe8090 (diff)
parentc149d6c7426e311b72c325e7ecb49e329c3a34fb (diff)
downloadlibdrm-emu-30-release.tar.gz
Snap for 6837279 from c149d6c7426e311b72c325e7ecb49e329c3a34fb to emu-30-releaseemu-30-release
Change-Id: Ia6bf87b29705decf824d40cf044cd6940699f8e4
-rw-r--r--.gitignore109
-rw-r--r--.gitlab-ci.yml268
-rw-r--r--.gitlab-ci/debian-install.sh67
-rw-r--r--Makefile.am176
-rw-r--r--README.rst30
-rw-r--r--RELEASING29
-rw-r--r--amdgpu/Makefile.am53
-rw-r--r--[-rwxr-xr-x]amdgpu/amdgpu-symbols.txt (renamed from amdgpu/amdgpu-symbol-check)21
-rw-r--r--amdgpu/amdgpu.h33
-rw-r--r--amdgpu/amdgpu_cs.c67
-rw-r--r--amdgpu/amdgpu_internal.h2
-rw-r--r--amdgpu/meson.build11
-rwxr-xr-xautogen.sh20
-rw-r--r--configure.ac605
-rw-r--r--core-symbols.txt197
-rw-r--r--data/Makefile.am25
-rw-r--r--data/amdgpu.ids20
-rw-r--r--etnaviv/Makefile.am28
-rw-r--r--[-rwxr-xr-x]etnaviv/etnaviv-symbols.txt (renamed from etnaviv/etnaviv-symbol-check)19
-rw-r--r--etnaviv/meson.build10
-rw-r--r--exynos/Makefile.am29
-rwxr-xr-xexynos/exynos-symbol-check42
-rw-r--r--exynos/exynos-symbols.txt23
-rw-r--r--exynos/meson.build11
-rw-r--r--freedreno/Makefile.am33
-rw-r--r--[-rwxr-xr-x]freedreno/freedreno-symbols.txt (renamed from freedreno/freedreno-symbol-check)20
-rw-r--r--freedreno/meson.build11
-rw-r--r--include/drm/amdgpu_drm.h24
-rw-r--r--include/drm/drm.h5
-rw-r--r--include/drm/nouveau_drm.h77
-rw-r--r--intel/Makefile.am75
-rw-r--r--intel/i915_pciids.h234
-rw-r--r--[-rwxr-xr-x]intel/intel-symbols.txt (renamed from intel/intel-symbol-check)19
-rw-r--r--intel/intel_bufmgr_gem.c45
-rw-r--r--intel/intel_chipset.c2
-rw-r--r--intel/intel_chipset.h1
-rw-r--r--intel/meson.build30
-rwxr-xr-xintel/tests/test-batch.sh2
-rw-r--r--libkms/Makefile.am45
-rwxr-xr-xlibkms/kms-symbol-check27
-rw-r--r--libkms/kms-symbols.txt8
-rw-r--r--libkms/meson.build11
-rw-r--r--m4/.gitignore5
-rw-r--r--man/Makefile.am62
-rw-r--r--meson.build58
-rw-r--r--nouveau/Makefile.am35
-rw-r--r--nouveau/meson.build11
-rw-r--r--[-rwxr-xr-x]nouveau/nouveau-symbols.txt (renamed from nouveau/nouveau-symbol-check)19
-rw-r--r--nouveau/private.h2
-rw-r--r--omap/Makefile.am26
-rw-r--r--omap/meson.build11
-rwxr-xr-xomap/omap-symbol-check37
-rw-r--r--omap/omap-symbols.txt18
-rw-r--r--radeon/Makefile.am49
-rw-r--r--radeon/meson.build11
-rw-r--r--[-rwxr-xr-x]radeon/radeon-symbols.txt (renamed from radeon/radeon-symbol-check)19
-rw-r--r--symbols-check.py130
-rw-r--r--tegra/Makefile.am27
-rw-r--r--tegra/meson.build11
-rwxr-xr-xtegra/tegra-symbol-check35
-rw-r--r--tegra/tegra-symbols.txt13
-rw-r--r--tests/Makefile.am53
-rw-r--r--tests/amdgpu/Makefile.am38
-rw-r--r--tests/amdgpu/amdgpu_test.c77
-rw-r--r--tests/amdgpu/amdgpu_test.h5
-rw-r--r--tests/amdgpu/basic_tests.c678
-rw-r--r--tests/amdgpu/bo_tests.c3
-rw-r--r--tests/amdgpu/cs_tests.c1
-rw-r--r--tests/amdgpu/deadlock_tests.c68
-rw-r--r--tests/amdgpu/decode_messages.h6
-rw-r--r--tests/amdgpu/meson.build2
-rw-r--r--tests/amdgpu/ras_tests.c729
-rw-r--r--tests/amdgpu/syncobj_tests.c2
-rw-r--r--tests/amdgpu/vcn_tests.c21
-rw-r--r--tests/etnaviv/Makefile.am43
-rw-r--r--tests/exynos/Makefile.am48
-rw-r--r--tests/kms/Makefile.am37
-rw-r--r--tests/kms/kms-steal-crtc.c2
-rw-r--r--tests/kms/kms-universal-planes.c2
-rw-r--r--tests/kms/libkms-test-screen.c4
-rw-r--r--tests/kmstest/Makefile.am26
-rw-r--r--tests/meson.build10
-rw-r--r--tests/modeprint/Makefile.am20
-rw-r--r--tests/modetest/Makefile.am25
-rw-r--r--tests/modetest/modetest.c856
-rw-r--r--tests/nouveau/Makefile.am17
-rw-r--r--tests/nouveau/threaded.c4
-rw-r--r--tests/proptest/Makefile.am22
-rw-r--r--tests/radeon/Makefile.am15
-rw-r--r--tests/random.c120
-rw-r--r--tests/tegra/Makefile.am15
-rw-r--r--tests/util/Makefile.am13
-rw-r--r--tests/util/pattern.c2
-rw-r--r--tests/vbltest/Makefile.am20
-rw-r--r--tests/vbltest/vbltest.c2
-rw-r--r--vc4/Makefile.am35
-rw-r--r--xf86atomic.h1
-rw-r--r--xf86drm.c429
-rw-r--r--xf86drm.h49
-rw-r--r--xf86drmMode.c52
-rw-r--r--xf86drmMode.h18
101 files changed, 3328 insertions, 3385 deletions
diff --git a/.gitignore b/.gitignore
index 811348ab..0ec9e7f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,110 +1 @@
-*.1
-*.3
-*.5
-*.7
-*.flags
-*.ko
-*.ko.cmd
-*.la
-*.lo
-*.log
-*.mod.c
-*.mod.o
-*.o
-*.o.cmd
-*.sw?
-*.trs
-*~
-.*check*
-.*install*
-.depend
-.deps
-.libs
-.tmp_versions
-/_build*
/build*
-Makefile
-Makefile.in
-TAGS
-aclocal.m4
-autom4te.cache
-bsd-core/*/@
-bsd-core/*/machine
-build-aux
-bus_if.h
-compile
-config.guess
-config.h
-config.h.in
-config.log
-config.status
-config.sub
-configure
-configure.lineno
-cscope.*
-depcomp
-device_if.h
-drm.kld
-drm_pciids.h
-export_syms
-i915.kld
-install-sh
-libdrm.pc
-libdrm/config.h.in
-libdrm_amdgpu.pc
-libdrm_etnaviv.pc
-libdrm_exynos.pc
-libdrm_freedreno.pc
-libdrm_intel.pc
-libdrm_nouveau.pc
-libdrm_omap.pc
-libdrm_radeon.pc
-libdrm_vc4.pc
-libkms.pc
-libtool
-ltmain.sh
-mach64.kld
-man/*.3
-man/.man_fixup
-mga.kld
-missing
-mkinstalldirs
-opt_drm.h
-pci_if.h
-r128.kld
-radeon.kld
-savage.kld
-sis.kld
-stamp-h1
-tdfx.kld
-tests/amdgpu/amdgpu_test
-tests/auth
-tests/dristat
-tests/drmdevice
-tests/drmsl
-tests/drmstat
-tests/etnaviv/etnaviv_2d_test
-tests/etnaviv/etnaviv_bo_cache_test
-tests/etnaviv/etnaviv_cmd_stream_test
-tests/exynos/exynos_fimg2d_event
-tests/exynos/exynos_fimg2d_perf
-tests/exynos/exynos_fimg2d_test
-tests/getclient
-tests/getstats
-tests/getversion
-tests/hash
-tests/kms/kms-steal-crtc
-tests/kms/kms-universal-planes
-tests/kmstest/kmstest
-tests/lock
-tests/modeprint/modeprint
-tests/modetest/modetest
-tests/name_from_fd
-tests/openclose
-tests/proptest/proptest
-tests/radeon/radeon_ttm
-tests/random
-tests/setversion
-tests/updatedraw
-tests/vbltest/vbltest
-via.kld
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ac2a9d2d..a6e3bd4a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,159 +1,131 @@
-.artifacts-meson: &artifacts-meson
- when: always
- paths:
- - _build/meson-logs
+# This is the tag of the docker image used for the build jobs. If the
+# image doesn't exist yet, the containers stage generates it.
+#
+# In order to generate a new image, one should generally change the tag.
+# While removing the image from the registry would also work, that's not
+# recommended except for ephemeral images during development: Replacing
+# an image after a significant amount of time might pull in newer
+# versions of gcc/clang or other packages, which might break the build
+# with older commits using the same tag.
+#
+# After merging a change resulting in generating a new image to the
+# main repository, it's recommended to remove the image from the source
+# repository's container registry, so that the image from the main
+# repository's registry will be used there as well.
+variables:
+ UPSTREAM_REPO: mesa/drm
+ DEBIAN_TAG: "2019-11-16"
+ DEBIAN_VERSION: buster-slim
+ DEBIAN_IMAGE: "$CI_REGISTRY_IMAGE/debian/$DEBIAN_VERSION:$DEBIAN_TAG"
-.artifacts-autotools: &artifacts-autotools
- when: always
- paths:
- - _build/*.log
- - _build/*/*.log
- - _build/*/*/*.log
+include:
+ - project: 'wayland/ci-templates'
+ ref: 0a9bdd33a98f05af6761ab118b5074952242aab0
+ file: '/templates/debian.yml'
-.meson-build: &meson-build
- - meson _build
- -D amdgpu=true
- -D cairo-tests=true
- -D etnaviv=true
- -D exynos=true
- -D freedreno=true
- -D freedreno-kgsl=true
- -D intel=true
- -D libkms=true
- -D man-pages=true
- -D nouveau=true
- -D omap=true
- -D radeon=true
- -D tegra=true
- -D udev=true
- -D valgrind=true
- -D vc4=true
- -D vmwgfx=true
- - ninja -C _build
- - ninja -C _build test
+stages:
+ - containers
+ - build
-.autotools-build: &autotools-build
- - mkdir _build
- - cd _build
- - ../autogen.sh
- --enable-udev
- --enable-libkms
- --enable-intel
- --enable-radeon
- --enable-amdgpu
- --enable-nouveau
- --enable-vmwgfx
- --enable-omap-experimental-api
- --enable-exynos-experimental-api
- --enable-freedreno
- --enable-freedreno-kgsl
- --enable-tegra-experimental-api
- --enable-vc4
- --enable-etnaviv-experimental-api
- - make
- - make check
-latest-meson:
- stage: build
- image: archlinux/base:latest
- before_script:
- - pacman -Syu --noconfirm --needed
- base-devel
- meson
- libpciaccess
- libxslt docbook-xsl
- valgrind
- libatomic_ops
- cairo cunit
- script: *meson-build
+# When & how to run the CI
+.ci-run-policy:
+ except:
+ - schedules
+ retry:
+ max: 2
+ when:
+ - runner_system_failure
-latest-autotools:
+# CONTAINERS
+
+debian:
+ stage: containers
+ extends:
+ - .ci-run-policy
+ - .debian@container-ifnot-exists
+ variables:
+ GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
+ DEBIAN_EXEC: 'bash .gitlab-ci/debian-install.sh'
+
+
+# BUILD
+
+.meson-build:
stage: build
- image: archlinux/base:latest
- artifacts: *artifacts-autotools
+ variables:
+ GIT_DEPTH: 10
+ script:
+ - meson build
+ -D amdgpu=true
+ -D cairo-tests=true
+ -D etnaviv=true
+ -D exynos=true
+ -D freedreno=true
+ -D freedreno-kgsl=true
+ -D intel=true
+ -D libkms=true
+ -D man-pages=true
+ -D nouveau=true
+ -D omap=true
+ -D radeon=true
+ -D tegra=true
+ -D udev=true
+ -D valgrind=auto
+ -D vc4=true
+ -D vmwgfx=true
+ ${CROSS+--cross /cross_file-$CROSS.txt}
+ - ninja -C build
+ - ninja -C build test
+ - DESTDIR=$PWD/install ninja -C build install
+ artifacts:
+ when: on_failure
+ paths:
+ - build/meson-logs/*
+
+meson-x86_64:
+ extends:
+ - .ci-run-policy
+ - .meson-build
+ image: $DEBIAN_IMAGE
+ needs:
+ - debian
+
+meson-i386:
+ extends: meson-x86_64
+ variables:
+ CROSS: i386
+
+meson-aarch64:
+ extends: meson-x86_64
+ variables:
+ CROSS: arm64
+
+meson-armhf:
+ extends: meson-x86_64
+ variables:
+ CROSS: armhf
+
+meson-ppc64el:
+ extends: meson-x86_64
+ variables:
+ CROSS: ppc64el
+
+meson-arch-daily:
+ rules:
+ - if: '$SCHEDULE == "arch-daily"'
+ when: on_success
+ - when: never
+ image: archlinux/base
before_script:
- pacman -Syu --noconfirm --needed
base-devel
- libpciaccess
- libxslt docbook-xsl
- valgrind
+ cairo
+ cunit
+ docbook-xsl
libatomic_ops
- cairo cunit
- xorg-util-macros
- git # autogen.sh depends on git
- script: *autotools-build
-
-oldest-meson:
- stage: build
- image: debian:stable
- artifacts: *artifacts-meson
- before_script:
- - printf > /etc/dpkg/dpkg.cfg.d/99-exclude-cruft "%s\n"
- 'path-exclude=/usr/share/doc/*'
- 'path-exclude=/usr/share/man/*'
- - printf > /usr/sbin/policy-rc.d "%s\n"
- '#!/bin/sh'
- 'exit 101'
- - chmod +x /usr/sbin/policy-rc.d
- - apt-get update
- - apt-get -y --no-install-recommends install
- build-essential
- pkg-config
- xsltproc
- libxslt1-dev docbook-xsl
- valgrind
- libatomic-ops-dev
- libcairo2-dev libcunit1-dev
- ninja-build
- python3 python3-pip
- wget
- # We need `--no-check-certificate` here because Debian's CA list is
- # too old to know about LetsEncrypt's CA, so it refuses to connect
- # to FreeDesktop.org
- - LIBPCIACCESS_VERSION=libpciaccess-0.10 &&
- wget --no-check-certificate https://xorg.freedesktop.org/releases/individual/lib/$LIBPCIACCESS_VERSION.tar.bz2 &&
- tar -jxvf $LIBPCIACCESS_VERSION.tar.bz2 &&
- (cd $LIBPCIACCESS_VERSION && ./configure --prefix=$HOME/prefix && make install)
- - pip3 install wheel setuptools
- - pip3 install meson==0.43
- - export PKG_CONFIG_PATH=$HOME/prefix/lib/pkgconfig:$HOME/prefix/share/pkgconfig
- - export LD_LIBRARY_PATH="$HOME/prefix/lib:$LD_LIBRARY_PATH"
- script: *meson-build
-
-oldest-autotools:
- stage: build
- image: debian:stable
- artifacts: *artifacts-autotools
- before_script:
- - printf > /etc/dpkg/dpkg.cfg.d/99-exclude-cruft "%s\n"
- 'path-exclude=/usr/share/doc/*'
- 'path-exclude=/usr/share/man/*'
- - printf > /usr/sbin/policy-rc.d "%s\n"
- '#!/bin/sh'
- 'exit 101'
- - chmod +x /usr/sbin/policy-rc.d
- - apt-get update
- - apt-get -y --no-install-recommends install
- build-essential
- automake
- autoconf
- libtool
- pkg-config
- xsltproc
- libxslt1-dev docbook-xsl
+ libpciaccess
+ libxslt
+ meson
valgrind
- libatomic-ops-dev
- libcairo2-dev libcunit1-dev
- wget
- xutils-dev
- git # autogen.sh depends on git
- # We need `--no-check-certificate` here because Debian's CA list is
- # too old to know about LetsEncrypt's CA, so it refuses to connect
- # to FreeDesktop.org
- - LIBPCIACCESS_VERSION=libpciaccess-0.10 &&
- wget --no-check-certificate https://xorg.freedesktop.org/releases/individual/lib/$LIBPCIACCESS_VERSION.tar.bz2 &&
- tar -jxvf $LIBPCIACCESS_VERSION.tar.bz2 &&
- (cd $LIBPCIACCESS_VERSION && ./configure --prefix=$HOME/prefix && make install)
- - export PKG_CONFIG_PATH=$HOME/prefix/lib/pkgconfig:$HOME/prefix/share/pkgconfig
- - export LD_LIBRARY_PATH="$HOME/prefix/lib:$LD_LIBRARY_PATH"
- script: *autotools-build
+ extends: .meson-build
diff --git a/.gitlab-ci/debian-install.sh b/.gitlab-ci/debian-install.sh
new file mode 100644
index 00000000..b2f1a791
--- /dev/null
+++ b/.gitlab-ci/debian-install.sh
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+set -o errexit
+set -o xtrace
+
+export DEBIAN_FRONTEND=noninteractive
+
+CROSS_ARCHITECTURES=(i386 armhf arm64 ppc64el)
+for arch in ${CROSS_ARCHITECTURES[@]}; do
+ dpkg --add-architecture $arch
+done
+
+apt-get install -y \
+ ca-certificates
+
+sed -i -e 's/http:\/\/deb/https:\/\/deb/g' /etc/apt/sources.list
+echo 'deb https://deb.debian.org/debian buster-backports main' >/etc/apt/sources.list.d/backports.list
+
+apt-get update
+
+# Use newer packages from backports by default
+cat >/etc/apt/preferences <<EOF
+Package: *
+Pin: release a=buster-backports
+Pin-Priority: 500
+EOF
+
+apt-get dist-upgrade -y
+
+apt-get install -y --no-remove \
+ build-essential \
+ docbook-xsl \
+ libatomic-ops-dev \
+ libcairo2-dev \
+ libcunit1-dev \
+ libpciaccess-dev \
+ libxslt1-dev \
+ meson \
+ ninja-build \
+ pkg-config \
+ python3 \
+ python3-pip \
+ python3-wheel \
+ python3-setuptools \
+ valgrind \
+ xsltproc
+
+for arch in ${CROSS_ARCHITECTURES[@]}; do
+ cross_file=/cross_file-$arch.txt
+
+ # Cross-build libdrm deps
+ apt-get install -y --no-remove \
+ libcairo2-dev:$arch \
+ libpciaccess-dev:$arch \
+ crossbuild-essential-$arch
+
+ # Generate cross build files for Meson
+ /usr/share/meson/debcrossgen --arch $arch -o $cross_file
+
+ # Work around a bug in debcrossgen that should be fixed in the next release
+ if [ $arch = i386 ]; then
+ sed -i "s|cpu_family = 'i686'|cpu_family = 'x86'|g" $cross_file
+ fi
+done
+
+
+# Test that the oldest Meson version we claim to support is still supported
+pip3 install meson==0.43
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index 730de1f2..00000000
--- a/Makefile.am
+++ /dev/null
@@ -1,176 +0,0 @@
-# Copyright 2005 Adam Jackson.
-#
-# 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
-# on the rights to use, copy, modify, merge, publish, distribute, sub
-# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-# ADAM JACKSON 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.
-
-include Makefile.sources
-
-ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
-
-AM_MAKEFLAGS = -s
-AM_DISTCHECK_CONFIGURE_FLAGS = \
- --enable-udev \
- --enable-libkms \
- --enable-intel \
- --enable-radeon \
- --enable-amdgpu \
- --enable-nouveau \
- --enable-vc4 \
- --enable-vmwgfx \
- --enable-omap-experimental-api \
- --enable-exynos-experimental-api \
- --enable-freedreno \
- --enable-freedreno-kgsl\
- --enable-tegra-experimental-api \
- --enable-etnaviv-experimental-api \
- --enable-install-test-programs \
- --enable-cairo-tests \
- --enable-manpages \
- --enable-valgrind
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm.pc
-
-if HAVE_LIBKMS
-LIBKMS_SUBDIR = libkms
-endif
-
-if HAVE_INTEL
-INTEL_SUBDIR = intel
-endif
-
-if HAVE_NOUVEAU
-NOUVEAU_SUBDIR = nouveau
-endif
-
-if HAVE_RADEON
-RADEON_SUBDIR = radeon
-endif
-
-if HAVE_AMDGPU
-AMDGPU_SUBDIR = amdgpu
-endif
-
-if HAVE_OMAP
-OMAP_SUBDIR = omap
-endif
-
-if HAVE_EXYNOS
-EXYNOS_SUBDIR = exynos
-endif
-
-if HAVE_FREEDRENO
-FREEDRENO_SUBDIR = freedreno
-endif
-
-if HAVE_TEGRA
-TEGRA_SUBDIR = tegra
-endif
-
-if HAVE_VC4
-VC4_SUBDIR = vc4
-endif
-
-if HAVE_ETNAVIV
-ETNAVIV_SUBDIR = etnaviv
-endif
-
-if BUILD_MANPAGES
-if HAVE_MANPAGES_STYLESHEET
-MAN_SUBDIR = man
-endif
-endif
-
-SUBDIRS = \
- . \
- $(LIBKMS_SUBDIR) \
- $(INTEL_SUBDIR) \
- $(NOUVEAU_SUBDIR) \
- $(RADEON_SUBDIR) \
- $(AMDGPU_SUBDIR) \
- $(OMAP_SUBDIR) \
- $(EXYNOS_SUBDIR) \
- $(FREEDRENO_SUBDIR) \
- $(TEGRA_SUBDIR) \
- $(VC4_SUBDIR) \
- $(ETNAVIV_SUBDIR) \
- data \
- tests \
- $(MAN_SUBDIR)
-
-libdrm_la_LTLIBRARIES = libdrm.la
-libdrm_ladir = $(libdir)
-libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined
-libdrm_la_LIBADD = @CLOCK_LIB@ -lm
-
-libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- $(VALGRIND_CFLAGS)
-
-libdrm_la_SOURCES = $(LIBDRM_FILES)
-
-libdrmincludedir = ${includedir}
-libdrminclude_HEADERS = $(LIBDRM_H_FILES)
-
-klibdrmincludedir = ${includedir}/libdrm
-klibdrminclude_HEADERS = $(LIBDRM_INCLUDE_H_FILES)
-
-if HAVE_VMWGFX
-klibdrminclude_HEADERS += $(LIBDRM_INCLUDE_VMWGFX_H_FILES)
-endif
-
-EXTRA_DIST = \
- include/drm/README \
- amdgpu/meson.build \
- data/meson.build \
- etnaviv/meson.build \
- exynos/meson.build \
- freedreno/meson.build \
- intel/meson.build \
- libkms/meson.build \
- man/meson.build \
- nouveau/meson.build \
- omap/meson.build \
- radeon/meson.build \
- tegra/meson.build \
- tests/amdgpu/meson.build \
- tests/etnaviv/meson.build \
- tests/exynos/meson.build \
- tests/kms/meson.build \
- tests/kmstest/meson.build \
- tests/meson.build \
- tests/modeprint/meson.build \
- tests/modetest/meson.build \
- tests/nouveau/meson.build \
- tests/proptest/meson.build \
- tests/radeon/meson.build \
- tests/tegra/meson.build \
- tests/util/meson.build \
- tests/vbltest/meson.build \
- vc4/meson.build \
- meson.build \
- meson_options.txt
-
-copy-headers :
- cp -r $(kernel_source)/include/uapi/drm/*.h $(top_srcdir)/include/drm/
-
-commit-headers : copy-headers
- git add include/drm/*.h
- git commit -am "Copy headers from kernel $$(GIT_DIR=$(kernel_source)/.git git describe)"
diff --git a/README.rst b/README.rst
index e47cb241..da995d0b 100644
--- a/README.rst
+++ b/README.rst
@@ -17,11 +17,7 @@ the Mesa drivers, the X drivers, libva and similar projects.
Compiling
---------
-libdrm has two build systems, a legacy autotools build system, and a newer
-meson build system. The meson build system is much faster, and offers a
-slightly different interface, but otherwise provides an equivalent feature set.
-
-To use it:
+To set up meson:
meson builddir/
@@ -35,27 +31,3 @@ Then use ninja to build and install:
If you are installing into a system location you will need to run install
separately, and as root.
-
-
-Alternatively you can invoke autotools configure:
-
- ./configure
-
-By default, libdrm will install into the /usr/local/ prefix. If you
-want to install this DRM to replace your system copy, pass
---prefix=/usr and --exec-prefix=/ to configure. If you are building
-libdrm from a git checkout, you first need to run the autogen.sh
-script. You can pass any options to autogen.sh that you would other
-wise pass to configure, or you can just re-run configure with the
-options you need once autogen.sh finishes.
-
-Next step is to build libdrm:
-
- make
-
-and once make finishes successfully, install the package using
-
- make install
-
-If you are installing into a system location, you will need to be root
-to perform the install step.
diff --git a/RELEASING b/RELEASING
index 7e03e3b9..903c1761 100644
--- a/RELEASING
+++ b/RELEASING
@@ -9,33 +9,22 @@ However, this is up to whoever is driving the feature in question.
Follow these steps to release a new version of libdrm:
- 1) Bump the version number in configure.ac and meson.build. We seem
- to have settled for 2.4.x as the versioning scheme for libdrm, so
- just bump the micro version.
+ 1) Bump the version number in meson.build. We seem to have settled for
+ 2.4.x as the versioning scheme for libdrm, so just bump the micro
+ version.
- 2) Run autoconf and then re-run ./configure so the build system
- picks up the new version number.
+ 2) Run `ninja -C builddir/ dist` to generate the tarballs.
+ Make sure that the version number of the tarball name in
+ builddir/meson-dist/ matches the number you bumped to. Move that
+ tarball to the libdrm repo root for the release script to pick up.
- 3) Verify that the code passes "make distcheck". Running "make
- distcheck" should result in no warnings or errors and end with a
- message of the form:
-
- =============================================
- libdrm-X.Y.Z archives ready for distribution:
- libdrm-X.Y.Z.tar.gz
- libdrm-X.Y.Z.tar.bz2
- =============================================
-
- Make sure that the version number reported by distcheck and in
- the tarball names matches the number you bumped to in configure.ac.
-
- 4) Push the updated master branch with the bumped version number:
+ 3) Push the updated master branch with the bumped version number:
git push origin master
assuming the remote for the upstream libdrm repo is called origin.
- 5) Use the release.sh script from the xorg/util/modular repo to
+ 4) Use the release.sh script from the xorg/util/modular repo to
upload the tarballs to the freedesktop.org download area and
create an announce email template. The script takes one argument:
the path to the libdrm checkout. So, if a checkout of modular is
diff --git a/amdgpu/Makefile.am b/amdgpu/Makefile.am
deleted file mode 100644
index ef8ab057..00000000
--- a/amdgpu/Makefile.am
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright © 2008 Jérôme Glisse
-#
-# 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:
-# Jérôme Glisse <glisse@freedesktop.org>
-
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrmdatadir = @libdrmdatadir@
-AM_CPPFLAGS = -DAMDGPU_ASIC_ID_TABLE=\"${libdrmdatadir}/amdgpu.ids\"
-
-libdrm_amdgpu_la_LTLIBRARIES = libdrm_amdgpu.la
-libdrm_amdgpu_ladir = $(libdir)
-libdrm_amdgpu_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_amdgpu_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-
-libdrm_amdgpu_la_SOURCES = $(LIBDRM_AMDGPU_FILES)
-amdgpu_asic_id.lo: $(top_srcdir)/data/amdgpu.ids
-
-libdrm_amdgpuincludedir = ${includedir}/libdrm
-libdrm_amdgpuinclude_HEADERS = $(LIBDRM_AMDGPU_H_FILES)
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_amdgpu.pc
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = amdgpu-symbol-check
-EXTRA_DIST = $(TESTS)
diff --git a/amdgpu/amdgpu-symbol-check b/amdgpu/amdgpu-symbols.txt
index 5ce15f46..e3bafaab 100755..100644
--- a/amdgpu/amdgpu-symbol-check
+++ b/amdgpu/amdgpu-symbols.txt
@@ -1,17 +1,3 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first five) are taken from the public headers.
-# A list of the latter should be available Makefile.am/libdrm_amdgpuinclude_HEADERS
-
-FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libdrm_amdgpu.so} | awk '{print $3}' | while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_start
-_edata
-_end
-_fini
-_init
amdgpu_bo_alloc
amdgpu_bo_cpu_map
amdgpu_bo_cpu_unmap
@@ -46,6 +32,7 @@ amdgpu_cs_fence_to_handle
amdgpu_cs_import_syncobj
amdgpu_cs_query_fence_status
amdgpu_cs_query_reset_state
+amdgpu_cs_query_reset_state2
amdgpu_query_sw_info
amdgpu_cs_signal_semaphore
amdgpu_cs_submit
@@ -56,6 +43,7 @@ amdgpu_cs_syncobj_export_sync_file2
amdgpu_cs_syncobj_import_sync_file
amdgpu_cs_syncobj_import_sync_file2
amdgpu_cs_syncobj_query
+amdgpu_cs_syncobj_query2
amdgpu_cs_syncobj_reset
amdgpu_cs_syncobj_signal
amdgpu_cs_syncobj_timeline_signal
@@ -84,8 +72,3 @@ amdgpu_va_range_free
amdgpu_va_range_query
amdgpu_vm_reserve_vmid
amdgpu_vm_unreserve_vmid
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index 66e45f73..188179c9 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -942,6 +942,21 @@ int amdgpu_cs_ctx_override_priority(amdgpu_device_handle dev,
int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
uint32_t *state, uint32_t *hangs);
+/**
+ * Query reset state for the specific GPU Context.
+ *
+ * \param context - \c [in] GPU Context handle
+ * \param flags - \c [out] A combination of AMDGPU_CTX_QUERY2_FLAGS_*
+ *
+ * \return 0 on success\n
+ * <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_cs_ctx_create()
+ *
+*/
+int amdgpu_cs_query_reset_state2(amdgpu_context_handle context,
+ uint64_t *flags);
+
/*
* Command Buffers Management
*
@@ -1591,6 +1606,24 @@ int amdgpu_cs_syncobj_timeline_wait(amdgpu_device_handle dev,
int amdgpu_cs_syncobj_query(amdgpu_device_handle dev,
uint32_t *handles, uint64_t *points,
unsigned num_handles);
+/**
+ * Query sync objects last signaled or submitted point.
+ *
+ * \param dev - \c [in] self-explanatory
+ * \param handles - \c [in] array of sync object handles
+ * \param points - \c [out] array of sync points returned, which presents
+ * syncobj payload.
+ * \param num_handles - \c [in] self-explanatory
+ * \param flags - \c [in] a bitmask of DRM_SYNCOBJ_QUERY_FLAGS_*
+ *
+ * \return 0 on success\n
+ * -ETIME - Timeout
+ * <0 - Negative POSIX Error code
+ *
+ */
+int amdgpu_cs_syncobj_query2(amdgpu_device_handle dev,
+ uint32_t *handles, uint64_t *points,
+ unsigned num_handles, uint32_t flags);
/**
* Export kernel sync object to shareable fd.
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index 20d5aef2..fad484bf 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -28,7 +28,7 @@
#include <pthread.h>
#include <sched.h>
#include <sys/ioctl.h>
-#ifdef HAVE_ALLOCA_H
+#if HAVE_ALLOCA_H
# include <alloca.h>
#endif
@@ -188,6 +188,25 @@ drm_public int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
return r;
}
+drm_public int amdgpu_cs_query_reset_state2(amdgpu_context_handle context,
+ uint64_t *flags)
+{
+ union drm_amdgpu_ctx args;
+ int r;
+
+ if (!context)
+ return -EINVAL;
+
+ memset(&args, 0, sizeof(args));
+ args.in.op = AMDGPU_CTX_OP_QUERY_STATE2;
+ args.in.ctx_id = context->id;
+ r = drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_CTX,
+ &args, sizeof(args));
+ if (!r)
+ *flags = args.out.state.flags;
+ return r;
+}
+
/**
* Submit command to kernel DRM
* \param dev - \c [in] Device handle
@@ -201,15 +220,15 @@ drm_public int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
static int amdgpu_cs_submit_one(amdgpu_context_handle context,
struct amdgpu_cs_request *ibs_request)
{
- union drm_amdgpu_cs cs;
- uint64_t *chunk_array;
struct drm_amdgpu_cs_chunk *chunks;
struct drm_amdgpu_cs_chunk_data *chunk_data;
struct drm_amdgpu_cs_chunk_dep *dependencies = NULL;
struct drm_amdgpu_cs_chunk_dep *sem_dependencies = NULL;
+ amdgpu_device_handle dev = context->dev;
struct list_head *sem_list;
amdgpu_semaphore_handle sem, tmp;
- uint32_t i, size, sem_count = 0;
+ uint32_t i, size, num_chunks, bo_list_handle = 0, sem_count = 0;
+ uint64_t seq_no;
bool user_fence;
int r = 0;
@@ -225,23 +244,18 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
size = ibs_request->number_of_ibs + (user_fence ? 2 : 1) + 1;
- chunk_array = alloca(sizeof(uint64_t) * size);
chunks = alloca(sizeof(struct drm_amdgpu_cs_chunk) * size);
size = ibs_request->number_of_ibs + (user_fence ? 1 : 0);
chunk_data = alloca(sizeof(struct drm_amdgpu_cs_chunk_data) * size);
- memset(&cs, 0, sizeof(cs));
- cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
- cs.in.ctx_id = context->id;
if (ibs_request->resources)
- cs.in.bo_list_handle = ibs_request->resources->handle;
- cs.in.num_chunks = ibs_request->number_of_ibs;
+ bo_list_handle = ibs_request->resources->handle;
+ num_chunks = ibs_request->number_of_ibs;
/* IB chunks */
for (i = 0; i < ibs_request->number_of_ibs; i++) {
struct amdgpu_cs_ib_info *ib;
- chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
chunks[i].chunk_id = AMDGPU_CHUNK_ID_IB;
chunks[i].length_dw = sizeof(struct drm_amdgpu_cs_chunk_ib) / 4;
chunks[i].chunk_data = (uint64_t)(uintptr_t)&chunk_data[i];
@@ -260,10 +274,9 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
pthread_mutex_lock(&context->sequence_mutex);
if (user_fence) {
- i = cs.in.num_chunks++;
+ i = num_chunks++;
/* fence chunk */
- chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
chunks[i].chunk_id = AMDGPU_CHUNK_ID_FENCE;
chunks[i].length_dw = sizeof(struct drm_amdgpu_cs_chunk_fence) / 4;
chunks[i].chunk_data = (uint64_t)(uintptr_t)&chunk_data[i];
@@ -276,7 +289,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
}
if (ibs_request->number_of_dependencies) {
- dependencies = malloc(sizeof(struct drm_amdgpu_cs_chunk_dep) *
+ dependencies = alloca(sizeof(struct drm_amdgpu_cs_chunk_dep) *
ibs_request->number_of_dependencies);
if (!dependencies) {
r = -ENOMEM;
@@ -293,10 +306,9 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
dep->handle = info->fence;
}
- i = cs.in.num_chunks++;
+ i = num_chunks++;
/* dependencies chunk */
- chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
chunks[i].chunk_id = AMDGPU_CHUNK_ID_DEPENDENCIES;
chunks[i].length_dw = sizeof(struct drm_amdgpu_cs_chunk_dep) / 4
* ibs_request->number_of_dependencies;
@@ -307,7 +319,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
LIST_FOR_EACH_ENTRY(sem, sem_list, list)
sem_count++;
if (sem_count) {
- sem_dependencies = malloc(sizeof(struct drm_amdgpu_cs_chunk_dep) * sem_count);
+ sem_dependencies = alloca(sizeof(struct drm_amdgpu_cs_chunk_dep) * sem_count);
if (!sem_dependencies) {
r = -ENOMEM;
goto error_unlock;
@@ -326,26 +338,23 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,
amdgpu_cs_reset_sem(sem);
amdgpu_cs_unreference_sem(sem);
}
- i = cs.in.num_chunks++;
+ i = num_chunks++;
/* dependencies chunk */
- chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
chunks[i].chunk_id = AMDGPU_CHUNK_ID_DEPENDENCIES;
chunks[i].length_dw = sizeof(struct drm_amdgpu_cs_chunk_dep) / 4 * sem_count;
chunks[i].chunk_data = (uint64_t)(uintptr_t)sem_dependencies;
}
- r = drmCommandWriteRead(context->dev->fd, DRM_AMDGPU_CS,
- &cs, sizeof(cs));
+ r = amdgpu_cs_submit_raw2(dev, context, bo_list_handle, num_chunks,
+ chunks, &seq_no);
if (r)
goto error_unlock;
- ibs_request->seq_no = cs.out.handle;
+ ibs_request->seq_no = seq_no;
context->last_seq[ibs_request->ip_type][ibs_request->ip_instance][ibs_request->ring] = ibs_request->seq_no;
error_unlock:
pthread_mutex_unlock(&context->sequence_mutex);
- free(dependencies);
- free(sem_dependencies);
return r;
}
@@ -721,6 +730,16 @@ drm_public int amdgpu_cs_syncobj_query(amdgpu_device_handle dev,
return drmSyncobjQuery(dev->fd, handles, points, num_handles);
}
+drm_public int amdgpu_cs_syncobj_query2(amdgpu_device_handle dev,
+ uint32_t *handles, uint64_t *points,
+ unsigned num_handles, uint32_t flags)
+{
+ if (!dev)
+ return -EINVAL;
+
+ return drmSyncobjQuery2(dev->fd, handles, points, num_handles, flags);
+}
+
drm_public int amdgpu_cs_export_syncobj(amdgpu_device_handle dev,
uint32_t handle,
int *shared_fd)
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index a340abbd..37a7c9d5 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -102,7 +102,7 @@ struct amdgpu_bo {
pthread_mutex_t cpu_access_mutex;
void *cpu_ptr;
- int cpu_map_count;
+ int64_t cpu_map_count;
};
struct amdgpu_bo_list {
diff --git a/amdgpu/meson.build b/amdgpu/meson.build
index 7c8ccc7e..a1781f59 100644
--- a/amdgpu/meson.build
+++ b/amdgpu/meson.build
@@ -58,8 +58,11 @@ ext_libdrm_amdgpu = declare_dependency(
)
test(
- 'amdgpu-symbol-check',
- prog_bash,
- env : env_test,
- args : [files('amdgpu-symbol-check'), libdrm_amdgpu]
+ 'amdgpu-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm_amdgpu,
+ '--symbols-file', files('amdgpu-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 13d6991e..00000000
--- a/autogen.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#! /bin/sh
-
-srcdir=`dirname "$0"`
-test -z "$srcdir" && srcdir=.
-
-ORIGDIR=`pwd`
-cd "$srcdir"
-
-git config --local --get format.subjectPrefix >/dev/null ||
- git config --local format.subjectPrefix "PATCH libdrm" 2>/dev/null
-
-git config --local --get sendemail.to >/dev/null ||
- git config --local sendemail.to "dri-devel@lists.freedesktop.org" 2>/dev/null
-
-autoreconf --force --verbose --install || exit 1
-cd "$ORIGDIR" || exit $?
-
-if test -z "$NOCONFIGURE"; then
- "$srcdir"/configure "$@"
-fi
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 1cf91347..00000000
--- a/configure.ac
+++ /dev/null
@@ -1,605 +0,0 @@
-# Copyright 2005 Adam Jackson.
-#
-# 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
-# on the rights to use, copy, modify, merge, publish, distribute, sub
-# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-# ADAM JACKSON 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.
-
-AC_PREREQ([2.63])
-AC_INIT([libdrm],
- [2.4.99],
- [https://bugs.freedesktop.org/enter_bug.cgi?product=DRI],
- [libdrm])
-
-AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_SRCDIR([Makefile.am])
-AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_AUX_DIR([build-aux])
-PKG_PROG_PKG_CONFIG
-
-# Require xorg-macros minimum of 1.12 for XORG_WITH_XSLTPROC
-m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.12)
-XORG_WITH_XSLTPROC
-XORG_MANPAGE_SECTIONS
-
-AM_INIT_AUTOMAKE([1.10 foreign dist-bzip2])
-
-# Enable quiet compiles on automake 1.11.
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
-
-# Check for programs
-AC_PROG_CC
-AC_PROG_CC_C99
-AC_PROG_NM
-
-if test "x$ac_cv_prog_cc_c99" = xno; then
- AC_MSG_ERROR([Building libdrm requires C99 enabled compiler])
-fi
-
-AC_USE_SYSTEM_EXTENSIONS
-AC_SYS_LARGEFILE
-AC_FUNC_ALLOCA
-
-save_CFLAGS="$CFLAGS"
-export CFLAGS="$CFLAGS -Werror"
-AC_HEADER_MAJOR
-CFLAGS="$save_CFLAGS"
-
-AC_CHECK_HEADERS([sys/sysctl.h sys/select.h])
-
-# Initialize libtool
-LT_PREREQ([2.2])
-LT_INIT([disable-static])
-
-dnl pthread-stubs is mandatory on some BSD platforms, due to the nature of the
-dnl project. Even then there's a notable issue as described in the project README
-case "$host_os" in
-linux* | cygwin* | darwin* | solaris* | *-gnu* | gnu* | openbsd*)
- pthread_stubs_possible="no"
- ;;
-* )
- pthread_stubs_possible="yes"
- ;;
-esac
-
-if test "x$pthread_stubs_possible" = xyes; then
- PKG_CHECK_MODULES(PTHREADSTUBS, pthread-stubs >= 0.4)
- AC_SUBST(PTHREADSTUBS_CFLAGS)
- AC_SUBST(PTHREADSTUBS_LIBS)
-fi
-
-pkgconfigdir=${libdir}/pkgconfig
-AC_SUBST(pkgconfigdir)
-libdrmdatadir=${datadir}/libdrm
-AC_SUBST(libdrmdatadir)
-
-AC_ARG_ENABLE([udev],
- [AS_HELP_STRING([--enable-udev],
- [Enable support for using udev instead of mknod (default: disabled)])],
- [UDEV=$enableval], [UDEV=no])
-
-AC_ARG_ENABLE(libkms,
- AS_HELP_STRING([--disable-libkms],
- [Disable KMS mm abstraction library (default: auto, enabled on supported platforms)]),
- [LIBKMS=$enableval], [LIBKMS=auto])
-
-AC_ARG_ENABLE(intel,
- AS_HELP_STRING([--disable-intel],
- [Enable support for intel's KMS API (default: auto, enabled on x86)]),
- [INTEL=$enableval], [INTEL=auto])
-
-AC_ARG_ENABLE(radeon,
- AS_HELP_STRING([--disable-radeon],
- [Enable support for radeon's KMS API (default: auto)]),
- [RADEON=$enableval], [RADEON=auto])
-
-AC_ARG_ENABLE(amdgpu,
- AS_HELP_STRING([--disable-amdgpu],
- [Enable support for amdgpu's KMS API (default: auto)]),
- [AMDGPU=$enableval], [AMDGPU=auto])
-
-AC_ARG_ENABLE(nouveau,
- AS_HELP_STRING([--disable-nouveau],
- [Enable support for nouveau's KMS API (default: auto)]),
- [NOUVEAU=$enableval], [NOUVEAU=auto])
-
-AC_ARG_ENABLE(vmwgfx,
- AS_HELP_STRING([--disable-vmwgfx],
- [Enable support for vmwgfx's KMS API (default: yes)]),
- [VMWGFX=$enableval], [VMWGFX=yes])
-
-AC_ARG_ENABLE(omap-experimental-api,
- AS_HELP_STRING([--enable-omap-experimental-api],
- [Enable support for OMAP's experimental API (default: disabled)]),
- [OMAP=$enableval], [OMAP=no])
-
-AC_ARG_ENABLE(exynos-experimental-api,
- AS_HELP_STRING([--enable-exynos-experimental-api],
- [Enable support for EXYNOS's experimental API (default: disabled)]),
- [EXYNOS=$enableval], [EXYNOS=no])
-
-AC_ARG_ENABLE(freedreno,
- AS_HELP_STRING([--disable-freedreno],
- [Enable support for freedreno's KMS API (default: auto, enabled on arm)]),
- [FREEDRENO=$enableval], [FREEDRENO=auto])
-
-AC_ARG_ENABLE(freedreno-kgsl,
- AS_HELP_STRING([--enable-freedreno-kgsl],
- [Enable support for freedreno's to use downstream android kernel API (default: disabled)]),
- [FREEDRENO_KGSL=$enableval], [FREEDRENO_KGSL=no])
-
-AC_ARG_ENABLE(tegra-experimental-api,
- AS_HELP_STRING([--enable-tegra-experimental-api],
- [Enable support for Tegra's experimental API (default: disabled)]),
- [TEGRA=$enableval], [TEGRA=no])
-
-AC_ARG_ENABLE(vc4,
- AS_HELP_STRING([--disable-vc4],
- [Enable support for vc4's API (default: auto, enabled on arm)]),
- [VC4=$enableval], [VC4=auto])
-
-AC_ARG_ENABLE(etnaviv-experimental-api,
- AS_HELP_STRING([--enable-etnaviv-experimental-api],
- [Enable support for etnaviv's experimental API (default: disabled)]),
- [ETNAVIV=$enableval], [ETNAVIV=no])
-
-AC_ARG_ENABLE(install-test-programs,
- AS_HELP_STRING([--enable-install-test-programs],
- [Install test programs (default: no)]),
- [INSTALL_TESTS=$enableval], [INSTALL_TESTS=no])
-
-dnl ===========================================================================
-dnl check compiler flags
-AC_DEFUN([LIBDRM_CC_TRY_FLAG], [
- AC_MSG_CHECKING([whether $CC supports $1])
-
- libdrm_save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $1"
-
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([ ])], [libdrm_cc_flag=yes], [libdrm_cc_flag=no])
- CFLAGS="$libdrm_save_CFLAGS"
-
- if test "x$libdrm_cc_flag" = "xyes"; then
- ifelse([$2], , :, [$2])
- else
- ifelse([$3], , :, [$3])
- fi
- AC_MSG_RESULT([$libdrm_cc_flag])
-])
-
-dnl We use clock_gettime to check for timeouts in drmWaitVBlank
-
-AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=],
- [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt],
- [AC_MSG_ERROR([Couldn't find clock_gettime])])])
-AC_SUBST([CLOCK_LIB])
-
-AC_CHECK_FUNCS([open_memstream],
- [AC_DEFINE([HAVE_OPEN_MEMSTREAM], 1, [Have open_memstream()])],
- [AC_DEFINE([HAVE_OPEN_MEMSTREAM], 0)])
-
-dnl Use lots of warning flags with with gcc and compatible compilers
-
-dnl Note: if you change the following variable, the cache is automatically
-dnl skipped and all flags rechecked. So there's no need to do anything
-dnl else. If for any reason you need to force a recheck, just change
-dnl MAYBE_WARN in an ignorable way (like adding whitespace)
-
-MAYBE_WARN="-Wall -Wextra -Werror=undef \
--Wsign-compare -Werror-implicit-function-declaration \
--Wpointer-arith -Wwrite-strings -Wstrict-prototypes \
--Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
--Wpacked -Wswitch-enum -Wmissing-format-attribute \
--Wstrict-aliasing=2 -Winit-self \
--Wdeclaration-after-statement -Wold-style-definition \
--Wno-unused-parameter \
--Wno-attributes -Wno-long-long -Winline -Wshadow \
--Wno-missing-field-initializers"
-
-# invalidate cached value if MAYBE_WARN has changed
-if test "x$libdrm_cv_warn_maybe" != "x$MAYBE_WARN"; then
- unset libdrm_cv_warn_cflags
-fi
-AC_CACHE_CHECK([for supported warning flags], libdrm_cv_warn_cflags, [
- echo
- WARN_CFLAGS=""
-
- # Some warning options are not supported by all versions of
- # gcc, so test all desired options against the current
- # compiler.
- #
- # Note that there are some order dependencies
- # here. Specifically, an option that disables a warning will
- # have no net effect if a later option then enables that
- # warnings, (perhaps implicitly). So we put some grouped
- # options (-Wall and -Wextra) up front and the -Wno options
- # last.
-
- for W in $MAYBE_WARN; do
- LIBDRM_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
- done
-
- libdrm_cv_warn_cflags=$WARN_CFLAGS
- libdrm_cv_warn_maybe=$MAYBE_WARN
-
- AC_MSG_CHECKING([which warning flags were supported])])
-WARN_CFLAGS="$libdrm_cv_warn_cflags"
-
-# Check for atomic intrinsics
-AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives, [
- drm_cv_atomic_primitives="none"
-
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[
- int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
- int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }
- ]],[[]])], [drm_cv_atomic_primitives="Intel"],[])
-
- if test "x$drm_cv_atomic_primitives" = "xnone"; then
- AC_CHECK_HEADER([atomic_ops.h], drm_cv_atomic_primitives="libatomic-ops")
- fi
-
- # atomic functions defined in <atomic.h> & libc on Solaris
- if test "x$drm_cv_atomic_primitives" = "xnone"; then
- AC_CHECK_FUNC([atomic_cas_uint], drm_cv_atomic_primitives="Solaris")
- fi
-])
-
-if test "x$drm_cv_atomic_primitives" = xIntel; then
- AC_DEFINE(HAVE_LIBDRM_ATOMIC_PRIMITIVES, 1,
- [Enable if your compiler supports the Intel __sync_* atomic primitives])
-else
- AC_DEFINE(HAVE_LIBDRM_ATOMIC_PRIMITIVES, 0)
-fi
-if test "x$drm_cv_atomic_primitives" = "xlibatomic-ops"; then
- AC_DEFINE(HAVE_LIB_ATOMIC_OPS, 1, [Enable if you have libatomic-ops-dev installed])
-else
- AC_DEFINE(HAVE_LIB_ATOMIC_OPS, 0)
-fi
-
-dnl Print out the approapriate message considering the value set be the
-dnl respective in $1.
-dnl $1 - value to be evaluated. Eg. $INTEL, $NOUVEAU, ...
-dnl $2 - libdrm shortname. Eg. intel, freedreno, ...
-dnl $3 - GPU name/brand. Eg. Intel, NVIDIA Tegra, ...
-dnl $4 - Configure switch. Eg. intel, omap-experimental-api, ...
-AC_DEFUN([LIBDRM_ATOMICS_NOT_FOUND_MSG], [
- case "x$1" in
- xyes) AC_MSG_ERROR([libdrm_$2 depends upon atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package, or, failing both of those, disable support for $3 GPUs by passing --disable-$4 to ./configure]) ;;
- xauto) AC_MSG_WARN([Disabling $2. It depends on atomic operations, which were not found for your compiler/cpu. Try compiling with -march=native, or install the libatomics-op-dev package.]) ;;
- *) ;;
- esac
-])
-
-if test "x$drm_cv_atomic_primitives" = "xnone"; then
- LIBDRM_ATOMICS_NOT_FOUND_MSG($INTEL, intel, Intel, intel)
- INTEL=no
-
- LIBDRM_ATOMICS_NOT_FOUND_MSG($RADEON, radeon, Radeon, radeon)
- RADEON=no
-
- LIBDRM_ATOMICS_NOT_FOUND_MSG($AMDGPU, amdgpu, AMD, amdgpu)
- AMDGPU=no
-
- LIBDRM_ATOMICS_NOT_FOUND_MSG($NOUVEAU, nouveau, NVIDIA, nouveau)
- NOUVEAU=no
-
- LIBDRM_ATOMICS_NOT_FOUND_MSG($OMAP, omap, OMAP, omap-experimental-api)
- OMAP=no
-
- LIBDRM_ATOMICS_NOT_FOUND_MSG($FREEDRENO, freedreno, Qualcomm Adreno, freedreno)
- FREEDRENO=no
-
- LIBDRM_ATOMICS_NOT_FOUND_MSG($TEGRA, tegra, NVIDIA Tegra, tegra-experimental-api)
- TEGRA=no
-
- LIBDRM_ATOMICS_NOT_FOUND_MSG($ETNAVIV, etnaviv, Vivante, etnaviv-experimental-api)
- ETNAVIV=no
-else
- if test "x$INTEL" = xauto; then
- case $host_cpu in
- i?86|x86_64) INTEL=yes ;;
- *) INTEL=no ;;
- esac
- fi
- if test "x$RADEON" = xauto; then
- RADEON=yes
- fi
- if test "x$AMDGPU" = xauto; then
- AMDGPU=yes
- fi
- if test "x$NOUVEAU" = xauto; then
- NOUVEAU=yes
- fi
- if test "x$FREEDRENO" = xauto; then
- case $host_cpu in
- arm*|aarch64) FREEDRENO=yes ;;
- *) FREEDRENO=no ;;
- esac
- fi
- if test "x$VC4" = xauto; then
- case $host_cpu in
- arm*|aarch64) VC4=yes ;;
- *) VC4=no ;;
- esac
- fi
-fi
-
-if test "x$INTEL" != "xno"; then
- PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
-fi
-AC_SUBST(PCIACCESS_CFLAGS)
-AC_SUBST(PCIACCESS_LIBS)
-
-if test "x$UDEV" = xyes; then
- AC_DEFINE(UDEV, 1, [Have UDEV support])
-else
- AC_DEFINE(UDEV, 0)
-fi
-
-AC_CANONICAL_HOST
-if test "x$LIBKMS" = xauto ; then
- case $host_os in
- linux*) LIBKMS="yes" ;;
- freebsd* | kfreebsd*-gnu)
- LIBKMS="yes" ;;
- dragonfly*) LIBKMS="yes" ;;
- *) LIBKMS="no" ;;
- esac
-fi
-
-AM_CONDITIONAL(HAVE_LIBKMS, [test "x$LIBKMS" = xyes])
-
-AM_CONDITIONAL(HAVE_INTEL, [test "x$INTEL" = xyes])
-if test "x$INTEL" = xyes; then
- AC_DEFINE(HAVE_INTEL, 1, [Have intel support])
-else
- AC_DEFINE(HAVE_INTEL, 0)
-fi
-
-AM_CONDITIONAL(HAVE_VMWGFX, [test "x$VMWGFX" = xyes])
-if test "x$VMWGFX" = xyes; then
- AC_DEFINE(HAVE_VMWGFX, 1, [Have vmwgfx kernel headers])
-else
- AC_DEFINE(HAVE_VMWGFX, 0)
-fi
-
-AM_CONDITIONAL(HAVE_NOUVEAU, [test "x$NOUVEAU" = xyes])
-if test "x$NOUVEAU" = xyes; then
- AC_DEFINE(HAVE_NOUVEAU, 1, [Have nouveau (nvidia) support])
-else
- AC_DEFINE(HAVE_NOUVEAU, 0)
-fi
-
-AM_CONDITIONAL(HAVE_OMAP, [test "x$OMAP" = xyes])
-
-AM_CONDITIONAL(HAVE_EXYNOS, [test "x$EXYNOS" = xyes])
-if test "x$EXYNOS" = xyes; then
- AC_DEFINE(HAVE_EXYNOS, 1, [Have EXYNOS support])
-else
- AC_DEFINE(HAVE_EXYNOS, 0)
-fi
-
-AM_CONDITIONAL(HAVE_FREEDRENO, [test "x$FREEDRENO" = xyes])
-
-if test "x$FREEDRENO_KGSL" = xyes; then
- if test "x$FREEDRENO" != xyes; then
- AC_MSG_ERROR([Cannot enable freedreno KGSL interface if freedreno is disabled])
- fi
-fi
-AM_CONDITIONAL(HAVE_FREEDRENO_KGSL, [test "x$FREEDRENO_KGSL" = xyes])
-if test "x$FREEDRENO_KGSL" = xyes; then
- AC_DEFINE(HAVE_FREEDRENO_KGSL, 1, [Have freedreno support for KGSL kernel interface])
-else
- AC_DEFINE(HAVE_FREEDRENO_KGSL, 0)
-fi
-
-AM_CONDITIONAL(HAVE_RADEON, [test "x$RADEON" = xyes])
-if test "x$RADEON" = xyes; then
- AC_DEFINE(HAVE_RADEON, 1, [Have radeon support])
-else
- AC_DEFINE(HAVE_RADEON, 0)
-fi
-
-if test "x$AMDGPU" != xno; then
- # Detect cunit library
- PKG_CHECK_MODULES([CUNIT], [cunit >= 2.1], [have_cunit=yes], [have_cunit=no])
- # If pkg-config does not find cunit, check it using AC_CHECK_LIB. We
- # do this because Debian (Ubuntu) lacks pkg-config file for cunit.
- # fixed in 2.1-2.dfsg-3: http://anonscm.debian.org/cgit/collab-maint/cunit.git/commit/?h=debian
- if test "x${have_cunit}" = "xno"; then
- AC_CHECK_LIB([cunit], [CU_initialize_registry], [have_cunit=yes], [have_cunit=no])
- if test "x${have_cunit}" = "xyes"; then
- CUNIT_LIBS="-lcunit"
- CUNIT_CFLAGS=""
- AC_SUBST([CUNIT_LIBS])
- AC_SUBST([CUNIT_CFLAGS])
- fi
- fi
-else
- have_cunit=no
-fi
-AM_CONDITIONAL(HAVE_CUNIT, [test "x$have_cunit" != "xno"])
-
-AM_CONDITIONAL(HAVE_AMDGPU, [test "x$AMDGPU" = xyes])
-if test "x$AMDGPU" = xyes; then
- AC_DEFINE(HAVE_AMDGPU, 1, [Have amdgpu support])
-
- if test "x$have_cunit" = "xno"; then
- AC_MSG_WARN([Could not find cunit library. Disabling amdgpu tests])
- fi
-else
- AC_DEFINE(HAVE_AMDGPU, 0)
-fi
-
-AM_CONDITIONAL(HAVE_TEGRA, [test "x$TEGRA" = xyes])
-
-AM_CONDITIONAL(HAVE_VC4, [test "x$VC4" = xyes])
-if test "x$VC4" = xyes; then
- AC_DEFINE(HAVE_VC4, 1, [Have VC4 support])
-else
- AC_DEFINE(HAVE_VC4, 0)
-fi
-
-AM_CONDITIONAL(HAVE_ETNAVIV, [test "x$ETNAVIV" = xyes])
-
-AM_CONDITIONAL(HAVE_INSTALL_TESTS, [test "x$INSTALL_TESTS" = xyes])
-
-AC_ARG_ENABLE([cairo-tests],
- [AS_HELP_STRING([--enable-cairo-tests],
- [Enable support for Cairo rendering in tests (default: auto)])],
- [CAIRO=$enableval], [CAIRO=auto])
-if test "x$CAIRO" != xno; then
- PKG_CHECK_MODULES(CAIRO, cairo, [HAVE_CAIRO=yes], [HAVE_CAIRO=no])
-fi
-AC_MSG_CHECKING([whether to enable Cairo tests])
-if test "x$CAIRO" = xauto; then
- CAIRO="$HAVE_CAIRO"
-fi
-if test "x$CAIRO" = xyes; then
- if ! test "x$HAVE_CAIRO" = xyes; then
- AC_MSG_ERROR([Cairo support required but not present])
- fi
- AC_DEFINE(HAVE_CAIRO, 1, [Have Cairo support])
-else
- AC_DEFINE(HAVE_CAIRO, 0)
-fi
-AC_MSG_RESULT([$CAIRO])
-AM_CONDITIONAL(HAVE_CAIRO, [test "x$CAIRO" = xyes])
-
-# xsltproc for docbook manpages
-AC_ARG_ENABLE([manpages],
- AS_HELP_STRING([--enable-manpages], [enable manpages @<:@default=auto@:>@]),
- [MANS=$enableval], [MANS=auto])
-AM_CONDITIONAL([BUILD_MANPAGES], [test "x$XSLTPROC" != "x" -a "x$MANS" != "xno"])
-
-# check for offline man-pages stylesheet
-AC_MSG_CHECKING([for docbook manpages stylesheet])
-MANPAGES_STYLESHEET="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
-AC_PATH_PROGS_FEATURE_CHECK([XSLTPROC_TMP], [xsltproc],
- AS_IF([`"$ac_path_XSLTPROC_TMP" --nonet "$MANPAGES_STYLESHEET" > /dev/null 2>&1`],
- [HAVE_MANPAGES_STYLESHEET=yes]))
-if test "x$HAVE_MANPAGES_STYLESHEET" = "xyes"; then
- AC_SUBST(MANPAGES_STYLESHEET)
- AC_MSG_RESULT([yes])
-else
- AC_MSG_RESULT([no])
-fi
-AM_CONDITIONAL([HAVE_MANPAGES_STYLESHEET], [test "x$HAVE_MANPAGES_STYLESHEET" = "xyes"])
-
-AC_ARG_ENABLE(valgrind,
- [AS_HELP_STRING([--enable-valgrind],
- [Build libdrm with valgrind support (default: auto)])],
- [VALGRIND=$enableval], [VALGRIND=auto])
-if test "x$VALGRIND" != xno; then
- PKG_CHECK_MODULES(VALGRIND, [valgrind], [have_valgrind=yes], [have_valgrind=no])
-fi
-AC_MSG_CHECKING([whether to enable Valgrind support])
-if test "x$VALGRIND" = xauto; then
- VALGRIND="$have_valgrind"
-fi
-
-if test "x$VALGRIND" = "xyes"; then
- if ! test "x$have_valgrind" = xyes; then
- AC_MSG_ERROR([Valgrind support required but not present])
- fi
- AC_DEFINE([HAVE_VALGRIND], 1, [Use valgrind intrinsics to suppress false warnings])
-else
- AC_DEFINE([HAVE_VALGRIND], 0)
-fi
-
-AC_MSG_RESULT([$VALGRIND])
-
-AC_ARG_WITH([kernel-source],
- [AS_HELP_STRING([--with-kernel-source],
- [specify path to linux kernel source])],
- [kernel_source="$with_kernel_source"])
-AC_SUBST(kernel_source)
-
-AC_MSG_CHECKING([whether $CC supports __attribute__(("hidden"))])
-AC_LINK_IFELSE([AC_LANG_PROGRAM([
- int foo_hidden( void ) __attribute__((visibility("hidden")));
-])], HAVE_ATTRIBUTE_VISIBILITY="yes"; AC_MSG_RESULT([yes]), AC_MSG_RESULT([no]));
-
-if test "x$HAVE_ATTRIBUTE_VISIBILITY" = xyes; then
- AC_DEFINE(HAVE_VISIBILITY, 1, [Compiler supports __attribute__(("hidden"))])
-else
- AC_DEFINE(HAVE_VISIBILITY, 0)
-fi
-
-CPPFLAGS="$CPPFLAGS -include config.h"
-
-AC_SUBST(WARN_CFLAGS)
-AC_CONFIG_FILES([
- Makefile
- data/Makefile
- libkms/Makefile
- libkms/libkms.pc
- intel/Makefile
- intel/libdrm_intel.pc
- radeon/Makefile
- radeon/libdrm_radeon.pc
- amdgpu/Makefile
- amdgpu/libdrm_amdgpu.pc
- nouveau/Makefile
- nouveau/libdrm_nouveau.pc
- omap/Makefile
- omap/libdrm_omap.pc
- exynos/Makefile
- exynos/libdrm_exynos.pc
- freedreno/Makefile
- freedreno/libdrm_freedreno.pc
- tegra/Makefile
- tegra/libdrm_tegra.pc
- vc4/Makefile
- vc4/libdrm_vc4.pc
- etnaviv/Makefile
- etnaviv/libdrm_etnaviv.pc
- tests/Makefile
- tests/modeprint/Makefile
- tests/modetest/Makefile
- tests/kms/Makefile
- tests/kmstest/Makefile
- tests/proptest/Makefile
- tests/radeon/Makefile
- tests/amdgpu/Makefile
- tests/vbltest/Makefile
- tests/exynos/Makefile
- tests/tegra/Makefile
- tests/nouveau/Makefile
- tests/etnaviv/Makefile
- tests/util/Makefile
- man/Makefile
- libdrm.pc])
-AC_OUTPUT
-
-echo ""
-echo "$PACKAGE_STRING will be compiled with:"
-echo ""
-echo " libkms $LIBKMS"
-echo " Intel API $INTEL"
-echo " vmwgfx API $VMWGFX"
-echo " Radeon API $RADEON"
-echo " AMDGPU API $AMDGPU"
-echo " Nouveau API $NOUVEAU"
-echo " OMAP API $OMAP"
-echo " EXYNOS API $EXYNOS"
-echo " Freedreno API $FREEDRENO (kgsl: $FREEDRENO_KGSL)"
-echo " Tegra API $TEGRA"
-echo " VC4 API $VC4"
-echo " Etnaviv API $ETNAVIV"
-echo ""
diff --git a/core-symbols.txt b/core-symbols.txt
new file mode 100644
index 00000000..1ff4ecaa
--- /dev/null
+++ b/core-symbols.txt
@@ -0,0 +1,197 @@
+drmAddBufs
+drmAddContextPrivateMapping
+drmAddContextTag
+drmAddMap
+drmAgpAcquire
+drmAgpAlloc
+drmAgpBase
+drmAgpBind
+drmAgpDeviceId
+drmAgpEnable
+drmAgpFree
+drmAgpGetMode
+drmAgpMemoryAvail
+drmAgpMemoryUsed
+drmAgpRelease
+drmAgpSize
+drmAgpUnbind
+drmAgpVendorId
+drmAgpVersionMajor
+drmAgpVersionMinor
+drmAuthMagic
+drmAvailable
+drmCheckModesettingSupported
+drmClose
+drmCloseOnce
+drmCommandNone
+drmCommandRead
+drmCommandWrite
+drmCommandWriteRead
+drmCreateContext
+drmCreateDrawable
+drmCrtcGetSequence
+drmCrtcQueueSequence
+drmCtlInstHandler
+drmCtlUninstHandler
+drmDelContextTag
+drmDestroyContext
+drmDestroyDrawable
+drmDevicesEqual
+drmDMA
+drmDropMaster
+drmError
+drmFinish
+drmFree
+drmFreeBufs
+drmFreeBusid
+drmFreeDevice
+drmFreeDevices
+drmFreeReservedContextList
+drmFreeVersion
+drmGetBufInfo
+drmGetBusid
+drmGetCap
+drmGetClient
+drmGetContextFlags
+drmGetContextPrivateMapping
+drmGetContextTag
+drmGetDevice
+drmGetDevice2
+drmGetDeviceNameFromFd
+drmGetDeviceNameFromFd2
+drmGetDevices
+drmGetDevices2
+drmGetEntry
+drmGetHashTable
+drmGetInterruptFromBusID
+drmGetLibVersion
+drmGetLock
+drmGetMagic
+drmGetMap
+drmGetNodeTypeFromFd
+drmGetPrimaryDeviceNameFromFd
+drmGetRenderDeviceNameFromFd
+drmGetReservedContextList
+drmGetStats
+drmGetVersion
+drmHandleEvent
+drmHashCreate
+drmHashDelete
+drmHashDestroy
+drmHashFirst
+drmHashInsert
+drmHashLookup
+drmHashNext
+drmIoctl
+drmIsMaster
+drmMalloc
+drmMap
+drmMapBufs
+drmMarkBufs
+drmModeAddFB
+drmModeAddFB2
+drmModeAddFB2WithModifiers
+drmModeAtomicAddProperty
+drmModeAtomicAlloc
+drmModeAtomicCommit
+drmModeAtomicDuplicate
+drmModeAtomicFree
+drmModeAtomicGetCursor
+drmModeAtomicMerge
+drmModeAtomicSetCursor
+drmModeAttachMode
+drmModeConnectorSetProperty
+drmModeCreateLease
+drmModeCreatePropertyBlob
+drmModeCrtcGetGamma
+drmModeCrtcSetGamma
+drmModeDestroyPropertyBlob
+drmModeDetachMode
+drmModeDirtyFB
+drmModeFreeConnector
+drmModeFreeCrtc
+drmModeFreeEncoder
+drmModeFreeFB
+drmModeFreeFB2
+drmModeFreeModeInfo
+drmModeFreeObjectProperties
+drmModeFreePlane
+drmModeFreePlaneResources
+drmModeFreeProperty
+drmModeFreePropertyBlob
+drmModeFreeResources
+drmModeGetConnector
+drmModeGetConnectorCurrent
+drmModeGetCrtc
+drmModeGetEncoder
+drmModeGetFB
+drmModeGetFB2
+drmModeGetLease
+drmModeGetPlane
+drmModeGetPlaneResources
+drmModeGetProperty
+drmModeGetPropertyBlob
+drmModeGetResources
+drmModeListLessees
+drmModeMoveCursor
+drmModeObjectGetProperties
+drmModeObjectSetProperty
+drmModePageFlip
+drmModePageFlipTarget
+drmModeRevokeLease
+drmModeRmFB
+drmModeSetCrtc
+drmModeSetCursor
+drmModeSetCursor2
+drmModeSetPlane
+drmMsg
+drmOpen
+drmOpenControl
+drmOpenOnce
+drmOpenOnceWithType
+drmOpenRender
+drmOpenWithType
+drmPrimeFDToHandle
+drmPrimeHandleToFD
+drmRandom
+drmRandomCreate
+drmRandomDestroy
+drmRandomDouble
+drmRmMap
+drmScatterGatherAlloc
+drmScatterGatherFree
+drmSetBusid
+drmSetClientCap
+drmSetContextFlags
+drmSetInterfaceVersion
+drmSetMaster
+drmSetServerInfo
+drmSLCreate
+drmSLDelete
+drmSLDestroy
+drmSLDump
+drmSLFirst
+drmSLInsert
+drmSLLookup
+drmSLLookupNeighbors
+drmSLNext
+drmSwitchToContext
+drmSyncobjCreate
+drmSyncobjDestroy
+drmSyncobjExportSyncFile
+drmSyncobjFDToHandle
+drmSyncobjHandleToFD
+drmSyncobjImportSyncFile
+drmSyncobjQuery
+drmSyncobjQuery2
+drmSyncobjReset
+drmSyncobjSignal
+drmSyncobjTimelineSignal
+drmSyncobjTimelineWait
+drmSyncobjTransfer
+drmSyncobjWait
+drmUnlock
+drmUnmap
+drmUnmapBufs
+drmUpdateDrawableInfo
+drmWaitVBlank
diff --git a/data/Makefile.am b/data/Makefile.am
deleted file mode 100644
index 897a7f35..00000000
--- a/data/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright © 2017 Advanced Micro Devices, Inc.
-# 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
-# on the rights to use, copy, modify, merge, publish, distribute, sub
-# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-# ADAM JACKSON 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.
-
-libdrmdatadir = @libdrmdatadir@
-if HAVE_AMDGPU
-dist_libdrmdata_DATA = amdgpu.ids
-endif
diff --git a/data/amdgpu.ids b/data/amdgpu.ids
index f61497e4..6fc6858b 100644
--- a/data/amdgpu.ids
+++ b/data/amdgpu.ids
@@ -140,6 +140,7 @@
6860, 02, Radeon Instinct MI25
6860, 03, Radeon Pro V340
6860, 04, Radeon Instinct MI25x2
+6860, 07, Radeon (TM) Pro V320
6861, 00, Radeon Pro WX 9100
6862, 00, Radeon Pro SSG
6863, 00, Radeon Vega Frontier Edition
@@ -174,6 +175,9 @@
6939, 0, AMD Radeon R9 200 Series
6939, F1, AMD Radeon (TM) R9 380 Series
6980, 00, Radeon Pro WX3100
+6981, 00, AMD Radeon (TM) Pro WX 3200 Series
+6981, 01, AMD Radeon (TM) Pro WX 3200 Series
+6981, 10, AMD Radeon (TM) Pro WX 3200 Series
6985, 00, AMD Radeon Pro WX3100
6987, 80, AMD Embedded Radeon E9171
6987, C0, Radeon 550X Series
@@ -184,12 +188,26 @@
699F, C0, Radeon 500 Series
699F, C1, Radeon 540 Series
699F, C3, Radeon 500 Series
-699F, C7, Radeon 550 Series
+699F, C7, Radeon RX550/550 Series
7300, C1, AMD FirePro (TM) S9300 x2
7300, C8, AMD Radeon (TM) R9 Fury Series
7300, C9, Radeon (TM) Pro Duo
7300, CB, AMD Radeon (TM) R9 Fury Series
7300, CA, AMD Radeon (TM) R9 Fury Series
+7312, 00, AMD Radeon Pro W5700
+731F, C0, AMD Radeon RX 5700 XT 50th Anniversary
+731F, C1, AMD Radeon RX 5700 XT
+731F, C2, AMD Radeon RX 5600M
+731F, C3, AMD Radeon RX 5700M
+731F, C4, AMD Radeon RX 5700
+731F, C5, AMD Radeon RX 5700 XT
+731F, CA, AMD Radeon RX 5600 XT
+731F, CB, AMD Radeon RX 5600 OEM
+7340, C1, Radeon RX 5500M
+7340, C5, Radeon RX 5500 XT
+7340, C7, Radeon RX 5500
+7341, 00, AMD Radeon Pro W5500
+7347, 00, AMD Radeon Pro W5500M
9874, C4, AMD Radeon R7 Graphics
9874, C5, AMD Radeon R6 Graphics
9874, C6, AMD Radeon R6 Graphics
diff --git a/etnaviv/Makefile.am b/etnaviv/Makefile.am
deleted file mode 100644
index 648e3c5b..00000000
--- a/etnaviv/Makefile.am
+++ /dev/null
@@ -1,28 +0,0 @@
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_etnaviv_ladir = $(libdir)
-libdrm_etnaviv_la_LTLIBRARIES = libdrm_etnaviv.la
-libdrm_etnaviv_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_etnaviv_la_LIBADD = \
- ../libdrm.la \
- @PTHREADSTUBS_LIBS@ \
- @CLOCK_LIB@
-
-libdrm_etnaviv_la_SOURCES = $(LIBDRM_ETNAVIV_FILES)
-
-libdrm_etnavivincludedir = ${includedir}/libdrm
-libdrm_etnavivinclude_HEADERS = $(LIBDRM_ETNAVIV_H_FILES)
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_etnaviv.pc
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = etnaviv-symbol-check
-EXTRA_DIST = $(TESTS)
diff --git a/etnaviv/etnaviv-symbol-check b/etnaviv/etnaviv-symbols.txt
index 6f6a7a28..f48cecea 100755..100644
--- a/etnaviv/etnaviv-symbol-check
+++ b/etnaviv/etnaviv-symbols.txt
@@ -1,17 +1,3 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first five) are taken from the public headers.
-# A list of the latter should be available Makefile.sources/LIBDRM_ETNAVIV_H_FILES
-
-FUNCS=$(nm -D --format=bsd --defined-only ${1-.libs/libdrm_etnaviv.so} | awk '{print $3}'| while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_start
-_edata
-_end
-_fini
-_init
etna_device_new
etna_device_new_dup
etna_device_ref
@@ -48,8 +34,3 @@ etna_perfmon_create
etna_perfmon_del
etna_perfmon_get_dom_by_name
etna_perfmon_get_sig_by_name
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/etnaviv/meson.build b/etnaviv/meson.build
index 515a4ed0..6040cf63 100644
--- a/etnaviv/meson.build
+++ b/etnaviv/meson.build
@@ -53,7 +53,11 @@ ext_libdrm_etnaviv = declare_dependency(
)
test(
- 'etnaviv-symbol-check',
- prog_bash,
- args : [files('etnaviv-symbol-check'), libdrm_etnaviv]
+ 'etnaviv-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm_etnaviv,
+ '--symbols-file', files('etnaviv-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/exynos/Makefile.am b/exynos/Makefile.am
deleted file mode 100644
index 76b185d3..00000000
--- a/exynos/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_exynos_la_LTLIBRARIES = libdrm_exynos.la
-libdrm_exynos_ladir = $(libdir)
-libdrm_exynos_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_exynos_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-
-libdrm_exynos_la_SOURCES = \
- exynos_drm.c \
- exynos_fimg2d.c \
- fimg2d_reg.h
-
-libdrm_exynoscommonincludedir = ${includedir}/exynos
-libdrm_exynoscommoninclude_HEADERS = exynos_drm.h exynos_fimg2d.h
-
-libdrm_exynosincludedir = ${includedir}/libdrm
-libdrm_exynosinclude_HEADERS = exynos_drmif.h
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_exynos.pc
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = exynos-symbol-check
-EXTRA_DIST = $(TESTS)
diff --git a/exynos/exynos-symbol-check b/exynos/exynos-symbol-check
deleted file mode 100755
index 49d611e6..00000000
--- a/exynos/exynos-symbol-check
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first five) are taken from the public headers.
-# A list of the latter should be available Makefile.am/libdrm_exynos*_HEADERS
-
-FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libdrm_exynos.so} | awk '{print $3}'| while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_start
-_edata
-_end
-_fini
-_init
-exynos_bo_create
-exynos_bo_destroy
-exynos_bo_from_name
-exynos_bo_get_info
-exynos_bo_get_name
-exynos_bo_handle
-exynos_bo_map
-exynos_device_create
-exynos_device_destroy
-exynos_prime_fd_to_handle
-exynos_prime_handle_to_fd
-exynos_vidi_connection
-exynos_handle_event
-g2d_blend
-g2d_copy
-g2d_copy_with_scale
-g2d_exec
-g2d_config_event
-g2d_fini
-g2d_init
-g2d_move
-g2d_scale_and_blend
-g2d_solid_fill
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/exynos/exynos-symbols.txt b/exynos/exynos-symbols.txt
new file mode 100644
index 00000000..c6748414
--- /dev/null
+++ b/exynos/exynos-symbols.txt
@@ -0,0 +1,23 @@
+exynos_bo_create
+exynos_bo_destroy
+exynos_bo_from_name
+exynos_bo_get_info
+exynos_bo_get_name
+exynos_bo_handle
+exynos_bo_map
+exynos_device_create
+exynos_device_destroy
+exynos_prime_fd_to_handle
+exynos_prime_handle_to_fd
+exynos_vidi_connection
+exynos_handle_event
+g2d_blend
+g2d_copy
+g2d_copy_with_scale
+g2d_exec
+g2d_config_event
+g2d_fini
+g2d_init
+g2d_move
+g2d_scale_and_blend
+g2d_solid_fill
diff --git a/exynos/meson.build b/exynos/meson.build
index bdfc3fc6..40d66fc1 100644
--- a/exynos/meson.build
+++ b/exynos/meson.build
@@ -47,8 +47,11 @@ pkg.generate(
)
test(
- 'exynos-symbol-check',
- prog_bash,
- env : env_test,
- args : [files('exynos-symbol-check'), libdrm_exynos]
+ 'exynos-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm_exynos,
+ '--symbols-file', files('exynos-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/freedreno/Makefile.am b/freedreno/Makefile.am
deleted file mode 100644
index 37845035..00000000
--- a/freedreno/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-AUTOMAKE_OPTIONS=subdir-objects
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- $(VALGRIND_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_freedreno_la_LTLIBRARIES = libdrm_freedreno.la
-libdrm_freedreno_ladir = $(libdir)
-libdrm_freedreno_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_freedreno_la_LIBADD = \
- ../libdrm.la \
- @PTHREADSTUBS_LIBS@ \
- @CLOCK_LIB@
-
-libdrm_freedreno_la_SOURCES = $(LIBDRM_FREEDRENO_FILES)
-if HAVE_FREEDRENO_KGSL
-libdrm_freedreno_la_SOURCES += $(LIBDRM_FREEDRENO_KGSL_FILES)
-endif
-
-libdrm_freedrenocommonincludedir = ${includedir}/freedreno
-libdrm_freedrenocommoninclude_HEADERS = $(LIBDRM_FREEDRENO_H_FILES)
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_freedreno.pc
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = freedreno-symbol-check
-EXTRA_DIST = $(TESTS)
diff --git a/freedreno/freedreno-symbol-check b/freedreno/freedreno-symbols.txt
index 978026c0..471ca997 100755..100644
--- a/freedreno/freedreno-symbol-check
+++ b/freedreno/freedreno-symbols.txt
@@ -1,17 +1,3 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first five) are taken from the public headers.
-# A list of the latter should be available Makefile.sources/LIBDRM_FREEDRENO_H_FILES
-
-FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libdrm_freedreno.so} | awk '{print $3}'| while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_start
-_edata
-_end
-_fini
-_init
fd_bo_cpu_fini
fd_bo_cpu_prep
fd_bo_del
@@ -43,7 +29,6 @@ fd_pipe_wait
fd_pipe_wait_timeout
fd_ringbuffer_cmd_count
fd_ringbuffer_del
-fd_ringbuffer_emit_reloc_ring
fd_ringbuffer_emit_reloc_ring_full
fd_ringbuffer_flush
fd_ringbuffer_grow
@@ -58,8 +43,3 @@ fd_ringbuffer_set_parent
fd_ringbuffer_size
fd_ringbuffer_timestamp
fd_ringbuffer_flush2
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/freedreno/meson.build b/freedreno/meson.build
index c9aba060..63b84fc9 100644
--- a/freedreno/meson.build
+++ b/freedreno/meson.build
@@ -70,8 +70,11 @@ pkg.generate(
)
test(
- 'freedreno-symbol-check',
- prog_bash,
- env : env_test,
- args : [files('freedreno-symbol-check'), libdrm_freedreno]
+ 'freedreno-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm_freedreno,
+ '--symbols-file', files('freedreno-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/include/drm/amdgpu_drm.h b/include/drm/amdgpu_drm.h
index 015bd9f4..4fe35d60 100644
--- a/include/drm/amdgpu_drm.h
+++ b/include/drm/amdgpu_drm.h
@@ -128,6 +128,10 @@ extern "C" {
* for the second page onward should be set to NC.
*/
#define AMDGPU_GEM_CREATE_MQD_GFX9 (1 << 8)
+/* Flag that BO may contain sensitive data that must be wiped before
+ * releasing the memory
+ */
+#define AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE (1 << 9)
struct drm_amdgpu_gem_create_in {
/** the requested memory size */
@@ -204,9 +208,9 @@ union drm_amdgpu_bo_list {
/* unknown cause */
#define AMDGPU_CTX_UNKNOWN_RESET 3
-/* indicate gpu reset occurred after ctx created */
+/* indicate gpu reset occured after ctx created */
#define AMDGPU_CTX_QUERY2_FLAGS_RESET (1<<0)
-/* indicate vram lost occurred after ctx created */
+/* indicate vram lost occured after ctx created */
#define AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST (1<<1)
/* indicate some job from this context once cause gpu hang */
#define AMDGPU_CTX_QUERY2_FLAGS_GUILTY (1<<2)
@@ -219,7 +223,10 @@ union drm_amdgpu_bo_list {
#define AMDGPU_CTX_PRIORITY_VERY_LOW -1023
#define AMDGPU_CTX_PRIORITY_LOW -512
#define AMDGPU_CTX_PRIORITY_NORMAL 0
-/* Selecting a priority above NORMAL requires CAP_SYS_NICE or DRM_MASTER */
+/*
+ * When used in struct drm_amdgpu_ctx_in, a priority above NORMAL requires
+ * CAP_SYS_NICE or DRM_MASTER
+*/
#define AMDGPU_CTX_PRIORITY_HIGH 512
#define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023
@@ -229,6 +236,7 @@ struct drm_amdgpu_ctx_in {
/** For future use, no flags defined so far */
__u32 flags;
__u32 ctx_id;
+ /** AMDGPU_CTX_PRIORITY_* */
__s32 priority;
};
@@ -281,6 +289,7 @@ struct drm_amdgpu_sched_in {
/* AMDGPU_SCHED_OP_* */
__u32 op;
__u32 fd;
+ /** AMDGPU_CTX_PRIORITY_* */
__s32 priority;
__u32 ctx_id;
};
@@ -611,12 +620,11 @@ struct drm_amdgpu_cs_chunk_sem {
};
struct drm_amdgpu_cs_chunk_syncobj {
- __u32 handle;
- __u32 flags;
- __u64 point;
+ __u32 handle;
+ __u32 flags;
+ __u64 point;
};
-
#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ 0
#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD 1
#define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2
@@ -995,6 +1003,8 @@ struct drm_amdgpu_info_device {
__u64 high_va_max;
/* gfx10 pa_sc_tile_steering_override */
__u32 pa_sc_tile_steering_override;
+ /* disabled TCCs */
+ __u64 tcc_disabled_mask;
};
struct drm_amdgpu_info_hw_ip {
diff --git a/include/drm/drm.h b/include/drm/drm.h
index 438abde3..c7fd2a35 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -772,11 +772,12 @@ struct drm_syncobj_array {
__u32 pad;
};
+#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */
struct drm_syncobj_timeline_array {
__u64 handles;
__u64 points;
__u32 count_handles;
- __u32 pad;
+ __u32 flags;
};
@@ -941,6 +942,8 @@ extern "C" {
#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer)
#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)
+#define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
+
/**
* Device specific ioctls should only be in their respective headers
* The device specific ioctl range is from 0x40 to 0x9f.
diff --git a/include/drm/nouveau_drm.h b/include/drm/nouveau_drm.h
index d42105c8..4f941489 100644
--- a/include/drm/nouveau_drm.h
+++ b/include/drm/nouveau_drm.h
@@ -73,15 +73,11 @@ struct drm_nouveau_gpuobj_free {
uint32_t handle;
};
-/* FIXME : maybe unify {GET,SET}PARAMs */
#define NOUVEAU_GETPARAM_PCI_VENDOR 3
#define NOUVEAU_GETPARAM_PCI_DEVICE 4
#define NOUVEAU_GETPARAM_BUS_TYPE 5
-#define NOUVEAU_GETPARAM_FB_PHYSICAL 6
-#define NOUVEAU_GETPARAM_AGP_PHYSICAL 7
#define NOUVEAU_GETPARAM_FB_SIZE 8
#define NOUVEAU_GETPARAM_AGP_SIZE 9
-#define NOUVEAU_GETPARAM_PCI_PHYSICAL 10
#define NOUVEAU_GETPARAM_CHIPSET_ID 11
#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12
#define NOUVEAU_GETPARAM_GRAPH_UNITS 13
@@ -175,12 +171,12 @@ struct drm_nouveau_gem_pushbuf {
__u64 push;
__u32 suffix0;
__u32 suffix1;
+#define NOUVEAU_GEM_PUSHBUF_SYNC (1ULL << 0)
__u64 vram_available;
__u64 gart_available;
};
#define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001
-#define NOUVEAU_GEM_CPU_PREP_NOBLOCK 0x00000002
#define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004
struct drm_nouveau_gem_cpu_prep {
__u32 handle;
@@ -191,29 +187,68 @@ struct drm_nouveau_gem_cpu_fini {
__u32 handle;
};
-enum nouveau_bus_type {
- NV_AGP = 0,
- NV_PCI = 1,
- NV_PCIE = 2,
-};
-
-struct drm_nouveau_sarea {
-};
-
-#define DRM_NOUVEAU_GETPARAM 0x00
-#define DRM_NOUVEAU_SETPARAM 0x01
-#define DRM_NOUVEAU_CHANNEL_ALLOC 0x02
-#define DRM_NOUVEAU_CHANNEL_FREE 0x03
-#define DRM_NOUVEAU_GROBJ_ALLOC 0x04
-#define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05
-#define DRM_NOUVEAU_GPUOBJ_FREE 0x06
+#define DRM_NOUVEAU_GETPARAM 0x00 /* deprecated */
+#define DRM_NOUVEAU_SETPARAM 0x01 /* deprecated */
+#define DRM_NOUVEAU_CHANNEL_ALLOC 0x02 /* deprecated */
+#define DRM_NOUVEAU_CHANNEL_FREE 0x03 /* deprecated */
+#define DRM_NOUVEAU_GROBJ_ALLOC 0x04 /* deprecated */
+#define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05 /* deprecated */
+#define DRM_NOUVEAU_GPUOBJ_FREE 0x06 /* deprecated */
#define DRM_NOUVEAU_NVIF 0x07
+#define DRM_NOUVEAU_SVM_INIT 0x08
+#define DRM_NOUVEAU_SVM_BIND 0x09
#define DRM_NOUVEAU_GEM_NEW 0x40
#define DRM_NOUVEAU_GEM_PUSHBUF 0x41
#define DRM_NOUVEAU_GEM_CPU_PREP 0x42
#define DRM_NOUVEAU_GEM_CPU_FINI 0x43
#define DRM_NOUVEAU_GEM_INFO 0x44
+struct drm_nouveau_svm_init {
+ __u64 unmanaged_addr;
+ __u64 unmanaged_size;
+};
+
+struct drm_nouveau_svm_bind {
+ __u64 header;
+ __u64 va_start;
+ __u64 va_end;
+ __u64 npages;
+ __u64 stride;
+ __u64 result;
+ __u64 reserved0;
+ __u64 reserved1;
+};
+
+#define NOUVEAU_SVM_BIND_COMMAND_SHIFT 0
+#define NOUVEAU_SVM_BIND_COMMAND_BITS 8
+#define NOUVEAU_SVM_BIND_COMMAND_MASK ((1 << 8) - 1)
+#define NOUVEAU_SVM_BIND_PRIORITY_SHIFT 8
+#define NOUVEAU_SVM_BIND_PRIORITY_BITS 8
+#define NOUVEAU_SVM_BIND_PRIORITY_MASK ((1 << 8) - 1)
+#define NOUVEAU_SVM_BIND_TARGET_SHIFT 16
+#define NOUVEAU_SVM_BIND_TARGET_BITS 32
+#define NOUVEAU_SVM_BIND_TARGET_MASK 0xffffffff
+
+/*
+ * Below is use to validate ioctl argument, userspace can also use it to make
+ * sure that no bit are set beyond known fields for a given kernel version.
+ */
+#define NOUVEAU_SVM_BIND_VALID_BITS 48
+#define NOUVEAU_SVM_BIND_VALID_MASK ((1ULL << NOUVEAU_SVM_BIND_VALID_BITS) - 1)
+
+
+/*
+ * NOUVEAU_BIND_COMMAND__MIGRATE: synchronous migrate to target memory.
+ * result: number of page successfuly migrate to the target memory.
+ */
+#define NOUVEAU_SVM_BIND_COMMAND__MIGRATE 0
+
+/*
+ * NOUVEAU_SVM_BIND_HEADER_TARGET__GPU_VRAM: target the GPU VRAM memory.
+ */
+#define NOUVEAU_SVM_BIND_TARGET__GPU_VRAM (1UL << 31)
+
+
#if defined(__cplusplus)
}
#endif
diff --git a/intel/Makefile.am b/intel/Makefile.am
deleted file mode 100644
index bad44f5f..00000000
--- a/intel/Makefile.am
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright © 2008 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>
-
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- $(PCIACCESS_CFLAGS) \
- $(VALGRIND_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_intel_la_LTLIBRARIES = libdrm_intel.la
-libdrm_intel_ladir = $(libdir)
-libdrm_intel_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_intel_la_LIBADD = ../libdrm.la \
- @PTHREADSTUBS_LIBS@ \
- @PCIACCESS_LIBS@ \
- @CLOCK_LIB@
-
-libdrm_intel_la_SOURCES = $(LIBDRM_INTEL_FILES)
-
-libdrm_intelincludedir = ${includedir}/libdrm
-libdrm_intelinclude_HEADERS = $(LIBDRM_INTEL_H_FILES)
-
-# This may be interesting even outside of "make check", due to the -dump option.
-noinst_PROGRAMS = test_decode
-
-BATCHES = \
- tests/gen4-3d.batch \
- tests/gm45-3d.batch \
- tests/gen5-3d.batch \
- tests/gen6-3d.batch \
- tests/gen7-2d-copy.batch \
- tests/gen7-3d.batch
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = \
- $(BATCHES:.batch=.batch.sh) \
- intel-symbol-check
-
-EXTRA_DIST = \
- $(BATCHES) \
- $(BATCHES:.batch=.batch.sh) \
- $(BATCHES:.batch=.batch-ref.txt) \
- $(BATCHES:.batch=.batch-ref.txt) \
- tests/test-batch.sh \
- $(TESTS)
-
-test_decode_LDADD = libdrm_intel.la ../libdrm.la
-
-pkgconfig_DATA = libdrm_intel.pc
diff --git a/intel/i915_pciids.h b/intel/i915_pciids.h
index c7cdbfc4..662d8351 100644
--- a/intel/i915_pciids.h
+++ b/intel/i915_pciids.h
@@ -108,8 +108,10 @@
INTEL_VGA_DEVICE(0x2e42, info), /* B43_G */ \
INTEL_VGA_DEVICE(0x2e92, info) /* B43_G.1 */
-#define INTEL_PINEVIEW_IDS(info) \
- INTEL_VGA_DEVICE(0xa001, info), \
+#define INTEL_PINEVIEW_G_IDS(info) \
+ INTEL_VGA_DEVICE(0xa001, info)
+
+#define INTEL_PINEVIEW_M_IDS(info) \
INTEL_VGA_DEVICE(0xa011, info)
#define INTEL_IRONLAKE_D_IDS(info) \
@@ -166,7 +168,18 @@
#define INTEL_IVB_Q_IDS(info) \
INTEL_QUANTA_VGA_DEVICE(info) /* Quanta transcode */
+#define INTEL_HSW_ULT_GT1_IDS(info) \
+ INTEL_VGA_DEVICE(0x0A02, info), /* ULT GT1 desktop */ \
+ INTEL_VGA_DEVICE(0x0A0A, info), /* ULT GT1 server */ \
+ INTEL_VGA_DEVICE(0x0A0B, info), /* ULT GT1 reserved */ \
+ INTEL_VGA_DEVICE(0x0A06, info) /* ULT GT1 mobile */
+
+#define INTEL_HSW_ULX_GT1_IDS(info) \
+ INTEL_VGA_DEVICE(0x0A0E, info) /* ULX GT1 mobile */
+
#define INTEL_HSW_GT1_IDS(info) \
+ INTEL_HSW_ULT_GT1_IDS(info), \
+ INTEL_HSW_ULX_GT1_IDS(info), \
INTEL_VGA_DEVICE(0x0402, info), /* GT1 desktop */ \
INTEL_VGA_DEVICE(0x040a, info), /* GT1 server */ \
INTEL_VGA_DEVICE(0x040B, info), /* GT1 reserved */ \
@@ -175,20 +188,26 @@
INTEL_VGA_DEVICE(0x0C0A, info), /* SDV GT1 server */ \
INTEL_VGA_DEVICE(0x0C0B, info), /* SDV GT1 reserved */ \
INTEL_VGA_DEVICE(0x0C0E, info), /* SDV GT1 reserved */ \
- INTEL_VGA_DEVICE(0x0A02, info), /* ULT GT1 desktop */ \
- INTEL_VGA_DEVICE(0x0A0A, info), /* ULT GT1 server */ \
- INTEL_VGA_DEVICE(0x0A0B, info), /* ULT GT1 reserved */ \
INTEL_VGA_DEVICE(0x0D02, info), /* CRW GT1 desktop */ \
INTEL_VGA_DEVICE(0x0D0A, info), /* CRW GT1 server */ \
INTEL_VGA_DEVICE(0x0D0B, info), /* CRW GT1 reserved */ \
INTEL_VGA_DEVICE(0x0D0E, info), /* CRW GT1 reserved */ \
INTEL_VGA_DEVICE(0x0406, info), /* GT1 mobile */ \
INTEL_VGA_DEVICE(0x0C06, info), /* SDV GT1 mobile */ \
- INTEL_VGA_DEVICE(0x0A06, info), /* ULT GT1 mobile */ \
- INTEL_VGA_DEVICE(0x0A0E, info), /* ULX GT1 mobile */ \
INTEL_VGA_DEVICE(0x0D06, info) /* CRW GT1 mobile */
+#define INTEL_HSW_ULT_GT2_IDS(info) \
+ INTEL_VGA_DEVICE(0x0A12, info), /* ULT GT2 desktop */ \
+ INTEL_VGA_DEVICE(0x0A1A, info), /* ULT GT2 server */ \
+ INTEL_VGA_DEVICE(0x0A1B, info), /* ULT GT2 reserved */ \
+ INTEL_VGA_DEVICE(0x0A16, info) /* ULT GT2 mobile */
+
+#define INTEL_HSW_ULX_GT2_IDS(info) \
+ INTEL_VGA_DEVICE(0x0A1E, info) /* ULX GT2 mobile */ \
+
#define INTEL_HSW_GT2_IDS(info) \
+ INTEL_HSW_ULT_GT2_IDS(info), \
+ INTEL_HSW_ULX_GT2_IDS(info), \
INTEL_VGA_DEVICE(0x0412, info), /* GT2 desktop */ \
INTEL_VGA_DEVICE(0x041a, info), /* GT2 server */ \
INTEL_VGA_DEVICE(0x041B, info), /* GT2 reserved */ \
@@ -197,9 +216,6 @@
INTEL_VGA_DEVICE(0x0C1A, info), /* SDV GT2 server */ \
INTEL_VGA_DEVICE(0x0C1B, info), /* SDV GT2 reserved */ \
INTEL_VGA_DEVICE(0x0C1E, info), /* SDV GT2 reserved */ \
- INTEL_VGA_DEVICE(0x0A12, info), /* ULT GT2 desktop */ \
- INTEL_VGA_DEVICE(0x0A1A, info), /* ULT GT2 server */ \
- INTEL_VGA_DEVICE(0x0A1B, info), /* ULT GT2 reserved */ \
INTEL_VGA_DEVICE(0x0D12, info), /* CRW GT2 desktop */ \
INTEL_VGA_DEVICE(0x0D1A, info), /* CRW GT2 server */ \
INTEL_VGA_DEVICE(0x0D1B, info), /* CRW GT2 reserved */ \
@@ -207,11 +223,17 @@
INTEL_VGA_DEVICE(0x0416, info), /* GT2 mobile */ \
INTEL_VGA_DEVICE(0x0426, info), /* GT2 mobile */ \
INTEL_VGA_DEVICE(0x0C16, info), /* SDV GT2 mobile */ \
- INTEL_VGA_DEVICE(0x0A16, info), /* ULT GT2 mobile */ \
- INTEL_VGA_DEVICE(0x0A1E, info), /* ULX GT2 mobile */ \
INTEL_VGA_DEVICE(0x0D16, info) /* CRW GT2 mobile */
+#define INTEL_HSW_ULT_GT3_IDS(info) \
+ INTEL_VGA_DEVICE(0x0A22, info), /* ULT GT3 desktop */ \
+ INTEL_VGA_DEVICE(0x0A2A, info), /* ULT GT3 server */ \
+ INTEL_VGA_DEVICE(0x0A2B, info), /* ULT GT3 reserved */ \
+ INTEL_VGA_DEVICE(0x0A26, info), /* ULT GT3 mobile */ \
+ INTEL_VGA_DEVICE(0x0A2E, info) /* ULT GT3 reserved */
+
#define INTEL_HSW_GT3_IDS(info) \
+ INTEL_HSW_ULT_GT3_IDS(info), \
INTEL_VGA_DEVICE(0x0422, info), /* GT3 desktop */ \
INTEL_VGA_DEVICE(0x042a, info), /* GT3 server */ \
INTEL_VGA_DEVICE(0x042B, info), /* GT3 reserved */ \
@@ -220,16 +242,11 @@
INTEL_VGA_DEVICE(0x0C2A, info), /* SDV GT3 server */ \
INTEL_VGA_DEVICE(0x0C2B, info), /* SDV GT3 reserved */ \
INTEL_VGA_DEVICE(0x0C2E, info), /* SDV GT3 reserved */ \
- INTEL_VGA_DEVICE(0x0A22, info), /* ULT GT3 desktop */ \
- INTEL_VGA_DEVICE(0x0A2A, info), /* ULT GT3 server */ \
- INTEL_VGA_DEVICE(0x0A2B, info), /* ULT GT3 reserved */ \
INTEL_VGA_DEVICE(0x0D22, info), /* CRW GT3 desktop */ \
INTEL_VGA_DEVICE(0x0D2A, info), /* CRW GT3 server */ \
INTEL_VGA_DEVICE(0x0D2B, info), /* CRW GT3 reserved */ \
INTEL_VGA_DEVICE(0x0D2E, info), /* CRW GT3 reserved */ \
INTEL_VGA_DEVICE(0x0C26, info), /* SDV GT3 mobile */ \
- INTEL_VGA_DEVICE(0x0A26, info), /* ULT GT3 mobile */ \
- INTEL_VGA_DEVICE(0x0A2E, info), /* ULT GT3 reserved */ \
INTEL_VGA_DEVICE(0x0D26, info) /* CRW GT3 mobile */
#define INTEL_HSW_IDS(info) \
@@ -245,35 +262,59 @@
INTEL_VGA_DEVICE(0x0157, info), \
INTEL_VGA_DEVICE(0x0155, info)
-#define INTEL_BDW_GT1_IDS(info) \
- INTEL_VGA_DEVICE(0x1602, info), /* GT1 ULT */ \
+#define INTEL_BDW_ULT_GT1_IDS(info) \
INTEL_VGA_DEVICE(0x1606, info), /* GT1 ULT */ \
- INTEL_VGA_DEVICE(0x160B, info), /* GT1 Iris */ \
- INTEL_VGA_DEVICE(0x160E, info), /* GT1 ULX */ \
+ INTEL_VGA_DEVICE(0x160B, info) /* GT1 Iris */
+
+#define INTEL_BDW_ULX_GT1_IDS(info) \
+ INTEL_VGA_DEVICE(0x160E, info) /* GT1 ULX */
+
+#define INTEL_BDW_GT1_IDS(info) \
+ INTEL_BDW_ULT_GT1_IDS(info), \
+ INTEL_BDW_ULX_GT1_IDS(info), \
+ INTEL_VGA_DEVICE(0x1602, info), /* GT1 ULT */ \
INTEL_VGA_DEVICE(0x160A, info), /* GT1 Server */ \
INTEL_VGA_DEVICE(0x160D, info) /* GT1 Workstation */
-#define INTEL_BDW_GT2_IDS(info) \
- INTEL_VGA_DEVICE(0x1612, info), /* GT2 Halo */ \
+#define INTEL_BDW_ULT_GT2_IDS(info) \
INTEL_VGA_DEVICE(0x1616, info), /* GT2 ULT */ \
- INTEL_VGA_DEVICE(0x161B, info), /* GT2 ULT */ \
- INTEL_VGA_DEVICE(0x161E, info), /* GT2 ULX */ \
+ INTEL_VGA_DEVICE(0x161B, info) /* GT2 ULT */
+
+#define INTEL_BDW_ULX_GT2_IDS(info) \
+ INTEL_VGA_DEVICE(0x161E, info) /* GT2 ULX */
+
+#define INTEL_BDW_GT2_IDS(info) \
+ INTEL_BDW_ULT_GT2_IDS(info), \
+ INTEL_BDW_ULX_GT2_IDS(info), \
+ INTEL_VGA_DEVICE(0x1612, info), /* GT2 Halo */ \
INTEL_VGA_DEVICE(0x161A, info), /* GT2 Server */ \
INTEL_VGA_DEVICE(0x161D, info) /* GT2 Workstation */
+#define INTEL_BDW_ULT_GT3_IDS(info) \
+ INTEL_VGA_DEVICE(0x1626, info), /* ULT */ \
+ INTEL_VGA_DEVICE(0x162B, info) /* Iris */ \
+
+#define INTEL_BDW_ULX_GT3_IDS(info) \
+ INTEL_VGA_DEVICE(0x162E, info) /* ULX */
+
#define INTEL_BDW_GT3_IDS(info) \
+ INTEL_BDW_ULT_GT3_IDS(info), \
+ INTEL_BDW_ULX_GT3_IDS(info), \
INTEL_VGA_DEVICE(0x1622, info), /* ULT */ \
- INTEL_VGA_DEVICE(0x1626, info), /* ULT */ \
- INTEL_VGA_DEVICE(0x162B, info), /* Iris */ \
- INTEL_VGA_DEVICE(0x162E, info), /* ULX */\
INTEL_VGA_DEVICE(0x162A, info), /* Server */ \
INTEL_VGA_DEVICE(0x162D, info) /* Workstation */
+#define INTEL_BDW_ULT_RSVD_IDS(info) \
+ INTEL_VGA_DEVICE(0x1636, info), /* ULT */ \
+ INTEL_VGA_DEVICE(0x163B, info) /* Iris */
+
+#define INTEL_BDW_ULX_RSVD_IDS(info) \
+ INTEL_VGA_DEVICE(0x163E, info) /* ULX */
+
#define INTEL_BDW_RSVD_IDS(info) \
+ INTEL_BDW_ULT_RSVD_IDS(info), \
+ INTEL_BDW_ULX_RSVD_IDS(info), \
INTEL_VGA_DEVICE(0x1632, info), /* ULT */ \
- INTEL_VGA_DEVICE(0x1636, info), /* ULT */ \
- INTEL_VGA_DEVICE(0x163B, info), /* Iris */ \
- INTEL_VGA_DEVICE(0x163E, info), /* ULX */ \
INTEL_VGA_DEVICE(0x163A, info), /* Server */ \
INTEL_VGA_DEVICE(0x163D, info) /* Workstation */
@@ -289,25 +330,40 @@
INTEL_VGA_DEVICE(0x22b2, info), \
INTEL_VGA_DEVICE(0x22b3, info)
+#define INTEL_SKL_ULT_GT1_IDS(info) \
+ INTEL_VGA_DEVICE(0x1906, info) /* ULT GT1 */
+
+#define INTEL_SKL_ULX_GT1_IDS(info) \
+ INTEL_VGA_DEVICE(0x190E, info) /* ULX GT1 */
+
#define INTEL_SKL_GT1_IDS(info) \
- INTEL_VGA_DEVICE(0x1906, info), /* ULT GT1 */ \
- INTEL_VGA_DEVICE(0x190E, info), /* ULX GT1 */ \
+ INTEL_SKL_ULT_GT1_IDS(info), \
+ INTEL_SKL_ULX_GT1_IDS(info), \
INTEL_VGA_DEVICE(0x1902, info), /* DT GT1 */ \
INTEL_VGA_DEVICE(0x190B, info), /* Halo GT1 */ \
INTEL_VGA_DEVICE(0x190A, info) /* SRV GT1 */
-#define INTEL_SKL_GT2_IDS(info) \
+#define INTEL_SKL_ULT_GT2_IDS(info) \
INTEL_VGA_DEVICE(0x1916, info), /* ULT GT2 */ \
- INTEL_VGA_DEVICE(0x1921, info), /* ULT GT2F */ \
- INTEL_VGA_DEVICE(0x191E, info), /* ULX GT2 */ \
+ INTEL_VGA_DEVICE(0x1921, info) /* ULT GT2F */
+
+#define INTEL_SKL_ULX_GT2_IDS(info) \
+ INTEL_VGA_DEVICE(0x191E, info) /* ULX GT2 */
+
+#define INTEL_SKL_GT2_IDS(info) \
+ INTEL_SKL_ULT_GT2_IDS(info), \
+ INTEL_SKL_ULX_GT2_IDS(info), \
INTEL_VGA_DEVICE(0x1912, info), /* DT GT2 */ \
INTEL_VGA_DEVICE(0x191B, info), /* Halo GT2 */ \
INTEL_VGA_DEVICE(0x191A, info), /* SRV GT2 */ \
INTEL_VGA_DEVICE(0x191D, info) /* WKS GT2 */
+#define INTEL_SKL_ULT_GT3_IDS(info) \
+ INTEL_VGA_DEVICE(0x1926, info) /* ULT GT3 */
+
#define INTEL_SKL_GT3_IDS(info) \
+ INTEL_SKL_ULT_GT3_IDS(info), \
INTEL_VGA_DEVICE(0x1923, info), /* ULT GT3 */ \
- INTEL_VGA_DEVICE(0x1926, info), /* ULT GT3 */ \
INTEL_VGA_DEVICE(0x1927, info), /* ULT GT3 */ \
INTEL_VGA_DEVICE(0x192B, info), /* Halo GT3 */ \
INTEL_VGA_DEVICE(0x192D, info) /* SRV GT3 */
@@ -336,29 +392,44 @@
INTEL_VGA_DEVICE(0x3184, info), \
INTEL_VGA_DEVICE(0x3185, info)
-#define INTEL_KBL_GT1_IDS(info) \
- INTEL_VGA_DEVICE(0x5913, info), /* ULT GT1.5 */ \
- INTEL_VGA_DEVICE(0x5915, info), /* ULX GT1.5 */ \
+#define INTEL_KBL_ULT_GT1_IDS(info) \
INTEL_VGA_DEVICE(0x5906, info), /* ULT GT1 */ \
+ INTEL_VGA_DEVICE(0x5913, info) /* ULT GT1.5 */
+
+#define INTEL_KBL_ULX_GT1_IDS(info) \
INTEL_VGA_DEVICE(0x590E, info), /* ULX GT1 */ \
+ INTEL_VGA_DEVICE(0x5915, info) /* ULX GT1.5 */
+
+#define INTEL_KBL_GT1_IDS(info) \
+ INTEL_KBL_ULT_GT1_IDS(info), \
+ INTEL_KBL_ULX_GT1_IDS(info), \
INTEL_VGA_DEVICE(0x5902, info), /* DT GT1 */ \
INTEL_VGA_DEVICE(0x5908, info), /* Halo GT1 */ \
INTEL_VGA_DEVICE(0x590B, info), /* Halo GT1 */ \
INTEL_VGA_DEVICE(0x590A, info) /* SRV GT1 */
-#define INTEL_KBL_GT2_IDS(info) \
+#define INTEL_KBL_ULT_GT2_IDS(info) \
INTEL_VGA_DEVICE(0x5916, info), /* ULT GT2 */ \
+ INTEL_VGA_DEVICE(0x5921, info) /* ULT GT2F */
+
+#define INTEL_KBL_ULX_GT2_IDS(info) \
+ INTEL_VGA_DEVICE(0x591E, info) /* ULX GT2 */
+
+#define INTEL_KBL_GT2_IDS(info) \
+ INTEL_KBL_ULT_GT2_IDS(info), \
+ INTEL_KBL_ULX_GT2_IDS(info), \
INTEL_VGA_DEVICE(0x5917, info), /* Mobile GT2 */ \
- INTEL_VGA_DEVICE(0x5921, info), /* ULT GT2F */ \
- INTEL_VGA_DEVICE(0x591E, info), /* ULX GT2 */ \
INTEL_VGA_DEVICE(0x5912, info), /* DT GT2 */ \
INTEL_VGA_DEVICE(0x591B, info), /* Halo GT2 */ \
INTEL_VGA_DEVICE(0x591A, info), /* SRV GT2 */ \
INTEL_VGA_DEVICE(0x591D, info) /* WKS GT2 */
+#define INTEL_KBL_ULT_GT3_IDS(info) \
+ INTEL_VGA_DEVICE(0x5926, info) /* ULT GT3 */
+
#define INTEL_KBL_GT3_IDS(info) \
+ INTEL_KBL_ULT_GT3_IDS(info), \
INTEL_VGA_DEVICE(0x5923, info), /* ULT GT3 */ \
- INTEL_VGA_DEVICE(0x5926, info), /* ULT GT3 */ \
INTEL_VGA_DEVICE(0x5927, info) /* ULT GT3 */
#define INTEL_KBL_GT4_IDS(info) \
@@ -375,27 +446,30 @@
/* CML GT1 */
#define INTEL_CML_GT1_IDS(info) \
- INTEL_VGA_DEVICE(0x9B21, info), \
- INTEL_VGA_DEVICE(0x9BAA, info), \
- INTEL_VGA_DEVICE(0x9BAB, info), \
- INTEL_VGA_DEVICE(0x9BAC, info), \
- INTEL_VGA_DEVICE(0x9BA0, info), \
INTEL_VGA_DEVICE(0x9BA5, info), \
INTEL_VGA_DEVICE(0x9BA8, info), \
INTEL_VGA_DEVICE(0x9BA4, info), \
INTEL_VGA_DEVICE(0x9BA2, info)
+#define INTEL_CML_U_GT1_IDS(info) \
+ INTEL_VGA_DEVICE(0x9B21, info), \
+ INTEL_VGA_DEVICE(0x9BAA, info), \
+ INTEL_VGA_DEVICE(0x9BAC, info)
+
/* CML GT2 */
#define INTEL_CML_GT2_IDS(info) \
- INTEL_VGA_DEVICE(0x9B41, info), \
- INTEL_VGA_DEVICE(0x9BCA, info), \
- INTEL_VGA_DEVICE(0x9BCB, info), \
- INTEL_VGA_DEVICE(0x9BCC, info), \
- INTEL_VGA_DEVICE(0x9BC0, info), \
INTEL_VGA_DEVICE(0x9BC5, info), \
INTEL_VGA_DEVICE(0x9BC8, info), \
INTEL_VGA_DEVICE(0x9BC4, info), \
- INTEL_VGA_DEVICE(0x9BC2, info)
+ INTEL_VGA_DEVICE(0x9BC2, info), \
+ INTEL_VGA_DEVICE(0x9BC6, info), \
+ INTEL_VGA_DEVICE(0x9BE6, info), \
+ INTEL_VGA_DEVICE(0x9BF6, info)
+
+#define INTEL_CML_U_GT2_IDS(info) \
+ INTEL_VGA_DEVICE(0x9B41, info), \
+ INTEL_VGA_DEVICE(0x9BCA, info), \
+ INTEL_VGA_DEVICE(0x9BCC, info)
#define INTEL_KBL_IDS(info) \
INTEL_KBL_GT1_IDS(info), \
@@ -462,10 +536,19 @@
INTEL_WHL_U_GT3_IDS(info), \
INTEL_AML_CFL_GT2_IDS(info), \
INTEL_CML_GT1_IDS(info), \
- INTEL_CML_GT2_IDS(info)
+ INTEL_CML_GT2_IDS(info), \
+ INTEL_CML_U_GT1_IDS(info), \
+ INTEL_CML_U_GT2_IDS(info)
/* CNL */
+#define INTEL_CNL_PORT_F_IDS(info) \
+ INTEL_VGA_DEVICE(0x5A54, info), \
+ INTEL_VGA_DEVICE(0x5A5C, info), \
+ INTEL_VGA_DEVICE(0x5A44, info), \
+ INTEL_VGA_DEVICE(0x5A4C, info)
+
#define INTEL_CNL_IDS(info) \
+ INTEL_CNL_PORT_F_IDS(info), \
INTEL_VGA_DEVICE(0x5A51, info), \
INTEL_VGA_DEVICE(0x5A59, info), \
INTEL_VGA_DEVICE(0x5A41, info), \
@@ -475,18 +558,12 @@
INTEL_VGA_DEVICE(0x5A42, info), \
INTEL_VGA_DEVICE(0x5A4A, info), \
INTEL_VGA_DEVICE(0x5A50, info), \
- INTEL_VGA_DEVICE(0x5A40, info), \
- INTEL_VGA_DEVICE(0x5A54, info), \
- INTEL_VGA_DEVICE(0x5A5C, info), \
- INTEL_VGA_DEVICE(0x5A44, info), \
- INTEL_VGA_DEVICE(0x5A4C, info)
+ INTEL_VGA_DEVICE(0x5A40, info)
/* ICL */
-#define INTEL_ICL_11_IDS(info) \
+#define INTEL_ICL_PORT_F_IDS(info) \
INTEL_VGA_DEVICE(0x8A50, info), \
- INTEL_VGA_DEVICE(0x8A51, info), \
INTEL_VGA_DEVICE(0x8A5C, info), \
- INTEL_VGA_DEVICE(0x8A5D, info), \
INTEL_VGA_DEVICE(0x8A59, info), \
INTEL_VGA_DEVICE(0x8A58, info), \
INTEL_VGA_DEVICE(0x8A52, info), \
@@ -496,13 +573,36 @@
INTEL_VGA_DEVICE(0x8A56, info), \
INTEL_VGA_DEVICE(0x8A71, info), \
INTEL_VGA_DEVICE(0x8A70, info), \
- INTEL_VGA_DEVICE(0x8A53, info)
+ INTEL_VGA_DEVICE(0x8A53, info), \
+ INTEL_VGA_DEVICE(0x8A54, info)
+
+#define INTEL_ICL_11_IDS(info) \
+ INTEL_ICL_PORT_F_IDS(info), \
+ INTEL_VGA_DEVICE(0x8A51, info), \
+ INTEL_VGA_DEVICE(0x8A5D, info)
-/* EHL */
+/* EHL/JSL */
#define INTEL_EHL_IDS(info) \
INTEL_VGA_DEVICE(0x4500, info), \
INTEL_VGA_DEVICE(0x4571, info), \
INTEL_VGA_DEVICE(0x4551, info), \
- INTEL_VGA_DEVICE(0x4541, info)
+ INTEL_VGA_DEVICE(0x4541, info), \
+ INTEL_VGA_DEVICE(0x4E71, info), \
+ INTEL_VGA_DEVICE(0x4E61, info), \
+ INTEL_VGA_DEVICE(0x4E51, info)
+
+/* TGL */
+#define INTEL_TGL_12_IDS(info) \
+ INTEL_VGA_DEVICE(0x9A40, info), \
+ INTEL_VGA_DEVICE(0x9A49, info), \
+ INTEL_VGA_DEVICE(0x9A59, info), \
+ INTEL_VGA_DEVICE(0x9A60, info), \
+ INTEL_VGA_DEVICE(0x9A68, info), \
+ INTEL_VGA_DEVICE(0x9A70, info), \
+ INTEL_VGA_DEVICE(0x9A78, info), \
+ INTEL_VGA_DEVICE(0x9AC0, info), \
+ INTEL_VGA_DEVICE(0x9AC9, info), \
+ INTEL_VGA_DEVICE(0x9AD9, info), \
+ INTEL_VGA_DEVICE(0x9AF8, info)
#endif /* _I915_PCIIDS_H */
diff --git a/intel/intel-symbol-check b/intel/intel-symbols.txt
index de377bef..132df96a 100755..100644
--- a/intel/intel-symbol-check
+++ b/intel/intel-symbols.txt
@@ -1,17 +1,3 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first five) are taken from the public headers.
-# A list of the latter should be available Makefile.sources/LIBDRM_INTEL_H_FILES
-
-FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libdrm_intel.so} | awk '{print $3}' | while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_start
-_edata
-_end
-_fini
-_init
drm_intel_bo_alloc
drm_intel_bo_alloc_for_render
drm_intel_bo_alloc_tiled
@@ -95,8 +81,3 @@ drm_intel_get_pooled_eu
drm_intel_get_reset_stats
drm_intel_get_subslice_total
drm_intel_reg_read
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index fbf48730..023af61f 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -1069,6 +1069,28 @@ check_bo_alloc_userptr(drm_intel_bufmgr *bufmgr,
tiling_mode, stride, size, flags);
}
+static int get_tiling_mode(drm_intel_bufmgr_gem *bufmgr_gem,
+ uint32_t gem_handle,
+ uint32_t *tiling_mode,
+ uint32_t *swizzle_mode)
+{
+ struct drm_i915_gem_get_tiling get_tiling = {
+ .handle = gem_handle,
+ };
+ int ret;
+
+ ret = drmIoctl(bufmgr_gem->fd,
+ DRM_IOCTL_I915_GEM_GET_TILING,
+ &get_tiling);
+ if (ret != 0 && errno != EOPNOTSUPP)
+ return ret;
+
+ *tiling_mode = get_tiling.tiling_mode;
+ *swizzle_mode = get_tiling.swizzle_mode;
+
+ return 0;
+}
+
/**
* Returns a drm_intel_bo wrapping the given buffer object handle.
*
@@ -1084,7 +1106,6 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
drm_intel_bo_gem *bo_gem;
int ret;
struct drm_gem_open open_arg;
- struct drm_i915_gem_get_tiling get_tiling;
/* At the moment most applications only have a few named bo.
* For instance, in a DRI client only the render buffers passed
@@ -1146,16 +1167,11 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
HASH_ADD(name_hh, bufmgr_gem->name_table,
global_name, sizeof(bo_gem->global_name), bo_gem);
- memclear(get_tiling);
- get_tiling.handle = bo_gem->gem_handle;
- ret = drmIoctl(bufmgr_gem->fd,
- DRM_IOCTL_I915_GEM_GET_TILING,
- &get_tiling);
+ ret = get_tiling_mode(bufmgr_gem, bo_gem->gem_handle,
+ &bo_gem->tiling_mode, &bo_gem->swizzle_mode);
if (ret != 0)
goto err_unref;
- bo_gem->tiling_mode = get_tiling.tiling_mode;
- bo_gem->swizzle_mode = get_tiling.swizzle_mode;
/* XXX stride is unknown */
drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem, 0);
DBG("bo_create_from_handle: %d (%s)\n", handle, bo_gem->name);
@@ -2634,7 +2650,6 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s
int ret;
uint32_t handle;
drm_intel_bo_gem *bo_gem;
- struct drm_i915_gem_get_tiling get_tiling;
pthread_mutex_lock(&bufmgr_gem->lock);
ret = drmPrimeFDToHandle(bufmgr_gem->fd, prime_fd, &handle);
@@ -2688,15 +2703,11 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr *bufmgr, int prime_fd, int s
bo_gem->has_error = false;
bo_gem->reusable = false;
- memclear(get_tiling);
- get_tiling.handle = bo_gem->gem_handle;
- if (drmIoctl(bufmgr_gem->fd,
- DRM_IOCTL_I915_GEM_GET_TILING,
- &get_tiling))
+ ret = get_tiling_mode(bufmgr_gem, handle,
+ &bo_gem->tiling_mode, &bo_gem->swizzle_mode);
+ if (ret)
goto err;
- bo_gem->tiling_mode = get_tiling.tiling_mode;
- bo_gem->swizzle_mode = get_tiling.swizzle_mode;
/* XXX stride is unknown */
drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem, 0);
@@ -2717,7 +2728,7 @@ drm_intel_bo_gem_export_to_prime(drm_intel_bo *bo, int *prime_fd)
drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
if (drmPrimeHandleToFD(bufmgr_gem->fd, bo_gem->gem_handle,
- DRM_CLOEXEC, prime_fd) != 0)
+ DRM_CLOEXEC | DRM_RDWR, prime_fd) != 0)
return -errno;
bo_gem->reusable = false;
diff --git a/intel/intel_chipset.c b/intel/intel_chipset.c
index 5aa4a2f2..f6e37ee7 100644
--- a/intel/intel_chipset.c
+++ b/intel/intel_chipset.c
@@ -35,6 +35,8 @@ static const struct pci_device {
uint16_t gen;
} pciids[] = {
/* Keep ids sorted by gen; latest gen first */
+ INTEL_TGL_12_IDS(12),
+ INTEL_EHL_IDS(11),
INTEL_ICL_11_IDS(11),
INTEL_CNL_IDS(10),
INTEL_CFL_IDS(9),
diff --git a/intel/intel_chipset.h b/intel/intel_chipset.h
index 5db207cc..0a48e0da 100644
--- a/intel/intel_chipset.h
+++ b/intel/intel_chipset.h
@@ -337,6 +337,7 @@ drm_private bool intel_get_genx(unsigned int devid, int *gen);
#define IS_GEN9(devid) intel_is_genx(devid, 9)
#define IS_GEN10(devid) intel_is_genx(devid, 10)
#define IS_GEN11(devid) intel_is_genx(devid, 11)
+#define IS_GEN12(devid) intel_is_genx(devid, 12)
#define IS_9XX(dev) (IS_GEN3(dev) || \
IS_GEN4(dev) || \
diff --git a/intel/meson.build b/intel/meson.build
index 3d6bbac6..4d3f1ebd 100644
--- a/intel/meson.build
+++ b/intel/meson.build
@@ -64,43 +64,41 @@ test_decode = executable(
test(
'gen4-3d.batch',
- prog_bash,
- args : files('tests/gen4-3d.batch.sh'),
+ find_program('tests/gen4-3d.batch.sh'),
workdir : meson.current_build_dir(),
)
test(
'gen45-3d.batch',
- prog_bash,
- args : files('tests/gm45-3d.batch.sh'),
+ find_program('tests/gm45-3d.batch.sh'),
workdir : meson.current_build_dir(),
)
test(
'gen5-3d.batch',
- prog_bash,
- args : files('tests/gen5-3d.batch.sh'),
+ find_program('tests/gen5-3d.batch.sh'),
workdir : meson.current_build_dir(),
)
test(
'gen6-3d.batch',
- prog_bash,
- args : files('tests/gen6-3d.batch.sh'),
+ find_program('tests/gen6-3d.batch.sh'),
workdir : meson.current_build_dir(),
)
test(
'gen7-3d.batch',
- prog_bash,
- args : files('tests/gen7-3d.batch.sh'),
+ find_program('tests/gen7-3d.batch.sh'),
workdir : meson.current_build_dir(),
)
test(
'gen7-2d-copy.batch',
- prog_bash,
- args : files('tests/gen7-2d-copy.batch.sh'),
+ find_program('tests/gen7-2d-copy.batch.sh'),
workdir : meson.current_build_dir(),
)
+
test(
- 'intel-symbol-check',
- prog_bash,
- env : env_test,
- args : [files('intel-symbol-check'), libdrm_intel]
+ 'intel-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm_intel,
+ '--symbols-file', files('intel-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/intel/tests/test-batch.sh b/intel/tests/test-batch.sh
index a94057ff..b85f639a 100755
--- a/intel/tests/test-batch.sh
+++ b/intel/tests/test-batch.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-TEST_FILENAME=`echo "$0" | sed 's|.sh||'`
+TEST_FILENAME=`echo "$0" | sed 's|\.sh$||'`
./test_decode $TEST_FILENAME
ret=$?
diff --git a/libkms/Makefile.am b/libkms/Makefile.am
deleted file mode 100644
index ff4c1b2a..00000000
--- a/libkms/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)
-
-libkms_la_LTLIBRARIES = libkms.la
-libkms_ladir = $(libdir)
-libkms_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libkms_la_LIBADD = ../libdrm.la
-
-libkms_la_SOURCES = $(LIBKMS_FILES)
-
-if HAVE_VMWGFX
-libkms_la_SOURCES += $(LIBKMS_VMWGFX_FILES)
-endif
-
-if HAVE_INTEL
-libkms_la_SOURCES += $(LIBKMS_INTEL_FILES)
-endif
-
-if HAVE_NOUVEAU
-libkms_la_SOURCES += $(LIBKMS_NOUVEAU_FILES)
-endif
-
-if HAVE_RADEON
-libkms_la_SOURCES += $(LIBKMS_RADEON_FILES)
-endif
-
-if HAVE_EXYNOS
-libkms_la_SOURCES += $(LIBKMS_EXYNOS_FILES)
-AM_CFLAGS += -I$(top_srcdir)/exynos
-endif
-
-libkmsincludedir = ${includedir}/libkms
-libkmsinclude_HEADERS = $(LIBKMS_H_FILES)
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libkms.pc
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = kms-symbol-check
-EXTRA_DIST = $(TESTS)
diff --git a/libkms/kms-symbol-check b/libkms/kms-symbol-check
deleted file mode 100755
index 30f444f7..00000000
--- a/libkms/kms-symbol-check
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first five) are taken from the public headers.
-# A list of the latter should be available Makefile.sources/LIBKMS_H_FILES
-
-FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libkms.so} | awk '{print $3}'| while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_start
-_edata
-_end
-_fini
-_init
-kms_bo_create
-kms_bo_destroy
-kms_bo_get_prop
-kms_bo_map
-kms_bo_unmap
-kms_create
-kms_destroy
-kms_get_prop
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/libkms/kms-symbols.txt b/libkms/kms-symbols.txt
new file mode 100644
index 00000000..e0ba8c91
--- /dev/null
+++ b/libkms/kms-symbols.txt
@@ -0,0 +1,8 @@
+kms_bo_create
+kms_bo_destroy
+kms_bo_get_prop
+kms_bo_map
+kms_bo_unmap
+kms_create
+kms_destroy
+kms_get_prop
diff --git a/libkms/meson.build b/libkms/meson.build
index dc931608..216be4df 100644
--- a/libkms/meson.build
+++ b/libkms/meson.build
@@ -68,8 +68,11 @@ pkg.generate(
)
test(
- 'kms-symbol-check',
- prog_bash,
- env : env_test,
- args : [files('kms-symbol-check'), libkms]
+ 'kms-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libkms,
+ '--symbols-file', files('kms-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/m4/.gitignore b/m4/.gitignore
deleted file mode 100644
index 464ba5ca..00000000
--- a/m4/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-libtool.m4
-lt~obsolete.m4
-ltoptions.m4
-ltsugar.m4
-ltversion.m4
diff --git a/man/Makefile.am b/man/Makefile.am
deleted file mode 100644
index 00eb4234..00000000
--- a/man/Makefile.am
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# This generates man-pages out of the Docbook XML files. Simply add your files
-# to the relevant *man_PRE array. If aliases are created, please add them to the
-# *man_aliases_PRE array so they get installed correctly.
-#
-
-libman_PRE = \
- drmAvailable.xml \
- drmHandleEvent.xml \
- drmModeGetResources.xml
-
-miscman_PRE = \
- drm.xml \
- drm-kms.xml \
- drm-memory.xml
-
-miscman_aliases_PRE = \
- drm-mm.xml \
- drm-gem.xml \
- drm-ttm.xml
-
-libmandir = $(LIB_MAN_DIR)
-miscmandir = $(MISC_MAN_DIR)
-miscman_aliasesdir = $(MISC_MAN_DIR)
-
-libman_DATA = $(libman_PRE:.xml=.$(LIB_MAN_SUFFIX))
-miscman_DATA = $(miscman_PRE:.xml=.$(MISC_MAN_SUFFIX))
-miscman_aliases_DATA = $(miscman_aliases_PRE:.xml=.$(MISC_MAN_SUFFIX))
-
-XML_FILES = \
- $(libman_PRE) \
- $(miscman_PRE)
-
-MAN_FILES = \
- $(libman_DATA) \
- $(miscman_DATA) \
- $(miscman_aliases_DATA)
-
-EXTRA_DIST = $(XML_FILES)
-CLEANFILES = $(MAN_FILES)
-
-XSLTPROC_FLAGS = \
- --stringparam man.authors.section.enabled 0 \
- --stringparam man.copyright.section.enabled 0 \
- --stringparam funcsynopsis.style ansi \
- --stringparam man.output.quietly 1 \
- --nonet \
- $(MANPAGES_STYLESHEET)
-
-XSLTPROC_PROCESS_MAN = \
- $(AM_V_GEN)$(XSLTPROC) -o "$@" $(XSLTPROC_FLAGS) "$<"
-
-$(miscman_aliases_DATA): $(miscman_DATA)
- $(AM_V_GEN)if test -n "$@" ; then $(SED) -i -e 's/^\.so \([a-z_]\+\)\.\([0-9]\)$$/\.so man\2\/\1\.\2/' "$@" ; fi
-
-SUFFIXES = .$(LIB_MAN_SUFFIX) .$(MISC_MAN_SUFFIX) .xml
-
-.xml.$(LIB_MAN_SUFFIX):
- $(XSLTPROC_PROCESS_MAN)
-
-.xml.$(MISC_MAN_SUFFIX):
- $(XSLTPROC_PROCESS_MAN)
diff --git a/meson.build b/meson.build
index e292554a..831c8836 100644
--- a/meson.build
+++ b/meson.build
@@ -21,7 +21,7 @@
project(
'libdrm',
['c'],
- version : '2.4.99',
+ version : '2.4.102',
license : 'MIT',
meson_version : '>= 0.43',
default_options : ['buildtype=debugoptimized', 'c_std=gnu99'],
@@ -44,14 +44,18 @@ dep_threads = dependency('threads')
cc = meson.get_compiler('c')
+symbols_check = find_program('symbols-check.py')
+prog_nm = find_program('nm')
+
# Check for atomics
intel_atomics = false
lib_atomics = false
dep_atomic_ops = dependency('atomic_ops', required : false)
-if cc.compiles('''
+if cc.links('''
int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }
+ int main() { }
''',
name : 'Intel Atomics')
intel_atomics = true
@@ -179,13 +183,31 @@ else
dep_rt = []
endif
dep_m = cc.find_library('m', required : false)
-foreach header : ['sys/sysctl.h', 'sys/select.h', 'alloca.h']
- config.set('HAVE_' + header.underscorify().to_upper(),
+
+# The header is not required on Linux, and is in fact deprecated in glibc 2.30+
+if ['linux'].contains(host_machine.system())
+ config.set10('HAVE_SYS_SYSCTL_H', false)
+else
+ # From Niclas Zeising:
+ # FreeBSD requires sys/types.h for sys/sysctl.h, so add it as part of
+ # the includes when checking for headers.
+ config.set10('HAVE_SYS_SYSCTL_H',
+ cc.compiles('#include <sys/types.h>\n#include <sys/sysctl.h>', name : 'sys/sysctl.h works'))
+endif
+
+foreach header : ['sys/select.h', 'alloca.h']
+ config.set10('HAVE_' + header.underscorify().to_upper(),
cc.compiles('#include <@0@>'.format(header), name : '@0@ works'.format(header)))
endforeach
-if cc.has_header_symbol('sys/sysmacros.h', 'major')
+
+if (cc.has_header_symbol('sys/sysmacros.h', 'major') and
+ cc.has_header_symbol('sys/sysmacros.h', 'minor') and
+ cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
config.set10('MAJOR_IN_SYSMACROS', true)
-elif cc.has_header_symbol('sys/mkdev.h', 'major')
+endif
+if (cc.has_header_symbol('sys/mkdev.h', 'major') and
+ cc.has_header_symbol('sys/mkdev.h', 'minor') and
+ cc.has_header_symbol('sys/mkdev.h', 'makedev'))
config.set10('MAJOR_IN_MKDEV', true)
endif
config.set10('HAVE_OPEN_MEMSTREAM', cc.has_function('open_memstream'))
@@ -227,7 +249,11 @@ else
endif
_valgrind = get_option('valgrind')
if _valgrind != 'false'
- dep_valgrind = dependency('valgrind', required : _valgrind == 'true')
+ if with_freedreno
+ dep_valgrind = dependency('valgrind', required : _valgrind == 'true', version : '>=3.10.0')
+ else
+ dep_valgrind = dependency('valgrind', required : _valgrind == 'true')
+ endif
with_valgrind = dep_valgrind.found()
else
dep_valgrind = []
@@ -248,9 +274,6 @@ if prog_xslt.found()
endif
with_man_pages = with_man_pages != 'false' and prog_xslt.found() and prog_sed.found()
-# Used for tets
-prog_bash = find_program('bash')
-
config.set10('HAVE_VISIBILITY',
cc.compiles('''int foo_hidden(void) __attribute__((visibility(("hidden"))));''',
name : 'compiler supports __attribute__(("hidden"))'))
@@ -276,7 +299,7 @@ config_file = configure_file(
configuration : config,
output : 'config.h',
)
-add_project_arguments('-include', 'config.h', language : 'c')
+add_project_arguments('-include', '@0@'.format(config_file), language : 'c')
inc_root = include_directories('.')
inc_drm = include_directories('include/drm')
@@ -296,6 +319,16 @@ libdrm = shared_library(
install : true,
)
+test(
+ 'core-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm,
+ '--symbols-file', files('core-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
+)
+
ext_libdrm = declare_dependency(
link_with : libdrm,
include_directories : [inc_root, inc_drm],
@@ -326,9 +359,6 @@ pkg.generate(
description : 'Userspace interface to kernel DRM services',
)
-env_test = environment()
-env_test.set('NM', find_program('nm').path())
-
if with_libkms
subdir('libkms')
endif
diff --git a/nouveau/Makefile.am b/nouveau/Makefile.am
deleted file mode 100644
index 5574fd8f..00000000
--- a/nouveau/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- -I$(top_srcdir)/include/drm \
- -DDEBUG
-
-libdrm_nouveau_la_LTLIBRARIES = libdrm_nouveau.la
-libdrm_nouveau_ladir = $(libdir)
-libdrm_nouveau_la_LDFLAGS = -version-number 2:0:0 -no-undefined
-libdrm_nouveau_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-
-libdrm_nouveau_la_SOURCES = $(LIBDRM_NOUVEAU_FILES)
-
-libdrm_nouveauincludedir = ${includedir}/libdrm/nouveau
-libdrm_nouveauinclude_HEADERS = $(LIBDRM_NOUVEAU_H_FILES)
-
-libdrm_nouveaunvifincludedir = ${includedir}/libdrm/nouveau/nvif
-libdrm_nouveaunvifinclude_HEADERS = nvif/class.h \
- nvif/cl0080.h \
- nvif/cl9097.h \
- nvif/if0002.h \
- nvif/if0003.h \
- nvif/ioctl.h \
- nvif/unpack.h
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_nouveau.pc
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = nouveau-symbol-check
-EXTRA_DIST = $(TESTS)
diff --git a/nouveau/meson.build b/nouveau/meson.build
index 0c1498d7..9bd58fca 100644
--- a/nouveau/meson.build
+++ b/nouveau/meson.build
@@ -52,8 +52,11 @@ pkg.generate(
)
test(
- 'nouveau-symbol-check',
- prog_bash,
- env : env_test,
- args : [files('nouveau-symbol-check'), libdrm_nouveau]
+ 'nouveau-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm_nouveau,
+ '--symbols-file', files('nouveau-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/nouveau/nouveau-symbol-check b/nouveau/nouveau-symbols.txt
index 6296244c..ef8032f2 100755..100644
--- a/nouveau/nouveau-symbol-check
+++ b/nouveau/nouveau-symbols.txt
@@ -1,17 +1,3 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first five) are taken from the public headers.
-# A list of the latter should be available Makefile.sources/LIBDRM_NOUVEAU_H_FILES
-
-FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libdrm_nouveau.so} | awk '{print $3}'| while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_start
-_edata
-_end
-_fini
-_init
nouveau_bo_map
nouveau_bo_name_get
nouveau_bo_name_ref
@@ -53,8 +39,3 @@ nouveau_pushbuf_reloc
nouveau_pushbuf_space
nouveau_pushbuf_validate
nouveau_setparam
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/nouveau/private.h b/nouveau/private.h
index 83060f96..034a958e 100644
--- a/nouveau/private.h
+++ b/nouveau/private.h
@@ -10,7 +10,7 @@
#include "nouveau.h"
#ifdef DEBUG
-drm_private uint32_t nouveau_debug;
+drm_private extern uint32_t nouveau_debug;
#define dbg_on(lvl) (nouveau_debug & (1 << lvl))
#define dbg(lvl, fmt, args...) do { \
if (dbg_on((lvl))) \
diff --git a/omap/Makefile.am b/omap/Makefile.am
deleted file mode 100644
index 38a1007b..00000000
--- a/omap/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_omap_la_LTLIBRARIES = libdrm_omap.la
-libdrm_omap_ladir = $(libdir)
-libdrm_omap_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libdrm_omap_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-
-libdrm_omap_la_SOURCES = omap_drm.c
-
-libdrm_omapcommonincludedir = ${includedir}/omap
-libdrm_omapcommoninclude_HEADERS = omap_drm.h
-
-libdrm_omapincludedir = ${includedir}/libdrm
-libdrm_omapinclude_HEADERS = omap_drmif.h
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_omap.pc
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = omap-symbol-check
-EXTRA_DIST = $(TESTS)
diff --git a/omap/meson.build b/omap/meson.build
index 54698c6a..53330b61 100644
--- a/omap/meson.build
+++ b/omap/meson.build
@@ -47,8 +47,11 @@ pkg.generate(
)
test(
- 'omap-symbol-check',
- prog_bash,
- env : env_test,
- args : [files('omap-symbol-check'), libdrm_omap]
+ 'omap-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm_omap,
+ '--symbols-file', files('omap-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/omap/omap-symbol-check b/omap/omap-symbol-check
deleted file mode 100755
index 16da3c40..00000000
--- a/omap/omap-symbol-check
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first five) are taken from the public headers.
-# A list of the latter should be available Makefile.am/libdrm_omap*HEADERS
-
-FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libdrm_omap.so} | awk '{print $3}'| while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_start
-_edata
-_end
-_fini
-_init
-omap_bo_cpu_fini
-omap_bo_cpu_prep
-omap_bo_del
-omap_bo_dmabuf
-omap_bo_from_dmabuf
-omap_bo_from_name
-omap_bo_get_name
-omap_bo_handle
-omap_bo_map
-omap_bo_new
-omap_bo_new_tiled
-omap_bo_ref
-omap_bo_size
-omap_device_del
-omap_device_new
-omap_device_ref
-omap_get_param
-omap_set_param
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/omap/omap-symbols.txt b/omap/omap-symbols.txt
new file mode 100644
index 00000000..749d0f7c
--- /dev/null
+++ b/omap/omap-symbols.txt
@@ -0,0 +1,18 @@
+omap_bo_cpu_fini
+omap_bo_cpu_prep
+omap_bo_del
+omap_bo_dmabuf
+omap_bo_from_dmabuf
+omap_bo_from_name
+omap_bo_get_name
+omap_bo_handle
+omap_bo_map
+omap_bo_new
+omap_bo_new_tiled
+omap_bo_ref
+omap_bo_size
+omap_device_del
+omap_device_new
+omap_device_ref
+omap_get_param
+omap_set_param
diff --git a/radeon/Makefile.am b/radeon/Makefile.am
deleted file mode 100644
index e712a4ac..00000000
--- a/radeon/Makefile.am
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright © 2008 Jérôme Glisse
-#
-# 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:
-# Jérôme Glisse <glisse@freedesktop.org>
-
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_radeon_la_LTLIBRARIES = libdrm_radeon.la
-libdrm_radeon_ladir = $(libdir)
-libdrm_radeon_la_LDFLAGS = -version-number 1:0:1 -no-undefined
-libdrm_radeon_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-
-libdrm_radeon_la_SOURCES = $(LIBDRM_RADEON_FILES)
-
-libdrm_radeonincludedir = ${includedir}/libdrm
-libdrm_radeoninclude_HEADERS = $(LIBDRM_RADEON_H_FILES)
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_radeon.pc
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = radeon-symbol-check
-EXTRA_DIST = $(LIBDRM_RADEON_BOF_FILES) $(TESTS)
diff --git a/radeon/meson.build b/radeon/meson.build
index 1fc5282c..ca128329 100644
--- a/radeon/meson.build
+++ b/radeon/meson.build
@@ -57,8 +57,11 @@ pkg.generate(
)
test(
- 'radeon-symbol-check',
- prog_bash,
- env : env_test,
- args : [files('radeon-symbol-check'), libdrm_radeon]
+ 'radeon-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm_radeon,
+ '--symbols-file', files('radeon-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/radeon/radeon-symbol-check b/radeon/radeon-symbols.txt
index da605bb8..5a532d83 100755..100644
--- a/radeon/radeon-symbol-check
+++ b/radeon/radeon-symbols.txt
@@ -1,17 +1,3 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first five) are taken from the public headers.
-# A list of the latter should be available Makefile.sources/LIBDRM_RADEON_H_FILES
-
-FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libdrm_radeon.so} | awk '{print $3}'| while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_start
-_edata
-_end
-_fini
-_init
radeon_bo_debug
radeon_bo_get_handle
radeon_bo_get_src_domain
@@ -56,8 +42,3 @@ radeon_surface_best
radeon_surface_init
radeon_surface_manager_free
radeon_surface_manager_new
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/symbols-check.py b/symbols-check.py
new file mode 100644
index 00000000..2e7ba68d
--- /dev/null
+++ b/symbols-check.py
@@ -0,0 +1,130 @@
+#!/usr/bin/env python3
+
+import argparse
+import os
+import platform
+import subprocess
+
+# This list contains symbols that _might_ be exported for some platforms
+PLATFORM_SYMBOLS = [
+ '__bss_end__',
+ '__bss_start__',
+ '__bss_start',
+ '__end__',
+ '_bss_end__',
+ '_edata',
+ '_end',
+ '_fini',
+ '_init',
+]
+
+
+def get_symbols(nm, lib):
+ '''
+ List all the (non platform-specific) symbols exported by the library
+ '''
+ symbols = []
+ platform_name = platform.system()
+ output = subprocess.check_output([nm, '-gP', lib],
+ stderr=open(os.devnull, 'w')).decode("ascii")
+ for line in output.splitlines():
+ fields = line.split()
+ if len(fields) == 2 or fields[1] == 'U':
+ continue
+ symbol_name = fields[0]
+ if platform_name == 'Linux':
+ if symbol_name in PLATFORM_SYMBOLS:
+ continue
+ elif platform_name == 'Darwin':
+ assert symbol_name[0] == '_'
+ symbol_name = symbol_name[1:]
+ symbols.append(symbol_name)
+
+ return symbols
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--symbols-file',
+ action='store',
+ required=True,
+ help='path to file containing symbols')
+ parser.add_argument('--lib',
+ action='store',
+ required=True,
+ help='path to library')
+ parser.add_argument('--nm',
+ action='store',
+ required=True,
+ help='path to binary (or name in $PATH)')
+ args = parser.parse_args()
+
+ try:
+ lib_symbols = get_symbols(args.nm, args.lib)
+ except:
+ # We can't run this test, but we haven't technically failed it either
+ # Return the GNU "skip" error code
+ exit(77)
+ mandatory_symbols = []
+ optional_symbols = []
+ with open(args.symbols_file) as symbols_file:
+ qualifier_optional = '(optional)'
+ for line in symbols_file.readlines():
+
+ # Strip comments
+ line = line.split('#')[0]
+ line = line.strip()
+ if not line:
+ continue
+
+ # Line format:
+ # [qualifier] symbol
+ qualifier = None
+ symbol = None
+
+ fields = line.split()
+ if len(fields) == 1:
+ symbol = fields[0]
+ elif len(fields) == 2:
+ qualifier = fields[0]
+ symbol = fields[1]
+ else:
+ print(args.symbols_file + ': invalid format: ' + line)
+ exit(1)
+
+ # The only supported qualifier is 'optional', which means the
+ # symbol doesn't have to be exported by the library
+ if qualifier and not qualifier == qualifier_optional:
+ print(args.symbols_file + ': invalid qualifier: ' + qualifier)
+ exit(1)
+
+ if qualifier == qualifier_optional:
+ optional_symbols.append(symbol)
+ else:
+ mandatory_symbols.append(symbol)
+
+ unknown_symbols = []
+ for symbol in lib_symbols:
+ if symbol in mandatory_symbols:
+ continue
+ if symbol in optional_symbols:
+ continue
+ unknown_symbols.append(symbol)
+
+ missing_symbols = [
+ sym for sym in mandatory_symbols if sym not in lib_symbols
+ ]
+
+ for symbol in unknown_symbols:
+ print(args.lib + ': unknown symbol exported: ' + symbol)
+
+ for symbol in missing_symbols:
+ print(args.lib + ': missing symbol: ' + symbol)
+
+ if unknown_symbols or missing_symbols:
+ exit(1)
+ exit(0)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tegra/Makefile.am b/tegra/Makefile.am
deleted file mode 100644
index 53119970..00000000
--- a/tegra/Makefile.am
+++ /dev/null
@@ -1,27 +0,0 @@
-AM_CPPFLAGS = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/include/drm
-
-AM_CFLAGS = \
- @PTHREADSTUBS_CFLAGS@ \
- $(WARN_CFLAGS) \
- -fvisibility=hidden
-
-libdrm_tegra_ladir = $(libdir)
-libdrm_tegra_la_LTLIBRARIES = libdrm_tegra.la
-libdrm_tegra_la_LDFLAGS = -version-number 0:0:0 -no-undefined
-libdrm_tegra_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
-
-libdrm_tegra_la_SOURCES = \
- private.h \
- tegra.c
-
-libdrm_tegraincludedir = ${includedir}/libdrm
-libdrm_tegrainclude_HEADERS = tegra.h
-
-pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = libdrm_tegra.pc
-
-AM_TESTS_ENVIRONMENT = NM='$(NM)'
-TESTS = tegra-symbol-check
-EXTRA_DIST = $(TESTS)
diff --git a/tegra/meson.build b/tegra/meson.build
index 4bc454b6..88613b9c 100644
--- a/tegra/meson.build
+++ b/tegra/meson.build
@@ -46,8 +46,11 @@ pkg.generate(
)
test(
- 'tegra-symbol-check',
- prog_bash,
- env : env_test,
- args : [files('tegra-symbol-check'), libdrm_tegra]
+ 'tegra-symbols-check',
+ symbols_check,
+ args : [
+ '--lib', libdrm_tegra,
+ '--symbols-file', files('tegra-symbols.txt'),
+ '--nm', prog_nm.path(),
+ ],
)
diff --git a/tegra/tegra-symbol-check b/tegra/tegra-symbol-check
deleted file mode 100755
index 8539b95b..00000000
--- a/tegra/tegra-symbol-check
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-
-set -u
-
-# The following symbols (past the first nine) are taken from tegra.h.
-
-FUNCS=$($NM -D --format=bsd --defined-only ${1-.libs/libdrm_tegra.so} | awk '{print $3}'| while read func; do
-( grep -q "^$func$" || echo $func ) <<EOF
-__bss_end__
-__bss_start__
-__bss_start
-__end__
-_bss_end__
-_edata
-_end
-_fini
-_init
-drm_tegra_bo_get_flags
-drm_tegra_bo_get_handle
-drm_tegra_bo_get_tiling
-drm_tegra_bo_map
-drm_tegra_bo_new
-drm_tegra_bo_ref
-drm_tegra_bo_set_flags
-drm_tegra_bo_set_tiling
-drm_tegra_bo_unmap
-drm_tegra_bo_unref
-drm_tegra_bo_wrap
-drm_tegra_close
-drm_tegra_new
-EOF
-done)
-
-test ! -n "$FUNCS" || echo $FUNCS
-test ! -n "$FUNCS"
diff --git a/tegra/tegra-symbols.txt b/tegra/tegra-symbols.txt
new file mode 100644
index 00000000..5e3e955f
--- /dev/null
+++ b/tegra/tegra-symbols.txt
@@ -0,0 +1,13 @@
+drm_tegra_bo_get_flags
+drm_tegra_bo_get_handle
+drm_tegra_bo_get_tiling
+drm_tegra_bo_map
+drm_tegra_bo_new
+drm_tegra_bo_ref
+drm_tegra_bo_set_flags
+drm_tegra_bo_set_tiling
+drm_tegra_bo_unmap
+drm_tegra_bo_unref
+drm_tegra_bo_wrap
+drm_tegra_close
+drm_tegra_new
diff --git a/tests/Makefile.am b/tests/Makefile.am
deleted file mode 100644
index d274a3e9..00000000
--- a/tests/Makefile.am
+++ /dev/null
@@ -1,53 +0,0 @@
-SUBDIRS = util kms modeprint proptest modetest vbltest
-
-if HAVE_LIBKMS
-SUBDIRS += kmstest
-endif
-
-if HAVE_RADEON
-SUBDIRS += radeon
-endif
-
-if HAVE_AMDGPU
-if HAVE_CUNIT
-SUBDIRS += amdgpu
-endif
-endif
-
-if HAVE_EXYNOS
-SUBDIRS += exynos
-endif
-
-if HAVE_TEGRA
-SUBDIRS += tegra
-endif
-
-if HAVE_ETNAVIV
-SUBDIRS += etnaviv
-endif
-
-if HAVE_NOUVEAU
-SUBDIRS += nouveau
-endif
-
-AM_CFLAGS = \
- $(WARN_CFLAGS)\
- -fvisibility=hidden \
- -I $(top_srcdir)/include/drm \
- -I $(top_srcdir)
-
-LDADD = $(top_builddir)/libdrm.la
-
-TESTS = \
- drmsl \
- hash \
- random
-
-check_PROGRAMS = \
- $(TESTS)
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS = drmdevice
-else
-check_PROGRAMS += drmdevice
-endif
diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am
deleted file mode 100644
index 920882d0..00000000
--- a/tests/amdgpu/Makefile.am
+++ /dev/null
@@ -1,38 +0,0 @@
-AM_CFLAGS = \
- -fvisibility=hidden \
- -I $(top_srcdir)/include/drm \
- -I $(top_srcdir)/amdgpu \
- -I $(top_srcdir) \
- -pthread
-
-LDADD = $(top_builddir)/libdrm.la \
- $(top_builddir)/amdgpu/libdrm_amdgpu.la \
- $(CUNIT_LIBS)
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS = \
- amdgpu_test
-else
-noinst_PROGRAMS = \
- amdgpu_test
-endif
-
-amdgpu_test_CPPFLAGS = $(CUNIT_CFLAGS)
-
-amdgpu_test_SOURCES = \
- amdgpu_test.c \
- amdgpu_test.h \
- basic_tests.c \
- bo_tests.c \
- cs_tests.c \
- decode_messages.h \
- vce_tests.c \
- vce_ib.h \
- frame.h \
- uvd_enc_tests.c \
- vcn_tests.c \
- uve_ib.h \
- deadlock_tests.c \
- vm_tests.c \
- ras_tests.c \
- syncobj_tests.c
diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
index 73403fb4..47e16762 100644
--- a/tests/amdgpu/amdgpu_test.c
+++ b/tests/amdgpu/amdgpu_test.c
@@ -202,44 +202,42 @@ static void display_test_suites(void)
CU_pSuite pSuite = NULL;
CU_pTest pTest = NULL;
- printf("Suites\n");
+ printf("%5s: %2s: %8s: %s\n", "What", "ID", "Status", "Name");
for (iSuite = 0; suites[iSuite].pName != NULL; iSuite++) {
pSuite = CU_get_suite_by_index((unsigned int) iSuite + 1,
- CU_get_registry());
+ CU_get_registry());
if (!pSuite) {
fprintf(stderr, "Invalid suite id : %d\n", iSuite + 1);
continue;
}
- printf("Suite id = %d: Name '%s status: %s'\n",
- iSuite + 1, suites[iSuite].pName,
- pSuite->fActive ? "ENABLED" : "DISABLED");
-
+ printf("Suite: %2d: %8s: %s\n",
+ iSuite + 1,
+ pSuite->fActive ? "ENABLED" : "DISABLED",
+ suites[iSuite].pName);
+ if (!pSuite->fActive)
+ continue;
for (iTest = 0; suites[iSuite].pTests[iTest].pName != NULL;
- iTest++) {
-
+ iTest++) {
pTest = CU_get_test_by_index((unsigned int) iTest + 1,
- pSuite);
-
+ pSuite);
if (!pTest) {
fprintf(stderr, "Invalid test id : %d\n", iTest + 1);
continue;
}
-
- printf("Test id %d: Name: '%s status: %s'\n", iTest + 1,
- suites[iSuite].pTests[iTest].pName,
- pSuite->fActive && pTest->fActive ?
- "ENABLED" : "DISABLED");
+ printf(" Test: %2d: %8s: %s\n",
+ iTest + 1,
+ pSuite->fActive && pTest->fActive ? "ENABLED" : "DISABLED",
+ suites[iSuite].pTests[iTest].pName);
}
}
}
-
/** Help string for command line parameters */
static const char usage[] =
"Usage: %s [-hlpr] [<-s <suite id>> [-t <test id>] [-f]] "
@@ -452,6 +450,41 @@ static void amdgpu_disable_suites()
"sdma ring block test (set amdgpu.lockup_timeout=50)", CU_FALSE))
fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+ /* This test was ran on GFX9 only */
+ //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
+ if (amdgpu_set_test_active(DEADLOCK_TESTS_STR,
+ "gfx ring bad dispatch test (set amdgpu.lockup_timeout=50)", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+
+ /* This test was ran on GFX9 only */
+ //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
+ if (amdgpu_set_test_active(DEADLOCK_TESTS_STR,
+ "compute ring bad dispatch test (set amdgpu.lockup_timeout=50,50)", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+
+ /* This test was ran on GFX9 only */
+ //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
+ if (amdgpu_set_test_active(DEADLOCK_TESTS_STR,
+ "gfx ring bad slow dispatch test (set amdgpu.lockup_timeout=50)", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+
+ /* This test was ran on GFX9 only */
+ //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
+ if (amdgpu_set_test_active(DEADLOCK_TESTS_STR,
+ "compute ring bad slow dispatch test (set amdgpu.lockup_timeout=50,50)", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+
+ //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
+ if (amdgpu_set_test_active(DEADLOCK_TESTS_STR,
+ "gfx ring bad draw test (set amdgpu.lockup_timeout=50)", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+
+ /* This test was ran on GFX9 only */
+ //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
+ if (amdgpu_set_test_active(DEADLOCK_TESTS_STR,
+ "gfx ring slow bad draw test (set amdgpu.lockup_timeout=50)", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+
if (amdgpu_set_test_active(BO_TESTS_STR, "Metadata", CU_FALSE))
fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
@@ -464,14 +497,22 @@ static void amdgpu_disable_suites()
fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
/* This test was ran on GFX9 only */
- if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
- if (amdgpu_set_test_active(BASIC_TESTS_STR, "Dispatch Test", CU_FALSE))
+ if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV) {
+ if (amdgpu_set_test_active(BASIC_TESTS_STR, "Dispatch Test (GFX)", CU_FALSE))
fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+ if (amdgpu_set_test_active(BASIC_TESTS_STR, "Dispatch Test (Compute)", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+ }
/* This test was ran on GFX9 only */
if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
if (amdgpu_set_test_active(BASIC_TESTS_STR, "Draw Test", CU_FALSE))
fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+
+ /* This test was ran on GFX9 only */
+ //if (family_id < AMDGPU_FAMILY_AI || family_id > AMDGPU_FAMILY_RV)
+ if (amdgpu_set_test_active(BASIC_TESTS_STR, "GPU reset Test", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
}
/* The main() function for setting up and running the tests.
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index 36675ea3..f5492258 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -236,6 +236,11 @@ CU_BOOL suite_syncobj_timeline_tests_enable(void);
*/
extern CU_TestInfo syncobj_timeline_tests[];
+void amdgpu_dispatch_hang_helper(amdgpu_device_handle device_handle, uint32_t ip_type);
+void amdgpu_dispatch_hang_slow_helper(amdgpu_device_handle device_handle, uint32_t ip_type);
+void amdgpu_memcpy_draw_test(amdgpu_device_handle device_handle, uint32_t ring,
+ int hang);
+void amdgpu_memcpy_draw_hang_slow_test(amdgpu_device_handle device_handle, uint32_t ring);
/**
* Helper functions
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 2d472691..57496c82 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -24,7 +24,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#ifdef HAVE_ALLOCA_H
+#include <sys/types.h>
+#ifdef MAJOR_IN_SYSMACROS
+#include <sys/sysmacros.h>
+#endif
+#include <sys/stat.h>
+#include <fcntl.h>
+#if HAVE_ALLOCA_H
# include <alloca.h>
#endif
#include <sys/wait.h>
@@ -49,8 +55,10 @@ static void amdgpu_userptr_test(void);
static void amdgpu_semaphore_test(void);
static void amdgpu_sync_dependency_test(void);
static void amdgpu_bo_eviction_test(void);
-static void amdgpu_dispatch_test(void);
+static void amdgpu_compute_dispatch_test(void);
+static void amdgpu_gfx_dispatch_test(void);
static void amdgpu_draw_test(void);
+static void amdgpu_gpu_reset_test(void);
static void amdgpu_command_submission_write_linear_helper(unsigned ip_type);
static void amdgpu_command_submission_const_fill_helper(unsigned ip_type);
@@ -72,11 +80,13 @@ CU_TestInfo basic_tests[] = {
{ "Command submission Test (SDMA)", amdgpu_command_submission_sdma },
{ "SW semaphore Test", amdgpu_semaphore_test },
{ "Sync dependency Test", amdgpu_sync_dependency_test },
- { "Dispatch Test", amdgpu_dispatch_test },
+ { "Dispatch Test (Compute)", amdgpu_compute_dispatch_test },
+ { "Dispatch Test (GFX)", amdgpu_gfx_dispatch_test },
{ "Draw Test", amdgpu_draw_test },
+ { "GPU reset Test", amdgpu_gpu_reset_test },
CU_TEST_INFO_NULL,
};
-#define BUFFER_SIZE (8 * 1024)
+#define BUFFER_SIZE (MAX2(8 * 1024, getpagesize()))
#define SDMA_PKT_HEADER_op_offset 0
#define SDMA_PKT_HEADER_op_mask 0x000000FF
#define SDMA_PKT_HEADER_op_shift 0
@@ -296,7 +306,9 @@ static uint32_t shader_bin[] = {
enum cs_type {
CS_BUFFERCLEAR,
- CS_BUFFERCOPY
+ CS_BUFFERCOPY,
+ CS_HANG,
+ CS_HANG_SLOW
};
static const uint32_t bufferclear_cs_shader_gfx9[] = {
@@ -329,14 +341,15 @@ static const uint32_t preamblecache_gfx9[] = {
0xc0016900, 0x2d5, 0x10000, 0xc0016900, 0x2dc, 0x0,
0xc0066900, 0x2de, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0026900, 0x2e5, 0x0, 0x0,
0xc0056900, 0x2f9, 0x5, 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000,
- 0xc0026900, 0x311, 0x3, 0x0, 0xc0026900, 0x316, 0x1e, 0x20,
+ 0xc0036900, 0x311, 0x3, 0, 0x100000, 0xc0026900, 0x316, 0x1e, 0x20,
0xc0016900, 0x349, 0x0, 0xc0016900, 0x358, 0x0, 0xc0016900, 0x367, 0x0,
0xc0016900, 0x376, 0x0, 0xc0016900, 0x385, 0x0, 0xc0016900, 0x19, 0x0,
0xc0056900, 0xe8, 0x0, 0x0, 0x0, 0x0, 0x0,
0xc0076900, 0x1e1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0xc0026900, 0x204, 0x90000, 0x4, 0xc0046900, 0x20c, 0x0, 0x0, 0x0, 0x0,
0xc0016900, 0x2b2, 0x0, 0xc0026900, 0x30e, 0xffffffff, 0xffffffff,
- 0xc0016900, 0x314, 0x0, 0xc0002f00, 0x1, 0xc0016900, 0x1, 0x1,
+ 0xc0016900, 0x314, 0x0, 0xc0016900, 0x2a6, 0, 0xc0016900, 0x210, 0,
+ 0xc0002f00, 0x1, 0xc0016900, 0x1, 0x1,
0xc0016900, 0x18, 0x2, 0xc0016900, 0x206, 0x300, 0xc0017900, 0x20000243, 0x0,
0xc0017900, 0x248, 0xffffffff, 0xc0017900, 0x249, 0x0, 0xc0017900, 0x24a, 0x0,
0xc0017900, 0x24b, 0x0
@@ -344,7 +357,9 @@ static const uint32_t preamblecache_gfx9[] = {
enum ps_type {
PS_CONST,
- PS_TEX
+ PS_TEX,
+ PS_HANG,
+ PS_HANG_SLOW
};
static const uint32_t ps_const_shader_gfx9[] = {
@@ -457,6 +472,60 @@ static const uint32_t cached_cmd_gfx9[] = {
0xc0026900, 0x2b0, 0x0, 0x0, 0xc0016900, 0x2f8, 0x0
};
+unsigned int memcpy_ps_hang[] = {
+ 0xFFFFFFFF, 0xBEFE0A7E, 0xBEFC0304, 0xC0C20100,
+ 0xC0800300, 0xC8080000, 0xC80C0100, 0xC8090001,
+ 0xC80D0101, 0xBF8C007F, 0xF0800F00, 0x00010002,
+ 0xBEFE040C, 0xBF8C0F70, 0xBF800000, 0xBF800000,
+ 0xF800180F, 0x03020100, 0xBF810000
+};
+
+struct amdgpu_test_shader {
+ uint32_t *shader;
+ uint32_t header_length;
+ uint32_t body_length;
+ uint32_t foot_length;
+};
+
+unsigned int memcpy_cs_hang_slow_ai_codes[] = {
+ 0xd1fd0000, 0x04010c08, 0xe00c2000, 0x80000100,
+ 0xbf8c0f70, 0xe01c2000, 0x80010100, 0xbf810000
+};
+
+struct amdgpu_test_shader memcpy_cs_hang_slow_ai = {
+ memcpy_cs_hang_slow_ai_codes,
+ 4,
+ 3,
+ 1
+};
+
+unsigned int memcpy_cs_hang_slow_rv_codes[] = {
+ 0x8e00860c, 0x32000000, 0xe00c2000, 0x80010100,
+ 0xbf8c0f70, 0xe01c2000, 0x80020100, 0xbf810000
+};
+
+struct amdgpu_test_shader memcpy_cs_hang_slow_rv = {
+ memcpy_cs_hang_slow_rv_codes,
+ 4,
+ 3,
+ 1
+};
+
+unsigned int memcpy_ps_hang_slow_ai_codes[] = {
+ 0xbefc000c, 0xbe8e017e, 0xbefe077e, 0xd4080000,
+ 0xd4090001, 0xd40c0100, 0xd40d0101, 0xf0800f00,
+ 0x00400002, 0xbefe010e, 0xbf8c0f70, 0xbf800000,
+ 0xbf800000, 0xbf800000, 0xbf800000, 0xc400180f,
+ 0x03020100, 0xbf810000
+};
+
+struct amdgpu_test_shader memcpy_ps_hang_slow_ai = {
+ memcpy_ps_hang_slow_ai_codes,
+ 7,
+ 2,
+ 9
+};
+
int amdgpu_bo_alloc_and_map_raw(amdgpu_device_handle dev, unsigned size,
unsigned alignment, unsigned heap, uint64_t alloc_flags,
uint64_t mapping_flags, amdgpu_bo_handle *bo, void **cpu,
@@ -2054,6 +2123,37 @@ static void amdgpu_sync_dependency_test(void)
free(ibs_request.dependencies);
}
+static int amdgpu_dispatch_load_cs_shader_hang_slow(uint32_t *ptr, int family)
+{
+ struct amdgpu_test_shader *shader;
+ int i, loop = 0x10000;
+
+ switch (family) {
+ case AMDGPU_FAMILY_AI:
+ shader = &memcpy_cs_hang_slow_ai;
+ break;
+ case AMDGPU_FAMILY_RV:
+ shader = &memcpy_cs_hang_slow_rv;
+ break;
+ default:
+ return -1;
+ break;
+ }
+
+ memcpy(ptr, shader->shader, shader->header_length * sizeof(uint32_t));
+
+ for (i = 0; i < loop; i++)
+ memcpy(ptr + shader->header_length + shader->body_length * i,
+ shader->shader + shader->header_length,
+ shader->body_length * sizeof(uint32_t));
+
+ memcpy(ptr + shader->header_length + shader->body_length * loop,
+ shader->shader + shader->header_length + shader->body_length,
+ shader->foot_length * sizeof(uint32_t));
+
+ return 0;
+}
+
static int amdgpu_dispatch_load_cs_shader(uint8_t *ptr,
int cs_type)
{
@@ -2069,6 +2169,10 @@ static int amdgpu_dispatch_load_cs_shader(uint8_t *ptr,
shader = buffercopy_cs_shader_gfx9;
shader_size = sizeof(buffercopy_cs_shader_gfx9);
break;
+ case CS_HANG:
+ shader = memcpy_ps_hang;
+ shader_size = sizeof(memcpy_ps_hang);
+ break;
default:
return -1;
break;
@@ -2094,10 +2198,7 @@ static int amdgpu_dispatch_init(uint32_t *ptr, uint32_t ip_type)
ptr[i++] = PACKET3_COMPUTE(PKT3_SET_SH_REG, 3);
ptr[i++] = 0x204;
i += 3;
- /* clear mmCOMPUTE_RESOURCE_LIMITS */
- ptr[i++] = PACKET3_COMPUTE(PKT3_SET_SH_REG, 1);
- ptr[i++] = 0x215;
- ptr[i++] = 0;
+
/* clear mmCOMPUTE_TMPRING_SIZE */
ptr[i++] = PACKET3_COMPUTE(PKT3_SET_SH_REG, 1);
ptr[i++] = 0x218;
@@ -2184,6 +2285,7 @@ static void amdgpu_memset_dispatch_test(amdgpu_device_handle device_handle,
&bo_shader, &ptr_shader,
&mc_address_shader, &va_shader);
CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_shader, 0, bo_shader_size);
r = amdgpu_dispatch_load_cs_shader(ptr_shader, CS_BUFFERCLEAR);
CU_ASSERT_EQUAL(r, 0);
@@ -2220,6 +2322,11 @@ static void amdgpu_memset_dispatch_test(amdgpu_device_handle device_handle,
ptr_cmd[i++] = 0x22222222;
ptr_cmd[i++] = 0x22222222;
+ /* clear mmCOMPUTE_RESOURCE_LIMITS */
+ ptr_cmd[i++] = PACKET3_COMPUTE(PKT3_SET_SH_REG, 1);
+ ptr_cmd[i++] = 0x215;
+ ptr_cmd[i++] = 0;
+
/* dispatch direct command */
ptr_cmd[i++] = PACKET3_COMPUTE(PACKET3_DISPATCH_DIRECT, 3);
ptr_cmd[i++] = 0x10;
@@ -2286,7 +2393,8 @@ static void amdgpu_memset_dispatch_test(amdgpu_device_handle device_handle,
static void amdgpu_memcpy_dispatch_test(amdgpu_device_handle device_handle,
uint32_t ip_type,
- uint32_t ring)
+ uint32_t ring,
+ int hang)
{
amdgpu_context_handle context_handle;
amdgpu_bo_handle bo_src, bo_dst, bo_shader, bo_cmd, resources[4];
@@ -2302,7 +2410,8 @@ static void amdgpu_memcpy_dispatch_test(amdgpu_device_handle device_handle,
int bo_cmd_size = 4096;
struct amdgpu_cs_request ibs_request = {0};
struct amdgpu_cs_ib_info ib_info= {0};
- uint32_t expired;
+ uint32_t expired, hang_state, hangs;
+ enum cs_type cs_type;
amdgpu_bo_list_handle bo_list;
struct amdgpu_cs_fence fence_status = {0};
@@ -2321,8 +2430,10 @@ static void amdgpu_memcpy_dispatch_test(amdgpu_device_handle device_handle,
&bo_shader, &ptr_shader,
&mc_address_shader, &va_shader);
CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_shader, 0, bo_shader_size);
- r = amdgpu_dispatch_load_cs_shader(ptr_shader, CS_BUFFERCOPY );
+ cs_type = hang ? CS_HANG : CS_BUFFERCOPY;
+ r = amdgpu_dispatch_load_cs_shader(ptr_shader, cs_type);
CU_ASSERT_EQUAL(r, 0);
r = amdgpu_bo_alloc_and_map(device_handle, bo_dst_size, 4096,
@@ -2365,6 +2476,11 @@ static void amdgpu_memcpy_dispatch_test(amdgpu_device_handle device_handle,
ptr_cmd[i++] = 0x400;
ptr_cmd[i++] = 0x74fac;
+ /* clear mmCOMPUTE_RESOURCE_LIMITS */
+ ptr_cmd[i++] = PACKET3_COMPUTE(PKT3_SET_SH_REG, 1);
+ ptr_cmd[i++] = 0x215;
+ ptr_cmd[i++] = 0;
+
/* dispatch direct command */
ptr_cmd[i++] = PACKET3_COMPUTE(PACKET3_DISPATCH_DIRECT, 3);
ptr_cmd[i++] = 0x10;
@@ -2403,14 +2519,21 @@ static void amdgpu_memcpy_dispatch_test(amdgpu_device_handle device_handle,
r = amdgpu_cs_query_fence_status(&fence_status,
AMDGPU_TIMEOUT_INFINITE,
0, &expired);
- CU_ASSERT_EQUAL(r, 0);
- CU_ASSERT_EQUAL(expired, true);
- /* verify if memcpy test result meets with expected */
- i = 0;
- while(i < bo_dst_size) {
- CU_ASSERT_EQUAL(ptr_dst[i], ptr_src[i]);
- i++;
+ if (!hang) {
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL(expired, true);
+
+ /* verify if memcpy test result meets with expected */
+ i = 0;
+ while(i < bo_dst_size) {
+ CU_ASSERT_EQUAL(ptr_dst[i], ptr_src[i]);
+ i++;
+ }
+ } else {
+ r = amdgpu_cs_query_reset_state(context_handle, &hang_state, &hangs);
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL(hang_state, AMDGPU_CTX_UNKNOWN_RESET);
}
r = amdgpu_bo_list_destroy(bo_list);
@@ -2430,7 +2553,8 @@ static void amdgpu_memcpy_dispatch_test(amdgpu_device_handle device_handle,
r = amdgpu_cs_ctx_free(context_handle);
CU_ASSERT_EQUAL(r, 0);
}
-static void amdgpu_dispatch_test(void)
+
+static void amdgpu_compute_dispatch_test(void)
{
int r;
struct drm_amdgpu_info_hw_ip info;
@@ -2438,21 +2562,248 @@ static void amdgpu_dispatch_test(void)
r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_COMPUTE, 0, &info);
CU_ASSERT_EQUAL(r, 0);
+ if (!info.available_rings)
+ printf("SKIP ... as there's no compute ring\n");
for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
amdgpu_memset_dispatch_test(device_handle, AMDGPU_HW_IP_COMPUTE, ring_id);
- amdgpu_memcpy_dispatch_test(device_handle, AMDGPU_HW_IP_COMPUTE, ring_id);
+ amdgpu_memcpy_dispatch_test(device_handle, AMDGPU_HW_IP_COMPUTE, ring_id, 0);
}
+}
+
+static void amdgpu_gfx_dispatch_test(void)
+{
+ int r;
+ struct drm_amdgpu_info_hw_ip info;
+ uint32_t ring_id;
r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_GFX, 0, &info);
CU_ASSERT_EQUAL(r, 0);
+ if (!info.available_rings)
+ printf("SKIP ... as there's no graphics ring\n");
for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
amdgpu_memset_dispatch_test(device_handle, AMDGPU_HW_IP_GFX, ring_id);
- amdgpu_memcpy_dispatch_test(device_handle, AMDGPU_HW_IP_GFX, ring_id);
+ amdgpu_memcpy_dispatch_test(device_handle, AMDGPU_HW_IP_GFX, ring_id, 0);
+ }
+}
+
+void amdgpu_dispatch_hang_helper(amdgpu_device_handle device_handle, uint32_t ip_type)
+{
+ int r;
+ struct drm_amdgpu_info_hw_ip info;
+ uint32_t ring_id;
+
+ r = amdgpu_query_hw_ip_info(device_handle, ip_type, 0, &info);
+ CU_ASSERT_EQUAL(r, 0);
+ if (!info.available_rings)
+ printf("SKIP ... as there's no ring for ip %d\n", ip_type);
+
+ for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
+ amdgpu_memcpy_dispatch_test(device_handle, ip_type, ring_id, 0);
+ amdgpu_memcpy_dispatch_test(device_handle, ip_type, ring_id, 1);
+ amdgpu_memcpy_dispatch_test(device_handle, ip_type, ring_id, 0);
}
}
+static void amdgpu_memcpy_dispatch_hang_slow_test(amdgpu_device_handle device_handle,
+ uint32_t ip_type, uint32_t ring)
+{
+ amdgpu_context_handle context_handle;
+ amdgpu_bo_handle bo_src, bo_dst, bo_shader, bo_cmd, resources[4];
+ volatile unsigned char *ptr_dst;
+ void *ptr_shader;
+ unsigned char *ptr_src;
+ uint32_t *ptr_cmd;
+ uint64_t mc_address_src, mc_address_dst, mc_address_shader, mc_address_cmd;
+ amdgpu_va_handle va_src, va_dst, va_shader, va_cmd;
+ int i, r;
+ int bo_dst_size = 0x4000000;
+ int bo_shader_size = 0x400000;
+ int bo_cmd_size = 4096;
+ struct amdgpu_cs_request ibs_request = {0};
+ struct amdgpu_cs_ib_info ib_info= {0};
+ uint32_t hang_state, hangs, expired;
+ struct amdgpu_gpu_info gpu_info = {0};
+ amdgpu_bo_list_handle bo_list;
+ struct amdgpu_cs_fence fence_status = {0};
+
+ r = amdgpu_query_gpu_info(device_handle, &gpu_info);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_ctx_create(device_handle, &context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, bo_cmd_size, 4096,
+ AMDGPU_GEM_DOMAIN_GTT, 0,
+ &bo_cmd, (void **)&ptr_cmd,
+ &mc_address_cmd, &va_cmd);
+ CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_cmd, 0, bo_cmd_size);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, bo_shader_size, 4096,
+ AMDGPU_GEM_DOMAIN_VRAM, 0,
+ &bo_shader, &ptr_shader,
+ &mc_address_shader, &va_shader);
+ CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_shader, 0, bo_shader_size);
+
+ r = amdgpu_dispatch_load_cs_shader_hang_slow(ptr_shader, gpu_info.family_id);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, bo_dst_size, 4096,
+ AMDGPU_GEM_DOMAIN_VRAM, 0,
+ &bo_src, (void **)&ptr_src,
+ &mc_address_src, &va_src);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, bo_dst_size, 4096,
+ AMDGPU_GEM_DOMAIN_VRAM, 0,
+ &bo_dst, (void **)&ptr_dst,
+ &mc_address_dst, &va_dst);
+ CU_ASSERT_EQUAL(r, 0);
+
+ memset(ptr_src, 0x55, bo_dst_size);
+
+ i = 0;
+ i += amdgpu_dispatch_init(ptr_cmd + i, ip_type);
+
+ /* Issue commands to set cu mask used in current dispatch */
+ i += amdgpu_dispatch_write_cumask(ptr_cmd + i);
+
+ /* Writes shader state to HW */
+ i += amdgpu_dispatch_write2hw(ptr_cmd + i, mc_address_shader);
+
+ /* Write constant data */
+ /* Writes the texture resource constants data to the SGPRs */
+ ptr_cmd[i++] = PACKET3_COMPUTE(PKT3_SET_SH_REG, 4);
+ ptr_cmd[i++] = 0x240;
+ ptr_cmd[i++] = mc_address_src;
+ ptr_cmd[i++] = (mc_address_src >> 32) | 0x100000;
+ ptr_cmd[i++] = 0x400000;
+ ptr_cmd[i++] = 0x74fac;
+
+ /* Writes the UAV constant data to the SGPRs. */
+ ptr_cmd[i++] = PACKET3_COMPUTE(PKT3_SET_SH_REG, 4);
+ ptr_cmd[i++] = 0x244;
+ ptr_cmd[i++] = mc_address_dst;
+ ptr_cmd[i++] = (mc_address_dst >> 32) | 0x100000;
+ ptr_cmd[i++] = 0x400000;
+ ptr_cmd[i++] = 0x74fac;
+
+ /* clear mmCOMPUTE_RESOURCE_LIMITS */
+ ptr_cmd[i++] = PACKET3_COMPUTE(PKT3_SET_SH_REG, 1);
+ ptr_cmd[i++] = 0x215;
+ ptr_cmd[i++] = 0;
+
+ /* dispatch direct command */
+ ptr_cmd[i++] = PACKET3_COMPUTE(PACKET3_DISPATCH_DIRECT, 3);
+ ptr_cmd[i++] = 0x10000;
+ ptr_cmd[i++] = 1;
+ ptr_cmd[i++] = 1;
+ ptr_cmd[i++] = 1;
+
+ while (i & 7)
+ ptr_cmd[i++] = 0xffff1000; /* type3 nop packet */
+
+ resources[0] = bo_shader;
+ resources[1] = bo_src;
+ resources[2] = bo_dst;
+ resources[3] = bo_cmd;
+ r = amdgpu_bo_list_create(device_handle, 4, resources, NULL, &bo_list);
+ CU_ASSERT_EQUAL(r, 0);
+
+ ib_info.ib_mc_address = mc_address_cmd;
+ ib_info.size = i;
+ ibs_request.ip_type = ip_type;
+ ibs_request.ring = ring;
+ ibs_request.resources = bo_list;
+ ibs_request.number_of_ibs = 1;
+ ibs_request.ibs = &ib_info;
+ ibs_request.fence_info.handle = NULL;
+ r = amdgpu_cs_submit(context_handle, 0, &ibs_request, 1);
+ CU_ASSERT_EQUAL(r, 0);
+
+ fence_status.ip_type = ip_type;
+ fence_status.ip_instance = 0;
+ fence_status.ring = ring;
+ fence_status.context = context_handle;
+ fence_status.fence = ibs_request.seq_no;
+
+ /* wait for IB accomplished */
+ r = amdgpu_cs_query_fence_status(&fence_status,
+ AMDGPU_TIMEOUT_INFINITE,
+ 0, &expired);
+
+ r = amdgpu_cs_query_reset_state(context_handle, &hang_state, &hangs);
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL(hang_state, AMDGPU_CTX_UNKNOWN_RESET);
+
+ r = amdgpu_bo_list_destroy(bo_list);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_unmap_and_free(bo_src, va_src, mc_address_src, bo_dst_size);
+ CU_ASSERT_EQUAL(r, 0);
+ r = amdgpu_bo_unmap_and_free(bo_dst, va_dst, mc_address_dst, bo_dst_size);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_unmap_and_free(bo_cmd, va_cmd, mc_address_cmd, bo_cmd_size);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_unmap_and_free(bo_shader, va_shader, mc_address_shader, bo_shader_size);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_ctx_free(context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+}
+
+void amdgpu_dispatch_hang_slow_helper(amdgpu_device_handle device_handle, uint32_t ip_type)
+{
+ int r;
+ struct drm_amdgpu_info_hw_ip info;
+ uint32_t ring_id;
+
+ r = amdgpu_query_hw_ip_info(device_handle, ip_type, 0, &info);
+ CU_ASSERT_EQUAL(r, 0);
+ if (!info.available_rings)
+ printf("SKIP ... as there's no ring for ip %d\n", ip_type);
+
+ for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
+ amdgpu_memcpy_dispatch_test(device_handle, ip_type, ring_id, 0);
+ amdgpu_memcpy_dispatch_hang_slow_test(device_handle, ip_type, ring_id);
+ amdgpu_memcpy_dispatch_test(device_handle, ip_type, ring_id, 0);
+ }
+}
+
+static int amdgpu_draw_load_ps_shader_hang_slow(uint32_t *ptr, int family)
+{
+ struct amdgpu_test_shader *shader;
+ int i, loop = 0x40000;
+
+ switch (family) {
+ case AMDGPU_FAMILY_AI:
+ case AMDGPU_FAMILY_RV:
+ shader = &memcpy_ps_hang_slow_ai;
+ break;
+ default:
+ return -1;
+ break;
+ }
+
+ memcpy(ptr, shader->shader, shader->header_length * sizeof(uint32_t));
+
+ for (i = 0; i < loop; i++)
+ memcpy(ptr + shader->header_length + shader->body_length * i,
+ shader->shader + shader->header_length,
+ shader->body_length * sizeof(uint32_t));
+
+ memcpy(ptr + shader->header_length + shader->body_length * loop,
+ shader->shader + shader->header_length + shader->body_length,
+ shader->foot_length * sizeof(uint32_t));
+
+ return 0;
+}
+
static int amdgpu_draw_load_ps_shader(uint8_t *ptr, int ps_type)
{
int i;
@@ -2478,6 +2829,12 @@ static int amdgpu_draw_load_ps_shader(uint8_t *ptr, int ps_type)
patchinfo_code_size = ps_tex_shader_patchinfo_code_size_gfx9;
patchcode_offset = ps_tex_shader_patchinfo_offset_gfx9;
break;
+ case PS_HANG:
+ shader = memcpy_ps_hang;
+ shader_size = sizeof(memcpy_ps_hang);
+
+ memcpy(ptr, shader, shader_size);
+ return 0;
default:
return -1;
break;
@@ -2534,7 +2891,8 @@ static int amdgpu_draw_init(uint32_t *ptr)
}
static int amdgpu_draw_setup_and_write_drawblt_surf_info(uint32_t *ptr,
- uint64_t dst_addr)
+ uint64_t dst_addr,
+ int hang_slow)
{
int i = 0;
@@ -2559,7 +2917,7 @@ static int amdgpu_draw_setup_and_write_drawblt_surf_info(uint32_t *ptr,
ptr[i++] = 0x318;
ptr[i++] = dst_addr >> 8;
ptr[i++] = dst_addr >> 40;
- ptr[i++] = 0x7c01f;
+ ptr[i++] = hang_slow ? 0x1ffc7ff : 0x7c01f;
ptr[i++] = 0;
ptr[i++] = 0x50438;
ptr[i++] = 0x10140000;
@@ -2568,7 +2926,7 @@ static int amdgpu_draw_setup_and_write_drawblt_surf_info(uint32_t *ptr,
/* mmCB_MRT0_EPITCH */
ptr[i++] = PACKET3(PACKET3_SET_CONTEXT_REG, 1);
ptr[i++] = 0x1e8;
- ptr[i++] = 0x1f;
+ ptr[i++] = hang_slow ? 0x7ff : 0x1f;
/* 0xA32B CB_COLOR1_BASE */
ptr[i++] = PACKET3(PACKET3_SET_CONTEXT_REG, 1);
@@ -2594,7 +2952,7 @@ static int amdgpu_draw_setup_and_write_drawblt_surf_info(uint32_t *ptr,
return i;
}
-static int amdgpu_draw_setup_and_write_drawblt_state(uint32_t *ptr)
+static int amdgpu_draw_setup_and_write_drawblt_state(uint32_t *ptr, int hang_slow)
{
int i = 0;
const uint32_t *cached_cmd_ptr;
@@ -2626,6 +2984,8 @@ static int amdgpu_draw_setup_and_write_drawblt_state(uint32_t *ptr)
cached_cmd_size = sizeof(cached_cmd_gfx9);
memcpy(ptr + i, cached_cmd_ptr, cached_cmd_size);
+ if (hang_slow)
+ *(ptr + i + 12) = 0x8000800;
i += cached_cmd_size/sizeof(uint32_t);
return i;
@@ -2633,7 +2993,8 @@ static int amdgpu_draw_setup_and_write_drawblt_state(uint32_t *ptr)
static int amdgpu_draw_vs_RectPosTexFast_write2hw(uint32_t *ptr,
int ps_type,
- uint64_t shader_addr)
+ uint64_t shader_addr,
+ int hang_slow)
{
int i = 0;
@@ -2675,8 +3036,8 @@ static int amdgpu_draw_vs_RectPosTexFast_write2hw(uint32_t *ptr,
ptr[i++] = PACKET3(PKT3_SET_SH_REG, 4);
ptr[i++] = 0x4c;
i += 2;
- ptr[i++] = 0x42000000;
- ptr[i++] = 0x42000000;
+ ptr[i++] = hang_slow ? 0x45000000 : 0x42000000;
+ ptr[i++] = hang_slow ? 0x45000000 : 0x42000000;
ptr[i++] = PACKET3(PKT3_SET_SH_REG, 4);
ptr[i++] = 0x50;
@@ -2813,11 +3174,11 @@ void amdgpu_memset_draw(amdgpu_device_handle device_handle,
i = 0;
i += amdgpu_draw_init(ptr_cmd + i);
- i += amdgpu_draw_setup_and_write_drawblt_surf_info(ptr_cmd + i, mc_address_dst);
+ i += amdgpu_draw_setup_and_write_drawblt_surf_info(ptr_cmd + i, mc_address_dst, 0);
- i += amdgpu_draw_setup_and_write_drawblt_state(ptr_cmd + i);
+ i += amdgpu_draw_setup_and_write_drawblt_state(ptr_cmd + i, 0);
- i += amdgpu_draw_vs_RectPosTexFast_write2hw(ptr_cmd + i, PS_CONST, mc_address_shader_vs);
+ i += amdgpu_draw_vs_RectPosTexFast_write2hw(ptr_cmd + i, PS_CONST, mc_address_shader_vs, 0);
i += amdgpu_draw_ps_write2hw(ptr_cmd + i, PS_CONST, mc_address_shader_ps);
@@ -2837,7 +3198,7 @@ void amdgpu_memset_draw(amdgpu_device_handle device_handle,
resources[1] = bo_shader_ps;
resources[2] = bo_shader_vs;
resources[3] = bo_cmd;
- r = amdgpu_bo_list_create(device_handle, 3, resources, NULL, &bo_list);
+ r = amdgpu_bo_list_create(device_handle, 4, resources, NULL, &bo_list);
CU_ASSERT_EQUAL(r, 0);
ib_info.ib_mc_address = mc_address_cmd;
@@ -2901,12 +3262,14 @@ static void amdgpu_memset_draw_test(amdgpu_device_handle device_handle,
&bo_shader_ps, &ptr_shader_ps,
&mc_address_shader_ps, &va_shader_ps);
CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_shader_ps, 0, bo_shader_size);
r = amdgpu_bo_alloc_and_map(device_handle, bo_shader_size, 4096,
AMDGPU_GEM_DOMAIN_VRAM, 0,
&bo_shader_vs, &ptr_shader_vs,
&mc_address_shader_vs, &va_shader_vs);
CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_shader_vs, 0, bo_shader_size);
r = amdgpu_draw_load_ps_shader(ptr_shader_ps, PS_CONST);
CU_ASSERT_EQUAL(r, 0);
@@ -2929,7 +3292,7 @@ static void amdgpu_memcpy_draw(amdgpu_device_handle device_handle,
amdgpu_bo_handle bo_shader_vs,
uint64_t mc_address_shader_ps,
uint64_t mc_address_shader_vs,
- uint32_t ring)
+ uint32_t ring, int hang)
{
amdgpu_context_handle context_handle;
amdgpu_bo_handle bo_dst, bo_src, bo_cmd, resources[5];
@@ -2943,7 +3306,8 @@ static void amdgpu_memcpy_draw(amdgpu_device_handle device_handle,
int bo_cmd_size = 4096;
struct amdgpu_cs_request ibs_request = {0};
struct amdgpu_cs_ib_info ib_info= {0};
- uint32_t hang_state, hangs, expired;
+ uint32_t hang_state, hangs;
+ uint32_t expired;
amdgpu_bo_list_handle bo_list;
struct amdgpu_cs_fence fence_status = {0};
@@ -2974,11 +3338,11 @@ static void amdgpu_memcpy_draw(amdgpu_device_handle device_handle,
i = 0;
i += amdgpu_draw_init(ptr_cmd + i);
- i += amdgpu_draw_setup_and_write_drawblt_surf_info(ptr_cmd + i, mc_address_dst);
+ i += amdgpu_draw_setup_and_write_drawblt_surf_info(ptr_cmd + i, mc_address_dst, 0);
- i += amdgpu_draw_setup_and_write_drawblt_state(ptr_cmd + i);
+ i += amdgpu_draw_setup_and_write_drawblt_state(ptr_cmd + i, 0);
- i += amdgpu_draw_vs_RectPosTexFast_write2hw(ptr_cmd + i, PS_TEX, mc_address_shader_vs);
+ i += amdgpu_draw_vs_RectPosTexFast_write2hw(ptr_cmd + i, PS_TEX, mc_address_shader_vs, 0);
i += amdgpu_draw_ps_write2hw(ptr_cmd + i, PS_TEX, mc_address_shader_ps);
@@ -2996,7 +3360,7 @@ static void amdgpu_memcpy_draw(amdgpu_device_handle device_handle,
ptr_cmd[i++] = 0x92;
i += 3;
- ptr_cmd[i++] = PACKET3(PKT3_SET_SH_REG, 1);
+ ptr_cmd[i++] = PACKET3(PACKET3_SET_CONTEXT_REG, 1);
ptr_cmd[i++] = 0x191;
ptr_cmd[i++] = 0;
@@ -3034,14 +3398,20 @@ static void amdgpu_memcpy_draw(amdgpu_device_handle device_handle,
r = amdgpu_cs_query_fence_status(&fence_status,
AMDGPU_TIMEOUT_INFINITE,
0, &expired);
- CU_ASSERT_EQUAL(r, 0);
- CU_ASSERT_EQUAL(expired, true);
+ if (!hang) {
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL(expired, true);
- /* verify if memcpy test result meets with expected */
- i = 0;
- while(i < bo_size) {
- CU_ASSERT_EQUAL(ptr_dst[i], ptr_src[i]);
- i++;
+ /* verify if memcpy test result meets with expected */
+ i = 0;
+ while(i < bo_size) {
+ CU_ASSERT_EQUAL(ptr_dst[i], ptr_src[i]);
+ i++;
+ }
+ } else {
+ r = amdgpu_cs_query_reset_state(context_handle, &hang_state, &hangs);
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL(hang_state, AMDGPU_CTX_UNKNOWN_RESET);
}
r = amdgpu_bo_list_destroy(bo_list);
@@ -3059,7 +3429,8 @@ static void amdgpu_memcpy_draw(amdgpu_device_handle device_handle,
CU_ASSERT_EQUAL(r, 0);
}
-static void amdgpu_memcpy_draw_test(amdgpu_device_handle device_handle, uint32_t ring)
+void amdgpu_memcpy_draw_test(amdgpu_device_handle device_handle, uint32_t ring,
+ int hang)
{
amdgpu_bo_handle bo_shader_ps, bo_shader_vs;
void *ptr_shader_ps;
@@ -3067,6 +3438,7 @@ static void amdgpu_memcpy_draw_test(amdgpu_device_handle device_handle, uint32_t
uint64_t mc_address_shader_ps, mc_address_shader_vs;
amdgpu_va_handle va_shader_ps, va_shader_vs;
int bo_shader_size = 4096;
+ enum ps_type ps_type = hang ? PS_HANG : PS_TEX;
int r;
r = amdgpu_bo_alloc_and_map(device_handle, bo_shader_size, 4096,
@@ -3074,21 +3446,23 @@ static void amdgpu_memcpy_draw_test(amdgpu_device_handle device_handle, uint32_t
&bo_shader_ps, &ptr_shader_ps,
&mc_address_shader_ps, &va_shader_ps);
CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_shader_ps, 0, bo_shader_size);
r = amdgpu_bo_alloc_and_map(device_handle, bo_shader_size, 4096,
AMDGPU_GEM_DOMAIN_VRAM, 0,
&bo_shader_vs, &ptr_shader_vs,
&mc_address_shader_vs, &va_shader_vs);
CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_shader_vs, 0, bo_shader_size);
- r = amdgpu_draw_load_ps_shader(ptr_shader_ps, PS_TEX);
+ r = amdgpu_draw_load_ps_shader(ptr_shader_ps, ps_type);
CU_ASSERT_EQUAL(r, 0);
r = amdgpu_draw_load_vs_shader(ptr_shader_vs);
CU_ASSERT_EQUAL(r, 0);
amdgpu_memcpy_draw(device_handle, bo_shader_ps, bo_shader_vs,
- mc_address_shader_ps, mc_address_shader_vs, ring);
+ mc_address_shader_ps, mc_address_shader_vs, ring, hang);
r = amdgpu_bo_unmap_and_free(bo_shader_ps, va_shader_ps, mc_address_shader_ps, bo_shader_size);
CU_ASSERT_EQUAL(r, 0);
@@ -3105,9 +3479,207 @@ static void amdgpu_draw_test(void)
r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_GFX, 0, &info);
CU_ASSERT_EQUAL(r, 0);
+ if (!info.available_rings)
+ printf("SKIP ... as there's no graphics ring\n");
for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
amdgpu_memset_draw_test(device_handle, ring_id);
- amdgpu_memcpy_draw_test(device_handle, ring_id);
+ amdgpu_memcpy_draw_test(device_handle, ring_id, 0);
}
}
+
+void amdgpu_memcpy_draw_hang_slow_test(amdgpu_device_handle device_handle, uint32_t ring)
+{
+ amdgpu_context_handle context_handle;
+ amdgpu_bo_handle bo_shader_ps, bo_shader_vs;
+ amdgpu_bo_handle bo_dst, bo_src, bo_cmd, resources[5];
+ void *ptr_shader_ps;
+ void *ptr_shader_vs;
+ volatile unsigned char *ptr_dst;
+ unsigned char *ptr_src;
+ uint32_t *ptr_cmd;
+ uint64_t mc_address_dst, mc_address_src, mc_address_cmd;
+ uint64_t mc_address_shader_ps, mc_address_shader_vs;
+ amdgpu_va_handle va_shader_ps, va_shader_vs;
+ amdgpu_va_handle va_dst, va_src, va_cmd;
+ struct amdgpu_gpu_info gpu_info = {0};
+ int i, r;
+ int bo_size = 0x4000000;
+ int bo_shader_ps_size = 0x400000;
+ int bo_shader_vs_size = 4096;
+ int bo_cmd_size = 4096;
+ struct amdgpu_cs_request ibs_request = {0};
+ struct amdgpu_cs_ib_info ib_info= {0};
+ uint32_t hang_state, hangs, expired;
+ amdgpu_bo_list_handle bo_list;
+ struct amdgpu_cs_fence fence_status = {0};
+
+ r = amdgpu_query_gpu_info(device_handle, &gpu_info);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_ctx_create(device_handle, &context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, bo_cmd_size, 4096,
+ AMDGPU_GEM_DOMAIN_GTT, 0,
+ &bo_cmd, (void **)&ptr_cmd,
+ &mc_address_cmd, &va_cmd);
+ CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_cmd, 0, bo_cmd_size);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, bo_shader_ps_size, 4096,
+ AMDGPU_GEM_DOMAIN_VRAM, 0,
+ &bo_shader_ps, &ptr_shader_ps,
+ &mc_address_shader_ps, &va_shader_ps);
+ CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_shader_ps, 0, bo_shader_ps_size);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, bo_shader_vs_size, 4096,
+ AMDGPU_GEM_DOMAIN_VRAM, 0,
+ &bo_shader_vs, &ptr_shader_vs,
+ &mc_address_shader_vs, &va_shader_vs);
+ CU_ASSERT_EQUAL(r, 0);
+ memset(ptr_shader_vs, 0, bo_shader_vs_size);
+
+ r = amdgpu_draw_load_ps_shader_hang_slow(ptr_shader_ps, gpu_info.family_id);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_draw_load_vs_shader(ptr_shader_vs);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, bo_size, 4096,
+ AMDGPU_GEM_DOMAIN_VRAM, 0,
+ &bo_src, (void **)&ptr_src,
+ &mc_address_src, &va_src);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_alloc_and_map(device_handle, bo_size, 4096,
+ AMDGPU_GEM_DOMAIN_VRAM, 0,
+ &bo_dst, (void **)&ptr_dst,
+ &mc_address_dst, &va_dst);
+ CU_ASSERT_EQUAL(r, 0);
+
+ memset(ptr_src, 0x55, bo_size);
+
+ i = 0;
+ i += amdgpu_draw_init(ptr_cmd + i);
+
+ i += amdgpu_draw_setup_and_write_drawblt_surf_info(ptr_cmd + i, mc_address_dst, 1);
+
+ i += amdgpu_draw_setup_and_write_drawblt_state(ptr_cmd + i, 1);
+
+ i += amdgpu_draw_vs_RectPosTexFast_write2hw(ptr_cmd + i, PS_TEX,
+ mc_address_shader_vs, 1);
+
+ i += amdgpu_draw_ps_write2hw(ptr_cmd + i, PS_TEX, mc_address_shader_ps);
+
+ ptr_cmd[i++] = PACKET3(PKT3_SET_SH_REG, 8);
+ ptr_cmd[i++] = 0xc;
+ ptr_cmd[i++] = mc_address_src >> 8;
+ ptr_cmd[i++] = mc_address_src >> 40 | 0x10e00000;
+ ptr_cmd[i++] = 0x1ffc7ff;
+ ptr_cmd[i++] = 0x90500fac;
+ ptr_cmd[i++] = 0xffe000;
+ i += 3;
+
+ ptr_cmd[i++] = PACKET3(PKT3_SET_SH_REG, 4);
+ ptr_cmd[i++] = 0x14;
+ ptr_cmd[i++] = 0x92;
+ i += 3;
+
+ ptr_cmd[i++] = PACKET3(PACKET3_SET_CONTEXT_REG, 1);
+ ptr_cmd[i++] = 0x191;
+ ptr_cmd[i++] = 0;
+
+ i += amdgpu_draw_draw(ptr_cmd + i);
+
+ while (i & 7)
+ ptr_cmd[i++] = 0xffff1000; /* type3 nop packet */
+
+ resources[0] = bo_dst;
+ resources[1] = bo_src;
+ resources[2] = bo_shader_ps;
+ resources[3] = bo_shader_vs;
+ resources[4] = bo_cmd;
+ r = amdgpu_bo_list_create(device_handle, 5, resources, NULL, &bo_list);
+ CU_ASSERT_EQUAL(r, 0);
+
+ ib_info.ib_mc_address = mc_address_cmd;
+ ib_info.size = i;
+ ibs_request.ip_type = AMDGPU_HW_IP_GFX;
+ ibs_request.ring = ring;
+ ibs_request.resources = bo_list;
+ ibs_request.number_of_ibs = 1;
+ ibs_request.ibs = &ib_info;
+ ibs_request.fence_info.handle = NULL;
+ r = amdgpu_cs_submit(context_handle, 0, &ibs_request, 1);
+ CU_ASSERT_EQUAL(r, 0);
+
+ fence_status.ip_type = AMDGPU_HW_IP_GFX;
+ fence_status.ip_instance = 0;
+ fence_status.ring = ring;
+ fence_status.context = context_handle;
+ fence_status.fence = ibs_request.seq_no;
+
+ /* wait for IB accomplished */
+ r = amdgpu_cs_query_fence_status(&fence_status,
+ AMDGPU_TIMEOUT_INFINITE,
+ 0, &expired);
+
+ r = amdgpu_cs_query_reset_state(context_handle, &hang_state, &hangs);
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL(hang_state, AMDGPU_CTX_UNKNOWN_RESET);
+
+ r = amdgpu_bo_list_destroy(bo_list);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_unmap_and_free(bo_dst, va_dst, mc_address_dst, bo_size);
+ CU_ASSERT_EQUAL(r, 0);
+ r = amdgpu_bo_unmap_and_free(bo_src, va_src, mc_address_src, bo_size);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_unmap_and_free(bo_cmd, va_cmd, mc_address_cmd, bo_cmd_size);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_bo_unmap_and_free(bo_shader_ps, va_shader_ps, mc_address_shader_ps, bo_shader_ps_size);
+ CU_ASSERT_EQUAL(r, 0);
+ r = amdgpu_bo_unmap_and_free(bo_shader_vs, va_shader_vs, mc_address_shader_vs, bo_shader_vs_size);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = amdgpu_cs_ctx_free(context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+}
+
+static void amdgpu_gpu_reset_test(void)
+{
+ int r;
+ char debugfs_path[256], tmp[10];
+ int fd;
+ struct stat sbuf;
+ amdgpu_context_handle context_handle;
+ uint32_t hang_state, hangs;
+
+ r = amdgpu_cs_ctx_create(device_handle, &context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ r = fstat(drm_amdgpu[0], &sbuf);
+ CU_ASSERT_EQUAL(r, 0);
+
+ sprintf(debugfs_path, "/sys/kernel/debug/dri/%d/amdgpu_gpu_recover", minor(sbuf.st_rdev));
+ fd = open(debugfs_path, O_RDONLY);
+ CU_ASSERT(fd >= 0);
+
+ r = read(fd, tmp, sizeof(tmp)/sizeof(char));
+ CU_ASSERT(r > 0);
+
+ r = amdgpu_cs_query_reset_state(context_handle, &hang_state, &hangs);
+ CU_ASSERT_EQUAL(r, 0);
+ CU_ASSERT_EQUAL(hang_state, AMDGPU_CTX_UNKNOWN_RESET);
+
+ close(fd);
+ r = amdgpu_cs_ctx_free(context_handle);
+ CU_ASSERT_EQUAL(r, 0);
+
+ amdgpu_compute_dispatch_test();
+ amdgpu_gfx_dispatch_test();
+}
diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c
index 7cff4cf7..4c11665a 100644
--- a/tests/amdgpu/bo_tests.c
+++ b/tests/amdgpu/bo_tests.c
@@ -267,7 +267,6 @@ static void amdgpu_memory_alloc(void)
static void amdgpu_mem_fail_alloc(void)
{
- amdgpu_bo_handle bo;
int r;
struct amdgpu_bo_alloc_request req = {0};
amdgpu_bo_handle buf_handle;
@@ -282,7 +281,7 @@ static void amdgpu_mem_fail_alloc(void)
CU_ASSERT_EQUAL(r, -ENOMEM);
if (!r) {
- r = amdgpu_bo_free(bo);
+ r = amdgpu_bo_free(buf_handle);
CU_ASSERT_EQUAL(r, 0);
}
}
diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c
index 7ad0f0dc..ae4f65f5 100644
--- a/tests/amdgpu/cs_tests.c
+++ b/tests/amdgpu/cs_tests.c
@@ -358,6 +358,7 @@ static void amdgpu_cs_uvd_decode(void)
bs_addr = fb_addr + 4*1024;
dpb_addr = ALIGN(bs_addr + sizeof(uvd_bitstream), 4*1024);
+ ctx_addr = 0;
if (family_id >= AMDGPU_FAMILY_VI) {
if ((family_id == AMDGPU_FAMILY_AI) ||
(chip_id == chip_rev+0x50 || chip_id == chip_rev+0x5A ||
diff --git a/tests/amdgpu/deadlock_tests.c b/tests/amdgpu/deadlock_tests.c
index 91368c15..a18d578f 100644
--- a/tests/amdgpu/deadlock_tests.c
+++ b/tests/amdgpu/deadlock_tests.c
@@ -24,7 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#ifdef HAVE_ALLOCA_H
+#if HAVE_ALLOCA_H
# include <alloca.h>
#endif
@@ -114,6 +114,12 @@ static void amdgpu_deadlock_compute(void);
static void amdgpu_illegal_reg_access();
static void amdgpu_illegal_mem_access();
static void amdgpu_deadlock_sdma(void);
+static void amdgpu_dispatch_hang_gfx(void);
+static void amdgpu_dispatch_hang_compute(void);
+static void amdgpu_dispatch_hang_slow_gfx(void);
+static void amdgpu_dispatch_hang_slow_compute(void);
+static void amdgpu_draw_hang_gfx(void);
+static void amdgpu_draw_hang_slow_gfx(void);
CU_BOOL suite_deadlock_tests_enable(void)
{
@@ -178,6 +184,12 @@ CU_TestInfo deadlock_tests[] = {
{ "sdma ring block test (set amdgpu.lockup_timeout=50)", amdgpu_deadlock_sdma },
{ "illegal reg access test", amdgpu_illegal_reg_access },
{ "illegal mem access test (set amdgpu.vm_fault_stop=2)", amdgpu_illegal_mem_access },
+ { "gfx ring bad dispatch test (set amdgpu.lockup_timeout=50)", amdgpu_dispatch_hang_gfx },
+ { "compute ring bad dispatch test (set amdgpu.lockup_timeout=50,50)", amdgpu_dispatch_hang_compute },
+ { "gfx ring bad slow dispatch test (set amdgpu.lockup_timeout=50)", amdgpu_dispatch_hang_slow_gfx },
+ { "compute ring bad slow dispatch test (set amdgpu.lockup_timeout=50,50)", amdgpu_dispatch_hang_slow_compute },
+ { "gfx ring bad draw test (set amdgpu.lockup_timeout=50)", amdgpu_draw_hang_gfx },
+ { "gfx ring slow bad draw test (set amdgpu.lockup_timeout=50)", amdgpu_draw_hang_slow_gfx },
CU_TEST_INFO_NULL,
};
@@ -478,3 +490,57 @@ static void amdgpu_illegal_mem_access()
{
bad_access_helper(0);
}
+
+static void amdgpu_dispatch_hang_gfx(void)
+{
+ amdgpu_dispatch_hang_helper(device_handle, AMDGPU_HW_IP_GFX);
+}
+
+static void amdgpu_dispatch_hang_compute(void)
+{
+ amdgpu_dispatch_hang_helper(device_handle, AMDGPU_HW_IP_COMPUTE);
+}
+
+static void amdgpu_dispatch_hang_slow_gfx(void)
+{
+ amdgpu_dispatch_hang_slow_helper(device_handle, AMDGPU_HW_IP_GFX);
+}
+
+static void amdgpu_dispatch_hang_slow_compute(void)
+{
+ amdgpu_dispatch_hang_slow_helper(device_handle, AMDGPU_HW_IP_COMPUTE);
+}
+
+static void amdgpu_draw_hang_gfx(void)
+{
+ int r;
+ struct drm_amdgpu_info_hw_ip info;
+ uint32_t ring_id;
+
+ r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_GFX, 0, &info);
+ CU_ASSERT_EQUAL(r, 0);
+ if (!info.available_rings)
+ printf("SKIP ... as there's no graphic ring\n");
+
+ for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
+ amdgpu_memcpy_draw_test(device_handle, ring_id, 0);
+ amdgpu_memcpy_draw_test(device_handle, ring_id, 1);
+ amdgpu_memcpy_draw_test(device_handle, ring_id, 0);
+ }
+}
+
+static void amdgpu_draw_hang_slow_gfx(void)
+{
+ struct drm_amdgpu_info_hw_ip info;
+ uint32_t ring_id;
+ int r;
+
+ r = amdgpu_query_hw_ip_info(device_handle, AMDGPU_HW_IP_GFX, 0, &info);
+ CU_ASSERT_EQUAL(r, 0);
+
+ for (ring_id = 0; (1 << ring_id) & info.available_rings; ring_id++) {
+ amdgpu_memcpy_draw_test(device_handle, ring_id, 0);
+ amdgpu_memcpy_draw_hang_slow_test(device_handle, ring_id);
+ amdgpu_memcpy_draw_test(device_handle, ring_id, 0);
+ }
+}
diff --git a/tests/amdgpu/decode_messages.h b/tests/amdgpu/decode_messages.h
index bd6fe4b6..52c1cbb6 100644
--- a/tests/amdgpu/decode_messages.h
+++ b/tests/amdgpu/decode_messages.h
@@ -845,4 +845,10 @@ static const uint8_t vcn_dec_destroy_msg[] = {
0x03,0x00,0x44,0x40,0x00,0x00,0x00,0x00,
};
+static const uint8_t feedback_msg[] = {
+ 0x2c,0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+};
+
#endif /* _DECODE_MESSAGES_H_ */
diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
index 1726cb43..4dfa5c83 100644
--- a/tests/amdgpu/meson.build
+++ b/tests/amdgpu/meson.build
@@ -26,7 +26,7 @@ if dep_cunit.found()
'vce_tests.c', 'uvd_enc_tests.c', 'vcn_tests.c', 'deadlock_tests.c',
'vm_tests.c', 'ras_tests.c', 'syncobj_tests.c',
),
- dependencies : [dep_cunit, dep_threads],
+ dependencies : [dep_cunit, dep_threads, dep_atomic_ops],
include_directories : [inc_root, inc_drm, include_directories('../../amdgpu')],
link_with : [libdrm, libdrm_amdgpu],
install : with_install_tests,
diff --git a/tests/amdgpu/ras_tests.c b/tests/amdgpu/ras_tests.c
index 81c34ad6..810bf172 100644
--- a/tests/amdgpu/ras_tests.c
+++ b/tests/amdgpu/ras_tests.c
@@ -30,6 +30,11 @@
#include <fcntl.h>
#include <stdio.h>
#include "xf86drm.h"
+#include <limits.h>
+
+#define PATH_SIZE PATH_MAX
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
const char *ras_block_string[] = {
"umc",
@@ -72,11 +77,251 @@ enum amdgpu_ras_block {
#define AMDGPU_RAS_BLOCK_COUNT AMDGPU_RAS_BLOCK__LAST
#define AMDGPU_RAS_BLOCK_MASK ((1ULL << AMDGPU_RAS_BLOCK_COUNT) - 1)
+enum amdgpu_ras_gfx_subblock {
+ /* CPC */
+ AMDGPU_RAS_BLOCK__GFX_CPC_INDEX_START = 0,
+ AMDGPU_RAS_BLOCK__GFX_CPC_SCRATCH =
+ AMDGPU_RAS_BLOCK__GFX_CPC_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_CPC_UCODE,
+ AMDGPU_RAS_BLOCK__GFX_DC_STATE_ME1,
+ AMDGPU_RAS_BLOCK__GFX_DC_CSINVOC_ME1,
+ AMDGPU_RAS_BLOCK__GFX_DC_RESTORE_ME1,
+ AMDGPU_RAS_BLOCK__GFX_DC_STATE_ME2,
+ AMDGPU_RAS_BLOCK__GFX_DC_CSINVOC_ME2,
+ AMDGPU_RAS_BLOCK__GFX_DC_RESTORE_ME2,
+ AMDGPU_RAS_BLOCK__GFX_CPC_INDEX_END =
+ AMDGPU_RAS_BLOCK__GFX_DC_RESTORE_ME2,
+ /* CPF */
+ AMDGPU_RAS_BLOCK__GFX_CPF_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_CPF_ROQ_ME2 =
+ AMDGPU_RAS_BLOCK__GFX_CPF_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_CPF_ROQ_ME1,
+ AMDGPU_RAS_BLOCK__GFX_CPF_TAG,
+ AMDGPU_RAS_BLOCK__GFX_CPF_INDEX_END = AMDGPU_RAS_BLOCK__GFX_CPF_TAG,
+ /* CPG */
+ AMDGPU_RAS_BLOCK__GFX_CPG_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_CPG_DMA_ROQ =
+ AMDGPU_RAS_BLOCK__GFX_CPG_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_CPG_DMA_TAG,
+ AMDGPU_RAS_BLOCK__GFX_CPG_TAG,
+ AMDGPU_RAS_BLOCK__GFX_CPG_INDEX_END = AMDGPU_RAS_BLOCK__GFX_CPG_TAG,
+ /* GDS */
+ AMDGPU_RAS_BLOCK__GFX_GDS_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_GDS_MEM = AMDGPU_RAS_BLOCK__GFX_GDS_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_GDS_INPUT_QUEUE,
+ AMDGPU_RAS_BLOCK__GFX_GDS_OA_PHY_CMD_RAM_MEM,
+ AMDGPU_RAS_BLOCK__GFX_GDS_OA_PHY_DATA_RAM_MEM,
+ AMDGPU_RAS_BLOCK__GFX_GDS_OA_PIPE_MEM,
+ AMDGPU_RAS_BLOCK__GFX_GDS_INDEX_END =
+ AMDGPU_RAS_BLOCK__GFX_GDS_OA_PIPE_MEM,
+ /* SPI */
+ AMDGPU_RAS_BLOCK__GFX_SPI_SR_MEM,
+ /* SQ */
+ AMDGPU_RAS_BLOCK__GFX_SQ_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_SQ_SGPR = AMDGPU_RAS_BLOCK__GFX_SQ_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_SQ_LDS_D,
+ AMDGPU_RAS_BLOCK__GFX_SQ_LDS_I,
+ AMDGPU_RAS_BLOCK__GFX_SQ_VGPR,
+ AMDGPU_RAS_BLOCK__GFX_SQ_INDEX_END = AMDGPU_RAS_BLOCK__GFX_SQ_VGPR,
+ /* SQC (3 ranges) */
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX_START,
+ /* SQC range 0 */
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX0_START =
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INST_UTCL1_LFIFO =
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX0_START,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU0_WRITE_DATA_BUF,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU0_UTCL1_LFIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU1_WRITE_DATA_BUF,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU1_UTCL1_LFIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU2_WRITE_DATA_BUF,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU2_UTCL1_LFIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX0_END =
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU2_UTCL1_LFIFO,
+ /* SQC range 1 */
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX1_START,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_TAG_RAM =
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX1_START,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_UTCL1_MISS_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_MISS_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_BANK_RAM,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_TAG_RAM,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_HIT_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_MISS_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_DIRTY_BIT_RAM,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_BANK_RAM,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX1_END =
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_BANK_RAM,
+ /* SQC range 2 */
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_START,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_TAG_RAM =
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_START,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_UTCL1_MISS_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_MISS_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_BANK_RAM,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_TAG_RAM,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_HIT_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_MISS_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_DIRTY_BIT_RAM,
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_BANK_RAM,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_END =
+ AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_BANK_RAM,
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX_END =
+ AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_END,
+ /* TA */
+ AMDGPU_RAS_BLOCK__GFX_TA_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_TA_FS_DFIFO =
+ AMDGPU_RAS_BLOCK__GFX_TA_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_TA_FS_AFIFO,
+ AMDGPU_RAS_BLOCK__GFX_TA_FL_LFIFO,
+ AMDGPU_RAS_BLOCK__GFX_TA_FX_LFIFO,
+ AMDGPU_RAS_BLOCK__GFX_TA_FS_CFIFO,
+ AMDGPU_RAS_BLOCK__GFX_TA_INDEX_END = AMDGPU_RAS_BLOCK__GFX_TA_FS_CFIFO,
+ /* TCA */
+ AMDGPU_RAS_BLOCK__GFX_TCA_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_TCA_HOLE_FIFO =
+ AMDGPU_RAS_BLOCK__GFX_TCA_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_TCA_REQ_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_TCA_INDEX_END =
+ AMDGPU_RAS_BLOCK__GFX_TCA_REQ_FIFO,
+ /* TCC (5 sub-ranges) */
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX_START,
+ /* TCC range 0 */
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX0_START =
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA =
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX0_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_0_1,
+ AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_1_0,
+ AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_1_1,
+ AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DIRTY_BANK_0,
+ AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DIRTY_BANK_1,
+ AMDGPU_RAS_BLOCK__GFX_TCC_HIGH_RATE_TAG,
+ AMDGPU_RAS_BLOCK__GFX_TCC_LOW_RATE_TAG,
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX0_END =
+ AMDGPU_RAS_BLOCK__GFX_TCC_LOW_RATE_TAG,
+ /* TCC range 1 */
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX1_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_IN_USE_DEC =
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX1_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_IN_USE_TRANSFER,
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX1_END =
+ AMDGPU_RAS_BLOCK__GFX_TCC_IN_USE_TRANSFER,
+ /* TCC range 2 */
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX2_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_RETURN_DATA =
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX2_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_RETURN_CONTROL,
+ AMDGPU_RAS_BLOCK__GFX_TCC_UC_ATOMIC_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_TCC_WRITE_RETURN,
+ AMDGPU_RAS_BLOCK__GFX_TCC_WRITE_CACHE_READ,
+ AMDGPU_RAS_BLOCK__GFX_TCC_SRC_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_TCC_SRC_FIFO_NEXT_RAM,
+ AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_TAG_PROBE_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX2_END =
+ AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_TAG_PROBE_FIFO,
+ /* TCC range 3 */
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX3_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_LATENCY_FIFO =
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX3_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_LATENCY_FIFO_NEXT_RAM,
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX3_END =
+ AMDGPU_RAS_BLOCK__GFX_TCC_LATENCY_FIFO_NEXT_RAM,
+ /* TCC range 4 */
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_WRRET_TAG_WRITE_RETURN =
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_START,
+ AMDGPU_RAS_BLOCK__GFX_TCC_ATOMIC_RETURN_BUFFER,
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_END =
+ AMDGPU_RAS_BLOCK__GFX_TCC_ATOMIC_RETURN_BUFFER,
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX_END =
+ AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_END,
+ /* TCI */
+ AMDGPU_RAS_BLOCK__GFX_TCI_WRITE_RAM,
+ /* TCP */
+ AMDGPU_RAS_BLOCK__GFX_TCP_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_TCP_CACHE_RAM =
+ AMDGPU_RAS_BLOCK__GFX_TCP_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_TCP_LFIFO_RAM,
+ AMDGPU_RAS_BLOCK__GFX_TCP_CMD_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_TCP_VM_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_TCP_DB_RAM,
+ AMDGPU_RAS_BLOCK__GFX_TCP_UTCL1_LFIFO0,
+ AMDGPU_RAS_BLOCK__GFX_TCP_UTCL1_LFIFO1,
+ AMDGPU_RAS_BLOCK__GFX_TCP_INDEX_END =
+ AMDGPU_RAS_BLOCK__GFX_TCP_UTCL1_LFIFO1,
+ /* TD */
+ AMDGPU_RAS_BLOCK__GFX_TD_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_TD_SS_FIFO_LO =
+ AMDGPU_RAS_BLOCK__GFX_TD_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_TD_SS_FIFO_HI,
+ AMDGPU_RAS_BLOCK__GFX_TD_CS_FIFO,
+ AMDGPU_RAS_BLOCK__GFX_TD_INDEX_END = AMDGPU_RAS_BLOCK__GFX_TD_CS_FIFO,
+ /* EA (3 sub-ranges) */
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX_START,
+ /* EA range 0 */
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX0_START =
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX_START,
+ AMDGPU_RAS_BLOCK__GFX_EA_DRAMRD_CMDMEM =
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX0_START,
+ AMDGPU_RAS_BLOCK__GFX_EA_DRAMWR_CMDMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_DRAMWR_DATAMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_RRET_TAGMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_WRET_TAGMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_GMIRD_CMDMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_CMDMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_DATAMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX0_END =
+ AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_DATAMEM,
+ /* EA range 1 */
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX1_START,
+ AMDGPU_RAS_BLOCK__GFX_EA_DRAMRD_PAGEMEM =
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX1_START,
+ AMDGPU_RAS_BLOCK__GFX_EA_DRAMWR_PAGEMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_IORD_CMDMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_IOWR_CMDMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_IOWR_DATAMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_GMIRD_PAGEMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_PAGEMEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX1_END =
+ AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_PAGEMEM,
+ /* EA range 2 */
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_START,
+ AMDGPU_RAS_BLOCK__GFX_EA_MAM_D0MEM =
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_START,
+ AMDGPU_RAS_BLOCK__GFX_EA_MAM_D1MEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_MAM_D2MEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_MAM_D3MEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_END =
+ AMDGPU_RAS_BLOCK__GFX_EA_MAM_D3MEM,
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX_END =
+ AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_END,
+ /* UTC VM L2 bank */
+ AMDGPU_RAS_BLOCK__UTC_VML2_BANK_CACHE,
+ /* UTC VM walker */
+ AMDGPU_RAS_BLOCK__UTC_VML2_WALKER,
+ /* UTC ATC L2 2MB cache */
+ AMDGPU_RAS_BLOCK__UTC_ATCL2_CACHE_2M_BANK,
+ /* UTC ATC L2 4KB cache */
+ AMDGPU_RAS_BLOCK__UTC_ATCL2_CACHE_4K_BANK,
+ AMDGPU_RAS_BLOCK__GFX_MAX
+};
+
enum amdgpu_ras_error_type {
- AMDGPU_RAS_ERROR__NONE = 0,
- AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE = 2,
- AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE = 4,
- AMDGPU_RAS_ERROR__POISON = 8,
+ AMDGPU_RAS_ERROR__NONE = 0,
+ AMDGPU_RAS_ERROR__PARITY = 1,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE = 2,
+ AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE = 4,
+ AMDGPU_RAS_ERROR__POISON = 8,
+};
+
+struct ras_inject_test_config {
+ char name[64];
+ char block[32];
+ int sub_block;
+ enum amdgpu_ras_error_type type;
+ uint64_t address;
+ uint64_t value;
};
struct ras_common_if {
@@ -100,8 +345,10 @@ struct ras_debug_if {
int op;
};
/* for now, only umc, gfx, sdma has implemented. */
-#define DEFAULT_RAS_BLOCK_MASK_INJECT (1 << AMDGPU_RAS_BLOCK__UMC)
-#define DEFAULT_RAS_BLOCK_MASK_QUERY (1 << AMDGPU_RAS_BLOCK__UMC)
+#define DEFAULT_RAS_BLOCK_MASK_INJECT ((1 << AMDGPU_RAS_BLOCK__UMC) |\
+ (1 << AMDGPU_RAS_BLOCK__GFX))
+#define DEFAULT_RAS_BLOCK_MASK_QUERY ((1 << AMDGPU_RAS_BLOCK__UMC) |\
+ (1 << AMDGPU_RAS_BLOCK__GFX))
#define DEFAULT_RAS_BLOCK_MASK_BASIC (1 << AMDGPU_RAS_BLOCK__UMC |\
(1 << AMDGPU_RAS_BLOCK__SDMA) |\
(1 << AMDGPU_RAS_BLOCK__GFX))
@@ -146,12 +393,78 @@ struct ras_DID_test_mask{
DEFAULT_RAS_BLOCK_MASK_BASIC\
}
+static const struct ras_inject_test_config umc_ras_inject_test[] = {
+ {"ras_umc.1.0", "umc", 0, AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+};
+
+static const struct ras_inject_test_config gfx_ras_inject_test[] = {
+ {"ras_gfx.2.0", "gfx", AMDGPU_RAS_BLOCK__GFX_CPC_UCODE,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.1", "gfx", AMDGPU_RAS_BLOCK__GFX_CPF_TAG,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.2", "gfx", AMDGPU_RAS_BLOCK__GFX_CPG_TAG,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.3", "gfx", AMDGPU_RAS_BLOCK__GFX_SQ_LDS_D,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.4", "gfx", AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU1_UTCL1_LFIFO,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.5", "gfx", AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_TAG_RAM,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.6", "gfx", AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_TAG_RAM,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.7", "gfx", AMDGPU_RAS_BLOCK__GFX_TA_FS_DFIFO,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.8", "gfx", AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.9", "gfx", AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_0_1,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.10", "gfx", AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_1_0,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.11", "gfx", AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_1_1,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.12", "gfx", AMDGPU_RAS_BLOCK__GFX_TCP_CACHE_RAM,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.13", "gfx", AMDGPU_RAS_BLOCK__GFX_TD_SS_FIFO_LO,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+ {"ras_gfx.2.14", "gfx", AMDGPU_RAS_BLOCK__GFX_EA_DRAMRD_CMDMEM,
+ AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE, 0, 0},
+};
+
static const struct ras_DID_test_mask ras_DID_array[] = {
{0x66a1, 0x00, RAS_BLOCK_MASK_ALL},
{0x66a1, 0x01, RAS_BLOCK_MASK_ALL},
{0x66a1, 0x04, RAS_BLOCK_MASK_ALL},
};
+static uint32_t amdgpu_ras_find_block_id_by_name(const char *name)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(ras_block_string); i++) {
+ if (strcmp(name, ras_block_string[i]) == 0)
+ return i;
+ }
+
+ return ARRAY_SIZE(ras_block_string);
+}
+
+static char *amdgpu_ras_get_error_type_id(enum amdgpu_ras_error_type type)
+{
+ switch (type) {
+ case AMDGPU_RAS_ERROR__PARITY:
+ return "parity";
+ case AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE:
+ return "single_correctable";
+ case AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE:
+ return "multi_uncorrectable";
+ case AMDGPU_RAS_ERROR__POISON:
+ return "poison";
+ case AMDGPU_RAS_ERROR__NONE:
+ default:
+ return NULL;
+ }
+}
+
static struct ras_test_mask amdgpu_ras_get_test_mask(drmDevicePtr device)
{
int i;
@@ -188,7 +501,7 @@ static int get_file_contents(char *file, char *buf, int size);
static int amdgpu_ras_lookup_id(drmDevicePtr device)
{
- char path[1024];
+ char path[PATH_SIZE];
char str[128];
drmPciBusInfo info;
int i;
@@ -197,7 +510,7 @@ static int amdgpu_ras_lookup_id(drmDevicePtr device)
for (i = 0; i < MAX_CARDS_SUPPORTED; i++) {
memset(str, 0, sizeof(str));
memset(&info, 0, sizeof(info));
- sprintf(path, "/sys/kernel/debug/dri/%d/name", i);
+ snprintf(path, PATH_SIZE, "/sys/kernel/debug/dri/%d/name", i);
if (get_file_contents(path, str, sizeof(str)) <= 0)
continue;
@@ -212,146 +525,24 @@ static int amdgpu_ras_lookup_id(drmDevicePtr device)
return -1;
}
-CU_BOOL suite_ras_tests_enable(void)
-{
- amdgpu_device_handle device_handle;
- uint32_t major_version;
- uint32_t minor_version;
- int i;
- drmDevicePtr device;
-
- for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
- if (amdgpu_device_initialize(drm_amdgpu[i], &major_version,
- &minor_version, &device_handle))
- continue;
-
- if (drmGetDevice2(drm_amdgpu[i],
- DRM_DEVICE_GET_PCI_REVISION,
- &device))
- continue;
-
- if (device->bustype == DRM_BUS_PCI &&
- amdgpu_ras_lookup_capability(device_handle)) {
- amdgpu_device_deinitialize(device_handle);
- return CU_TRUE;
- }
-
- if (amdgpu_device_deinitialize(device_handle))
- continue;
- }
-
- return CU_FALSE;
-}
-
-int suite_ras_tests_init(void)
-{
- drmDevicePtr device;
- amdgpu_device_handle device_handle;
- uint32_t major_version;
- uint32_t minor_version;
- uint32_t capability;
- struct ras_test_mask test_mask;
- int id;
- int i;
- int r;
-
- for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
- r = amdgpu_device_initialize(drm_amdgpu[i], &major_version,
- &minor_version, &device_handle);
- if (r)
- continue;
-
- if (drmGetDevice2(drm_amdgpu[i],
- DRM_DEVICE_GET_PCI_REVISION,
- &device)) {
- amdgpu_device_deinitialize(device_handle);
- continue;
- }
-
- if (device->bustype != DRM_BUS_PCI) {
- amdgpu_device_deinitialize(device_handle);
- continue;
- }
-
- capability = amdgpu_ras_lookup_capability(device_handle);
- if (capability == 0) {
- amdgpu_device_deinitialize(device_handle);
- continue;
-
- }
-
- id = amdgpu_ras_lookup_id(device);
- if (id == -1) {
- amdgpu_device_deinitialize(device_handle);
- continue;
- }
-
- test_mask = amdgpu_ras_get_test_mask(device);
-
- devices[devices_count++] = (struct amdgpu_ras_data) {
- device_handle, id, capability, test_mask,
- };
- }
-
- if (devices_count == 0)
- return CUE_SINIT_FAILED;
-
- return CUE_SUCCESS;
-}
-
-int suite_ras_tests_clean(void)
-{
- int r;
- int i;
- int ret = CUE_SUCCESS;
-
- for (i = 0; i < devices_count; i++) {
- r = amdgpu_device_deinitialize(devices[i].device_handle);
- if (r)
- ret = CUE_SCLEAN_FAILED;
- }
- return ret;
-}
-
-static void amdgpu_ras_disable_test(void);
-static void amdgpu_ras_enable_test(void);
-static void amdgpu_ras_inject_test(void);
-static void amdgpu_ras_query_test(void);
-static void amdgpu_ras_basic_test(void);
-
-CU_TestInfo ras_tests[] = {
- { "ras basic test", amdgpu_ras_basic_test },
- { "ras query test", amdgpu_ras_query_test },
- { "ras inject test", amdgpu_ras_inject_test },
- { "ras disable test", amdgpu_ras_disable_test },
-#if 0
- { "ras enable test", amdgpu_ras_enable_test },
-#endif
- CU_TEST_INFO_NULL,
-};
-
//helpers
static int test_card;
-static char sysfs_path[1024];
-static char debugfs_path[1024];
+static char sysfs_path[PATH_SIZE];
+static char debugfs_path[PATH_SIZE];
static uint32_t ras_mask;
static amdgpu_device_handle device_handle;
-static int set_test_card(int card)
+static void set_test_card(int card)
{
- int i;
-
test_card = card;
- sprintf(sysfs_path, "/sys/class/drm/card%d/device/ras/", devices[card].id);
- sprintf(debugfs_path, "/sys/kernel/debug/dri/%d/ras/", devices[card].id);
+ snprintf(sysfs_path, PATH_SIZE, "/sys/class/drm/card%d/device/ras/", devices[card].id);
+ snprintf(debugfs_path, PATH_SIZE, "/sys/kernel/debug/dri/%d/ras/", devices[card].id);
ras_mask = devices[card].capability;
device_handle = devices[card].device_handle;
ras_block_mask_inject = devices[card].test_mask.inject_mask;
ras_block_mask_query = devices[card].test_mask.query_mask;
ras_block_mask_basic = devices[card].test_mask.basic_mask;
-
- return 0;
}
static const char *get_ras_sysfs_root(void)
@@ -417,10 +608,11 @@ static int amdgpu_ras_is_feature_supported(enum amdgpu_ras_block block)
static int amdgpu_ras_invoke(struct ras_debug_if *data)
{
- char path[1024];
+ char path[PATH_SIZE];
int ret;
- sprintf(path, "%s%s", get_ras_debugfs_root(), "ras_ctrl");
+ snprintf(path, sizeof(path), "%s", get_ras_debugfs_root());
+ strncat(path, "ras_ctrl", sizeof(path) - strlen(path));
ret = set_file_contents(path, (char *)data, sizeof(*data))
- sizeof(*data);
@@ -431,15 +623,16 @@ static int amdgpu_ras_query_err_count(enum amdgpu_ras_block block,
unsigned long *ue, unsigned long *ce)
{
char buf[64];
- char name[1024];
- int ret;
+ char name[PATH_SIZE];
*ue = *ce = 0;
if (amdgpu_ras_is_feature_supported(block) <= 0)
return -1;
- sprintf(name, "%s%s%s", get_ras_sysfs_root(), ras_block_str(block), "_err_count");
+ snprintf(name, sizeof(name), "%s", get_ras_sysfs_root());
+ strncat(name, ras_block_str(block), sizeof(name) - strlen(name));
+ strncat(name, "_err_count", sizeof(name) - strlen(name));
if (is_file_ok(name, O_RDONLY))
return 0;
@@ -453,6 +646,34 @@ static int amdgpu_ras_query_err_count(enum amdgpu_ras_block block,
return 0;
}
+static int amdgpu_ras_inject(enum amdgpu_ras_block block,
+ uint32_t sub_block, enum amdgpu_ras_error_type type,
+ uint64_t address, uint64_t value)
+{
+ struct ras_debug_if data = { .op = 2, };
+ struct ras_inject_if *inject = &data.inject;
+ int ret;
+
+ if (amdgpu_ras_is_feature_enabled(block) <= 0) {
+ fprintf(stderr, "block id(%d) is not valid\n", block);
+ return -1;
+ }
+
+ inject->head.block = block;
+ inject->head.type = type;
+ inject->head.sub_block_index = sub_block;
+ strncpy(inject->head.name, ras_block_str(block), sizeof(inject->head.name)-1);
+ inject->address = address;
+ inject->value = value;
+
+ ret = amdgpu_ras_invoke(&data);
+ CU_ASSERT_EQUAL(ret, 0);
+ if (ret)
+ return -1;
+
+ return 0;
+}
+
//tests
static void amdgpu_ras_features_test(int enable)
{
@@ -503,69 +724,83 @@ static void amdgpu_ras_enable_test(void)
}
}
-static void __amdgpu_ras_inject_test(void)
+static void __amdgpu_ras_ip_inject_test(const struct ras_inject_test_config *ip_test,
+ uint32_t size)
{
- struct ras_debug_if data;
- int ret;
- int i;
- unsigned long ue, ce, ue_old, ce_old;
+ int i, ret;
+ unsigned long old_ue, old_ce;
+ unsigned long ue, ce;
+ uint32_t block;
+ int timeout;
+ bool pass;
- data.op = 2;
- for (i = 0; i < AMDGPU_RAS_BLOCK__LAST; i++) {
- int timeout = 3;
- struct ras_inject_if inject = {
- .head = {
- .block = i,
- .type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE,
- .sub_block_index = 0,
- .name = "",
- },
- .address = 0,
- .value = 0,
- };
+ for (i = 0; i < size; i++) {
+ timeout = 3;
+ pass = false;
- if (amdgpu_ras_is_feature_enabled(i) <= 0)
- continue;
+ block = amdgpu_ras_find_block_id_by_name(ip_test[i].block);
- if (!((1 << i) & ras_block_mask_inject))
- continue;
+ /* Ensure one valid ip block */
+ if (block == ARRAY_SIZE(ras_block_string))
+ break;
- data.inject = inject;
+ /* Ensure RAS feature for the IP block is enabled by kernel */
+ if (amdgpu_ras_is_feature_supported(block) <= 0)
+ break;
- ret = amdgpu_ras_query_err_count(i, &ue_old, &ce_old);
+ ret = amdgpu_ras_query_err_count(block, &old_ue, &old_ce);
CU_ASSERT_EQUAL(ret, 0);
-
if (ret)
- continue;
+ break;
- ret = amdgpu_ras_invoke(&data);
+ ret = amdgpu_ras_inject(block,
+ ip_test[i].sub_block,
+ ip_test[i].type,
+ ip_test[i].address,
+ ip_test[i].value);
CU_ASSERT_EQUAL(ret, 0);
-
if (ret)
- continue;
+ break;
-loop:
while (timeout > 0) {
- ret = amdgpu_ras_query_err_count(i, &ue, &ce);
- CU_ASSERT_EQUAL(ret, 0);
+ sleep(5);
+ ret = amdgpu_ras_query_err_count(block, &ue, &ce);
+ CU_ASSERT_EQUAL(ret, 0);
if (ret)
- continue;
- if (ue_old != ue) {
- /*recovery takes ~10s*/
- sleep(10);
break;
- }
- sleep(1);
+ if (old_ue != ue || old_ce != ce) {
+ pass = true;
+ sleep(20);
+ break;
+ }
timeout -= 1;
}
-
- CU_ASSERT_EQUAL(ue_old + 1, ue);
- CU_ASSERT_EQUAL(ce_old, ce);
+ printf("\t Test %s@block %s, subblock %d, error_type %s, address %ld, value %ld: %s\n",
+ ip_test[i].name,
+ ip_test[i].block,
+ ip_test[i].sub_block,
+ amdgpu_ras_get_error_type_id(ip_test[i].type),
+ ip_test[i].address,
+ ip_test[i].value,
+ pass ? "Pass" : "Fail");
}
}
+static void __amdgpu_ras_inject_test(void)
+{
+ printf("...\n");
+
+ /* run UMC ras inject test */
+ __amdgpu_ras_ip_inject_test(umc_ras_inject_test,
+ ARRAY_SIZE(umc_ras_inject_test));
+
+ /* run GFX ras inject test */
+ __amdgpu_ras_ip_inject_test(gfx_ras_inject_test,
+ ARRAY_SIZE(gfx_ras_inject_test));
+}
+
static void amdgpu_ras_inject_test(void)
{
int i;
@@ -604,13 +839,11 @@ static void amdgpu_ras_query_test(void)
static void amdgpu_ras_basic_test(void)
{
- unsigned long ue, ce;
- char name[1024];
int ret;
int i;
int j;
uint32_t features;
- char path[1024];
+ char path[PATH_SIZE];
ret = is_file_ok("/sys/module/amdgpu/parameters/ras_mask", O_RDONLY);
CU_ASSERT_EQUAL(ret, 0);
@@ -622,11 +855,15 @@ static void amdgpu_ras_basic_test(void)
sizeof(features), &features);
CU_ASSERT_EQUAL(ret, 0);
- sprintf(path, "%s%s", get_ras_debugfs_root(), "ras_ctrl");
+ snprintf(path, sizeof(path), "%s", get_ras_debugfs_root());
+ strncat(path, "ras_ctrl", sizeof(path) - strlen(path));
+
ret = is_file_ok(path, O_WRONLY);
CU_ASSERT_EQUAL(ret, 0);
- sprintf(path, "%s%s", get_ras_sysfs_root(), "features");
+ snprintf(path, sizeof(path), "%s", get_ras_sysfs_root());
+ strncat(path, "features", sizeof(path) - strlen(path));
+
ret = is_file_ok(path, O_RDONLY);
CU_ASSERT_EQUAL(ret, 0);
@@ -638,13 +875,129 @@ static void amdgpu_ras_basic_test(void)
if (!((1 << j) & ras_block_mask_basic))
continue;
- sprintf(path, "%s%s%s", get_ras_sysfs_root(), ras_block_str(j), "_err_count");
+ snprintf(path, sizeof(path), "%s", get_ras_sysfs_root());
+ strncat(path, ras_block_str(j), sizeof(path) - strlen(path));
+ strncat(path, "_err_count", sizeof(path) - strlen(path));
+
ret = is_file_ok(path, O_RDONLY);
CU_ASSERT_EQUAL(ret, 0);
- sprintf(path, "%s%s%s", get_ras_debugfs_root(), ras_block_str(j), "_err_inject");
+ snprintf(path, sizeof(path), "%s", get_ras_debugfs_root());
+ strncat(path, ras_block_str(j), sizeof(path) - strlen(path));
+ strncat(path, "_err_inject", sizeof(path) - strlen(path));
+
ret = is_file_ok(path, O_WRONLY);
CU_ASSERT_EQUAL(ret, 0);
}
}
}
+
+CU_TestInfo ras_tests[] = {
+ { "ras basic test", amdgpu_ras_basic_test },
+ { "ras query test", amdgpu_ras_query_test },
+ { "ras inject test", amdgpu_ras_inject_test },
+ { "ras disable test", amdgpu_ras_disable_test },
+ { "ras enable test", amdgpu_ras_enable_test },
+ CU_TEST_INFO_NULL,
+};
+
+CU_BOOL suite_ras_tests_enable(void)
+{
+ amdgpu_device_handle device_handle;
+ uint32_t major_version;
+ uint32_t minor_version;
+ int i;
+ drmDevicePtr device;
+
+ for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
+ if (amdgpu_device_initialize(drm_amdgpu[i], &major_version,
+ &minor_version, &device_handle))
+ continue;
+
+ if (drmGetDevice2(drm_amdgpu[i],
+ DRM_DEVICE_GET_PCI_REVISION,
+ &device))
+ continue;
+
+ if (device->bustype == DRM_BUS_PCI &&
+ amdgpu_ras_lookup_capability(device_handle)) {
+ amdgpu_device_deinitialize(device_handle);
+ return CU_TRUE;
+ }
+
+ if (amdgpu_device_deinitialize(device_handle))
+ continue;
+ }
+
+ return CU_FALSE;
+}
+
+int suite_ras_tests_init(void)
+{
+ drmDevicePtr device;
+ amdgpu_device_handle device_handle;
+ uint32_t major_version;
+ uint32_t minor_version;
+ uint32_t capability;
+ struct ras_test_mask test_mask;
+ int id;
+ int i;
+ int r;
+
+ for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
+ r = amdgpu_device_initialize(drm_amdgpu[i], &major_version,
+ &minor_version, &device_handle);
+ if (r)
+ continue;
+
+ if (drmGetDevice2(drm_amdgpu[i],
+ DRM_DEVICE_GET_PCI_REVISION,
+ &device)) {
+ amdgpu_device_deinitialize(device_handle);
+ continue;
+ }
+
+ if (device->bustype != DRM_BUS_PCI) {
+ amdgpu_device_deinitialize(device_handle);
+ continue;
+ }
+
+ capability = amdgpu_ras_lookup_capability(device_handle);
+ if (capability == 0) {
+ amdgpu_device_deinitialize(device_handle);
+ continue;
+
+ }
+
+ id = amdgpu_ras_lookup_id(device);
+ if (id == -1) {
+ amdgpu_device_deinitialize(device_handle);
+ continue;
+ }
+
+ test_mask = amdgpu_ras_get_test_mask(device);
+
+ devices[devices_count++] = (struct amdgpu_ras_data) {
+ device_handle, id, capability, test_mask,
+ };
+ }
+
+ if (devices_count == 0)
+ return CUE_SINIT_FAILED;
+
+ return CUE_SUCCESS;
+}
+
+int suite_ras_tests_clean(void)
+{
+ int r;
+ int i;
+ int ret = CUE_SUCCESS;
+
+ for (i = 0; i < devices_count; i++) {
+ r = amdgpu_device_deinitialize(devices[i].device_handle);
+ if (r)
+ ret = CUE_SCLEAN_FAILED;
+ }
+ return ret;
+}
diff --git a/tests/amdgpu/syncobj_tests.c b/tests/amdgpu/syncobj_tests.c
index 869ed88e..3a7b38eb 100644
--- a/tests/amdgpu/syncobj_tests.c
+++ b/tests/amdgpu/syncobj_tests.c
@@ -96,7 +96,7 @@ static int syncobj_command_submission_helper(uint32_t syncobj_handle, bool
struct amdgpu_cs_fence fence_status;
amdgpu_bo_list_handle bo_list;
amdgpu_va_handle va_handle;
- uint32_t expired, flags;
+ uint32_t expired;
int i, r;
uint64_t seq_no;
static uint32_t *ptr;
diff --git a/tests/amdgpu/vcn_tests.c b/tests/amdgpu/vcn_tests.c
index ad438f35..77ceeb14 100644
--- a/tests/amdgpu/vcn_tests.c
+++ b/tests/amdgpu/vcn_tests.c
@@ -56,6 +56,7 @@ static amdgpu_device_handle device_handle;
static uint32_t major_version;
static uint32_t minor_version;
static uint32_t family_id;
+static uint32_t asic_id;
static amdgpu_context_handle context_handle;
static amdgpu_bo_handle ib_handle;
@@ -95,6 +96,7 @@ CU_BOOL suite_vcn_tests_enable(void)
return CU_FALSE;
family_id = device_handle->info.family_id;
+ asic_id = device_handle->info.asic_id;
if (amdgpu_device_deinitialize(device_handle))
return CU_FALSE;
@@ -106,11 +108,19 @@ CU_BOOL suite_vcn_tests_enable(void)
}
if (family_id == AMDGPU_FAMILY_RV) {
- reg.data0 = 0x81c4;
- reg.data1 = 0x81c5;
- reg.cmd = 0x81c3;
- reg.nop = 0x81ff;
- reg.cntl = 0x81c6;
+ if (asic_id == 0x1636) {
+ reg.data0 = 0x504;
+ reg.data1 = 0x505;
+ reg.cmd = 0x503;
+ reg.nop = 0x53f;
+ reg.cntl = 0x506;
+ } else {
+ reg.data0 = 0x81c4;
+ reg.data1 = 0x81c5;
+ reg.cmd = 0x81c3;
+ reg.nop = 0x81ff;
+ reg.cntl = 0x81c6;
+ }
} else if (family_id == AMDGPU_FAMILY_NV) {
reg.data0 = 0x504;
reg.data1 = 0x505;
@@ -333,6 +343,7 @@ static void amdgpu_cs_vcn_dec_decode(void)
avc_decode_msg, sizeof(avc_decode_msg));
dec += 4*1024;
+ memcpy(dec, feedback_msg, sizeof(feedback_msg));
dec += 4*1024;
memcpy(dec, uvd_it_scaling_table, sizeof(uvd_it_scaling_table));
diff --git a/tests/etnaviv/Makefile.am b/tests/etnaviv/Makefile.am
deleted file mode 100644
index 3e0c6120..00000000
--- a/tests/etnaviv/Makefile.am
+++ /dev/null
@@ -1,43 +0,0 @@
-AM_CFLAGS = \
- -fvisibility=hidden \
- -I $(top_srcdir)/include/drm \
- -I $(top_srcdir)/etnaviv \
- -I $(top_srcdir)
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS = \
- etnaviv_2d_test \
- etnaviv_cmd_stream_test \
- etnaviv_bo_cache_test
-else
-noinst_PROGRAMS = \
- etnaviv_2d_test \
- etnaviv_cmd_stream_test \
- etnaviv_bo_cache_test
-endif
-
-etnaviv_2d_test_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/etnaviv/libdrm_etnaviv.la
-
-etnaviv_2d_test_SOURCES = \
- cmdstream.xml.h \
- etnaviv_2d_test.c \
- state.xml.h \
- state_2d.xml.h \
- write_bmp.c \
- write_bmp.h
-
-etnaviv_cmd_stream_test_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/etnaviv/libdrm_etnaviv.la
-
-etnaviv_cmd_stream_test_SOURCES = \
- etnaviv_cmd_stream_test.c
-
-etnaviv_bo_cache_test_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/etnaviv/libdrm_etnaviv.la
-
-etnaviv_bo_cache_test_SOURCES = \
- etnaviv_bo_cache_test.c
diff --git a/tests/exynos/Makefile.am b/tests/exynos/Makefile.am
deleted file mode 100644
index 9658fb42..00000000
--- a/tests/exynos/Makefile.am
+++ /dev/null
@@ -1,48 +0,0 @@
-AM_CFLAGS = \
- -pthread \
- $(WARN_CFLAGS)\
- -fvisibility=hidden \
- -I $(top_srcdir)/include/drm \
- -I $(top_srcdir)/libkms/ \
- -I $(top_srcdir)/exynos \
- -I $(top_srcdir)
-
-bin_PROGRAMS =
-noinst_PROGRAMS =
-
-if HAVE_LIBKMS
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS += \
- exynos_fimg2d_test
-else
-noinst_PROGRAMS += \
- exynos_fimg2d_test
-endif
-endif
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS += \
- exynos_fimg2d_perf \
- exynos_fimg2d_event
-else
-noinst_PROGRAMS += \
- exynos_fimg2d_perf \
- exynos_fimg2d_event
-endif
-
-exynos_fimg2d_perf_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/exynos/libdrm_exynos.la
-
-exynos_fimg2d_event_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/exynos/libdrm_exynos.la
-
-exynos_fimg2d_test_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/libkms/libkms.la \
- $(top_builddir)/exynos/libdrm_exynos.la
-
-exynos_fimg2d_test_SOURCES = \
- exynos_fimg2d_test.c
-
diff --git a/tests/kms/Makefile.am b/tests/kms/Makefile.am
deleted file mode 100644
index 42242006..00000000
--- a/tests/kms/Makefile.am
+++ /dev/null
@@ -1,37 +0,0 @@
-AM_CPPFLAGS = \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/tests \
- -I$(top_srcdir)
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden
-
-noinst_LTLIBRARIES = libkms-test.la
-
-libkms_test_la_SOURCES = \
- libkms-test.h \
- libkms-test-crtc.c \
- libkms-test-device.c \
- libkms-test-framebuffer.c \
- libkms-test-plane.c \
- libkms-test-screen.c
-
-libkms_test_la_LIBADD = \
- $(top_builddir)/libdrm.la
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS = \
- kms-steal-crtc \
- kms-universal-planes
-else
-noinst_PROGRAMS = \
- kms-steal-crtc \
- kms-universal-planes
-endif
-
-kms_steal_crtc_SOURCES = kms-steal-crtc.c
-kms_steal_crtc_LDADD = libkms-test.la ../util/libutil.la $(CAIRO_LIBS)
-
-kms_universal_planes_SOURCES = kms-universal-planes.c
-kms_universal_planes_LDADD = libkms-test.la $(CAIRO_LIBS)
diff --git a/tests/kms/kms-steal-crtc.c b/tests/kms/kms-steal-crtc.c
index cd40758d..4d884c07 100644
--- a/tests/kms/kms-steal-crtc.c
+++ b/tests/kms/kms-steal-crtc.c
@@ -28,7 +28,7 @@
#include <stdint.h>
#include <string.h>
#include <unistd.h>
-#ifdef HAVE_SYS_SELECT_H
+#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
diff --git a/tests/kms/kms-universal-planes.c b/tests/kms/kms-universal-planes.c
index 2163c987..1d793880 100644
--- a/tests/kms/kms-universal-planes.c
+++ b/tests/kms/kms-universal-planes.c
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#ifdef HAVE_SYS_SELECT_H
+#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
diff --git a/tests/kms/libkms-test-screen.c b/tests/kms/libkms-test-screen.c
index bbe972a0..d00ae547 100644
--- a/tests/kms/libkms-test-screen.c
+++ b/tests/kms/libkms-test-screen.c
@@ -42,7 +42,9 @@ static void kms_screen_probe(struct kms_screen *screen)
else
screen->connected = false;
- memcpy(&screen->mode, &con->modes[0], sizeof(drmModeModeInfo));
+ if (con->modes)
+ memcpy(&screen->mode, &con->modes[0], sizeof(drmModeModeInfo));
+
screen->width = screen->mode.hdisplay;
screen->height = screen->mode.vdisplay;
diff --git a/tests/kmstest/Makefile.am b/tests/kmstest/Makefile.am
deleted file mode 100644
index 4c993b04..00000000
--- a/tests/kmstest/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-AM_CFLAGS = \
- $(WARN_CFLAGS)\
- -fvisibility=hidden \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/libkms/ \
- -I$(top_srcdir)/tests/ \
- -I$(top_srcdir)
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS = \
- kmstest
-else
-noinst_PROGRAMS = \
- kmstest
-endif
-
-kmstest_SOURCES = \
- main.c
-
-kmstest_LDADD = \
- $(top_builddir)/tests/util/libutil.la \
- $(top_builddir)/libkms/libkms.la \
- $(top_builddir)/libdrm.la
-
-run: kmstest
- ./kmstest
diff --git a/tests/meson.build b/tests/meson.build
index 6c8ddd9c..196edbfa 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -64,23 +64,15 @@ hash = executable(
c_args : libdrm_c_args,
)
-random = executable(
- 'random',
- files('random.c'),
- include_directories : [inc_root, inc_drm],
- link_with : libdrm,
- c_args : libdrm_c_args,
-)
-
drmdevice = executable(
'drmdevice',
files('drmdevice.c'),
include_directories : [inc_root, inc_drm],
link_with : libdrm,
c_args : libdrm_c_args,
+ install : with_install_tests,
)
-test('random', random, timeout : 240)
test('hash', hash)
test('drmsl', drmsl)
test('drmdevice', drmdevice)
diff --git a/tests/modeprint/Makefile.am b/tests/modeprint/Makefile.am
deleted file mode 100644
index 568185f0..00000000
--- a/tests/modeprint/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-AM_CFLAGS = \
- $(WARN_CFLAGS)\
- -fvisibility=hidden \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/tests \
- -I$(top_srcdir)
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS = \
- modeprint
-else
-noinst_PROGRAMS = \
- modeprint
-endif
-
-modeprint_SOURCES = \
- modeprint.c
-modeprint_LDADD = \
- $(top_builddir)/tests/util/libutil.la \
- $(top_builddir)/libdrm.la
diff --git a/tests/modetest/Makefile.am b/tests/modetest/Makefile.am
deleted file mode 100644
index 5eebd960..00000000
--- a/tests/modetest/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-include Makefile.sources
-
-AM_CFLAGS = $(filter-out -Wpointer-arith, $(WARN_CFLAGS))
-
-AM_CFLAGS += \
- -fvisibility=hidden \
- -pthread \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/tests \
- -I$(top_srcdir)
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS = \
- modetest
-else
-noinst_PROGRAMS = \
- modetest
-endif
-
-modetest_SOURCES = $(MODETEST_FILES)
-
-modetest_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/tests/util/libutil.la \
- $(CAIRO_LIBS)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index e66be660..3371eee0 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -51,9 +51,10 @@
#include <errno.h>
#include <poll.h>
#include <sys/time.h>
-#ifdef HAVE_SYS_SELECT_H
+#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
+#include <math.h>
#include "xf86drm.h"
#include "xf86drmMode.h"
@@ -99,14 +100,16 @@ struct plane {
};
struct resources {
- drmModeRes *res;
- drmModePlaneRes *plane_res;
-
struct crtc *crtcs;
+ int count_crtcs;
struct encoder *encoders;
+ int count_encoders;
struct connector *connectors;
+ int count_connectors;
struct fb *fbs;
+ int count_fbs;
struct plane *planes;
+ uint32_t count_planes;
};
struct device {
@@ -132,6 +135,12 @@ static inline int64_t U642I64(uint64_t val)
return (int64_t)*((int64_t *)&val);
}
+static float mode_vrefresh(drmModeModeInfo *mode)
+{
+ return mode->clock * 1000.00
+ / (mode->htotal * mode->vtotal);
+}
+
#define bit_name_fn(res) \
const char * res##_str(int type) { \
unsigned int i; \
@@ -192,7 +201,7 @@ static void dump_encoders(struct device *dev)
printf("Encoders:\n");
printf("id\tcrtc\ttype\tpossible crtcs\tpossible clones\t\n");
- for (i = 0; i < dev->resources->res->count_encoders; i++) {
+ for (i = 0; i < dev->resources->count_encoders; i++) {
encoder = dev->resources->encoders[i].encoder;
if (!encoder)
continue;
@@ -207,11 +216,12 @@ static void dump_encoders(struct device *dev)
printf("\n");
}
-static void dump_mode(drmModeModeInfo *mode)
+static void dump_mode(drmModeModeInfo *mode, int index)
{
- printf(" %s %d %d %d %d %d %d %d %d %d %d",
+ printf(" #%i %s %.2f %d %d %d %d %d %d %d %d %d",
+ index,
mode->name,
- mode->vrefresh,
+ mode_vrefresh(mode),
mode->hdisplay,
mode->hsync_start,
mode->hsync_end,
@@ -426,7 +436,7 @@ static void dump_connectors(struct device *dev)
printf("Connectors:\n");
printf("id\tencoder\tstatus\t\tname\t\tsize (mm)\tmodes\tencoders\n");
- for (i = 0; i < dev->resources->res->count_connectors; i++) {
+ for (i = 0; i < dev->resources->count_connectors; i++) {
struct connector *_connector = &dev->resources->connectors[i];
drmModeConnector *connector = _connector->connector;
if (!connector)
@@ -446,10 +456,10 @@ static void dump_connectors(struct device *dev)
if (connector->count_modes) {
printf(" modes:\n");
- printf("\tname refresh (Hz) hdisp hss hse htot vdisp "
+ printf("\tindex name refresh (Hz) hdisp hss hse htot vdisp "
"vss vse vtot)\n");
for (j = 0; j < connector->count_modes; j++)
- dump_mode(&connector->modes[j]);
+ dump_mode(&connector->modes[j], j);
}
if (_connector->props) {
@@ -470,7 +480,7 @@ static void dump_crtcs(struct device *dev)
printf("CRTCs:\n");
printf("id\tfb\tpos\tsize\n");
- for (i = 0; i < dev->resources->res->count_crtcs; i++) {
+ for (i = 0; i < dev->resources->count_crtcs; i++) {
struct crtc *_crtc = &dev->resources->crtcs[i];
drmModeCrtc *crtc = _crtc->crtc;
if (!crtc)
@@ -481,7 +491,7 @@ static void dump_crtcs(struct device *dev)
crtc->buffer_id,
crtc->x, crtc->y,
crtc->width, crtc->height);
- dump_mode(&crtc->mode);
+ dump_mode(&crtc->mode, 0);
if (_crtc->props) {
printf(" props:\n");
@@ -503,7 +513,7 @@ static void dump_framebuffers(struct device *dev)
printf("Frame buffers:\n");
printf("id\tsize\tpitch\n");
- for (i = 0; i < dev->resources->res->count_fbs; i++) {
+ for (i = 0; i < dev->resources->count_fbs; i++) {
fb = dev->resources->fbs[i].fb;
if (!fb)
continue;
@@ -523,10 +533,7 @@ static void dump_planes(struct device *dev)
printf("Planes:\n");
printf("id\tcrtc\tfb\tCRTC x,y\tx,y\tgamma size\tpossible crtcs\n");
- if (!dev->resources->plane_res)
- return;
-
- for (i = 0; i < dev->resources->plane_res->count_planes; i++) {
+ for (i = 0; i < dev->resources->count_planes; i++) {
struct plane *plane = &dev->resources->planes[i];
drmModePlane *ovr = plane->plane;
if (!ovr)
@@ -567,11 +574,11 @@ static void free_resources(struct resources *res)
if (!res)
return;
-#define free_resource(_res, __res, type, Type) \
+#define free_resource(_res, type, Type) \
do { \
if (!(_res)->type##s) \
break; \
- for (i = 0; i < (int)(_res)->__res->count_##type##s; ++i) { \
+ for (i = 0; i < (int)(_res)->count_##type##s; ++i) { \
if (!(_res)->type##s[i].type) \
break; \
drmModeFree##Type((_res)->type##s[i].type); \
@@ -579,42 +586,38 @@ static void free_resources(struct resources *res)
free((_res)->type##s); \
} while (0)
-#define free_properties(_res, __res, type) \
+#define free_properties(_res, type) \
do { \
- for (i = 0; i < (int)(_res)->__res->count_##type##s; ++i) { \
- drmModeFreeObjectProperties(res->type##s[i].props); \
+ for (i = 0; i < (int)(_res)->count_##type##s; ++i) { \
+ unsigned int j; \
+ for (j = 0; j < res->type##s[i].props->count_props; ++j)\
+ drmModeFreeProperty(res->type##s[i].props_info[j]);\
free(res->type##s[i].props_info); \
+ drmModeFreeObjectProperties(res->type##s[i].props); \
} \
} while (0)
- if (res->res) {
- free_properties(res, res, crtc);
-
- free_resource(res, res, crtc, Crtc);
- free_resource(res, res, encoder, Encoder);
+ free_properties(res, plane);
+ free_resource(res, plane, Plane);
- for (i = 0; i < res->res->count_connectors; i++)
- free(res->connectors[i].name);
+ free_properties(res, connector);
+ free_properties(res, crtc);
- free_resource(res, res, connector, Connector);
- free_resource(res, res, fb, FB);
+ for (i = 0; i < res->count_connectors; i++)
+ free(res->connectors[i].name);
- drmModeFreeResources(res->res);
- }
-
- if (res->plane_res) {
- free_properties(res, plane_res, plane);
-
- free_resource(res, plane_res, plane, Plane);
-
- drmModeFreePlaneResources(res->plane_res);
- }
+ free_resource(res, fb, FB);
+ free_resource(res, connector, Connector);
+ free_resource(res, encoder, Encoder);
+ free_resource(res, crtc, Crtc);
free(res);
}
static struct resources *get_resources(struct device *dev)
{
+ drmModeRes *_res;
+ drmModePlaneRes *plane_res;
struct resources *res;
int i;
@@ -624,40 +627,51 @@ static struct resources *get_resources(struct device *dev)
drmSetClientCap(dev->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
- res->res = drmModeGetResources(dev->fd);
- if (!res->res) {
+ _res = drmModeGetResources(dev->fd);
+ if (!_res) {
fprintf(stderr, "drmModeGetResources failed: %s\n",
strerror(errno));
- goto error;
+ free(res);
+ return NULL;
}
- res->crtcs = calloc(res->res->count_crtcs, sizeof(*res->crtcs));
- res->encoders = calloc(res->res->count_encoders, sizeof(*res->encoders));
- res->connectors = calloc(res->res->count_connectors, sizeof(*res->connectors));
- res->fbs = calloc(res->res->count_fbs, sizeof(*res->fbs));
+ res->count_crtcs = _res->count_crtcs;
+ res->count_encoders = _res->count_encoders;
+ res->count_connectors = _res->count_connectors;
+ res->count_fbs = _res->count_fbs;
- if (!res->crtcs || !res->encoders || !res->connectors || !res->fbs)
+ res->crtcs = calloc(res->count_crtcs, sizeof(*res->crtcs));
+ res->encoders = calloc(res->count_encoders, sizeof(*res->encoders));
+ res->connectors = calloc(res->count_connectors, sizeof(*res->connectors));
+ res->fbs = calloc(res->count_fbs, sizeof(*res->fbs));
+
+ if (!res->crtcs || !res->encoders || !res->connectors || !res->fbs) {
+ drmModeFreeResources(_res);
goto error;
+ }
#define get_resource(_res, __res, type, Type) \
do { \
- for (i = 0; i < (int)(_res)->__res->count_##type##s; ++i) { \
- (_res)->type##s[i].type = \
- drmModeGet##Type(dev->fd, (_res)->__res->type##s[i]); \
- if (!(_res)->type##s[i].type) \
+ for (i = 0; i < (int)(_res)->count_##type##s; ++i) { \
+ uint32_t type##id = (__res)->type##s[i]; \
+ (_res)->type##s[i].type = \
+ drmModeGet##Type(dev->fd, type##id); \
+ if (!(_res)->type##s[i].type) \
fprintf(stderr, "could not get %s %i: %s\n", \
- #type, (_res)->__res->type##s[i], \
+ #type, type##id, \
strerror(errno)); \
} \
} while (0)
- get_resource(res, res, crtc, Crtc);
- get_resource(res, res, encoder, Encoder);
- get_resource(res, res, connector, Connector);
- get_resource(res, res, fb, FB);
+ get_resource(res, _res, crtc, Crtc);
+ get_resource(res, _res, encoder, Encoder);
+ get_resource(res, _res, connector, Connector);
+ get_resource(res, _res, fb, FB);
+
+ drmModeFreeResources(_res);
/* Set the name of all connectors based on the type name and the per-type ID. */
- for (i = 0; i < res->res->count_connectors; i++) {
+ for (i = 0; i < res->count_connectors; i++) {
struct connector *connector = &res->connectors[i];
drmModeConnector *conn = connector->connector;
int num;
@@ -669,9 +683,9 @@ static struct resources *get_resources(struct device *dev)
goto error;
}
-#define get_properties(_res, __res, type, Type) \
+#define get_properties(_res, type, Type) \
do { \
- for (i = 0; i < (int)(_res)->__res->count_##type##s; ++i) { \
+ for (i = 0; i < (int)(_res)->count_##type##s; ++i) { \
struct type *obj = &res->type##s[i]; \
unsigned int j; \
obj->props = \
@@ -694,25 +708,30 @@ static struct resources *get_resources(struct device *dev)
} \
} while (0)
- get_properties(res, res, crtc, CRTC);
- get_properties(res, res, connector, CONNECTOR);
+ get_properties(res, crtc, CRTC);
+ get_properties(res, connector, CONNECTOR);
- for (i = 0; i < res->res->count_crtcs; ++i)
+ for (i = 0; i < res->count_crtcs; ++i)
res->crtcs[i].mode = &res->crtcs[i].crtc->mode;
- res->plane_res = drmModeGetPlaneResources(dev->fd);
- if (!res->plane_res) {
+ plane_res = drmModeGetPlaneResources(dev->fd);
+ if (!plane_res) {
fprintf(stderr, "drmModeGetPlaneResources failed: %s\n",
strerror(errno));
return res;
}
- res->planes = calloc(res->plane_res->count_planes, sizeof(*res->planes));
- if (!res->planes)
+ res->count_planes = plane_res->count_planes;
+
+ res->planes = calloc(res->count_planes, sizeof(*res->planes));
+ if (!res->planes) {
+ drmModeFreePlaneResources(plane_res);
goto error;
+ }
get_resource(res, plane_res, plane, Plane);
- get_properties(res, plane_res, plane, PLANE);
+ drmModeFreePlaneResources(plane_res);
+ get_properties(res, plane, PLANE);
return res;
@@ -721,17 +740,31 @@ error:
return NULL;
}
-static int get_crtc_index(struct device *dev, uint32_t id)
+static struct crtc *get_crtc_by_id(struct device *dev, uint32_t id)
{
int i;
- for (i = 0; i < dev->resources->res->count_crtcs; ++i) {
+ for (i = 0; i < dev->resources->count_crtcs; ++i) {
drmModeCrtc *crtc = dev->resources->crtcs[i].crtc;
if (crtc && crtc->crtc_id == id)
- return i;
+ return &dev->resources->crtcs[i];
}
- return -1;
+ return NULL;
+}
+
+static uint32_t get_crtc_mask(struct device *dev, struct crtc *crtc)
+{
+ unsigned int i;
+
+ for (i = 0; i < (unsigned int)dev->resources->count_crtcs; i++) {
+ if (crtc->crtc->crtc_id == dev->resources->crtcs[i].crtc->crtc_id)
+ return 1 << i;
+ }
+ /* Unreachable: crtc->crtc is one of resources->crtcs[] */
+ /* Don't return zero or static analysers will complain */
+ abort();
+ return 0;
}
static drmModeConnector *get_connector_by_name(struct device *dev, const char *name)
@@ -739,7 +772,7 @@ static drmModeConnector *get_connector_by_name(struct device *dev, const char *n
struct connector *connector;
int i;
- for (i = 0; i < dev->resources->res->count_connectors; i++) {
+ for (i = 0; i < dev->resources->count_connectors; i++) {
connector = &dev->resources->connectors[i];
if (strcmp(connector->name, name) == 0)
@@ -754,7 +787,7 @@ static drmModeConnector *get_connector_by_id(struct device *dev, uint32_t id)
drmModeConnector *connector;
int i;
- for (i = 0; i < dev->resources->res->count_connectors; i++) {
+ for (i = 0; i < dev->resources->count_connectors; i++) {
connector = dev->resources->connectors[i].connector;
if (connector && connector->connector_id == id)
return connector;
@@ -768,7 +801,7 @@ static drmModeEncoder *get_encoder_by_id(struct device *dev, uint32_t id)
drmModeEncoder *encoder;
int i;
- for (i = 0; i < dev->resources->res->count_encoders; i++) {
+ for (i = 0; i < dev->resources->count_encoders; i++) {
encoder = dev->resources->encoders[i].encoder;
if (encoder && encoder->encoder_id == id)
return encoder;
@@ -795,7 +828,7 @@ struct pipe_arg {
uint32_t crtc_id;
char mode_str[64];
char format_str[5];
- unsigned int vrefresh;
+ float vrefresh;
unsigned int fourcc;
drmModeModeInfo *mode;
struct crtc *crtc;
@@ -822,7 +855,7 @@ struct plane_arg {
static drmModeModeInfo *
connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str,
- const unsigned int vrefresh)
+ const float vrefresh)
{
drmModeConnector *connector;
drmModeModeInfo *mode;
@@ -832,16 +865,27 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str,
if (!connector || !connector->count_modes)
return NULL;
+ /* Pick by Index */
+ if (mode_str[0] == '#') {
+ int index = atoi(mode_str + 1);
+
+ if (index >= connector->count_modes || index < 0)
+ return NULL;
+ return &connector->modes[index];
+ }
+
+ /* Pick by Name */
for (i = 0; i < connector->count_modes; i++) {
mode = &connector->modes[i];
if (!strcmp(mode->name, mode_str)) {
- /* If the vertical refresh frequency is not specified then return the
- * first mode that match with the name. Else, return the mode that match
- * the name and the specified vertical refresh frequency.
+ /* If the vertical refresh frequency is not specified
+ * then return the first mode that match with the name.
+ * Else, return the mode that match the name and
+ * the specified vertical refresh frequency.
*/
if (vrefresh == 0)
return mode;
- else if (mode->vrefresh == vrefresh)
+ else if (fabs(mode_vrefresh(mode) - vrefresh) < 0.005)
return mode;
}
}
@@ -861,7 +905,7 @@ static struct crtc *pipe_find_crtc(struct device *dev, struct pipe_arg *pipe)
uint32_t crtcs_for_connector = 0;
drmModeConnector *connector;
drmModeEncoder *encoder;
- int idx;
+ struct crtc *crtc;
connector = get_connector_by_id(dev, pipe->con_ids[i]);
if (!connector)
@@ -873,10 +917,10 @@ static struct crtc *pipe_find_crtc(struct device *dev, struct pipe_arg *pipe)
continue;
crtcs_for_connector |= encoder->possible_crtcs;
-
- idx = get_crtc_index(dev, encoder->crtc_id);
- if (idx >= 0)
- active_crtcs |= 1 << idx;
+ crtc = get_crtc_by_id(dev, encoder->crtc_id);
+ if (!crtc)
+ continue;
+ active_crtcs |= get_crtc_mask(dev, crtc);
}
possible_crtcs &= crtcs_for_connector;
@@ -907,7 +951,13 @@ static int pipe_find_crtc_and_mode(struct device *dev, struct pipe_arg *pipe)
mode = connector_find_mode(dev, pipe->con_ids[i],
pipe->mode_str, pipe->vrefresh);
if (mode == NULL) {
- fprintf(stderr,
+ if (pipe->vrefresh)
+ fprintf(stderr,
+ "failed to find mode "
+ "\"%s-%.2fHz\" for connector %s\n",
+ pipe->mode_str, pipe->vrefresh, pipe->cons[i]);
+ else
+ fprintf(stderr,
"failed to find mode \"%s\" for connector %s\n",
pipe->mode_str, pipe->cons[i]);
return -EINVAL;
@@ -918,16 +968,10 @@ static int pipe_find_crtc_and_mode(struct device *dev, struct pipe_arg *pipe)
* locate a CRTC that can be attached to all the connectors.
*/
if (pipe->crtc_id != (uint32_t)-1) {
- for (i = 0; i < dev->resources->res->count_crtcs; i++) {
- struct crtc *crtc = &dev->resources->crtcs[i];
-
- if (pipe->crtc_id == crtc->crtc->crtc_id) {
- pipe->crtc = crtc;
- break;
- }
- }
+ pipe->crtc = get_crtc_by_id(dev, pipe->crtc_id);
} else {
pipe->crtc = pipe_find_crtc(dev, pipe);
+ pipe->crtc_id = pipe->crtc->crtc->crtc_id;
}
if (!pipe->crtc) {
@@ -965,9 +1009,9 @@ static bool set_property(struct device *dev, struct property_arg *p)
p->obj_type = 0;
p->prop_id = 0;
-#define find_object(_res, __res, type, Type) \
+#define find_object(_res, type, Type) \
do { \
- for (i = 0; i < (int)(_res)->__res->count_##type##s; ++i) { \
+ for (i = 0; i < (int)(_res)->count_##type##s; ++i) { \
struct type *obj = &(_res)->type##s[i]; \
if (obj->type->type##_id != p->obj_id) \
continue; \
@@ -978,11 +1022,11 @@ static bool set_property(struct device *dev, struct property_arg *p)
} \
} while(0) \
- find_object(dev->resources, res, crtc, CRTC);
+ find_object(dev->resources, crtc, CRTC);
if (p->obj_type == 0)
- find_object(dev->resources, res, connector, CONNECTOR);
+ find_object(dev->resources, connector, CONNECTOR);
if (p->obj_type == 0)
- find_object(dev->resources, plane_res, plane, PLANE);
+ find_object(dev->resources, plane, PLANE);
if (p->obj_type == 0) {
fprintf(stderr, "Object %i not found, can't set property\n",
p->obj_id);
@@ -1041,7 +1085,7 @@ page_flip_handler(int fd, unsigned int frame,
else
new_fb_id = pipe->fb_id[0];
- drmModePageFlip(fd, pipe->crtc->crtc->crtc_id, new_fb_id,
+ drmModePageFlip(fd, pipe->crtc_id, new_fb_id,
DRM_MODE_PAGE_FLIP_EVENT, pipe);
pipe->current_fb_id = new_fb_id;
pipe->swap_count++;
@@ -1128,26 +1172,41 @@ static void set_gamma(struct device *dev, unsigned crtc_id, unsigned fourcc)
}
}
+static int
+bo_fb_create(int fd, unsigned int fourcc, const uint32_t w, const uint32_t h,
+ enum util_fill_pattern pat, struct bo **out_bo, unsigned int *out_fb_id)
+{
+ uint32_t handles[4] = {0}, pitches[4] = {0}, offsets[4] = {0};
+ struct bo *bo;
+ unsigned int fb_id;
+
+ bo = bo_create(fd, fourcc, w, h, handles, pitches, offsets, pat);
+
+ if (bo == NULL)
+ return -1;
+
+ if (drmModeAddFB2(fd, w, h, fourcc, handles, pitches, offsets, &fb_id, 0)) {
+ fprintf(stderr, "failed to add fb (%ux%u): %s\n", w, h, strerror(errno));
+ bo_destroy(bo);
+ return -1;
+ }
+ *out_bo = bo;
+ *out_fb_id = fb_id;
+ return 0;
+}
+
static int atomic_set_plane(struct device *dev, struct plane_arg *p,
int pattern, bool update)
{
- uint32_t handles[4] = {0}, pitches[4] = {0}, offsets[4] = {0};
struct bo *plane_bo;
int crtc_x, crtc_y, crtc_w, crtc_h;
struct crtc *crtc = NULL;
- unsigned int i;
unsigned int old_fb_id;
/* Find an unused plane which can be connected to our CRTC. Find the
* CRTC index first, then iterate over available planes.
*/
- for (i = 0; i < (unsigned int)dev->resources->res->count_crtcs; i++) {
- if (p->crtc_id == dev->resources->res->crtcs[i]) {
- crtc = &dev->resources->crtcs[i];
- break;
- }
- }
-
+ crtc = get_crtc_by_id(dev, p->crtc_id);
if (!crtc) {
fprintf(stderr, "CRTC %u not found\n", p->crtc_id);
return -1;
@@ -1161,17 +1220,9 @@ static int atomic_set_plane(struct device *dev, struct plane_arg *p,
p->old_bo = p->bo;
if (!plane_bo) {
- plane_bo = bo_create(dev->fd, p->fourcc, p->w, p->h,
- handles, pitches, offsets, pattern);
-
- if (plane_bo == NULL)
- return -1;
-
- if (drmModeAddFB2(dev->fd, p->w, p->h, p->fourcc,
- handles, pitches, offsets, &p->fb_id, 0)) {
- fprintf(stderr, "failed to add fb: %s\n", strerror(errno));
+ if (bo_fb_create(dev->fd, p->fourcc, p->w, p->h,
+ pattern, &plane_bo, &p->fb_id))
return -1;
- }
}
p->bo = plane_bo;
@@ -1207,34 +1258,23 @@ static int atomic_set_plane(struct device *dev, struct plane_arg *p,
static int set_plane(struct device *dev, struct plane_arg *p)
{
drmModePlane *ovr;
- uint32_t handles[4] = {0}, pitches[4] = {0}, offsets[4] = {0};
uint32_t plane_id;
- struct bo *plane_bo;
- uint32_t plane_flags = 0;
int crtc_x, crtc_y, crtc_w, crtc_h;
struct crtc *crtc = NULL;
- unsigned int pipe;
- unsigned int i;
+ unsigned int i, crtc_mask;
/* Find an unused plane which can be connected to our CRTC. Find the
* CRTC index first, then iterate over available planes.
*/
- for (i = 0; i < (unsigned int)dev->resources->res->count_crtcs; i++) {
- if (p->crtc_id == dev->resources->res->crtcs[i]) {
- crtc = &dev->resources->crtcs[i];
- pipe = i;
- break;
- }
- }
-
+ crtc = get_crtc_by_id(dev, p->crtc_id);
if (!crtc) {
fprintf(stderr, "CRTC %u not found\n", p->crtc_id);
return -1;
}
-
+ crtc_mask = get_crtc_mask(dev, crtc);
plane_id = p->plane_id;
- for (i = 0; i < dev->resources->plane_res->count_planes; i++) {
+ for (i = 0; i < dev->resources->count_planes; i++) {
ovr = dev->resources->planes[i].plane;
if (!ovr)
continue;
@@ -1245,35 +1285,26 @@ static int set_plane(struct device *dev, struct plane_arg *p)
if (!format_support(ovr, p->fourcc))
continue;
- if ((ovr->possible_crtcs & (1 << pipe)) &&
+ if ((ovr->possible_crtcs & crtc_mask) &&
(ovr->crtc_id == 0 || ovr->crtc_id == p->crtc_id)) {
plane_id = ovr->plane_id;
break;
}
}
- if (i == dev->resources->plane_res->count_planes) {
+ if (i == dev->resources->count_planes) {
fprintf(stderr, "no unused plane available for CRTC %u\n",
- crtc->crtc->crtc_id);
+ p->crtc_id);
return -1;
}
fprintf(stderr, "testing %dx%d@%s overlay plane %u\n",
p->w, p->h, p->format_str, plane_id);
- plane_bo = bo_create(dev->fd, p->fourcc, p->w, p->h, handles,
- pitches, offsets, secondary_fill);
- if (plane_bo == NULL)
- return -1;
-
- p->bo = plane_bo;
-
/* just use single plane format for now.. */
- if (drmModeAddFB2(dev->fd, p->w, p->h, p->fourcc,
- handles, pitches, offsets, &p->fb_id, plane_flags)) {
- fprintf(stderr, "failed to add fb: %s\n", strerror(errno));
+ if (bo_fb_create(dev->fd, p->fourcc, p->w, p->h,
+ secondary_fill, &p->bo, &p->fb_id))
return -1;
- }
crtc_w = p->w * p->scale;
crtc_h = p->h * p->scale;
@@ -1287,15 +1318,15 @@ static int set_plane(struct device *dev, struct plane_arg *p)
}
/* note src coords (last 4 args) are in Q16 format */
- if (drmModeSetPlane(dev->fd, plane_id, crtc->crtc->crtc_id, p->fb_id,
- plane_flags, crtc_x, crtc_y, crtc_w, crtc_h,
+ if (drmModeSetPlane(dev->fd, plane_id, p->crtc_id, p->fb_id,
+ 0, crtc_x, crtc_y, crtc_w, crtc_h,
0, 0, p->w << 16, p->h << 16)) {
fprintf(stderr, "failed to enable plane: %s\n",
strerror(errno));
return -1;
}
- ovr->crtc_id = crtc->crtc->crtc_id;
+ ovr->crtc_id = p->crtc_id;
return 0;
}
@@ -1317,6 +1348,41 @@ static void atomic_set_planes(struct device *dev, struct plane_arg *p,
}
}
+static void
+atomic_test_page_flip(struct device *dev, struct pipe_arg *pipe_args,
+ struct plane_arg *plane_args, unsigned int plane_count)
+{
+ int ret;
+
+ gettimeofday(&pipe_args->start, NULL);
+ pipe_args->swap_count = 0;
+
+ while (true) {
+ drmModeAtomicFree(dev->req);
+ dev->req = drmModeAtomicAlloc();
+ atomic_set_planes(dev, plane_args, plane_count, true);
+
+ ret = drmModeAtomicCommit(dev->fd, dev->req, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+ if (ret) {
+ fprintf(stderr, "Atomic Commit failed [2]\n");
+ return;
+ }
+
+ pipe_args->swap_count++;
+ if (pipe_args->swap_count == 60) {
+ struct timeval end;
+ double t;
+
+ gettimeofday(&end, NULL);
+ t = end.tv_sec + end.tv_usec * 1e-6 -
+ (pipe_args->start.tv_sec + pipe_args->start.tv_usec * 1e-6);
+ fprintf(stderr, "freq: %.02fHz\n", pipe_args->swap_count / t);
+ pipe_args->swap_count = 0;
+ pipe_args->start = end;
+ }
+ }
+}
+
static void atomic_clear_planes(struct device *dev, struct plane_arg *p, unsigned int count)
{
unsigned int i;
@@ -1372,131 +1438,269 @@ static void clear_planes(struct device *dev, struct plane_arg *p, unsigned int c
}
}
-static void atomic_set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int count)
+static int pipe_resolve_connectors(struct device *dev, struct pipe_arg *pipe)
{
+ drmModeConnector *connector;
unsigned int i;
- unsigned int j;
- int ret;
+ uint32_t id;
+ char *endp;
- for (i = 0; i < count; i++) {
- struct pipe_arg *pipe = &pipes[i];
+ for (i = 0; i < pipe->num_cons; i++) {
+ id = strtoul(pipe->cons[i], &endp, 10);
+ if (endp == pipe->cons[i]) {
+ connector = get_connector_by_name(dev, pipe->cons[i]);
+ if (!connector) {
+ fprintf(stderr, "no connector named '%s'\n",
+ pipe->cons[i]);
+ return -ENODEV;
+ }
- ret = pipe_find_crtc_and_mode(dev, pipe);
- if (ret < 0)
+ id = connector->connector_id;
+ }
+
+ pipe->con_ids[i] = id;
+ }
+
+ return 0;
+}
+
+static int pipe_attempt_connector(struct device *dev, drmModeConnector *con,
+ struct pipe_arg *pipe)
+{
+ char *con_str;
+ int i;
+
+ con_str = calloc(8, sizeof(char));
+ if (!con_str)
+ return -1;
+
+ sprintf(con_str, "%d", con->connector_id);
+ strcpy(pipe->format_str, "XR24");
+ pipe->fourcc = util_format_fourcc(pipe->format_str);
+ pipe->num_cons = 1;
+ pipe->con_ids = calloc(1, sizeof(*pipe->con_ids));
+ pipe->cons = calloc(1, sizeof(*pipe->cons));
+
+ if (!pipe->con_ids || !pipe->cons)
+ goto free_con_str;
+
+ pipe->con_ids[0] = con->connector_id;
+ pipe->cons[0] = (const char*)con_str;
+
+ pipe->crtc = pipe_find_crtc(dev, pipe);
+ if (!pipe->crtc)
+ goto free_all;
+
+ pipe->crtc_id = pipe->crtc->crtc->crtc_id;
+
+ /* Return the first mode if no preferred. */
+ pipe->mode = &con->modes[0];
+
+ for (i = 0; i < con->count_modes; i++) {
+ drmModeModeInfo *current_mode = &con->modes[i];
+
+ if (current_mode->type & DRM_MODE_TYPE_PREFERRED) {
+ pipe->mode = current_mode;
+ break;
+ }
+ }
+
+ sprintf(pipe->mode_str, "%dx%d", pipe->mode->hdisplay, pipe->mode->vdisplay);
+
+ return 0;
+
+free_all:
+ free(pipe->cons);
+ free(pipe->con_ids);
+free_con_str:
+ free(con_str);
+ return -1;
+}
+
+static int pipe_find_preferred(struct device *dev, struct pipe_arg **out_pipes)
+{
+ struct pipe_arg *pipes;
+ struct resources *res = dev->resources;
+ drmModeConnector *con = NULL;
+ int i, connected = 0, attempted = 0;
+
+ for (i = 0; i < res->count_connectors; i++) {
+ con = res->connectors[i].connector;
+ if (!con || con->connection != DRM_MODE_CONNECTED)
continue;
+ connected++;
+ }
+ if (!connected) {
+ printf("no connected connector!\n");
+ return 0;
}
- for (i = 0; i < count; i++) {
- struct pipe_arg *pipe = &pipes[i];
- uint32_t blob_id;
+ pipes = calloc(connected, sizeof(struct pipe_arg));
+ if (!pipes)
+ return 0;
- if (pipe->mode == NULL)
+ for (i = 0; i < res->count_connectors && attempted < connected; i++) {
+ con = res->connectors[i].connector;
+ if (!con || con->connection != DRM_MODE_CONNECTED)
continue;
- printf("setting mode %s-%dHz on connectors ",
- pipe->mode_str, pipe->mode->vrefresh);
- for (j = 0; j < pipe->num_cons; ++j) {
- printf("%s, ", pipe->cons[j]);
- add_property(dev, pipe->con_ids[j], "CRTC_ID", pipe->crtc->crtc->crtc_id);
+ if (pipe_attempt_connector(dev, con, &pipes[attempted]) < 0) {
+ printf("failed fetching preferred mode for connector\n");
+ continue;
}
- printf("crtc %d\n", pipe->crtc->crtc->crtc_id);
-
- drmModeCreatePropertyBlob(dev->fd, pipe->mode, sizeof(*pipe->mode), &blob_id);
- add_property(dev, pipe->crtc->crtc->crtc_id, "MODE_ID", blob_id);
- add_property(dev, pipe->crtc->crtc->crtc_id, "ACTIVE", 1);
+ attempted++;
}
+
+ *out_pipes = pipes;
+ return attempted;
}
-static void atomic_clear_mode(struct device *dev, struct pipe_arg *pipes, unsigned int count)
+static struct plane *get_primary_plane_by_crtc(struct device *dev, struct crtc *crtc)
{
unsigned int i;
- unsigned int j;
- for (i = 0; i < count; i++) {
- struct pipe_arg *pipe = &pipes[i];
-
- if (pipe->mode == NULL)
+ for (i = 0; i < dev->resources->count_planes; i++) {
+ struct plane *plane = &dev->resources->planes[i];
+ drmModePlane *ovr = plane->plane;
+ if (!ovr)
continue;
- for (j = 0; j < pipe->num_cons; ++j)
- add_property(dev, pipe->con_ids[j], "CRTC_ID",0);
+ // XXX: add is_primary_plane and (?) format checks
- add_property(dev, pipe->crtc->crtc->crtc_id, "MODE_ID", 0);
- add_property(dev, pipe->crtc->crtc->crtc_id, "ACTIVE", 0);
+ if (ovr->possible_crtcs & get_crtc_mask(dev, crtc))
+ return plane;
}
+ return NULL;
}
static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int count)
{
- uint32_t handles[4] = {0}, pitches[4] = {0}, offsets[4] = {0};
- unsigned int fb_id;
- struct bo *bo;
- unsigned int i;
- unsigned int j;
- int ret, x;
-
- dev->mode.width = 0;
- dev->mode.height = 0;
- dev->mode.fb_id = 0;
+ unsigned int i, j;
+ int ret, x = 0;
+ int preferred = count == 0;
for (i = 0; i < count; i++) {
struct pipe_arg *pipe = &pipes[i];
+ ret = pipe_resolve_connectors(dev, pipe);
+ if (ret < 0)
+ return;
+
ret = pipe_find_crtc_and_mode(dev, pipe);
if (ret < 0)
continue;
+ }
+ if (preferred) {
+ struct pipe_arg *pipe_args;
- dev->mode.width += pipe->mode->hdisplay;
- if (dev->mode.height < pipe->mode->vdisplay)
- dev->mode.height = pipe->mode->vdisplay;
+ count = pipe_find_preferred(dev, &pipe_args);
+ if (!count) {
+ fprintf(stderr, "can't find any preferred connector/mode.\n");
+ return;
+ }
+ pipes = pipe_args;
}
- bo = bo_create(dev->fd, pipes[0].fourcc, dev->mode.width,
- dev->mode.height, handles, pitches, offsets,
- primary_fill);
- if (bo == NULL)
- return;
+ if (!dev->use_atomic) {
+ for (i = 0; i < count; i++) {
+ struct pipe_arg *pipe = &pipes[i];
- dev->mode.bo = bo;
+ if (pipe->mode == NULL)
+ continue;
- ret = drmModeAddFB2(dev->fd, dev->mode.width, dev->mode.height,
- pipes[0].fourcc, handles, pitches, offsets, &fb_id, 0);
- if (ret) {
- fprintf(stderr, "failed to add fb (%ux%u): %s\n",
- dev->mode.width, dev->mode.height, strerror(errno));
- return;
- }
+ if (!preferred) {
+ dev->mode.width += pipe->mode->hdisplay;
+ if (dev->mode.height < pipe->mode->vdisplay)
+ dev->mode.height = pipe->mode->vdisplay;
+ } else {
+ /* XXX: Use a clone mode, more like atomic. We could do per
+ * connector bo/fb, so we don't have the stretched image.
+ */
+ if (dev->mode.width < pipe->mode->hdisplay)
+ dev->mode.width = pipe->mode->hdisplay;
+ if (dev->mode.height < pipe->mode->vdisplay)
+ dev->mode.height = pipe->mode->vdisplay;
+ }
+ }
- dev->mode.fb_id = fb_id;
+ if (bo_fb_create(dev->fd, pipes[0].fourcc, dev->mode.width, dev->mode.height,
+ primary_fill, &dev->mode.bo, &dev->mode.fb_id))
+ return;
+ }
- x = 0;
for (i = 0; i < count; i++) {
struct pipe_arg *pipe = &pipes[i];
+ uint32_t blob_id;
if (pipe->mode == NULL)
continue;
- printf("setting mode %s-%dHz@%s on connectors ",
- pipe->mode_str, pipe->mode->vrefresh, pipe->format_str);
- for (j = 0; j < pipe->num_cons; ++j)
+ printf("setting mode %s-%.2fHz on connectors ",
+ pipe->mode->name, mode_vrefresh(pipe->mode));
+ for (j = 0; j < pipe->num_cons; ++j) {
printf("%s, ", pipe->cons[j]);
- printf("crtc %d\n", pipe->crtc->crtc->crtc_id);
+ if (dev->use_atomic)
+ add_property(dev, pipe->con_ids[j], "CRTC_ID", pipe->crtc_id);
+ }
+ printf("crtc %d\n", pipe->crtc_id);
- ret = drmModeSetCrtc(dev->fd, pipe->crtc->crtc->crtc_id, fb_id,
- x, 0, pipe->con_ids, pipe->num_cons,
- pipe->mode);
+ if (!dev->use_atomic) {
+ ret = drmModeSetCrtc(dev->fd, pipe->crtc_id, dev->mode.fb_id,
+ x, 0, pipe->con_ids, pipe->num_cons,
+ pipe->mode);
- /* XXX: Actually check if this is needed */
- drmModeDirtyFB(dev->fd, fb_id, NULL, 0);
+ /* XXX: Actually check if this is needed */
+ drmModeDirtyFB(dev->fd, dev->mode.fb_id, NULL, 0);
- x += pipe->mode->hdisplay;
+ if (!preferred)
+ x += pipe->mode->hdisplay;
- if (ret) {
- fprintf(stderr, "failed to set mode: %s\n", strerror(errno));
- return;
+ if (ret) {
+ fprintf(stderr, "failed to set mode: %s\n", strerror(errno));
+ return;
+ }
+
+ set_gamma(dev, pipe->crtc_id, pipe->fourcc);
+ } else {
+ drmModeCreatePropertyBlob(dev->fd, pipe->mode, sizeof(*pipe->mode), &blob_id);
+ add_property(dev, pipe->crtc_id, "MODE_ID", blob_id);
+ add_property(dev, pipe->crtc_id, "ACTIVE", 1);
+
+ /* By default atomic modeset does not set a primary plane, shrug */
+ if (preferred) {
+ struct plane *plane = get_primary_plane_by_crtc(dev, pipe->crtc);
+ struct plane_arg plane_args = {
+ .plane_id = plane->plane->plane_id,
+ .crtc_id = pipe->crtc_id,
+ .w = pipe->mode->hdisplay,
+ .h = pipe->mode->vdisplay,
+ .scale = 1.0,
+ .format_str = "XR24",
+ .fourcc = util_format_fourcc(pipe->format_str),
+ };
+
+ atomic_set_planes(dev, &plane_args, 1, false);
+ }
}
+ }
+}
+
+static void atomic_clear_mode(struct device *dev, struct pipe_arg *pipes, unsigned int count)
+{
+ unsigned int i;
+ unsigned int j;
+
+ for (i = 0; i < count; i++) {
+ struct pipe_arg *pipe = &pipes[i];
- set_gamma(dev, pipe->crtc->crtc->crtc_id, pipe->fourcc);
+ if (pipe->mode == NULL)
+ continue;
+
+ for (j = 0; j < pipe->num_cons; ++j)
+ add_property(dev, pipe->con_ids[j], "CRTC_ID",0);
+
+ add_property(dev, pipe->crtc_id, "MODE_ID", 0);
+ add_property(dev, pipe->crtc_id, "ACTIVE", 0);
}
}
@@ -1542,7 +1746,7 @@ static void set_cursors(struct device *dev, struct pipe_arg *pipes, unsigned int
for (i = 0; i < count; i++) {
struct pipe_arg *pipe = &pipes[i];
ret = cursor_init(dev->fd, handles[0],
- pipe->crtc->crtc->crtc_id,
+ pipe->crtc_id,
pipe->mode->hdisplay, pipe->mode->vdisplay,
cw, ch);
if (ret) {
@@ -1565,34 +1769,23 @@ static void clear_cursors(struct device *dev)
static void test_page_flip(struct device *dev, struct pipe_arg *pipes, unsigned int count)
{
- uint32_t handles[4] = {0}, pitches[4] = {0}, offsets[4] = {0};
unsigned int other_fb_id;
struct bo *other_bo;
drmEventContext evctx;
unsigned int i;
int ret;
- other_bo = bo_create(dev->fd, pipes[0].fourcc, dev->mode.width,
- dev->mode.height, handles, pitches, offsets,
- UTIL_PATTERN_PLAIN);
- if (other_bo == NULL)
+ if (bo_fb_create(dev->fd, pipes[0].fourcc, dev->mode.width, dev->mode.height,
+ UTIL_PATTERN_PLAIN, &other_bo, &other_fb_id))
return;
- ret = drmModeAddFB2(dev->fd, dev->mode.width, dev->mode.height,
- pipes[0].fourcc, handles, pitches, offsets,
- &other_fb_id, 0);
- if (ret) {
- fprintf(stderr, "failed to add fb: %s\n", strerror(errno));
- goto err;
- }
-
for (i = 0; i < count; i++) {
struct pipe_arg *pipe = &pipes[i];
if (pipe->mode == NULL)
continue;
- ret = drmModePageFlip(dev->fd, pipe->crtc->crtc->crtc_id,
+ ret = drmModePageFlip(dev->fd, pipe->crtc_id,
other_fb_id, DRM_MODE_PAGE_FLIP_EVENT,
pipe);
if (ret) {
@@ -1650,7 +1843,6 @@ static void test_page_flip(struct device *dev, struct pipe_arg *pipes, unsigned
err_rmfb:
drmModeRmFB(dev->fd, other_fb_id);
-err:
bo_destroy(other_bo);
}
@@ -1695,6 +1887,8 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg)
return -1;
/* Parse the remaining parameters. */
+ if (!endp)
+ return -1;
if (*endp == '@') {
arg = endp + 1;
pipe->crtc_id = strtoul(arg, &endp, 10);
@@ -1713,7 +1907,7 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg)
pipe->mode_str[len] = '\0';
if (*p == '-') {
- pipe->vrefresh = strtoul(p + 1, &endp, 10);
+ pipe->vrefresh = strtof(p + 1, &endp);
p = endp;
}
@@ -1811,7 +2005,7 @@ static void parse_fill_patterns(char *arg)
static void usage(char *name)
{
- fprintf(stderr, "usage: %s [-acDdefMPpsCvw]\n", name);
+ fprintf(stderr, "usage: %s [-acDdefMPpsCvrw]\n", name);
fprintf(stderr, "\n Query options:\n\n");
fprintf(stderr, "\t-c\tlist connectors\n");
@@ -1821,9 +2015,10 @@ static void usage(char *name)
fprintf(stderr, "\n Test options:\n\n");
fprintf(stderr, "\t-P <plane_id>@<crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n");
- fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[-<vrefresh>][@<format>]\tset a mode\n");
+ fprintf(stderr, "\t-s <connector_id>[,<connector_id>][@<crtc_id>]:[#<mode index>]<mode>[-<vrefresh>][@<format>]\tset a mode\n");
fprintf(stderr, "\t-C\ttest hw cursor\n");
fprintf(stderr, "\t-v\ttest vsynced page flipping\n");
+ fprintf(stderr, "\t-r\tset the preferred mode for all connectors\n");
fprintf(stderr, "\t-w <obj_id>:<prop_name>:<value>\tset property\n");
fprintf(stderr, "\t-a \tuse atomic API\n");
fprintf(stderr, "\t-F pattern1,pattern2\tspecify fill patterns\n");
@@ -1837,60 +2032,7 @@ static void usage(char *name)
exit(0);
}
-static int page_flipping_supported(void)
-{
- /*FIXME: generic ioctl needed? */
- return 1;
-#if 0
- int ret, value;
- struct drm_i915_getparam gp;
-
- gp.param = I915_PARAM_HAS_PAGEFLIPPING;
- gp.value = &value;
-
- ret = drmCommandWriteRead(fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
- if (ret) {
- fprintf(stderr, "drm_i915_getparam: %m\n");
- return 0;
- }
-
- return *gp.value;
-#endif
-}
-
-static int cursor_supported(void)
-{
- /*FIXME: generic ioctl needed? */
- return 1;
-}
-
-static int pipe_resolve_connectors(struct device *dev, struct pipe_arg *pipe)
-{
- drmModeConnector *connector;
- unsigned int i;
- uint32_t id;
- char *endp;
-
- for (i = 0; i < pipe->num_cons; i++) {
- id = strtoul(pipe->cons[i], &endp, 10);
- if (endp == pipe->cons[i]) {
- connector = get_connector_by_name(dev, pipe->cons[i]);
- if (!connector) {
- fprintf(stderr, "no connector named '%s'\n",
- pipe->cons[i]);
- return -ENODEV;
- }
-
- id = connector->connector_id;
- }
-
- pipe->con_ids[i] = id;
- }
-
- return 0;
-}
-
-static char optstr[] = "acdD:efF:M:P:ps:Cvw:";
+static char optstr[] = "acdD:efF:M:P:ps:Cvrw:";
int main(int argc, char **argv)
{
@@ -1901,6 +2043,7 @@ int main(int argc, char **argv)
int drop_master = 0;
int test_vsync = 0;
int test_cursor = 0;
+ int set_preferred = 0;
int use_atomic = 0;
char *device = NULL;
char *module = NULL;
@@ -1922,12 +2065,15 @@ int main(int argc, char **argv)
switch (c) {
case 'a':
use_atomic = 1;
+ /* Preserve the default behaviour of dumping all information. */
+ args--;
break;
case 'c':
connectors = 1;
break;
case 'D':
device = optarg;
+ /* Preserve the default behaviour of dumping all information. */
args--;
break;
case 'd':
@@ -1985,6 +2131,9 @@ int main(int argc, char **argv)
case 'v':
test_vsync = 1;
break;
+ case 'r':
+ set_preferred = 1;
+ break;
case 'w':
prop_args = realloc(prop_args,
(prop_count + 1) * sizeof *prop_args);
@@ -2005,51 +2154,45 @@ int main(int argc, char **argv)
}
}
- if (!args || (args == 1 && use_atomic))
+ /* Dump all the details when no* arguments are provided. */
+ if (!args)
encoders = connectors = crtcs = planes = framebuffers = 1;
- dev.fd = util_open(device, module);
- if (dev.fd < 0)
- return -1;
-
- ret = drmSetClientCap(dev.fd, DRM_CLIENT_CAP_ATOMIC, 1);
- if (ret && use_atomic) {
- fprintf(stderr, "no atomic modesetting support: %s\n", strerror(errno));
- drmClose(dev.fd);
+ if (test_vsync && !count) {
+ fprintf(stderr, "page flipping requires at least one -s option.\n");
return -1;
}
-
- dev.use_atomic = use_atomic;
-
- if (test_vsync && !page_flipping_supported()) {
- fprintf(stderr, "page flipping not supported by drm.\n");
+ if (set_preferred && count) {
+ fprintf(stderr, "cannot use -r (preferred) when -s (mode) is set\n");
return -1;
}
- if (test_vsync && !count) {
- fprintf(stderr, "page flipping requires at least one -s option.\n");
+ if (set_preferred && plane_count) {
+ fprintf(stderr, "cannot use -r (preferred) when -P (plane) is set\n");
return -1;
}
- if (test_cursor && !cursor_supported()) {
- fprintf(stderr, "hw cursor not supported by drm.\n");
+ dev.fd = util_open(device, module);
+ if (dev.fd < 0)
return -1;
+
+ if (use_atomic) {
+ ret = drmSetClientCap(dev.fd, DRM_CLIENT_CAP_ATOMIC, 1);
+ if (ret) {
+ fprintf(stderr, "no atomic modesetting support: %s\n", strerror(errno));
+ drmClose(dev.fd);
+ return -1;
+ }
}
+ dev.use_atomic = use_atomic;
+
dev.resources = get_resources(&dev);
if (!dev.resources) {
drmClose(dev.fd);
return 1;
}
- for (i = 0; i < count; i++) {
- if (pipe_resolve_connectors(&dev, &pipe_args[i]) < 0) {
- free_resources(dev.resources);
- drmClose(dev.fd);
- return 1;
- }
- }
-
#define dump_resource(dev, res) if (res) dump_##res(dev)
dump_resource(&dev, encoders);
@@ -2064,7 +2207,7 @@ int main(int argc, char **argv)
if (dev.use_atomic) {
dev.req = drmModeAtomicAlloc();
- if (count && plane_count) {
+ if (set_preferred || (count && plane_count)) {
uint64_t cap = 0;
ret = drmGetCap(dev.fd, DRM_CAP_DUMB_BUFFER, &cap);
@@ -2073,8 +2216,11 @@ int main(int argc, char **argv)
return 1;
}
- atomic_set_mode(&dev, pipe_args, count);
- atomic_set_planes(&dev, plane_args, plane_count, false);
+ if (set_preferred || count)
+ set_mode(&dev, pipe_args, count);
+
+ if (plane_count)
+ atomic_set_planes(&dev, plane_args, plane_count, false);
ret = drmModeAtomicCommit(dev.fd, dev.req, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
if (ret) {
@@ -2082,33 +2228,8 @@ int main(int argc, char **argv)
return 1;
}
- gettimeofday(&pipe_args->start, NULL);
- pipe_args->swap_count = 0;
-
- while (test_vsync) {
- drmModeAtomicFree(dev.req);
- dev.req = drmModeAtomicAlloc();
- atomic_set_planes(&dev, plane_args, plane_count, true);
-
- ret = drmModeAtomicCommit(dev.fd, dev.req, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
- if (ret) {
- fprintf(stderr, "Atomic Commit failed [2]\n");
- return 1;
- }
-
- pipe_args->swap_count++;
- if (pipe_args->swap_count == 60) {
- struct timeval end;
- double t;
-
- gettimeofday(&end, NULL);
- t = end.tv_sec + end.tv_usec * 1e-6 -
- (pipe_args->start.tv_sec + pipe_args->start.tv_usec * 1e-6);
- fprintf(stderr, "freq: %.02fHz\n", pipe_args->swap_count / t);
- pipe_args->swap_count = 0;
- pipe_args->start = end;
- }
- }
+ if (test_vsync)
+ atomic_test_page_flip(&dev, pipe_args, plane_args, plane_count);
if (drop_master)
drmDropMaster(dev.fd);
@@ -2118,20 +2239,24 @@ int main(int argc, char **argv)
drmModeAtomicFree(dev.req);
dev.req = drmModeAtomicAlloc();
- atomic_clear_mode(&dev, pipe_args, count);
- atomic_clear_planes(&dev, plane_args, plane_count);
+ /* XXX: properly teardown the preferred mode/plane state */
+ if (plane_count)
+ atomic_clear_planes(&dev, plane_args, plane_count);
+
+ if (count)
+ atomic_clear_mode(&dev, pipe_args, count);
+
ret = drmModeAtomicCommit(dev.fd, dev.req, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
- if (ret) {
+ if (ret)
fprintf(stderr, "Atomic Commit failed\n");
- return 1;
- }
- atomic_clear_FB(&dev, plane_args, plane_count);
+ if (plane_count)
+ atomic_clear_FB(&dev, plane_args, plane_count);
}
drmModeAtomicFree(dev.req);
} else {
- if (count || plane_count) {
+ if (set_preferred || count || plane_count) {
uint64_t cap = 0;
ret = drmGetCap(dev.fd, DRM_CAP_DUMB_BUFFER, &cap);
@@ -2140,7 +2265,7 @@ int main(int argc, char **argv)
return 1;
}
- if (count)
+ if (set_preferred || count)
set_mode(&dev, pipe_args, count);
if (plane_count)
@@ -2163,12 +2288,13 @@ int main(int argc, char **argv)
if (plane_count)
clear_planes(&dev, plane_args, plane_count);
- if (count)
+ if (set_preferred || count)
clear_mode(&dev);
}
}
free_resources(dev.resources);
+ drmClose(dev.fd);
return 0;
}
diff --git a/tests/nouveau/Makefile.am b/tests/nouveau/Makefile.am
deleted file mode 100644
index 554f43ec..00000000
--- a/tests/nouveau/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-AM_CFLAGS = \
- -pthread \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/nouveau \
- -I$(top_srcdir)
-
-LDADD = \
- ../../nouveau/libdrm_nouveau.la \
- ../../libdrm.la \
- -ldl
-
-TESTS = threaded
-
-check_PROGRAMS = $(TESTS)
-
diff --git a/tests/nouveau/threaded.c b/tests/nouveau/threaded.c
index 3669bcd3..ddbac74e 100644
--- a/tests/nouveau/threaded.c
+++ b/tests/nouveau/threaded.c
@@ -36,7 +36,11 @@ static int failed;
static int import_fd;
+#if defined(__GLIBC__) || defined(__FreeBSD__)
int ioctl(int fd, unsigned long request, ...)
+#else
+int ioctl(int fd, int request, ...)
+#endif
{
va_list va;
int ret;
diff --git a/tests/proptest/Makefile.am b/tests/proptest/Makefile.am
deleted file mode 100644
index 33b8705b..00000000
--- a/tests/proptest/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS)\
- -fvisibility=hidden \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/tests \
- -I$(top_srcdir)
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS = \
- proptest
-else
-noinst_PROGRAMS = \
- proptest
-endif
-
-proptest_SOURCES = $(PROPTEST_FILES)
-
-proptest_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/tests/util/libutil.la
diff --git a/tests/radeon/Makefile.am b/tests/radeon/Makefile.am
deleted file mode 100644
index 3d173e31..00000000
--- a/tests/radeon/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-AM_CFLAGS = \
- $(WARN_CFLAGS)\
- -fvisibility=hidden \
- -I $(top_srcdir)/include/drm \
- -I $(top_srcdir)
-
-LDADD = $(top_builddir)/libdrm.la
-
-noinst_PROGRAMS = \
- radeon_ttm
-
-radeon_ttm_SOURCES = \
- rbo.c \
- rbo.h \
- radeon_ttm.c
diff --git a/tests/random.c b/tests/random.c
deleted file mode 100644
index 13d4c805..00000000
--- a/tests/random.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* xf86drmRandom.c -- "Minimal Standard" PRNG Implementation
- * Created: Mon Apr 19 08:28:13 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * 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.
- *
- * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
- *
- * DESCRIPTION
- *
- * This file contains a simple, straightforward implementation of the Park
- * & Miller "Minimal Standard" PRNG [PM88, PMS93], which is a Lehmer
- * multiplicative linear congruential generator (MLCG) with a period of
- * 2^31-1.
- *
- * This implementation is intended to provide a reliable, portable PRNG
- * that is suitable for testing a hash table implementation and for
- * implementing skip lists.
- *
- * FUTURE ENHANCEMENTS
- *
- * If initial seeds are not selected randomly, two instances of the PRNG
- * can be correlated. [Knuth81, pp. 32-33] describes a shuffling technique
- * that can eliminate this problem.
- *
- * If PRNGs are used for simulation, the period of the current
- * implementation may be too short. [LE88] discusses methods of combining
- * MLCGs to produce much longer periods, and suggests some alternative
- * values for A and M. [LE90 and Sch92] also provide information on
- * long-period PRNGs.
- *
- * REFERENCES
- *
- * [Knuth81] Donald E. Knuth. The Art of Computer Programming. Volume 2:
- * Seminumerical Algorithms. Reading, Massachusetts: Addison-Wesley, 1981.
- *
- * [LE88] Pierre L'Ecuyer. "Efficient and Portable Combined Random Number
- * Generators". CACM 31(6), June 1988, pp. 742-774.
- *
- * [LE90] Pierre L'Ecuyer. "Random Numbers for Simulation". CACM 33(10,
- * October 1990, pp. 85-97.
- *
- * [PM88] Stephen K. Park and Keith W. Miller. "Random Number Generators:
- * Good Ones are Hard to Find". CACM 31(10), October 1988, pp. 1192-1201.
- *
- * [Sch92] Bruce Schneier. "Pseudo-Ransom Sequence Generator for 32-Bit
- * CPUs". Dr. Dobb's Journal 17(2), February 1992, pp. 34, 37-38, 40.
- *
- * [PMS93] Stephen K. Park, Keith W. Miller, and Paul K. Stockmeyer. In
- * "Technical Correspondence: Remarks on Choosing and Implementing Random
- * Number Generators". CACM 36(7), July 1993, pp. 105-110.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "xf86drm.h"
-#include "xf86drmRandom.h"
-
-static void check_period(unsigned long seed)
-{
- unsigned long count = 0;
- unsigned long initial;
- void *state;
-
- state = drmRandomCreate(seed);
- initial = drmRandom(state);
- ++count;
- while (initial != drmRandom(state)) {
- if (!++count) break;
- }
- printf("With seed of %10lu, period = %10lu (0x%08lx)\n",
- seed, count, count);
- drmRandomDestroy(state);
-}
-
-int main(void)
-{
- RandomState *state;
- int i;
- int ret;
- unsigned long rand;
-
- state = drmRandomCreate(1);
- for (i = 0; i < 10000; i++) {
- rand = drmRandom(state);
- }
- ret = rand != state->check;
- printf("After 10000 iterations: %lu (%lu expected): %s\n",
- rand, state->check,
- ret ? "*INCORRECT*" : "CORRECT");
- drmRandomDestroy(state);
-
- printf("Checking periods...\n");
- check_period(1);
- check_period(2);
- check_period(31415926);
-
- return ret;
-}
diff --git a/tests/tegra/Makefile.am b/tests/tegra/Makefile.am
deleted file mode 100644
index b462a30c..00000000
--- a/tests/tegra/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-AM_CPPFLAGS = \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/tegra \
- -I$(top_srcdir)
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden
-
-LDADD = \
- ../../tegra/libdrm_tegra.la \
- ../../libdrm.la
-
-noinst_PROGRAMS = \
- openclose
diff --git a/tests/util/Makefile.am b/tests/util/Makefile.am
deleted file mode 100644
index f8e0b171..00000000
--- a/tests/util/Makefile.am
+++ /dev/null
@@ -1,13 +0,0 @@
-include Makefile.sources
-
-noinst_LTLIBRARIES = \
- libutil.la
-
-libutil_la_CPPFLAGS = \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)
-
-libutil_la_CFLAGS = \
- $(CAIRO_CFLAGS)
-
-libutil_la_SOURCES = $(UTIL_FILES)
diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index 42a0e5c7..bf1797d4 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -643,7 +643,7 @@ void util_smpte_c8_gamma(unsigned size, struct drm_color_lut *lut)
printf("Error: gamma too small: %d < %d\n", size, 7 + 7 + 8);
return;
}
- memset(lut, size * sizeof(struct drm_color_lut), 0);
+ memset(lut, 0, size * sizeof(struct drm_color_lut));
#define FILL_COLOR(idx, r, g, b) \
lut[idx].red = (r) << 8; \
diff --git a/tests/vbltest/Makefile.am b/tests/vbltest/Makefile.am
deleted file mode 100644
index b6cd7a4d..00000000
--- a/tests/vbltest/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-AM_CFLAGS = \
- $(WARN_CFLAGS)\
- -fvisibility=hidden \
- -I$(top_srcdir)/include/drm \
- -I$(top_srcdir)/tests \
- -I$(top_srcdir)
-
-if HAVE_INSTALL_TESTS
-bin_PROGRAMS = \
- vbltest
-else
-noinst_PROGRAMS = \
- vbltest
-endif
-
-vbltest_SOURCES = \
- vbltest.c
-vbltest_LDADD = \
- $(top_builddir)/libdrm.la \
- $(top_builddir)/tests/util/libutil.la
diff --git a/tests/vbltest/vbltest.c b/tests/vbltest/vbltest.c
index 48708d20..1c2b519e 100644
--- a/tests/vbltest/vbltest.c
+++ b/tests/vbltest/vbltest.c
@@ -33,7 +33,7 @@
#include <errno.h>
#include <poll.h>
#include <sys/time.h>
-#ifdef HAVE_SYS_SELECT_H
+#if HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
diff --git a/vc4/Makefile.am b/vc4/Makefile.am
deleted file mode 100644
index 5f82d04e..00000000
--- a/vc4/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright © 2016 Broadcom
-#
-# 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.
-
-include Makefile.sources
-
-AM_CFLAGS = \
- $(WARN_CFLAGS) \
- -fvisibility=hidden \
- -I$(top_srcdir) \
- $(PTHREADSTUBS_CFLAGS) \
- $(VALGRIND_CFLAGS) \
- -I$(top_srcdir)/include/drm
-
-libdrm_vc4includedir = ${includedir}/libdrm
-libdrm_vc4include_HEADERS = $(LIBDRM_VC4_H_FILES)
-
-pkgconfig_DATA = libdrm_vc4.pc
diff --git a/xf86atomic.h b/xf86atomic.h
index 2d733bd5..efa47a77 100644
--- a/xf86atomic.h
+++ b/xf86atomic.h
@@ -54,6 +54,7 @@ typedef struct {
#endif
#if HAVE_LIB_ATOMIC_OPS
+#define AO_REQUIRE_CAS
#include <atomic_ops.h>
#define HAS_ATOMIC_OPS 1
diff --git a/xf86drm.c b/xf86drm.c
index 155c5a8a..b49d42f7 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -57,8 +57,16 @@
#ifdef MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
#endif
+#if HAVE_SYS_SYSCTL_H
+#include <sys/sysctl.h>
+#endif
#include <math.h>
+#if defined(__FreeBSD__)
+#include <sys/param.h>
+#include <sys/pciio.h>
+#endif
+
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
/* Not all systems have MAP_FAILED defined */
@@ -71,17 +79,7 @@
#include "util_math.h"
-#ifdef __OpenBSD__
-#define DRM_PRIMARY_MINOR_NAME "drm"
-#define DRM_CONTROL_MINOR_NAME "drmC"
-#define DRM_RENDER_MINOR_NAME "drmR"
-#else
-#define DRM_PRIMARY_MINOR_NAME "card"
-#define DRM_CONTROL_MINOR_NAME "controlD"
-#define DRM_RENDER_MINOR_NAME "renderD"
-#endif
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+#ifdef __DragonFly__
#define DRM_MAJOR 145
#endif
@@ -123,6 +121,9 @@ struct drm_pciinfo {
static drmServerInfoPtr drm_server_info;
+static bool drmNodeIsDRM(int maj, int min);
+static char *drmGetMinorNameForFD(int fd, int type);
+
drm_public void drmSetServerInfo(drmServerInfoPtr info)
{
drm_server_info = info;
@@ -310,6 +311,19 @@ static int chown_check_return(const char *path, uid_t owner, gid_t group)
}
#endif
+static const char *drmGetDeviceName(int type)
+{
+ switch (type) {
+ case DRM_NODE_PRIMARY:
+ return DRM_DEV_NAME;
+ case DRM_NODE_CONTROL:
+ return DRM_CONTROL_DEV_NAME;
+ case DRM_NODE_RENDER:
+ return DRM_RENDER_DEV_NAME;
+ }
+ return NULL;
+}
+
/**
* Open the DRM device, creating it if necessary.
*
@@ -326,8 +340,8 @@ static int chown_check_return(const char *path, uid_t owner, gid_t group)
static int drmOpenDevice(dev_t dev, int minor, int type)
{
stat_t st;
- const char *dev_name;
- char buf[64];
+ const char *dev_name = drmGetDeviceName(type);
+ char buf[DRM_NODE_NAME_MAX];
int fd;
mode_t devmode = DRM_DEV_MODE, serv_mode;
gid_t serv_group;
@@ -337,19 +351,8 @@ static int drmOpenDevice(dev_t dev, int minor, int type)
gid_t group = DRM_DEV_GID;
#endif
- switch (type) {
- case DRM_NODE_PRIMARY:
- dev_name = DRM_DEV_NAME;
- break;
- case DRM_NODE_CONTROL:
- dev_name = DRM_CONTROL_DEV_NAME;
- break;
- case DRM_NODE_RENDER:
- dev_name = DRM_RENDER_DEV_NAME;
- break;
- default:
+ if (!dev_name)
return -EINVAL;
- };
sprintf(buf, dev_name, DRM_DIR_NAME, minor);
drmMsg("drmOpenDevice: node name is %s\n", buf);
@@ -455,25 +458,14 @@ wait_for_udev:
static int drmOpenMinor(int minor, int create, int type)
{
int fd;
- char buf[64];
- const char *dev_name;
+ char buf[DRM_NODE_NAME_MAX];
+ const char *dev_name = drmGetDeviceName(type);
if (create)
return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type);
- switch (type) {
- case DRM_NODE_PRIMARY:
- dev_name = DRM_DEV_NAME;
- break;
- case DRM_NODE_CONTROL:
- dev_name = DRM_CONTROL_DEV_NAME;
- break;
- case DRM_NODE_RENDER:
- dev_name = DRM_RENDER_DEV_NAME;
- break;
- default:
+ if (!dev_name)
return -EINVAL;
- };
sprintf(buf, dev_name, DRM_DIR_NAME, minor);
if ((fd = open(buf, O_RDWR | O_CLOEXEC, 0)) >= 0)
@@ -530,8 +522,28 @@ static int drmGetMinorBase(int type)
};
}
-static int drmGetMinorType(int minor)
+static int drmGetMinorType(int major, int minor)
{
+#ifdef __FreeBSD__
+ char name[SPECNAMELEN];
+ int id;
+
+ if (!devname_r(makedev(major, minor), S_IFCHR, name, sizeof(name)))
+ return -1;
+
+ if (sscanf(name, "drm/%d", &id) != 1) {
+ // If not in /dev/drm/ we have the type in the name
+ if (sscanf(name, "dri/card%d\n", &id) >= 1)
+ return DRM_NODE_PRIMARY;
+ else if (sscanf(name, "dri/control%d\n", &id) >= 1)
+ return DRM_NODE_CONTROL;
+ else if (sscanf(name, "dri/renderD%d\n", &id) >= 1)
+ return DRM_NODE_RENDER;
+ return -1;
+ }
+
+ minor = id;
+#endif
int type = minor >> 6;
if (minor < 0)
@@ -2763,6 +2775,19 @@ drm_public int drmIsMaster(int fd)
drm_public char *drmGetDeviceNameFromFd(int fd)
{
+#ifdef __FreeBSD__
+ struct stat sbuf;
+ int maj, min;
+ int nodetype;
+
+ if (fstat(fd, &sbuf))
+ return NULL;
+
+ maj = major(sbuf.st_rdev);
+ min = minor(sbuf.st_rdev);
+ nodetype = drmGetMinorType(maj, min);
+ return drmGetMinorNameForFD(fd, nodetype);
+#else
char name[128];
struct stat sbuf;
dev_t d;
@@ -2785,6 +2810,7 @@ drm_public char *drmGetDeviceNameFromFd(int fd)
return NULL;
return strdup(name);
+#endif
}
static bool drmNodeIsDRM(int maj, int min)
@@ -2796,6 +2822,16 @@ static bool drmNodeIsDRM(int maj, int min)
snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device/drm",
maj, min);
return stat(path, &sbuf) == 0;
+#elif __FreeBSD__
+ char name[SPECNAMELEN];
+
+ if (!devname_r(makedev(maj, min), S_IFCHR, name, sizeof(name)))
+ return 0;
+ /* Handle drm/ and dri/ as both are present in different FreeBSD version
+ * FreeBSD on amd64/i386/powerpc external kernel modules create node in
+ * in /dev/drm/ and links in /dev/dri while a WIP in kernel driver creates
+ * only device nodes in /dev/dri/ */
+ return (!strncmp(name, "drm/", 4) || !strncmp(name, "dri/", 4));
#else
return maj == DRM_MAJOR;
#endif
@@ -2817,7 +2853,7 @@ drm_public int drmGetNodeTypeFromFd(int fd)
return -1;
}
- type = drmGetMinorType(min);
+ type = drmGetMinorType(maj, min);
if (type == -1)
errno = ENODEV;
return type;
@@ -2899,12 +2935,55 @@ static char *drmGetMinorNameForFD(int fd, int type)
closedir(sysdir);
return NULL;
+#elif __FreeBSD__
+ struct stat sbuf;
+ char dname[SPECNAMELEN];
+ const char *mname;
+ char name[SPECNAMELEN];
+ int id, maj, min, nodetype, i;
+
+ if (fstat(fd, &sbuf))
+ return NULL;
+
+ maj = major(sbuf.st_rdev);
+ min = minor(sbuf.st_rdev);
+
+ if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
+ return NULL;
+
+ if (!devname_r(sbuf.st_rdev, S_IFCHR, dname, sizeof(dname)))
+ return NULL;
+
+ /* Handle both /dev/drm and /dev/dri
+ * FreeBSD on amd64/i386/powerpc external kernel modules create node in
+ * in /dev/drm/ and links in /dev/dri while a WIP in kernel driver creates
+ * only device nodes in /dev/dri/ */
+
+ /* Get the node type represented by fd so we can deduce the target name */
+ nodetype = drmGetMinorType(maj, min);
+ if (nodetype == -1)
+ return (NULL);
+ mname = drmGetMinorName(type);
+
+ for (i = 0; i < SPECNAMELEN; i++) {
+ if (isalpha(dname[i]) == 0 && dname[i] != '/')
+ break;
+ }
+ if (dname[i] == '\0')
+ return (NULL);
+
+ id = (int)strtol(&dname[i], NULL, 10);
+ id -= drmGetMinorBase(nodetype);
+ snprintf(name, sizeof(name), DRM_DIR_NAME "/%s%d", mname,
+ id + drmGetMinorBase(type));
+
+ return strdup(name);
#else
struct stat sbuf;
char buf[PATH_MAX + 1];
- const char *dev_name;
+ const char *dev_name = drmGetDeviceName(type);
unsigned int maj, min;
- int n, base;
+ int n;
if (fstat(fd, &sbuf))
return NULL;
@@ -2915,25 +2994,10 @@ static char *drmGetMinorNameForFD(int fd, int type)
if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
return NULL;
- switch (type) {
- case DRM_NODE_PRIMARY:
- dev_name = DRM_DEV_NAME;
- break;
- case DRM_NODE_CONTROL:
- dev_name = DRM_CONTROL_DEV_NAME;
- break;
- case DRM_NODE_RENDER:
- dev_name = DRM_RENDER_DEV_NAME;
- break;
- default:
- return NULL;
- };
-
- base = drmGetMinorBase(type);
- if (base < 0)
+ if (!dev_name)
return NULL;
- n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min - base);
+ n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min);
if (n == -1 || n >= sizeof(buf))
return NULL;
@@ -3043,17 +3107,20 @@ static int drmParseSubsystemType(int maj, int min)
int subsystem_type;
snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min);
- if (!realpath(path, real_path))
- return -errno;
- snprintf(path, sizeof(path), "%s", real_path);
subsystem_type = get_subsystem_type(path);
+ /* Try to get the parent (underlying) device type */
if (subsystem_type == DRM_BUS_VIRTIO) {
+ /* Assume virtio-pci on error */
+ if (!realpath(path, real_path))
+ return DRM_BUS_VIRTIO;
strncat(path, "/..", PATH_MAX);
subsystem_type = get_subsystem_type(path);
- }
+ if (subsystem_type < 0)
+ return DRM_BUS_VIRTIO;
+ }
return subsystem_type;
-#elif defined(__OpenBSD__) || defined(__DragonFly__)
+#elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD__)
return DRM_BUS_PCI;
#else
#warning "Missing implementation of drmParseSubsystemType"
@@ -3061,6 +3128,7 @@ static int drmParseSubsystemType(int maj, int min)
#endif
}
+#ifdef __linux__
static void
get_pci_path(int maj, int min, char *pci_path)
{
@@ -3076,6 +3144,67 @@ get_pci_path(int maj, int min, char *pci_path)
if (term && strncmp(term, "/virtio", 7) == 0)
*term = 0;
}
+#endif
+
+#ifdef __FreeBSD__
+static int get_sysctl_pci_bus_info(int maj, int min, drmPciBusInfoPtr info)
+{
+ char dname[SPECNAMELEN];
+ char sysctl_name[16];
+ char sysctl_val[256];
+ size_t sysctl_len;
+ int id, type, nelem;
+ unsigned int rdev, majmin, domain, bus, dev, func;
+
+ rdev = makedev(maj, min);
+ if (!devname_r(rdev, S_IFCHR, dname, sizeof(dname)))
+ return -EINVAL;
+
+ if (sscanf(dname, "drm/%d\n", &id) != 1)
+ return -EINVAL;
+ type = drmGetMinorType(maj, min);
+ if (type == -1)
+ return -EINVAL;
+
+ /* BUG: This above section is iffy, since it mandates that a driver will
+ * create both card and render node.
+ * If it does not, the next DRM device will create card#X and
+ * renderD#(128+X)-1.
+ * This is a possibility in FreeBSD but for now there is no good way for
+ * obtaining the info.
+ */
+ switch (type) {
+ case DRM_NODE_PRIMARY:
+ break;
+ case DRM_NODE_CONTROL:
+ id -= 64;
+ break;
+ case DRM_NODE_RENDER:
+ id -= 128;
+ break;
+ }
+ if (id < 0)
+ return -EINVAL;
+
+ if (snprintf(sysctl_name, sizeof(sysctl_name), "hw.dri.%d.busid", id) <= 0)
+ return -EINVAL;
+ sysctl_len = sizeof(sysctl_val);
+ if (sysctlbyname(sysctl_name, sysctl_val, &sysctl_len, NULL, 0))
+ return -EINVAL;
+
+ #define bus_fmt "pci:%04x:%02x:%02x.%u"
+
+ nelem = sscanf(sysctl_val, bus_fmt, &domain, &bus, &dev, &func);
+ if (nelem != 4)
+ return -EINVAL;
+ info->domain = domain;
+ info->bus = bus;
+ info->dev = dev;
+ info->func = func;
+
+ return 0;
+}
+#endif
static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
{
@@ -3106,7 +3235,7 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
struct drm_pciinfo pinfo;
int fd, type;
- type = drmGetMinorType(min);
+ type = drmGetMinorType(maj, min);
if (type == -1)
return -ENODEV;
@@ -3126,6 +3255,8 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
info->func = pinfo.func;
return 0;
+#elif __FreeBSD__
+ return get_sysctl_pci_bus_info(maj, min, info);
#else
#warning "Missing implementation of drmParsePciBusInfo"
return -EINVAL;
@@ -3162,10 +3293,6 @@ drm_public int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b)
static int drmGetNodeType(const char *name)
{
- if (strncmp(name, DRM_PRIMARY_MINOR_NAME,
- sizeof(DRM_PRIMARY_MINOR_NAME) - 1) == 0)
- return DRM_NODE_PRIMARY;
-
if (strncmp(name, DRM_CONTROL_MINOR_NAME,
sizeof(DRM_CONTROL_MINOR_NAME ) - 1) == 0)
return DRM_NODE_CONTROL;
@@ -3174,6 +3301,10 @@ static int drmGetNodeType(const char *name)
sizeof(DRM_RENDER_MINOR_NAME) - 1) == 0)
return DRM_NODE_RENDER;
+ if (strncmp(name, DRM_PRIMARY_MINOR_NAME,
+ sizeof(DRM_PRIMARY_MINOR_NAME) - 1) == 0)
+ return DRM_NODE_PRIMARY;
+
return -EINVAL;
}
@@ -3272,7 +3403,7 @@ static int drmParsePciDeviceInfo(int maj, int min,
struct drm_pciinfo pinfo;
int fd, type;
- type = drmGetMinorType(min);
+ type = drmGetMinorType(maj, min);
if (type == -1)
return -ENODEV;
@@ -3293,6 +3424,48 @@ static int drmParsePciDeviceInfo(int maj, int min,
device->subdevice_id = pinfo.subdevice_id;
return 0;
+#elif __FreeBSD__
+ drmPciBusInfo info;
+ struct pci_conf_io pc;
+ struct pci_match_conf patterns[1];
+ struct pci_conf results[1];
+ int fd, error;
+
+ if (get_sysctl_pci_bus_info(maj, min, &info) != 0)
+ return -EINVAL;
+
+ fd = open("/dev/pci", O_RDONLY, 0);
+ if (fd < 0)
+ return -errno;
+
+ bzero(&patterns, sizeof(patterns));
+ patterns[0].pc_sel.pc_domain = info.domain;
+ patterns[0].pc_sel.pc_bus = info.bus;
+ patterns[0].pc_sel.pc_dev = info.dev;
+ patterns[0].pc_sel.pc_func = info.func;
+ patterns[0].flags = PCI_GETCONF_MATCH_DOMAIN | PCI_GETCONF_MATCH_BUS
+ | PCI_GETCONF_MATCH_DEV | PCI_GETCONF_MATCH_FUNC;
+ bzero(&pc, sizeof(struct pci_conf_io));
+ pc.num_patterns = 1;
+ pc.pat_buf_len = sizeof(patterns);
+ pc.patterns = patterns;
+ pc.match_buf_len = sizeof(results);
+ pc.matches = results;
+
+ if (ioctl(fd, PCIOCGETCONF, &pc) || pc.status == PCI_GETCONF_ERROR) {
+ error = errno;
+ close(fd);
+ return -error;
+ }
+ close(fd);
+
+ device->vendor_id = results[0].pc_vendor;
+ device->device_id = results[0].pc_device;
+ device->subvendor_id = results[0].pc_subvendor;
+ device->subdevice_id = results[0].pc_subdevice;
+ device->revision_id = results[0].pc_revid;
+
+ return 0;
#else
#warning "Missing implementation of drmParsePciDeviceInfo"
return -EINVAL;
@@ -3442,6 +3615,46 @@ free_device:
return ret;
}
+#ifdef __linux__
+static int drm_usb_dev_path(int maj, int min, char *path, size_t len)
+{
+ char *value, *tmp_path, *slash;
+
+ snprintf(path, len, "/sys/dev/char/%d:%d/device", maj, min);
+
+ value = sysfs_uevent_get(path, "DEVTYPE");
+ if (!value)
+ return -ENOENT;
+
+ if (strcmp(value, "usb_device") == 0)
+ return 0;
+ if (strcmp(value, "usb_interface") != 0)
+ return -ENOTSUP;
+
+ /* The parent of a usb_interface is a usb_device */
+
+ tmp_path = realpath(path, NULL);
+ if (!tmp_path)
+ return -errno;
+
+ slash = strrchr(tmp_path, '/');
+ if (!slash) {
+ free(tmp_path);
+ return -EINVAL;
+ }
+
+ *slash = '\0';
+
+ if (snprintf(path, len, "%s", tmp_path) >= (int)len) {
+ free(tmp_path);
+ return -EINVAL;
+ }
+
+ free(tmp_path);
+ return 0;
+}
+#endif
+
static int drmParseUsbBusInfo(int maj, int min, drmUsbBusInfoPtr info)
{
#ifdef __linux__
@@ -3449,7 +3662,9 @@ static int drmParseUsbBusInfo(int maj, int min, drmUsbBusInfoPtr info)
unsigned int bus, dev;
int ret;
- snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min);
+ ret = drm_usb_dev_path(maj, min, path, sizeof(path));
+ if (ret < 0)
+ return ret;
value = sysfs_uevent_get(path, "BUSNUM");
if (!value)
@@ -3488,7 +3703,9 @@ static int drmParseUsbDeviceInfo(int maj, int min, drmUsbDeviceInfoPtr info)
unsigned int vendor, product;
int ret;
- snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min);
+ ret = drm_usb_dev_path(maj, min, path, sizeof(path));
+ if (ret < 0)
+ return ret;
value = sysfs_uevent_get(path, "PRODUCT");
if (!value)
@@ -3754,6 +3971,7 @@ process_device(drmDevicePtr *device, const char *d_name,
switch (subsystem_type) {
case DRM_BUS_PCI:
+ case DRM_BUS_VIRTIO:
return drmProcessPciDevice(device, node, node_type, maj, min,
fetch_deviceinfo, flags);
case DRM_BUS_USB:
@@ -3847,7 +4065,7 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
char node[PATH_MAX + 1];
const char *dev_name;
int node_type, subsystem_type;
- int maj, min, n, ret, base;
+ int maj, min, n, ret;
if (fd == -1 || device == NULL)
return -EINVAL;
@@ -3861,29 +4079,15 @@ drm_public int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
return -EINVAL;
- node_type = drmGetMinorType(min);
+ node_type = drmGetMinorType(maj, min);
if (node_type == -1)
return -ENODEV;
- switch (node_type) {
- case DRM_NODE_PRIMARY:
- dev_name = DRM_DEV_NAME;
- break;
- case DRM_NODE_CONTROL:
- dev_name = DRM_CONTROL_DEV_NAME;
- break;
- case DRM_NODE_RENDER:
- dev_name = DRM_RENDER_DEV_NAME;
- break;
- default:
+ dev_name = drmGetDeviceName(node_type);
+ if (!dev_name)
return -EINVAL;
- };
- base = drmGetMinorBase(node_type);
- if (base < 0)
- return -EINVAL;
-
- n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+ n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
if (n == -1 || n >= PATH_MAX)
return -errno;
if (stat(node, &sbuf))
@@ -4098,12 +4302,14 @@ drm_public char *drmGetDeviceNameFromFd2(int fd)
free(value);
return strdup(path);
+#elif __FreeBSD__
+ return drmGetDeviceNameFromFd(fd);
#else
struct stat sbuf;
char node[PATH_MAX + 1];
const char *dev_name;
int node_type;
- int maj, min, n, base;
+ int maj, min, n;
if (fstat(fd, &sbuf))
return NULL;
@@ -4114,29 +4320,15 @@ drm_public char *drmGetDeviceNameFromFd2(int fd)
if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
return NULL;
- node_type = drmGetMinorType(min);
+ node_type = drmGetMinorType(maj, min);
if (node_type == -1)
return NULL;
- switch (node_type) {
- case DRM_NODE_PRIMARY:
- dev_name = DRM_DEV_NAME;
- break;
- case DRM_NODE_CONTROL:
- dev_name = DRM_CONTROL_DEV_NAME;
- break;
- case DRM_NODE_RENDER:
- dev_name = DRM_RENDER_DEV_NAME;
- break;
- default:
- return NULL;
- };
-
- base = drmGetMinorBase(node_type);
- if (base < 0)
+ dev_name = drmGetDeviceName(node_type);
+ if (!dev_name)
return NULL;
- n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min - base);
+ n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
if (n == -1 || n >= PATH_MAX)
return NULL;
@@ -4334,6 +4526,21 @@ drm_public int drmSyncobjQuery(int fd, uint32_t *handles, uint64_t *points,
return 0;
}
+drm_public int drmSyncobjQuery2(int fd, uint32_t *handles, uint64_t *points,
+ uint32_t handle_count, uint32_t flags)
+{
+ struct drm_syncobj_timeline_array args;
+
+ memclear(args);
+ args.handles = (uintptr_t)handles;
+ args.points = (uintptr_t)points;
+ args.count_handles = handle_count;
+ args.flags = flags;
+
+ return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_QUERY, &args);
+}
+
+
drm_public int drmSyncobjTransfer(int fd,
uint32_t dst_handle, uint64_t dst_point,
uint32_t src_handle, uint64_t src_point,
diff --git a/xf86drm.h b/xf86drm.h
index 3fb1d1ca..7b85079a 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -78,17 +78,29 @@ extern "C" {
#ifdef __OpenBSD__
#define DRM_DIR_NAME "/dev"
-#define DRM_DEV_NAME "%s/drm%d"
-#define DRM_CONTROL_DEV_NAME "%s/drmC%d"
-#define DRM_RENDER_DEV_NAME "%s/drmR%d"
+#define DRM_PRIMARY_MINOR_NAME "drm"
+#define DRM_CONTROL_MINOR_NAME "drmC"
+#define DRM_RENDER_MINOR_NAME "drmR"
#else
#define DRM_DIR_NAME "/dev/dri"
-#define DRM_DEV_NAME "%s/card%d"
-#define DRM_CONTROL_DEV_NAME "%s/controlD%d"
-#define DRM_RENDER_DEV_NAME "%s/renderD%d"
+#define DRM_PRIMARY_MINOR_NAME "card"
+#define DRM_CONTROL_MINOR_NAME "controlD"
+#define DRM_RENDER_MINOR_NAME "renderD"
#define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
#endif
+#define DRM_DEV_NAME "%s/" DRM_PRIMARY_MINOR_NAME "%d"
+#define DRM_CONTROL_DEV_NAME "%s/" DRM_CONTROL_MINOR_NAME "%d"
+#define DRM_RENDER_DEV_NAME "%s/" DRM_RENDER_MINOR_NAME "%d"
+
+#define DRM_NODE_NAME_MAX \
+ (sizeof(DRM_DIR_NAME) + 1 /* slash */ \
+ + MAX3(sizeof(DRM_PRIMARY_MINOR_NAME), \
+ sizeof(DRM_CONTROL_MINOR_NAME), \
+ sizeof(DRM_RENDER_MINOR_NAME)) \
+ + sizeof("144") /* highest possible node number */ \
+ + 1) /* NULL-terminator */
+
#define DRM_ERR_NO_DEVICE (-1001)
#define DRM_ERR_NO_ACCESS (-1002)
#define DRM_ERR_NOT_ROOT (-1003)
@@ -469,6 +481,29 @@ do { register unsigned int __old __asm("o0"); \
: "cr0", "memory"); \
} while (0)
+# elif defined (__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
+ || defined (__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \
+ || defined (__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) \
+ || defined (__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
+ || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
+ || defined(__ARM_ARCH_7EM__)
+ /* excluding ARMv4/ARMv5 and lower (lacking ldrex/strex support) */
+ #undef DRM_DEV_MODE
+ #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
+
+ #define DRM_CAS(lock,old,new,__ret) \
+ do { \
+ __asm__ __volatile__ ( \
+ "1: ldrex %0, [%1]\n" \
+ " teq %0, %2\n" \
+ " ite eq\n" \
+ " strexeq %0, %3, [%1]\n" \
+ " movne %0, #1\n" \
+ : "=&r" (__ret) \
+ : "r" (lock), "r" (old), "r" (new) \
+ : "cc","memory"); \
+ } while (0)
+
#endif /* architecture */
#endif /* __GNUC__ >= 2 */
@@ -884,6 +919,8 @@ extern int drmSyncobjTimelineWait(int fd, uint32_t *handles, uint64_t *points,
uint32_t *first_signaled);
extern int drmSyncobjQuery(int fd, uint32_t *handles, uint64_t *points,
uint32_t handle_count);
+extern int drmSyncobjQuery2(int fd, uint32_t *handles, uint64_t *points,
+ uint32_t handle_count, uint32_t flags);
extern int drmSyncobjTransfer(int fd,
uint32_t dst_handle, uint64_t dst_point,
uint32_t src_handle, uint64_t src_point,
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 207d7be9..5af27c4a 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -42,7 +42,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <sys/ioctl.h>
-#ifdef HAVE_SYS_SYSCTL_H
+#if HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
#include <stdio.h>
@@ -683,6 +683,7 @@ drm_public void drmModeFreeProperty(drmModePropertyPtr ptr)
drmFree(ptr->values);
drmFree(ptr->enums);
+ drmFree(ptr->blob_ids);
drmFree(ptr);
}
@@ -800,21 +801,13 @@ drm_public int drmCheckModesettingSupported(const char *busid)
if (found)
return 0;
#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
- char kbusid[1024], sbusid[1024];
+ char sbusid[1024];
char oid[128];
- int domain, bus, dev, func;
int i, modesetting, ret;
size_t len;
- ret = sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev,
- &func);
- if (ret != 4)
- return -EINVAL;
- snprintf(kbusid, sizeof(kbusid), "pci:%04x:%02x:%02x.%d", domain, bus,
- dev, func);
-
/* How many GPUs do we expect in the machine ? */
- for (i = 0; i < 16; i++) {
+ for (i = 0; i < 10; i++) {
snprintf(oid, sizeof(oid), "hw.dri.%d.busid", i);
len = sizeof(sbusid);
ret = sysctlbyname(oid, sbusid, &len, NULL, 0);
@@ -823,7 +816,7 @@ drm_public int drmCheckModesettingSupported(const char *busid)
continue;
return -EINVAL;
}
- if (strcmp(sbusid, kbusid) != 0)
+ if (strcmp(sbusid, busid) != 0)
continue;
snprintf(oid, sizeof(oid), "hw.dri.%d.modesetting", i);
len = sizeof(modesetting);
@@ -1594,3 +1587,38 @@ drmModeRevokeLease(int fd, uint32_t lessee_id)
return 0;
return -errno;
}
+
+drm_public drmModeFB2Ptr
+drmModeGetFB2(int fd, uint32_t fb_id)
+{
+ struct drm_mode_fb_cmd2 get = {
+ .fb_id = fb_id,
+ };
+ drmModeFB2Ptr ret;
+ int err;
+
+ err = DRM_IOCTL(fd, DRM_IOCTL_MODE_GETFB2, &get);
+ if (err != 0)
+ return NULL;
+
+ ret = drmMalloc(sizeof(drmModeFB2));
+ if (!ret)
+ return NULL;
+
+ ret->fb_id = fb_id;
+ ret->width = get.width;
+ ret->height = get.height;
+ ret->pixel_format = get.pixel_format;
+ ret->flags = get.flags;
+ ret->modifier = get.modifier[0];
+ memcpy(ret->handles, get.handles, sizeof(uint32_t) * 4);
+ memcpy(ret->pitches, get.pitches, sizeof(uint32_t) * 4);
+ memcpy(ret->offsets, get.offsets, sizeof(uint32_t) * 4);
+
+ return ret;
+}
+
+drm_public void drmModeFreeFB2(drmModeFB2Ptr ptr)
+{
+ drmFree(ptr);
+}
diff --git a/xf86drmMode.h b/xf86drmMode.h
index a32902f7..54493205 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -41,6 +41,8 @@ extern "C" {
#endif
#include <drm.h>
+#include <stddef.h>
+#include <stdint.h>
/*
* This is the interface for modesetting for drm.
@@ -160,6 +162,7 @@ extern "C" {
#define DRM_MODE_CONNECTOR_VIRTUAL 15
#define DRM_MODE_CONNECTOR_DSI 16
#define DRM_MODE_CONNECTOR_DPI 17
+#define DRM_MODE_CONNECTOR_WRITEBACK 18
#define DRM_MODE_PROP_PENDING (1<<0)
#define DRM_MODE_PROP_RANGE (1<<1)
@@ -223,6 +226,19 @@ typedef struct _drmModeFB {
uint32_t handle;
} drmModeFB, *drmModeFBPtr;
+typedef struct _drmModeFB2 {
+ uint32_t fb_id;
+ uint32_t width, height;
+ uint32_t pixel_format; /* fourcc code from drm_fourcc.h */
+ uint64_t modifier; /* applies to all buffers */
+ uint32_t flags;
+
+ /* per-plane GEM handle; may be duplicate entries for multiple planes */
+ uint32_t handles[4];
+ uint32_t pitches[4]; /* bytes */
+ uint32_t offsets[4]; /* bytes */
+} drmModeFB2, *drmModeFB2Ptr;
+
typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr;
typedef struct _drmModePropertyBlob {
@@ -341,6 +357,7 @@ typedef struct _drmModePlaneRes {
extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr );
extern void drmModeFreeResources( drmModeResPtr ptr );
extern void drmModeFreeFB( drmModeFBPtr ptr );
+extern void drmModeFreeFB2( drmModeFB2Ptr ptr );
extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
extern void drmModeFreeConnector( drmModeConnectorPtr ptr );
extern void drmModeFreeEncoder( drmModeEncoderPtr ptr );
@@ -360,6 +377,7 @@ extern drmModeResPtr drmModeGetResources(int fd);
* Retrieve information about framebuffer bufferId
*/
extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId);
+extern drmModeFB2Ptr drmModeGetFB2(int fd, uint32_t bufferId);
/**
* Creates a new framebuffer with an buffer object as its scanout buffer.