Commit Graph

68 Commits

Author SHA1 Message Date
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
Konstantin Belousov
c325e866f4 Different consumers of the struct vm_page abuse pageq member to keep
additional information, when the page is guaranteed to not belong to a
paging queue.  Usually, this results in a lot of type casts which make
reasoning about the code correctness harder.

Sometimes m->object is used instead of pageq, which could cause real
and confusing bugs if non-NULL m->object is leaked.  See r141955 and
r253140 for examples.

Change the pageq member into a union containing explicitly-typed
members.  Use them instead of type-punning or abusing m->object in x86
pmaps, uma and vm_page_alloc_contig().

Requested and reviewed by:	alc
Sponsored by:	The FreeBSD Foundation
2013-08-10 17:36:42 +00:00
Attilio Rao
e946b94934 On all the architectures, avoid to preallocate the physical memory
for nodes used in vm_radix.
On architectures supporting direct mapping, also avoid to pre-allocate
the KVA for such nodes.

In order to do so make the operations derived from vm_radix_insert()
to fail and handle all the deriving failure of those.

vm_radix-wise introduce a new function called vm_radix_replace(),
which can replace a leaf node, already present, with a new one,
and take into account the possibility, during vm_radix_insert()
allocation, that the operations on the radix trie can recurse.
This means that if operations in vm_radix_insert() recursed
vm_radix_insert() will start from scratch again.

Sponsored by:	EMC / Isilon storage division
Reviewed by:	alc (older version)
Reviewed by:	jeff
Tested by:	pho, scottl
2013-08-09 11:28:55 +00:00
Attilio Rao
c7aebda8a1 The soft and hard busy mechanism rely on the vm object lock to work.
Unify the 2 concept into a real, minimal, sxlock where the shared
acquisition represent the soft busy and the exclusive acquisition
represent the hard busy.
The old VPO_WANTED mechanism becames the hard-path for this new lock
and it becomes per-page rather than per-object.
The vm_object lock becames an interlock for this functionality:
it can be held in both read or write mode.
However, if the vm_object lock is held in read mode while acquiring
or releasing the busy state, the thread owner cannot make any
assumption on the busy state unless it is also busying it.

Also:
- Add a new flag to directly shared busy pages while vm_page_alloc
  and vm_page_grab are being executed.  This will be very helpful
  once these functions happen under a read object lock.
- Move the swapping sleep into its own per-object flag

The KPI is heavilly changed this is why the version is bumped.
It is very likely that some VM ports users will need to change
their own code.

Sponsored by:	EMC / Isilon storage division
Discussed with:	alc
Reviewed by:	jeff, kib
Tested by:	gavin, bapt (older version)
Tested by:	pho, scottl
2013-08-09 11:11:11 +00:00
Jeff Roberson
5df87b21d3 Replace kernel virtual address space allocation with vmem. This provides
transparent layering and better fragmentation.

 - Normalize functions that allocate memory to use kmem_*
 - Those that allocate address space are named kva_*
 - Those that operate on maps are named kmap_*
 - Implement recursive allocation handling for kmem_arena in vmem.

Reviewed by:	alc
Tested by:	pho
Sponsored by:	EMC / Isilon Storage Division
2013-08-07 06:21:20 +00:00
Konstantin Belousov
18ec23deea 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
2013-07-27 16:44:37 +00:00
Konstantin Belousov
49c1fb04b2 The pmap_qenter() and pmap_qremove() perform TLB invalidation on its
own, no need to call pmap_invalidate_range() one more time.

Noted by:	alc
MFC after:	1 week
2013-07-27 16:42:29 +00:00
Konstantin Belousov
da6335eb54 Use the right name for the vm_map_find(9) flag to specify shared
mapping.  The MAP_SHARED and MAP_INHERIT_SHARE values are identical.

Noted by:	alc
MFC after:	3 days
2013-07-20 13:52:40 +00:00
John Baldwin
ff74a3fa6b Be more aggressive in using superpages in all mappings of objects:
- Add a new address space allocation method (VMFS_OPTIMAL_SPACE) for
  vm_map_find() that will try to alter the alignment of a mapping to match
  any existing superpage mappings of the object being mapped.  If no
  suitable address range is found with the necessary alignment,
  vm_map_find() will fall back to using the simple first-fit strategy
  (VMFS_ANY_SPACE).
- Change mmap() without MAP_FIXED, shmat(), and the GEM mapping ioctl to
  use VMFS_OPTIMAL_SPACE instead of VMFS_ANY_SPACE.

Reviewed by:	alc (earlier version)
MFC after:	2 weeks
2013-07-19 19:06:15 +00:00
Konstantin Belousov
5af68df670 Remove unneeded page lock around vm_page_insert().
Submitted by:	alc
2013-07-06 04:46:42 +00:00
Konstantin Belousov
1dc72d3681 On some generations of the Intel GPU, disabling of the VGA Display
stops updating the vertical retrace indicator.  The text mouse
renderer in syscons is executing from the callout and spins waiting
for the start of next frame.  As result, after the X server finishes,
since the VGA cannot be turned on, but syscons does not know about
this, the clock swi spins forever.

Hack around the problem by disabling wait for the retrace if KMS is
activated.

Diagnosed and tested by:	Michiel Boland <boland37@xs4all.nl>
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2013-06-18 20:19:09 +00:00
Konstantin Belousov
aec577b8d1 Since the gem pagefault handler relocks the vm object lock, other
thread might fault on the same GTT offset meantime and instantiate the
mapping.  Recheck that the mgt device object still does not have a
page at the current offset after relocking, and return a possibly
installed page.

Reported by:	Oleg Sidorkin <osidorkin@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2013-06-18 20:02:52 +00:00
Konstantin Belousov
8b73dbd71f Remove stray empty line.
MFC after:	3 days
2013-06-18 19:56:52 +00:00
Alan Cox
27a18d6a23 Don't busy the page unless we are likely to release the object lock.
Reviewed by:	kib
Sponsored by:	EMC / Isilon Storage Division
2013-06-06 06:17:20 +00:00
Konstantin Belousov
aed1e745d0 The vm_page lock is not needed around the call to vm_page_insert().
Submitted by:	alc
MFC after:	1 week
2013-06-03 04:11:42 +00:00
Jean-Sébastien Pédron
63495f12a6 drm: Right-shift I2C slave address before passing it to aux channel
In r249041, I2C slave addresses were left-shifted at creation time to
have the same behavior between i915 and radeon (not committed yet). This
change broke the aux channel. The user-visible change was that display
port on i915 didn't work anymore.

To fix this, we right-shift the address back to restore the original value.

Reported by:	Olivier Cochard-Labbé <olivier@cochard.me>
Tested by:	Olivier Cochard-Labbé <olivier@cochard.me>
Reviewed by:	kib@
2013-04-08 08:37:57 +00:00
Jean-Sébastien Pédron
c1ebf400c3 drm and i915: Left-shift iic_msg.slave at creation time
This is required because, in the radeon driver, we can't left-shift in a
central place, like it was done in the i915 driver.

Reviewed by:	kib@, kan@, avg@
Tested by:	kib@, avg@
2013-04-03 08:27:35 +00:00
Konstantin Belousov
b11d58b63f 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
2013-03-23 22:23:15 +00:00
Jean-Sébastien Pédron
accadf8de2 drm/ttm: Fix a typo: s/pTTM]/[TTM]/ 2013-03-23 20:46:47 +00:00
Jean-Sébastien Pédron
76c40c6986 drm/ttm: Explain why we don't need to acquire a ref in ttm_bo_vm_ctor() 2013-03-23 20:43:26 +00:00
Jean-Sébastien Pédron
a649986089 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>
2013-03-23 19:19:19 +00:00
Attilio Rao
89f6b8632c Switch the vm_object mutex to be a rwlock. This will enable in the
future further optimizations where the vm_object lock will be held
in read mode most of the time the page cache resident pool of pages
are accessed for reading purposes.

The change is mostly mechanical but few notes are reported:
* The KPI changes as follow:
  - VM_OBJECT_LOCK() -> VM_OBJECT_WLOCK()
  - VM_OBJECT_TRYLOCK() -> VM_OBJECT_TRYWLOCK()
  - VM_OBJECT_UNLOCK() -> VM_OBJECT_WUNLOCK()
  - VM_OBJECT_LOCK_ASSERT(MA_OWNED) -> VM_OBJECT_ASSERT_WLOCKED()
    (in order to avoid visibility of implementation details)
  - The read-mode operations are added:
    VM_OBJECT_RLOCK(), VM_OBJECT_TRYRLOCK(), VM_OBJECT_RUNLOCK(),
    VM_OBJECT_ASSERT_RLOCKED(), VM_OBJECT_ASSERT_LOCKED()
* The vm/vm_pager.h namespace pollution avoidance (forcing requiring
  sys/mutex.h in consumers directly to cater its inlining functions
  using VM_OBJECT_LOCK()) imposes that all the vm/vm_pager.h
  consumers now must include also sys/rwlock.h.
* zfs requires a quite convoluted fix to include FreeBSD rwlocks into
  the compat layer because the name clash between FreeBSD and solaris
  versions must be avoided.
  At this purpose zfs redefines the vm_object locking functions
  directly, isolating the FreeBSD components in specific compat stubs.

The KPI results heavilly broken by this commit.  Thirdy part ports must
be updated accordingly (I can think off-hand of VirtualBox, for example).

Sponsored by:	EMC / Isilon storage division
Reviewed by:	jeff
Reviewed by:	pjd (ZFS specific review)
Discussed with:	alc
Tested by:	pho
2013-03-09 02:32:23 +00:00
Jean-Sébastien Pédron
b3469f58a7 Import Linux commit a1b7736dac5f2d5876e68c47a0fce3f423840070
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Wed Feb 1 11:38:22 2012 +0100

    drm drm_fb_helper: destroy modes

    drm_setup_crtcs allocated modes using drm_mode_duplicate. Free
    them in drm_fb_helper_crtc_free.

    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

Discussed with:	Konstantin Belousov (kib@)
2013-03-08 18:15:07 +00:00
Jean-Sébastien Pédron
3f81c67746 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@)
2013-03-08 18:11:02 +00:00
Konstantin Belousov
257d427d5f Fix build with gcc, do not use unnamed union.
Reported and tested by:	gjb
MFC after:	1 month
2013-03-05 16:15:34 +00:00
Konstantin Belousov
94415dd90e Fix build with gcc, remove redundand declarations.
Reported and tested by:	gjb
MFC after:	1 month
2013-03-05 16:14:55 +00:00
Jean-Sébastien Pédron
f0916543a6 drm_global.c: Destroy sx in drm_global_release()
This fixes a build error at the same time (unused variable "item"), if
the kernel is compiled without INVARIANTS.

Reported by:	Hartmann, O. <ohartman@zedat.fu-berlin.de> (build error)
Reviewed by:	Konstantin Belousov (kib@)
2013-03-05 11:18:57 +00:00
Konstantin Belousov
9b7efb7458 Correct the r247832.
Noted by:	marius, rdivacky
MFC after:	1 month
2013-03-05 11:02:38 +00:00
Konstantin Belousov
e6cd8542ed 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
2013-03-05 09:49:34 +00:00