Merge remote branch 'nouveau/for-airlied' of /ssd/git/drm-nouveau-next into drm-fixes

* 'nouveau/for-airlied' of /ssd/git/drm-nouveau-next: (25 commits)
nouveau: Acknowledge HPD irq in handler, not bottom half
drm/nouveau: Fix a few confusions between "chipset" and "card_type".
drm/nouveau: don't expose backlight control when available through ACPI
drm/nouveau/pm: improve memtiming mappings
drm/nouveau: Make PCIE GART size depend on the available RAMIN space.
drm/nouveau: Return error from nouveau_gpuobj_new if we're out of RAMIN.
drm/nouveau: Fix compilation issues in nouveau_pm when CONFIG_HWMON is not set
drm/nouveau: Don't use load detection for connector polling.
drm/nv10-nv20: Fix instability after MPLL changes.
drm/nv50: implement possible workaround for NV86 PGRAPH TLB flush hang
drm/nouveau: Don't poll LVDS outputs.
drm/nouveau: Use "force" to decide if analog load detection is ok or not.
drm/nv04: Fix scanout over the 16MB mark.
drm/nouveau: fix nv40 pcie gart size
drm/nva3: fix overflow in fixed point math used for pll calculation
drm/nv10: Balance RTs expected to be accessed simultaneously by the 3d engine.
drm/nouveau: Expose some BO usage flags to userspace.
drm/nouveau: Reduce severity of the unknown getparam error.
drm/nouveau: Avoid lock dependency between ramht and ramin spinlocks.
drm/nouveau: Some random cleanups.
...

+391 -223
+9
drivers/gpu/drm/nouveau/nouveau_backlight.c
··· 31 */ 32 33 #include <linux/backlight.h> 34 35 #include "drmP.h" 36 #include "nouveau_drv.h" ··· 136 int nouveau_backlight_init(struct drm_device *dev) 137 { 138 struct drm_nouveau_private *dev_priv = dev->dev_private; 139 140 switch (dev_priv->card_type) { 141 case NV_40:
··· 31 */ 32 33 #include <linux/backlight.h> 34 + #include <linux/acpi.h> 35 36 #include "drmP.h" 37 #include "nouveau_drv.h" ··· 135 int nouveau_backlight_init(struct drm_device *dev) 136 { 137 struct drm_nouveau_private *dev_priv = dev->dev_private; 138 + 139 + #ifdef CONFIG_ACPI 140 + if (acpi_video_backlight_support()) { 141 + NV_INFO(dev, "ACPI backlight interface available, " 142 + "not registering our own\n"); 143 + return 0; 144 + } 145 + #endif 146 147 switch (dev_priv->card_type) { 148 case NV_40:
+1 -1
drivers/gpu/drm/nouveau/nouveau_bios.c
··· 6829 struct drm_nouveau_private *dev_priv = dev->dev_private; 6830 unsigned htotal; 6831 6832 - if (dev_priv->chipset >= NV_50) { 6833 if (NVReadVgaCrtc(dev, 0, 0x00) == 0 && 6834 NVReadVgaCrtc(dev, 0, 0x1a) == 0) 6835 return false;
··· 6829 struct drm_nouveau_private *dev_priv = dev->dev_private; 6830 unsigned htotal; 6831 6832 + if (dev_priv->card_type >= NV_50) { 6833 if (NVReadVgaCrtc(dev, 0, 0x00) == 0 && 6834 NVReadVgaCrtc(dev, 0, 0x1a) == 0) 6835 return false;
+38 -5
drivers/gpu/drm/nouveau/nouveau_bo.c
··· 143 nvbo->no_vm = no_vm; 144 nvbo->tile_mode = tile_mode; 145 nvbo->tile_flags = tile_flags; 146 147 - nouveau_bo_fixup_align(dev, tile_mode, tile_flags, &align, &size); 148 align >>= PAGE_SHIFT; 149 150 nouveau_bo_placement_set(nvbo, flags, 0); ··· 178 pl[(*n)++] = TTM_PL_FLAG_SYSTEM | flags; 179 } 180 181 void 182 nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t type, uint32_t busy) 183 { ··· 217 pl->busy_placement = nvbo->busy_placements; 218 set_placement_list(nvbo->busy_placements, &pl->num_busy_placement, 219 type | busy, flags); 220 } 221 222 int ··· 554 stride = 16 * 4; 555 height = amount / stride; 556 557 - if (new_mem->mem_type == TTM_PL_VRAM && nvbo->tile_flags) { 558 ret = RING_SPACE(chan, 8); 559 if (ret) 560 return ret; ··· 576 BEGIN_RING(chan, NvSubM2MF, 0x0200, 1); 577 OUT_RING (chan, 1); 578 } 579 - if (old_mem->mem_type == TTM_PL_VRAM && nvbo->tile_flags) { 580 ret = RING_SPACE(chan, 8); 581 if (ret) 582 return ret; ··· 784 if (dev_priv->card_type == NV_50) { 785 ret = nv50_mem_vm_bind_linear(dev, 786 offset + dev_priv->vm_vram_base, 787 - new_mem->size, nvbo->tile_flags, 788 offset); 789 if (ret) 790 return ret; ··· 926 * nothing to do here. 927 */ 928 if (bo->mem.mem_type != TTM_PL_VRAM) { 929 - if (dev_priv->card_type < NV_50 || !nvbo->tile_flags) 930 return 0; 931 } 932
··· 143 nvbo->no_vm = no_vm; 144 nvbo->tile_mode = tile_mode; 145 nvbo->tile_flags = tile_flags; 146 + nvbo->bo.bdev = &dev_priv->ttm.bdev; 147 148 + nouveau_bo_fixup_align(dev, tile_mode, nouveau_bo_tile_layout(nvbo), 149 + &align, &size); 150 align >>= PAGE_SHIFT; 151 152 nouveau_bo_placement_set(nvbo, flags, 0); ··· 176 pl[(*n)++] = TTM_PL_FLAG_SYSTEM | flags; 177 } 178 179 + static void 180 + set_placement_range(struct nouveau_bo *nvbo, uint32_t type) 181 + { 182 + struct drm_nouveau_private *dev_priv = nouveau_bdev(nvbo->bo.bdev); 183 + 184 + if (dev_priv->card_type == NV_10 && 185 + nvbo->tile_mode && (type & TTM_PL_FLAG_VRAM)) { 186 + /* 187 + * Make sure that the color and depth buffers are handled 188 + * by independent memory controller units. Up to a 9x 189 + * speed up when alpha-blending and depth-test are enabled 190 + * at the same time. 191 + */ 192 + int vram_pages = dev_priv->vram_size >> PAGE_SHIFT; 193 + 194 + if (nvbo->tile_flags & NOUVEAU_GEM_TILE_ZETA) { 195 + nvbo->placement.fpfn = vram_pages / 2; 196 + nvbo->placement.lpfn = ~0; 197 + } else { 198 + nvbo->placement.fpfn = 0; 199 + nvbo->placement.lpfn = vram_pages / 2; 200 + } 201 + } 202 + } 203 + 204 void 205 nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t type, uint32_t busy) 206 { ··· 190 pl->busy_placement = nvbo->busy_placements; 191 set_placement_list(nvbo->busy_placements, &pl->num_busy_placement, 192 type | busy, flags); 193 + 194 + set_placement_range(nvbo, type); 195 } 196 197 int ··· 525 stride = 16 * 4; 526 height = amount / stride; 527 528 + if (new_mem->mem_type == TTM_PL_VRAM && 529 + nouveau_bo_tile_layout(nvbo)) { 530 ret = RING_SPACE(chan, 8); 531 if (ret) 532 return ret; ··· 546 BEGIN_RING(chan, NvSubM2MF, 0x0200, 1); 547 OUT_RING (chan, 1); 548 } 549 + if (old_mem->mem_type == TTM_PL_VRAM && 550 + nouveau_bo_tile_layout(nvbo)) { 551 ret = RING_SPACE(chan, 8); 552 if (ret) 553 return ret; ··· 753 if (dev_priv->card_type == NV_50) { 754 ret = nv50_mem_vm_bind_linear(dev, 755 offset + dev_priv->vm_vram_base, 756 + new_mem->size, 757 + nouveau_bo_tile_layout(nvbo), 758 offset); 759 if (ret) 760 return ret; ··· 894 * nothing to do here. 895 */ 896 if (bo->mem.mem_type != TTM_PL_VRAM) { 897 + if (dev_priv->card_type < NV_50 || 898 + !nouveau_bo_tile_layout(nvbo)) 899 return 0; 900 } 901
+30 -47
drivers/gpu/drm/nouveau/nouveau_connector.c
··· 281 nv_encoder = find_encoder_by_type(connector, OUTPUT_ANALOG); 282 if (!nv_encoder && !nouveau_tv_disable) 283 nv_encoder = find_encoder_by_type(connector, OUTPUT_TV); 284 - if (nv_encoder) { 285 struct drm_encoder *encoder = to_drm_encoder(nv_encoder); 286 struct drm_encoder_helper_funcs *helper = 287 encoder->helper_private; ··· 641 return ret; 642 } 643 644 static int 645 nouveau_connector_mode_valid(struct drm_connector *connector, 646 struct drm_display_mode *mode) 647 { 648 - struct drm_nouveau_private *dev_priv = connector->dev->dev_private; 649 struct nouveau_connector *nv_connector = nouveau_connector(connector); 650 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder; 651 struct drm_encoder *encoder = to_drm_encoder(nv_encoder); ··· 680 max_clock = 400000; 681 break; 682 case OUTPUT_TMDS: 683 - if ((dev_priv->card_type >= NV_50 && !nouveau_duallink) || 684 - !nv_encoder->dcb->duallink_possible) 685 - max_clock = 165000; 686 - else 687 - max_clock = 330000; 688 break; 689 case OUTPUT_ANALOG: 690 max_clock = nv_encoder->dcb->crtconf.maxfreq; ··· 722 return to_drm_encoder(nv_connector->detected_encoder); 723 724 return NULL; 725 - } 726 - 727 - void 728 - nouveau_connector_set_polling(struct drm_connector *connector) 729 - { 730 - struct drm_device *dev = connector->dev; 731 - struct drm_nouveau_private *dev_priv = dev->dev_private; 732 - struct drm_crtc *crtc; 733 - bool spare_crtc = false; 734 - 735 - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) 736 - spare_crtc |= !crtc->enabled; 737 - 738 - connector->polled = 0; 739 - 740 - switch (connector->connector_type) { 741 - case DRM_MODE_CONNECTOR_VGA: 742 - case DRM_MODE_CONNECTOR_TV: 743 - if (dev_priv->card_type >= NV_50 || 744 - (nv_gf4_disp_arch(dev) && spare_crtc)) 745 - connector->polled = DRM_CONNECTOR_POLL_CONNECT; 746 - break; 747 - 748 - case DRM_MODE_CONNECTOR_DVII: 749 - case DRM_MODE_CONNECTOR_DVID: 750 - case DRM_MODE_CONNECTOR_HDMIA: 751 - case DRM_MODE_CONNECTOR_DisplayPort: 752 - case DRM_MODE_CONNECTOR_eDP: 753 - if (dev_priv->card_type >= NV_50) 754 - connector->polled = DRM_CONNECTOR_POLL_HPD; 755 - else if (connector->connector_type == DRM_MODE_CONNECTOR_DVID || 756 - spare_crtc) 757 - connector->polled = DRM_CONNECTOR_POLL_CONNECT; 758 - break; 759 - 760 - default: 761 - break; 762 - } 763 } 764 765 static const struct drm_connector_helper_funcs ··· 849 dev->mode_config.scaling_mode_property, 850 nv_connector->scaling_mode); 851 } 852 /* fall-through */ 853 case DCB_CONNECTOR_TV_0: 854 case DCB_CONNECTOR_TV_1: ··· 866 dev->mode_config.dithering_mode_property, 867 nv_connector->use_dithering ? 868 DRM_MODE_DITHERING_ON : DRM_MODE_DITHERING_OFF); 869 break; 870 } 871 - 872 - nouveau_connector_set_polling(connector); 873 874 drm_sysfs_connector_add(connector); 875 dcb->drm = connector;
··· 281 nv_encoder = find_encoder_by_type(connector, OUTPUT_ANALOG); 282 if (!nv_encoder && !nouveau_tv_disable) 283 nv_encoder = find_encoder_by_type(connector, OUTPUT_TV); 284 + if (nv_encoder && force) { 285 struct drm_encoder *encoder = to_drm_encoder(nv_encoder); 286 struct drm_encoder_helper_funcs *helper = 287 encoder->helper_private; ··· 641 return ret; 642 } 643 644 + static unsigned 645 + get_tmds_link_bandwidth(struct drm_connector *connector) 646 + { 647 + struct nouveau_connector *nv_connector = nouveau_connector(connector); 648 + struct drm_nouveau_private *dev_priv = connector->dev->dev_private; 649 + struct dcb_entry *dcb = nv_connector->detected_encoder->dcb; 650 + 651 + if (dcb->location != DCB_LOC_ON_CHIP || 652 + dev_priv->chipset >= 0x46) 653 + return 165000; 654 + else if (dev_priv->chipset >= 0x40) 655 + return 155000; 656 + else if (dev_priv->chipset >= 0x18) 657 + return 135000; 658 + else 659 + return 112000; 660 + } 661 + 662 static int 663 nouveau_connector_mode_valid(struct drm_connector *connector, 664 struct drm_display_mode *mode) 665 { 666 struct nouveau_connector *nv_connector = nouveau_connector(connector); 667 struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder; 668 struct drm_encoder *encoder = to_drm_encoder(nv_encoder); ··· 663 max_clock = 400000; 664 break; 665 case OUTPUT_TMDS: 666 + max_clock = get_tmds_link_bandwidth(connector); 667 + if (nouveau_duallink && nv_encoder->dcb->duallink_possible) 668 + max_clock *= 2; 669 break; 670 case OUTPUT_ANALOG: 671 max_clock = nv_encoder->dcb->crtconf.maxfreq; ··· 707 return to_drm_encoder(nv_connector->detected_encoder); 708 709 return NULL; 710 } 711 712 static const struct drm_connector_helper_funcs ··· 872 dev->mode_config.scaling_mode_property, 873 nv_connector->scaling_mode); 874 } 875 + connector->polled = DRM_CONNECTOR_POLL_CONNECT; 876 /* fall-through */ 877 case DCB_CONNECTOR_TV_0: 878 case DCB_CONNECTOR_TV_1: ··· 888 dev->mode_config.dithering_mode_property, 889 nv_connector->use_dithering ? 890 DRM_MODE_DITHERING_ON : DRM_MODE_DITHERING_OFF); 891 + 892 + if (dcb->type != DCB_CONNECTOR_LVDS) { 893 + if (dev_priv->card_type >= NV_50) 894 + connector->polled = DRM_CONNECTOR_POLL_HPD; 895 + else 896 + connector->polled = DRM_CONNECTOR_POLL_CONNECT; 897 + } 898 break; 899 } 900 901 drm_sysfs_connector_add(connector); 902 dcb->drm = connector;
-3
drivers/gpu/drm/nouveau/nouveau_connector.h
··· 52 struct drm_connector * 53 nouveau_connector_create(struct drm_device *, int index); 54 55 - void 56 - nouveau_connector_set_polling(struct drm_connector *); 57 - 58 int 59 nouveau_connector_bpp(struct drm_connector *); 60
··· 52 struct drm_connector * 53 nouveau_connector_create(struct drm_device *, int index); 54 55 int 56 nouveau_connector_bpp(struct drm_connector *); 57
+17 -38
drivers/gpu/drm/nouveau/nouveau_drv.h
··· 100 int pin_refcnt; 101 }; 102 103 static inline struct nouveau_bo * 104 nouveau_bo(struct ttm_buffer_object *bo) 105 { ··· 307 void (*destroy_context)(struct nouveau_channel *); 308 int (*load_context)(struct nouveau_channel *); 309 int (*unload_context)(struct drm_device *); 310 }; 311 312 struct nouveau_pgraph_object_method { ··· 340 void (*destroy_context)(struct nouveau_channel *); 341 int (*load_context)(struct nouveau_channel *); 342 int (*unload_context)(struct drm_device *); 343 344 void (*set_region_tiling)(struct drm_device *dev, int i, uint32_t addr, 345 uint32_t size, uint32_t pitch); ··· 490 }; 491 492 struct nv04_crtc_reg { 493 - unsigned char MiscOutReg; /* */ 494 uint8_t CRTC[0xa0]; 495 uint8_t CR58[0x10]; 496 uint8_t Sequencer[5]; 497 uint8_t Graphics[9]; 498 uint8_t Attribute[21]; 499 - unsigned char DAC[768]; /* Internal Colorlookuptable */ 500 501 /* PCRTC regs */ 502 uint32_t fb_start; ··· 544 }; 545 546 struct nv04_mode_state { 547 - uint32_t bpp; 548 - uint32_t width; 549 - uint32_t height; 550 - uint32_t interlace; 551 - uint32_t repaint0; 552 - uint32_t repaint1; 553 - uint32_t screen; 554 - uint32_t scale; 555 - uint32_t dither; 556 - uint32_t extra; 557 - uint32_t fifo; 558 - uint32_t pixel; 559 - uint32_t horiz; 560 - int arbitration0; 561 - int arbitration1; 562 - uint32_t pll; 563 - uint32_t pllB; 564 - uint32_t vpll; 565 - uint32_t vpll2; 566 - uint32_t vpllB; 567 - uint32_t vpll2B; 568 uint32_t pllsel; 569 uint32_t sel_clk; 570 - uint32_t general; 571 - uint32_t crtcOwner; 572 - uint32_t head; 573 - uint32_t head2; 574 - uint32_t cursorConfig; 575 - uint32_t cursor0; 576 - uint32_t cursor1; 577 - uint32_t cursor2; 578 - uint32_t timingH; 579 - uint32_t timingV; 580 - uint32_t displayV; 581 - uint32_t crtcSync; 582 - 583 - struct nv04_crtc_reg crtc_reg[2]; 584 }; 585 586 enum nouveau_card_type { ··· 583 struct workqueue_struct *wq; 584 struct work_struct irq_work; 585 struct work_struct hpd_work; 586 587 struct list_head vbl_waiting; 588 ··· 1022 extern void nv50_fifo_destroy_context(struct nouveau_channel *); 1023 extern int nv50_fifo_load_context(struct nouveau_channel *); 1024 extern int nv50_fifo_unload_context(struct drm_device *); 1025 1026 /* nvc0_fifo.c */ 1027 extern int nvc0_fifo_init(struct drm_device *); ··· 1100 extern int nv50_graph_unload_context(struct drm_device *); 1101 extern void nv50_graph_context_switch(struct drm_device *); 1102 extern int nv50_grctx_init(struct nouveau_grctx *); 1103 1104 /* nvc0_graph.c */ 1105 extern int nvc0_graph_init(struct drm_device *); ··· 1219 extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val); 1220 extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index); 1221 extern void nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val); 1222 - extern int nouveau_bo_sync_gpu(struct nouveau_bo *, struct nouveau_channel *); 1223 1224 /* nouveau_fence.c */ 1225 struct nouveau_fence;
··· 100 int pin_refcnt; 101 }; 102 103 + #define nouveau_bo_tile_layout(nvbo) \ 104 + ((nvbo)->tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) 105 + 106 static inline struct nouveau_bo * 107 nouveau_bo(struct ttm_buffer_object *bo) 108 { ··· 304 void (*destroy_context)(struct nouveau_channel *); 305 int (*load_context)(struct nouveau_channel *); 306 int (*unload_context)(struct drm_device *); 307 + void (*tlb_flush)(struct drm_device *dev); 308 }; 309 310 struct nouveau_pgraph_object_method { ··· 336 void (*destroy_context)(struct nouveau_channel *); 337 int (*load_context)(struct nouveau_channel *); 338 int (*unload_context)(struct drm_device *); 339 + void (*tlb_flush)(struct drm_device *dev); 340 341 void (*set_region_tiling)(struct drm_device *dev, int i, uint32_t addr, 342 uint32_t size, uint32_t pitch); ··· 485 }; 486 487 struct nv04_crtc_reg { 488 + unsigned char MiscOutReg; 489 uint8_t CRTC[0xa0]; 490 uint8_t CR58[0x10]; 491 uint8_t Sequencer[5]; 492 uint8_t Graphics[9]; 493 uint8_t Attribute[21]; 494 + unsigned char DAC[768]; 495 496 /* PCRTC regs */ 497 uint32_t fb_start; ··· 539 }; 540 541 struct nv04_mode_state { 542 + struct nv04_crtc_reg crtc_reg[2]; 543 uint32_t pllsel; 544 uint32_t sel_clk; 545 }; 546 547 enum nouveau_card_type { ··· 612 struct workqueue_struct *wq; 613 struct work_struct irq_work; 614 struct work_struct hpd_work; 615 + 616 + struct { 617 + spinlock_t lock; 618 + uint32_t hpd0_bits; 619 + uint32_t hpd1_bits; 620 + } hpd_state; 621 622 struct list_head vbl_waiting; 623 ··· 1045 extern void nv50_fifo_destroy_context(struct nouveau_channel *); 1046 extern int nv50_fifo_load_context(struct nouveau_channel *); 1047 extern int nv50_fifo_unload_context(struct drm_device *); 1048 + extern void nv50_fifo_tlb_flush(struct drm_device *dev); 1049 1050 /* nvc0_fifo.c */ 1051 extern int nvc0_fifo_init(struct drm_device *); ··· 1122 extern int nv50_graph_unload_context(struct drm_device *); 1123 extern void nv50_graph_context_switch(struct drm_device *); 1124 extern int nv50_grctx_init(struct nouveau_grctx *); 1125 + extern void nv50_graph_tlb_flush(struct drm_device *dev); 1126 + extern void nv86_graph_tlb_flush(struct drm_device *dev); 1127 1128 /* nvc0_graph.c */ 1129 extern int nvc0_graph_init(struct drm_device *); ··· 1239 extern void nouveau_bo_wr16(struct nouveau_bo *nvbo, unsigned index, u16 val); 1240 extern u32 nouveau_bo_rd32(struct nouveau_bo *nvbo, unsigned index); 1241 extern void nouveau_bo_wr32(struct nouveau_bo *nvbo, unsigned index, u32 val); 1242 1243 /* nouveau_fence.c */ 1244 struct nouveau_fence;
+6 -1
drivers/gpu/drm/nouveau/nouveau_fence.c
··· 249 { 250 struct drm_nouveau_private *dev_priv = dev->dev_private; 251 struct nouveau_semaphore *sema; 252 253 if (!USE_SEMA(dev)) 254 return NULL; ··· 258 if (!sema) 259 goto fail; 260 261 spin_lock(&dev_priv->fence.lock); 262 sema->mem = drm_mm_search_free(&dev_priv->fence.heap, 4, 0, 0); 263 if (sema->mem) 264 - sema->mem = drm_mm_get_block(sema->mem, 4, 0); 265 spin_unlock(&dev_priv->fence.lock); 266 267 if (!sema->mem)
··· 249 { 250 struct drm_nouveau_private *dev_priv = dev->dev_private; 251 struct nouveau_semaphore *sema; 252 + int ret; 253 254 if (!USE_SEMA(dev)) 255 return NULL; ··· 257 if (!sema) 258 goto fail; 259 260 + ret = drm_mm_pre_get(&dev_priv->fence.heap); 261 + if (ret) 262 + goto fail; 263 + 264 spin_lock(&dev_priv->fence.lock); 265 sema->mem = drm_mm_search_free(&dev_priv->fence.heap, 4, 0, 0); 266 if (sema->mem) 267 + sema->mem = drm_mm_get_block_atomic(sema->mem, 4, 0); 268 spin_unlock(&dev_priv->fence.lock); 269 270 if (!sema->mem)
+21 -15
drivers/gpu/drm/nouveau/nouveau_gem.c
··· 107 } 108 109 static bool 110 - nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags) { 111 - switch (tile_flags) { 112 - case 0x0000: 113 - case 0x1800: 114 - case 0x2800: 115 - case 0x4800: 116 - case 0x7000: 117 - case 0x7400: 118 - case 0x7a00: 119 - case 0xe000: 120 - break; 121 - default: 122 - NV_ERROR(dev, "bad page flags: 0x%08x\n", tile_flags); 123 - return false; 124 } 125 126 - return true; 127 } 128 129 int
··· 107 } 108 109 static bool 110 + nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags) 111 + { 112 + struct drm_nouveau_private *dev_priv = dev->dev_private; 113 + 114 + if (dev_priv->card_type >= NV_50) { 115 + switch (tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) { 116 + case 0x0000: 117 + case 0x1800: 118 + case 0x2800: 119 + case 0x4800: 120 + case 0x7000: 121 + case 0x7400: 122 + case 0x7a00: 123 + case 0xe000: 124 + return true; 125 + } 126 + } else { 127 + if (!(tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK)) 128 + return true; 129 } 130 131 + NV_ERROR(dev, "bad page flags: 0x%08x\n", tile_flags); 132 + return false; 133 } 134 135 int
+4 -4
drivers/gpu/drm/nouveau/nouveau_hw.c
··· 519 520 struct pll_lims pll_lim; 521 struct nouveau_pll_vals pv; 522 - uint32_t pllreg = head ? NV_RAMDAC_VPLL2 : NV_PRAMDAC_VPLL_COEFF; 523 524 - if (get_pll_limits(dev, pllreg, &pll_lim)) 525 return; 526 - nouveau_hw_get_pllvals(dev, pllreg, &pv); 527 528 if (pv.M1 >= pll_lim.vco1.min_m && pv.M1 <= pll_lim.vco1.max_m && 529 pv.N1 >= pll_lim.vco1.min_n && pv.N1 <= pll_lim.vco1.max_n && ··· 536 pv.M1 = pll_lim.vco1.max_m; 537 pv.N1 = pll_lim.vco1.min_n; 538 pv.log2P = pll_lim.max_usable_log2p; 539 - nouveau_hw_setpll(dev, pllreg, &pv); 540 } 541 542 /*
··· 519 520 struct pll_lims pll_lim; 521 struct nouveau_pll_vals pv; 522 + enum pll_types pll = head ? PLL_VPLL1 : PLL_VPLL0; 523 524 + if (get_pll_limits(dev, pll, &pll_lim)) 525 return; 526 + nouveau_hw_get_pllvals(dev, pll, &pv); 527 528 if (pv.M1 >= pll_lim.vco1.min_m && pv.M1 <= pll_lim.vco1.max_m && 529 pv.N1 >= pll_lim.vco1.min_n && pv.N1 <= pll_lim.vco1.max_n && ··· 536 pv.M1 = pll_lim.vco1.max_m; 537 pv.N1 = pll_lim.vco1.min_n; 538 pv.log2P = pll_lim.max_usable_log2p; 539 + nouveau_hw_setpll(dev, pll_lim.reg, &pv); 540 } 541 542 /*
+19
drivers/gpu/drm/nouveau/nouveau_hw.h
··· 416 } 417 418 static inline void 419 nv_show_cursor(struct drm_device *dev, int head, bool show) 420 { 421 struct drm_nouveau_private *dev_priv = dev->dev_private;
··· 416 } 417 418 static inline void 419 + nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset) 420 + { 421 + struct drm_nouveau_private *dev_priv = dev->dev_private; 422 + 423 + NVWriteCRTC(dev, head, NV_PCRTC_START, offset); 424 + 425 + if (dev_priv->card_type == NV_04) { 426 + /* 427 + * Hilarious, the 24th bit doesn't want to stick to 428 + * PCRTC_START... 429 + */ 430 + int cre_heb = NVReadVgaCrtc(dev, head, NV_CIO_CRE_HEB__INDEX); 431 + 432 + NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HEB__INDEX, 433 + (cre_heb & ~0x40) | ((offset >> 18) & 0x40)); 434 + } 435 + } 436 + 437 + static inline void 438 nv_show_cursor(struct drm_device *dev, int head, bool show) 439 { 440 struct drm_nouveau_private *dev_priv = dev->dev_private;
+1 -1
drivers/gpu/drm/nouveau/nouveau_i2c.c
··· 256 if (index >= DCB_MAX_NUM_I2C_ENTRIES) 257 return NULL; 258 259 - if (dev_priv->chipset >= NV_50 && (i2c->entry & 0x00000100)) { 260 uint32_t reg = 0xe500, val; 261 262 if (i2c->port_type == 6) {
··· 256 if (index >= DCB_MAX_NUM_I2C_ENTRIES) 257 return NULL; 258 259 + if (dev_priv->card_type >= NV_50 && (i2c->entry & 0x00000100)) { 260 uint32_t reg = 0xe500, val; 261 262 if (i2c->port_type == 6) {
+23 -19
drivers/gpu/drm/nouveau/nouveau_irq.c
··· 42 #include "nouveau_connector.h" 43 #include "nv50_display.h" 44 45 void 46 nouveau_irq_preinstall(struct drm_device *dev) 47 { ··· 60 if (dev_priv->card_type >= NV_50) { 61 INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh); 62 INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh); 63 INIT_LIST_HEAD(&dev_priv->vbl_waiting); 64 } 65 } ··· 210 } 211 212 if (status & NV_PFIFO_INTR_DMA_PUSHER) { 213 - u32 get = nv_rd32(dev, 0x003244); 214 - u32 put = nv_rd32(dev, 0x003240); 215 u32 push = nv_rd32(dev, 0x003220); 216 u32 state = nv_rd32(dev, 0x003228); 217 ··· 221 u32 ib_get = nv_rd32(dev, 0x003334); 222 u32 ib_put = nv_rd32(dev, 0x003330); 223 224 - NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%02x%08x " 225 "Put 0x%02x%08x IbGet 0x%08x IbPut 0x%08x " 226 "State 0x%08x Push 0x%08x\n", 227 - chid, ho_get, get, ho_put, put, ib_get, ib_put, 228 - state, push); 229 230 /* METHOD_COUNT, in DMA_STATE on earlier chipsets */ 231 nv_wr32(dev, 0x003364, 0x00000000); 232 - if (get != put || ho_get != ho_put) { 233 - nv_wr32(dev, 0x003244, put); 234 nv_wr32(dev, 0x003328, ho_put); 235 } else 236 if (ib_get != ib_put) { ··· 241 } else { 242 NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%08x " 243 "Put 0x%08x State 0x%08x Push 0x%08x\n", 244 - chid, get, put, state, push); 245 246 - if (get != put) 247 - nv_wr32(dev, 0x003244, put); 248 } 249 250 nv_wr32(dev, 0x003228, 0x00000000); ··· 276 } 277 278 if (status) { 279 - NV_INFO(dev, "PFIFO_INTR 0x%08x - Ch %d\n", 280 - status, chid); 281 nv_wr32(dev, NV03_PFIFO_INTR_0, status); 282 status = 0; 283 } ··· 553 554 if (unhandled) 555 nouveau_graph_dump_trap_info(dev, "PGRAPH_NOTIFY", &trap); 556 - } 557 - 558 - static DEFINE_RATELIMIT_STATE(nouveau_ratelimit_state, 3 * HZ, 20); 559 - 560 - static int nouveau_ratelimit(void) 561 - { 562 - return __ratelimit(&nouveau_ratelimit_state); 563 } 564 565
··· 42 #include "nouveau_connector.h" 43 #include "nv50_display.h" 44 45 + static DEFINE_RATELIMIT_STATE(nouveau_ratelimit_state, 3 * HZ, 20); 46 + 47 + static int nouveau_ratelimit(void) 48 + { 49 + return __ratelimit(&nouveau_ratelimit_state); 50 + } 51 + 52 void 53 nouveau_irq_preinstall(struct drm_device *dev) 54 { ··· 53 if (dev_priv->card_type >= NV_50) { 54 INIT_WORK(&dev_priv->irq_work, nv50_display_irq_handler_bh); 55 INIT_WORK(&dev_priv->hpd_work, nv50_display_irq_hotplug_bh); 56 + spin_lock_init(&dev_priv->hpd_state.lock); 57 INIT_LIST_HEAD(&dev_priv->vbl_waiting); 58 } 59 } ··· 202 } 203 204 if (status & NV_PFIFO_INTR_DMA_PUSHER) { 205 + u32 dma_get = nv_rd32(dev, 0x003244); 206 + u32 dma_put = nv_rd32(dev, 0x003240); 207 u32 push = nv_rd32(dev, 0x003220); 208 u32 state = nv_rd32(dev, 0x003228); 209 ··· 213 u32 ib_get = nv_rd32(dev, 0x003334); 214 u32 ib_put = nv_rd32(dev, 0x003330); 215 216 + if (nouveau_ratelimit()) 217 + NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%02x%08x " 218 "Put 0x%02x%08x IbGet 0x%08x IbPut 0x%08x " 219 "State 0x%08x Push 0x%08x\n", 220 + chid, ho_get, dma_get, ho_put, 221 + dma_put, ib_get, ib_put, state, 222 + push); 223 224 /* METHOD_COUNT, in DMA_STATE on earlier chipsets */ 225 nv_wr32(dev, 0x003364, 0x00000000); 226 + if (dma_get != dma_put || ho_get != ho_put) { 227 + nv_wr32(dev, 0x003244, dma_put); 228 nv_wr32(dev, 0x003328, ho_put); 229 } else 230 if (ib_get != ib_put) { ··· 231 } else { 232 NV_INFO(dev, "PFIFO_DMA_PUSHER - Ch %d Get 0x%08x " 233 "Put 0x%08x State 0x%08x Push 0x%08x\n", 234 + chid, dma_get, dma_put, state, push); 235 236 + if (dma_get != dma_put) 237 + nv_wr32(dev, 0x003244, dma_put); 238 } 239 240 nv_wr32(dev, 0x003228, 0x00000000); ··· 266 } 267 268 if (status) { 269 + if (nouveau_ratelimit()) 270 + NV_INFO(dev, "PFIFO_INTR 0x%08x - Ch %d\n", 271 + status, chid); 272 nv_wr32(dev, NV03_PFIFO_INTR_0, status); 273 status = 0; 274 } ··· 542 543 if (unhandled) 544 nouveau_graph_dump_trap_info(dev, "PGRAPH_NOTIFY", &trap); 545 } 546 547
+27 -22
drivers/gpu/drm/nouveau/nouveau_mem.c
··· 33 #include "drmP.h" 34 #include "drm.h" 35 #include "drm_sarea.h" 36 - #include "nouveau_drv.h" 37 38 - #define MIN(a,b) a < b ? a : b 39 40 /* 41 * NV10-NV40 tiling helpers ··· 175 } 176 } 177 } 178 - dev_priv->engine.instmem.flush(dev); 179 180 - nv50_vm_flush(dev, 5); 181 - nv50_vm_flush(dev, 0); 182 - nv50_vm_flush(dev, 4); 183 nv50_vm_flush(dev, 6); 184 return 0; 185 } ··· 208 pte++; 209 } 210 } 211 - dev_priv->engine.instmem.flush(dev); 212 213 - nv50_vm_flush(dev, 5); 214 - nv50_vm_flush(dev, 0); 215 - nv50_vm_flush(dev, 4); 216 nv50_vm_flush(dev, 6); 217 } 218 ··· 651 void 652 nouveau_mem_timing_init(struct drm_device *dev) 653 { 654 struct drm_nouveau_private *dev_priv = dev->dev_private; 655 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 656 struct nouveau_pm_memtimings *memtimings = &pm->memtimings; ··· 718 tUNK_19 = 1; 719 tUNK_20 = 0; 720 tUNK_21 = 0; 721 - switch (MIN(recordlen,21)) { 722 - case 21: 723 tUNK_21 = entry[21]; 724 - case 20: 725 tUNK_20 = entry[20]; 726 - case 19: 727 tUNK_19 = entry[19]; 728 - case 18: 729 tUNK_18 = entry[18]; 730 default: 731 tUNK_0 = entry[0]; ··· 755 timing->reg_100228 = (tUNK_12 << 16 | tUNK_11 << 8 | tUNK_10); 756 if(recordlen > 19) { 757 timing->reg_100228 += (tUNK_19 - 1) << 24; 758 - } else { 759 timing->reg_100228 += tUNK_12 << 24; 760 - } 761 762 /* XXX: reg_10022c */ 763 764 timing->reg_100230 = (tUNK_20 << 24 | tUNK_21 << 16 | 765 tUNK_13 << 8 | tUNK_13); 766 767 /* XXX: +6? */ 768 timing->reg_100234 = (tRAS << 24 | (tUNK_19 + 6) << 8 | tRC); 769 - if(tUNK_10 > tUNK_11) { 770 - timing->reg_100234 += tUNK_10 << 16; 771 - } else { 772 - timing->reg_100234 += tUNK_11 << 16; 773 } 774 775 - /* XXX; reg_100238, reg_10023c */ 776 NV_DEBUG(dev, "Entry %d: 220: %08x %08x %08x %08x\n", i, 777 timing->reg_100220, timing->reg_100224, 778 timing->reg_100228, timing->reg_10022c);
··· 33 #include "drmP.h" 34 #include "drm.h" 35 #include "drm_sarea.h" 36 37 + #include "nouveau_drv.h" 38 + #include "nouveau_pm.h" 39 40 /* 41 * NV10-NV40 tiling helpers ··· 175 } 176 } 177 } 178 179 + dev_priv->engine.instmem.flush(dev); 180 + dev_priv->engine.fifo.tlb_flush(dev); 181 + dev_priv->engine.graph.tlb_flush(dev); 182 nv50_vm_flush(dev, 6); 183 return 0; 184 } ··· 209 pte++; 210 } 211 } 212 213 + dev_priv->engine.instmem.flush(dev); 214 + dev_priv->engine.fifo.tlb_flush(dev); 215 + dev_priv->engine.graph.tlb_flush(dev); 216 nv50_vm_flush(dev, 6); 217 } 218 ··· 653 void 654 nouveau_mem_timing_init(struct drm_device *dev) 655 { 656 + /* cards < NVC0 only */ 657 struct drm_nouveau_private *dev_priv = dev->dev_private; 658 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 659 struct nouveau_pm_memtimings *memtimings = &pm->memtimings; ··· 719 tUNK_19 = 1; 720 tUNK_20 = 0; 721 tUNK_21 = 0; 722 + switch (min(recordlen, 22)) { 723 + case 22: 724 tUNK_21 = entry[21]; 725 + case 21: 726 tUNK_20 = entry[20]; 727 + case 20: 728 tUNK_19 = entry[19]; 729 + case 19: 730 tUNK_18 = entry[18]; 731 default: 732 tUNK_0 = entry[0]; ··· 756 timing->reg_100228 = (tUNK_12 << 16 | tUNK_11 << 8 | tUNK_10); 757 if(recordlen > 19) { 758 timing->reg_100228 += (tUNK_19 - 1) << 24; 759 + }/* I cannot back-up this else-statement right now 760 + else { 761 timing->reg_100228 += tUNK_12 << 24; 762 + }*/ 763 764 /* XXX: reg_10022c */ 765 + timing->reg_10022c = tUNK_2 - 1; 766 767 timing->reg_100230 = (tUNK_20 << 24 | tUNK_21 << 16 | 768 tUNK_13 << 8 | tUNK_13); 769 770 /* XXX: +6? */ 771 timing->reg_100234 = (tRAS << 24 | (tUNK_19 + 6) << 8 | tRC); 772 + timing->reg_100234 += max(tUNK_10,tUNK_11) << 16; 773 + 774 + /* XXX; reg_100238, reg_10023c 775 + * reg: 0x00?????? 776 + * reg_10023c: 777 + * 0 for pre-NV50 cards 778 + * 0x????0202 for NV50+ cards (empirical evidence) */ 779 + if(dev_priv->card_type >= NV_50) { 780 + timing->reg_10023c = 0x202; 781 } 782 783 NV_DEBUG(dev, "Entry %d: 220: %08x %08x %08x %08x\n", i, 784 timing->reg_100220, timing->reg_100224, 785 timing->reg_100228, timing->reg_10022c);
+1 -1
drivers/gpu/drm/nouveau/nouveau_object.c
··· 129 if (ramin == NULL) { 130 spin_unlock(&dev_priv->ramin_lock); 131 nouveau_gpuobj_ref(NULL, &gpuobj); 132 - return ret; 133 } 134 135 ramin = drm_mm_get_block_atomic(ramin, size, align);
··· 129 if (ramin == NULL) { 130 spin_unlock(&dev_priv->ramin_lock); 131 nouveau_gpuobj_ref(NULL, &gpuobj); 132 + return -ENOMEM; 133 } 134 135 ramin = drm_mm_get_block_atomic(ramin, size, align);
+6 -1
drivers/gpu/drm/nouveau/nouveau_pm.c
··· 284 } 285 } 286 287 static ssize_t 288 nouveau_hwmon_show_temp(struct device *d, struct device_attribute *a, char *buf) 289 { ··· 396 static const struct attribute_group hwmon_attrgroup = { 397 .attrs = hwmon_attributes, 398 }; 399 400 static int 401 nouveau_hwmon_init(struct drm_device *dev) 402 { 403 struct drm_nouveau_private *dev_priv = dev->dev_private; 404 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 405 struct device *hwmon_dev; ··· 428 } 429 430 pm->hwmon = hwmon_dev; 431 - 432 return 0; 433 } 434 435 static void 436 nouveau_hwmon_fini(struct drm_device *dev) 437 { 438 struct drm_nouveau_private *dev_priv = dev->dev_private; 439 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 440 ··· 443 sysfs_remove_group(&pm->hwmon->kobj, &hwmon_attrgroup); 444 hwmon_device_unregister(pm->hwmon); 445 } 446 } 447 448 int
··· 284 } 285 } 286 287 + #ifdef CONFIG_HWMON 288 static ssize_t 289 nouveau_hwmon_show_temp(struct device *d, struct device_attribute *a, char *buf) 290 { ··· 395 static const struct attribute_group hwmon_attrgroup = { 396 .attrs = hwmon_attributes, 397 }; 398 + #endif 399 400 static int 401 nouveau_hwmon_init(struct drm_device *dev) 402 { 403 + #ifdef CONFIG_HWMON 404 struct drm_nouveau_private *dev_priv = dev->dev_private; 405 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 406 struct device *hwmon_dev; ··· 425 } 426 427 pm->hwmon = hwmon_dev; 428 + #endif 429 return 0; 430 } 431 432 static void 433 nouveau_hwmon_fini(struct drm_device *dev) 434 { 435 + #ifdef CONFIG_HWMON 436 struct drm_nouveau_private *dev_priv = dev->dev_private; 437 struct nouveau_pm_engine *pm = &dev_priv->engine.pm; 438 ··· 439 sysfs_remove_group(&pm->hwmon->kobj, &hwmon_attrgroup); 440 hwmon_device_unregister(pm->hwmon); 441 } 442 + #endif 443 } 444 445 int
+44 -27
drivers/gpu/drm/nouveau/nouveau_ramht.c
··· 153 return -ENOMEM; 154 } 155 156 static void 157 - nouveau_ramht_remove_locked(struct nouveau_channel *chan, u32 handle) 158 { 159 struct drm_device *dev = chan->dev; 160 struct drm_nouveau_private *dev_priv = dev->dev_private; 161 struct nouveau_instmem_engine *instmem = &dev_priv->engine.instmem; 162 struct nouveau_gpuobj *ramht = chan->ramht->gpuobj; 163 - struct nouveau_ramht_entry *entry, *tmp; 164 u32 co, ho; 165 166 - list_for_each_entry_safe(entry, tmp, &chan->ramht->entries, head) { 167 - if (entry->channel != chan || entry->handle != handle) 168 - continue; 169 - 170 - nouveau_gpuobj_ref(NULL, &entry->gpuobj); 171 - list_del(&entry->head); 172 - kfree(entry); 173 - break; 174 - } 175 - 176 co = ho = nouveau_ramht_hash_handle(chan, handle); 177 do { 178 if (nouveau_ramht_entry_valid(dev, ramht, co) && ··· 200 nv_wo32(ramht, co + 0, 0x00000000); 201 nv_wo32(ramht, co + 4, 0x00000000); 202 instmem->flush(dev); 203 - return; 204 } 205 206 co += 8; ··· 210 211 NV_ERROR(dev, "RAMHT entry not found. ch=%d, handle=0x%08x\n", 212 chan->id, handle); 213 } 214 215 void 216 nouveau_ramht_remove(struct nouveau_channel *chan, u32 handle) 217 { 218 - struct nouveau_ramht *ramht = chan->ramht; 219 - unsigned long flags; 220 221 - spin_lock_irqsave(&ramht->lock, flags); 222 - nouveau_ramht_remove_locked(chan, handle); 223 - spin_unlock_irqrestore(&ramht->lock, flags); 224 } 225 226 struct nouveau_gpuobj * ··· 286 nouveau_ramht_ref(struct nouveau_ramht *ref, struct nouveau_ramht **ptr, 287 struct nouveau_channel *chan) 288 { 289 - struct nouveau_ramht_entry *entry, *tmp; 290 struct nouveau_ramht *ramht; 291 - unsigned long flags; 292 293 if (ref) 294 kref_get(&ref->refcount); 295 296 ramht = *ptr; 297 if (ramht) { 298 - spin_lock_irqsave(&ramht->lock, flags); 299 - list_for_each_entry_safe(entry, tmp, &ramht->entries, head) { 300 - if (entry->channel != chan) 301 - continue; 302 - 303 - nouveau_ramht_remove_locked(chan, entry->handle); 304 } 305 - spin_unlock_irqrestore(&ramht->lock, flags); 306 307 kref_put(&ramht->refcount, nouveau_ramht_del); 308 }
··· 153 return -ENOMEM; 154 } 155 156 + static struct nouveau_ramht_entry * 157 + nouveau_ramht_remove_entry(struct nouveau_channel *chan, u32 handle) 158 + { 159 + struct nouveau_ramht *ramht = chan ? chan->ramht : NULL; 160 + struct nouveau_ramht_entry *entry; 161 + unsigned long flags; 162 + 163 + if (!ramht) 164 + return NULL; 165 + 166 + spin_lock_irqsave(&ramht->lock, flags); 167 + list_for_each_entry(entry, &ramht->entries, head) { 168 + if (entry->channel == chan && 169 + (!handle || entry->handle == handle)) { 170 + list_del(&entry->head); 171 + spin_unlock_irqrestore(&ramht->lock, flags); 172 + 173 + return entry; 174 + } 175 + } 176 + spin_unlock_irqrestore(&ramht->lock, flags); 177 + 178 + return NULL; 179 + } 180 + 181 static void 182 + nouveau_ramht_remove_hash(struct nouveau_channel *chan, u32 handle) 183 { 184 struct drm_device *dev = chan->dev; 185 struct drm_nouveau_private *dev_priv = dev->dev_private; 186 struct nouveau_instmem_engine *instmem = &dev_priv->engine.instmem; 187 struct nouveau_gpuobj *ramht = chan->ramht->gpuobj; 188 + unsigned long flags; 189 u32 co, ho; 190 191 + spin_lock_irqsave(&chan->ramht->lock, flags); 192 co = ho = nouveau_ramht_hash_handle(chan, handle); 193 do { 194 if (nouveau_ramht_entry_valid(dev, ramht, co) && ··· 184 nv_wo32(ramht, co + 0, 0x00000000); 185 nv_wo32(ramht, co + 4, 0x00000000); 186 instmem->flush(dev); 187 + goto out; 188 } 189 190 co += 8; ··· 194 195 NV_ERROR(dev, "RAMHT entry not found. ch=%d, handle=0x%08x\n", 196 chan->id, handle); 197 + out: 198 + spin_unlock_irqrestore(&chan->ramht->lock, flags); 199 } 200 201 void 202 nouveau_ramht_remove(struct nouveau_channel *chan, u32 handle) 203 { 204 + struct nouveau_ramht_entry *entry; 205 206 + entry = nouveau_ramht_remove_entry(chan, handle); 207 + if (!entry) 208 + return; 209 + 210 + nouveau_ramht_remove_hash(chan, entry->handle); 211 + nouveau_gpuobj_ref(NULL, &entry->gpuobj); 212 + kfree(entry); 213 } 214 215 struct nouveau_gpuobj * ··· 265 nouveau_ramht_ref(struct nouveau_ramht *ref, struct nouveau_ramht **ptr, 266 struct nouveau_channel *chan) 267 { 268 + struct nouveau_ramht_entry *entry; 269 struct nouveau_ramht *ramht; 270 271 if (ref) 272 kref_get(&ref->refcount); 273 274 ramht = *ptr; 275 if (ramht) { 276 + while ((entry = nouveau_ramht_remove_entry(chan, 0))) { 277 + nouveau_ramht_remove_hash(chan, entry->handle); 278 + nouveau_gpuobj_ref(NULL, &entry->gpuobj); 279 + kfree(entry); 280 } 281 282 kref_put(&ramht->refcount, nouveau_ramht_del); 283 }
+9 -5
drivers/gpu/drm/nouveau/nouveau_sgdma.c
··· 120 dev_priv->engine.instmem.flush(nvbe->dev); 121 122 if (dev_priv->card_type == NV_50) { 123 - nv50_vm_flush(dev, 5); /* PGRAPH */ 124 - nv50_vm_flush(dev, 0); /* PFIFO */ 125 } 126 127 nvbe->bound = true; ··· 162 dev_priv->engine.instmem.flush(nvbe->dev); 163 164 if (dev_priv->card_type == NV_50) { 165 - nv50_vm_flush(dev, 5); 166 - nv50_vm_flush(dev, 0); 167 } 168 169 nvbe->bound = false; ··· 224 int i, ret; 225 226 if (dev_priv->card_type < NV_50) { 227 - aper_size = (64 * 1024 * 1024); 228 obj_size = (aper_size >> NV_CTXDMA_PAGE_SHIFT) * 4; 229 obj_size += 8; /* ctxdma header */ 230 } else {
··· 120 dev_priv->engine.instmem.flush(nvbe->dev); 121 122 if (dev_priv->card_type == NV_50) { 123 + dev_priv->engine.fifo.tlb_flush(dev); 124 + dev_priv->engine.graph.tlb_flush(dev); 125 } 126 127 nvbe->bound = true; ··· 162 dev_priv->engine.instmem.flush(nvbe->dev); 163 164 if (dev_priv->card_type == NV_50) { 165 + dev_priv->engine.fifo.tlb_flush(dev); 166 + dev_priv->engine.graph.tlb_flush(dev); 167 } 168 169 nvbe->bound = false; ··· 224 int i, ret; 225 226 if (dev_priv->card_type < NV_50) { 227 + if(dev_priv->ramin_rsvd_vram < 2 * 1024 * 1024) 228 + aper_size = 64 * 1024 * 1024; 229 + else 230 + aper_size = 512 * 1024 * 1024; 231 + 232 obj_size = (aper_size >> NV_CTXDMA_PAGE_SHIFT) * 4; 233 obj_size += 8; /* ctxdma header */ 234 } else {
+15 -2
drivers/gpu/drm/nouveau/nouveau_state.c
··· 354 engine->graph.destroy_context = nv50_graph_destroy_context; 355 engine->graph.load_context = nv50_graph_load_context; 356 engine->graph.unload_context = nv50_graph_unload_context; 357 engine->fifo.channels = 128; 358 engine->fifo.init = nv50_fifo_init; 359 engine->fifo.takedown = nv50_fifo_takedown; ··· 374 engine->fifo.destroy_context = nv50_fifo_destroy_context; 375 engine->fifo.load_context = nv50_fifo_load_context; 376 engine->fifo.unload_context = nv50_fifo_unload_context; 377 engine->display.early_init = nv50_display_early_init; 378 engine->display.late_takedown = nv50_display_late_takedown; 379 engine->display.create = nv50_display_create; ··· 1051 case NOUVEAU_GETPARAM_PTIMER_TIME: 1052 getparam->value = dev_priv->engine.timer.read(dev); 1053 break; 1054 case NOUVEAU_GETPARAM_GRAPH_UNITS: 1055 /* NV40 and NV50 versions are quite different, but register 1056 * address is the same. User is supposed to know the card ··· 1064 } 1065 /* FALLTHRU */ 1066 default: 1067 - NV_ERROR(dev, "unknown parameter %lld\n", getparam->param); 1068 return -EINVAL; 1069 } 1070 ··· 1079 1080 switch (setparam->param) { 1081 default: 1082 - NV_ERROR(dev, "unknown parameter %lld\n", setparam->param); 1083 return -EINVAL; 1084 } 1085
··· 354 engine->graph.destroy_context = nv50_graph_destroy_context; 355 engine->graph.load_context = nv50_graph_load_context; 356 engine->graph.unload_context = nv50_graph_unload_context; 357 + if (dev_priv->chipset != 0x86) 358 + engine->graph.tlb_flush = nv50_graph_tlb_flush; 359 + else { 360 + /* from what i can see nvidia do this on every 361 + * pre-NVA3 board except NVAC, but, we've only 362 + * ever seen problems on NV86 363 + */ 364 + engine->graph.tlb_flush = nv86_graph_tlb_flush; 365 + } 366 engine->fifo.channels = 128; 367 engine->fifo.init = nv50_fifo_init; 368 engine->fifo.takedown = nv50_fifo_takedown; ··· 365 engine->fifo.destroy_context = nv50_fifo_destroy_context; 366 engine->fifo.load_context = nv50_fifo_load_context; 367 engine->fifo.unload_context = nv50_fifo_unload_context; 368 + engine->fifo.tlb_flush = nv50_fifo_tlb_flush; 369 engine->display.early_init = nv50_display_early_init; 370 engine->display.late_takedown = nv50_display_late_takedown; 371 engine->display.create = nv50_display_create; ··· 1041 case NOUVEAU_GETPARAM_PTIMER_TIME: 1042 getparam->value = dev_priv->engine.timer.read(dev); 1043 break; 1044 + case NOUVEAU_GETPARAM_HAS_BO_USAGE: 1045 + getparam->value = 1; 1046 + break; 1047 case NOUVEAU_GETPARAM_GRAPH_UNITS: 1048 /* NV40 and NV50 versions are quite different, but register 1049 * address is the same. User is supposed to know the card ··· 1051 } 1052 /* FALLTHRU */ 1053 default: 1054 + NV_DEBUG(dev, "unknown parameter %lld\n", getparam->param); 1055 return -EINVAL; 1056 } 1057 ··· 1066 1067 switch (setparam->param) { 1068 default: 1069 + NV_DEBUG(dev, "unknown parameter %lld\n", setparam->param); 1070 return -EINVAL; 1071 } 1072
+1 -1
drivers/gpu/drm/nouveau/nouveau_temp.c
··· 191 int offset = sensor->offset_mult / sensor->offset_div; 192 int core_temp; 193 194 - if (dev_priv->chipset >= 0x50) { 195 core_temp = nv_rd32(dev, 0x20008); 196 } else { 197 core_temp = nv_rd32(dev, 0x0015b4) & 0x1fff;
··· 191 int offset = sensor->offset_mult / sensor->offset_div; 192 int core_temp; 193 194 + if (dev_priv->card_type >= NV_50) { 195 core_temp = nv_rd32(dev, 0x20008); 196 } else { 197 core_temp = nv_rd32(dev, 0x0015b4) & 0x1fff;
+1 -6
drivers/gpu/drm/nouveau/nv04_crtc.c
··· 158 { 159 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 160 struct drm_device *dev = crtc->dev; 161 - struct drm_connector *connector; 162 unsigned char seq1 = 0, crtc17 = 0; 163 unsigned char crtc1A; 164 ··· 212 NVVgaSeqReset(dev, nv_crtc->index, false); 213 214 NVWriteVgaCrtc(dev, nv_crtc->index, NV_CIO_CRE_RPC1_INDEX, crtc1A); 215 - 216 - /* Update connector polling modes */ 217 - list_for_each_entry(connector, &dev->mode_config.connector_list, head) 218 - nouveau_connector_set_polling(connector); 219 } 220 221 static bool ··· 826 /* Update the framebuffer location. */ 827 regp->fb_start = nv_crtc->fb.offset & ~3; 828 regp->fb_start += (y * drm_fb->pitch) + (x * drm_fb->bits_per_pixel / 8); 829 - NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_START, regp->fb_start); 830 831 /* Update the arbitration parameters. */ 832 nouveau_calc_arb(dev, crtc->mode.clock, drm_fb->bits_per_pixel,
··· 158 { 159 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 160 struct drm_device *dev = crtc->dev; 161 unsigned char seq1 = 0, crtc17 = 0; 162 unsigned char crtc1A; 163 ··· 213 NVVgaSeqReset(dev, nv_crtc->index, false); 214 215 NVWriteVgaCrtc(dev, nv_crtc->index, NV_CIO_CRE_RPC1_INDEX, crtc1A); 216 } 217 218 static bool ··· 831 /* Update the framebuffer location. */ 832 regp->fb_start = nv_crtc->fb.offset & ~3; 833 regp->fb_start += (y * drm_fb->pitch) + (x * drm_fb->bits_per_pixel / 8); 834 + nv_set_crtc_base(dev, nv_crtc->index, regp->fb_start); 835 836 /* Update the arbitration parameters. */ 837 nouveau_calc_arb(dev, crtc->mode.clock, drm_fb->bits_per_pixel,
+7 -6
drivers/gpu/drm/nouveau/nv04_dfp.c
··· 185 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 186 struct nouveau_connector *nv_connector = nouveau_encoder_connector_get(nv_encoder); 187 188 - /* For internal panels and gpu scaling on DVI we need the native mode */ 189 - if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) { 190 - if (!nv_connector->native_mode) 191 - return false; 192 nv_encoder->mode = *nv_connector->native_mode; 193 adjusted_mode->clock = nv_connector->native_mode->clock; 194 - } else { 195 - nv_encoder->mode = *adjusted_mode; 196 } 197 198 return true;
··· 185 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 186 struct nouveau_connector *nv_connector = nouveau_encoder_connector_get(nv_encoder); 187 188 + if (!nv_connector->native_mode || 189 + nv_connector->scaling_mode == DRM_MODE_SCALE_NONE || 190 + mode->hdisplay > nv_connector->native_mode->hdisplay || 191 + mode->vdisplay > nv_connector->native_mode->vdisplay) { 192 + nv_encoder->mode = *adjusted_mode; 193 + 194 + } else { 195 nv_encoder->mode = *nv_connector->native_mode; 196 adjusted_mode->clock = nv_connector->native_mode->clock; 197 } 198 199 return true;
+9
drivers/gpu/drm/nouveau/nv04_pm.c
··· 76 reg += 4; 77 78 nouveau_hw_setpll(dev, reg, &state->calc); 79 kfree(state); 80 } 81
··· 76 reg += 4; 77 78 nouveau_hw_setpll(dev, reg, &state->calc); 79 + 80 + if (dev_priv->card_type < NV_30 && reg == NV_PRAMDAC_MPLL_COEFF) { 81 + if (dev_priv->card_type == NV_20) 82 + nv_mask(dev, 0x1002c4, 0, 1 << 20); 83 + 84 + /* Reset the DLLs */ 85 + nv_mask(dev, 0x1002c0, 0, 1 << 8); 86 + } 87 + 88 kfree(state); 89 } 90
+10 -6
drivers/gpu/drm/nouveau/nv50_calc.c
··· 51 int *N, int *fN, int *M, int *P) 52 { 53 fixed20_12 fb_div, a, b; 54 55 - *P = pll->vco1.maxfreq / clk; 56 if (*P > pll->max_p) 57 *P = pll->max_p; 58 if (*P < pll->min_p) 59 *P = pll->min_p; 60 61 - /* *M = ceil(refclk / pll->vco.max_inputfreq); */ 62 - a.full = dfixed_const(pll->refclk); 63 - b.full = dfixed_const(pll->vco1.max_inputfreq); 64 a.full = dfixed_div(a, b); 65 - a.full = dfixed_ceil(a); 66 *M = dfixed_trunc(a); 67 68 /* fb_div = (vco * *M) / refclk; */ 69 fb_div.full = dfixed_const(clk * *P); 70 fb_div.full = dfixed_mul(fb_div, a); 71 - a.full = dfixed_const(pll->refclk); 72 fb_div.full = dfixed_div(fb_div, a); 73 74 /* *N = floor(fb_div); */
··· 51 int *N, int *fN, int *M, int *P) 52 { 53 fixed20_12 fb_div, a, b; 54 + u32 refclk = pll->refclk / 10; 55 + u32 max_vco_freq = pll->vco1.maxfreq / 10; 56 + u32 max_vco_inputfreq = pll->vco1.max_inputfreq / 10; 57 + clk /= 10; 58 59 + *P = max_vco_freq / clk; 60 if (*P > pll->max_p) 61 *P = pll->max_p; 62 if (*P < pll->min_p) 63 *P = pll->min_p; 64 65 + /* *M = floor((refclk + max_vco_inputfreq) / max_vco_inputfreq); */ 66 + a.full = dfixed_const(refclk + max_vco_inputfreq); 67 + b.full = dfixed_const(max_vco_inputfreq); 68 a.full = dfixed_div(a, b); 69 + a.full = dfixed_floor(a); 70 *M = dfixed_trunc(a); 71 72 /* fb_div = (vco * *M) / refclk; */ 73 fb_div.full = dfixed_const(clk * *P); 74 fb_div.full = dfixed_mul(fb_div, a); 75 + a.full = dfixed_const(refclk); 76 fb_div.full = dfixed_div(fb_div, a); 77 78 /* *N = floor(fb_div); */
+2 -2
drivers/gpu/drm/nouveau/nv50_crtc.c
··· 546 } 547 548 nv_crtc->fb.offset = fb->nvbo->bo.offset - dev_priv->vm_vram_base; 549 - nv_crtc->fb.tile_flags = fb->nvbo->tile_flags; 550 nv_crtc->fb.cpp = drm_fb->bits_per_pixel / 8; 551 if (!nv_crtc->fb.blanked && dev_priv->chipset != 0x50) { 552 ret = RING_SPACE(evo, 2); ··· 578 fb->nvbo->tile_mode); 579 } 580 if (dev_priv->chipset == 0x50) 581 - OUT_RING(evo, (fb->nvbo->tile_flags << 8) | format); 582 else 583 OUT_RING(evo, format); 584
··· 546 } 547 548 nv_crtc->fb.offset = fb->nvbo->bo.offset - dev_priv->vm_vram_base; 549 + nv_crtc->fb.tile_flags = nouveau_bo_tile_layout(fb->nvbo); 550 nv_crtc->fb.cpp = drm_fb->bits_per_pixel / 8; 551 if (!nv_crtc->fb.blanked && dev_priv->chipset != 0x50) { 552 ret = RING_SPACE(evo, 2); ··· 578 fb->nvbo->tile_mode); 579 } 580 if (dev_priv->chipset == 0x50) 581 + OUT_RING(evo, (nv_crtc->fb.tile_flags << 8) | format); 582 else 583 OUT_RING(evo, format); 584
+26 -9
drivers/gpu/drm/nouveau/nv50_display.c
··· 1032 struct drm_connector *connector; 1033 const uint32_t gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 }; 1034 uint32_t unplug_mask, plug_mask, change_mask; 1035 - uint32_t hpd0, hpd1 = 0; 1036 1037 - hpd0 = nv_rd32(dev, 0xe054) & nv_rd32(dev, 0xe050); 1038 if (dev_priv->chipset >= 0x90) 1039 - hpd1 = nv_rd32(dev, 0xe074) & nv_rd32(dev, 0xe070); 1040 1041 plug_mask = (hpd0 & 0x0000ffff) | (hpd1 << 16); 1042 unplug_mask = (hpd0 >> 16) | (hpd1 & 0xffff0000); ··· 1085 helper->dpms(connector->encoder, DRM_MODE_DPMS_OFF); 1086 } 1087 1088 - nv_wr32(dev, 0xe054, nv_rd32(dev, 0xe054)); 1089 - if (dev_priv->chipset >= 0x90) 1090 - nv_wr32(dev, 0xe074, nv_rd32(dev, 0xe074)); 1091 - 1092 drm_helper_hpd_irq_event(dev); 1093 } 1094 ··· 1095 uint32_t delayed = 0; 1096 1097 if (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_HOTPLUG) { 1098 - if (!work_pending(&dev_priv->hpd_work)) 1099 - queue_work(dev_priv->wq, &dev_priv->hpd_work); 1100 } 1101 1102 while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) {
··· 1032 struct drm_connector *connector; 1033 const uint32_t gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 }; 1034 uint32_t unplug_mask, plug_mask, change_mask; 1035 + uint32_t hpd0, hpd1; 1036 1037 + spin_lock_irq(&dev_priv->hpd_state.lock); 1038 + hpd0 = dev_priv->hpd_state.hpd0_bits; 1039 + dev_priv->hpd_state.hpd0_bits = 0; 1040 + hpd1 = dev_priv->hpd_state.hpd1_bits; 1041 + dev_priv->hpd_state.hpd1_bits = 0; 1042 + spin_unlock_irq(&dev_priv->hpd_state.lock); 1043 + 1044 + hpd0 &= nv_rd32(dev, 0xe050); 1045 if (dev_priv->chipset >= 0x90) 1046 + hpd1 &= nv_rd32(dev, 0xe070); 1047 1048 plug_mask = (hpd0 & 0x0000ffff) | (hpd1 << 16); 1049 unplug_mask = (hpd0 >> 16) | (hpd1 & 0xffff0000); ··· 1078 helper->dpms(connector->encoder, DRM_MODE_DPMS_OFF); 1079 } 1080 1081 drm_helper_hpd_irq_event(dev); 1082 } 1083 ··· 1092 uint32_t delayed = 0; 1093 1094 if (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_HOTPLUG) { 1095 + uint32_t hpd0_bits, hpd1_bits = 0; 1096 + 1097 + hpd0_bits = nv_rd32(dev, 0xe054); 1098 + nv_wr32(dev, 0xe054, hpd0_bits); 1099 + 1100 + if (dev_priv->chipset >= 0x90) { 1101 + hpd1_bits = nv_rd32(dev, 0xe074); 1102 + nv_wr32(dev, 0xe074, hpd1_bits); 1103 + } 1104 + 1105 + spin_lock(&dev_priv->hpd_state.lock); 1106 + dev_priv->hpd_state.hpd0_bits |= hpd0_bits; 1107 + dev_priv->hpd_state.hpd1_bits |= hpd1_bits; 1108 + spin_unlock(&dev_priv->hpd_state.lock); 1109 + 1110 + queue_work(dev_priv->wq, &dev_priv->hpd_work); 1111 } 1112 1113 while (nv_rd32(dev, NV50_PMC_INTR_0) & NV50_PMC_INTR_0_DISPLAY) {
+5
drivers/gpu/drm/nouveau/nv50_fifo.c
··· 464 return 0; 465 } 466
··· 464 return 0; 465 } 466 467 + void 468 + nv50_fifo_tlb_flush(struct drm_device *dev) 469 + { 470 + nv50_vm_flush(dev, 5); 471 + }
+52
drivers/gpu/drm/nouveau/nv50_graph.c
··· 402 { 0x8597, false, NULL }, /* tesla (nva3, nva5, nva8) */ 403 {} 404 };
··· 402 { 0x8597, false, NULL }, /* tesla (nva3, nva5, nva8) */ 403 {} 404 }; 405 + 406 + void 407 + nv50_graph_tlb_flush(struct drm_device *dev) 408 + { 409 + nv50_vm_flush(dev, 0); 410 + } 411 + 412 + void 413 + nv86_graph_tlb_flush(struct drm_device *dev) 414 + { 415 + struct drm_nouveau_private *dev_priv = dev->dev_private; 416 + struct nouveau_timer_engine *ptimer = &dev_priv->engine.timer; 417 + bool idle, timeout = false; 418 + unsigned long flags; 419 + u64 start; 420 + u32 tmp; 421 + 422 + spin_lock_irqsave(&dev_priv->context_switch_lock, flags); 423 + nv_mask(dev, 0x400500, 0x00000001, 0x00000000); 424 + 425 + start = ptimer->read(dev); 426 + do { 427 + idle = true; 428 + 429 + for (tmp = nv_rd32(dev, 0x400380); tmp && idle; tmp >>= 3) { 430 + if ((tmp & 7) == 1) 431 + idle = false; 432 + } 433 + 434 + for (tmp = nv_rd32(dev, 0x400384); tmp && idle; tmp >>= 3) { 435 + if ((tmp & 7) == 1) 436 + idle = false; 437 + } 438 + 439 + for (tmp = nv_rd32(dev, 0x400388); tmp && idle; tmp >>= 3) { 440 + if ((tmp & 7) == 1) 441 + idle = false; 442 + } 443 + } while (!idle && !(timeout = ptimer->read(dev) - start > 2000000000)); 444 + 445 + if (timeout) { 446 + NV_ERROR(dev, "PGRAPH TLB flush idle timeout fail: " 447 + "0x%08x 0x%08x 0x%08x 0x%08x\n", 448 + nv_rd32(dev, 0x400700), nv_rd32(dev, 0x400380), 449 + nv_rd32(dev, 0x400384), nv_rd32(dev, 0x400388)); 450 + } 451 + 452 + nv50_vm_flush(dev, 0); 453 + 454 + nv_mask(dev, 0x400500, 0x00000001, 0x00000001); 455 + spin_unlock_irqrestore(&dev_priv->context_switch_lock, flags); 456 + }
-1
drivers/gpu/drm/nouveau/nv50_instmem.c
··· 402 } 403 dev_priv->engine.instmem.flush(dev); 404 405 - nv50_vm_flush(dev, 4); 406 nv50_vm_flush(dev, 6); 407 408 gpuobj->im_bound = 1;
··· 402 } 403 dev_priv->engine.instmem.flush(dev); 404 405 nv50_vm_flush(dev, 6); 406 407 gpuobj->im_bound = 1;
+7
include/drm/nouveau_drm.h
··· 80 #define NOUVEAU_GETPARAM_VM_VRAM_BASE 12 81 #define NOUVEAU_GETPARAM_GRAPH_UNITS 13 82 #define NOUVEAU_GETPARAM_PTIMER_TIME 14 83 struct drm_nouveau_getparam { 84 uint64_t param; 85 uint64_t value; ··· 95 #define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1) 96 #define NOUVEAU_GEM_DOMAIN_GART (1 << 2) 97 #define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) 98 99 struct drm_nouveau_gem_info { 100 uint32_t handle;
··· 80 #define NOUVEAU_GETPARAM_VM_VRAM_BASE 12 81 #define NOUVEAU_GETPARAM_GRAPH_UNITS 13 82 #define NOUVEAU_GETPARAM_PTIMER_TIME 14 83 + #define NOUVEAU_GETPARAM_HAS_BO_USAGE 15 84 struct drm_nouveau_getparam { 85 uint64_t param; 86 uint64_t value; ··· 94 #define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1) 95 #define NOUVEAU_GEM_DOMAIN_GART (1 << 2) 96 #define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) 97 + 98 + #define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00 99 + #define NOUVEAU_GEM_TILE_16BPP 0x00000001 100 + #define NOUVEAU_GEM_TILE_32BPP 0x00000002 101 + #define NOUVEAU_GEM_TILE_ZETA 0x00000004 102 + #define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008 103 104 struct drm_nouveau_gem_info { 105 uint32_t handle;