Commit Graph

59 Commits

Author SHA1 Message Date
freza
6e9d339816 o Split device_t/softc for agp(4).
o agp_ali.c: remove unused 'agp' member from agp_ali_softc.
o drm: agp_find_device() returns 'void *', not a device_t.
o Use device_t, cfdata_t instead of struct pointers.
o Don't cast void pointers in assignments.
2008-06-09 06:49:54 +00:00
dyoung
e71b1ed16e Make the atomic macros compile: do not discard 'volatile' qualification
from argument `p'.  Use `b' instead of `bit'.
2008-06-03 20:35:01 +00:00
bjs
def465f1ec Use symbolic names for mem->phase, make error reporting more sensible. 2008-06-01 12:28:09 +00:00
jmcneill
4bb5a59ae8 Don't call devsw_attach/detach if _MODULE is not defined 2008-05-30 11:26:21 +00:00
bjs
c693c2b2dd Add work-in-progress of NetBSD-specific code. I will be committing a lot
more changes shortly (as soon as I work out the mmap offset insanity).
2008-05-28 04:52:48 +00:00
bjs
91174b68e0 Rework drm_atomic.h for correctness and readability:
- Use macros where appropriate.
 - Remove code for other operating systems -- we don't need it.
 - In atomic_read/atomic_set, cast to volatile.
 - Misc. cleanup.
2008-05-28 04:51:20 +00:00
jmcneill
bbfbae40ef Don't use MALLOC_DECLARE / MALLOC_DEFINE if building as a module. 2008-05-19 21:05:37 +00:00
bjs
06031773dc NOTE: this commit message accompnies the last one for sys/dev/pci/drm.
Revert condvar changes; there seem to be other locking issues
(independent of these changes insofar as I can tell), and it will
only complicate things for now to introduce more changes.

Argh!
2008-05-19 00:17:39 +00:00
jmcneill
a8685978bd Allow building as a module. 2008-05-18 19:53:22 +00:00
bjs
c15e1f4356 Oops, did not compile. Fix it. 2008-05-18 03:49:08 +00:00
bjs
52c6ca762a Use cv(9) instead of mtsleep/wakeup. Also, define drm_hz as
mstohz(333) (this seems to eliminate lockups for me using the r300
driver).  Tested with i915 and radeon on amd64.
2008-05-18 02:45:17 +00:00
bjs
da04fccfd8 atomic_add_32 -> atomic_and_32. For atomic_read/atomic_write, cast
to volatile uint32_t *.
2008-05-18 02:42:43 +00:00
bjs
e28a3e014b Revert all the changes this time. 2008-05-06 01:51:00 +00:00
bjs
829081eaa7 Revert last commit -- breaks i915. 2008-05-06 01:45:47 +00:00
bjs
a65a4adb77 A few steps down the yellow brick road toward bus_dma-ification:
- Add drm_dmamem_alloc/drm_dmamem_free to drm_memory.c to nicely wrap up
   the bus_dma API.

 - Start using the above in drm_pci.c.

 - Add DRM_NETBSD_DMA_ADDR/DRM_NETBSD_DMA_VADDR macros.

 Locking:

 - Use IPL_NONE for all locks except the IRQ lock, which runs at IPL_VM.

 - Use IPL_VM instead of IPL_TTY with pci_intr_establish() for consistency's
   sake. These two changes seem to eliminate the presistent lockups I was
   having (NetBSD-current/amd64 r300).

 - Start getting rid of DRM_SPININIT/DRM_SPINUNINIT and DRM_SPINLOCK/
   DRM_SPINUNLOCK ... these annoy me to no end--not to mention that they
   locks may or may not be spinlocks!  It's a linux frob, really.
   We're way beyond merging any useful bsd-core code on a large scale, which
   was the only good reason to keep them around.

 Memory allocation:

  - Change drm_memory.c so that it contains generally useful, memory
    allocation functions using kmem(9) (mostly used by the drivers
    themselves).  However, I expect to use this more in the future
    in the "bsd core".  These functions always use KM_NOSLEEP.
    The new drm_dmamem_alloc function has a wait argument which
    takes DRM_DMA_WAIT/DRM_DMA_NOWAIT (defined as their bus_dma
    counterparts), and honors this hint in its calls to kmem(9)
    and bus_dma(9) functions.

  - Got rid of these functions' "area" argument--it's been deprecated for
    ages.  Provide macros in drmP.h to deal with the os-independent code.

  - Declare these functions inline -- I believe they're used enough
    by the i915 and radeon drivers to justify it.  Please let me know
    if I am mistaken.

    NOTE: With these changes, a glxgears score which was previously
    ~3900fps is now ~4400fps (same setup as mentioned above).  I realize
    that using kmem(9) could cause problems, but I can't seem to run into
    any with my test setup.  If anyone smells regression, please let me
    know.
2008-05-06 01:26:14 +00:00
jmcneill
ad9936b335 Use aprint instead of DRM_INFO macro to cleanup attachment messages. 2008-05-05 14:00:10 +00:00
jmcneill
dc2a8d24fc Ugh, unbreak _DRM_SHM on amd64 again. 2008-05-04 21:43:01 +00:00
jmcneill
63b0503310 Fix compilation on i386. 2008-05-04 20:27:50 +00:00
jmcneill
2b4fd7dc0e For _DRM_SHM allocations, do not use the VA as drm_map handle on x86_64
since udv_attach will not accept a larger offset than signed 64-bit will
provide. Not the best fix, but good enough for now -- at least an X server
will now startup and get proper mappings.
2008-05-04 20:09:32 +00:00
jmcneill
7380b7991e Returning EINVAL from drm_mmap isn't a smart thing to do. 2008-05-04 19:19:40 +00:00
drochner
1120b085ae make device lock adaptive
(needed because pfind() is called from inside)
2008-05-03 14:26:01 +00:00
bjs
98dd3c4324 Wedge in a smattering of updates for ati_pcigart.c and radeon support:
-- detypedef drm_ati_pcigart_info
-- add support for variable sized apertures in ati_pcigart.c
-- Add support for radeon IGP adapters (untested on NetBSD)
-- Update r300_reg.h to a much newer version.
-- Miscellaneous fixes in radeon_cp.c, radeon_state.c.

TODO: r300_cmdbuf.c  (?)

Please report any regressions to me.  While I try to make sure the
updates are somewhat coherent, our initial code base is old enough
such that it's quite difficult to be absolutely certain.  I hope to
rebase the NetBSD-specific code on the BSD code at the head of GIT
within a month or two, so this will do for now.
2008-05-02 01:29:36 +00:00
xtraeme
82947dad7d Adapt to recent NetBSD which has an atomic MI API. With code from
bjs@ and ad@.
2008-04-25 12:15:19 +00:00
xtraeme
49a45b73c5 DRM_SPINLOCK() wants a spin mutex, it may be called from interrupt
context. Switch it to IPL_VM.
2008-04-23 20:21:50 +00:00
bjs
79cf86c8af Change the DRM_SPININIT macro to call mutex_init with MUTEX_DEFAULT
and IPL_NONE.  MUTEX_DRIVER is no longer part of the stable API.  Moreover,
IPL_TTY is now IPL_VM, and this code should not be running with such a
high ipl.
2008-04-15 04:08:58 +00:00
cegger
1b044f414a use aprint_*_dev and device_xname 2008-04-08 07:35:35 +00:00
ad
a9ca7a3734 Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
2008-03-21 21:54:58 +00:00
bjs
c5051ae798 Don't include i810 hack if DRM_NO_AGP is defined, as it results in
an undefined symbol (agp_i810_borrow) at kernel link time.
2008-03-13 05:35:43 +00:00
drochner
1f41b0e499 -map 64-bit PCI BARs
-integrate some bits from upstream to support i965
from Yorick Hardy per PM
2008-03-04 11:52:38 +00:00
bjs
9edaf4a46f Fix bus_dmamem_free() call to provide 'segs' as the second argument.
While here, add DRM_PCI_DMAADDR macro so that we set handle->busaddr
in a portable way.
Next is the more difficult [annoying] part: use bus_dma(9) with
scatter/gather buffers.
2008-03-02 07:12:15 +00:00
drochner
d9ffad8652 Add a horrible hack to allow the DRM driver to get at the bus_space_handle
allocated by the AGP driver in the case of Intel chipset graphics.
This is different from the patch by Yorick Hardy circulated a while ago
in that it doesn't change the semantics of reference counting within
the (3rd-party) DRM code -- it just bypasses it.
Needless to say that it is uglier, but it eases future updates to
the DRM code because the change there is just 2 LOC.

Imo, a cleaner solution for all that would be to attach "agp" to "vga"
in the intel chipset graphics case, which better reflects how the hardware
is structured. This would still need a hack to the DRM code, but
it would be confined to childs of the "vga" device, without need for
global variables.
Since there is a variety of intel chipsets with AGP and/or builtin
graphics options, this would need a considerable testing effort.
2008-02-22 19:47:06 +00:00
ad
93b4e84394 membar_memory -> membar_sync 2007-12-22 15:33:42 +00:00
ad
7162fade9b Use new style memory barriers. 2007-12-21 10:40:12 +00:00
perry
9b2b412c19 __FUNCTION__ -> __func__ 2007-12-15 00:39:14 +00:00
lukem
afb2a5863e use __KERNEL_RCSID() 2007-12-11 11:17:30 +00:00
bjs
2e1c69e6e8 Bring in some modest fixes from GIT that seemed appropriate to me and did not
break functionality.  I've tested this on a PCIE R423 (X800).

- In drm_drv.c, check that the requested context lock matches the holder
of the lock.

- Unify radeon offset checking.  (r300_cmdbuf.c, radeon_drv.h, radeon_state.c)
[Replace r300_check_offset() with generic radeon_check_offset(), which doesn't
reject valid offsets when the framebuffer area is at the very end of the card's
32 bit address space. Make radeon_check_and_fixup_offset() use
radeon_check_offset() as well.
This fixes https://bugs.freedesktop.org/show_bug.cgi?id=7697]

NOTE: There is another AGP fix that I didn't have time to merge
that I thought might help with getting this to work on macppc.
Contact me if you're interested. Hi macallan@! ;)

radeon_cp.c, radeon_drv.h: (GIT id: bb5f2158dbd30dbbffa3881fac75b71d71ecaaf9)
- set the address to access the aperture on the CPU side correctly
[This code relied on the CPU and GPU address for the aperture being the same,
On some r5xx hardware I was playing with I noticed that this isn't always true.
I wonder if this will fix some of those r4xx DRI issues we've seen in the past.]

- Commit the ring after earch partial texture. (radeon_state.c)
(GIT ID: ac8406420ea80ffe5ccaadc1ff0124f95709a23d)
[Commit the ring after each partial texture upload blit.
This makes sure each blit starts as early as possible, which may improve
texture upload performance in some cases.]

If anyone's having any issues in particular--especially those which
can be _teased apart from AGP driver issues--please let me know
and I'll investigate.  Thanks.  There are also tons of fixes for the i915,
but I don't want to change too much at once.
2007-12-07 08:02:48 +00:00
bjs
72127ffc00 drm unbreaking, round 1:
Fix the bus_dma(9) use in drm_pci.c and chnage struct drm_dma_handle_t
to match it.  Remove member dmaaddr from drm_dma_handle_t as well,
as I don't see it used anywhere.  Compile-tested only for now; please
report any problems to me.  Thanks.
2007-12-04 12:51:13 +00:00
bjs
27bbf3c565 Remove #ifdef __OpSys__ sections to make this readable. Add RCS tags.
Nothing done in header files, nor in dev/pci/drm (we might not want to
touch this for the sake of merging) yet.  Compile tested; please let
me know if this broke anything.
2007-11-21 19:22:12 +00:00
bjs
d81bca762e Until I have a chance to further evaluate and re-work the locking here,
change from an adaptive to spin mutex @ IPL_TTY.  This seems to mitigate
or eliminate a lot of locking-related issues (such as a hang when running
glxgears under AIGLX).  Tested by me and Vincent <10.50@free.fr>.

In this code, we have three locks: irq, dma, and device.  If anyone has
any thoughts on how to improve this situation, e.g. by using different
lock types/priorities/soft interrupts/etc. for different locks, please
share them with me.

NOTE: I've had the best results thusfar using Mesa 7.0.2-rc1 (r300 users
could even try the r300 driver code from the master branch) and xorg-server
1.4+patches from GIT.
2007-11-01 13:20:04 +00:00
bjs
acac55ab19 First round of DRM improvements: switch to mutex(9), make use of &
operator consistent in locking macros, use mb(9) for memory barrier ops
(to be replaced with bus_space_barrier(9) at a later date; this is not
necessary for x86 but might be for e.g. mips).


More to come.  Try it out!  It's a lot more stable now just with the
mutex(9) changes.
2007-10-19 20:53:47 +00:00
ad
a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
rmind
084180cb58 drm_do_addbufs_pci: Fix the mess of malloc()s and free()s, which
do not accept NULL arguments.
Found via CID: 4439
2007-04-04 00:30:58 +00:00
jmcneill
4ce279101e In drm_remove_magic, free the magic entry when it is found instead of
attempting to free a NULL reference in the error case. From Yorick Hardy.
2007-03-29 11:31:06 +00:00
jmcneill
11827f045a Introduce options DRM_NO_AGP and DRM_NO_MTRR, so I can run this on
platforms that don't provide these services.

In drm_mmap, don't wrap the return value with atop() if we're on macppc.

While we're here, fix:
	pci_intr_establish(&dev->pa.pa_pc, ...);
to:
	pci_intr_establish(dev->pa.pa_pc, ...);

The former doesn't even compile on macppc, and I'm amazed that it works at
all anywhere else.
2007-03-28 11:29:36 +00:00
dogcow
1aec633c29 caddr_t -> char *, even though it's in #ifdef __FreeBSD__ sections, just
so grep -r won't show it any more.
2007-03-23 20:01:45 +00:00
drochner
f67e2cbf66 Free ressources more agressively.
(The natural place for this would be on each close, but we don't have
a driver entry point for this.)
from Yorick Hardy
2007-03-23 11:06:31 +00:00
xtraeme
3cd917fe6c Use void * rather than caddr_t to fix the build. 2007-03-22 23:35:00 +00:00
jmcneill
7126d77514 Newline after foodrm0 at vga0 message. 2007-03-22 15:14:20 +00:00
jmcneill
4683f1b535 Pass a proper vaddr to uvm_mmap. 2007-03-21 22:24:57 +00:00
jmcneill
ccbe7856ca Initialize extra AGP resource slots. 2007-03-21 22:16:45 +00:00