Changeset 66523 in vbox
- Timestamp:
- Apr 12, 2017 10:22:50 AM (8 years ago)
- Location:
- trunk/src/VBox/Additions/linux/drm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/drm/vbox_drv.h
r66189 r66523 90 90 #define VBOX_MAX_SCREENS 32 91 91 92 #define GUEST_HEAP_OFFSET(vbox) (vbox->full_vram_size - VBVA_ADAPTER_INFORMATION_SIZE) 93 #define GUEST_HEAP_SIZE VBVA_ADAPTER_INFORMATION_SIZE 94 #define GUEST_HEAP_USABLE_SIZE (VBVA_ADAPTER_INFORMATION_SIZE - \ 95 sizeof(HGSMIHOSTFLAGS)) 96 #define HOST_FLAGS_OFFSET GUEST_HEAP_USABLE_SIZE 97 92 98 struct vbox_fbdev; 93 99 … … 95 101 struct drm_device *dev; 96 102 97 uint8_t __iomem *mapped_vram; 103 u8 __iomem *guest_heap; 104 u8 __iomem *vbva_buffers; 98 105 HGSMIGUESTCOMMANDCONTEXT submit_info; 99 106 struct VBVABUFFERCONTEXT *vbva_info; … … 104 111 /** Amount of available VRAM, not including space used for buffers. */ 105 112 uint32_t available_vram_size; 106 /** Offset of mapped VRAM area in full VRAM. */107 uint32_t vram_map_start;108 /** Offset to the host flags in the VRAM. */109 uint32_t host_flags_offset;110 113 /** Array of structures for receiving mode hints. */ 111 114 VBVAMODEHINT *last_mode_hints; -
trunk/src/VBox/Additions/linux/drm/vbox_irq.c
r66224 r66523 57 57 static uint32_t vbox_get_flags(struct vbox_private *vbox) 58 58 { 59 return (uint32_t)readl(vbox->mapped_vram + vbox->host_flags_offset);59 return readl(vbox->guest_heap + HOST_FLAGS_OFFSET); 60 60 } 61 61 -
trunk/src/VBox/Additions/linux/drm/vbox_main.c
r66509 r66523 68 68 unsigned i; 69 69 struct VBVABUFFER *vbva; 70 uint32_t vram_map_offset = vbox->available_vram_size - vbox->vram_map_start; 71 72 if (vbox->vbva_info == NULL) { /* Should never happen... */ 70 71 if (!vbox->vbva_info || !vbox->vbva_buffers) { /* Should never happen... */ 73 72 printk(KERN_ERR "vboxvideo: failed to set up VBVA.\n"); 74 73 return; … … 76 75 for (i = 0; i < vbox->num_crtcs; ++i) { 77 76 if (vbox->vbva_info[i].pVBVA == NULL) { 78 vbva = (struct VBVABUFFER *) ( ((uint8_t *)vbox->mapped_vram) 79 + vram_map_offset 77 vbva = (struct VBVABUFFER *) ((u8 *)vbox->vbva_buffers 80 78 + i * VBVA_MIN_BUFFER_SIZE); 81 79 if (!VBoxVBVAEnable(&vbox->vbva_info[i], &vbox->submit_info, vbva, i)) { … … 238 236 vbox->vbva_info = NULL; 239 237 } 238 if (vbox->vbva_buffers) { 239 pci_iounmap(vbox->dev->pdev, vbox->vbva_buffers); 240 vbox->vbva_buffers = NULL; 241 } 240 242 } 241 243 … … 251 253 /* Take a command buffer for each screen from the end of usable VRAM. */ 252 254 vbox->available_vram_size -= vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE; 255 256 vbox->vbva_buffers = pci_iomap_range(vbox->dev->pdev, 0, 257 vbox->available_vram_size, 258 vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE); 259 if (!vbox->vbva_buffers) 260 return -ENOMEM; 261 253 262 for (i = 0; i < vbox->num_crtcs; ++i) 254 263 VBoxVBVASetupBufferContext(&vbox->vbva_info[i], … … 303 312 static int vbox_hw_init(struct vbox_private *vbox) 304 313 { 305 uint32_t base_offset, map_start, guest_heap_offset, guest_heap_size, host_flags_offset;306 void *guest_heap;307 308 314 vbox->full_vram_size = VBoxVideoGetVRAMSize(); 309 315 vbox->any_pitch = VBoxVideoAnyWidthAllowed(); 310 316 DRM_INFO("VRAM %08x\n", vbox->full_vram_size); 311 VBoxHGSMIGetBaseMappingInfo(vbox->full_vram_size, &base_offset, NULL, 312 &guest_heap_offset, &guest_heap_size, &host_flags_offset); 313 map_start = (uint32_t)max((int)base_offset 314 - VBOX_MAX_SCREENS * VBVA_MIN_BUFFER_SIZE, 0); 315 vbox->mapped_vram = pci_iomap_range(vbox->dev->pdev, 0, map_start, 316 vbox->full_vram_size - map_start); 317 if (!vbox->mapped_vram) 317 318 /* Map guest-heap at end of vram */ 319 vbox->guest_heap = pci_iomap_range(vbox->dev->pdev, 0, GUEST_HEAP_OFFSET(vbox), 320 GUEST_HEAP_SIZE); 321 if (!vbox->guest_heap) 318 322 return -ENOMEM; 319 vbox->vram_map_start = map_start; 320 guest_heap = ((uint8_t *)vbox->mapped_vram) + base_offset - map_start 321 + guest_heap_offset; 322 vbox->host_flags_offset = base_offset - map_start + host_flags_offset; 323 if (RT_FAILURE(VBoxHGSMISetupGuestContext(&vbox->submit_info, guest_heap, 324 guest_heap_size, 325 base_offset + guest_heap_offset, 323 324 if (RT_FAILURE(VBoxHGSMISetupGuestContext(&vbox->submit_info, vbox->guest_heap, 325 GUEST_HEAP_USABLE_SIZE, GUEST_HEAP_OFFSET(vbox), 326 326 &hgsmi_environ))) 327 327 return -ENOMEM; 328 328 /* Reduce available VRAM size to reflect the guest heap. */ 329 vbox->available_vram_size = base_offset;329 vbox->available_vram_size = GUEST_HEAP_OFFSET(vbox); 330 330 /* Linux drm represents monitors as a 32-bit array. */ 331 331 vbox->num_crtcs = min(VBoxHGSMIGetMonitorCount(&vbox->submit_info), … … 413 413 vbox_hw_fini(vbox); 414 414 vbox_mm_fini(vbox); 415 if (vbox-> mapped_vram)416 pci_iounmap(dev->pdev, vbox-> mapped_vram);415 if (vbox->guest_heap) 416 pci_iounmap(dev->pdev, vbox->guest_heap); 417 417 kfree(vbox); 418 418 dev->dev_private = NULL; -
trunk/src/VBox/Additions/linux/drm/vbox_mode.c
r65992 r66523 547 547 * We need to report the flags location before reporting the IRQ 548 548 * capability. */ 549 VBoxHGSMIReportFlagsLocation(&vbox->submit_info, vbox->vram_map_start550 + vbox->host_flags_offset);549 VBoxHGSMIReportFlagsLocation(&vbox->submit_info, GUEST_HEAP_OFFSET(vbox) + 550 HOST_FLAGS_OFFSET); 551 551 if (vbox_connector->vbox_crtc->crtc_id == 0) 552 552 vbox_report_caps(vbox);
Note:
See TracChangeset
for help on using the changeset viewer.