drm-misc-next for 5.11:
UAPI Changes:
- doc: rules for EBUSY on non-blocking commits; requirements for fourcc
modifiers; on parsing EDID
- fbdev/sbuslib: Remove unused FBIOSCURSOR32
- fourcc: deprecate DRM_FORMAT_MOD_NONE
- virtio: Support blob resources for memory allocations; Expose host-visible
and cross-device features
Cross-subsystem Changes:
- devicetree: Add vendor Prefix for Yes Optoelectronics, Shanghai Top Display
Optoelectronics
- dma-buf: Add struct dma_buf_map that stores DMA pointer and I/O-memory flag;
dma_buf_vmap()/vunmap() return address in dma_buf_map; Use struct_size() macro
Core Changes:
- atomic: pass full state to CRTC atomic enable/disable; warn for EBUSY during
non-blocking commits
- dp: Prepare for DP 2.0 DPCD
- dp_mst: Receive extended DPCD caps
- dma-buf: Documentation
- doc: Format modifiers; dma-buf-map; Cleanups
- fbdev: Don't use compat_alloc_user_space(); mark as orphaned
- fb-helper: Take lock in drm_fb_helper_restore_work_fb()
- gem: Convert implementation and drivers to GEM object functions, remove
GEM callbacks from struct drm_driver (expect gem_prime_mmap)
- panel: Cleanups
- pci: Add legacy infix to drm_irq_by_busid()
- sched: Avoid infinite waits in drm_sched_entity_destroy()
- switcheroo: Cleanups
- ttm: Remove AGP support; Don't modify caching during swapout; Major
refactoring of the implementation and API that affects all depending
drivers; Add ttm_bo_wait_ctx(); Add ttm_bo_pin()/unpin() in favor of
TTM_PL_FLAG_NO_EVICT; Remove ttm_bo_create(); Remove fault_reserve_notify()
callback; Push move() implementation into drivers; Remove TTM_PAGE_FLAG_WRITE;
Replace caching flags with init-time cache setting; Push ttm_tt_bind() into
drivers; Replace move_notify() with delete_mem_notify(); No overlapping memcpy();
no more ttm_set_populated()
- vram-helper: Fix BO top-down placement; TTM-related changes; Init GEM
object functions with defaults; Default placement in system memory; Cleanups
Driver Changes:
- amdgpu: Use GEM object functions
- armada: Use GEM object functions
- aspeed: Configure output via sysfs; Init struct drm_driver with
- ast: Reload LUT after FB format changes
- bridge: Add driver and DT bindings for anx7625; Cleanups
- bridge/dw-hdmi: Constify ops
- bridge/ti-sn65dsi86: Add retries for link training
- bridge/lvds-codec: Add support for regulator
- bridge/tc358768: Restore connector support DRM_GEM_CMA_DRIVEROPS; Cleanups
- display/ti,j721e-dss: Add DT properies assigned-clocks, assigned-clocks-parent and
dma-coherent
- display/ti,am65s-dss: Add DT properies assigned-clocks, assigned-clocks-parent and
dma-coherent
- etnaviv: Use GEM object functions
- exynos: Use GEM object functions
- fbdev: Cleanups and compiler fixes throughout framebuffer drivers
- fbdev/cirrusfb: Avoid division by 0
- gma500: Use GEM object functions; Fix double-free of connector; Cleanups
- hisilicon/hibmc: I2C-based DDC support; Use to_hibmc_drm_device(); Cleanups
- i915: Use GEM object functions
- imx/dcss: Init driver with DRM_GEM_CMA_DRIVER_OPS; Cleanups
- ingenic: Reset pixel clock when parent clock changes; support reserved
memory; Alloc F0 and F1 DMA channels at once; Support different pixel formats;
Revert support for cached mmap buffers
on F0/F1; support 30-bit/24-bit/8-bit-palette modes
- komeda: Use DEFINE_SHOW_ATTRIBUTE
- mcde: Detect platform_get_irq() errors
- mediatek: Use GEM object functions
- msm: Use GEM object functions
- nouveau: Cleanups; TTM-related changes; Use GEM object functions
- omapdrm: Use GEM object functions
- panel: Add driver and DT bindings for Novatak nt36672a; Add driver and DT
bindings for YTC700TLAG-05-201C; Add driver and DT bindings for TDO TL070WSH30;
Cleanups
- panel/mantix: Fix reset; Fix deref of NULL pointer in mantix_get_modes()
- panel/otm8009a: Allow non-continuous dsi clock; Cleanups
- panel/rm68200: Allow non-continuous dsi clock; Fix mode to 50 FPS
- panfrost: Fix job timeout handling; Cleanups
- pl111: Use GEM object functions
- qxl: Cleanups; TTM-related changes; Pin new BOs with ttm_bo_init_reserved()
- radeon: Cleanups; TTM-related changes; Use GEM object functions
- rockchip: Use GEM object functions
- shmobile: Cleanups
- tegra: Use GEM object functions
- tidss: Set drm_plane_helper_funcs.prepare_fb
- tilcdc: Don't keep vblank interrupt enabled all the time
- tve200: Detect platform_get_irq() errors
- vc4: Use GEM object functions; Only register components once DSI is attached;
Add Maxime as maintainer
- vgem: Use GEM object functions
- via: Simplify critical section in via_mem_alloc()
- virtgpu: Use GEM object functions
- virtio: Implement blob resources, host-visible and cross-device features;
Support mapping of host-allocated resources; Use UUID APi; Cleanups
- vkms: Use GEM object functions; Switch to SHMEM
- vmwgfx: TTM-related changes; Inline ttm_bo_swapout_all()
- xen: Use GEM object functions
- xlnx: Use GEM object functions
Signed-off-by: Dave Airlie <airlied@redhat.com>
From: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201027100936.GA4858@linux-uq9g
182 lines
4.4 KiB
C
182 lines
4.4 KiB
C
// SPDX-License-Identifier: GPL-2.0 OR MIT
|
|
/*
|
|
* Huge page-table-entry support for IO memory.
|
|
*
|
|
* Copyright (C) 2007-2019 Vmware, Inc. All rights reservedd.
|
|
*/
|
|
#include "vmwgfx_drv.h"
|
|
#include <drm/ttm/ttm_module.h>
|
|
#include <drm/ttm/ttm_bo_driver.h>
|
|
#include <drm/ttm/ttm_placement.h>
|
|
|
|
/**
|
|
* struct vmw_thp_manager - Range manager implementing huge page alignment
|
|
*
|
|
* @mm: The underlying range manager. Protected by @lock.
|
|
* @lock: Manager lock.
|
|
*/
|
|
struct vmw_thp_manager {
|
|
struct ttm_resource_manager manager;
|
|
struct drm_mm mm;
|
|
spinlock_t lock;
|
|
};
|
|
|
|
static struct vmw_thp_manager *to_thp_manager(struct ttm_resource_manager *man)
|
|
{
|
|
return container_of(man, struct vmw_thp_manager, manager);
|
|
}
|
|
|
|
static const struct ttm_resource_manager_func vmw_thp_func;
|
|
|
|
static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node,
|
|
unsigned long align_pages,
|
|
const struct ttm_place *place,
|
|
struct ttm_resource *mem,
|
|
unsigned long lpfn,
|
|
enum drm_mm_insert_mode mode)
|
|
{
|
|
if (align_pages >= mem->page_alignment &&
|
|
(!mem->page_alignment || align_pages % mem->page_alignment == 0)) {
|
|
return drm_mm_insert_node_in_range(mm, node,
|
|
mem->num_pages,
|
|
align_pages, 0,
|
|
place->fpfn, lpfn, mode);
|
|
}
|
|
|
|
return -ENOSPC;
|
|
}
|
|
|
|
static int vmw_thp_get_node(struct ttm_resource_manager *man,
|
|
struct ttm_buffer_object *bo,
|
|
const struct ttm_place *place,
|
|
struct ttm_resource *mem)
|
|
{
|
|
struct vmw_thp_manager *rman = to_thp_manager(man);
|
|
struct drm_mm *mm = &rman->mm;
|
|
struct drm_mm_node *node;
|
|
unsigned long align_pages;
|
|
unsigned long lpfn;
|
|
enum drm_mm_insert_mode mode = DRM_MM_INSERT_BEST;
|
|
int ret;
|
|
|
|
node = kzalloc(sizeof(*node), GFP_KERNEL);
|
|
if (!node)
|
|
return -ENOMEM;
|
|
|
|
lpfn = place->lpfn;
|
|
if (!lpfn)
|
|
lpfn = man->size;
|
|
|
|
mode = DRM_MM_INSERT_BEST;
|
|
if (place->flags & TTM_PL_FLAG_TOPDOWN)
|
|
mode = DRM_MM_INSERT_HIGH;
|
|
|
|
spin_lock(&rman->lock);
|
|
if (IS_ENABLED(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD)) {
|
|
align_pages = (HPAGE_PUD_SIZE >> PAGE_SHIFT);
|
|
if (mem->num_pages >= align_pages) {
|
|
ret = vmw_thp_insert_aligned(mm, node, align_pages,
|
|
place, mem, lpfn, mode);
|
|
if (!ret)
|
|
goto found_unlock;
|
|
}
|
|
}
|
|
|
|
align_pages = (HPAGE_PMD_SIZE >> PAGE_SHIFT);
|
|
if (mem->num_pages >= align_pages) {
|
|
ret = vmw_thp_insert_aligned(mm, node, align_pages, place, mem,
|
|
lpfn, mode);
|
|
if (!ret)
|
|
goto found_unlock;
|
|
}
|
|
|
|
ret = drm_mm_insert_node_in_range(mm, node, mem->num_pages,
|
|
mem->page_alignment, 0,
|
|
place->fpfn, lpfn, mode);
|
|
found_unlock:
|
|
spin_unlock(&rman->lock);
|
|
|
|
if (unlikely(ret)) {
|
|
kfree(node);
|
|
} else {
|
|
mem->mm_node = node;
|
|
mem->start = node->start;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
|
|
static void vmw_thp_put_node(struct ttm_resource_manager *man,
|
|
struct ttm_resource *mem)
|
|
{
|
|
struct vmw_thp_manager *rman = to_thp_manager(man);
|
|
|
|
if (mem->mm_node) {
|
|
spin_lock(&rman->lock);
|
|
drm_mm_remove_node(mem->mm_node);
|
|
spin_unlock(&rman->lock);
|
|
|
|
kfree(mem->mm_node);
|
|
mem->mm_node = NULL;
|
|
}
|
|
}
|
|
|
|
int vmw_thp_init(struct vmw_private *dev_priv)
|
|
{
|
|
struct vmw_thp_manager *rman;
|
|
|
|
rman = kzalloc(sizeof(*rman), GFP_KERNEL);
|
|
if (!rman)
|
|
return -ENOMEM;
|
|
|
|
ttm_resource_manager_init(&rman->manager,
|
|
dev_priv->vram_size >> PAGE_SHIFT);
|
|
|
|
rman->manager.func = &vmw_thp_func;
|
|
drm_mm_init(&rman->mm, 0, rman->manager.size);
|
|
spin_lock_init(&rman->lock);
|
|
|
|
ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, &rman->manager);
|
|
ttm_resource_manager_set_used(&rman->manager, true);
|
|
return 0;
|
|
}
|
|
|
|
void vmw_thp_fini(struct vmw_private *dev_priv)
|
|
{
|
|
struct ttm_resource_manager *man = ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM);
|
|
struct vmw_thp_manager *rman = to_thp_manager(man);
|
|
struct drm_mm *mm = &rman->mm;
|
|
int ret;
|
|
|
|
ttm_resource_manager_set_used(man, false);
|
|
|
|
ret = ttm_resource_manager_evict_all(&dev_priv->bdev, man);
|
|
if (ret)
|
|
return;
|
|
spin_lock(&rman->lock);
|
|
drm_mm_clean(mm);
|
|
drm_mm_takedown(mm);
|
|
spin_unlock(&rman->lock);
|
|
ttm_resource_manager_cleanup(man);
|
|
ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, NULL);
|
|
kfree(rman);
|
|
}
|
|
|
|
static void vmw_thp_debug(struct ttm_resource_manager *man,
|
|
struct drm_printer *printer)
|
|
{
|
|
struct vmw_thp_manager *rman = to_thp_manager(man);
|
|
|
|
spin_lock(&rman->lock);
|
|
drm_mm_print(&rman->mm, printer);
|
|
spin_unlock(&rman->lock);
|
|
}
|
|
|
|
static const struct ttm_resource_manager_func vmw_thp_func = {
|
|
.alloc = vmw_thp_get_node,
|
|
.free = vmw_thp_put_node,
|
|
.debug = vmw_thp_debug
|
|
};
|