Commit Graph

187 Commits (2c6308fe54c10075379cb00506d5519e0ced1076)

Author SHA1 Message Date
Eric Anholt 4b2235d2e0 Correct a LOR related to the PCI resource allocations by simply moving the
uninit to unload time rather than lastclose.
2005-11-08 06:11:55 +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 145b23b552 Correct a recursion on non-recursive mutex in drm_addmap from radeon's
firstopen, by making drm_addmap require the drm device lock to be held.
    Also, make matching of kernel maps match linux by requiring shm matches
    to have the contains_lock flag set if the offset doesn't match.
2005-11-08 01:12:08 +00:00
Eric Anholt 900a7e4c36 Re-disable the via driver while it's broken on BSD. 2005-11-06 06:32:25 +00:00
Dave Airlie f42cdc8dcb Add support to turn writeback off via radeon module option 2005-09-30 06:41:10 +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 22ec8ebb17 - Don't try to allocate mappings of less than a PAGE_SIZE in MGA DMA code.
- Comment out the "is this mapping/bufs in allocated AGP" bits in BSD
    because they break mga (which uses AGP allocation that doesn't track
    entries). It's not a security issue when we still have the related
    ioctls marked root-only.
- Apply some power-of-two alignment restrictions to hopefully avoid some
    panicing in bad cases of drm_pci_alloc() on FreeBSD.
- Add verbosity to some error handling that I found useful while debugging.
2005-08-26 23:27:19 +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 5105f9ea59 Fix a lack of parenthesis in macro usage that showed up with INVARIANTS
turned on, i.e. in a kernel build.
2005-08-26 19:07:03 +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 8c21b783c3 Port the VIA DRM to FreeBSD. Original patch by Jake, with some cleanup by
me to match other drivers and avoid ifdeffing. The linux via_drv.c will
    be moved from shared-core to linux-core soon by repocopy.
Submitted by: Jake Burkholder <jake@FreeBSD.org> Tested by: unichrome
2005-08-15 18:07:12 +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 942545721f Correct a couple of descriptions of files in comments (were just
copy'n'pasted).
Submitted by: jkim
2005-07-27 20:20:30 +00:00
Eric Anholt fccd351c8f Link in the savage files from shared-core.
Submitted by: jkim
2005-07-27 20:19:29 +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
Ian Romanick dfc650bd80 Completely re-initialize DMA settings
There were two problems. First, the 'warp' and 'primary' pointers weren't
    cleared, so mga_do_cleanup_dma, which gets called multiple times, would
    try to ioremapfree them multiple times. This resulted in the new error
    messages to syslog. The second problem was the, since the dev_private
    structure isn't reallocated and cleaned out in mga_do_init_dma, when
    the server is reloaded idle-waits would wait for impossible values.
I have given this patch some more riggorous testing. This includes:
- Load module, start server, run GL app, stop server, unload module.
- Load module, start server, run GL app, stop server, unload module, reload
    module, restart server, run GL app.
- Load module, start server, run GL app, stop server, restart server, run
    GL app, stop server, unload module.
In all three cases, everything worked as expected. Please let me know if
    there are any further regressions with this patch.
Xorg bug: 3408 Reported by: Chris Rankin
2005-06-09 21:18:56 +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 a686be5bc8 Change the MGA initialization and cleanup a bit. The dev_private structure
is now allocated (and partially filled in) by the new
    mga_driver_preinit function.
This allows the driver to detect the type of card (i.e., G200 class vs.
    G400 class) on its own. The chipset value passed to mga_dma_init is now
    ignored. This same technique is used by the radeon DRM.
As a result of this, mga_driver_pretakedown was converted to
    mga_driver_postcleanup. This routine gets called in some other places
    than might be expected, and it sets the dev_private pointer to NULL.
    That little gem took over an hour to track down. :(
2005-05-21 02:27:51 +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 6aae7bd5b0 Convert NOMAN to the new preferred spelling NO_MAN to quiet warnings. 2005-04-26 15:27:58 +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 be9e67a927 Fix a panic on startup with non-initmapping drivers by assigning the
drm_ioremap return value to the map handle again.
Submitted by: Tor Egge, tegge at freebsd dot org
2005-04-24 19:09:09 +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 926298e822 Fix build on FreeBSD-current, thanks to jhb@. 2005-04-13 04:20:08 +00:00
Eric Anholt baeb76076e Merge r1.26 from FreeBSD: Now that mem(4) is a kernel module, we need to
depend on it.
2005-02-19 20:00:55 +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 ed082798f4 Use the proper API to get PCI vendor/device number for a dev.
PR: ports/76879 Submitted by: Alex, lesha at intercaf dot ru.
2005-02-14 03:26:52 +00:00
Eric Anholt 0d2eb2b90c Fix bad copy'n'pastage of copyrights -- don't disclaim anything for VA
Linux or PI in my copyrights when I should be doing it for myself.
2005-02-13 01:18:25 +00:00
Eric Anholt ba18d68ff5 Add the first bits necessary for a port of savage to FreeBSD. More to
follow later.
2005-02-13 01:08:29 +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
Eric Anholt 5a332a0f61 Restore a debugging message to DRM_DEBUG instead of DRM_ERROR. 2005-02-07 03:10:03 +00:00
Eric Anholt 2239c55a30 Remove some annoying trailing whitespace. 2005-02-07 01:14:42 +00:00
Eric Anholt 080a547d4d - Implement drm_initmap, and extend it with the resource number to help
FreeBSD. Add drm_get_resource_{start|len} so linux-specific stuff
    doesn't need to be in shared code.
- Fix mach64 build by using __DECONST to work around passing a const
    pointer to useracc, which is unfortunately not marked const.
- Get rid of a lot of maplist code by not having dev->maplist be a pointer,
    and by sticking the link entries directly in drm_local_map_t rather
    than having a separate structure for the linked list.
- Factor out map uninit and removal into its own routine, rather than
    duplicating in both drm_takedown() and drm_rmmap().
- Hook up more driver functions, and correct FreeBSD-specific bits of
    radeon_cp.c, making radeon work.
- Baby steps towards using bus_space as we should.
2005-02-05 08:00:14 +00:00
Eric Anholt 7d0cb01cbf Add detection of whether the device is AGP by walking the capabilities
list.
2005-01-17 20:24:52 +00:00
Eric Anholt 3e65f52bda Use SYSCTL_ADD_OID macro instead of calling function directly.
Submitted by: reffie@FreeBSD.org
2004-12-15 03:34:09 +00:00
Eric Anholt a1d9e5abaf Refine the locking of the DRM. Most significant is covering the driver
ioctls with dev_lock, which is a major step toward being able to remove
    Giant. Covers some new pieces (dev->unique*) in the core, and avoids
    one call down into system internals with the drm lock held, which is
    usually bad (FreeBSD LOR #23, #27).
2004-11-07 04:11:15 +00:00
Eric Anholt 67f6c5e36a Don't link in files which no longer exist. 2004-11-07 00:30:15 +00:00
Eric Anholt fa3fdbd99c Now that the memory debug code is gone, and all 3 BSDs have M_ZERO, stop
using drm_alloc/drm_free in the core and instead use plain malloc/free.
2004-11-07 00:25:49 +00:00
Eric Anholt d37457b599 Add the drm Makefile and update .cvsignores. 2004-11-06 23:05:46 +00:00
Eric Anholt cb5aaa8987 Convert more drivers for bsd-core, moving the ioctl definitions to shared
code. Remove the "drv" from sisdrv, as it's unnecessary. Use the
    drm_pci functions in i915 instead of per-os implementations of the
    same. Avoid whitespace within fields in drm_pciids.txt (one of the r300
    definitions), since it breaks the bsd pciids script. Tested on sis,
    mga, r128. i915 needs more work.
2004-11-06 23:02:07 +00:00
Eric Anholt 7ddbd38dde Remove some core stuff that ended up being unnecessary. 2004-11-06 21:44:54 +00:00
Eric Anholt 7bdccfd0bb Get r128 basically working: Hook up the driver's dma ioctl, use the proper
offset into the driver ioctl array, and don't make the ctx bitmap
    conditional.
2004-11-06 21:18:49 +00:00