[go: nahoru, domu]

History log of /drivers/gpu/drm/nouveau/nouveau_bo.c
Revision Date Author Comments
bb6178b04f5ef6f62990306713fb6afdf5d8bc56 09-Jan-2014 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nouveau: export reservation_object from dmabuf to ttm

Adds an extra argument to nouveau_bo_new, which is only used in nouveau_prime.c.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
f4f4e3e3e9f3bde110067b9e4487cb267d90055a 09-Jan-2014 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/ttm: add reservation_object as argument to ttm_bo_init

This allows importing reservation objects from dma-bufs.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
e3be4c230dfadf79567a245505a47a90db97f968 16-Sep-2014 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nouveau: specify if interruptible wait is desired in nouveau_fence_sync

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
809e9447b92ffe1346b2d6ec390e212d5307f61c 09-Apr-2014 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nouveau: use shared fences for readable objects

nouveau keeps track in userspace whether a buffer is being
written to or being read, but it doesn't use that information.

Change this to allow multiple readers on the same bo.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Ben Skeggs <bskeggs@redhat.com>
f2c24b83ae90292d315aa7ac029c6ce7929e01aa 02-Apr-2014 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/ttm: flip the switch, and convert to dma_fence

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
29ba89b2371d466ca68973525816cf10debc2655 09-Jan-2014 Maarten Lankhorst <maarten.lankhorst@ubuntu.com> drm/nouveau: rework to new fence interface

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Ben Skeggs <bskeggs@redhat.com>
dd7cfd641228abb2669d8d047d5ec377b1835900 21-Jan-2014 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/ttm: kill fence_lock

No users are left, kill it off! :D
Conversion to the reservation api is next on the list, after
that the functionality can be restored with rcu.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
bdaf7ddf652ef51fd363b052e320711c06f6f553 21-Jan-2014 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nouveau: require reservations for nouveau_fence_sync and nouveau_bo_fence

This will ensure we always hold the required lock when calling those functions.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: Ben Skeggs <bskeggs@redhat.com>
f1217ed09f827e42a49ffa6a5aab672aa6f57a65 27-Aug-2014 Christian König <christian.koenig@amd.com> drm/ttm: move fpfn and lpfn into each placement v2

This allows us to more fine grained specify where to place the buffer object.

v2: rebased on drm-next, add bochs changes as well

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
5c13cac149b96910291b00bc7953ce984efc4fbc 09-Aug-2014 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: kill unused variable warning if !__OS_HAS_AGP

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
f392ec4b1d92004949e5a4f4418b1fbb2582ef0d 09-Aug-2014 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: use ram info from nvif_device

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
fdb751ef2bbc78314d1e01d3425cfacfb19b9f86 09-Aug-2014 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: remove as much direct use of core headers as possible

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
f45f55c4bbf8a9f9c607e5f6013abac60427e3f7 09-Aug-2014 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: remove (most) hardcoded object handle usage

The PFIFO<->EVO sync buffers will be fixed up later when inter-channel
sync in general is improved.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
0ad72863ea426d46b2786cba9430e122a40aad0b 09-Aug-2014 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: port to nvif client/device/objects

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
967e7bde8739fe3b215f7537e8f1f39c044902af 09-Aug-2014 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: initial pass at moving to struct nvif_device

This is an attempt at isolating some of the changes necessary to port
to NVIF in a separate commit.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
db2bec187dd68e79d512112df1f6e7a849e7f0ce 09-Aug-2014 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: kill nouveau_dev() + wrap register macros

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
fa2bade99a6fb24c3847d48ba3cad9a70dbb5364 09-Aug-2014 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: fix some usages of the wrong print function

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
3ee6f5b5036be4fd4e64be4233f29ee1c552c005 09-Aug-2014 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: store a pointer to vm in nouveau_cli

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
fd1496a0fc77f955317d6ca511f66a9e788e7e02 31-Jul-2014 Alexandre Courbot <acourbot@nvidia.com> drm/nouveau: map pages using DMA API

The DMA API is the recommended way to map pages no matter what the
underlying bus is. Use the DMA functions for page mapping and remove
currently existing wrappers.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
e2a4e78cdccc4bb2d3729981313da237ad4ad43f 27-Jun-2014 Alexandre Courbot <acourbot@nvidia.com> drm/nouveau/bar: add noncached ioremap property

Some BARs (like GK20A's) do not support being ioremapped write-combined.
Add a boolean property to the BAR structure and handle that case in the
Nouveau BO implementation.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
ee3939e07920f4a5405aba5f40529fd0fdd1dfb5 21-Jul-2014 Thierry Reding <treding@nvidia.com> drm/ttm: Fix a few sparse warnings

The final parameter to ttm_bo_reserve() is a pointer, therefore callers
should use NULL instead of 0.

Fixes a bunch of sparse warnings of this type:

warning: Using plain integer as NULL pointer

Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
420b94697722512a2c0732970dc1530197a49adb 17-Feb-2014 Alexandre Courbot <acourbot@nvidia.com> support for platform devices

Upcoming mobile Kepler GPUs (such as GK20A) use the platform bus instead
of PCI to which Nouveau is tightly dependent. This patch allows Nouveau
to handle platform devices by:

- abstracting PCI-dependent functions that were typically used for
resource querying and page mapping,
- introducing a nv_device_is_pci() function that allows to make
PCI-dependent code conditional,
- providing a nouveau_drm_platform_probe() function that takes a GPU
platform device to be probed.

Core code as well as engine/subdev drivers are updated wherever possible
to make use of these functions. Some older drivers are too dependent on
PCI to be properly updated, but all newer code on which future chips may
depend should at least be runnable with platform devices.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
34d595081812da62b5357579267c4ab5eae64ac1 16-Feb-2014 Ilia Mirkin <imirkin@alum.mit.edu> drm/nouveau: fix TTM_PL_TT memtype on pre-nv50

Commit a55409066 ("drm/nv50-: map TTM_PL_SYSTEM through a BAR for CPU
access") made it possible to work with tiled memory. However
mem->mm_node is not a nouveau_mem for AGP-using pre-NV50 cards, but a
drm_mm_node, as created by the ttm_bo_manager_func. As such, extend the
untiled check to explicitly include all pre-nv50 cards.

Reported-by: Ronald <ronald645@gmail.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74613
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Tested-by: Ronald Uitermark <ronald645@gmail.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
cef9e99e1e7514ec228ee8a4d667ec3c88007830 22-Nov-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/ttm: explicitly wait for bo idle before memcpy buffer move

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
35b8141b829a7bf66b901432f435a5528fa4c2e3 22-Nov-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/ttm: explicity sync with kernel channel before moving buffer

The GEM code handles this currently, but that'll be removed.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
3c57d85d7d8f2d87c6700327d1db69b73fc66533 22-Nov-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/ttm: tidy up creation of temporary buffer move vmas

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
a554090664728384c94b027ba15bc7df87f9ac09 12-Nov-2013 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nv50-: map TTM_PL_SYSTEM through a BAR for CPU access

Moves bo's to TTM_PL_TT for BAR mapping, to hide tiling from user.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
ce8f7699f2b6ffe4aa8368b8d9d370875accaa5f 12-Nov-2013 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nouveau: fix m2mf copy to tiled gart

Commit de7b7d59d54852c introduced tiled GART, but a linear copy is
still performed. This may result in errors on eviction, fix it by
checking tiling from memtype.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: stable@vger.kernel.org #3.10+
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2e2cfbe61b8e2cb1339e456ba764c0bd7c913a6e 15-Nov-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/vm: reduce number of entry-points to vm_map()

Pretty much everywhere had to make the decision which to use, so it
makes a lot more sense to just have one entrypoint decide the path
to take instead.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
d2c7ab32ceb0737c1aba84765c555e0f73d3c935 12-Nov-2013 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nouveau: do not map evicted vram buffers in nouveau_bo_vma_add

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
5d216f6013d54a6085d5e499407aec6d67e79990 13-Nov-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: allow nouveau_fence_ref() to be a noop

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
4a0ff75418851116d034fa4d91bef114f01a329d 05-Sep-2013 Ilia Mirkin <imirkin@alum.mit.edu> drm/nv10: introduce a new NV_11 card type

NV11/17/1F/18 come after NV10/15/16/1A. In order to facilitate using
numerical comparisons, split up the two sets into different card types.

This change should be a no-op except that the relevant cards will see
NV11 printed instead of NV10 for the family.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1934a2add96bdd9922c6752b07244cbd11d6a7d7 17-Sep-2013 Dave Jones <davej@redhat.com> drm/nouveau: remove pointless assignment

self-assignment of a variable doesn't make a lot of sense.

Signed-off-by: Dave Jones <davej@fedoraproject.org>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
55fb74adc628b99424360b0123f47ea4484c56fd 02-Oct-2013 David Herrmann <dh.herrmann@gmail.com> drm/nouveau: embed gem object in nouveau_bo

There is no reason to keep the gem object separately allocated. nouveau is
the last user of gem_obj->driver_private, so if we embed it, we can get
rid of 8bytes per gem-object.

The implementation follows the radeon driver. bo->gem is only valid, iff
the bo was created via the gem helpers _and_ iff the user holds a valid
gem reference. That is, as the gem object holds a reference to the
nouveau_bo. If you use nouveau_ref() to gain a bo reference, you are not
guaranteed to also hold a gem reference. The gem object might get
destroyed after the last user drops the gem-ref via
drm_gem_object_unreference(). Use drm_gem_object_reference() to gain a
gem-reference.

For debugging, we can use bo->gem.filp != NULL to test whether a gem-bo is
valid. However, this shouldn't be used for real functionality to avoid
gem-internal dependencies.

Note that the implementation follows the previous style. However, we no
longer can check for bo->gem != NULL to test for a valid gem object. This
wasn't done before, so we should be safe now.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
acb4652703f0a452405a3ab9319594eddc41391b 25-Aug-2013 David Herrmann <dh.herrmann@gmail.com> drm: verify vma access in TTM+GEM drivers

GEM does already a good job in tracking access to gem buffers via handles
and drm_vma access management. However, TTM drivers currently do not
verify this during mmap().

TTM provides the verify_access() callback to test this. So fix all drivers
to actually call into gem+vma to verify access instead of always returning
0.

All drivers assume that user-space can only get access to TTM buffers via
GEM handles. So whenever the verify_access() callback is called from
ttm_bo_mmap(), the buffer must have a valid embedded gem object. This is
true for all TTM+GEM drivers. But that's why this patch doesn't touch pure
TTM drivers (ie, vmwgfx).

v2: Switch to drm_vma_node_verify_access() to correctly return -EACCES if
access was denied.

Cc: Dave Airlie <airlied@redhat.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
35095f7529bb6abdfc956e7a41ca6957520b70a7 27-Jul-2013 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nouveau: fix size check for cards without vm

Op 24-07-13 17:55, Dan Carpenter schreef:
> Hello Maarten Lankhorst,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 0108bc808107: "drm/nouveau: do not allow negative sizes for
> now" from Jul 7, 2013, leads to the following Smatch complaint:
>
> drivers/gpu/drm/nouveau/nouveau_bo.c:222 nouveau_bo_new()
> warn: variable dereferenced before check 'drm->client.base.vm' (see line 201)
>
> drivers/gpu/drm/nouveau/nouveau_bo.c
> 200 int type = ttm_bo_type_device;
> 201 int max_size = INT_MAX & ~((1 << drm->client.base.vm->vmm->lpg_shift) - 1);
> ^^^^^^^^^^^^^^^^^^^
> New dereference.
>
> 202
> 203 if (size <= 0 || size > max_size) {
> 204 nv_warn(drm, "skipped size %x\n", (u32)size);
> 205 return -EINVAL;
> 206 }
> 207
> 208 if (sg)
> 209 type = ttm_bo_type_sg;
> 210
> 211 nvbo = kzalloc(sizeof(struct nouveau_bo), GFP_KERNEL);
> 212 if (!nvbo)
> 213 return -ENOMEM;
> 214 INIT_LIST_HEAD(&nvbo->head);
> 215 INIT_LIST_HEAD(&nvbo->entry);
> 216 INIT_LIST_HEAD(&nvbo->vma_list);
> 217 nvbo->tile_mode = tile_mode;
> 218 nvbo->tile_flags = tile_flags;
> 219 nvbo->bo.bdev = &drm->ttm.bdev;
> 220
> 221 nvbo->page_shift = 12;
> 222 if (drm->client.base.vm) {
> ^^^^^^^^^^^^^^^^^^^
> Old check.
>
> 223 if (!(flags & TTM_PL_FLAG_TT) && size > 256 * 1024)
> 224 nvbo->page_shift = drm->client.base.vm->vmm->lpg_shift;
>
> regards,
> dan carpenter

8<-----
Commit 0108bc808107: "drm/nouveau: do not allow negative sizes for now" broke
older nvidia gpu's that lack a vm. Add an explicit check to handle this.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: konrad wilk <konrad.wilk@oracle.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
0108bc808107b97e101b15af9705729626be6447 07-Jul-2013 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nouveau: do not allow negative sizes for now

The API allows up to 64-bits allocations, but size is handled as int
inside nouveau almost everywhere. Until this is fixed it's better to
prevent negative sizes.

The 256 kB before INT_MAX is paranoia, because of the large page
aligning below that could flip it above INT_MAX.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
00fc6f6f731efb7b76b839598e494b01890d901d 09-Jul-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: use dedicated channel for async moves on GT/GF chipsets.

The moves themselves were generally async to graphics previously, with
the exception that if the "main" channel is used to synchronise a
page flip at the same time, it can end up blocked for a noticable amount
of time for large buffer moves.

Not really critical, and there's better ways of handling this, but they
are all rather invasive, so this is fine for now.

Based on a patch by Maarten Lankhorst addressing the same issue.

Reported-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
4f3855997c5d2bf6443853800eb1a03f61ad9140 07-Jul-2013 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/nouveau: do not unpin in nouveau_gem_object_del

This should no longer be required, and is harmful for framebuffer pinning.
Also add a warning if unpin causes the pin count to drop below 0.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
060810d7abaabcab282e062c595871d661561400 08-Jul-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: fix locking issues in page flipping paths

b580c9e2b7ba5030a795aa2fb73b796523d65a78 introduced additional problems
while trying to solve issues that became apparent while porting to the
new reservation stuff.

The major problem was that the the previously mentioned patch took the
client mutex earlier than previously, but the pinning of new_bo can
can potentially cause a buffer move, which would result in attempting to
acquire the same mutex again.

This commit attempts to fix that "fix".

Thanks to Maarten for the tips on keeping lockdep happy and cooking :)

Reported-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
1bb3f6a252c92cbc07884091e185a51b4ccb4f1d 08-Jul-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: fix minor thinko causing bo moves to not be async on kepler

Reported-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
c4c7044ffc1ba973e2ec0f0dc94980b49101d877 07-May-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: delay busy bo vma removal until fence signals

As opposed to an explicit wait. Allows userspace to not stall waiting
on buffer deletion.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
dceef5d87cc01358cc1434416f3272e2ddc3d97a 04-Mar-2013 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/fb: initialise vram controller as pfb sub-object

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
c1b90df22595441d3a0ae86bd7c3bcc32787950a 03-Mar-2013 Marcin Slusarz <marcin.slusarz@gmail.com> drm/nv50: use correct tiling methods for m2mf buffer moves

Currently used only on original nv50, nvaa and nvac.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
264ce192b3e7f45d0adb37bfbab2b01a3fbe6c30 14-Feb-2013 Ben Skeggs <bskeggs@redhat.com> drm/nv84-/fence: prepare for emit/sync support of sysram sequences

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
3e2b756ba330343c960c332695608b9c5881a173 01-Feb-2013 Chris Metcalf <cmetcalf@tilera.com> drm: fix compile failure by including <linux/swiotlb.h>

On tile architecture (with "make allyesconfig") including
<linux/swiotlb.h> is required to call swiotlb_nr_tbl().

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
4cfe7629be069d6e951694fecf76f9221badc638 01-Feb-2013 Chris Metcalf <cmetcalf@tilera.com> drm: fix compile failure by including <linux/swiotlb.h>

On tile architecture (with "make allyesconfig") including
<linux/swiotlb.h> is required to call swiotlb_nr_tbl().

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Acked-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
0ae6d7bc0e70dafc1739d50b2b8d9d7c61968395 11-Dec-2012 Daniel Vetter <daniel.vetter@ffwll.ch> drm/nouveau: try to protect nbo->pin_refcount

... by moving the bo_pin/bo_unpin manipulation of the pin_refcount
under the protection of the ttm reservation lock. pin/unpin seems
to get called from all over the place, so atm this is completely racy.

After this patch there are only a few places in cleanup functions
left which access ->pin_refcount without locking. But I'm hoping that
those are safe and some other code invariant guarantees that this
won't blow up.

In any case, I only need to fix up pin/unpin to make ->pageflip work
safely, so let's keep it at that.

Add a comment to the header to explain the new locking rule.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
eda85d6ad490923152544fba0473798b6cc0edf6 31-Dec-2012 Aaro Koskinen <aaro.koskinen@iki.fi> drm/nouveau: fix init with agpgart-uninorth

Check that the AGP aperture can be mapped. This follows a similar change
done for Radeon (commit 365048ff, drm/radeon: AGP memory is only I/O if
the aperture can be mapped by the CPU.).

The patch fixes the following error seen on G5 iMac:

nouveau E[ DRM] failed to create kernel channel, -12

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58806
Cc: stable@vger.kernel.org
Reviewed-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Dave Airlie <airlied@redhat.com>
97a875cbdf89a4638eea57c2b456c7cc4e3e8b21 28-Nov-2012 Maarten Lankhorst <m.b.lankhorst@gmail.com> drm/ttm: remove no_wait_reserve, v3

All items on the lru list are always reservable, so this is a stupid
thing to keep. Not only that, it is used in a way which would
guarantee deadlocks if it were ever to be set to block on reserve.

This is a lot of churn, but mostly because of the removal of the
argument which can be nested arbitrarily deeply in many places.

No change of code in this patch except removal of the no_wait_reserve
argument, the previous patch removed the use of no_wait_reserve.

v2:
- Warn if -EBUSY is returned on reservation, all objects on the list
should be reservable. Adjusted patch slightly due to conflicts.
v3:
- Focus on no_wait_reserve removal only.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
dedfdffd448aea2543b59fd504b92b8212ab3b7d 12-Oct-2012 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/ttm: remove sync_arg from driver functions

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-By: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
b03640b1de2eb349c2453d060d0bd0b0486e29b8 12-Oct-2012 Maarten Lankhorst <maarten.lankhorst@canonical.com> drm/ttm: remove sync_obj_arg from ttm_bo_move_accel_cleanup

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-By: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
0b91c4a1cd7cc368763de2fe25b8ea64ea803c08 06-Nov-2012 Marcin Slusarz <marcin.slusarz@gmail.com> drm/ttm: remove ttm_buffer_object->buffer_start

All drivers set it to 0 and nothing uses it.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
df1b4b91e5dae04782f65f657d771b23ca3bdc99 13-Oct-2012 Max Filippov <jcmvbkbc@gmail.com> drm/nouveau: only call ttm_agp_tt_create when __OS_HAS_AGP

ttm_agp_tt_create is itself defined under CONFIG_AGP, so there's no
point calling it otherwise.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
49981046e3dc2f934663548a270d4bf1a4534bb9 06-Aug-2012 Ben Skeggs <bskeggs@redhat.com> drm/nve0: use async copy engine for ttm buffer moves if available

Kepler PFIFO lost the ability to address multiple engines from a single
channel, so we need a separate one for the copy engine.

v2: Marcin Slusarz <marcin.slusarz@gmail.com>
- regression fix: restore hw accelerated buffer copies

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
77145f1cbdf8d28b46ff8070ca749bad821e0774 31-Jul-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: port remainder of drm code, and rip out compat layer

v2: Ben Skeggs <bskeggs@redhat.com>
- fill in nouveau_pm.dev to prevent oops
- fix ppc issues (build + OF shadow)

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
ebb945a94bba2ce8dff7b0942ff2b3f2a52a0a69 20-Jul-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: port all engines to new engine module format

This is a HUGE commit, but it's not nearly as bad as it looks - any problems
can be isolated to a particular chipset and engine combination. It was
simply too difficult to port each one at a time, the compat layers are
*already* ridiculous.

Most of the changes here are simply to the glue, the process for each of the
engine modules was to start with a standard skeleton and copy+paste the old
code into the appropriate places, fixing up variable names etc as needed.

v2: Marcin Slusarz <marcin.slusarz@gmail.com>
- fix find/replace bug in license header

v3: Ben Skeggs <bskeggs@redhat.com>
- bump indirect pushbuf size to 8KiB, 4KiB barely enough for userspace and
left no space for kernel's requirements during GEM pushbuf submission.
- fix duplicate assignments noticed by clang

v4: Marcin Slusarz <marcin.slusarz@gmail.com>
- add sparse annotations to nv04_fifo_pause/nv04_fifo_start
- use ioread32_native/iowrite32_native for fifo control registers

v5: Ben Skeggs <bskeggs@redhat.com>
- rebase on v3.6-rc4, modified to keep copy engine fix intact
- nv10/fence: unmap fence bo before destroying
- fixed fermi regression when using nvidia gr fuc
- fixed typo in supported dma_mask checking

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
bc9e7b9a61e9e92ddb58920cb2cb5c2e2825ca8a 19-Jul-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: move some more code around to more appropriate places

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
3863c9bc887e9638a9d905d55f6038641ece78d6 14-Jul-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/instmem: completely new implementation, as a subdev module

v2 (Ben Skeggs):
- some fixes for 64KiB PAGE_SIZE
- fix porting issues in (currently unused) nv41/nv44 pciegart code

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
861d21074bbb141b0cc165a61c11f571571cda12 11-Jul-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/fb: merge fb/vram and port to subdev interfaces

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
9458029940ffc64bca0c5a30ea626c377205842e 05-Jul-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: implement module init functions in nouveau_drm.c

These currently just call the existing ones in nouveau_drv.c, but will be
extended in upcoming commits. This needed to be separated from the current
code as there will be some header clashes until things are ported.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
02a841d434513c7b3620250271c372fabce56de5 04-Jul-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: restructure source tree, split core from drm implementation

Future work will be headed in the way of separating the policy supplied by
the nouveau drm module from the mechanisms provided by the driver core.

There will be a couple of major classes (subdev, engine) of driver modules
that have clearly defined tasks, and the further directory structure change
is to reflect this.

No code changes here whatsoever, aside from fixing up a couple of include
file pathnames.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
760285e7e7ab282c25b5e90816f7c47000557f4f 02-Oct-2012 David Howells <dhowells@redhat.com> UAPI: (Scripted) Convert #include "..." to #include <path/...> in drivers/gpu/

Convert #include "..." to #include <path/...> in drivers/gpu/.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Dave Jones <davej@redhat.com>
1a46098e910b96337f0fe3838223db43b923bad4 04-May-2012 Ben Skeggs <bskeggs@redhat.com> drm/nvc0/ttm: use copy engines for async buffer moves

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
fdf53241c1845a4a1d8bd2df65f574b281649957 04-May-2012 Ben Skeggs <bskeggs@redhat.com> drm/nva3/ttm: use copy engine for async buffer moves

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
5490e5dfb9e9d654b0ed06c2989a73402496adf6 04-May-2012 Ben Skeggs <bskeggs@redhat.com> drm/nv98/ttm: add in a (disabled) crypto engine buffer copy method

Disabled for the moment until some performance issues are sorted out, code
committed as a reference point.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
4c193d254ee94da02857b9670e815b1765a9579b 04-May-2012 Ben Skeggs <bskeggs@redhat.com> drm/nv84/ttm: use crypto engine for async buffer copies

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
d1b167e168bdac0b6af11e7a8c601773639fc419 04-May-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/ttm: untangle code to support accelerated buffer moves

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
d375e7d56dffa564a6c337d2ed3217fb94826100 30-Apr-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/fence: minor api changes for an upcoming rework

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
875ac34aad49bb875833aed2b4f2deb7a28df9f0 29-Apr-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/fence: make ttm interfaces wrap ours, not the other way around

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6d597027755b2eed4298b85ebe3cb5c93b29d1a9 01-Apr-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: use the same packet header macros as userspace

Cosmetic cleanup only.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
c6b7e89582bdb028e1b1763197ff24c77a43e1b0 20-Mar-2012 Ben Skeggs <bskeggs@redhat.com> drm/nve0/ttm: implement buffer moves with weirdo pcopy-on-pgraph methods

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
22b33e8ed0e38b8ddcf082e35580f2e67a3a0262 02-Apr-2012 Dave Airlie <airlied@redhat.com> nouveau: add PRIME support

This adds prime->fd and fd->prime support to nouveau,
it passes the SG object to TTM, and then populates the
GART entries using it.

v2: add stubbed kmap + use new function to fill out pages array
for faulting + add reimport test.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
129b78bfca591e736e56a294f0e357d73d938f7e 02-Apr-2012 Dave Airlie <airlied@redhat.com> ttm: add prime sharing support to TTM (v2)

This adds the ability for ttm common code to take an SG table
and use it as the backing for a slave TTM object.

The drivers can then populate their GTT tables using the SG object.

v2: make sure to setup VM for sg bos as well.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
c284815debba2f14ee2fd07b1b4cc972ab116110 18-May-2012 Dave Airlie <airlied@redhat.com> nouveau: nouveau_set_bo_placement takes TTM flags

This seems to be wrong to me, spotted while thinking about dma-buf.

Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
accf94969f226ddfe7dd3a6a76ce093ace839b26 15-Mar-2012 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/ttm: always do buffer moves on kernel channel

There was once good reasons for wanting the drm to be able to use M2MF etc
on user channels, but they're not relevant anymore. For the general
buffer move case, we've already lost by transferring between vram/sysmem
already so the context switching overhead is minimal in comparison.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
9f1feed2e16652a6e599ed4a73b4c501bb3d4568 25-Jan-2012 Ben Skeggs <bskeggs@redhat.com> drm/ttm: fix two regressions since move_notify changes

Both changes in dc97b3409a790d2a21aac6e5cdb99558b5944119 cause serious
regressions in the nouveau driver.

move_notify() was originally able to presume that bo->mem is the old node,
and new_mem is the new node. The above commit moves the call to
move_notify() to after move() has been done, which means that now, sometimes,
new_mem isn't the new node at all, bo->mem is, and new_mem points at a
stale, possibly-just-been-killed-by-move node.

This is clearly not a good situation. This patch reverts this change, and
replaces it with a cleanup in the move() failure path instead.

The second issue is that the call to move_notify() from cleanup_memtype_use()
causes the TTM ghost objects to get passed into the driver. This is clearly
bad as the driver knows nothing about these "fake" TTM BOs, and ends up
accessing uninitialised memory.

I worked around this in nouveau's move_notify() hook by ensuring the BO
destructor was nouveau's. I don't particularly like this solution, and
would rather TTM never pass the driver these objects. However, I don't
clearly understand the reason why we're calling move_notify() here anyway
and am happy to work around the problem in nouveau instead of breaking the
behaviour expected by other drivers.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Jerome Glisse <j.glisse@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
dea7e0ac45fd28f90bbc38ff226d36a9f788efbf 03-Jan-2012 Jerome Glisse <jglisse@redhat.com> ttm: fix agp since ttm tt rework

ttm tt rework modified the way we allocate and populate the
ttm_tt structure, the AGP side was missing some bit to properly
work. Fix those and fix radeon and nouveau AGP support.

Tested on radeon only so far.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
f7b24c42da1a7bbb98145d27aa716d8af3cae2a6 22-Dec-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau/ttm: fix crash as a result of a recent ttm change

"drm/ttm: callback move_notify any time bo placement change v4" failed to
avoid a NULL pointer dereference in nouveau caused by move_notify being
expected to handle that case now.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
dc97b3409a790d2a21aac6e5cdb99558b5944119 18-Nov-2011 Jerome Glisse <jglisse@redhat.com> drm/ttm: callback move_notify any time bo placement change v4

Previously we were calling back move_notify in error path when the
bo is returned to it's original position or when destroy the bo.
When destroying the bo set the new mem placement as NULL when calling
back in the driver.

Updating nouveau to deal with NULL placement properly.

v2: reserve the object before calling move_notify in bo destroy path
at that point ttm should be the only piece of code interacting
with the object so atomic_set is safe here.
v3: callback move notify only once the bo is in its new position
call move notify want swaping out the buffer
v4:- don't call move_notify when swapin out bo, assume driver should
do what is appropriate in swap notify
- move move_notify call back to ttm_bo_cleanup_memtype_use for
destroy path

Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
57de4ba959b290f0b8cf36ecd5e7f1b29d4b8a12 11-Nov-2011 Jerome Glisse <jglisse@redhat.com> drm/ttm: simplify memory accounting for ttm user v2

Provide helper function to compute the kernel memory size needed
for each buffer object. Move all the accounting inside ttm, simplifying
driver and avoiding code duplication accross them.

v2 fix accounting of ghost object, one would have thought that i
would have run into the issue since a longtime but it seems
ghost object are rare when you have plenty of vram ;)

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
8e7e70522d760c4ccd4cd370ebfa0ba69e006c6e 09-Nov-2011 Jerome Glisse <jglisse@redhat.com> drm/ttm: isolate dma data from ttm_tt V4

Move dma data to a superset ttm_dma_tt structure which herit
from ttm_tt. This allow driver that don't use dma functionalities
to not have to waste memory for it.

V2 Rebase on top of no memory account changes (where/when is my
delorean when i need it ?)
V3 Make sure page list is initialized empty
V4 typo/syntax fixes

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
3230cfc34fca9d17c1628cf0e4ac25199592a69a 17-Oct-2011 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> drm/nouveau: enable the ttm dma pool when swiotlb is active V3

If the card is capable of more than 32-bit, then use the default
TTM page pool code which allocates from anywhere in the memory.

Note: If the 'ttm.no_dma' parameter is set, the override is ignored
and the default TTM pool is used.

V2 use pci_set_consistent_dma_mask
V3 Rebase on top of no memory account changes (where/when is my
delorean when i need it ?)

CC: Ben Skeggs <bskeggs@redhat.com>
CC: Francisco Jerez <currojerez@riseup.net>
CC: Dave Airlie <airlied@redhat.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
b1e5f172325547270f35e7d1e42416a606e1dbd2 03-Nov-2011 Jerome Glisse <jglisse@redhat.com> drm/ttm: introduce callback for ttm_tt populate & unpopulate V4

Move the page allocation and freeing to driver callback and
provide ttm code helper function for those.

Most intrusive change, is the fact that we now only fully
populate an object this simplify some of code designed around
the page fault design.

V2 Rebase on top of memory accounting overhaul
V3 New rebase on top of more memory accouting changes
V4 Rebase on top of no memory account changes (where/when is my
delorean when i need it ?)

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
649bf3ca77343e3be1e0af8e21356fa569b1abd9 02-Nov-2011 Jerome Glisse <jglisse@redhat.com> drm/ttm: merge ttm_backend and ttm_tt V5

ttm_backend will only exist with a ttm_tt, and ttm_tt
will only be of interest when bound to a backend. Merge them
to avoid code and data duplication.

V2 Rebase on top of memory accounting overhaul
V3 Rebase on top of more memory accounting changes
V4 Rebase on top of no memory account changes (where/when is my
delorean when i need it ?)
V5 make sure ttm is unbound before destroying, change commit
message on suggestion from Tormod Volden

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
4beb116a454867cc3a98d02d906e0f0459aefe72 06-Nov-2011 Francisco Jerez <currojerez@riseup.net> drm/nv10: Change the BO size threshold determining the memory placement range.

Fixes the framebuffer memory allocation failure seen on some
low-memory cards, followed by X refusing to start.

https://bugs.freedesktop.org/show_bug.cgi?id=42384

Reported-by: Chris Paulson-Ellis <chris@edesix.com>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1717c0e23f411147490c7a3312b894f0ea9a5fb1 27-Oct-2011 Dave Airlie <airlied@redhat.com> Revert "drm/ttm: add a way to bo_wait for either the last read or last write"

This reverts commit dfadbbdb57b3f2bb33e14f129a43047c6f0caefa.

Further upstream discussion between Marek and Thomas decided this wasn't
fully baked and needed further work, so revert it before it hits mainline.

Signed-off-by: Dave Airlie <airlied@redhat.com>
2e9733ff7d4f1c7185bea16041f532d6142ca40a 02-Jul-2011 Ben Skeggs <bskeggs@redhat.com> drm/nvd0: add a card_type for 0xdX chipsets

These are different enough from 0xcX to justify it, half fermi, half
kepler(??)..

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
dfadbbdb57b3f2bb33e14f129a43047c6f0caefa 13-Aug-2011 Marek Olšák <maraeo@gmail.com> drm/ttm: add a way to bo_wait for either the last read or last write

Sometimes we want to know whether a buffer is busy and wait for it (bo_wait).
However, sometimes it would be more useful to be able to query whether
a buffer is busy and being either read or written, and wait until it's stopped
being either read or written. The point of this is to be able to avoid
unnecessary waiting, e.g. if a GPU has written something to a buffer and is now
reading that buffer, and a CPU wants to map that buffer for read, it needs to
only wait for the last write. If there were no write, there wouldn't be any
waiting needed.

This, or course, requires user space drivers to send read/write flags
with each relocation (like we have read/write domains in radeon, so we can
actually use those for something useful now).

Now how this patch works:

The read/write flags should passed to ttm_validate_buffer. TTM maintains
separate sync objects of the last read and write for each buffer, in addition
to the sync object of the last use of a buffer. ttm_bo_wait then operates
with one the sync objects.

Signed-off-by: Marek Olšák <maraeo@gmail.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2fd3db6f1457050bdebf97e45147ce6827e1742a 07-Jun-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: remove implicit mapping of every bo into chan_vm

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
7375c95b343aa575940704a38482a334ea87ac6c 07-Jun-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: remove 'chan' argument from nouveau_bo_new

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
fd2871af3d2dad4e07df84941128b0813b5dd34b 06-Jun-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: initial changes to support multiple VMAs per buffer object

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
180cc30637b47dafa26e3202a41964b5ebdab365 07-Jun-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: convert bo.mem.start usage to bo.offset

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
07533ea549e725360209f958bb916085f18ff5b9 07-Jun-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: convert some bo.offset use to vma.offset

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
d2f96666c56a501c5b74c645d81918b7805d46ce 06-Jun-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: create temp vmas for both src and dst of bo moves

Greatly simplifies a number of things, particularly once per-client GPU
address spaces are involved.

May add this back later once I know what things'll look like.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
f91bac5bf694e8060b7473fb0aefb8de09aa9595 06-Jun-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: store bo's page size in nouveau_bo

Was previously assuming a page size of 4KiB unless a VMA was present to
override it. Eventually, a buffer won't necessarily have a VMA at all at
some stages of its life, so we need to store this info elsewhere.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
111af5c100fa0c0b94301f719dd22dab87f5d0a4 03-Jun-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: skip move_notify() if bo does not have a vma attached

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
d359d51cba731a72fede6c09b1d567de02f081dc 03-Jun-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: no need to update bo.offset from vma after validate

On chipsets using nouveau_vm, the virtual address stays constant, so
the value set at bo creation time is fine.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
7db26623257a16c901a4b77bfc5096ee05304932 28-Feb-2011 Ben Skeggs <bskeggs@redhat.com> drm/nv50-nvc0: make sure vma is definitely unmapped when destroying bo

Somehow fixes a misrendering + hang at GDM startup on my NVA8...

My first guess would have been stale TLB entries laying around that a new
bo then accidentally inherits. That doesn't make a great deal of sense
however, as when we mapped the pages for the new bo the TLBs would've
gotten flushed anyway.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
26c0c9e33a2eb44b345d22d5928d5c8b7b261226 09-Feb-2011 Ben Skeggs <bskeggs@redhat.com> drm/nv50-nvc0: delay GART binding until move_notify time

The immediate benefit of doing this is that on NV50 and up, the GPU
virtual address of any buffer is now constant, regardless of what
memtype they're placed in.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
d5f423947a11103c43ad26ebb680d049c2d8edd6 09-Feb-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: rename nouveau_vram to nouveau_mem

This structure will also be used for GART in the near future.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
3425df486ca247d9e8487be06a6cd0763ba38180 10-Feb-2011 Ben Skeggs <bskeggs@redhat.com> drm/nv50-nvc0: unmap buffers from the vm when they're evicted

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
a4154bbffdc9f6a38556ea9e82aef4975018ba23 10-Feb-2011 Ben Skeggs <bskeggs@redhat.com> drm/nv50-nvc0: move vm bind/unbind to move_notify hook

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
db5c8e299a30db48a3a60dadc676cf05d19d268d 10-Feb-2011 Ben Skeggs <bskeggs@redhat.com> drm/nv50-nvc0: restrict memtype to those specified at creation time

Upcoming patches are going to enable full support for buffers that keep
a constant GPU virtual address whenever they're validated for use by
the GPU.

In order for this to work properly while keeping support for large pages,
we need to know if it's ever going to be possible for a buffer to end
up in GART, and if so, disable large pages for the buffer's VMA.

This is a new restriction that's not present in earlier kernel's, but
should not break userspace as the current code never attempts to validate
buffers into a memtype other than it was created with.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
a67047883410ee37d27806bb8415a84673934b4f 16-Feb-2011 Ben Skeggs <bskeggs@redhat.com> drm/nv50: simplify bo moves now that they're all through the vm

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
d550c41e4ff11fe69b5f92868157253d27937d1f 15-Feb-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: remove no_vm/mappable flags from nouveau_bo

'mappable' isn't really used at all, nor is it necessary anymore as the
bo code is capable of moving buffers to mappable vram as required.

'no_vm' isn't necessary anymore either, any places that don't want to be
mapped into a GPU address space should allocate the VRAM directly instead.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
58e6c7a9183071b89b0ac94862f369ed55775a7a 11-Jan-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: introduce new gart type, and name _SGDMA more appropriately

In preparation for the addition of a new nv40 backend, we'll need to be
able to distinguish between a paged dma object and the on-chip GART.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
b8884da6113be83f6f3b296539bcd9f602a6abd8 14-Feb-2011 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: flips/flipd need to always set 'evict' for move_accel_cleanup()

We free the temporary binding before leaving this function, so we also have
to wait for the move to actually complete.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
812f219a0f8a74a558c35be7942a07232ba348a5 03-Feb-2011 Francisco Jerez <currojerez@riseup.net> drm/nv10: Fix crash when allocating a BO larger than half the available VRAM.

Reported-by: Alex Buell <alex.buell@munted.org.uk>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
183720b8af5301e2eab7f3163f03133c5a6ad6da 09-Dec-2010 Ben Skeggs <bskeggs@redhat.com> drm/nvc0: accelerate ttm buffer moves

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6d86951a45013ac5b060c5e6307b11b7c685c76f 08-Dec-2010 Ben Skeggs <bskeggs@redhat.com> drm/nvc0: initial support for tiled buffer objects

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
966a5b7daa15e152bc2e1f0407939cc721fb5995 24-Nov-2010 Ben Skeggs <bskeggs@redhat.com> drm/nvc0: implement pgraph engine hooks

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
8984e046153eb1d6b0b24626169f9c6e58232e1b 15-Nov-2010 Ben Skeggs <bskeggs@redhat.com> drm/nvc0: initial vm implementation, use for bar1/bar3 management

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
4c74eb7ff276813ee73943a3756b295675fb2865 10-Nov-2010 Ben Skeggs <bskeggs@redhat.com> drm/nvc0: import initial vm backend

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
b571fe21f5c24760368b3fb927af5a7384d7721b 16-Nov-2010 Ben Skeggs <bskeggs@redhat.com> drm/nv50: tidy up PCIEGART implementation

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
bfd83aca5a1c4cc07fb18d96ed8660f2c338a8f3 12-Nov-2010 Ben Skeggs <bskeggs@redhat.com> drm/nv50: enable 4KiB pages for small vram allocations

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
4c1361429841344ce4d164492ee7620cf3286eb7 15-Nov-2010 Ben Skeggs <bskeggs@redhat.com> drm/nv50: implement global channel address space on new VM code

As of this commit, it's guaranteed that if an object is in VRAM that its
GPU virtual address will be constant.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
f869ef882382a4b6cb42d259e399aeec3781d4bb 15-Nov-2010 Ben Skeggs <bskeggs@redhat.com> drm/nv50: implement BAR1/BAR3 management on top of new VM code

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
573a2a37e8648a3249426c816f51e7ef50f6f73e 25-Aug-2010 Ben Skeggs <bskeggs@redhat.com> drm/nv50: implement custom vram mm

This is required on nv50 as we need to be able to have more precise control
over physical VRAM allocations to avoid buffer corruption when using
buffers of mixed memory types.

This removes some nasty overallocation/alignment that we were previously
using to "control" this problem.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
7a45d764a8e3177f0c9cd4a0be9f2ab7965e55cb 21-Nov-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: wrap calls to ttm_bo_validate()

This will be used later to fixup bo.offset with a buffer's fixed GPU
virtual address.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
a3d487ea5463a9c091b7f9b836b860cf3d82e641 20-Nov-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Use WC memory on the AGP GART.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
23c45e8ed203f933753fb66a6290c4ff853eb7bb 28-Oct-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Fix sleep while atomic in nouveau_bo_fence().

Reported-by: Pekka Paalanen <pq@iki.fi>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
a5cf68b04b2b8ea716cf6fd8499c1c54d05fdf5e 24-Oct-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Rework tile region handling.

The point is to share more code between the PFB/PGRAPH tile region
hooks, and give the hardware specific functions a chance to allocate
per-region resources.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
e419cf0954901bb3a987f8b76cbc9654ca06121c 25-Oct-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Add a separate class for the kernel channel mutex.

nouveau_bo_move_m2mf() needs to lock the kernel channel, and it may be
called from the pushbuf IOCTL with an user channel already locked. Use
a separate subclass for the kernel channel mutex because this is
legitimate mutex nesting.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
332b242f47786d1a43bd7a19a0513dd5d493db8e 20-Oct-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Implement the pageflip ioctl.

nv0x-nv4x should be mostly fine, nv50 doesn't work yet.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
382d62e524db528cdf53563ad9a018adc170dfde 20-Oct-2010 Marcin Slusarz <marcin.slusarz@gmail.com> drm/nouveau: fix annoying nouveau_fence type issue

nouveau_fence_* functions are not type safe, which could lead to bugs.
Additionally every use of nouveau_fence_unref had to cast struct
nouveau_fence to void **.
Fix it by renaming old functions and creating static inline functions with
new prototypes. We still need old functions, because we pass function
pointers to ttm.
As we are wrapping functions, drop unused "void *arg" parameter where possible.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
aa5ac7358c010dcb5916d1d0c2651ae65a4f7ab7 14-Oct-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Leave BO eviction synchronization for later.

The pushbuf ioctl syncs after validation, no need for this anymore.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6a6b73f254123851f7f73ab5e57344a569d6a0ab 05-Oct-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: add per-channel mutex, use to lock access to drm's channel

This fixes a race condition between fbcon acceleration and TTM buffer
moves. To reproduce:

- start X
- switch to vt and "while (true); do dmesg; done"
- switch to another vt and "sleep 2 && cat /path/to/debugfs/dri/0/evict_vram"
- switch back to vt running dmesg

We don't make use of this on any other channel yet, they're currently
protected by drm_global_mutex. This will change in the near future.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
699ddfd98061b725c52fd34ff1c4346e5b4824d4 10-Oct-2010 Francisco Jerez <currojerez@riseup.net> drm/nv10: Balance RTs expected to be accessed simultaneously by the 3d engine.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
f13b32630dda7e583a84a8c535880cff7e4a9bdd 10-Oct-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Expose some BO usage flags to userspace.

This will be needed for Z compression and to take smarter placement
decisions.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Acked-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
d961db75ce86a84f1f04e91ad1014653ed7d9f46 05-Aug-2010 Ben Skeggs <bskeggs@redhat.com> drm/ttm: restructure to allow driver to plug in alternate memory manager

Nouveau will need this on GeForce 8 and up to account for the GPU
reordering physical VRAM for some memory types.

Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Acked-by: Thomas Hellström <thellstrom@vmware.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
42311ff90dc8746bd81427b2ed6efda9af791b77 03-Aug-2010 Ben Skeggs <bskeggs@redhat.com> drm/ttm: introduce utility function to free an allocated memory node

Existing core code/drivers call drm_mm_put_block on ttm_mem_reg.mm_node
directly. Future patches will modify TTM behaviour in such a way that
ttm_mem_reg.mm_node doesn't necessarily belong to drm_mm.

Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Acked-by: Thomas Hellström <thellstrom@vmware.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
647988175234a733cc0d4cf968949344803a77a7 21-Sep-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Synchronize buffer object moves in hardware.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
2730723bbc4a8b289fa536fc3555e15947da09c1 21-Sep-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Minor refactoring/cleanup of the fence code.

Mainly to make room for inter-channel sync.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
9bb5863ab4c2bad487e9d02fabde60e858c22411 23-Sep-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: fix chipset vs card_type thinko

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
5220b3c14b5d4e35df5a4574534519d7007713c3 23-Sep-2010 Ben Skeggs <bskeggs@redhat.com> drm/nv50: assume smaller tiles for bo moves

Somehow fixes some corruption seen in KDE..

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
e1429b4c3c79512f0e1a44d9d895c1db52b8c42f 10-Sep-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: better handling of unmappable vram

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
fbd2895e45aebdb3d3ea73a3a796cf3bb9c912da 01-Sep-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: rework init ordering so nv50_instmem.c can be less bad

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
9d59e8a1fc8fc35bf22dc92d7722a7502769ab7e 27-Aug-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: require explicit unmap of kmapped bos

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
b8a6a8045d4d3e5b7330603c35cbfaf9f3cc2e50 27-Aug-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: move check for no-op bo move before memcpy fallback

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
f1ab0cc9bacdd33a37603a80852ee0579f809ce7 26-Aug-2010 Ben Skeggs <bskeggs@redhat.com> drm/nv50: add new accelerated bo move funtion

Hopefully this one will be better able to cope with moving tiled buffers
around without getting them all scrambled as a result.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
415e6186f17136075f7cc825ba3835d005773637 23-Jul-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: fix race condition when under memory pressure

When VRAM is running out it's possible that the client's push buffers get
evicted to main memory. When they're validated back in, the GPU may
be used for the copy back to VRAM, but the existing synchronisation code
only deals with inter-channel sync, not sync between PFIFO and PGRAPH on
the same channel. This leads to PFIFO fetching from command buffers that
haven't quite been copied by PGRAPH yet.

This patch marks push buffers as so, and forces any GPU-assisted buffer
moves to be done on a different channel, which triggers the correct
synchronisation to happen before we submit them.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
0d3470d218949dc1307313647c70154c7452a68b 02-Aug-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: remove unused ttm bo list

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
b6d3d8717855c72e541bace5edd0460f2eed6dde 07-Jun-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: remove dev_priv->init_state and friends

Nouveau will no longer load at all if card initialisation fails, so all
these checks are unnecessary.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
311ab6943fad769a1435bb375d3c821f3b41cdde 04-Jul-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Move the fence wait before migration resource clean-up.

Avoids an oops in the fence wait failure path (bug 26521).

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Tested-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
01d73a6967f12fe6c4bbde1834a9fe662264a2eb 27-May-2010 Jordan Crouse <jcrouse@codeaurora.org> drm: Remove drm_resource wrappers

Remove the drm_resource wrappers and directly use the
actual PCI and/or platform functions in their place.

[airlied: fixup nouveau properly to build]

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
90af89b93c664f42096ef89edc8f7c7fc776d426 15-Apr-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: fix a nouveau_bo dereference after it's been destroyed

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
0c321c79627189204d7d0bf65ab19f5ac419abed 07-Apr-2010 Jerome Glisse <jglisse@redhat.com> drm/ttm: remove io_ field from TTM V6

All TTM driver have been converted to new io_mem_reserve/free
interface which allow driver to choose and return proper io
base, offset to core TTM for ioremapping if necessary. This
patch remove what is now deadcode.

V2 adapt to match with change in first patch of the patchset
V3 update after io_mem_reserve/io_mem_free callback balancing
V4 adjust to minor cleanup
V5 remove the needs ioremap flag
V6 keep the ioremapping facility in TTM

[airlied- squashed driver removals in here also]

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
f32f02fd81f3177cce0c16cc7d210fcc9cad953c 09-Apr-2010 Jerome Glisse <jglisse@redhat.com> drm/nouveau/kms: add support for new TTM fault callback V5

This add the support for the new fault callback, does change anything
from driver point of view, thought it should allow nouveau to add
support for unmappable VRAM.

Improvement: store the aperture base in a variable so that we don't
call a function to get it on each fault.

Patch hasn't been tested on any hw.

V2 don't derefence bo->mem.mm_node as it's not NULL only for
VRAM or GTT
V3 update after io_mem_reserve/io_mem_free callback balancing
V4 callback has to ioremap
V5 ioremap is done by ttm

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
a76fb4e8ffe42144529e21fe1e609b762e8eb5cc 18-Mar-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: detect vram amount once, and save the value

As opposed to repeatedly reading the amount back from the GPU every
time we need to know the VRAM size.

We should now fail to load gracefully on detecting no VRAM, rather than
something potentially messy happening.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
78ad0f7bf2bb667729581f099781fc0b7ae58fcc 18-Mar-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Make use of TTM busy_placements.

Previously we were filling it the same as "placements", but in some
cases there're valid alternatives that we were ignoring completely.
Keeping a back-up memory type helps on several low-mem situations.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
9d87fa2138d06ff400551800d67d522625033e35 07-Apr-2010 Jerome Glisse <jglisse@redhat.com> drm/ttm: split no_wait argument in 2 GPU or reserve wait

There is case where we want to be able to wait only for the
GPU while not waiting for other buffer to be unreserved. This
patch split the no_wait argument all the way down in the whole
ttm path so that upper level can decide on what to wait on or
not.

[airlied: squashed these 4 for bisectability reasons.]
drm/radeon/kms: update to TTM no_wait splitted argument
drm/nouveau: update to TTM no_wait splitted argument
drm/vmwgfx: update to TTM no_wait splitted argument
[vmwgfx patch: Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>]

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Acked-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
965cf68e8797932e9cd49238a6dd39423ac9b256 06-Mar-2010 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Never evict VRAM buffers to system.

VRAM->system is a synchronous operation: it involves scheduling a
VRAM->TT DMA transfer and stalling the CPU until it's finished so that
we can unbind the new memory from the translation tables. VRAM->TT can
always be performed asynchronously, even if TT is already full and we
have to move something out of it.

Additionally, allowing VRAM->system behaves badly under heavy memory
pressure because once we run out of TT, stuff starts to be moved back
and forth between VRAM and system, and the TT contents are hardly
renewed.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
eb1dba0ebaa5b7642b323fac148f9947522a48a8 27-Dec-2009 Maarten Maathuis <madman2003@gmail.com> drm/nv50: align size of buffer object to the right boundaries.

- In the current situation the padding that is added is dangerous to write
to, userspace could potentially overwrite parts of another bo.
- Depth and stencil buffers are supposed to be large enough in general so
the waste of memory should be acceptable.
- Alternatives are hiding the padding from users or splitting vram into 2
zones.

Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
e147eae80afe98b86a7921a40a709584e6603e34 12-Jan-2010 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: wait on fence after bo move if validating for another channel

Not an ideal solution, but it'll do for the moment for correctness. We
need to come up with a nicer way to manage inter-channel sync, the hw
is unfortunately a little lacking in this area.

Should fix some resume corruption, as well as corruption that may be seen
while under memory pressure.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
0a2d090f99c9686e5107ed59533fc4210a9a47d1 26-Dec-2009 Maarten Maathuis <madman2003@gmail.com> drm/nv50: make the blocksize depend on vram size

- This should be better than what we have now.
- I'm less sure about the non power of two path.

Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
c2b82924bda0c3de2b49bd3a4d8b6725721820bc 25-Dec-2009 Maarten Maathuis <madman2003@gmail.com> drm/nouveau: better alignment of bo sizes and use roundup instead of ALIGN

- Aligning to block size should ensure that the extra size is enough.
- Using roundup, because not all sizes are powers of two.

Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
aeca15e596eba284c727049d0b9b855b13c48856 16-Dec-2009 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Drop redundant placement initialization.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
69a18c328b762eaec3f8ca3af8c7cbf10b536bf8 16-Dec-2009 Francisco Jerez <currojerez@riseup.net> drm/nouveau: No need to force evict=true when swapping evicted BOs back in.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
c6af6053be60840dcbb037c3798557cbf71cbb08 16-Dec-2009 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Fix "general protection fault" in the flipd/flips eviction path.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
287c1532145b63d394060d46c0309b123b862345 11-Dec-2009 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Make the MM aware of pre-G80 tiling.

This commit has also the following 3 bugfix commits squashed into it from
the nouveau git tree:

drm/nouveau: Fix up the tiling alignment restrictions for nv1x.
drm/nouveau: Fix up the nv2x tiling alignment restrictions.
drm/nv50: fix align typo for g9x

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
a510604df9444a2a1bdecafc048749e0f35816b5 26-Dec-2009 Maarten Maathuis <madman2003@gmail.com> drm/nv50: make the blocksize depend on vram size

- This should be better than what we have now.
- I'm less sure about the non power of two path.

Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
1c7059e4f36e76c72cefbb6c9bd2bcf45c12e777 25-Dec-2009 Maarten Maathuis <madman2003@gmail.com> drm/nouveau: better alignment of bo sizes and use roundup instead of ALIGN

- Aligning to block size should ensure that the extra size is enough.
- Using roundup, because not all sizes are powers of two.

Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
8dea4a1935fabbc5fcea6016d6670e6bc06de198 16-Dec-2009 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Drop redundant placement initialization.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
27f691a69d411b9b2093163cdd27780f9c927422 16-Dec-2009 Francisco Jerez <currojerez@riseup.net> drm/nouveau: No need to force evict=true when swapping evicted BOs back in.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
77e2b5ed83864f0a58e2cd046b15aab6865babfb 16-Dec-2009 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Fix "general protection fault" in the flipd/flips eviction path.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
a0af9add499cf29a16707b7b148842992077f4cb 11-Dec-2009 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Make the MM aware of pre-G80 tiling.

This commit has also the following 3 bugfix commits squashed into it from
the nouveau git tree:

drm/nouveau: Fix up the tiling alignment restrictions for nv1x.
drm/nouveau: Fix up the nv2x tiling alignment restrictions.
drm/nv50: fix align typo for g9x

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
37cb3e08852be92d94e6a65c489bd8afa2e8a15f 16-Dec-2009 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: fix bug causing pinned buffers to lose their NO_EVICT flag

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
0735f62e116fae1e4f36237a97de28e8a56b4c2c 16-Dec-2009 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: prevent all channel creation if accel not available

Previously, if there was no firmware available, the DRM would just
disable channel creation from userspace, but still use a single
channel for its own purposes.

With a bit of care it should actually be possible to do this, due
to the DRM's very limited use of the engine. It currently doesn't
work correctly however, resulting in corrupted fbcon and hangs on
a number of cards.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
22fbd53809eb7a1b00fe09159fe0a565fb6c725c 11-Dec-2009 Francisco Jerez <currojerez@riseup.net> drm/nouveau: Fix up buffer eviction, and evict them to GART, if possible.

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
b694dfb25a8de4ffbc14c9092ab8f88344ca86b1 15-Dec-2009 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: fix build with CONFIG_AGP=n

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
6ee738610f41b59733f63718f0bdbcba7d3a3f12 11-Dec-2009 Ben Skeggs <bskeggs@redhat.com> drm/nouveau: Add DRM driver for NVIDIA GPUs

This adds a drm/kms staging non-API stable driver for GPUs from NVIDIA.

This driver is a KMS-based driver and requires a compatible nouveau
userspace libdrm and nouveau X.org driver.

This driver requires firmware files not available in this kernel tree,
interested parties can find them via the nouveau project git archive.

This driver is reverse engineered, and is in no way supported by nVidia.

Support for nearly the complete range of nvidia hw from nv04->g80 (nv50)
is available, and the kms driver should support driving nearly all
output types (displayport is under development still) along with supporting
suspend/resume.

This work is all from the upstream nouveau project found at
nouveau.freedesktop.org.

The original authors list from nouveau git tree is:
Anssi Hannula <anssi.hannula@iki.fi>
Ben Skeggs <bskeggs@redhat.com>
Francisco Jerez <currojerez@riseup.net>
Maarten Maathuis <madman2003@gmail.com>
Marcin Kościelnicki <koriakin@0x04.net>
Matthew Garrett <mjg@redhat.com>
Matt Parnell <mparnell@gmail.com>
Patrice Mandin <patmandin@gmail.com>
Pekka Paalanen <pq@iki.fi>
Xavier Chantry <shiningxc@gmail.com>
along with project founder Stephane Marchesin <marchesin@icps.u-strasbg.fr>

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>