History log of /freebsd-current/sys/dev/drm2/ttm/ttm_bo.c
Revision Date Author Comments
# 2619c5cc 20-Nov-2023 Jason A. Harmening <jah@FreeBSD.org>

Avoid waiting on physical allocations that can't possibly be satisfied

- Change vm_page_reclaim_contig[_domain] to return an errno instead
of a boolean. 0 indicates a successful reclaim, ENOMEM indicates
lack of available memory to reclaim, with any other error (currently
only ERANGE) indicating that reclamation is impossible for the
specified address range. Change all callers to only follow
up with vm_page_wait* in the ENOMEM case.

- Introduce vm_domainset_iter_ignore(), which marks the specified
domain as unavailable for further use by the iterator. Use this
function to ignore domains that can't possibly satisfy a physical
allocation request. Since WAITOK allocations run the iterators
repeatedly, this avoids the possibility of infinitely spinning
in domain iteration if no available domain can satisfy the
allocation request.

PR: 274252
Reported by: kevans
Tested by: kevans
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D42706


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 84c39222 19-Oct-2021 Mark Johnston <markj@FreeBSD.org>

Convert consumers to vm_page_alloc_noobj_contig()

Remove now-unneeded page zeroing. No functional change intended.

Reviewed by: alc, hselasky, kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32006


# 592ffb21 23-Aug-2018 Warner Losh <imp@FreeBSD.org>

Revert drm2 removal.

Revert r338177, r338176, r338175, r338174, r338172

After long consultations with re@, core members and mmacy, revert
these changes. Followup changes will be made to mark them as
deprecated and prent a message about where to find the up-to-date
driver. Followup commits will be made to make this clear in the
installer. Followup commits to reduce POLA in ways we're still
exploring.

It's anticipated that after the freeze, this will be removed in
13-current (with the residual of the drm2 code copied to
sys/arm/dev/drm2 for the TEGRA port's use w/o the intel or
radeon drivers).

Due to the impending freeze, there was no formal core vote for
this. I've been talking to different core members all day, as well as
Matt Macey and Glen Barber. Nobody is completely happy, all are
grudgingly going along with this. Work is in progress to mitigate
the negative effects as much as possible.

Requested by: re@ (gjb, rgrimes)


# d157fbd5 21-Aug-2018 Matt Macy <mmacy@FreeBSD.org>

Remove legacy drm and drm2 from tree

As discussed on the MLs drm2 conflicts with the ports' version and there
is no upstream for most if not all of drm. Both have been merged in to
a single port.

Users on powerpc, 32-bit hardware, or with GPUs predating Radeon
and i915 will need to install the graphics/drm-legacy-kmod. All
other users should be able to use one of the LinuxKPI-based ports:
graphics/drm-stable-kmod, graphics/drm-next-kmod, graphics/drm-devel-kmod.

MFC: never
Approved by: core@


# c869e672 19-Dec-2015 Alan Cox <alc@FreeBSD.org>

Introduce a new mechanism for relocating virtual pages to a new physical
address and use this mechanism when:

1. kmem_alloc_{attr,contig}() can't find suitable free pages in the physical
memory allocator's free page lists. This replaces the long-standing
approach of scanning the inactive and inactive queues, converting clean
pages into PG_CACHED pages and laundering dirty pages. In contrast, the
new mechanism does not use PG_CACHED pages nor does it trigger a large
number of I/O operations.

2. on 32-bit MIPS processors, uma_small_alloc() and the pmap can't find
free pages in the physical memory allocator's free page lists that are
covered by the direct map. Tested by: adrian

3. ttm_bo_global_init() and ttm_vm_page_alloc_dma32() can't find suitable
free pages in the physical memory allocator's free page lists.

In the coming months, I expect that this new mechanism will be applied in
other places. For example, balloon drivers should use relocation to
minimize fragmentation of the guest physical address space.

Make vm_phys_alloc_contig() a little smarter (and more efficient in some
cases). Specifically, use vm_phys_segs[] earlier to avoid scanning free
page lists that can't possibly contain suitable pages.

Reviewed by: kib, markj
Glanced at: jhb
Discussed with: jeff
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D4444


# 7bead7ac 08-Sep-2015 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm: Drain taskqueue if taskqueue_cancel_timeout() returned an error

Before, this was done if `pending` was true. This is not what the
manpage suggests and not what was done elsewhere in the same file.


# 455fa651 17-Mar-2015 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm: Update the device-independent code to match Linux 3.8.13

This update brings few features:
o Support for the setmaster/dropmaster ioctls. For instance, they
are used to run multiple X servers simultaneously.
o Support for minor devices. The only user-visible change is a new
entry in /dev/dri but it is useless at the moment. This is a
first step to support render nodes [1].

The main benefit is to greatly reduce the diff with Linux (at the
expense of an unreadable commit diff). Hopefully, next upgrades will be
easier.

No updates were made to the drivers, beside adapting them to API
changes.

[1] https://en.wikipedia.org/wiki/Direct_Rendering_Manager#Render_nodes

Tested by: Many people
MFC after: 1 month
Relnotes: yes


# 98173b7f 03-Feb-2015 Konstantin Belousov <kib@FreeBSD.org>

If the vm_page_alloc_contig() failed in the ttm page allocators, do
what other callers of vm_page_alloc_contig() do, retry after
vm_pageout_grow_cache().

Sponsored by: The FreeBSD Foundation


# a883f5ea 21-Dec-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm, drm/radeon: Replace EINTR/ERESTART by ERESTARTSYS...

... for msleep/cv_*wait() return values, where wait_event*() is used
on Linux. ERESTARTSYS is the return code expected by callers when the
operation was interrupted.

For instance, this is the case of radeon_cs_ioctl() (radeon_cs.c): if
an error occurs, and the code isn't ERESTARTSYS (eg. EINTR), it logs an
error.

Note that ERESTARTSYS is defined as ERESTART, but this keeps callers'
code close to Linux.

Submitted by: avg@ (previous version)


# 7a22215c 30-Nov-2013 Eitan Adler <eadler@FreeBSD.org>

Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
shifts into the sign bit. Instead use (1U << 31) which gets the
expected result.

This fix is not ideal as it assumes a 32 bit int, but does fix the issue
for most cases.

A similar change was made in OpenBSD.

Discussed with: -arch, rdivacky
Reviewed by: cperciva


# 346c9ece 29-Aug-2013 Jung-uk Kim <jkim@FreeBSD.org>

Partially revert r254880. The bitmap operations actually use long type now.


# e558c87b 25-Aug-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm: Use the new drm_atomic.h, following the merge of projects/atomic64

Submitted by: jkim@


# 4360c0bb 25-Aug-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm: Fix a reversed condition and add missing locks

This allows to run OpenGL applications on at least two test machines
with the Radeon driver.

Approved by: kib@


# 970c941a 25-Aug-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm: Fix unmap of buffer object

Add a new ttm_bo_release_mmap() function to unmap pages in a
vm_object_t. Pages are freed when the buffer object is later released.

This function is called in ttm_bo_unmap_virtual_locked(), replacing
Linux' unmap_mapping_range(). In particular this is called when a buffer
object is about to be moved, so that its mapping is invalidated.

However, we don't use this function in ttm_bo_vm_dtor(), because the
vm_object_t is already marked as OBJ_DEAD and the pages will be
unmapped.

Approved by: kib@


# 9ba6f1ae 25-Aug-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm: Fix style errors


# 6ee96714 25-Aug-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm: Import Linux commit 014b34409fb2015f63663b6cafdf557fdf289628

Author: Dave Airlie <airlied@gmail.com>
Date: Wed Jan 16 15:58:34 2013 +1000

ttm: on move memory failure don't leave a node dangling

if we have a move notify callback, when moving fails, we call move notify
the opposite way around, however this ends up with *mem containing the mm_node
from the bo, which means we double free it. This is a follow on to the previous
fix.

Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>

Approved by: kib@


# aacce5b6 25-Aug-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm: Import Linux commit cc4c0c4de3c775be22072ec3251f2e581b63d9a0

Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Tue Jan 15 14:57:28 2013 +0100

drm/ttm: unexport ttm_bo_wait_unreserved

All legitimate users of this function outside ttm_bo.c are gone, now
it's only an implementation detail.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>

Approved by: kib@


# 8aa5d019 25-Aug-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm: Import Linux commit 5e45d7dfd74100d622f9cdc70bfd1f9fae1671de

Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Tue Jan 15 14:57:05 2013 +0100

drm/ttm: add ttm_bo_reserve_slowpath

Instead of dropping everything, waiting for the bo to be unreserved
and trying over, a better strategy would be to do a blocking wait.

This can be mapped a lot better to a mutex_lock-like call.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>

Approved by: kib@


# aa675725 25-Aug-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm: Import Linux commit 7a1863084c9d90ce4b67d645bf9b0f1612e68f62

Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Tue Jan 15 14:56:48 2013 +0100

drm/ttm: cleanup ttm_eu_reserve_buffers handling

With the lru lock no longer required for protecting reservations we
can just do a ttm_bo_reserve_nolru on -EBUSY, and handle all errors
in a single path.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>


# f25ca896 25-Aug-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm/ttm: Import Linux commit 63d0a4195560362e2e00a3ad38fc331d34e1da9b

Author: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Tue Jan 15 14:56:37 2013 +0100

drm/ttm: remove lru_lock around ttm_bo_reserve

There should no longer be assumptions that reserve will always succeed
with the lru lock held, so we can safely break the whole atomic
reserve/lru thing. As a bonus this fixes most lockdep annotations for
reservations.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>


# 3f81c677 08-Mar-2013 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

drm: Fix a call to free(9) with an incorrect malloc type

While here, the call to free(9) is moved to drm_global.c, near the
initial malloc(9).

Reviewed by: Konstantin Belousov (kib@)


# e6cd8542 05-Mar-2013 Konstantin Belousov <kib@FreeBSD.org>

Import the preliminary port of the TTM.

The early commit is done to facilitate the off-tree work on the
porting of the Radeon driver.

Sponsored by: The FreeBSD Foundation
Debugged and tested by: dumbbell
MFC after: 1 month