2019-10-25 23:37:22 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/*
|
|
|
|
* Copyright © 2019 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "intel_memory_region.h"
|
|
|
|
#include "gem/i915_gem_region.h"
|
|
|
|
#include "gem/i915_gem_lmem.h"
|
|
|
|
#include "i915_drv.h"
|
|
|
|
|
2021-04-27 16:54:16 +08:00
|
|
|
void __iomem *
|
|
|
|
i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj,
|
|
|
|
unsigned long n,
|
|
|
|
unsigned long size)
|
|
|
|
{
|
|
|
|
resource_size_t offset;
|
|
|
|
|
|
|
|
GEM_BUG_ON(!i915_gem_object_is_contiguous(obj));
|
|
|
|
|
|
|
|
offset = i915_gem_object_get_dma_address(obj, n);
|
|
|
|
offset -= obj->mm.region->region.start;
|
|
|
|
|
|
|
|
return io_mapping_map_wc(&obj->mm.region->iomap, offset, size);
|
|
|
|
}
|
|
|
|
|
2019-10-25 23:37:22 +08:00
|
|
|
bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj)
|
|
|
|
{
|
2021-04-21 18:46:56 +08:00
|
|
|
struct intel_memory_region *mr = obj->mm.region;
|
|
|
|
|
|
|
|
return mr && (mr->type == INTEL_MEMORY_LOCAL ||
|
|
|
|
mr->type == INTEL_MEMORY_STOLEN_LOCAL);
|
2019-10-25 23:37:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct drm_i915_gem_object *
|
|
|
|
i915_gem_object_create_lmem(struct drm_i915_private *i915,
|
|
|
|
resource_size_t size,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
return i915_gem_object_create_region(i915->mm.regions[INTEL_REGION_LMEM],
|
|
|
|
size, flags);
|
|
|
|
}
|