History log of /freebsd-9.3-release/sys/dev/drm2/ttm/
Revision Date Author Comments
267654 20-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


263170 14-Mar-2014 dumbbell

MFC Radeon KMS driver

FreeBSD 9 already had modern Intel GPUs support, now this is the case for
Radeon GPUs too. This will ease the work on ports, where there won't be a
need to distinguish between FreeBSD 9/10 and different hardware vendors.

Help from: jhb@, jkim@, kan@, kib@,
J.R. Oldroyd <fbsd@opal.com> (previous version of the patch)

The following revisions were merged in this single commit:

r254885:
drm/radeon: Import the Radeon KMS driver

This driver is based on Linux 3.8 and a previous effort by kan@.

More informations about this project can be found on the FreeBSD wiki:
https://wiki.freebsd.org/AMD_GPU

The driver is split into:

sys/dev/drm2:
The driver sources.

sys/modules/drm2/radeonkmw:
The driver main kernel module's Makefile.

sys/modules/drm2/radeonkmsfw:
All firmware kernel module Makefiles. There's one directory and one
Makefile for each firmware.

sys/contrib/dev/drm2/radeonkmsfw:
All firmware binary sources.

tools/tools/drm/radeon
Tools to update firmwares or regenerate some headers.

Merging the driver to FreeBSD 9.x may be possible but not a priority for
now.

Help from: kib@, kan@
Tested by: avg@, kwm@, ray@,
Alexander Yerenkow <yerenkow@gmail.com>,
Anders Bolt-Evensen <andersbo87@me.com>,
Denis Djubajlo <stdedjub@googlemail.com>,
J.R. Oldroyd <fbsd@opal.com>,
Mikaël Urankar <mikael.urankar@gmail.com>,
Pierre-Emmanuel Pédron <pepcitron@gmail.com>,
Sam Fourman Jr. <sfourman@gmail.com>,
Wade <wade-is-great@live.com>,
(probably other I forgot...)
HW donations: kyzh, Yakaz

r254894:
drm/radeon: Rename the (S)DEBUG macros in atom.c to avoid conflicts

For instance, DEBUG is already defined in the LINT kernel configuration.
This fixes the build of LINT.

r254899:
drm/radeon: Disable build on i386/pc98

r255572:
drm/radeon: Fix usage of vga_pci_map_bios()

vga_pci_(un)map_bios() takes a vgapci device as argument, not a drmn
one. This fixes a bug where the BIOS couldn't be mapped if the device
wasn't the boot display.

Approved by: re (kib; blanket for following drm2/radeon commits)

r255573:
drm/radeon: Fix usage of pci_save_state() and pci_restore_state()

Calling those functions with the drmn device as argument causes a panic,
because it's not a direct child of pci$N. They must be called with the
vgapci device instead.

This fix is not enough to make suspend/resume work reliably.

Approved by: re (blanket)

r255587:
drm/radeon: Add missing "return false" after unmapping invalid BIOS

Without that, we would try to copy the unmapped BIOS.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
Approved by: re (blanket)

r256771:
drm/radeon: radeonkms depends on firmware(9)

Submitted by: tijl@

r257869:
drm: Initialize "handle" to 0 before calling drm_gem_handle_create()

This is variable is being checked in drm_gem_name_create() before being
set.

r257870:
drm/radeon: Wake up userland after page flip

For instance, this caused issues in KDE, such as stuttered animations
(with desktop effects enabled).

r259003:
Initialize modesetting sysctls in radeonkms.

This is intended for MFC if re@ permits.

Reviewed by: kib, dumbbell
Tested by: Steven Chamberlain <steven@pyro.eu.org>
MFC after: 3 days

r259101:
drm/radeon: agp_info->ai_aperture_size is in bytes, not Mbytes

This fixes radeon_agp_init() and gtt_size is now correct. However, this
is not enough to make Radeon AGP cards work: ttm_agp_backend.c isn't
implemented yet.

Submitted by: tijl@

r259104:
drm/radeon: radeon_dp_i2c_aux_ch() must return 0 on FreeBSD

The code was unmodified compared to Linux and returned the amount of
received bytes from the i2c bus. This led to non-working i2c bus and
failure to eg. read monitor's EDID, if connected to DisplayPort.

MFC after: 3 days
Tested by: Mikaël Urankar <mikael.urankar@gmail.com>

r259684:
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)

r261497:
Abort when firmware isn't present in R600+ models.

More details at:
http://anonscm.debian.org/viewvc/kernel/dists/trunk/linux/debian/patches/bugfix/all/radeon-firmware-is-required-for-drm-and-kms-on-r600-onward.patch?revision=20909&view=co

Reviewed by: dumbbell
MFC after: 1 week


263119 13-Mar-2014 dumbbell

MFC changes to atomic.h usage in DRM code

This commit follows the merge of atomic.h changes in r262807 and r262823.
The original work is from Jung-uk Kim (jkim@).

The following revisions were merged in this single commit:

r255009:
Fix a compiler warning. With this fix, a negative time can be converted to
a struct timeval and back to the original nanoseconds correctly.

r255012:
Fix a compiler warning and add couple of VM map types.

r255013:
Correct atomic operations in i915.

r255037:
Fix atomic operations on context_flag without altering semantics.

r255039:
- Remove test_and_set_bit() macro. It is unused since r255037.
- Relax atomic_read() and atomic_set() macros. Linux does not require any
memory barrier. Also, these macros may be even reordered or optimized away
according to the API documentation:

https://www.kernel.org/doc/Documentation/atomic_ops.txt

r255041:
Clarify confusions between atomic_t and bitmap. Fix bitmap operations
accordingly.

r255042:
Fix the incomplete conversion from atomic_t to long for test_bit().

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

r255045:
'u_long' is consistently spelled 'unsigned long' in this file. Fix it.


262988 10-Mar-2014 dumbbell

MFC TTM, a memory manager used by video drivers

This is the last step before the merge of the Radeon KMS driver. Other
changes to TTM will be merged with radeonkms.

The following revisions were merged in this single commit:

r247835:
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

r247848:
Fix build with gcc, remove redundand declarations.

Reported and tested by: gjb
MFC after: 1 month

r247849:
Fix build with gcc, do not use unnamed union.

Reported and tested by: gjb
MFC after: 1 month

r248060:
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@)

r248657:
drm/ttm: Fix TTM buffer object refcount

This fixes memory leaks in the radeonkms driver.

Reviewed by: Konstantin Belousov (kib@)
Tested by: J.R. Oldroyd <jr@opal.com>

r248661:
drm/ttm: Explain why we don't need to acquire a ref in ttm_bo_vm_ctor()

r248663:
drm/ttm: Fix a typo: s/pTTM]/[TTM]/

r248666:
Do not call malloc(M_WAITOK) while bodev->fence_lock mutex is
held. The ttm_buffer_object_transfer() does not need the mutex locked
at all, except for the call to the driver sync_obj_ref() method.

Reported and tested by: dumbbell
MFC after: 2 weeks

r252864:
Remove unneeded page lock around vm_page_insert().

Submitted by: alc

r253710:
MFgem r251960: re-check the mgt device object for the requested page
after the object was relocked.

Tested by: dumbbell
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

r254822:
drm: In drm_mmap_single, try ttm_bo_mmap_single() before drm_gem_mmap_single()

In drivers such as the Radeon driver, the DRIVER_GEM features flag is
set but TTM is used to mmap buffer object.

r254858:
drm: Add missing bits to drmP.h, required by the Radeon driver

Some of the FreeBSD-specific definitions are moved to drm_os_freebsd.h.
But there's still work to do to clean it up and reduce the diff with
Linux' drmP.h.

r254860:
drm: Update drm_atomic.h, now that projects/atomic64 is in HEAD

Submitted by: jkim@

r254861:
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>

r254862:
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>

r254863:
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@

r254864:
drm/ttm: Import Linux commit f2d476a110bc24fde008698ae9018c99e803e25c

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

drm/ttm: use ttm_bo_reserve_slowpath_nolru in ttm_eu_reserve_buffers, v2

This requires re-use of the seqno, which increases fairness slightly.
Instead of spinning with a new seqno every time we keep the current one,
but still drop all other reservations we hold. Only when we succeed,
we try to get back our other reservations again.

This should increase fairness slightly as well.

Changes since v1:
- Increase val_seq before calling ttm_bo_reserve_slowpath_nolru and
retrying to take all entries to prevent a race.

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

Approved by: kib@

r254865:
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@

r254866:
drm/ttm: Import Linux commit 630541863b29f88c7ab34e647758344e4cd1eafd

Author: Dave Airlie <airlied@gmail.com>
Date: Wed Jan 16 14:25:44 2013 +1000

ttm: don't destroy old mm_node on memcpy failure

When we are using memcpy to move objects around, and we fail to memcpy
due to lack of memory to populate or failure to finish the copy, we don't
want to destroy the mm_node that has been copied into old_copy.

While working on a new kms driver that uses memcpy, if I overallocated bo's
up to the memory limits, and eviction failed, then machine would oops soon
after due to having an active bo with an already freed drm_mm embedded in it,
freeing it a second time didn't end well.

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

Approved by: kib@

r254867:
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@

r254868:
drm/ttm: Import Linux commit ff7c60c580d9722f820d85c9c58ca55ecc1ee7c4

Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Mon Jan 14 15:08:14 2013 +0100

drm/ttm: fix fence locking in ttm_buffer_object_transfer, 2nd try

This fixes up

commit e8e89622ed361c46bf90ba4828e685a8b603f7e5
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Tue Dec 18 22:25:11 2012 +0100

drm/ttm: fix fence locking in ttm_buffer_object_transfer

which leaves behind a might_sleep in atomic context, since the
fence_lock spinlock is held over a kmalloc(GFP_KERNEL) call. The fix
is to revert the above commit and only take the lock where we need it,
around the call to ->sync_obj_ref.

v2: Fixup things noticed by Maarten Lankhorst:
- Brown paper bag locking bug.
- No need for kzalloc if we clear the entire thing on the next line.
- check for bo->sync_obj (totally unlikely race, but still someone
else could have snuck in) and clear fbo->sync_obj if it's cleared
already.

Reported-by: Dave Airlie <airlied@gmail.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>

Approved by: kib@

r254870:
drm/ttm: Make ttm_bo_wait() call uninterruptible in page fault handler

This fixes a crash where a SIGLALRM, heavily used by X.Org, would
interrupt the wait, causing the page fault to fail and the "Xorg"
process to receive a SIGSEGV.

Approved by: kib@

r254871:
drm/ttm: Fix style errors

r254873:
drm/ttm: When removing a range of pages from a pool, remove all of them

Submitted by: Mark Kettenis and Jonathan Gray from OpenBSD
Approved by: kib@

r254874:
drm/ttm: Improve comment in ttm_bo_vm_ctor() about lack of ref acquisition

Approved by: kib@

r254875:
ttm: "to_page->valid = VM_PAGE_BITS_ALL" before vm_page_dirty(to_page)

Approved by; kib@

r254876:
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@

r254877:
drm/ttm: Fix style in ttm_bo_release_mmap()

r254878:
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@

r254879:
drm/ttm: Remove unused VM_ALLOC_DMA32 define

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

Submitted by: jkim@

r259612:
ttm_bo_vm_lookup_rb: actually make use of the red-black tree

Previously the code would just iterate over the whole tree as if it were
just a list.

Without this change I would observe X server becoming more and more
jerky over time.

MFC after: 5 days


247835 05-Mar-2013 kib

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