MFC r254882, r254883, r255571:

vga_pci: Add API to map the Video BIOS

Here are two new functions to map and unmap the Video BIOS:
    void * vga_pci_map_bios(device_t dev, size_t *size);
    void   vga_pci_unmap_bios(device_t dev, void *bios);

The BIOS is either taken from the shadow copy made by the System BIOS at
boot time if the given device was used for the default display (i386,
amd64 and ia64 only), or from the PCI expansion ROM.

Additionally, one can determine if a given device was the default
display at boot time using the following new function:
    int    vga_pci_is_boot_display(device_t dev);

Submitted by:	jhb@ (r255571)


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261622 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r259679:

vga_pci: Improve boot display detection

The previous code was checking the "VGA Enable" bit on the video card's
parent PCI-to-PCI bridge only. This didn't work for the case where the
video card is attached to the root PCI bus (ie. the card has no parent
PCI-to-PCI bridge).

Now, the new code:
    1. checks the "VGA Enable" bit on the parent bridge only if it's a
       PCI-to-PCI bridge;
    2. always checks the "I/O" and "Memory address space decoding" bits
       on the video card itself.

However, vendor-specific bits are not used.

This fixes the use of many integrated Radeon cards: without this patch,
we fail to detect them as the boot display and, when radeonkms looks for
the Video BIOS, it skips the shadow copy made by the System BIOS. It
then fails to fully initialize the card, because the shadow copy is the
only way to read the Video BIOS in these situations. A workaround was to
force the boot display selection using the "hw.pci.default_vgapci_unit"
tunable.

A previous version of this patch added a new function doing the checks.
Now, the vga_pci_is_boot_display() function is used to perform the
checks (only until the boot display is found) and return if the given
device is the boot display or not.

Furthermore, vga_pci_attach() logs "Boot video device" if the card being
attached it the Chosen One:
    vgapci0: <VGA-compatible display> [...]
    vgapci0: Boot video device

Reviewed by:	kib@, jhb@ (both a previous version)
Tested by:	lunatic_ (#freebsd-xorg, integrated Radeon card,
		xmj (#freebsd-xorg, i915+NVIDIA cards)


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261623 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r248061:

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


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261624 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r249041, r249249:

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@,
		Olivier Cochard-Labbé <olivier@cochard.me>


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261625 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254792:

drm: Call drm_global_init() & drm_global_release() at module load/unload


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261626 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254794:

drm: Import drm_buffer.[ch] from Linux 3.8-rc3

This will be used by the Radeon KMS driver.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261629 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254796:

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>


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261630 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254797:

drm: Const'ify the 1st "drm_display_mode" passed to "mode_fixup" callbacks

This will be needed by the Radeon KMS driver.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261631 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254798:

drm: Fix leak of connector->edid_blob_ptr


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261632 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r261354:
In _pthread_kill(), if passed pthread is current thread, do not send
the signal second time, by adding the missed else before if statement.

PR:	threads/186309


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261637 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r255093 (by theraven):

  Don't use _Unwind_Backtrace() on ARM as it's currently missing from
  our libgcc_s.  andrew@ has patches to add it, so this can be reverted
  and sync'd with upstream later.

MFC r255815 (by theraven):

  Import a new libcxxrt.  This fixes some potential crashing in the
  demangler.

MFC r260553 (by theraven):

  Add missing C++11 typeinfos to the libcxxrt version script.

  PR:		185663


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261645 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254817:

drm: Import drm_dp_helper.c from Linux 3.8-rc3

While here, update drm_dp_helper.h to better match Linux one.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261652 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254818:

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.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261653 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254819:

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@


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261654 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254820:

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.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261658 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254821:

drm: Fix cleanup if device initialization fails

This plugs some memory leaks.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261659 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254833:

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>


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261660 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254835:

drm: Fix typo in KASSERT message: s/Dandling/Dangling/


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261661 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254836, r254837:

drm: Support gem_open_object() and gem_close_object() callbacks

... in struct drm_driver_info.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261662 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r254838:

drm: In drm_gem_name_create(), verify argument before acquiring lock

Submitted by:	J.R. Oldroyd <jr@opal.com>


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@261664 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f