Commit Graph

96 Commits

Author SHA1 Message Date
Jung-uk Kim
9dcd4b1293 Clarify confusions between atomic_t and bitmap. Fix bitmap operations
accordingly.
2013-08-29 20:40:45 +00:00
Jung-uk Kim
ea4447500d - 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
2013-08-29 19:47:52 +00:00
Jung-uk Kim
0289d87d9c Fix atomic operations on context_flag without altering semantics. 2013-08-29 18:36:47 +00:00
Jung-uk Kim
8e0caa60f2 Correct atomic operations in i915. 2013-08-28 23:59:38 +00:00
Jung-uk Kim
6ac96a7e7e Fix a compiler warning and add couple of VM map types. 2013-08-28 23:43:28 +00:00
Jung-uk Kim
2d0196c405 Fix a compiler warning. With this fix, a negative time can be converted to
a struct timeval and back to the original nanoseconds correctly.
2013-08-28 22:57:49 +00:00
Jean-Sébastien Pédron
f171f214dc 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.
2013-08-26 06:31:57 +00:00
Jean-Sébastien Pédron
0adf4921fb 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
2013-08-25 19:37:15 +00:00
Jean-Sébastien Pédron
e558c87be3 drm: Use the new drm_atomic.h, following the merge of projects/atomic64
Submitted by:	jkim@
2013-08-25 15:38:16 +00:00
Jean-Sébastien Pédron
a18d713ab7 drm/ttm: Remove unused VM_ALLOC_DMA32 define 2013-08-25 15:33:17 +00:00
Jean-Sébastien Pédron
4360c0bb20 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@
2013-08-25 15:29:23 +00:00
Jean-Sébastien Pédron
be562465c9 drm/ttm: Fix style in ttm_bo_release_mmap() 2013-08-25 15:26:45 +00:00
Jean-Sébastien Pédron
970c941acb 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@
2013-08-25 15:15:55 +00:00
Jean-Sébastien Pédron
39db4184ec ttm: "to_page->valid = VM_PAGE_BITS_ALL" before vm_page_dirty(to_page)
Approved by;	kib@
2013-08-25 15:12:26 +00:00
Jean-Sébastien Pédron
fbe1da288c drm/ttm: Improve comment in ttm_bo_vm_ctor() about lack of ref acquisition
Approved by:	kib@
2013-08-25 15:06:48 +00:00
Jean-Sébastien Pédron
df58787aad 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@
2013-08-25 15:05:22 +00:00
Jean-Sébastien Pédron
9ba6f1ae72 drm/ttm: Fix style errors 2013-08-25 15:01:35 +00:00
Jean-Sébastien Pédron
098cced799 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@
2013-08-25 15:00:48 +00:00
Jean-Sébastien Pédron
a7fa1c7cc3 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@
2013-08-25 14:58:44 +00:00
Jean-Sébastien Pédron
6ee96714c8 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@
2013-08-25 14:56:14 +00:00
Jean-Sébastien Pédron
6f65d975ed 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@
2013-08-25 14:55:08 +00:00
Jean-Sébastien Pédron
aacce5b681 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@
2013-08-25 14:53:39 +00:00
Jean-Sébastien Pédron
fb61ac33be 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@
2013-08-25 14:52:20 +00:00
Jean-Sébastien Pédron
8aa5d01931 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@
2013-08-25 14:47:22 +00:00
Jean-Sébastien Pédron
aa675725db 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>
2013-08-25 14:41:22 +00:00
Jean-Sébastien Pédron
f25ca89630 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>
2013-08-25 14:39:51 +00:00
Jean-Sébastien Pédron
0277f749a3 drm: Update drm_atomic.h, now that projects/atomic64 is in HEAD
Submitted by:	jkim@
2013-08-25 14:33:49 +00:00
Jean-Sébastien Pédron
01655b8522 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.
2013-08-25 14:27:14 +00:00
Jean-Sébastien Pédron
bd5c482a8c drm: Import drm_fixed.h from Linux 3.8 2013-08-25 12:27:15 +00:00
Jean-Sébastien Pédron
a435cf5cd5 drm: Update drm_pciids.h based on Linux 3.8
This header can be easily updated using the new "gen-drm_pciids" script,
available in tools/tools/drm. The script uses the Linux' drm_pciids.h
header for new IDs, the FreeBSD's one because we add the name of the
device to each IDs, and the PCI IDs database (misc/pciids port) to fill
this name automatically for new IDS.

To call the script:
  tools/tools/drm/gen-drm_pciids					\
    /path/to/linux/drm_pciids.h						\
    /path/to/freebsd/drm_pciids.h					\
    /path/to/pciids/pci.ids
2013-08-25 12:20:57 +00:00
Jean-Sébastien Pédron
e27c6c9fa2 drm: Import drm_pcie_get_speed_cap_mask() in drm_pci.c
This comes with several PCI_VENDOR_ID_* defines which should go in a
more central place.
2013-08-25 11:34:37 +00:00
Jean-Sébastien Pédron
adeff39cd4 drm: Import list_for_each_entry_safe_from() macro 2013-08-25 10:28:02 +00:00
Jean-Sébastien Pédron
9f2e0f5d19 drm: Use DRM_IF_MAJOR & DRM_IF_MINOR from drm_core.h 2013-08-25 10:13:23 +00:00
Jean-Sébastien Pédron
735f427563 drm: In drm_gem_name_create(), verify argument before acquiring lock
Submitted by:	J.R. Oldroyd <jr@opal.com>
2013-08-25 10:04:10 +00:00
Jean-Sébastien Pédron
10548903da drm: Call "gem_close_object" driver callback from drm_gem_object_release_handle()
This fixes leakage of "bo_va" for Cayman and following card generations.
2013-08-25 10:01:59 +00:00
Jean-Sébastien Pédron
1eeccc8f4c drm: Support gem_open_object() and gem_close_object() callbacks
... in struct drm_driver_info.
2013-08-25 09:58:31 +00:00
Jean-Sébastien Pédron
b5185a8933 drm: Fix typo in KASSERT message: s/Dandling/Dangling/ 2013-08-25 09:53:00 +00:00
Jean-Sébastien Pédron
8479311ef0 drm: Import Linux commit cd004b3f4cd4169815c82bf9e424fda06978898a
Author: Shirish S <s.shirish@samsung.com>
Date:   Thu Aug 30 07:04:06 2012 +0000

    drm: edid: add support for E-DDC

    The current logic for probing ddc is limited to
    2 blocks (256 bytes), this patch adds support
    for the 4 block (512) data.

    To do this, a single 8-bit segment index is
    passed to the display via the I2C address 30h.
    Data from the selected segment is then immediately
    read via the regular DDC2 address using a repeated
    I2C 'START' signal.

    Signed-off-by: Shirish S <s.shirish@samsung.com>
    Reviewed-by: Jean Delvare <jdelvare@suse.de>
    Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Reviewed-by: Ville Syrjala <ville.syrjala@linux.intel.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-08-25 09:46:03 +00:00
Jean-Sébastien Pédron
92cf4f8de0 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.
2013-08-25 00:34:44 +00:00
Jean-Sébastien Pédron
5eaeb54990 drm: Fix cleanup if device initialization fails
This plugs some memory leaks.
2013-08-25 00:22:34 +00:00
Jean-Sébastien Pédron
22f61fe5d4 drm: Use driver-provided "use_msi" callback to determine if MSI is blacklisted
For now, keep the static array for i915. But eventually, it should be
moved to a callback in the driver itself.
2013-08-25 00:13:53 +00:00
Jean-Sébastien Pédron
f7eda40d0e drm: Don't delete already deleted iicbus child from drm_iic_dp_aux
The iic_dp_aux_detach callback is therefore useless: it's replaced by
bus_generic_detach. This fixes a "General protection fault" panic during
second (incorrect) deletion of the child.

Tested by:	kwm@
Reviewed by:	ray@
2013-08-24 23:54:06 +00:00
Jean-Sébastien Pédron
285be846af drm: Move definition of EREMOTEIO to drmP.h
It will be used by both i915 and radeon drivers.

Add ERESTARTSYS definition at the same time.
2013-08-24 23:47:31 +00:00
Jean-Sébastien Pédron
74eb6a63ca drm: Import drm_dp_helper.c from Linux 3.8-rc3
While here, update drm_dp_helper.h to better match Linux one.
2013-08-24 23:38:57 +00:00
Jean-Sébastien Pédron
06b77ec36d drm: Fix leak of connector->edid_blob_ptr 2013-08-24 16:55:53 +00:00
Jean-Sébastien Pédron
0bf283a517 drm: Const'ify the 1st "drm_display_mode" passed to "mode_fixup" callbacks
This will be needed by the Radeon KMS driver.
2013-08-24 16:50:47 +00:00
Jean-Sébastien Pédron
d08e4108f6 drm/i915: Import Linux commit 71244653a8fb0f46bc12ae421f1d5f72af6a75da
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Mon Jun 4 18:39:20 2012 +0200

    drm/i915: adjusted_mode->clock in the dp mode_fixup

    ... instead of changing mode->clock, which we should leave as-is.

    After the previous patch we only touch that if it's a panel, and then
    adjusted mode->clock equals adjusted_mode->clock. Outside of
    intel_dp.c we only use ajusted_mode->clock in the mode_set functions.

    Within intel_dp.c we only use it to calculate the dp dithering
    and link bw parameters, so that's the only thing we need to fix
    up.

    As a temporary ugliness (until the cleanup in the next patch) we
    pass the adjusted_mode into dp_dither for both parameters (because
    that one still looks at mode->clock).

    Note that we do overwrite adjusted_mode->clock with the selected dp
    link clock, but that only happens after we've calculated everything we
    need based on the dotclock of the adjusted output configuration.

    Outside of intel_dp.c only intel_display.c uses adjusted_mode->clock,
    and that stays the same after this patch (still equals the selected dp
    link clock). intel_display.c also needs the actual dotclock (as
    target_clock), but that has been fixed up in the previous patch.

    v2: Adjust the debug message to also use adjusted_mode->clock.

    Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
    Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
    Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2013-08-24 16:41:14 +00:00
Jean-Sébastien Pédron
943c0e86fe drm: Import drm_buffer.[ch] from Linux 3.8-rc3
This will be used by the Radeon KMS driver.
2013-08-24 16:14:20 +00:00
Jean-Sébastien Pédron
e3b7062fce drm: Call drm_global_init() & drm_global_release() at module load/unload 2013-08-24 15:47:15 +00:00
Konstantin Belousov
5944de8ecd Remove the deprecated VM_ALLOC_RETRY flag for the vm_page_grab(9).
The flag was mandatory since r209792, where vm_page_grab(9) was
changed to only support the alloc retry semantic.

Suggested and reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
2013-08-22 07:39:53 +00:00