2018-10-18 23:03:32 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
2017-07-06 22:06:01 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013-2017 Oracle Corporation
|
|
|
|
* This file is based on ast_ttm.c
|
|
|
|
* Copyright 2012 Red Hat Inc.
|
|
|
|
* Authors: Dave Airlie <airlied@redhat.com>
|
|
|
|
* Michael Thayer <michael.thayer@oracle.com>
|
|
|
|
*/
|
2018-10-22 22:57:45 +08:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <drm/drm_file.h>
|
2017-07-06 22:06:01 +08:00
|
|
|
#include "vbox_drv.h"
|
|
|
|
|
|
|
|
int vbox_mm_init(struct vbox_private *vbox)
|
|
|
|
{
|
|
|
|
int ret;
|
2021-09-17 02:16:01 +08:00
|
|
|
resource_size_t base, size;
|
2018-09-19 01:44:30 +08:00
|
|
|
struct drm_device *dev = &vbox->ddev;
|
2020-12-01 18:35:39 +08:00
|
|
|
struct pci_dev *pdev = to_pci_dev(dev->dev);
|
2017-07-06 22:06:01 +08:00
|
|
|
|
2021-09-17 02:16:01 +08:00
|
|
|
base = pci_resource_start(pdev, 0);
|
|
|
|
size = pci_resource_len(pdev, 0);
|
|
|
|
|
|
|
|
/* Don't fail on errors, but performance might be reduced. */
|
|
|
|
devm_arch_phys_wc_add(&pdev->dev, base, size);
|
|
|
|
|
|
|
|
ret = drmm_vram_helper_init(dev, base, vbox->available_vram_size);
|
2021-03-03 09:39:46 +08:00
|
|
|
if (ret) {
|
2019-05-08 16:26:28 +08:00
|
|
|
DRM_ERROR("Error initializing VRAM MM; %d\n", ret);
|
2018-10-19 22:55:26 +08:00
|
|
|
return ret;
|
2017-07-06 22:06:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|