Commit Graph

89 Commits

Author SHA1 Message Date
chs fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00
maya b8f12c7fce Check pmf_device_register return value. NFC
Appeases static analyzers.
2017-01-20 12:25:07 +00:00
jmcneill c8d7979553 add dependency on "drm" module 2011-08-28 17:18:31 +00:00
jmcneill 6a0ee33bc0 add VirtualBox DRM driver 2011-02-20 15:40:21 +00:00
mrg f8e80dd3fa remove the old drm sources. 2009-06-21 20:15:47 +00:00
cegger 529e91fca1 struct device * -> device_t, no functional changes intended. 2009-05-12 14:16:35 +00:00
mrg a35a651446 you can now easily select trying external drm with "options DRM_EXTERNAL". 2009-05-06 01:33:24 +00:00
rafal a566e67fbe Rework scatter / gather page allocation inspired by r186295 of FreeBSD SVN:
rework drm_scatter.c which allocates scatter / gather pages for use by
    ati pci gart to use bus_dma to handle the allocations.  This fixes
    a garbled screen issue on at least some radeons (X1400 tested).  It is
    also likely that this is the correct fix for PR# 119324, though that
    is not confirmed yet.

Fixes similar issues on a Radeon Mobility X300, non-Mobility X800 (including
a hard-lock of the machine).

With feedback from ad@, ok mrg@
2009-04-21 01:15:37 +00:00
joerg 95021059eb Move initialisation of the irq spinlock into the device handling code,
at least the Intel driver depends on it whether the IRQ is currently
enabled or not.
2009-04-17 19:02:33 +00:00
mrg ac009d4632 drm_addmap():
- for _DRM_CONSISTENT mappings, keep the handle.
- use DRM_HANDLE_NEEDS_MASK()

drm_mapbufs():
- use DRM_HANDLE_NEEDS_MASK()

drm_mmap():
- use DRM_HANDLE_NEEDS_MASK()
- for _DRM_SCATTER_GATHER and _DRM_SHM, use vtophys() on the
  adjusted offset. XXX


this is gets radeon working on amd64 with an older PCI 9250 card.

XXX: need to excise vtophys() usage.
XXX: need to finish porting these fixes to external.
2009-03-29 19:50:17 +00:00
mrg 44475ef083 include the size in a falled allocation message. 2009-03-29 19:39:10 +00:00
mrg b9bbc2157f add a comment explaining DRM_NETBSD_ADDR2HANDLE/DRM_NETBSD_HANDLE2ADDR:
* This hack strips the top bit from amd64 addresses, which avoid
 * udv_attach() returning NULL for "negative" offset.
 * A better hack would be to encode the offset of some kernel data
 * structure..

add a new DRM_HANDLE_NEEDS_MASK macro to check whether the above need to
be applied for various mapping types (_DRM_SHM and _DRM_SCATTER_GATHER.)
2009-03-29 17:00:50 +00:00
cegger c363a9cb62 bzero -> memset 2009-03-18 16:00:08 +00:00
mrg 9526e87d38 move a DRM_SPINUNLOCK() to where it will actually be executed. 2009-03-07 05:46:09 +00:00
jmcneill b16648eaeb Only pull in genfb.h if _KERNEL_OPT is defined. Reported by Kurt Schreiner 2009-02-15 20:21:24 +00:00
jmcneill 2fa3d3184a Use genfb_borrow; drm works with genfb now. 2009-02-15 18:42:20 +00:00
bouyer 12ae2b8914 Pass a bus_space_tag_t as first argument of bus_space_unmap, not an int. 2009-01-31 13:49:29 +00:00
drochner d767912be3 Change major()/minor() to return 32-bit types again, called
devmajor_t/devminor_t, as proposed on tech-kern.
This avoids 64-bit arithmetics and 64-bit printf formats in parts
of the kernel where it is not really useful, and helps clarity.
2009-01-20 18:20:47 +00:00
mrg 94ed4b4374 Don't attempt to unload a DRM device that's in use. (Note:
Unloading doesn't work right in any case -- it doesn't clean up the
sysctl tree, among other things.  This code needs Work, but at least
this prevents it crashing randomly due to autounload while X is
running.)  Also, fix the dependency list for radeondrm.

contributed anonymously.
2009-01-18 10:04:35 +00:00
bjs 8ff9ca028e Fix handling of lists with a single entry in list_for_each_safe();
this also plugs a memory leak.
2008-10-14 14:55:28 +00:00
mrg 41097c94f6 support new drm.
XXX: not fully enabled yet.  config(1) has a makeoptions bug
with complex conditionals.  see files.drm / files.pcidrm for
some instructions on how to enable it.
2008-07-19 07:26:54 +00:00
mrg fcfa8efe26 remove some more local changes of the form "foo.h" -> <dev/*/foo.h>
by using makeoptions in files.drm/files.pcidrm.  this reduces the
diffs against other drm code by about 40kb.
2008-07-08 06:50:22 +00:00
mrg 8e2cdafb2e revert unnecessary changes to 3rd party code. 2008-07-07 00:31:30 +00:00
drochner f5d73c7fd3 split device/softc 2008-07-03 17:36:44 +00:00
jmcneill 875766b9be Revert previous, i915drm works again. 2008-06-29 12:49:08 +00:00
bjs 48193539c3 Revert to using atop(offset + map->offset) for map types _DRM_AGP,
_DRM_REGISTERS, and _DRM_FRAME_BUFFER.  Fixes issue where a call
to DrmMap() in libdrm returns EINVAL.
2008-06-21 19:31:31 +00:00
cegger 779448ef9d make an i386 ALL kernel build again 2008-06-20 09:15:39 +00:00
bjs 16e84d5575 - Don't use btop, as only three (?) platforms define this macro; use
round_page(x) >> PAGE_SHIFT instead.

- Add bus_space_mmap() in drm_vm.c to give a proper cookie to the device pager;
  this gets rid of one of the two #ifdef macppc conditionals.
2008-06-20 05:53:46 +00:00
bjs 6c1a2fee8f - Use the extent manager to track mappings and provide sane offset
"cookies" for mmap.  Now the radeon driver works on amd64!

- Use bus_dma for nearly all map types (carried over from prior patch).

- Plug some lock leaks in drm_bufs.c and remove superfluous locking in
  drm_add_magic() (from git).

- Lower spl of mutexes to IPL_NONE (and so are now adaptive instead of
  spin mutexes), save for irq_lock which is a spin mutex at IPL_VM.
  Use mutex_spin_enter()/mutex_spin_exit() for irq_lock.

ok jmcneill@
2008-06-20 00:14:28 +00:00
bjs 429b5c8282 DRM_IOCTL_SG_ALLOC needs IOWR, not IOR! 2008-06-13 00:34:48 +00:00
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