Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * Copyright 2009 Jerome Glisse. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 | * OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: Dave Airlie |
| 25 | * Alex Deucher |
| 26 | * Jerome Glisse |
| 27 | */ |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 28 | #include <drm/drmP.h> |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 29 | #include "radeon.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 30 | #include <drm/radeon_drm.h> |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 31 | #include "radeon_asic.h" |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 32 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 33 | #include <linux/vga_switcheroo.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 34 | #include <linux/slab.h> |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 35 | #include <linux/pm_runtime.h> |
Alex Deucher | 7848865 | 2014-03-11 15:02:30 -0400 | [diff] [blame] | 36 | |
| 37 | #if defined(CONFIG_VGA_SWITCHEROO) |
Alex Deucher | 90c4cde | 2014-04-10 22:29:01 -0400 | [diff] [blame] | 38 | bool radeon_has_atpx(void); |
Alex Deucher | 7848865 | 2014-03-11 15:02:30 -0400 | [diff] [blame] | 39 | #else |
Alex Deucher | 90c4cde | 2014-04-10 22:29:01 -0400 | [diff] [blame] | 40 | static inline bool radeon_has_atpx(void) { return false; } |
Alex Deucher | 7848865 | 2014-03-11 15:02:30 -0400 | [diff] [blame] | 41 | #endif |
| 42 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 43 | /** |
| 44 | * radeon_driver_unload_kms - Main unload function for KMS. |
| 45 | * |
| 46 | * @dev: drm dev pointer |
| 47 | * |
| 48 | * This is the main unload function for KMS (all asics). |
| 49 | * It calls radeon_modeset_fini() to tear down the |
| 50 | * displays, and radeon_device_fini() to tear down |
| 51 | * the rest of the device (CP, writeback, etc.). |
| 52 | * Returns 0 on success. |
| 53 | */ |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 54 | int radeon_driver_unload_kms(struct drm_device *dev) |
| 55 | { |
| 56 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 57 | |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 58 | if (rdev == NULL) |
| 59 | return 0; |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 60 | |
Alex Deucher | 0cd9cb7 | 2013-04-12 19:15:52 -0400 | [diff] [blame] | 61 | if (rdev->rmmio == NULL) |
| 62 | goto done_free; |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 63 | |
| 64 | pm_runtime_get_sync(dev->dev); |
| 65 | |
Alex Deucher | c491707 | 2012-07-31 17:14:35 -0400 | [diff] [blame] | 66 | radeon_acpi_fini(rdev); |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 67 | |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 68 | radeon_modeset_fini(rdev); |
| 69 | radeon_device_fini(rdev); |
Alex Deucher | 0cd9cb7 | 2013-04-12 19:15:52 -0400 | [diff] [blame] | 70 | |
| 71 | done_free: |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 72 | kfree(rdev); |
| 73 | dev->dev_private = NULL; |
| 74 | return 0; |
| 75 | } |
| 76 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 77 | /** |
| 78 | * radeon_driver_load_kms - Main load function for KMS. |
| 79 | * |
| 80 | * @dev: drm dev pointer |
| 81 | * @flags: device flags |
| 82 | * |
| 83 | * This is the main load function for KMS (all asics). |
| 84 | * It calls radeon_device_init() to set up the non-display |
| 85 | * parts of the chip (asic init, CP, writeback, etc.), and |
| 86 | * radeon_modeset_init() to set up the display parts |
| 87 | * (crtcs, encoders, hotplug detect, etc.). |
| 88 | * Returns 0 on success, error on failure. |
| 89 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 90 | int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) |
| 91 | { |
| 92 | struct radeon_device *rdev; |
Alberto Milone | d7a2952 | 2010-07-06 11:40:24 -0400 | [diff] [blame] | 93 | int r, acpi_status; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 94 | |
| 95 | rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL); |
| 96 | if (rdev == NULL) { |
| 97 | return -ENOMEM; |
| 98 | } |
| 99 | dev->dev_private = (void *)rdev; |
| 100 | |
| 101 | /* update BUS flag */ |
Dave Airlie | 8410ea3 | 2010-12-15 03:16:38 +1000 | [diff] [blame] | 102 | if (drm_pci_device_is_agp(dev)) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 103 | flags |= RADEON_IS_AGP; |
Jon Mason | 58b6542 | 2011-06-27 16:07:50 +0000 | [diff] [blame] | 104 | } else if (pci_is_pcie(dev->pdev)) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 105 | flags |= RADEON_IS_PCIE; |
| 106 | } else { |
| 107 | flags |= RADEON_IS_PCI; |
| 108 | } |
| 109 | |
Alex Deucher | 73acacc | 2014-04-15 12:44:35 -0400 | [diff] [blame] | 110 | if ((radeon_runtime_pm != 0) && |
| 111 | radeon_has_atpx() && |
| 112 | ((flags & RADEON_IS_IGP) == 0)) |
Alex Deucher | 90c4cde | 2014-04-10 22:29:01 -0400 | [diff] [blame] | 113 | flags |= RADEON_IS_PX; |
| 114 | |
Jerome Glisse | 6cf8a3f | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 115 | /* radeon_device_init should report only fatal error |
| 116 | * like memory allocation failure or iomapping failure, |
| 117 | * or memory manager initialization failure, it must |
| 118 | * properly initialize the GPU MC controller and permit |
| 119 | * VRAM allocation |
| 120 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 121 | r = radeon_device_init(rdev, dev, dev->pdev, flags); |
| 122 | if (r) { |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 123 | dev_err(&dev->pdev->dev, "Fatal error during GPU init\n"); |
| 124 | goto out; |
Jerome Glisse | 6cf8a3f | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 125 | } |
Alberto Milone | d7a2952 | 2010-07-06 11:40:24 -0400 | [diff] [blame] | 126 | |
Jerome Glisse | 6cf8a3f | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 127 | /* Again modeset_init should fail only on fatal error |
| 128 | * otherwise it should provide enough functionalities |
| 129 | * for shadowfb to run |
| 130 | */ |
| 131 | r = radeon_modeset_init(rdev); |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 132 | if (r) |
| 133 | dev_err(&dev->pdev->dev, "Fatal error during modeset init\n"); |
Luca Tettamanti | fda4b25 | 2012-07-30 21:20:35 +0200 | [diff] [blame] | 134 | |
| 135 | /* Call ACPI methods: require modeset init |
| 136 | * but failure is not fatal |
| 137 | */ |
| 138 | if (!r) { |
| 139 | acpi_status = radeon_acpi_init(rdev); |
| 140 | if (acpi_status) |
| 141 | dev_dbg(&dev->pdev->dev, |
| 142 | "Error during ACPI methods call\n"); |
| 143 | } |
| 144 | |
Alex Deucher | 90c4cde | 2014-04-10 22:29:01 -0400 | [diff] [blame] | 145 | if (radeon_is_px(dev)) { |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 146 | pm_runtime_use_autosuspend(dev->dev); |
| 147 | pm_runtime_set_autosuspend_delay(dev->dev, 5000); |
| 148 | pm_runtime_set_active(dev->dev); |
| 149 | pm_runtime_allow(dev->dev); |
| 150 | pm_runtime_mark_last_busy(dev->dev); |
| 151 | pm_runtime_put_autosuspend(dev->dev); |
| 152 | } |
| 153 | |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 154 | out: |
| 155 | if (r) |
| 156 | radeon_driver_unload_kms(dev); |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 157 | |
| 158 | |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 159 | return r; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 160 | } |
| 161 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 162 | /** |
| 163 | * radeon_set_filp_rights - Set filp right. |
| 164 | * |
| 165 | * @dev: drm dev pointer |
| 166 | * @owner: drm file |
| 167 | * @applier: drm file |
| 168 | * @value: value |
| 169 | * |
| 170 | * Sets the filp rights for the device (all asics). |
| 171 | */ |
Marek Olšák | 9eba4a9 | 2011-01-05 05:46:48 +0100 | [diff] [blame] | 172 | static void radeon_set_filp_rights(struct drm_device *dev, |
| 173 | struct drm_file **owner, |
| 174 | struct drm_file *applier, |
| 175 | uint32_t *value) |
| 176 | { |
| 177 | mutex_lock(&dev->struct_mutex); |
| 178 | if (*value == 1) { |
| 179 | /* wants rights */ |
| 180 | if (!*owner) |
| 181 | *owner = applier; |
| 182 | } else if (*value == 0) { |
| 183 | /* revokes rights */ |
| 184 | if (*owner == applier) |
| 185 | *owner = NULL; |
| 186 | } |
| 187 | *value = *owner == applier ? 1 : 0; |
| 188 | mutex_unlock(&dev->struct_mutex); |
| 189 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 190 | |
| 191 | /* |
Marek Olšák | 9eba4a9 | 2011-01-05 05:46:48 +0100 | [diff] [blame] | 192 | * Userspace get information ioctl |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 193 | */ |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 194 | /** |
| 195 | * radeon_info_ioctl - answer a device specific request. |
| 196 | * |
| 197 | * @rdev: radeon device pointer |
| 198 | * @data: request object |
| 199 | * @filp: drm filp |
| 200 | * |
| 201 | * This function is used to pass device specific parameters to the userspace |
| 202 | * drivers. Examples include: pci device id, pipeline parms, tiling params, |
| 203 | * etc. (all asics). |
| 204 | * Returns 0 on success, -EINVAL on failure. |
| 205 | */ |
Rashika Kheria | 5520345 | 2014-01-06 20:53:07 +0530 | [diff] [blame] | 206 | static int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 207 | { |
| 208 | struct radeon_device *rdev = dev->dev_private; |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 209 | struct drm_radeon_info *info = data; |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 210 | struct radeon_mode_info *minfo = &rdev->mode_info; |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 211 | uint32_t *value, value_tmp, *value_ptr, value_size; |
| 212 | uint64_t value64; |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 213 | struct drm_crtc *crtc; |
| 214 | int i, found; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 215 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 216 | value_ptr = (uint32_t *)((unsigned long)info->value); |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 217 | value = &value_tmp; |
| 218 | value_size = sizeof(uint32_t); |
Dr. David Alan Gilbert | d8ab355 | 2010-08-02 09:43:52 +1000 | [diff] [blame] | 219 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 220 | switch (info->request) { |
| 221 | case RADEON_INFO_DEVICE_ID: |
Ville Syrjälä | ffbab09b | 2013-10-04 14:53:40 +0300 | [diff] [blame] | 222 | *value = dev->pdev->device; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 223 | break; |
| 224 | case RADEON_INFO_NUM_GB_PIPES: |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 225 | *value = rdev->num_gb_pipes; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 226 | break; |
Alex Deucher | f779b3e | 2009-08-19 19:11:39 -0400 | [diff] [blame] | 227 | case RADEON_INFO_NUM_Z_PIPES: |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 228 | *value = rdev->num_z_pipes; |
Alex Deucher | f779b3e | 2009-08-19 19:11:39 -0400 | [diff] [blame] | 229 | break; |
Jerome Glisse | 733289c | 2009-09-16 15:24:21 +0200 | [diff] [blame] | 230 | case RADEON_INFO_ACCEL_WORKING: |
Alex Deucher | 148a03b | 2010-06-03 19:00:03 -0400 | [diff] [blame] | 231 | /* xf86-video-ati 6.13.0 relies on this being false for evergreen */ |
| 232 | if ((rdev->family >= CHIP_CEDAR) && (rdev->family <= CHIP_HEMLOCK)) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 233 | *value = false; |
Alex Deucher | 148a03b | 2010-06-03 19:00:03 -0400 | [diff] [blame] | 234 | else |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 235 | *value = rdev->accel_working; |
Jerome Glisse | 733289c | 2009-09-16 15:24:21 +0200 | [diff] [blame] | 236 | break; |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 237 | case RADEON_INFO_CRTC_FROM_ID: |
Daniel Vetter | 1d6ac18 | 2013-12-11 11:34:44 +0100 | [diff] [blame] | 238 | if (copy_from_user(value, value_ptr, sizeof(uint32_t))) { |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 239 | DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); |
| 240 | return -EFAULT; |
| 241 | } |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 242 | for (i = 0, found = 0; i < rdev->num_crtc; i++) { |
| 243 | crtc = (struct drm_crtc *)minfo->crtcs[i]; |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 244 | if (crtc && crtc->base.id == *value) { |
Alex Deucher | 0baf2d8 | 2010-07-21 14:05:35 -0400 | [diff] [blame] | 245 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 246 | *value = radeon_crtc->crtc_id; |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 247 | found = 1; |
| 248 | break; |
| 249 | } |
| 250 | } |
| 251 | if (!found) { |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 252 | DRM_DEBUG_KMS("unknown crtc id %d\n", *value); |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 253 | return -EINVAL; |
| 254 | } |
| 255 | break; |
Alex Deucher | 148a03b | 2010-06-03 19:00:03 -0400 | [diff] [blame] | 256 | case RADEON_INFO_ACCEL_WORKING2: |
Alex Deucher | 3c64bd2 | 2014-08-01 20:05:30 +0200 | [diff] [blame] | 257 | if (rdev->family == CHIP_HAWAII) { |
| 258 | if (rdev->accel_working) |
| 259 | *value = 2; |
| 260 | else |
| 261 | *value = 0; |
| 262 | } else { |
| 263 | *value = rdev->accel_working; |
| 264 | } |
Alex Deucher | 148a03b | 2010-06-03 19:00:03 -0400 | [diff] [blame] | 265 | break; |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 266 | case RADEON_INFO_TILING_CONFIG: |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 267 | if (rdev->family >= CHIP_BONAIRE) |
| 268 | *value = rdev->config.cik.tile_config; |
| 269 | else if (rdev->family >= CHIP_TAHITI) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 270 | *value = rdev->config.si.tile_config; |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 271 | else if (rdev->family >= CHIP_CAYMAN) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 272 | *value = rdev->config.cayman.tile_config; |
Alex Deucher | fecf1d0 | 2011-03-02 20:07:29 -0500 | [diff] [blame] | 273 | else if (rdev->family >= CHIP_CEDAR) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 274 | *value = rdev->config.evergreen.tile_config; |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 275 | else if (rdev->family >= CHIP_RV770) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 276 | *value = rdev->config.rv770.tile_config; |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 277 | else if (rdev->family >= CHIP_R600) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 278 | *value = rdev->config.r600.tile_config; |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 279 | else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 280 | DRM_DEBUG_KMS("tiling config is r6xx+ only!\n"); |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 281 | return -EINVAL; |
| 282 | } |
Alex Deucher | b824b36 | 2010-08-12 08:25:47 -0400 | [diff] [blame] | 283 | break; |
Dave Airlie | ab9e1f5 | 2010-07-13 11:11:11 +1000 | [diff] [blame] | 284 | case RADEON_INFO_WANT_HYPERZ: |
Marek Olšák | 43861f7 | 2010-08-07 03:36:34 +0200 | [diff] [blame] | 285 | /* The "value" here is both an input and output parameter. |
| 286 | * If the input value is 1, filp requests hyper-z access. |
| 287 | * If the input value is 0, filp revokes its hyper-z access. |
| 288 | * |
| 289 | * When returning, the value is 1 if filp owns hyper-z access, |
| 290 | * 0 otherwise. */ |
Daniel Vetter | 1d6ac18 | 2013-12-11 11:34:44 +0100 | [diff] [blame] | 291 | if (copy_from_user(value, value_ptr, sizeof(uint32_t))) { |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 292 | DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); |
| 293 | return -EFAULT; |
| 294 | } |
| 295 | if (*value >= 2) { |
| 296 | DRM_DEBUG_KMS("WANT_HYPERZ: invalid value %d\n", *value); |
Marek Olšák | 43861f7 | 2010-08-07 03:36:34 +0200 | [diff] [blame] | 297 | return -EINVAL; |
Dave Airlie | ab9e1f5 | 2010-07-13 11:11:11 +1000 | [diff] [blame] | 298 | } |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 299 | radeon_set_filp_rights(dev, &rdev->hyperz_filp, filp, value); |
Marek Olšák | 9eba4a9 | 2011-01-05 05:46:48 +0100 | [diff] [blame] | 300 | break; |
| 301 | case RADEON_INFO_WANT_CMASK: |
| 302 | /* The same logic as Hyper-Z. */ |
Daniel Vetter | 1d6ac18 | 2013-12-11 11:34:44 +0100 | [diff] [blame] | 303 | if (copy_from_user(value, value_ptr, sizeof(uint32_t))) { |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 304 | DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); |
| 305 | return -EFAULT; |
| 306 | } |
| 307 | if (*value >= 2) { |
| 308 | DRM_DEBUG_KMS("WANT_CMASK: invalid value %d\n", *value); |
Marek Olšák | 9eba4a9 | 2011-01-05 05:46:48 +0100 | [diff] [blame] | 309 | return -EINVAL; |
Marek Olšák | 43861f7 | 2010-08-07 03:36:34 +0200 | [diff] [blame] | 310 | } |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 311 | radeon_set_filp_rights(dev, &rdev->cmask_filp, filp, value); |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 312 | break; |
Alex Deucher | 58bbf01 | 2011-01-24 17:14:26 -0500 | [diff] [blame] | 313 | case RADEON_INFO_CLOCK_CRYSTAL_FREQ: |
| 314 | /* return clock value in KHz */ |
Alex Deucher | 454d2e2 | 2013-02-14 10:04:02 -0500 | [diff] [blame] | 315 | if (rdev->asic->get_xclk) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 316 | *value = radeon_get_xclk(rdev) * 10; |
Alex Deucher | 454d2e2 | 2013-02-14 10:04:02 -0500 | [diff] [blame] | 317 | else |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 318 | *value = rdev->clock.spll.reference_freq * 10; |
Alex Deucher | 58bbf01 | 2011-01-24 17:14:26 -0500 | [diff] [blame] | 319 | break; |
Dave Airlie | 486af18 | 2011-03-01 14:32:27 +1000 | [diff] [blame] | 320 | case RADEON_INFO_NUM_BACKENDS: |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 321 | if (rdev->family >= CHIP_BONAIRE) |
| 322 | *value = rdev->config.cik.max_backends_per_se * |
| 323 | rdev->config.cik.max_shader_engines; |
| 324 | else if (rdev->family >= CHIP_TAHITI) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 325 | *value = rdev->config.si.max_backends_per_se * |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 326 | rdev->config.si.max_shader_engines; |
| 327 | else if (rdev->family >= CHIP_CAYMAN) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 328 | *value = rdev->config.cayman.max_backends_per_se * |
Alex Deucher | fecf1d0 | 2011-03-02 20:07:29 -0500 | [diff] [blame] | 329 | rdev->config.cayman.max_shader_engines; |
| 330 | else if (rdev->family >= CHIP_CEDAR) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 331 | *value = rdev->config.evergreen.max_backends; |
Dave Airlie | 486af18 | 2011-03-01 14:32:27 +1000 | [diff] [blame] | 332 | else if (rdev->family >= CHIP_RV770) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 333 | *value = rdev->config.rv770.max_backends; |
Dave Airlie | 486af18 | 2011-03-01 14:32:27 +1000 | [diff] [blame] | 334 | else if (rdev->family >= CHIP_R600) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 335 | *value = rdev->config.r600.max_backends; |
Dave Airlie | 486af18 | 2011-03-01 14:32:27 +1000 | [diff] [blame] | 336 | else { |
| 337 | return -EINVAL; |
| 338 | } |
| 339 | break; |
Alex Deucher | 6565945 | 2011-04-26 13:27:43 -0400 | [diff] [blame] | 340 | case RADEON_INFO_NUM_TILE_PIPES: |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 341 | if (rdev->family >= CHIP_BONAIRE) |
| 342 | *value = rdev->config.cik.max_tile_pipes; |
| 343 | else if (rdev->family >= CHIP_TAHITI) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 344 | *value = rdev->config.si.max_tile_pipes; |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 345 | else if (rdev->family >= CHIP_CAYMAN) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 346 | *value = rdev->config.cayman.max_tile_pipes; |
Alex Deucher | 6565945 | 2011-04-26 13:27:43 -0400 | [diff] [blame] | 347 | else if (rdev->family >= CHIP_CEDAR) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 348 | *value = rdev->config.evergreen.max_tile_pipes; |
Alex Deucher | 6565945 | 2011-04-26 13:27:43 -0400 | [diff] [blame] | 349 | else if (rdev->family >= CHIP_RV770) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 350 | *value = rdev->config.rv770.max_tile_pipes; |
Alex Deucher | 6565945 | 2011-04-26 13:27:43 -0400 | [diff] [blame] | 351 | else if (rdev->family >= CHIP_R600) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 352 | *value = rdev->config.r600.max_tile_pipes; |
Alex Deucher | 6565945 | 2011-04-26 13:27:43 -0400 | [diff] [blame] | 353 | else { |
| 354 | return -EINVAL; |
| 355 | } |
| 356 | break; |
Alex Deucher | 8aeb96f | 2011-05-03 19:28:02 -0400 | [diff] [blame] | 357 | case RADEON_INFO_FUSION_GART_WORKING: |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 358 | *value = 1; |
Alex Deucher | 8aeb96f | 2011-05-03 19:28:02 -0400 | [diff] [blame] | 359 | break; |
Alex Deucher | e55b942 | 2011-07-15 19:53:52 +0000 | [diff] [blame] | 360 | case RADEON_INFO_BACKEND_MAP: |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 361 | if (rdev->family >= CHIP_BONAIRE) |
Michel Dänzer | 1ddce27 | 2013-11-18 18:25:59 +0900 | [diff] [blame] | 362 | *value = rdev->config.cik.backend_map; |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 363 | else if (rdev->family >= CHIP_TAHITI) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 364 | *value = rdev->config.si.backend_map; |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 365 | else if (rdev->family >= CHIP_CAYMAN) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 366 | *value = rdev->config.cayman.backend_map; |
Alex Deucher | e55b942 | 2011-07-15 19:53:52 +0000 | [diff] [blame] | 367 | else if (rdev->family >= CHIP_CEDAR) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 368 | *value = rdev->config.evergreen.backend_map; |
Alex Deucher | e55b942 | 2011-07-15 19:53:52 +0000 | [diff] [blame] | 369 | else if (rdev->family >= CHIP_RV770) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 370 | *value = rdev->config.rv770.backend_map; |
Alex Deucher | e55b942 | 2011-07-15 19:53:52 +0000 | [diff] [blame] | 371 | else if (rdev->family >= CHIP_R600) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 372 | *value = rdev->config.r600.backend_map; |
Alex Deucher | e55b942 | 2011-07-15 19:53:52 +0000 | [diff] [blame] | 373 | else { |
| 374 | return -EINVAL; |
| 375 | } |
| 376 | break; |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 377 | case RADEON_INFO_VA_START: |
| 378 | /* this is where we report if vm is supported or not */ |
| 379 | if (rdev->family < CHIP_CAYMAN) |
| 380 | return -EINVAL; |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 381 | *value = RADEON_VA_RESERVED_SIZE; |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 382 | break; |
| 383 | case RADEON_INFO_IB_VM_MAX_SIZE: |
| 384 | /* this is where we report if vm is supported or not */ |
| 385 | if (rdev->family < CHIP_CAYMAN) |
| 386 | return -EINVAL; |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 387 | *value = RADEON_IB_VM_MAX_SIZE; |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 388 | break; |
Tom Stellard | 609c1e1 | 2012-03-20 17:17:55 -0400 | [diff] [blame] | 389 | case RADEON_INFO_MAX_PIPES: |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 390 | if (rdev->family >= CHIP_BONAIRE) |
| 391 | *value = rdev->config.cik.max_cu_per_sh; |
| 392 | else if (rdev->family >= CHIP_TAHITI) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 393 | *value = rdev->config.si.max_cu_per_sh; |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 394 | else if (rdev->family >= CHIP_CAYMAN) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 395 | *value = rdev->config.cayman.max_pipes_per_simd; |
Tom Stellard | 609c1e1 | 2012-03-20 17:17:55 -0400 | [diff] [blame] | 396 | else if (rdev->family >= CHIP_CEDAR) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 397 | *value = rdev->config.evergreen.max_pipes; |
Tom Stellard | 609c1e1 | 2012-03-20 17:17:55 -0400 | [diff] [blame] | 398 | else if (rdev->family >= CHIP_RV770) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 399 | *value = rdev->config.rv770.max_pipes; |
Tom Stellard | 609c1e1 | 2012-03-20 17:17:55 -0400 | [diff] [blame] | 400 | else if (rdev->family >= CHIP_R600) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 401 | *value = rdev->config.r600.max_pipes; |
Tom Stellard | 609c1e1 | 2012-03-20 17:17:55 -0400 | [diff] [blame] | 402 | else { |
| 403 | return -EINVAL; |
| 404 | } |
| 405 | break; |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 406 | case RADEON_INFO_TIMESTAMP: |
| 407 | if (rdev->family < CHIP_R600) { |
| 408 | DRM_DEBUG_KMS("timestamp is r6xx+ only!\n"); |
| 409 | return -EINVAL; |
| 410 | } |
| 411 | value = (uint32_t*)&value64; |
| 412 | value_size = sizeof(uint64_t); |
| 413 | value64 = radeon_get_gpu_clock_counter(rdev); |
| 414 | break; |
Alex Deucher | 2e1a767 | 2012-12-04 12:55:37 -0500 | [diff] [blame] | 415 | case RADEON_INFO_MAX_SE: |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 416 | if (rdev->family >= CHIP_BONAIRE) |
| 417 | *value = rdev->config.cik.max_shader_engines; |
| 418 | else if (rdev->family >= CHIP_TAHITI) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 419 | *value = rdev->config.si.max_shader_engines; |
Alex Deucher | 2e1a767 | 2012-12-04 12:55:37 -0500 | [diff] [blame] | 420 | else if (rdev->family >= CHIP_CAYMAN) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 421 | *value = rdev->config.cayman.max_shader_engines; |
Alex Deucher | 2e1a767 | 2012-12-04 12:55:37 -0500 | [diff] [blame] | 422 | else if (rdev->family >= CHIP_CEDAR) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 423 | *value = rdev->config.evergreen.num_ses; |
Alex Deucher | 2e1a767 | 2012-12-04 12:55:37 -0500 | [diff] [blame] | 424 | else |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 425 | *value = 1; |
Alex Deucher | 2e1a767 | 2012-12-04 12:55:37 -0500 | [diff] [blame] | 426 | break; |
| 427 | case RADEON_INFO_MAX_SH_PER_SE: |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 428 | if (rdev->family >= CHIP_BONAIRE) |
| 429 | *value = rdev->config.cik.max_sh_per_se; |
| 430 | else if (rdev->family >= CHIP_TAHITI) |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 431 | *value = rdev->config.si.max_sh_per_se; |
Alex Deucher | 2e1a767 | 2012-12-04 12:55:37 -0500 | [diff] [blame] | 432 | else |
| 433 | return -EINVAL; |
| 434 | break; |
Samuel Li | a0a53aa | 2013-04-08 17:25:47 -0400 | [diff] [blame] | 435 | case RADEON_INFO_FASTFB_WORKING: |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 436 | *value = rdev->fastfb_working; |
Samuel Li | a0a53aa | 2013-04-08 17:25:47 -0400 | [diff] [blame] | 437 | break; |
Christian König | 902aaef | 2013-04-09 10:35:42 -0400 | [diff] [blame] | 438 | case RADEON_INFO_RING_WORKING: |
Daniel Vetter | 1d6ac18 | 2013-12-11 11:34:44 +0100 | [diff] [blame] | 439 | if (copy_from_user(value, value_ptr, sizeof(uint32_t))) { |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 440 | DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); |
| 441 | return -EFAULT; |
| 442 | } |
| 443 | switch (*value) { |
Christian König | 902aaef | 2013-04-09 10:35:42 -0400 | [diff] [blame] | 444 | case RADEON_CS_RING_GFX: |
| 445 | case RADEON_CS_RING_COMPUTE: |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 446 | *value = rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready; |
Christian König | 902aaef | 2013-04-09 10:35:42 -0400 | [diff] [blame] | 447 | break; |
| 448 | case RADEON_CS_RING_DMA: |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 449 | *value = rdev->ring[R600_RING_TYPE_DMA_INDEX].ready; |
| 450 | *value |= rdev->ring[CAYMAN_RING_TYPE_DMA1_INDEX].ready; |
Christian König | 902aaef | 2013-04-09 10:35:42 -0400 | [diff] [blame] | 451 | break; |
| 452 | case RADEON_CS_RING_UVD: |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 453 | *value = rdev->ring[R600_RING_TYPE_UVD_INDEX].ready; |
Christian König | 902aaef | 2013-04-09 10:35:42 -0400 | [diff] [blame] | 454 | break; |
Christian König | f7ba8b0 | 2014-01-27 10:16:06 -0700 | [diff] [blame] | 455 | case RADEON_CS_RING_VCE: |
| 456 | *value = rdev->ring[TN_RING_TYPE_VCE1_INDEX].ready; |
| 457 | break; |
Christian König | 902aaef | 2013-04-09 10:35:42 -0400 | [diff] [blame] | 458 | default: |
| 459 | return -EINVAL; |
| 460 | } |
| 461 | break; |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 462 | case RADEON_INFO_SI_TILE_MODE_ARRAY: |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 463 | if (rdev->family >= CHIP_BONAIRE) { |
Alex Deucher | 39aee49 | 2013-04-10 13:41:25 -0400 | [diff] [blame] | 464 | value = rdev->config.cik.tile_mode_array; |
| 465 | value_size = sizeof(uint32_t)*32; |
| 466 | } else if (rdev->family >= CHIP_TAHITI) { |
| 467 | value = rdev->config.si.tile_mode_array; |
| 468 | value_size = sizeof(uint32_t)*32; |
| 469 | } else { |
| 470 | DRM_DEBUG_KMS("tile mode array is si+ only!\n"); |
Alex Deucher | 64f759c | 2012-07-06 17:40:32 -0400 | [diff] [blame] | 471 | return -EINVAL; |
| 472 | } |
Jerome Glisse | 64d7b8b | 2013-04-09 11:17:08 -0400 | [diff] [blame] | 473 | break; |
Michel Dänzer | 32f79a8 | 2013-11-18 18:26:00 +0900 | [diff] [blame] | 474 | case RADEON_INFO_CIK_MACROTILE_MODE_ARRAY: |
| 475 | if (rdev->family >= CHIP_BONAIRE) { |
| 476 | value = rdev->config.cik.macrotile_mode_array; |
| 477 | value_size = sizeof(uint32_t)*16; |
| 478 | } else { |
| 479 | DRM_DEBUG_KMS("macrotile mode array is cik+ only!\n"); |
| 480 | return -EINVAL; |
| 481 | } |
| 482 | break; |
Tom Stellard | e5b9e75 | 2013-08-16 17:47:39 -0400 | [diff] [blame] | 483 | case RADEON_INFO_SI_CP_DMA_COMPUTE: |
| 484 | *value = 1; |
| 485 | break; |
Marek Olšák | 439a1cf | 2013-12-22 02:18:01 +0100 | [diff] [blame] | 486 | case RADEON_INFO_SI_BACKEND_ENABLED_MASK: |
| 487 | if (rdev->family >= CHIP_BONAIRE) { |
| 488 | *value = rdev->config.cik.backend_enable_mask; |
| 489 | } else if (rdev->family >= CHIP_TAHITI) { |
| 490 | *value = rdev->config.si.backend_enable_mask; |
| 491 | } else { |
| 492 | DRM_DEBUG_KMS("BACKEND_ENABLED_MASK is si+ only!\n"); |
| 493 | } |
| 494 | break; |
Alex Deucher | f5f1f89 | 2014-01-20 18:20:29 -0500 | [diff] [blame] | 495 | case RADEON_INFO_MAX_SCLK: |
| 496 | if ((rdev->pm.pm_method == PM_METHOD_DPM) && |
| 497 | rdev->pm.dpm_enabled) |
| 498 | *value = rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac.sclk * 10; |
| 499 | else |
| 500 | *value = rdev->pm.default_sclk * 10; |
| 501 | break; |
Christian König | 98ccc29 | 2014-01-23 09:50:49 -0700 | [diff] [blame] | 502 | case RADEON_INFO_VCE_FW_VERSION: |
| 503 | *value = rdev->vce.fw_version; |
| 504 | break; |
| 505 | case RADEON_INFO_VCE_FB_VERSION: |
| 506 | *value = rdev->vce.fb_version; |
| 507 | break; |
Marek Olšák | 67e8e3f | 2014-03-02 00:56:18 +0100 | [diff] [blame] | 508 | case RADEON_INFO_NUM_BYTES_MOVED: |
| 509 | value = (uint32_t*)&value64; |
| 510 | value_size = sizeof(uint64_t); |
| 511 | value64 = atomic64_read(&rdev->num_bytes_moved); |
| 512 | break; |
| 513 | case RADEON_INFO_VRAM_USAGE: |
| 514 | value = (uint32_t*)&value64; |
| 515 | value_size = sizeof(uint64_t); |
| 516 | value64 = atomic64_read(&rdev->vram_usage); |
| 517 | break; |
| 518 | case RADEON_INFO_GTT_USAGE: |
| 519 | value = (uint32_t*)&value64; |
| 520 | value_size = sizeof(uint64_t); |
| 521 | value64 = atomic64_read(&rdev->gtt_usage); |
| 522 | break; |
Alex Deucher | 65fcf66 | 2014-06-02 16:13:21 -0400 | [diff] [blame] | 523 | case RADEON_INFO_ACTIVE_CU_COUNT: |
| 524 | if (rdev->family >= CHIP_BONAIRE) |
| 525 | *value = rdev->config.cik.active_cus; |
| 526 | else if (rdev->family >= CHIP_TAHITI) |
| 527 | *value = rdev->config.si.active_cus; |
| 528 | else if (rdev->family >= CHIP_CAYMAN) |
| 529 | *value = rdev->config.cayman.active_simds; |
| 530 | else if (rdev->family >= CHIP_CEDAR) |
| 531 | *value = rdev->config.evergreen.active_simds; |
| 532 | else if (rdev->family >= CHIP_RV770) |
| 533 | *value = rdev->config.rv770.active_simds; |
| 534 | else if (rdev->family >= CHIP_R600) |
| 535 | *value = rdev->config.r600.active_simds; |
| 536 | else |
| 537 | *value = 1; |
| 538 | break; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 539 | default: |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 540 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 541 | return -EINVAL; |
| 542 | } |
Daniel Vetter | 1d6ac18 | 2013-12-11 11:34:44 +0100 | [diff] [blame] | 543 | if (copy_to_user(value_ptr, (char*)value, value_size)) { |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 544 | DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 545 | return -EFAULT; |
| 546 | } |
| 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | |
| 551 | /* |
| 552 | * Outdated mess for old drm with Xorg being in charge (void function now). |
| 553 | */ |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 554 | /** |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 555 | * radeon_driver_firstopen_kms - drm callback for last close |
| 556 | * |
| 557 | * @dev: drm dev pointer |
| 558 | * |
| 559 | * Switch vga switcheroo state after last close (all asics). |
| 560 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 561 | void radeon_driver_lastclose_kms(struct drm_device *dev) |
| 562 | { |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 563 | vga_switcheroo_process_delayed_switch(); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 564 | } |
| 565 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 566 | /** |
| 567 | * radeon_driver_open_kms - drm callback for open |
| 568 | * |
| 569 | * @dev: drm dev pointer |
| 570 | * @file_priv: drm file |
| 571 | * |
| 572 | * On device open, init vm on cayman+ (all asics). |
| 573 | * Returns 0 on success, error on failure. |
| 574 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 575 | int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) |
| 576 | { |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 577 | struct radeon_device *rdev = dev->dev_private; |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 578 | int r; |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 579 | |
| 580 | file_priv->driver_priv = NULL; |
| 581 | |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 582 | r = pm_runtime_get_sync(dev->dev); |
| 583 | if (r < 0) |
| 584 | return r; |
| 585 | |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 586 | /* new gpu have virtual address space support */ |
| 587 | if (rdev->family >= CHIP_CAYMAN) { |
| 588 | struct radeon_fpriv *fpriv; |
Christian König | cc9e67e | 2014-07-18 13:48:10 +0200 | [diff] [blame] | 589 | struct radeon_vm *vm; |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 590 | int r; |
| 591 | |
| 592 | fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); |
| 593 | if (unlikely(!fpriv)) { |
| 594 | return -ENOMEM; |
| 595 | } |
| 596 | |
Christian König | cc9e67e | 2014-07-18 13:48:10 +0200 | [diff] [blame] | 597 | vm = &fpriv->vm; |
| 598 | r = radeon_vm_init(rdev, vm); |
Quentin Casasnovas | 74073c9 | 2014-03-18 17:16:52 +0100 | [diff] [blame] | 599 | if (r) { |
| 600 | kfree(fpriv); |
Christian König | 6d2f294 | 2014-02-20 13:42:17 +0100 | [diff] [blame] | 601 | return r; |
Quentin Casasnovas | 74073c9 | 2014-03-18 17:16:52 +0100 | [diff] [blame] | 602 | } |
Christian König | d72d43c | 2012-10-09 13:31:18 +0200 | [diff] [blame] | 603 | |
Jérôme Glisse | 24f47ac | 2014-05-07 16:35:24 -0400 | [diff] [blame] | 604 | if (rdev->accel_working) { |
| 605 | r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); |
| 606 | if (r) { |
Christian König | cc9e67e | 2014-07-18 13:48:10 +0200 | [diff] [blame] | 607 | radeon_vm_fini(rdev, vm); |
Jérôme Glisse | 24f47ac | 2014-05-07 16:35:24 -0400 | [diff] [blame] | 608 | kfree(fpriv); |
| 609 | return r; |
| 610 | } |
| 611 | |
| 612 | /* map the ib pool buffer read only into |
| 613 | * virtual address space */ |
Christian König | cc9e67e | 2014-07-18 13:48:10 +0200 | [diff] [blame] | 614 | vm->ib_bo_va = radeon_vm_bo_add(rdev, vm, |
| 615 | rdev->ring_tmp_bo.bo); |
| 616 | r = radeon_vm_bo_set_addr(rdev, vm->ib_bo_va, |
| 617 | RADEON_VA_IB_OFFSET, |
Jérôme Glisse | 24f47ac | 2014-05-07 16:35:24 -0400 | [diff] [blame] | 618 | RADEON_VM_PAGE_READABLE | |
| 619 | RADEON_VM_PAGE_SNOOPED); |
| 620 | |
| 621 | radeon_bo_unreserve(rdev->ring_tmp_bo.bo); |
| 622 | if (r) { |
Christian König | cc9e67e | 2014-07-18 13:48:10 +0200 | [diff] [blame] | 623 | radeon_vm_fini(rdev, vm); |
Jérôme Glisse | 24f47ac | 2014-05-07 16:35:24 -0400 | [diff] [blame] | 624 | kfree(fpriv); |
| 625 | return r; |
| 626 | } |
Quentin Casasnovas | 74073c9 | 2014-03-18 17:16:52 +0100 | [diff] [blame] | 627 | } |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 628 | file_priv->driver_priv = fpriv; |
| 629 | } |
Dave Airlie | 10ebc0b | 2012-09-17 14:40:31 +1000 | [diff] [blame] | 630 | |
| 631 | pm_runtime_mark_last_busy(dev->dev); |
| 632 | pm_runtime_put_autosuspend(dev->dev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 633 | return 0; |
| 634 | } |
| 635 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 636 | /** |
| 637 | * radeon_driver_postclose_kms - drm callback for post close |
| 638 | * |
| 639 | * @dev: drm dev pointer |
| 640 | * @file_priv: drm file |
| 641 | * |
| 642 | * On device post close, tear down vm on cayman+ (all asics). |
| 643 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 644 | void radeon_driver_postclose_kms(struct drm_device *dev, |
| 645 | struct drm_file *file_priv) |
| 646 | { |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 647 | struct radeon_device *rdev = dev->dev_private; |
| 648 | |
| 649 | /* new gpu have virtual address space support */ |
| 650 | if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) { |
| 651 | struct radeon_fpriv *fpriv = file_priv->driver_priv; |
Christian König | cc9e67e | 2014-07-18 13:48:10 +0200 | [diff] [blame] | 652 | struct radeon_vm *vm = &fpriv->vm; |
Christian König | d72d43c | 2012-10-09 13:31:18 +0200 | [diff] [blame] | 653 | int r; |
| 654 | |
Jérôme Glisse | 24f47ac | 2014-05-07 16:35:24 -0400 | [diff] [blame] | 655 | if (rdev->accel_working) { |
| 656 | r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); |
| 657 | if (!r) { |
Christian König | cc9e67e | 2014-07-18 13:48:10 +0200 | [diff] [blame] | 658 | if (vm->ib_bo_va) |
| 659 | radeon_vm_bo_rmv(rdev, vm->ib_bo_va); |
Jérôme Glisse | 24f47ac | 2014-05-07 16:35:24 -0400 | [diff] [blame] | 660 | radeon_bo_unreserve(rdev->ring_tmp_bo.bo); |
| 661 | } |
Christian König | d72d43c | 2012-10-09 13:31:18 +0200 | [diff] [blame] | 662 | } |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 663 | |
Christian König | cc9e67e | 2014-07-18 13:48:10 +0200 | [diff] [blame] | 664 | radeon_vm_fini(rdev, vm); |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 665 | kfree(fpriv); |
| 666 | file_priv->driver_priv = NULL; |
| 667 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 668 | } |
| 669 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 670 | /** |
| 671 | * radeon_driver_preclose_kms - drm callback for pre close |
| 672 | * |
| 673 | * @dev: drm dev pointer |
| 674 | * @file_priv: drm file |
| 675 | * |
| 676 | * On device pre close, tear down hyperz and cmask filps on r1xx-r5xx |
| 677 | * (all asics). |
| 678 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 679 | void radeon_driver_preclose_kms(struct drm_device *dev, |
| 680 | struct drm_file *file_priv) |
| 681 | { |
Dave Airlie | ab9e1f5 | 2010-07-13 11:11:11 +1000 | [diff] [blame] | 682 | struct radeon_device *rdev = dev->dev_private; |
| 683 | if (rdev->hyperz_filp == file_priv) |
| 684 | rdev->hyperz_filp = NULL; |
Marek Olšák | dca0d61 | 2011-01-27 22:46:15 +0100 | [diff] [blame] | 685 | if (rdev->cmask_filp == file_priv) |
| 686 | rdev->cmask_filp = NULL; |
Christian König | f2ba57b | 2013-04-08 12:41:29 +0200 | [diff] [blame] | 687 | radeon_uvd_free_handles(rdev, file_priv); |
Christian König | d93f793 | 2013-05-23 12:10:04 +0200 | [diff] [blame] | 688 | radeon_vce_free_handles(rdev, file_priv); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 689 | } |
| 690 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 691 | /* |
| 692 | * VBlank related functions. |
| 693 | */ |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 694 | /** |
| 695 | * radeon_get_vblank_counter_kms - get frame count |
| 696 | * |
| 697 | * @dev: drm dev pointer |
| 698 | * @crtc: crtc to get the frame count from |
| 699 | * |
| 700 | * Gets the frame count on the requested crtc (all asics). |
| 701 | * Returns frame count on success, -EINVAL on failure. |
| 702 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 703 | u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc) |
| 704 | { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 705 | struct radeon_device *rdev = dev->dev_private; |
| 706 | |
Dave Airlie | 9c950a4 | 2010-04-23 13:21:58 +1000 | [diff] [blame] | 707 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 708 | DRM_ERROR("Invalid crtc %d\n", crtc); |
| 709 | return -EINVAL; |
| 710 | } |
| 711 | |
| 712 | return radeon_get_vblank_counter(rdev, crtc); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 713 | } |
| 714 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 715 | /** |
| 716 | * radeon_enable_vblank_kms - enable vblank interrupt |
| 717 | * |
| 718 | * @dev: drm dev pointer |
| 719 | * @crtc: crtc to enable vblank interrupt for |
| 720 | * |
| 721 | * Enable the interrupt on the requested crtc (all asics). |
| 722 | * Returns 0 on success, -EINVAL on failure. |
| 723 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 724 | int radeon_enable_vblank_kms(struct drm_device *dev, int crtc) |
| 725 | { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 726 | struct radeon_device *rdev = dev->dev_private; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 727 | unsigned long irqflags; |
| 728 | int r; |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 729 | |
Dave Airlie | 9c950a4 | 2010-04-23 13:21:58 +1000 | [diff] [blame] | 730 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 731 | DRM_ERROR("Invalid crtc %d\n", crtc); |
| 732 | return -EINVAL; |
| 733 | } |
| 734 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 735 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 736 | rdev->irq.crtc_vblank_int[crtc] = true; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 737 | r = radeon_irq_set(rdev); |
| 738 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
| 739 | return r; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 740 | } |
| 741 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 742 | /** |
| 743 | * radeon_disable_vblank_kms - disable vblank interrupt |
| 744 | * |
| 745 | * @dev: drm dev pointer |
| 746 | * @crtc: crtc to disable vblank interrupt for |
| 747 | * |
| 748 | * Disable the interrupt on the requested crtc (all asics). |
| 749 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 750 | void radeon_disable_vblank_kms(struct drm_device *dev, int crtc) |
| 751 | { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 752 | struct radeon_device *rdev = dev->dev_private; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 753 | unsigned long irqflags; |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 754 | |
Dave Airlie | 9c950a4 | 2010-04-23 13:21:58 +1000 | [diff] [blame] | 755 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 756 | DRM_ERROR("Invalid crtc %d\n", crtc); |
| 757 | return; |
| 758 | } |
| 759 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 760 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 761 | rdev->irq.crtc_vblank_int[crtc] = false; |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 762 | radeon_irq_set(rdev); |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 763 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 764 | } |
| 765 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 766 | /** |
| 767 | * radeon_get_vblank_timestamp_kms - get vblank timestamp |
| 768 | * |
| 769 | * @dev: drm dev pointer |
| 770 | * @crtc: crtc to get the timestamp for |
| 771 | * @max_error: max error |
| 772 | * @vblank_time: time value |
| 773 | * @flags: flags passed to the driver |
| 774 | * |
| 775 | * Gets the timestamp on the requested crtc based on the |
| 776 | * scanout position. (all asics). |
| 777 | * Returns postive status flags on success, negative error on failure. |
| 778 | */ |
Mario Kleiner | f5a8020 | 2010-10-23 04:42:17 +0200 | [diff] [blame] | 779 | int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc, |
| 780 | int *max_error, |
| 781 | struct timeval *vblank_time, |
| 782 | unsigned flags) |
| 783 | { |
| 784 | struct drm_crtc *drmcrtc; |
| 785 | struct radeon_device *rdev = dev->dev_private; |
| 786 | |
| 787 | if (crtc < 0 || crtc >= dev->num_crtcs) { |
| 788 | DRM_ERROR("Invalid crtc %d\n", crtc); |
| 789 | return -EINVAL; |
| 790 | } |
| 791 | |
| 792 | /* Get associated drm_crtc: */ |
| 793 | drmcrtc = &rdev->mode_info.crtcs[crtc]->base; |
| 794 | |
| 795 | /* Helper routine in DRM core does all the work: */ |
| 796 | return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error, |
| 797 | vblank_time, flags, |
Ville Syrjälä | 7da903e | 2013-10-26 17:57:31 +0300 | [diff] [blame] | 798 | drmcrtc, &drmcrtc->hwmode); |
Mario Kleiner | f5a8020 | 2010-10-23 04:42:17 +0200 | [diff] [blame] | 799 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 800 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 801 | #define KMS_INVALID_IOCTL(name) \ |
Rashika Kheria | f6e2e40 | 2014-01-06 21:06:44 +0530 | [diff] [blame] | 802 | static int name(struct drm_device *dev, void *data, struct drm_file \ |
| 803 | *file_priv) \ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 804 | { \ |
| 805 | DRM_ERROR("invalid ioctl with kms %s\n", __func__); \ |
| 806 | return -EINVAL; \ |
| 807 | } |
| 808 | |
| 809 | /* |
| 810 | * All these ioctls are invalid in kms world. |
| 811 | */ |
| 812 | KMS_INVALID_IOCTL(radeon_cp_init_kms) |
| 813 | KMS_INVALID_IOCTL(radeon_cp_start_kms) |
| 814 | KMS_INVALID_IOCTL(radeon_cp_stop_kms) |
| 815 | KMS_INVALID_IOCTL(radeon_cp_reset_kms) |
| 816 | KMS_INVALID_IOCTL(radeon_cp_idle_kms) |
| 817 | KMS_INVALID_IOCTL(radeon_cp_resume_kms) |
| 818 | KMS_INVALID_IOCTL(radeon_engine_reset_kms) |
| 819 | KMS_INVALID_IOCTL(radeon_fullscreen_kms) |
| 820 | KMS_INVALID_IOCTL(radeon_cp_swap_kms) |
| 821 | KMS_INVALID_IOCTL(radeon_cp_clear_kms) |
| 822 | KMS_INVALID_IOCTL(radeon_cp_vertex_kms) |
| 823 | KMS_INVALID_IOCTL(radeon_cp_indices_kms) |
| 824 | KMS_INVALID_IOCTL(radeon_cp_texture_kms) |
| 825 | KMS_INVALID_IOCTL(radeon_cp_stipple_kms) |
| 826 | KMS_INVALID_IOCTL(radeon_cp_indirect_kms) |
| 827 | KMS_INVALID_IOCTL(radeon_cp_vertex2_kms) |
| 828 | KMS_INVALID_IOCTL(radeon_cp_cmdbuf_kms) |
| 829 | KMS_INVALID_IOCTL(radeon_cp_getparam_kms) |
| 830 | KMS_INVALID_IOCTL(radeon_cp_flip_kms) |
| 831 | KMS_INVALID_IOCTL(radeon_mem_alloc_kms) |
| 832 | KMS_INVALID_IOCTL(radeon_mem_free_kms) |
| 833 | KMS_INVALID_IOCTL(radeon_mem_init_heap_kms) |
| 834 | KMS_INVALID_IOCTL(radeon_irq_emit_kms) |
| 835 | KMS_INVALID_IOCTL(radeon_irq_wait_kms) |
| 836 | KMS_INVALID_IOCTL(radeon_cp_setparam_kms) |
| 837 | KMS_INVALID_IOCTL(radeon_surface_alloc_kms) |
| 838 | KMS_INVALID_IOCTL(radeon_surface_free_kms) |
| 839 | |
| 840 | |
Rob Clark | baa7094 | 2013-08-02 13:27:49 -0400 | [diff] [blame] | 841 | const struct drm_ioctl_desc radeon_ioctls_kms[] = { |
Dave Airlie | 1b2f148 | 2010-08-14 20:20:34 +1000 | [diff] [blame] | 842 | DRM_IOCTL_DEF_DRV(RADEON_CP_INIT, radeon_cp_init_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 843 | DRM_IOCTL_DEF_DRV(RADEON_CP_START, radeon_cp_start_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 844 | DRM_IOCTL_DEF_DRV(RADEON_CP_STOP, radeon_cp_stop_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 845 | DRM_IOCTL_DEF_DRV(RADEON_CP_RESET, radeon_cp_reset_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 846 | DRM_IOCTL_DEF_DRV(RADEON_CP_IDLE, radeon_cp_idle_kms, DRM_AUTH), |
| 847 | DRM_IOCTL_DEF_DRV(RADEON_CP_RESUME, radeon_cp_resume_kms, DRM_AUTH), |
| 848 | DRM_IOCTL_DEF_DRV(RADEON_RESET, radeon_engine_reset_kms, DRM_AUTH), |
| 849 | DRM_IOCTL_DEF_DRV(RADEON_FULLSCREEN, radeon_fullscreen_kms, DRM_AUTH), |
| 850 | DRM_IOCTL_DEF_DRV(RADEON_SWAP, radeon_cp_swap_kms, DRM_AUTH), |
| 851 | DRM_IOCTL_DEF_DRV(RADEON_CLEAR, radeon_cp_clear_kms, DRM_AUTH), |
| 852 | DRM_IOCTL_DEF_DRV(RADEON_VERTEX, radeon_cp_vertex_kms, DRM_AUTH), |
| 853 | DRM_IOCTL_DEF_DRV(RADEON_INDICES, radeon_cp_indices_kms, DRM_AUTH), |
| 854 | DRM_IOCTL_DEF_DRV(RADEON_TEXTURE, radeon_cp_texture_kms, DRM_AUTH), |
| 855 | DRM_IOCTL_DEF_DRV(RADEON_STIPPLE, radeon_cp_stipple_kms, DRM_AUTH), |
| 856 | DRM_IOCTL_DEF_DRV(RADEON_INDIRECT, radeon_cp_indirect_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 857 | DRM_IOCTL_DEF_DRV(RADEON_VERTEX2, radeon_cp_vertex2_kms, DRM_AUTH), |
| 858 | DRM_IOCTL_DEF_DRV(RADEON_CMDBUF, radeon_cp_cmdbuf_kms, DRM_AUTH), |
| 859 | DRM_IOCTL_DEF_DRV(RADEON_GETPARAM, radeon_cp_getparam_kms, DRM_AUTH), |
| 860 | DRM_IOCTL_DEF_DRV(RADEON_FLIP, radeon_cp_flip_kms, DRM_AUTH), |
| 861 | DRM_IOCTL_DEF_DRV(RADEON_ALLOC, radeon_mem_alloc_kms, DRM_AUTH), |
| 862 | DRM_IOCTL_DEF_DRV(RADEON_FREE, radeon_mem_free_kms, DRM_AUTH), |
| 863 | DRM_IOCTL_DEF_DRV(RADEON_INIT_HEAP, radeon_mem_init_heap_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 864 | DRM_IOCTL_DEF_DRV(RADEON_IRQ_EMIT, radeon_irq_emit_kms, DRM_AUTH), |
| 865 | DRM_IOCTL_DEF_DRV(RADEON_IRQ_WAIT, radeon_irq_wait_kms, DRM_AUTH), |
| 866 | DRM_IOCTL_DEF_DRV(RADEON_SETPARAM, radeon_cp_setparam_kms, DRM_AUTH), |
| 867 | DRM_IOCTL_DEF_DRV(RADEON_SURF_ALLOC, radeon_surface_alloc_kms, DRM_AUTH), |
| 868 | DRM_IOCTL_DEF_DRV(RADEON_SURF_FREE, radeon_surface_free_kms, DRM_AUTH), |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 869 | /* KMS */ |
Christian König | f33bcab | 2013-08-25 18:29:03 +0200 | [diff] [blame] | 870 | DRM_IOCTL_DEF_DRV(RADEON_GEM_INFO, radeon_gem_info_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 871 | DRM_IOCTL_DEF_DRV(RADEON_GEM_CREATE, radeon_gem_create_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 872 | DRM_IOCTL_DEF_DRV(RADEON_GEM_MMAP, radeon_gem_mmap_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 873 | DRM_IOCTL_DEF_DRV(RADEON_GEM_SET_DOMAIN, radeon_gem_set_domain_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
Dave Airlie | 1b2f148 | 2010-08-14 20:20:34 +1000 | [diff] [blame] | 874 | DRM_IOCTL_DEF_DRV(RADEON_GEM_PREAD, radeon_gem_pread_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 875 | DRM_IOCTL_DEF_DRV(RADEON_GEM_PWRITE, radeon_gem_pwrite_ioctl, DRM_AUTH|DRM_UNLOCKED), |
Christian König | f33bcab | 2013-08-25 18:29:03 +0200 | [diff] [blame] | 876 | DRM_IOCTL_DEF_DRV(RADEON_GEM_WAIT_IDLE, radeon_gem_wait_idle_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 877 | DRM_IOCTL_DEF_DRV(RADEON_CS, radeon_cs_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 878 | DRM_IOCTL_DEF_DRV(RADEON_INFO, radeon_info_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 879 | DRM_IOCTL_DEF_DRV(RADEON_GEM_SET_TILING, radeon_gem_set_tiling_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 880 | DRM_IOCTL_DEF_DRV(RADEON_GEM_GET_TILING, radeon_gem_get_tiling_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 881 | DRM_IOCTL_DEF_DRV(RADEON_GEM_BUSY, radeon_gem_busy_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
| 882 | DRM_IOCTL_DEF_DRV(RADEON_GEM_VA, radeon_gem_va_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
Marek Olšák | bda72d5 | 2014-03-02 00:56:17 +0100 | [diff] [blame] | 883 | DRM_IOCTL_DEF_DRV(RADEON_GEM_OP, radeon_gem_op_ioctl, DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW), |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 884 | }; |
Damien Lespiau | f95aeb1 | 2014-06-09 14:39:49 +0100 | [diff] [blame] | 885 | int radeon_max_kms_ioctl = ARRAY_SIZE(radeon_ioctls_kms); |