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 -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEchf7rIzpz2NEoWjlaA3BHVMLeiMFAl+X8N4ACgkQaA3BHVML eiPulggAu/RudQn0GmWPcDg9DpM30zE/ppBrmKk+WGWqj6M2DgK9gy+KhJps+Uht Fb2jMnUirNS5ZNa5kVhkdazOKqHq5jHHV+SbRPziySzV56TW8lbPU/HOUhKSQbkF FUB/YCWbb2kJA23So9VwNkjSJUXKpy896WoVxH7b/gLYL7c+sHUK9TOWAlsbFEmD t3kjxQgsHdVhqaZIKE7zg72Vi1AkkhjCVraPQeZY1GgmmLxdQeEKhNO8xdfG3OzY US4MYwJ51RfaCDTFr5t1UA224ODxoJtV3dTDDtrx4R5sf4MYJUC4SJYZHIyHyUkm 9KXjFFzB9+Hd0JjpUHFUyl+4k8JjHQ== =GWwb -----END PGP SIGNATURE----- Merge tag 'drm-misc-next-2020-10-27' of git://anongit.freedesktop.org/drm/drm-misc into drm-next 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
203 lines
5.2 KiB
C
203 lines
5.2 KiB
C
/*
|
|
* Copyright 2017 Red Hat Inc.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
#include "nouveau_mem.h"
|
|
#include "nouveau_drv.h"
|
|
#include "nouveau_bo.h"
|
|
|
|
#include <drm/ttm/ttm_bo_driver.h>
|
|
|
|
#include <nvif/class.h>
|
|
#include <nvif/if000a.h>
|
|
#include <nvif/if500b.h>
|
|
#include <nvif/if500d.h>
|
|
#include <nvif/if900b.h>
|
|
#include <nvif/if900d.h>
|
|
|
|
int
|
|
nouveau_mem_map(struct nouveau_mem *mem,
|
|
struct nvif_vmm *vmm, struct nvif_vma *vma)
|
|
{
|
|
union {
|
|
struct nv50_vmm_map_v0 nv50;
|
|
struct gf100_vmm_map_v0 gf100;
|
|
} args;
|
|
u32 argc = 0;
|
|
bool super;
|
|
int ret;
|
|
|
|
switch (vmm->object.oclass) {
|
|
case NVIF_CLASS_VMM_NV04:
|
|
break;
|
|
case NVIF_CLASS_VMM_NV50:
|
|
args.nv50.version = 0;
|
|
args.nv50.ro = 0;
|
|
args.nv50.priv = 0;
|
|
args.nv50.kind = mem->kind;
|
|
args.nv50.comp = mem->comp;
|
|
argc = sizeof(args.nv50);
|
|
break;
|
|
case NVIF_CLASS_VMM_GF100:
|
|
case NVIF_CLASS_VMM_GM200:
|
|
case NVIF_CLASS_VMM_GP100:
|
|
args.gf100.version = 0;
|
|
if (mem->mem.type & NVIF_MEM_VRAM)
|
|
args.gf100.vol = 0;
|
|
else
|
|
args.gf100.vol = 1;
|
|
args.gf100.ro = 0;
|
|
args.gf100.priv = 0;
|
|
args.gf100.kind = mem->kind;
|
|
argc = sizeof(args.gf100);
|
|
break;
|
|
default:
|
|
WARN_ON(1);
|
|
return -ENOSYS;
|
|
}
|
|
|
|
super = vmm->object.client->super;
|
|
vmm->object.client->super = true;
|
|
ret = nvif_vmm_map(vmm, vma->addr, mem->mem.size, &args, argc,
|
|
&mem->mem, 0);
|
|
vmm->object.client->super = super;
|
|
return ret;
|
|
}
|
|
|
|
void
|
|
nouveau_mem_fini(struct nouveau_mem *mem)
|
|
{
|
|
nvif_vmm_put(&mem->cli->drm->client.vmm.vmm, &mem->vma[1]);
|
|
nvif_vmm_put(&mem->cli->drm->client.vmm.vmm, &mem->vma[0]);
|
|
mutex_lock(&mem->cli->drm->master.lock);
|
|
nvif_mem_dtor(&mem->mem);
|
|
mutex_unlock(&mem->cli->drm->master.lock);
|
|
}
|
|
|
|
int
|
|
nouveau_mem_host(struct ttm_resource *reg, struct ttm_tt *tt)
|
|
{
|
|
struct nouveau_mem *mem = nouveau_mem(reg);
|
|
struct nouveau_cli *cli = mem->cli;
|
|
struct nouveau_drm *drm = cli->drm;
|
|
struct nvif_mmu *mmu = &cli->mmu;
|
|
struct nvif_mem_ram_v0 args = {};
|
|
bool super = cli->base.super;
|
|
u8 type;
|
|
int ret;
|
|
|
|
if (!nouveau_drm_use_coherent_gpu_mapping(drm))
|
|
type = drm->ttm.type_ncoh[!!mem->kind];
|
|
else
|
|
type = drm->ttm.type_host[0];
|
|
|
|
if (mem->kind && !(mmu->type[type].type & NVIF_MEM_KIND))
|
|
mem->comp = mem->kind = 0;
|
|
if (mem->comp && !(mmu->type[type].type & NVIF_MEM_COMP)) {
|
|
if (mmu->object.oclass >= NVIF_CLASS_MMU_GF100)
|
|
mem->kind = mmu->kind[mem->kind];
|
|
mem->comp = 0;
|
|
}
|
|
|
|
if (tt->sg)
|
|
args.sgl = tt->sg->sgl;
|
|
else
|
|
args.dma = tt->dma_address;
|
|
|
|
mutex_lock(&drm->master.lock);
|
|
cli->base.super = true;
|
|
ret = nvif_mem_ctor_type(mmu, "ttmHostMem", cli->mem->oclass, type, PAGE_SHIFT,
|
|
reg->num_pages << PAGE_SHIFT,
|
|
&args, sizeof(args), &mem->mem);
|
|
cli->base.super = super;
|
|
mutex_unlock(&drm->master.lock);
|
|
return ret;
|
|
}
|
|
|
|
int
|
|
nouveau_mem_vram(struct ttm_resource *reg, bool contig, u8 page)
|
|
{
|
|
struct nouveau_mem *mem = nouveau_mem(reg);
|
|
struct nouveau_cli *cli = mem->cli;
|
|
struct nouveau_drm *drm = cli->drm;
|
|
struct nvif_mmu *mmu = &cli->mmu;
|
|
bool super = cli->base.super;
|
|
u64 size = ALIGN(reg->num_pages << PAGE_SHIFT, 1 << page);
|
|
int ret;
|
|
|
|
mutex_lock(&drm->master.lock);
|
|
cli->base.super = true;
|
|
switch (cli->mem->oclass) {
|
|
case NVIF_CLASS_MEM_GF100:
|
|
ret = nvif_mem_ctor_type(mmu, "ttmVram", cli->mem->oclass,
|
|
drm->ttm.type_vram, page, size,
|
|
&(struct gf100_mem_v0) {
|
|
.contig = contig,
|
|
}, sizeof(struct gf100_mem_v0),
|
|
&mem->mem);
|
|
break;
|
|
case NVIF_CLASS_MEM_NV50:
|
|
ret = nvif_mem_ctor_type(mmu, "ttmVram", cli->mem->oclass,
|
|
drm->ttm.type_vram, page, size,
|
|
&(struct nv50_mem_v0) {
|
|
.bankswz = mmu->kind[mem->kind] == 2,
|
|
.contig = contig,
|
|
}, sizeof(struct nv50_mem_v0),
|
|
&mem->mem);
|
|
break;
|
|
default:
|
|
ret = -ENOSYS;
|
|
WARN_ON(1);
|
|
break;
|
|
}
|
|
cli->base.super = super;
|
|
mutex_unlock(&drm->master.lock);
|
|
|
|
reg->start = mem->mem.addr >> PAGE_SHIFT;
|
|
return ret;
|
|
}
|
|
|
|
void
|
|
nouveau_mem_del(struct ttm_resource *reg)
|
|
{
|
|
struct nouveau_mem *mem = nouveau_mem(reg);
|
|
if (!mem)
|
|
return;
|
|
nouveau_mem_fini(mem);
|
|
kfree(reg->mm_node);
|
|
reg->mm_node = NULL;
|
|
}
|
|
|
|
int
|
|
nouveau_mem_new(struct nouveau_cli *cli, u8 kind, u8 comp,
|
|
struct ttm_resource *reg)
|
|
{
|
|
struct nouveau_mem *mem;
|
|
|
|
if (!(mem = kzalloc(sizeof(*mem), GFP_KERNEL)))
|
|
return -ENOMEM;
|
|
mem->cli = cli;
|
|
mem->kind = kind;
|
|
mem->comp = comp;
|
|
|
|
reg->mm_node = mem;
|
|
return 0;
|
|
}
|