Home | History | Annotate | Download | only in ttm
History log of /src/sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c
RevisionDateAuthorComments
 1.19  26-Jun-2022  riastradh drm/ttm: Fix potential leak in error branch.

Not likely but let's not leave a rake to trip on.
 1.18  19-Dec-2021  riastradh drm/ttm: Fix ttm_tt pages and DMA map allocation.
 1.17  19-Dec-2021  riastradh drm: Nix use of uvm pglist. Just use arrays of page pointers.
 1.16  19-Dec-2021  riastradh drm/ttm: uao_create takes pages, not bytes.
 1.15  19-Dec-2021  riastradh drm/drm_mem_util.h for drm_free_large


Author: Maya Rashish <maya@NetBSD.org>
 1.14  19-Dec-2021  riastradh Fix up ttm.
 1.13  18-Dec-2021  riastradh Merge linux-drm-v5-6-rc3
 1.12  14-Feb-2020  maya Reduce diffs by side-loading some header files like Linux.

From riastradh
 1.11  27-Aug-2018  riastradh branches: 1.11.6;
merge linux-drm-v4-4-143
 1.10  30-Jul-2017  riastradh branches: 1.10.2; 1.10.4;
Fix error branch in ttm_dma_tt_init to avoid double-free.

Should fix symptom of PR kern/52438, but who knows what underlying
problem causes us to reach the error branch in the first place.
 1.9  09-Mar-2017  maya branches: 1.9.6;
Clarify ttm state transitions tt_unpopulated<->tt_unbound<->tt_bound.
Assert it, too, and don't handle other cases.

We can add the assertion to ttm_agp_tt_unpopulate because it is called by
{nouveau,radeon}_ttm_tt_unpopulate, which is generically called
ttm_tt_unpopulate.

And the sole caller to ttm_tt_unpopulate (ttm_tt_destroy) only does so if the
state is unbound. the other caller is in a !NetBSD block.

We can add the assertion to ttm_agp_tt_populate and avoid handling the
!unpopulated case because the sole callers are {nouveau,radeon}_ttm_tt_populate
both of which return early in the !unpopulated case.

We can change the assertion on ttm_tt_wire because it is solely called by
ttm_bus_dma_populate, which already asserts that it is the unpopulated case.

from riastradh
 1.8  24-Dec-2016  riastradh branches: 1.8.2;
Guarantee no zero-size uao/kmem allocations via ttm.

It may be that all callers guarantee no zero-size ttm objects, but I
can't prove that in five minutes of browsing callers. Rather than
add a KASSERT, lacking proof, we'll add a warning message so that if
it does happen then it happens noisily, but we'll also prevent the
bad consequences of passing zero into uao_create by rounding up to a
harmless nonzero allocation.

XXX pullup-7
 1.7  24-Apr-2016  riastradh branches: 1.7.2;
Rework ttm tt swapin/swapout logic.

Rather than handling `swapping in/out' here, per se, we let uvm do
that, we interpret `swap out' as `deactivate pages', and we add
generic ttm operations to wire and unwire pages, for the ttm_tt
driver to use.

This fixes certain graphics buffer eviction logic, which enables
nouveau to suspend/resume on one of my machines. (The machine
doesn't resume overall for other reasons, but the nouveau device
suspends and resumes in isolation.)

XXX pullup to netbsd-7 after a couple weeks
 1.6  27-Jul-2014  riastradh branches: 1.6.2; 1.6.4; 1.6.6; 1.6.8; 1.6.10;
Revert ttm_bo.c 1.3 and try to fix the double-free properly.

bo->destroy doesn't ttm_tt_destroy or ttm_tt_fini anything. Trouble
is that ttm_tt_fini expects the swap storage to still be there, and
ttm_tt_destroy -- which is what calls ttm_tt_fini by way of
ttm->func->destroy -- has already nulled it out.
 1.5  26-Jul-2014  rjs Fix non debug build.
 1.4  22-Jul-2014  riastradh Fix ttm swap storage destruction.
 1.3  17-Jul-2014  riastradh Don't forget to advance the array index as we walk the queue...
 1.2  16-Jul-2014  riastradh First whack at radeon driver.

No hardware to test yet, but it builds.
 1.1  23-Jul-2013  riastradh branches: 1.1.1;
Initial revision
 1.1.1.4  18-Dec-2021  riastradh Import drm from Linux v5.6-rc3 (commit f8788d86ab28f61f7b46eb6be375f8a726783636)

drivers/gpu/drm -> sys/external/bsd/drm2/dist/drm
include/drm -> sys/external/bsd/drm2/dist/include/drm
include/uapi/drm -> sys/external/bsd/drm2/dist/include/uapi/drm

GPL exclusions in dist/drm:

- amd/amdgpu/amdgpu_atpx_handler.c
- arc/
- arm/
- armada/
- aspeed/
- atmel-hlcdc/
- bochs/
- bridge/
- cirrus/
- drm_dp_cec.c
- drm_dp_mst_topology_internal.h
- drm_edid_load.c
- drm_format_helper.c
- drm_gem_cma_helper.c
- drm_gem_framebuffer_helper.c
- drm_gem_shmem_helper.c
- drm_gem_ttm_helper.c
- drm_gem_vram_helper.c
- drm_hdcp.c
- drm_lease.c
- drm_mipi_dbi.c
- drm_simple_kms_helper.c
- drm_sysfs.c
- drm_trace.h
- drm_vram_helper_common.c
- drm_writeback.c
- etnaviv/
- exynos/
- fsl-dcu/
- gma500/
- hisilicon/
- i2c/tda9950.c
- i2c/tda998x_drv.c
- i915/gt/selftest_context.c
- i915/gt/selftest_engine.c
- i915/gt/selftest_engine.h
- i915/gt/selftest_engine_cs.c
- i915/gt/selftest_engine_pm.c
- i915/i915_trace.h
- i915/selftests/i915_live_selftests.h
- i915/selftests/i915_mock_selftests.h
- i915/selftests/i915_perf_selftests.h
- i915/selftests/lib_sw_fence.h
- imx/
- ingenic/
- lima/
- mcde/
- mediatek/
- meson/
- mgag200/
- msm/
- mxsfb/
- omapdrm/
- panel/
- panfrost/
- pl111/
- radeon/radeon_atpx_handler.c
- rcar-du/
- rockchip/
- selftests/drm_cmdline_selftests.h
- selftests/drm_modeset_selftests.h
- selftests/test-drm_cmdline_parser.c
- selftests/test-drm_damage_helper.c
- selftests/test-drm_dp_mst_helper.c
- selftests/test-drm_format.c
- selftests/test-drm_framebuffer.c
- selftests/test-drm_modeset_common.c
- selftests/test-drm_modeset_common.h
- selftests/test-drm_plane_helper.c
- selftests/test-drm_rect.c
- shmobile/
- sti/
- stm/
- sun4i/
- tegra/
- tilcdc/
- tiny/
- tve200/
- udl/
- v3d/
- vc4/
- virtio/virtgpu_trace.h
- virtio/virtgpu_trace_points.c
- vkms/
- vmwgfx/device_include/vmware_pack_begin.h
- vmwgfx/device_include/vmware_pack_end.h
- zte/

Exceptions -- these all appear to be files to which someone added
an SPDX license header automatically by a script that is not aware
of the default MIT licensing under drivers/gpu/drm:

- ast/ast_dp501.c
- ast/ast_dram_tables.h
- lib/drm_random.c
- lib/drm_random.h
- i915/display/intel_acpi.c
- i915/selftests/mock_gem_device.h
- i915/selftests/i915_mock_selftests.h
- i915/selftests/i915_live_selftests.h
- r128/ati_pcigart.h
- selftests/drm_mm_selftests.h
- selftests/test-drm_mm.c
- vmwgfx/device_include/vm_basic_types.h

GPL exclusions in dist/include/drm:

- bridge
- drm_client.h
- drm_fb_cma_helper.h
- drm_format_helper.h
- drm_gem_cma_helper.h
- drm_gem_shmem_helper.h
- drm_gem_ttm_helper.h
- drm_gem_vram_helper.h
- drm_lease.h
- drm_mipi_dbi.h
- drm_mipi_dsi.h
- drm_of.h
- drm_simple_kms_helper.h
- drm_sysfs.h
- drm_writeback.h
- gma_drm.h
- i2c/tda998x.h
- i915_mei_hdcp_interface.h
- intel-gtt.h

Exceptions:
- drm_agpsupport.h - was in original drm; wrong spdx header auto-added

GPL exclusions in dist/include/uapi/drm:

- armada_drm.h
- etnaviv_drm.h
- exynos_drm.h
- lima_drm.h
- omap_drm.h

Exceptions:
- i810_drm.h - was in original drm; spdx header is wrong
 1.1.1.3  27-Aug-2018  riastradh Import drm from Linux v4.4.143 (commit a8ea6276d00555387deaaa5eaeb380cd5c17bdc9).

drivers/gpu/drm -> sys/external/bsd/drm2/dist/drm
include/drm -> sys/external/bsd/drm2/dist/include/drm
include/uapi/drm -> sys/external/bsd/drm2/dist/uapi/drm

GPL sources excluded.
 1.1.1.2  16-Jul-2014  riastradh Import drm from Linux 3.15 (commitid 1860e379875dfe7271c649058aeddffe5afd9d0d).

drivers/gpu/drm -> sys/external/bsd/drm2/dist/drm
include/drm -> sys/external/bsd/drm2/dist/include/drm
include/uapi/drm -> sys/external/bsd/drm2/dist/uapi/drm

GPL sources excluded.
 1.1.1.1  23-Jul-2013  riastradh branches: 1.1.1.1.2; 1.1.1.1.4; 1.1.1.1.6; 1.1.1.1.8;
Import drm sources from Linux v3.8-rc6.
(commit id 88b62b915b0b7e25870eb0604ed9a92ba4bfc9f7)

Linux NetBSD
drivers/gpu/drm sys/external/bsd/drm2/dist/drm
include/drm sys/external/bsd/drm2/dist/include/drm
include/uapi/drm sys/external/bsd/drm2/dist/uapi/drm

Files/subtrees excluded because of licence issues, to be either
revisited later (particularly nouveau and radeon, which are mostly
permissively licensed but a number of whose files have no licence
statements), rewritten/ignored, or imported later as kernel modules
under external/gpl2 instead:

include/drm/drm_fb_cma_helper.h
include/drm/drm_gem_cma_helper.h
include/drm/drm_os_linux.h
include/drm/drm_pciids.h
include/drm/drm_sysfs.h
include/drm/drm_usb.h
include/drm/exynos_drm.h
include/drm/gma_drm.h
include/drm/intel-gtt.h
drm/cirrus
drm/drm_edid_load.c
drm/drm_fb_cma_helper.c
drm/drm_gem_cma_helper.c
drm/drm_sysfs.c
drm/drm_trace.h
drm/drm_trace_points.c
drm/drm_usb.c
drm/exynos
drm/gma500
drm/i915/i915_trace.h
drm/i915/i915_trace_points.c
drm/i915/intel_acpi.c
drm/mgag200
drm/nouveau
drm/radeon
drm/shmobile
drm/tegra
drm/udl
uapi/exynos_drm.h
 1.1.1.1.8.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.1.1.8.1  23-Jul-2013  yamt file ttm_tt.c was added on branch yamt-pagecache on 2014-05-22 11:40:54 +0000
 1.1.1.1.6.1  10-Aug-2014  tls Rebase.
 1.1.1.1.4.2  28-Aug-2013  rmind sync with head
 1.1.1.1.4.1  23-Jul-2013  rmind file ttm_tt.c was added on branch rmind-smpnet on 2013-08-28 23:59:34 +0000
 1.1.1.1.2.2  23-Jul-2013  riastradh sync with HEAD and actually get the drm2 import
 1.1.1.1.2.1  23-Jul-2013  riastradh file ttm_tt.c was added on branch riastradh-drm2 on 2013-07-23 21:28:23 +0000
 1.6.10.2  13-Mar-2017  skrll Sync with netbsd-7-1-RELEASE
 1.6.10.1  18-Jan-2017  skrll Sync with netbsd-5
 1.6.8.1  29-Jan-2017  snj Pull up following revision(s) (requested by maya in ticket #1350):
sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c: revision 1.8
Guarantee no zero-size uao/kmem allocations via ttm.
It may be that all callers guarantee no zero-size ttm objects, but I
can't prove that in five minutes of browsing callers. Rather than
add a KASSERT, lacking proof, we'll add a warning message so that if
it does happen then it happens noisily, but we'll also prevent the
bad consequences of passing zero into uao_create by rounding up to a
harmless nonzero allocation.
XXX pullup-7
 1.6.6.3  28-Aug-2017  skrll Sync with HEAD
 1.6.6.2  05-Feb-2017  skrll Sync with HEAD
 1.6.6.1  29-May-2016  skrll Sync with HEAD
 1.6.4.3  03-Dec-2017  jdolecek update from HEAD
 1.6.4.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.4.1  27-Jul-2014  tls file ttm_tt.c was added on branch tls-maxphys on 2014-08-20 00:04:19 +0000
 1.6.2.2  29-Jan-2017  snj Pull up following revision(s) (requested by maya in ticket #1350):
sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c: revision 1.8
Guarantee no zero-size uao/kmem allocations via ttm.
It may be that all callers guarantee no zero-size ttm objects, but I
can't prove that in five minutes of browsing callers. Rather than
add a KASSERT, lacking proof, we'll add a warning message so that if
it does happen then it happens noisily, but we'll also prevent the
bad consequences of passing zero into uao_create by rounding up to a
harmless nonzero allocation.
 1.6.2.1  12-Dec-2016  msaitoh Pull up following revision(s) (requested by snj in ticket #1280):
sys/external/bsd/drm2/ttm/ttm_bus_dma.c: revision 1.2
sys/external/bsd/drm2/include/drm/drm_wait_netbsd.h: revision 1.14
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_dp.c: revision 1.2
sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c: revision 1.7
sys/external/bsd/drm2/dist/drm/nouveau/core/engine/device/nouveau_engine_device_base.c: revision 1.11
sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_nv40.c: revision 1.2
sys/external/bsd/drm2/dist/include/drm/ttm/ttm_bo_driver.h: revision 1.3
sys/external/bsd/drm2/dist/drm/radeon/radeon_ttm.c: revision 1.8
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_connector.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_gem.c: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/devinit/nouveau_subdev_devinit_nv04.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/nouveau_bo.c: revision 1.7
sys/external/bsd/drm2/dist/drm/nouveau/core/core/nouveau_core_object.c: revision 1.3
sys/external/bsd/drm2/dist/drm/i915/i915_gpu_error.c: revision 1.4
sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/mxm/nouveau_subdev_mxm_mxms.c: revision 1.2
sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/mxm/nouveau_subdev_mxm_nv50.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/core/engine/disp/nouveau_engine_disp_nvd0.c: revision 1.3
sys/external/bsd/drm2/dist/drm/nouveau/core/engine/fifo/nouveau_engine_fifo_base.c: revision 1.5
sys/external/bsd/drm2/include/drm/ttm/ttm_page_alloc.h: revision 1.2
sys/external/bsd/drm2/drm/drm_vma_manager.c: revision 1.4
sys/external/bsd/drm2/nouveau/nouveau_pci.c: revision 1.8
- fix non-debug build
- Use %"PRIx8", not %hx, for uint8_t. %hx is for unsigned short.
- Flush unused function. Found by joerg.
- Make sure rbtrees are empty on desctruction.
If related to PR kern/51076, might help catch the bug a bit earlier.
- revert rev 1.6. we don't have access to those files as normal files
and possible will get them directly elsewhere soon.
(if i hack my nouveau to ignore fireware failure, it end up having
a vaguely working console and slowly working X, which is better than
the current situation.)
- Avoid possible null pointer dereference. Found by Coverity, CID 709895.
- Mark fallthrough to suppress Coverity complaints.
CID 143119
CID 143120
CID 143121
CID 143122
CID 143123
CID 143124
- Sanity-check that the encoder we found is not null.
I think the previous code guarantees that finding this encoder should
work, so this should be a moot point. CID 145720.
- Mark intended fallthrough to suppress Coverity CID 201378.
- Mark fallthrough with a comment to appease Coverity, CID 703385.
- Make it clearer to Coverity that there's no array overrun. CID 989067.
- Rework ttm tt swapin/swapout logic.
Rather than handling `swapping in/out' here, per se, we let uvm do
that, we interpret `swap out' as `deactivate pages', and we add
generic ttm operations to wire and unwire pages, for the ttm_tt
driver to use.
This fixes certain graphics buffer eviction logic, which enables
nouveau to suspend/resume on one of my machines. (The machine
doesn't resume overall for other reasons, but the nouveau device
suspends and resumes in isolation.)
- Use bus_space_subregion to get fifo channels out of mmio registers.
Evidently it is not enough to just map them separately. Ran out of
time to investigate why, last time I poked at this and confirmed this
change works.
- Avoid taking locks during interrupts and explain why we are doing it this way.
- We now use cpu_intr_p() all the time.
 1.7.2.2  20-Mar-2017  pgoyette Sync with HEAD
 1.7.2.1  07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.9.6.1  01-Sep-2018  martin Pull up following revision(s) (requested by riastradh in ticket #1003):

sys/external/bsd/drm2/dist/drm/i915/intel_sdvo.c: revision 1.8
sys/external/bsd/drm2/dist/drm/ttm/ttm_tt.c: revision 1.10
sys/external/bsd/drm2/drm/drm_scatter.c: revision 1.4
sys/external/bsd/drm2/dist/drm/i915/i915_reg.h: revision 1.2
sys/external/bsd/drm2/linux/linux_ww_mutex.c: revision 1.3
sys/external/bsd/drm2/linux/linux_ww_mutex.c: revision 1.4
sys/external/bsd/drm2/linux/linux_idr.c: revision 1.6

Pull in upstream commit:
Author: Ville Syrj=E4l=E4 <ville.syrjala%linux.intel.com@localhost>
Date: Mon Jun 9 16:20:46 2014 +0300
drm/i915: Avoid div-by-zero when pixel_multiplier is zero
On certain platforms pixel_multiplier is read out in
.get_pipe_config(), but it also gets used to calculate the
pixel clock in intel_sdvo_get_config(). If the pipe is disabled
but some SDVO outputs are active, we may end up dividing by zero
in intel_sdvo_get_config().
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=3D76520
Tweak slightly sketchy logic in linux_idr.
1. idr_preload can fail if you don't set __GFP_WAIT.
2. If idr_preload fails, it is wrong for idr_alloc to assert.
3. There is no way for idr_alloc to know what flags idr_preload got.
Probably won't *fix* any bugs, but if there is a bug with a missing
__GFP_WAIT, then we will learn about a trifle sooner.
Fix error branch in ttm_dma_tt_init to avoid double-free.
Should fix symptom of PR kern/52438, but who knows what underlying
problem causes us to reach the error branch in the first place.
Fix lockdebug_locked annotations.
When thread A grants ownership to thread B waiting with a context,
thread B needs to assert lockdebug_locked; otherwise, when it
releases, lockdebug_unlocked thinks it's releasing an unlocked
ww_mutex.

Fixes LOCKDEBUG failure with radeon noticed by martin@.

more const

XXX: add a NULL init to avoid a GCC 6 maybe uninit warning.

Remove UB from definition of symbols in i915_reg.h
Kernel Undefined Behavior Sanitizer enforces more warnings in build time.
This makes the build fatal in the drm/i915 code in:
- intel_ddi_put_crtc_pll(),
- intel_ddi_clock_get(),
- intel_ddi_pll_enable(),
- intel_ddi_setup_hw_pll_state().
The error message in all the cases says:
error: case label does not reduce to an integer constant
Set the type of the value left shifted to unsigned.
This change is required to build NetBSD/amd64 with KUBSan.
 1.10.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.10.4.1  10-Jun-2019  christos Sync with HEAD
 1.10.2.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.11.6.1  29-Feb-2020  ad Sync with head.

RSS XML Feed