Add new API for reusable "state objects" which can be re-used multiple
times. Backend implementation for msm will follow. (Probably not
needed to support this for any device that uses kgsl backend, since this
is mostly useful for a5xx+.)
Signed-off-by: Rob Clark <robclark@freedesktop.org>
In drmGetDevice2 when no local device is found or when
drm_device_has_rdev filters out all devices, *device might be left
uninitialized causing drmGetDevice2 to not return error - since
it's only returned when *device == NULL.
Above leads to crash in the firefox in system with amdgpu.
With this change firefox displays:
libGL error: MESA-LOADER: failed to retrieve device information
libGL error: unable to load driver: amdgpu_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: amdgpu
libGL error: MESA-LOADER: failed to retrieve device information
libGL error: unable to load driver: amdgpu_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: amdgpu
and doesn't crash.
Bugzilla: https://bugs.freedesktop.org/107384
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Mariusz Ceier <mceier+mesa-dev@gmail.com>
While fairly close, the host1x and platform are two separate things.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Making the output a little bit easier to parse by human beings.
v2: Add extra whitespace (Eric)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com> (v1)
Reviewed-by: Robert Foss <robert.foss@collabora.com> (v1)
Reviewed-by: Eric Engestrom <eric@engestrom.ch> (v1)
Add a few printf statements, which should make the output easier to
parse.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
It's mildly useful program, to ship it when the user wants the "tests"
installed. Obviously the "tests" in the name is a misnomer.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
The GPU almost exclusively lives on the PCI bus, so we expose it as a
normal PCI one.
This allows all existing drmDevice users to work without any changes.
One could wonder why a separate typeset is not introduced, alike say
host1x. Unlike host1x the PCI/platform distinction for virtio provides
no extra information. Plus if needed we can add the separate set at a
later stage.
Here are a few 'features' that virtio seems to be missing:
- provides extra information on top the plaform devices
- supports a range of GPU devices
- is considered hardware description (DT)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Introduce a helper which gets the real sysfs path for the given pci
device.
In other words, instead opening the /sys/dev/char/*/device symlink, we
opt for the actual /sys/devices/pci*/*/
It folds three (nearly identical) snprintf's and paves the way of adding
extra devices (see next patch) a piece of pie.
v2: use a caller (on stack) provided real_path (Eric)
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com> (v1)
Reviewed-by: Robert Foss <robert.foss@collabora.com> (v1)
Reviewed-by: Eric Engestrom <eric@engestrom.ch> (v1)
Currently we dynamically allocate 16 pointers and reallocate more as
needed.
Instead, allocate the maximum number (256) on stack - the number is
small enough and is unlikely to change in the foreseeable future.
This allows us to simplify the error handling and even shed a few bytes
off the final binary.
v2:
- add a define & description behind the magic 256
- report error to strerr and skip when over 256 device nodes
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com> (v1)
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch> (v1)
Don't duplicate the nearly identical code across the two call sites.
It improves legibility and the diff stat seems nice.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Currently we match the opened drmDevice fd with each drmDevice we
process.
Move that after all the devices are processed and folded, via the
drm_device_has_rdev(). This makes the code easier to follow and allows
us to unify the massive process loop across drmGetDevice2 and
drmGetDevices2. That in itself is coming with a later commit.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Currently one can open() any /dev node. If it's unknown
drmParseSubsystemType() will return an error.
Track that and bail as needed.
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Otherwise we leak file descriptors into child processes.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Junwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
This reverts commit fe0488aa13.
It caused messages like
amdgpu 0000:23:00.0: bo 000000007dce0b3e va 0x0000101800-0x000010181f conflict with 0x0000101800-0x0000101820
in dmesg, and eventually a Xorg crash while running piglit.
Evidently, such BOs can actually be re-imported by other means than via
a KMS handle.
Amber Lake uses the same gen graphics as Kaby Lake, including a id
that were previously marked as reserved on Kaby Lake, but that now is
moved to AML page.
So, let's just move it to AML macro that will feed into KBL macro
just to keep it better organized to make easier future code review
but it will be handled as a KBL.
This is a copy of merged i915's
commit e364672477a1 ("drm/i915/aml: Introducing Amber Lake platform")
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Whiskey Lake uses the same gen graphics as Coffe Lake, including some
ids that were previously marked as reserved on Coffe Lake, but that
now are moved to WHL page.
So, let's just move them to WHL macros that will feed into CFL macro
just to keep it better organized to make easier future code review
but it will be handled as a CFL.
This is a copy of merged i915's
commit b9be78531d27 ("drm/i915/whl: Introducing Whiskey Lake platform")
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Something for users of fd_ringbuffer to use as they see fit. (For now,
just so mesa can add some debugging state.)
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Fixes memory leak on module unload.
Analogous to mesa commit of the same name.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Analogous to the mesa commit of the same name.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Close the file descriptors under lock as well.
v2: close fds after removing from hash table
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
removed in commit bb45ce4e3a
Adding it back as it is still needed in the case where we don't find a
match.
Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
Fixes: bb45ce4e3a "libdrm: Use readdir instead of readdir_r to
avoid build warnings"$
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
In mesa/gallium, a pipe_fence can outlive the pipe_context it was
created from. But to wait on the fence we need to know the submit-
queue (ie. the fd_pipe).
The most straightforward way to fix this is to add reference counting
to the fd_pipe and let the fence hold a reference to the pipe (rather
than hanging on to the context, which might have been destroyed before
the fence).
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Add the PCI IDs and the basic code to enable ICL. This is the current
PCI ID list in our documentation.
Kernel commit: d55cb4fa2cf0 ("drm/i915/icl: Add the ICL PCI IDs")
v2: Michel provided a fix to IS_9XX that was broken by rebase bot.
v3: Fix double definition of PCI IDs, update IDs according to bspec
and keep them in the same order and rebase (Lucas)
Cc: Michel Thierry <michel.thierry@intel.com>
Reviewed-by: Michel Thierry <michel.thierry@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
128 is the maximum number of cards that the kernel can support
at the moment.
Change-Id: I155b7b21635306d8ecc440b85fb8954501ab5599
Signed-off-by: Xiaojie Yuan <Xiaojie.Yuan@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
In trying to integrate the new gralloc_handle.h with the
drm_hwcomposer, I started seeing the following compilation
errors:
In file included from external/drm_hwcomposer/platformdrmgeneric.cpp:28:
external/libdrm/android/gralloc_handle.h:108:9: error: cannot initialize return object of type 'native_handle_t *' (aka 'native_handle *') with an lvalue of type 'struct gralloc_handle_t *'
return handle;
^~~~~~
1 error generated.
This seems to be due to the gralloc_handle_create() definition
needs to return a native_handle_t * type, rather then a
gralloc_handle_t *, which is what the code actually returns.
After talking w/ Rob Herring, having the code return the
native handle should be the proper fix, so that is what
this patch changes.
Cc: Chih-Wei Huang <cwhuang@android-x86.org>
Cc: Stefan Schake <stschake@gmail.com>
Cc: Robert Foss <robert.foss@collabora.com>
Cc: Sean Paul <seanpaul@google.com>
Cc: Rob Herring <robh@kernel.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Nouveau has made a very deliberate choice to hide its actual kernel ABI
behind libdrm. i915 is no longer out of date.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Taken from the drm-next pull for 4.17-rc1 (694f54f680f7), and manually
reconciled:
core:
- Dropped DRM_MODE_TYPE_ALL and DRM_MODE_FLAG_ALL; these are purely
internal details of the bits accepted by the currently running
kernel, and can not be generally relied on by userspace
- Add HDCP flags
- Note CTM entry representation is sign-magnitude format, not
two's-complement
amdgpu:
- Add QUERY_STATE2 context op
- Add VCN firmware version query
etnaviv:
- Add more GPU feature flags
i915:
- Add caps, params and ioctls for PMU / perf-stream
- Add support for explicit fencing
nouveau:
- Add TILE_COMP layout
vc4:
- Add perfmon ioctls
virtgpu:
- Add capset-fix param
vmware:
- Add handle-close ioctl and explicit-fencing support
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Add sensor_info type
AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK
AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK
Reviewed-by: Evan Quan <evan.quan@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
This reverts commit ed07718ae7.
The commit added a guard since libpciaccess may be missing on some
setups. As of last commit there are no traces of the project, from
Android POV.
Hence, we can revert this workaround - which caused similar breakage to
the one it's trying to fix. This time in Mesa.
Cc: Rob Herring <rob.herring@linaro.org>
Acked-by: John Stultz <john.stultz@linaro.org>
This patch makes the code not rely anymore on libpciaccess when compiled
for Android to eliminate ioperm() and iopl() syscalls required by that
library. As a side effect, the mappable aperture size is hardcoded to 64
MiB on Android, however nothing seems to rely on this value anyway, as
checked be grepping relevant code in drm_gralloc and Mesa.
Cc: Rob Herring <rob.herring@linaro.org>
Signed-off-by: Tomasz Figa <tfiga@google.com>
[Emil Velikov: rebase against master. add missing __func__, Eric]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Building libdrm under AOSP, we see the following build warning:
external/libdrm/xf86drm.c:2861:12: warning: 'readdir_r' is deprecated: readdir_r is deprecated; use readdir instead [-Wdeprecated-declarations]
while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {
^
Building on Linux with glibc produces the same warning.
Thus, this patch replaces readdir_r with readdir.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102031
Cc: Robert Foss <robert.foss@collabora.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Stefan Schake <stschake@gmail.com>
Cc: John Stultz <john.stultz@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
[Emil Velikov: remove unused variables, Eric]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
They were set for the static library but not the shared variant.
Signed-off-by: Stefan Schake <stschake@gmail.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Currently while exporting prime handle to fd read write access is
not granted. mmap fails because of this. mmap was not supported on
prime initially.
Here is link to related discussion
https://lists.freedesktop.org/archives/dri-devel/2017-February/131840.html
Adding the DRM_RDWR flag in amdgpu_bo_export to support mmap.
Signed-off-by: Satyajit <satyajit.sahu@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
libdrm only needed libudev for a few days 3 years ago,
between fde4969176 and its revert 5b0e76f143.
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
This will prevent any more missing `#include "config.h"` bug, at the
cost of having to recompile some files that didn't need to be when
changing build options.
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>