This source file includes following definitions.
- vbox_mm_init
- vbox_mm_fini
1
2
3
4
5
6
7
8
9 #include <linux/pci.h>
10 #include <drm/drm_file.h>
11 #include "vbox_drv.h"
12
13 int vbox_mm_init(struct vbox_private *vbox)
14 {
15 struct drm_vram_mm *vmm;
16 int ret;
17 struct drm_device *dev = &vbox->ddev;
18
19 vmm = drm_vram_helper_alloc_mm(dev, pci_resource_start(dev->pdev, 0),
20 vbox->available_vram_size,
21 &drm_gem_vram_mm_funcs);
22 if (IS_ERR(vmm)) {
23 ret = PTR_ERR(vmm);
24 DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
25 return ret;
26 }
27
28 #ifdef DRM_MTRR_WC
29 vbox->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 0),
30 pci_resource_len(dev->pdev, 0),
31 DRM_MTRR_WC);
32 #else
33 vbox->fb_mtrr = arch_phys_wc_add(pci_resource_start(dev->pdev, 0),
34 pci_resource_len(dev->pdev, 0));
35 #endif
36 return 0;
37 }
38
39 void vbox_mm_fini(struct vbox_private *vbox)
40 {
41 #ifdef DRM_MTRR_WC
42 drm_mtrr_del(vbox->fb_mtrr,
43 pci_resource_start(vbox->ddev.pdev, 0),
44 pci_resource_len(vbox->ddev.pdev, 0), DRM_MTRR_WC);
45 #else
46 arch_phys_wc_del(vbox->fb_mtrr);
47 #endif
48 drm_vram_helper_release_mm(&vbox->ddev);
49 }