29 #include <linux/slab.h>
40 static const char radeon_family_name[][16] = {
144 for (i = 0; i < rdev->
scratch.num_reg; i++) {
163 for (i = 0; i < rdev->
scratch.num_reg; i++) {
185 for (i = 0; i < rdev->
scratch.num_reg; i++) {
186 if (rdev->
scratch.reg[i] == reg) {
211 if (rdev->
wb.wb_obj) {
217 radeon_bo_unreserve(rdev->
wb.wb_obj);
219 rdev->
wb.enabled =
false;
233 if (rdev->
wb.wb_obj) {
253 if (rdev->
wb.wb_obj ==
NULL) {
257 dev_warn(rdev->
dev,
"(%d) create WB bo failed\n", r);
269 radeon_bo_unreserve(rdev->
wb.wb_obj);
275 radeon_bo_unreserve(rdev->
wb.wb_obj);
285 rdev->
wb.use_event =
false;
288 rdev->
wb.enabled =
false;
292 rdev->
wb.enabled =
false;
295 rdev->
wb.enabled =
false;
297 rdev->
wb.enabled =
true;
300 rdev->
wb.use_event =
true;
306 rdev->
wb.enabled =
true;
307 rdev->
wb.use_event =
true;
310 dev_info(rdev->
dev,
"WB %sabled\n", rdev->
wb.enabled ?
"en" :
"dis");
362 dev_warn(rdev->
dev,
"limiting VRAM to PCI aperture size\n");
368 dev_warn(rdev->
dev,
"limiting VRAM to PCI aperture size\n");
373 if (limit && limit < mc->real_vram_size)
375 dev_info(rdev->
dev,
"VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n",
394 u64 size_af, size_bf;
398 if (size_bf > size_af) {
412 dev_info(rdev->
dev,
"GTT: %lluM 0x%016llX - 0x%016llX\n",
494 rdev->
pm.sclk.full = dfixed_div(rdev->
pm.sclk, a);
496 rdev->
pm.mclk.full = dfixed_div(rdev->
pm.mclk, a);
501 rdev->
pm.core_bandwidth.full = dfixed_div(rdev->
pm.sclk, a);
520 DRM_INFO(
"GPU not posted. posting now...\n");
527 dev_err(rdev->
dev,
"Card not posted and no BIOS - ignoring\n");
552 dev_err(&rdev->
pdev->dev,
"Failed to DMA MAP the dummy page\n");
741 rdev->
mode_info.atom_card_info = atom_card_info;
742 atom_card_info->
dev = rdev->
ddev;
743 atom_card_info->
reg_read = cail_reg_read;
744 atom_card_info->
reg_write = cail_reg_write;
750 DRM_ERROR(
"Unable to find PCI I/O BAR; using MMIO for ATOM IIO\n");
754 atom_card_info->
mc_read = cail_mc_read;
755 atom_card_info->
mc_write = cail_mc_write;
756 atom_card_info->
pll_read = cail_pll_read;
757 atom_card_info->
pll_write = cail_pll_write;
828 static unsigned int radeon_vga_set_decode(
void *
cookie,
bool state)
847 static bool radeon_check_pot_argument(
int arg)
849 return (arg & (arg - 1)) == 0;
860 static void radeon_check_arguments(
struct radeon_device *rdev)
864 dev_warn(rdev->
dev,
"vram limit (%d) must be a power of 2\n",
871 dev_warn(rdev->
dev,
"gart size (%d) too small forcing to 512M\n",
876 dev_warn(rdev->
dev,
"gart size (%d) must be a power of 2\n",
892 dev_warn(rdev->
dev,
"invalid AGP mode %d (valid mode: "
915 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
917 dev->switch_power_state = DRM_SWITCH_POWER_ON;
922 dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
924 dev->switch_power_state = DRM_SWITCH_POWER_OFF;
937 static bool radeon_switcheroo_can_switch(
struct pci_dev *pdev)
939 struct drm_device *dev = pci_get_drvdata(pdev);
942 spin_lock(&dev->count_lock);
943 can_switch = (dev->open_count == 0);
944 spin_unlock(&dev->count_lock);
949 .set_gpu_state = radeon_switcheroo_set_state,
951 .can_switch = radeon_switcheroo_can_switch,
989 DRM_INFO(
"initializing kernel modesetting (%s 0x%04X:0x%04X 0x%04X:0x%04X).\n",
1020 radeon_check_arguments(rdev);
1069 DRM_INFO(
"register mmio size: %u\n", (
unsigned)rdev->
rmmio_size);
1080 DRM_ERROR(
"Unable to find PCI I/O BAR\n");
1094 DRM_ERROR(
"ib ring test failed (%d).\n", r);
1119 static void radeon_debugfs_remove_files(
struct radeon_device *rdev);
1131 DRM_INFO(
"radeon: finishing device.\n");
1143 radeon_debugfs_remove_files(rdev);
1167 if (dev ==
NULL || dev->dev_private ==
NULL) {
1173 rdev = dev->dev_private;
1175 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
1199 radeon_bo_unreserve(robj);
1249 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
1265 DRM_ERROR(
"ib ring test failed (%d).\n", r);
1325 if (ring_sizes[i]) {
1327 dev_info(rdev->
dev,
"Saved %d dwords of commands "
1328 "on ring %d.\n", ring_sizes[i], i);
1335 dev_info(rdev->
dev,
"GPU reset succeeded, trying to resume\n");
1345 ring_sizes[i], ring_data[i]);
1347 ring_data[
i] =
NULL;
1352 dev_err(rdev->
dev,
"ib ring test failed (%d).\n", r);
1361 kfree(ring_data[i]);
1380 struct drm_info_list *
files,
1386 if (rdev->
debugfs[i].files == files) {
1394 DRM_ERROR(
"Reached maximum number of debugfs components.\n");
1395 DRM_ERROR(
"Report so we increase "
1396 "RADEON_DEBUGFS_MAX_COMPONENTS.\n");
1402 #if defined(CONFIG_DEBUG_FS)
1403 drm_debugfs_create_files(files, nfiles,
1404 rdev->
ddev->control->debugfs_root,
1405 rdev->
ddev->control);
1406 drm_debugfs_create_files(files, nfiles,
1407 rdev->
ddev->primary->debugfs_root,
1408 rdev->
ddev->primary);
1413 static void radeon_debugfs_remove_files(
struct radeon_device *rdev)
1415 #if defined(CONFIG_DEBUG_FS)
1419 drm_debugfs_remove_files(rdev->
debugfs[i].files,
1421 rdev->
ddev->control);
1422 drm_debugfs_remove_files(rdev->
debugfs[i].files,
1424 rdev->
ddev->primary);
1429 #if defined(CONFIG_DEBUG_FS)
1430 int radeon_debugfs_init(
struct drm_minor *minor)
1435 void radeon_debugfs_cleanup(
struct drm_minor *minor)