Commit Graph

101 Commits (9101a0205c897fea28e6a3d875111a83ad7f7732)

Author SHA1 Message Date
Robert Noland 2580a065d8 [FreeBSD] Catch up to linux on vblank-rework 2008-07-24 00:21:00 -04:00
Robert Noland f57f01f028 [FreeBSD] Improve upper_32_bits define.
Thanks to airlied.
2008-07-21 18:06:52 -04:00
Robert Noland 480c317a6a [FreeBSD] drm_irq.c updates for vblank fixes. 2008-07-17 14:08:06 -04:00
Robert Noland b0e4619a39 FreeBSD: Fix radeon build 2008-07-16 23:39:25 -04:00
Owain Gordon Ainsworth 74cf1f91be BSD: change drm_locked_task*() to use the same scheme as linux.
The current code can sleep in an interrupt handler, that is bad. So
instead if we can't grab the lock, flag it and run the tasklet on
unlock.

Signed-off-by: Robert Noland <rnoland@2hip.net>
2008-07-16 21:37:39 -04:00
Robert Noland 6d6921719c [FreeBSD] Incorporate vblank fixes for bsd. 2008-06-08 01:53:45 -04:00
Robert Noland fc74c2e9d6 [FreeBSD] Go back to using vbl_lock and move init/destroy to load/unload. 2008-06-08 01:53:45 -04:00
Robert Noland 4ce47fd328 [FreeBSD] Get rid of vbl_lock and re-use irq_lock. 2008-06-01 20:33:30 -07:00
Robert Noland 8cd045079e [FreeBSD] Add vblank-rework support and get drivers building.
The i915 driver now works again.
2008-05-27 14:25:20 -07:00
Eric Anholt ad8eb0ed01 [FreeBSD] Convert from drm_device_t to struct drm_device for consistency. 2008-05-27 14:25:08 -07:00
Robert Noland 690dd04d1b bsd: Replace other occurrences of msleep with mtx_sleep 2007-12-02 01:45:09 -05:00
Robert Noland fbc307274f bsd: Now make secondary vblank work
We needed to specifically check for driver support and test the correct
vbl_received value.  Also pulled over support for _DRM_VBLANK_NEXTONMISS
from the linux code.
2007-12-02 01:23:11 -05:00
Robert Noland 787d500c15 bsd: Hook secondary vblank support. 2007-12-01 17:23:09 -05:00
Robert C. Noland III 9be085cbf4 Fix up drm_ati_pcigart_info 2007-11-29 09:38:43 +10:00
Robert Noland c12a3a3ce0 Bug #13233: Chase move of agp headers on FreeBSD. 2007-11-18 22:41:41 -08:00
Kristian Høgsberg 68cdcda1ea Add new shared header file drm_internal.h.
This header file is shared across linux and bsd, but is not installed
for user space to access.  It's the place to put prototypes and data
types that aren't platform or chipset specific, but still internal to
the drm.
2007-11-14 14:28:34 -05:00
vehemens 4340f49bf7 Bug #11951: Fix an errno sign inversion on pre-FreeBSD 5.
Also, annotate where signs change, to hopefully remind the reader of these
issues in the future.
2007-08-13 11:36:10 -07:00
Eric Anholt 5b38e13416 Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
The data is now in kernel space, copied in/out as appropriate according to the
This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal
with those failures.  This also means that XFree86 4.2.0 support for i810 DRM
is lost.
2007-07-20 18:16:42 -07:00
Eric Anholt c1119b1b09 Replace filp in ioctl arguments with drm_file *file_priv.
As a fallout, replace filp storage with file_priv storage for "unique
identifier of a client" all over the DRM.  There is a 1:1 mapping, so this
should be a noop.  This could be a minor performance improvement, as everything
on Linux dereferenced filp to get file_priv anyway, while only the mmap ioctls
went the other direction.
2007-07-20 13:39:45 -07:00
Eric Anholt e39286eb5e Remove DRM_ERR OS macro.
This was used to make all ioctl handlers return -errno on linux and errno on
*BSD.  Instead, just return -errno in shared code, and flip sign on return from
shared code to *BSD code.
2007-07-20 12:53:52 -07:00
Eric Anholt f4e1c1d05c FreeBSD warnings cleanup. 2007-07-19 06:46:13 -07:00
Eric Anholt 33a50412c2 Add dry-coded DRM drawable private information storage for FreeBSD.
With this, all modules build again.
2007-07-18 14:22:49 -07:00
Eric Anholt 3f04fe7890 Fix FreeBSD build. 2007-07-16 01:53:06 -07:00
Arthur Huillet 04e4922c0c Made drm_sg_alloc accessible from inside the DRM - drm_sg_alloc_ioctl is the ioctl wrapper 2007-07-11 02:34:00 +02:00
Jung-uk Kim b0c8d885ce Update a bunch of FreeBSD port code.
Tested on r200/r300.  i915 updates still remain to be done.
2007-05-29 15:02:44 -07:00
Eric Anholt dddacd7a3a Use the DRM_INIT_WAITQUEUE argument (needed on Linux) to avoid a warning. 2006-09-06 23:26:50 -07:00
Eric Anholt 55057660f0 Put the PCI device/vendor id in the drm_device_t.
This helps us unbreak FreeBSD DRM from the 965 changes.
2006-09-06 23:25:14 -07:00
Eric Anholt d572676185 Add a typedef for u64. 2006-09-06 23:08:29 -07:00
Eric Anholt 2abd1f270b Reorder the DRM_*_AGP enum to match linux's numbers (oops). Fixes i915
attachment. Make our mga_drv.c use them, while I'm here.
Submitted by: Jonathan Fosburgh <jonathan@fosburgh.org>
2006-04-18 06:08:17 +00:00
Eric Anholt a10d8178e3 Initial port of savage to FreeBSD for the AGP and !ShadowStatus case. Adds
drm_mtrr_{add,del} for handling the MTRR setup. Still has a LOR issue
    with DRM_VERIFYAREA_READ/DRM_COPY_FROM_USER_UNCHECKED in savage_bci.c
    -- this won't work with the fine-grained locking in use, and just doing
    a single copyin to a temporary will probably work fine. Also note that
    the module leaks approximately 4 kb on unload.
2005-11-08 20:25:00 +00:00
Eric Anholt 71f9b7357c Fix FreeBSD DRM for latest MGA changes to agp support, which cleans things
up a good bit, I think. Also, remove the agp_uninit() function which
    has lain around as a noop for years now. The FreeBSD DRM is now all
    compiling, with the exception of via. One known sleeping-with-lock-held
    issue remains.
2005-11-08 05:29:26 +00:00
Eric Anholt 1a256df480 Catch FreeBSD up to the pcie gart changes. Required minor modification to
radeon_cp.c to use a drm_local_map_t-type mapping (drm_core_ioremap
    rather than drm_ioremap), which contains private device mapping
    information on BSD. I also changed the ati_pcigart interface to use
    "void *" for pointers to kva rather than "unsigned long". While PCIGART
    support appears to be broken on FreeBSD currently, I think this is not
    new, and BusType PCI remains working on my r100 in Linux.
2005-11-08 02:38:01 +00:00
Eric Anholt 4b2a94db46 Fix the spelling of DRM_AUTH so that the bsd core stuff builds again. Next
up is pcigart.
2005-09-12 05:35:51 +00:00
Dave Airlie 0d346a07a8 convert ioctl flags to use flags instead of separate ints 2005-09-03 03:27:14 +00:00
Eric Anholt c425ad1a34 Previously, drm_get_resource_start() and drm_get_resource_len() would
allocate the resource RF_ACTIVE, pull out the appropriate value, and
    return it. However, allocating large framebuffers RF_ACTIVE would run
    the system out of KVA, and this also left open the possibility of the
    resource getting moved after getting the offset. Instead, when either
    of these are called, allocate the resource if it isn't allocated
    already (non-RF_ACTIVE) and store it in the DRM device, to be cleaned
    up on lastclose.
2005-08-26 20:56:11 +00:00
Eric Anholt 55bea952b3 [1] Fix BSD DRM for the nonroot changes. [2] Don't attempt to acquire the
DMA lock in a non-DMA driver, as it will be uninitialized.
Submitted by: [1] jkim (minor changes by me)
2005-08-26 00:16:01 +00:00
Dave Airlie 8ac2fcb193 add agp buffer token 2005-08-17 22:59:00 +00:00
Eric Anholt 4050f5066a Fix build after linux-side checkin of master/root-only split. Still only
cares about root on the BSD side, but should be secure.
2005-08-12 17:18:08 +00:00
Eric Anholt c789ea1521 Rename the driver hooks in the DRM to something a little more
understandable: preinit -> load postinit -> (removed) presetup ->
    firstopen postsetup -> (removed) open_helper -> open prerelease ->
    preclose free_filp_priv -> postclose pretakedown -> lastclose
    postcleanup -> unload release -> reclaim_buffers_locked version ->
    (removed)
postinit and version were replaced with generic code in the Linux DRM
    (drivers now set their version numbers and description in the driver
    structure, like on BSD). postsetup wasn't used at all. Fixes the savage
    hooks for initializing and tearing down mappings at the right times.
    Testing involved at least starting X, running glxgears, killing
    glxgears, exiting X, and repeating.
Tested on: FreeBSD (g200, g400, r200, r128) Linux (r200, savage4)
2005-08-05 03:50:23 +00:00
Eric Anholt b0da5df90a Fix the MGA driver on BSD by passing in the proper chipset flags to the
driver's preinit routine, and by using DRM_COPY_TO_USER_IOCTL when
    copying out to an ioctl's data pointer. Pulled from the latest version
    of my drm-hook-rename.diff and only compile-tested after that.
2005-08-04 07:42:01 +00:00
Eric Anholt ab59dd285c Add latest r300 support from r300.sf.net CVS. Patch submitted by volodya,
with BSD fix from jkim and the r300_reg.h license from Nicolai Haehnle.
    Big thanks to everyone involved!
2005-07-20 21:17:47 +00:00
Eric Anholt c798a382f1 Get the BSD DRM compiling again after MGA and mapping changes. Note that
i915 has been disabled for the moment, rather than working around
    linux-specific code in the shared dir.
2005-06-29 02:54:19 +00:00
Ian Romanick 72cfc797b5 Adds support for PCI cards to MGA DRM
This patch adds serveral new ioctls and a new query to get_param query to
    support PCI MGA cards.
Two ioctls were added to implement interrupt based waiting. With this
    change, the client-side driver no longer needs to map the primary DMA
    region or the MMIO region. Previously, end-of-frame waiting was done by
    busy waiting in the client-side driver until one of the MMIO registers
    (the current DMA pointer) matched a pointer to the end of primary DMA
    space. By using interrupts, the busy waiting and the extra mappings are
    removed.
A third ioctl was added to bootstrap DMA. This ioctl, which is used by the
    X-server, moves a *LOT* of code from the X-server into the kernel. This
    allows the kernel to do whatever needs to be done to setup DMA buffers.
    The entire process and the locations of the buffers are hidden from
    user-mode.
Additionally, a get_param query was added to differentiate between G4x0
    cards and G550 cards. A gap was left in the numbering sequence so that,
    if needed, G450 cards could be distinguished from G400 cards. According
    to Ville Syrjälä, the G4x0 cards and the G550 cards handle
    anisotropic filtering differently. This seems the most compatible way
    to let the client-side driver know which card it's own. Doing this very
    small change now eliminates the need to bump the DRM minor version
    twice.
http://marc.theaimsgroup.com/?l=dri-devel&m=106625815319773&w=2
A number of ioctl handlers in linux-core were also modified so that they
    could be called in-kernel. In these cases, the in-kernel callable
    version kept the existing name (e.g., drm_agp_acquire) and the ioctl
    handler added _ioctl to the name (e.g., drm_agp_acquire_ioctl).
This patch also replaces the drm_agp_do_release function with
    drm_agp_release. drm_agp_release (drm_core_agp_release in the previous
    patch) is very similar to drm_agp_do_release, and I saw no reason to
    have both.
This commit *breaks the build* on BSD. Eric said that he would make the
    required updates to the BSD side soon.
Xorg bug: 3259 Reviewed by: Eric Anholt
2005-06-14 22:34:11 +00:00
Eric Anholt 751765dba5 Add a few more bits of Tonnerre's NetBSD port (Still need to deal with the
device attachment).
2005-06-06 06:45:41 +00:00
Ian Romanick 4a84416c45 Modify drm_driver::device_is_agp to return a tri-state value to indicate
that a device absolutely is, absolutely is not, or may or may not be
    AGP. Modify the i915 DRM to use this to force all i9x5 devices to be
    "AGP" (even the PCI-e devices).
Reported by: Lukas Hejtmanek
2005-05-27 23:42:11 +00:00
Ian Romanick e051cd19c0 Added device_is_agp callback to drm_driver. This function is called by the
platform-specific drm_device_is_agp function. Added implementation of
    this function the the Linux-specific portion of the MGA driver to
    detect PCI G450 cards. Added code to the Linux-specific portion of the
    generic DRM layer to not initialize AGP infrastructure if the card is
    not AGP (this matches what already existed in BSD).
Bumped the driver date and the driver patch-level for MGA.
This mostly fixes bugzilla #3248. The BSD side still needs an
    implementation of mga_driver_device_is_agp.
2005-05-16 17:37:10 +00:00
Eric Anholt ec111d70fe Convert BSD code to mostly use bus_dma, the dma abstraction for dealing
with IOMMUs and such. There is one usage of the forbidden vtophys()
    left in drm_scatter.c which will be fixed up soon. This required a KPI
    change for drm_pci_alloc/free() to return/use a drm_dma_handle_t that
    keeps track of os-specific bits, rather than just passing around the
    vaddr/busaddr/size.
Submitted by: Tonnerre Lombard (partially) Tested on: FreeBSD: Rage128
    AGP/PCI Linux: Savage4 AGP/PCI
2005-04-26 05:19:11 +00:00
Eric Anholt 10ddbc8c8c Use /*- to begin license blocks in BSD code to reduce diffs against FreeBSD
CVS.
2005-04-16 03:02:52 +00:00
Eric Anholt 3e8792e705 Use fuword32 for DRM_GET_USER_UNCHECKED when available. May help on 64-bit
platforms.
Submitted by: Jung-uk Kim, jkim at niksun dot com
2005-02-14 03:28:01 +00:00
Eric Anholt 81459d6e50 Close a race which could allow for privilege escalation by users with DRI
privileges on Radeon hardware. Essentially, a malicious program could
    submit a packet containing an offset (possibly in main memory) to be
    rendered from/to, while a separate thread switched that offset in
    userspace rapidly between a valid value and an invalid one.
    radeon_check_and_fixup_offset() would pull the offset in from user
    space, check it, and spit it back out to user space to be copied in
    later by the emit code. It would sometimes catch the bad value, but
    sometimes the malicious program could modify it after the check and get
    an invalid offset rendered from/to.
Fix this by allocating a temporary buffer and copying the data in at once.
    While here, make the cliprects stuff not do the VERIFYAREA_READ and
    COPY_FROM_USER_UNCHECKED gymnastics, avoiding a lock order reversal on
    FreeBSD. Performance impact is negligible -- no difference on r200 to
    ~1% improvement on rv200 in quake3 tests (P4 1Ghz, demofour at
    1024x768, n=4 or 5).
2005-02-08 04:17:14 +00:00