mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 05:25:20 +07:00
ef96152e6a
-----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJYr5aeAAoJEAx081l5xIa+ZK4P/RD3XUsduYqziVFCRQ2n0X8r +D92F4peTnSeSq7ZcZvprv+fezUGAHbfsWFs8feYCI5quUO6pEQSPwN+wyGazUi0 4hUVB/K9Iq7U/Bj7Z/SmsU3NuWJnkNqbmvSFvUdqYK9D/kl+Tnllzap2N4cTzjwu GZOObz4n85cx94NqC3qw+7/ptL1X2MhXa+z0MzbkKyas84Bko1LwCSHRHsDKUnJc IcSpOcYZ6pSRMIsKH4Kd79Go4vWm7djXT9XL3PwDk2NcXXUOuR+cfdHqYchYaM/O iD2hvaSywBcflxSAml5x6vlXraoRd91ZZulgOObXtFfnUXdZB81TVq4uv6LU4Bx3 jLFixUZuk/TJT+W/8N10l7M6yMIFaTpNoNMc5n4IF5RNNyWba4BKnrI+f+lQiOpY mmjIaidb0t5BICnJzCD264RhCEXmP0HaDV+iQQV6y6jJRXfd1bgnOXLKP73JekzB TsbDshCoE7UO0dJ7n0LFpXSTQDTYzlazoEp14f2kFBxir5/l7r67nUlnDTvUQfuN tSRvpN/s0wqvH3o7zhmpHxyJ/ZasPMQjNCFAuUEbx8L5SKXsua0FubIzN4aVpilb XvfdFRWM/lkOT/q+8cGI/TcE3YTqEmALmGxdV/akbdNCiCg6aClyCLRE/DZhgmSQ UMFjr9wlHl5Qo/OqLKj0 =Yjfg -----END PGP SIGNATURE----- Merge tag 'drm-for-v4.11-less-shouty' of git://people.freedesktop.org/~airlied/linux Pull drm updates from Dave Airlie: "This is the main drm pull request for v4.11. Nothing too major, the tinydrm and mmu-less support should make writing smaller drivers easier for some of the simpler platforms, and there are a bunch of documentation updates. Intel grew displayport MST audio support which is hopefully useful to people, and FBC is on by default for GEN9+ (so people know where to look for regressions). AMDGPU has a lot of fixes that would like new firmware files installed for some GPUs. Other than that it's pretty scattered all over. I may have a follow up pull request as I know BenH has a bunch of AST rework and fixes and I'd like to get those in once they've been tested by AST, and I've got at least one pull request I'm just trying to get the author to fix up. Core: - drm_mm reworked - Connector list locking and iterators - Documentation updates - Format handling rework - MMU-less support for fbdev helpers - drm_crtc_from_index helper - Core CRC API - Remove drm_framebuffer_unregister_private - Debugfs cleanup - EDID/Infoframe fixes - Release callback - Tinydrm support (smaller drivers for simple hw) panel: - Add support for some new simple panels i915: - FBC by default for gen9+ - Shared dpll cleanups and docs - GEN8 powerdomain cleanup - DMC support on GLK - DP MST audio support - HuC loading support - GVT init ordering fixes - GVT IOMMU workaround fix amdgpu/radeon: - Power/clockgating improvements - Preliminary SR-IOV support - TTM buffer priority and eviction fixes - SI DPM quirks removed due to firmware fixes - Powerplay improvements - VCE/UVD powergating fixes - Cleanup SI GFX code to match CI/VI - Support for > 2 displays on 3/5 crtc asics - SI headless fixes nouveau: - Rework securre boot code in prep for GP10x secure boot - Channel recovery improvements - Initial power budget code - MMU rework preperation vmwgfx: - Bunch of fixes and cleanups exynos: - Runtime PM support for MIC driver - Cleanups to use atomic helpers - UHD Support for TM2/TM2E boards - Trigger mode fix for Rinato board etnaviv: - Shader performance fix - Command stream validator fixes - Command buffer suballocator rockchip: - CDN DisplayPort support - IOMMU support for arm64 platform imx-drm: - Fix i.MX5 TV encoder probing - Remove lower fb size limits msm: - Support for HW cursor on MDP5 devices - DSI encoder cleanup - GPU DT bindings cleanup sti: - stih410 cleanups - Create fbdev at binding - HQVDP fixes - Remove stih416 chip functionality - DVI/HDMI mode selection fixes - FPS statistic reporting omapdrm: - IRQ code cleanup dwi-hdmi bridge: - Cleanups and fixes adv-bridge: - Updates for nexus sii8520 bridge: - Add interlace mode support - Rework HDMI and lots of fixes qxl: - probing/teardown cleanups ZTE drm: - HDMI audio via SPDIF interface - Video Layer overlay plane support - Add TV encoder output device atmel-hlcdc: - Rework fbdev creation logic tegra: - OF node fix fsl-dcu: - Minor fixes mali-dp: - Assorted fixes sunxi: - Minor fix" [ This was the "fixed" pull, that still had build warnings due to people not even having build tested the result. I'm not a happy camper I've fixed the things I noticed up in this merge. - Linus ] * tag 'drm-for-v4.11-less-shouty' of git://people.freedesktop.org/~airlied/linux: (1177 commits) lib/Kconfig: make PRIME_NUMBERS not user selectable drm/tinydrm: helpers: Properly fix backlight dependency drm/tinydrm: mipi-dbi: Fix field width specifier warning drm/tinydrm: mipi-dbi: Silence: ‘cmd’ may be used uninitialized drm/sti: fix build warnings in sti_drv.c and sti_vtg.c files drm/amd/powerplay: fix PSI feature on Polars12 drm/amdgpu: refuse to reserve io mem for split VRAM buffers drm/ttm: fix use-after-free races in vm fault handling drm/tinydrm: Add support for Multi-Inno MI0283QT display dt-bindings: Add Multi-Inno MI0283QT binding dt-bindings: display/panel: Add common rotation property of: Add vendor prefix for Multi-Inno drm/tinydrm: Add MIPI DBI support drm/tinydrm: Add helper functions drm: Add DRM support for tiny LCD displays drm/amd/amdgpu: post card if there is real hw resetting performed drm/nouveau/tmr: provide backtrace when a timeout is hit drm/nouveau/pci/g92: Fix rearm drm/nouveau/drm/therm/fan: add a fallback if no fan control is specified in the vbios drm/nouveau/hwmon: expose power_max and power_crit ..
440 lines
13 KiB
C
440 lines
13 KiB
C
/*
|
|
* Copyright (c) 2016 Intel Corporation
|
|
*
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
* that the name of the copyright holders not be used in advertising or
|
|
* publicity pertaining to distribution of the software without specific,
|
|
* written prior permission. The copyright holders make no representations
|
|
* about the suitability of this software for any purpose. It is provided "as
|
|
* is" without express or implied warranty.
|
|
*
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
* OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#include <linux/export.h>
|
|
#include <drm/drmP.h>
|
|
#include <drm/drm_mode_object.h>
|
|
#include <drm/drm_atomic.h>
|
|
|
|
#include "drm_crtc_internal.h"
|
|
|
|
/*
|
|
* Internal function to assign a slot in the object idr and optionally
|
|
* register the object into the idr.
|
|
*/
|
|
int drm_mode_object_get_reg(struct drm_device *dev,
|
|
struct drm_mode_object *obj,
|
|
uint32_t obj_type,
|
|
bool register_obj,
|
|
void (*obj_free_cb)(struct kref *kref))
|
|
{
|
|
int ret;
|
|
|
|
mutex_lock(&dev->mode_config.idr_mutex);
|
|
ret = idr_alloc(&dev->mode_config.crtc_idr, register_obj ? obj : NULL, 1, 0, GFP_KERNEL);
|
|
if (ret >= 0) {
|
|
/*
|
|
* Set up the object linking under the protection of the idr
|
|
* lock so that other users can't see inconsistent state.
|
|
*/
|
|
obj->id = ret;
|
|
obj->type = obj_type;
|
|
if (obj_free_cb) {
|
|
obj->free_cb = obj_free_cb;
|
|
kref_init(&obj->refcount);
|
|
}
|
|
}
|
|
mutex_unlock(&dev->mode_config.idr_mutex);
|
|
|
|
return ret < 0 ? ret : 0;
|
|
}
|
|
|
|
/**
|
|
* drm_mode_object_get - allocate a new modeset identifier
|
|
* @dev: DRM device
|
|
* @obj: object pointer, used to generate unique ID
|
|
* @obj_type: object type
|
|
*
|
|
* Create a unique identifier based on @ptr in @dev's identifier space. Used
|
|
* for tracking modes, CRTCs and connectors. Note that despite the _get postfix
|
|
* modeset identifiers are _not_ reference counted. Hence don't use this for
|
|
* reference counted modeset objects like framebuffers.
|
|
*
|
|
* Returns:
|
|
* Zero on success, error code on failure.
|
|
*/
|
|
int drm_mode_object_get(struct drm_device *dev,
|
|
struct drm_mode_object *obj, uint32_t obj_type)
|
|
{
|
|
return drm_mode_object_get_reg(dev, obj, obj_type, true, NULL);
|
|
}
|
|
|
|
void drm_mode_object_register(struct drm_device *dev,
|
|
struct drm_mode_object *obj)
|
|
{
|
|
mutex_lock(&dev->mode_config.idr_mutex);
|
|
idr_replace(&dev->mode_config.crtc_idr, obj, obj->id);
|
|
mutex_unlock(&dev->mode_config.idr_mutex);
|
|
}
|
|
|
|
/**
|
|
* drm_mode_object_unregister - free a modeset identifer
|
|
* @dev: DRM device
|
|
* @object: object to free
|
|
*
|
|
* Free @id from @dev's unique identifier pool.
|
|
* This function can be called multiple times, and guards against
|
|
* multiple removals.
|
|
* These modeset identifiers are _not_ reference counted. Hence don't use this
|
|
* for reference counted modeset objects like framebuffers.
|
|
*/
|
|
void drm_mode_object_unregister(struct drm_device *dev,
|
|
struct drm_mode_object *object)
|
|
{
|
|
mutex_lock(&dev->mode_config.idr_mutex);
|
|
if (object->id) {
|
|
idr_remove(&dev->mode_config.crtc_idr, object->id);
|
|
object->id = 0;
|
|
}
|
|
mutex_unlock(&dev->mode_config.idr_mutex);
|
|
}
|
|
|
|
struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev,
|
|
uint32_t id, uint32_t type)
|
|
{
|
|
struct drm_mode_object *obj = NULL;
|
|
|
|
mutex_lock(&dev->mode_config.idr_mutex);
|
|
obj = idr_find(&dev->mode_config.crtc_idr, id);
|
|
if (obj && type != DRM_MODE_OBJECT_ANY && obj->type != type)
|
|
obj = NULL;
|
|
if (obj && obj->id != id)
|
|
obj = NULL;
|
|
|
|
if (obj && obj->free_cb) {
|
|
if (!kref_get_unless_zero(&obj->refcount))
|
|
obj = NULL;
|
|
}
|
|
mutex_unlock(&dev->mode_config.idr_mutex);
|
|
|
|
return obj;
|
|
}
|
|
|
|
/**
|
|
* drm_mode_object_find - look up a drm object with static lifetime
|
|
* @dev: drm device
|
|
* @id: id of the mode object
|
|
* @type: type of the mode object
|
|
*
|
|
* This function is used to look up a modeset object. It will acquire a
|
|
* reference for reference counted objects. This reference must be dropped again
|
|
* by callind drm_mode_object_unreference().
|
|
*/
|
|
struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
|
|
uint32_t id, uint32_t type)
|
|
{
|
|
struct drm_mode_object *obj = NULL;
|
|
|
|
obj = __drm_mode_object_find(dev, id, type);
|
|
return obj;
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_object_find);
|
|
|
|
/**
|
|
* drm_mode_object_unreference - decr the object refcnt
|
|
* @obj: mode_object
|
|
*
|
|
* This function decrements the object's refcount if it is a refcounted modeset
|
|
* object. It is a no-op on any other object. This is used to drop references
|
|
* acquired with drm_mode_object_reference().
|
|
*/
|
|
void drm_mode_object_unreference(struct drm_mode_object *obj)
|
|
{
|
|
if (obj->free_cb) {
|
|
DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, kref_read(&obj->refcount));
|
|
kref_put(&obj->refcount, obj->free_cb);
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_object_unreference);
|
|
|
|
/**
|
|
* drm_mode_object_reference - incr the object refcnt
|
|
* @obj: mode_object
|
|
*
|
|
* This function increments the object's refcount if it is a refcounted modeset
|
|
* object. It is a no-op on any other object. References should be dropped again
|
|
* by calling drm_mode_object_unreference().
|
|
*/
|
|
void drm_mode_object_reference(struct drm_mode_object *obj)
|
|
{
|
|
if (obj->free_cb) {
|
|
DRM_DEBUG("OBJ ID: %d (%d)\n", obj->id, kref_read(&obj->refcount));
|
|
kref_get(&obj->refcount);
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(drm_mode_object_reference);
|
|
|
|
/**
|
|
* drm_object_attach_property - attach a property to a modeset object
|
|
* @obj: drm modeset object
|
|
* @property: property to attach
|
|
* @init_val: initial value of the property
|
|
*
|
|
* This attaches the given property to the modeset object with the given initial
|
|
* value. Currently this function cannot fail since the properties are stored in
|
|
* a statically sized array.
|
|
*/
|
|
void drm_object_attach_property(struct drm_mode_object *obj,
|
|
struct drm_property *property,
|
|
uint64_t init_val)
|
|
{
|
|
int count = obj->properties->count;
|
|
|
|
if (count == DRM_OBJECT_MAX_PROPERTY) {
|
|
WARN(1, "Failed to attach object property (type: 0x%x). Please "
|
|
"increase DRM_OBJECT_MAX_PROPERTY by 1 for each time "
|
|
"you see this message on the same object type.\n",
|
|
obj->type);
|
|
return;
|
|
}
|
|
|
|
obj->properties->properties[count] = property;
|
|
obj->properties->values[count] = init_val;
|
|
obj->properties->count++;
|
|
}
|
|
EXPORT_SYMBOL(drm_object_attach_property);
|
|
|
|
/**
|
|
* drm_object_property_set_value - set the value of a property
|
|
* @obj: drm mode object to set property value for
|
|
* @property: property to set
|
|
* @val: value the property should be set to
|
|
*
|
|
* This function sets a given property on a given object. This function only
|
|
* changes the software state of the property, it does not call into the
|
|
* driver's ->set_property callback.
|
|
*
|
|
* Note that atomic drivers should not have any need to call this, the core will
|
|
* ensure consistency of values reported back to userspace through the
|
|
* appropriate ->atomic_get_property callback. Only legacy drivers should call
|
|
* this function to update the tracked value (after clamping and other
|
|
* restrictions have been applied).
|
|
*
|
|
* Returns:
|
|
* Zero on success, error code on failure.
|
|
*/
|
|
int drm_object_property_set_value(struct drm_mode_object *obj,
|
|
struct drm_property *property, uint64_t val)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < obj->properties->count; i++) {
|
|
if (obj->properties->properties[i] == property) {
|
|
obj->properties->values[i] = val;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
return -EINVAL;
|
|
}
|
|
EXPORT_SYMBOL(drm_object_property_set_value);
|
|
|
|
/**
|
|
* drm_object_property_get_value - retrieve the value of a property
|
|
* @obj: drm mode object to get property value from
|
|
* @property: property to retrieve
|
|
* @val: storage for the property value
|
|
*
|
|
* This function retrieves the softare state of the given property for the given
|
|
* property. Since there is no driver callback to retrieve the current property
|
|
* value this might be out of sync with the hardware, depending upon the driver
|
|
* and property.
|
|
*
|
|
* Atomic drivers should never call this function directly, the core will read
|
|
* out property values through the various ->atomic_get_property callbacks.
|
|
*
|
|
* Returns:
|
|
* Zero on success, error code on failure.
|
|
*/
|
|
int drm_object_property_get_value(struct drm_mode_object *obj,
|
|
struct drm_property *property, uint64_t *val)
|
|
{
|
|
int i;
|
|
|
|
/* read-only properties bypass atomic mechanism and still store
|
|
* their value in obj->properties->values[].. mostly to avoid
|
|
* having to deal w/ EDID and similar props in atomic paths:
|
|
*/
|
|
if (drm_drv_uses_atomic_modeset(property->dev) &&
|
|
!(property->flags & DRM_MODE_PROP_IMMUTABLE))
|
|
return drm_atomic_get_property(obj, property, val);
|
|
|
|
for (i = 0; i < obj->properties->count; i++) {
|
|
if (obj->properties->properties[i] == property) {
|
|
*val = obj->properties->values[i];
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
}
|
|
EXPORT_SYMBOL(drm_object_property_get_value);
|
|
|
|
/* helper for getconnector and getproperties ioctls */
|
|
int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
|
|
uint32_t __user *prop_ptr,
|
|
uint64_t __user *prop_values,
|
|
uint32_t *arg_count_props)
|
|
{
|
|
int i, ret, count;
|
|
|
|
for (i = 0, count = 0; i < obj->properties->count; i++) {
|
|
struct drm_property *prop = obj->properties->properties[i];
|
|
uint64_t val;
|
|
|
|
if ((prop->flags & DRM_MODE_PROP_ATOMIC) && !atomic)
|
|
continue;
|
|
|
|
if (*arg_count_props > count) {
|
|
ret = drm_object_property_get_value(obj, prop, &val);
|
|
if (ret)
|
|
return ret;
|
|
|
|
if (put_user(prop->base.id, prop_ptr + count))
|
|
return -EFAULT;
|
|
|
|
if (put_user(val, prop_values + count))
|
|
return -EFAULT;
|
|
}
|
|
|
|
count++;
|
|
}
|
|
*arg_count_props = count;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* drm_mode_obj_get_properties_ioctl - get the current value of a object's property
|
|
* @dev: DRM device
|
|
* @data: ioctl data
|
|
* @file_priv: DRM file info
|
|
*
|
|
* This function retrieves the current value for an object's property. Compared
|
|
* to the connector specific ioctl this one is extended to also work on crtc and
|
|
* plane objects.
|
|
*
|
|
* Called by the user via ioctl.
|
|
*
|
|
* Returns:
|
|
* Zero on success, negative errno on failure.
|
|
*/
|
|
int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv)
|
|
{
|
|
struct drm_mode_obj_get_properties *arg = data;
|
|
struct drm_mode_object *obj;
|
|
int ret = 0;
|
|
|
|
if (!drm_core_check_feature(dev, DRIVER_MODESET))
|
|
return -EINVAL;
|
|
|
|
drm_modeset_lock_all(dev);
|
|
|
|
obj = drm_mode_object_find(dev, arg->obj_id, arg->obj_type);
|
|
if (!obj) {
|
|
ret = -ENOENT;
|
|
goto out;
|
|
}
|
|
if (!obj->properties) {
|
|
ret = -EINVAL;
|
|
goto out_unref;
|
|
}
|
|
|
|
ret = drm_mode_object_get_properties(obj, file_priv->atomic,
|
|
(uint32_t __user *)(unsigned long)(arg->props_ptr),
|
|
(uint64_t __user *)(unsigned long)(arg->prop_values_ptr),
|
|
&arg->count_props);
|
|
|
|
out_unref:
|
|
drm_mode_object_unreference(obj);
|
|
out:
|
|
drm_modeset_unlock_all(dev);
|
|
return ret;
|
|
}
|
|
|
|
struct drm_property *drm_mode_obj_find_prop_id(struct drm_mode_object *obj,
|
|
uint32_t prop_id)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < obj->properties->count; i++)
|
|
if (obj->properties->properties[i]->base.id == prop_id)
|
|
return obj->properties->properties[i];
|
|
|
|
return NULL;
|
|
}
|
|
|
|
int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
|
|
struct drm_file *file_priv)
|
|
{
|
|
struct drm_mode_obj_set_property *arg = data;
|
|
struct drm_mode_object *arg_obj;
|
|
struct drm_property *property;
|
|
int ret = -EINVAL;
|
|
struct drm_mode_object *ref;
|
|
|
|
if (!drm_core_check_feature(dev, DRIVER_MODESET))
|
|
return -EINVAL;
|
|
|
|
drm_modeset_lock_all(dev);
|
|
|
|
arg_obj = drm_mode_object_find(dev, arg->obj_id, arg->obj_type);
|
|
if (!arg_obj) {
|
|
ret = -ENOENT;
|
|
goto out;
|
|
}
|
|
|
|
if (!arg_obj->properties)
|
|
goto out_unref;
|
|
|
|
property = drm_mode_obj_find_prop_id(arg_obj, arg->prop_id);
|
|
if (!property)
|
|
goto out_unref;
|
|
|
|
if (!drm_property_change_valid_get(property, arg->value, &ref))
|
|
goto out_unref;
|
|
|
|
switch (arg_obj->type) {
|
|
case DRM_MODE_OBJECT_CONNECTOR:
|
|
ret = drm_mode_connector_set_obj_prop(arg_obj, property,
|
|
arg->value);
|
|
break;
|
|
case DRM_MODE_OBJECT_CRTC:
|
|
ret = drm_mode_crtc_set_obj_prop(arg_obj, property, arg->value);
|
|
break;
|
|
case DRM_MODE_OBJECT_PLANE:
|
|
ret = drm_mode_plane_set_obj_prop(obj_to_plane(arg_obj),
|
|
property, arg->value);
|
|
break;
|
|
}
|
|
|
|
drm_property_change_valid_put(property, ref);
|
|
|
|
out_unref:
|
|
drm_mode_object_unreference(arg_obj);
|
|
out:
|
|
drm_modeset_unlock_all(dev);
|
|
return ret;
|
|
}
|