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