vbox_ttm.c (844B)
1// SPDX-License-Identifier: MIT 2/* 3 * Copyright (C) 2013-2017 Oracle Corporation 4 * This file is based on ast_ttm.c 5 * Copyright 2012 Red Hat Inc. 6 * Authors: Dave Airlie <airlied@redhat.com> 7 * Michael Thayer <michael.thayer@oracle.com> 8 */ 9#include <linux/pci.h> 10#include <drm/drm_file.h> 11#include "vbox_drv.h" 12 13int vbox_mm_init(struct vbox_private *vbox) 14{ 15 int ret; 16 resource_size_t base, size; 17 struct drm_device *dev = &vbox->ddev; 18 struct pci_dev *pdev = to_pci_dev(dev->dev); 19 20 base = pci_resource_start(pdev, 0); 21 size = pci_resource_len(pdev, 0); 22 23 /* Don't fail on errors, but performance might be reduced. */ 24 devm_arch_phys_wc_add(&pdev->dev, base, size); 25 26 ret = drmm_vram_helper_init(dev, base, vbox->available_vram_size); 27 if (ret) { 28 DRM_ERROR("Error initializing VRAM MM; %d\n", ret); 29 return ret; 30 } 31 32 return 0; 33}