Commit Graph

88 Commits (7136f55faaf3afefe522ec978a4cbc906dace861)

Author SHA1 Message Date
Jung-uk Kim 36120264ca Bug #11870: FreeBSD hardware lock cleanup fix with multiple opens by a process.
Previously, the lock would get released on the first close by the X Server
(during AIGLX setup), and the Radeon driver would then hang in initialization
due to unexpected failure in DRM calls that required the lock to be held.

Based on a patch by Kostik Belousov.
2007-10-17 12:52:12 -07:00
Eric Anholt f0fd53f86b FreeBSD: Fill in domain field when supported. 2007-10-10 15:32:05 -07:00
vehemens a9ee144eab BSD: simplify drm_ioctl() after other refactoring. 2007-08-15 11:12:46 -07:00
Eric Anholt 5346fc5f36 BSD: Replace brief description in each file's first line with doxygen later on.
The brief descriptions usually had the wrong filename in them.
2007-08-15 11:06:49 -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 e544286eae FreeBSD: Fix the recently added drawable add/remove/update code. 2007-07-19 06:17:58 -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
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 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 7f2c7f9977 Merge patch from jhb to catch up with FreeBSD-current vgapci master device
changes.
2005-12-30 02:17:05 +00:00
Eric Anholt 20fcbae5ac Finish the last bits necessary to get the i915 DRM port working on FreeBSD
Submitted by: Alexey Popov <llp@iteranet.com>
2005-12-02 23:41:47 +00:00
Eric Anholt 422002dc84 FreeBSD PR kern/85479: Restore the enabling of debugging by default by the
DRM_DEBUG kernel option. It remains controlled by hw.dri.*.debug no
    matter what.
2005-12-02 08:47:04 +00:00
Eric Anholt c7af46cf7d Correct another LOR issue with resource allocation. This leaves the
drm_get_resource_* resource allocation a little racy, but they're
    getting called at either X Server startup or driver load, so it's
    serialized anyway.
2005-11-08 21:36:54 +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 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
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
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 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
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 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 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 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 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 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 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
Eric Anholt ae7a171313 Move the lock/unlock ioctls to a more logical place, in drm_lock.c. 2004-11-06 20:27:19 +00:00
Eric Anholt b2f275b46e Hook the debug output up to a sysctl, so you can choose to enable at
runtime.
2004-11-06 11:50:08 +00:00
Eric Anholt d7510ea413 Commit first pieces of port to OpenBSD, done by Martin Lexa (martin at
martinlexa dot cz). Now that we've got porting for all three major BSDs
    (and the fourth being very similar to FreeBSD), move the
    mostly-duplication drm_os_* files into drmP.h. Remove some cruft from
    linux heritage and from pieces of the DRM that have since been removed.
Note that things are still not quite working for even FreeBSD, but these
    are first steps at cleanup, and just a WIP checkpoint.
2004-11-06 11:16:26 +00:00
Eric Anholt c9202c8965 Commit WIP of BSD conversion to core model. Compiles for r128, radeon, but
doesn't run yet. Moves the ioctl definitions for these two drivers back
    to the shared code -- they aren't OS-specific.
2004-11-06 01:41:47 +00:00
Dave Airlie 5c9ed83094 Merged drmfntbl-0-0-1 2004-08-17 13:10:05 +00:00
Dave Airlie 6c9715eaf5 bring over fix from i865-agp branch, it now probes the driver, X hangs
box..
2004-08-03 11:26:38 +00:00
Eric Anholt 694291fbd3 MFC as of 20040705: dev_t -> struct cdev * change. 2004-07-06 00:23:42 +00:00
Eric Anholt 853adb8be3 Merge from FreeBSD-current. Mostly 64-bit cleanliness fixes, but a few
driver interface changes from -current.
2004-05-11 04:43:43 +00:00
Eric Anholt 51ed2f5937 Warning fixes. 2004-05-09 22:16:11 +00:00
Dave Airlie a2f7a9fa5f Commit sysfs and drm PCI changes for 2.6 kernel 2004-05-09 06:45:17 +00:00
Dave Airlie 93bd67ef62 centralise pci ids into one place and use scripts to generate files for
kernel
2004-04-21 12:13:31 +00:00
Eric Anholt 9fb6986e83 Don't ioremap the framebuffer area. The ioremapped area wasn't used by
anything, and took up valuable KVA. While I'm in the area, clean up BSD
    MTRR stuff some more.
Suggested by: jonsmirl
2003-12-16 08:57:08 +00:00
Eric Anholt 6e56c39371 Fix a locking nit, and add asserts in some things that should be called
with locks held.
2003-11-12 20:30:51 +00:00
Eric Anholt 66c9e3053f - Tie the DRM to a specific device: setunique no longer succeeds when given
a busid that doesn't correspond to the device the DRM is attached to.
    This is a breaking of backwards-compatibility only for the
    multiple-DRI-head case with X Servers that don't use interface 1.1.
- Move irq_busid to drm_irq.h and make it only return the IRQ for the
    current device. Retains compatibility with previous X Servers, cleans
    up unnecessary code. This means no irq_busid on !__HAVE_IRQ, but can be
    changed if necessary.
- Bump interface version to 1.2. This version when set signifies that the
    control ioctl should ignore the irq number passed in and enable the
    interrupt handler for the attached device. Otherwise it errors out when
    the passed-in irq is not equal to the device's.
- Store the highest version the interface has been set to in the device.
- Fix a recursion on DRM_LOCK in irq_uninstall on FreeBSD. This leaves
    irq_uninstall being done without the lock in some cases, but it was
    racey anyways.
2003-11-05 08:13:52 +00:00
Eric Anholt e5cad7fced Remove buf_alloc which is unused since the locking commit. 2003-11-05 00:49:35 +00:00