Commit Graph

140 Commits

Author SHA1 Message Date
Robert Noland
162e0ab8c1 Use flsl() here rather than ffsl()
I discovered that we were computing page_order differently than linux.

MFC after:	3 days
2009-03-17 03:32:12 +00:00
Robert Noland
6443904ee1 Use the right MSI_REARM for RS600.
MFC after:	3 days
2009-03-16 19:09:59 +00:00
Robert Noland
85c5cd4b94 Get rid of any remaining PZERO flags in mtx_sleep()
Also, clean up some ifdef mess while I'm here.

MFC after:	3 days
2009-03-16 08:19:11 +00:00
Robert Noland
96deaed545 Fix R600 writeback across suspend/resume.
This is likely a NOOP for us, since I haven't ported the suspend/resume
code yet.

MFC after:	3 days
2009-03-16 08:15:35 +00:00
Robert Noland
f0eb29f4a6 Consistently use kdev for the kernel device.
Submitted by:	vehemens <vehemens@verizon.net>
MFC after:	3 days
2009-03-09 07:55:18 +00:00
Robert Noland
4d4420bda8 Clean up the printing on amd64. Should also be consistent on i386.
MFC after:	3 days
2009-03-09 07:50:27 +00:00
Robert Noland
d3f8d87d33 There is no need to sync these buffers to swap.
MFC after:	3 days
2009-03-09 07:49:13 +00:00
Robert Noland
254c58f9fd Change the flags to bus_dmamem around to allow it to sleep waiting for
resources during allocation, but not during map load.  Also, zero the
buffers here.

MFC after:	3 days
2009-03-09 07:47:03 +00:00
Robert Noland
00a55e42d6 Fix the flags to bus_dmamem_* to allow the allocation to sleep while
waiting for resources.  It is really the load that we can't defer.
BUS_DMA_NOCACHE belongs on bus_dmamap_load() as well.

MFC after:	3 days
2009-03-09 07:38:22 +00:00
Robert Noland
bf32f93e11 -Make the PCI(E)/AGP calculations consistent
-Calculate the scratch address correctly

MFC after:	10 days
2009-03-09 07:33:35 +00:00
Robert Noland
566be5d4e1 Call the right function for the right chipset.
MFC after:	10 days
2009-03-09 07:24:32 +00:00
Robert Noland
4fcda8938e Import support for ATI Radeon R600 and R700 series chips.
Tested on an HD3850 (RV670) on loan from Warren Block.

Currently, you need one of the following for this to be useful:

	x11-drivers/xf86-video-radeonhd-devel (not tested)
	xf86-video-ati from git (EXA works, xv is too fast)
	xf86-video-radeonhd from git (EXA works, xv works)

There is no 3d support available from dri just yet.

MFC after:	2 weeks
2009-03-07 21:36:57 +00:00
Robert Noland
51e39089c9 Initialize the vblank structures at load time. Previously we did this
at irq install/uninstall time, but when we vt switch, we uninstall the
irq handler.  When the irq handler is reinstalled, the modeset ioctl
happens first.  The modeset ioctl is supposed to tell us that we can
disable vblank interrupts if there are no active consumers.  This will
fail after a vt switch until another modeset ioctl is called via dpms
or xrandr.  Leading to cases where either interrupts are on and can't
be disabled, or worse, no interrupts at all.

MFC after:	2 weeks
2009-02-28 02:37:55 +00:00
Robert Noland
45de2347c4 Add a tuneable to allow disabling msi on drm at runtime.
Suggested by:	jhb@

MFC after:	2 weeks
2009-02-27 23:50:55 +00:00
Robert Noland
2a4f4fc196 Fix up some ioctl permissions issues long overlooked.
Submitted by:	jkim@
MFC after:	2 weeks
2009-02-27 06:01:42 +00:00
Robert Noland
23b90efbcf The GM45 handles vblank differently. Pull the changes from Intel in.
MFC after:	2 Weeks
2009-02-25 20:24:13 +00:00
Robert Noland
cc27cbe330 Remove D_NEEDGIANT.
MFC after:	2 weeks
2009-02-25 18:56:49 +00:00
Robert Noland
bbc33a7d31 Turn on MSI if the card supports it. There is a blacklist for chips
which report that they are capable of MSI, but don't work correctly.

MFC after:	2 weeks
2009-02-25 18:54:35 +00:00
Robert Noland
5493c70e90 Prepare the radeon driver for MSI support.
MFC after:	2 weeks
2009-02-25 18:50:35 +00:00
Robert Noland
82369f9166 Add some vblank related debugging and replace the DRM_WAIT_ON macro
with a localized version.

MFC after:	2 weeks
2009-02-25 18:48:33 +00:00
Robert Noland
dc5c632deb This was part of a sync to the code that Intel is shipping in linux.
- Remove the old TTM interface
	- Move register definitions to i915_reg.h
	- Overhaul the irq handler

MFC after:	2 weeks
2009-02-25 18:44:50 +00:00
Robert Noland
67f435f03e The i915 driver was the only consumer of locked task support.
Now that it doesn't use it anymore, get right of the taskqueue
and locked task support.

MFC after:	2 weeks
2009-02-25 18:25:47 +00:00
Robert Noland
c148ca706e The vblank_swap ioctl was fundamentally race prone. Get rid of it.
MFC after:	2 weeks
2009-02-25 18:22:57 +00:00
Robert Noland
a87b4f7293 There is no reason to hold the lock here.
When I was LOCK_PROFILING this was pretty high up and there is no
reason for it.

MFC after:	2 weeks
2009-02-25 18:19:16 +00:00
Robert Noland
4f02999996 Remove the PZERO priority from mtx_sleep.
MFC after:	2 weeks
2009-02-25 18:16:50 +00:00
Robert Noland
b2dc68697e Only set registers if irqs are enabled
Approved by:	kib
Obtained from:	drm git
2008-12-23 22:53:57 +00:00
Robert Noland
241dd5673c Convert DRM_[DEBUG,ERROR,INFO] macros to c99 __VA_ARGS__.
Approved by:	kib
2008-12-21 22:32:01 +00:00
Robert Noland
73e1b34a9e Garbage collect entries from pcireg.h since we now include it.
Approved by:	kib@
MFC after:	2 weeks
2008-12-18 22:01:46 +00:00
Robert Noland
c9e7b21284 We only want drm to ever attach to the primary pci device.
Intel 855 chips present the same pci id for both heads.  This prevents
us from attaching to the dummy second head.  All other chips that I
am aware of either only present a single pci id, or different ids
for each head so that we only match on the correct head.

Approved by:	kib@
MFC after:	2 weeks
2008-12-18 21:58:57 +00:00
Robert Noland
8b8df0ff61 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.

Reviewed by:	jhb@ (mentor, prior version)
Approved by:	kib@
MFC after:	2 weeks
2008-12-18 21:04:50 +00:00
Robert Noland
f3dcc5387b Fix error in busmaster enable logic
rs400/rs480 should clear the RADEON_BUS_MASTER_DIS bit.  This should get
the rs485 IGP chips going again.

Approved by:	jhb (mentor)
Obtained from:	drm git master
2008-10-27 21:24:34 +00:00
Robert Noland
38cbf617d3 Fix some fallout from the busmaster disable cleanup
rs400 is just like rs480

Approved by:	jhb (mentor)
Obtained from:	drm git
2008-10-27 21:21:36 +00:00
Robert Noland
c85e91464a Don't report GEM capability until we actually have GEM support.
This was causing the newer Intel video drivers to fail and abort X.

Approved by:	jhb (mentor)
2008-10-27 21:16:07 +00:00
Robert Noland
bee8d4f213 drm/i915: fix ioremap of a user address for non-root (CVE-2008-3831)
Olaf Kirch noticed that the i915_set_status_page() function of the i915
kernel driver calls ioremap with an address offset that is supplied by
userspace via ioctl. The function zeroes the mapped memory via memset
and tells the hardware about the address. Turns out that access to that
ioctl is not restricted to root so users could probably exploit that to
do nasty things. We haven't tried to write actual exploit code though.

It only affects the Intel G33 series and newer.

Approved by:	bz (secteam)
Obtained from:	Intel drm repo
Security:	CVE-2008-3831
2008-10-25 16:29:28 +00:00
Robert Noland
cdab8377da Replace calls to minor() with dev2unit(). Ed already fixed this once,
but I inadvertently overwrote the change when I synced to git.  Commit
the fix in both places, so this doesn't happen again.

Approved by:	jhb (mentor)
MFC after:	2 weeks
2008-10-23 20:23:03 +00:00
Robert Noland
fd3c63db72 This check is invalid and I disabled it once already. I accidentally
reintroduced it with the sync to git master.  Commit the fix in both
places this time.

Approved by:	jhb (mentor)
MFC after:	2 weeks
2008-10-23 20:19:56 +00:00
Robert Noland
206267e7bb Correct memory leak of info->rects. Previously we would free info, but
but abandon info->rects.

Approved by:	jhb (mentor)
2008-10-13 18:06:33 +00:00
Robert Noland
f00755f06b Rework memory allocation to allocate memory with different type names. This
will ease the identification of memory leaks as the OS will be able to track
allocations for us by malloc type.  vmstat -m will show all of the
allocations.

Convert the calls to drm_alloc() and friends, which are used in shared code
to static __inline__ while we are here.

Approved by:	jhb (mentor)
2008-10-13 18:03:27 +00:00
Robert Noland
b470dd86f8 The linux list compat code had an error which prevented list_for_each_safe()
from operating on a list with a single item.  This code is used much more by
the i915 driver with xorg-7.4.  Correct it to match the actual linux
implementation.

Approved by:	jhb (mentor)
2008-10-13 17:52:41 +00:00
Robert Noland
41c257c7bf Correct the interrupt handling in the Intel i915 driver.
Approved by:	jhb (mentor)
2008-10-13 17:47:13 +00:00
Robert Noland
af2da6a40e Several of the newer radeon cards have moved around the registers for enabling
busmastering support.  This also adds register definitions for MSI support,
which we will be using shortly.

Approved by:	jhb (mentor)
Obtained from:	drm git master
2008-10-13 17:43:39 +00:00
Robert Noland
b8865a7993 Add support for Radeon rs740 (HD 2100)
Approved by:	jhb (mentor)
Obtained from:	drm git master
2008-10-13 17:38:04 +00:00
Robert Noland
6059e92408 Don't explicitly bzer driver softc
new-bus already handles this for us.

Suggested by jhb@

Approved by:	jhb (mentor)
2008-10-04 14:51:14 +00:00
Robert Noland
e0b8582173 Use M_WAITOK when allocating driver memory
We don't explicity check for error here and M_WAITOK will just put the
process to sleep waiting on resources to become available.

Suggested by jhb@

Approved by:	jhb (mentor)
2008-10-04 14:48:40 +00:00
Robert Noland
4d3ad1c1a6 Change drm_order() to use ffsl()
pointed out by jhb@

Approved by:	jhb (mentor)
2008-10-04 14:45:34 +00:00
Robert Noland
4cd2e9581f resync to git master
This reverts a private patch which is causing issues with many Intel chipsets.
I will review that patch and see what we need to do to fix it up later, but
for the time being, we will just get these chips working again.

This update contains a lot of code cleanup and is post gem merge
(no, we don't have gem support).  It should prove much easier to read the
code now.  A lot of thanks goes to vehemens for that work.  I have adapted
the code to use cdevpriv for tracking per open file data.  That alleviates
the old ugly hack that we used to try and accomplish the task and helped to
clean up the open / close behavior a good bit.  This also replaces the hack
that was put in place a year or so ago to prevent radeons from locking up
with AIGLX enabled.  I have had a couple of radeon testers report that it
still works as expected, though I no longer have radeon hardware to test with
myself.  Other various fixes from the linux crew and Intel, many of
which are muddled in with the gem merge.

Approved by:	jhb (mentor)
Obtained from:	mesa/drm git master
MFC after:	2 weeks
2008-10-03 16:59:11 +00:00
Ed Schouten
6bfa9a2d66 Replace all calls to minor() with dev2unit().
After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by:	kib
2008-09-27 08:51:18 +00:00
Robert Noland
275d30b973 IGP based radeon cards such as the rs485 and rs690 require that the GART table
be un-cached.  Our previous memory barrier was not sufficient.  This patch
allocates the IGP GART tables using the BUS_DMA_NOCACHE flag to get these
cards working.

Approved by:	kib
2008-09-09 02:18:37 +00:00
Robert Noland
0020a2cded We should never call drm_pci_alloc() while holding locks, due the the
calls to bus_dma.  There were multiple paths that held different locks or
no locks at all. This patch ensures that all of the calling paths drop
their lock(s) before calling drm_pci_alloc().

Reviewed by:	kib
2008-09-09 02:05:03 +00:00
Robert Noland
6f81ba0e97 Don't return EINVAL when trying to unlock.
anholt thinks that he added this check as part of some regression testing,
but it is failing at least some of the time.  I don't want to remove it
just yet.  I added a bit of debugging to help identify the issue.

Approved by:	kib
2008-08-30 01:00:18 +00:00