Re: [PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Michel Dänzer
On Don, 2011-10-27 at 22:19 -0500, Ilija Hadzic wrote: 
> On Thu, 27 Oct 2011, Daniel Vetter wrote:
> 
> > So I think the right thing to do is
> > - Kill dev->last_vblank_wait (in a prep patch).
> 
> Agreed. Also drm_vblank_info function can go away

Actually, I was rather going to submit a patch to hook it up again —
AFAICT it was unhooked without any justification. It could be useful for
debugging vblank related hangs. Any issues with it, such as
last_vblank_wait not being guaranteed to really be the last one, can
always be improved later on.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Ilija Hadzic


On Thu, 27 Oct 2011, Ilija Hadzic wrote:

>
>> While locking at the code I also noticed that wait_vblank calls
>> drm_vblank_get, but not always drm_vblank_put. The code is correct, the
>> missing vblank_put is hidden in drm_queue_vblank_event. Can you also write
>> the patch to move that around to not trip up reviewers the next time
>> around?
>> 
>
> Actually, there is something fishy here. Look at the 'else' branch under the 
> 'if ((seq - vblwait->request.sequence) <= (1 << 23))' at the end of the 
> drm_queue_vblank_event. It doesn't have the 'drm_vblank_put'. It looks wrong 
> to me, but I need to first convince myself that there is not some other 
> obscure place where drm_vblank_put is accounted for. If that branch is really 
> missing a drm_vblank_put, then it will be easy pull the drm_vblank_put out. 
> Otherwise, it will be another knot to untangle.
>
>

OK, I checked this. Although the code is a little hard to read, it is done 
the way it is with the reason. Whenever the drm_queue_vblank_event and 
that 'else' branch is caught, the drm_vblank_put should *not* be called.
The reason is that the relevant vblank has not come in yet, so the 
reference must remain up so that the vblank interrupts are not disabled 
until the event occurs.

The seemingly missing drm_vblank_put will be accounted for in 
drm_handle_vblank_events.

So I should not move anything around. If anything, this should be 
annotated with comments to explain what's going on.

-- Ilija



[PATCH 08/23] drm/via: use drm_mm instead of drm_sman

2011-10-27 Thread Daniel Vetter
On Thu, Oct 27, 2011 at 01:07:35PM +0200, Daniel Vetter wrote:
> Now that we are again in proper control of owner_list, we need to
> properly list_del it on free.
> 
> Signed-off-by: Daniel Vetter 

Chris Wilson rightly complained that this doesn't explain the list_del
magic going on. New commit msg reads:

To make the transition in a piece-wise and bisectable way possible,
I've hijacked the ->owner_list from drm_sman. While transitioning, the
list_add was done by the driver, while the list_del was still done by
the dying sman code.

Now that we are in full control of ->owner_list, do the list_del
ourselves.

He also noted the superflous additions of INIT_LIST_HEAD and the stale
comment about spinlock locking in the idr allocation (protected by
dev->struct_mutex) that I've copied over. All fixed up and pushed out for
the moment to my fdo repo:

http://cgit.freedesktop.org/~danvet/drm/log/?h=kill-with-fire

Cheers, Daniel
-- 
Daniel Vetter
Mail: daniel at ffwll.ch
Mobile: +41 (0)79 365 57 48


[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #48 from Ilija Hadzic  
2011-10-27 15:33:33 PDT ---
> first) and apply the patch as 'patch -p1 name_of_the_patch.patch'

Typo, it should be


patch -p1 < name_of_the_patch.patch
^

but you probably already know that

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #47 from Ilija Hadzic  
2011-10-27 15:31:31 PDT ---
(In reply to comment #45)
> mmm... I wanted to try it but I still don't understand how to apply it (what
> version of files, where to get them and what command to run). I'm used with
> patchfiles and patch -pNum < patchfilename.

I have attached the patch for you to this bug report. Download it and save it
as
a .patch file.

If you are using a kernel that you checked out from git, you can use 
'git am name_of_the_patch.patch'

If you are using stock kernel that came with your distribution (Ubuntu ?) then
go to the top of your kernel source directory (you must have it installed
first) and apply the patch as 'patch -p1 name_of_the_patch.patch'

After that you have to recompile and reinstall your kernel (look at this page
for Ubuntu-specific instructions
https://help.ubuntu.com/community/Kerne/Compile).

The patch is meant for the latest kernel in Git repository, but I have just
tried it on 2.6.39 kernel (which I understand is what you are using) and it
applies fine.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #46 from Ilija Hadzic  
2011-10-27 15:27:15 PDT ---
Created attachment 52833
  --> https://bugs.freedesktop.org/attachment.cgi?id=52833
provisional patch to try as an experiment

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


[PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Ilija Hadzic


On Thu, 27 Oct 2011, Daniel Vetter wrote:

>
> On a quick glance
> - drm_vblank functions call by wait_vblank seem to do correct locking
>  already using various spinlocks and atomic ops.
> - linux waitqueues have their own locking
> - dev->last_vblank_wait is only used for a procfs file. I don't think it
>  makes much sense given that we can have more than one vblank waiter
> - there's no selective wakeup going on, all waiters get woken for every
>  vblank and call schedule again if it's not the right vblank
>

I concur.


> The only really hairy thing going on is racing modeset ioctls against
> vblank waiters. But modeset is protected by the dev->mode_config.mutex
> and hence already races against wait_vblank with the current code, so I'm
> slightly inclined to ignore this for the moment. Would be great if you
> coudl check that in-depth, too.
>

Will leave this for some other patch at some other time; the critical path 
is to fix the hang/crawl that I explained in my previous note.


> So I think the right thing to do is
> - Kill dev->last_vblank_wait (in a prep patch).

Agreed. Also drm_vblank_info function can go away

> - Imo we also have a few too many atomic ops going on, e.g.
>  dev->vblank_refcount looks like it's atomic only because or the procfs
>  file, so maybe kill that procfs file entirely.

I am not sure about that. dev->vblank_refcount looks critical to me: it is 
incremented through drm_vblank_get which is called from several different 
contexts: page-flip functions in several drivers (which can run in the 
context of multiple user processes), **_pm_** stuff in radeon driver 
(which looks like it runs in the context of kernel worker thread). Mutexes 
used at all these different places are not quite consistent. If anything, 
as the result of a later audit, some other mutexes may be rendered 
unecessary, but definitely, I would keep vblank_refcount atomic.

> - Audit the vblank locking, maybe resulting in a patch with updated
>  comments, if there's anything misleading or tricky going on. And it's
>  always good when the locking of structe members is explained in the
>  header file ...

I'll add comments that I feel make sense for this set of patches (if 
anything). Full audit, should come later at a slower pace. There are quite 
a few mutexes and locks many of which are overlapping in function and some 
are spurious. It will take more than just myself to untangle this know.

> - Drop the mutex locking because it's not needed.
>

Agreed. Will drop.

> While locking at the code I also noticed that wait_vblank calls
> drm_vblank_get, but not always drm_vblank_put. The code is correct, the
> missing vblank_put is hidden in drm_queue_vblank_event. Can you also write
> the patch to move that around to not trip up reviewers the next time
> around?
>

Actually, there is something fishy here. Look at the 'else' branch under 
the 'if ((seq - vblwait->request.sequence) <= (1 << 23))' at the end of 
the drm_queue_vblank_event. It doesn't have the 'drm_vblank_put'. It looks 
wrong to me, but I need to first convince myself that there is not some 
other obscure place where drm_vblank_put is accounted for. If that branch 
is really missing a drm_vblank_put, then it will be easy pull the 
drm_vblank_put out. Otherwise, it will be another knot to untangle.



[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #45 from Siganderson  2011-10-27 15:05:52 PDT 
---
mmm... I wanted to try it but I still don't understand how to apply it (what
version of files, where to get them and what command to run). I'm used with
patchfiles and patch -pNum < patchfilename.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


Re: [PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Ilija Hadzic



On Thu, 27 Oct 2011, Ilija Hadzic wrote:




While locking at the code I also noticed that wait_vblank calls
drm_vblank_get, but not always drm_vblank_put. The code is correct, the
missing vblank_put is hidden in drm_queue_vblank_event. Can you also write
the patch to move that around to not trip up reviewers the next time
around?



Actually, there is something fishy here. Look at the 'else' branch under the 
'if ((seq - vblwait->request.sequence) <= (1 << 23))' at the end of the 
drm_queue_vblank_event. It doesn't have the 'drm_vblank_put'. It looks wrong 
to me, but I need to first convince myself that there is not some other 
obscure place where drm_vblank_put is accounted for. If that branch is really 
missing a drm_vblank_put, then it will be easy pull the drm_vblank_put out. 
Otherwise, it will be another knot to untangle.





OK, I checked this. Although the code is a little hard to read, it is done 
the way it is with the reason. Whenever the drm_queue_vblank_event and 
that 'else' branch is caught, the drm_vblank_put should *not* be called.
The reason is that the relevant vblank has not come in yet, so the 
reference must remain up so that the vblank interrupts are not disabled 
until the event occurs.


The seemingly missing drm_vblank_put will be accounted for in 
drm_handle_vblank_events.


So I should not move anything around. If anything, this should be 
annotated with comments to explain what's going on.


-- Ilija

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 42117] R200 driver performance, UMS, all mesa versions from 7.6

2011-10-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=42117

--- Comment #12 from Michal  2011-10-27 13:39:59 PDT 
---
csm->gart_limit and csm->vram_limit are correct.

With GARTSize "64", openarena works great. ETRacer does not (but no fallbacks)
In ETRacer, when I disabled show fps in options, after few seconds on the map,
framerate back to normal.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #44 from Siganderson  2011-10-27 13:36:58 PDT 
---
I'll try the patch.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


Re: [PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Ilija Hadzic



On Thu, 27 Oct 2011, Daniel Vetter wrote:



On a quick glance
- drm_vblank functions call by wait_vblank seem to do correct locking
 already using various spinlocks and atomic ops.
- linux waitqueues have their own locking
- dev->last_vblank_wait is only used for a procfs file. I don't think it
 makes much sense given that we can have more than one vblank waiter
- there's no selective wakeup going on, all waiters get woken for every
 vblank and call schedule again if it's not the right vblank



I concur.



The only really hairy thing going on is racing modeset ioctls against
vblank waiters. But modeset is protected by the dev->mode_config.mutex
and hence already races against wait_vblank with the current code, so I'm
slightly inclined to ignore this for the moment. Would be great if you
coudl check that in-depth, too.



Will leave this for some other patch at some other time; the critical path 
is to fix the hang/crawl that I explained in my previous note.




So I think the right thing to do is
- Kill dev->last_vblank_wait (in a prep patch).


Agreed. Also drm_vblank_info function can go away


- Imo we also have a few too many atomic ops going on, e.g.
 dev->vblank_refcount looks like it's atomic only because or the procfs
 file, so maybe kill that procfs file entirely.


I am not sure about that. dev->vblank_refcount looks critical to me: it is 
incremented through drm_vblank_get which is called from several different 
contexts: page-flip functions in several drivers (which can run in the 
context of multiple user processes), **_pm_** stuff in radeon driver 
(which looks like it runs in the context of kernel worker thread). Mutexes 
used at all these different places are not quite consistent. If anything, 
as the result of a later audit, some other mutexes may be rendered 
unecessary, but definitely, I would keep vblank_refcount atomic.



- Audit the vblank locking, maybe resulting in a patch with updated
 comments, if there's anything misleading or tricky going on. And it's
 always good when the locking of structe members is explained in the
 header file ...


I'll add comments that I feel make sense for this set of patches (if 
anything). Full audit, should come later at a slower pace. There are quite 
a few mutexes and locks many of which are overlapping in function and some 
are spurious. It will take more than just myself to untangle this know.



- Drop the mutex locking because it's not needed.



Agreed. Will drop.


While locking at the code I also noticed that wait_vblank calls
drm_vblank_get, but not always drm_vblank_put. The code is correct, the
missing vblank_put is hidden in drm_queue_vblank_event. Can you also write
the patch to move that around to not trip up reviewers the next time
around?



Actually, there is something fishy here. Look at the 'else' branch under 
the 'if ((seq - vblwait->request.sequence) <= (1 << 23))' at the end of 
the drm_queue_vblank_event. It doesn't have the 'drm_vblank_put'. It looks 
wrong to me, but I need to first convince myself that there is not some 
other obscure place where drm_vblank_put is accounted for. If that branch 
is really missing a drm_vblank_put, then it will be easy pull the 
drm_vblank_put out. Otherwise, it will be another knot to untangle.


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] drm rc1 tree

2011-10-27 Thread Dave Airlie

Hi Linus,

this is the main pull request for the drm tree, I've got some more stuff 
coming but it all looks like -fixes stuff so no reason to hold this up 
which I had ready pre-ks except for some reverts off a radeon/ttm feature 
that wasn't what we wanted yet.

Highlights:
Samsung: exynos SoC modesetting driver (no accel support/interfaces).
vmwgfx: driver moves out of staging and has supportable ABI.
nouveau: displayport rewrite and 0xd9 gpu modesetting code
radeon: general fixes + blit speedups
intel: Apple Macbook Air fixes, RHEL stabilisation fixes.

Also a whole bunch of deinlining of insane stuff from Andi, 

This tree also contains some cross-over with dwmw2 on iommu fixes, as we
weren't sure what the merge plan was for them, but they shouldn't 
conflict, and had to be in this tree just to let me test them usefully.

/me goes back to looking for replacement cars :)

Dave.

The following changes since commit 899e3ee404961a90b828ad527573c39f0ab1:

  Linux 3.1-rc10 (2011-10-17 21:06:23 -0700)

are available in the git repository at:
  git://people.freedesktop.org/~airlied/linux.git drm-core-next

Adam Jackson (9):
  drm: Add KMS debug printk's for encoder and crtc fixup failure
  drm/i915: Remove "i2c_speed" nonsense from child device table
  drm/i915: Fix multifunction SDVO detection
  drm/i915: Rename intel_sdvo_hdmi_sink_detect
  drm/i915: Remove redundant bit shifting from intel_gmbus_set_speed
  drm/i915/dp: Fix the math in intel_dp_link_required
  drm/i915/dp: Remove eDP special cases from bandwidth checks
  drm/i915/dp: Introduce is_cpu_edp()
  drm/i915/dp: Fix eDP on PCH DP on CPT/PPT

Akshay Joshi (1):
  Drivers: i915: Fix all space related issues.

Alex Deucher (5):
  drm/radeon/kms: bail early in dvi_detect for digital only connectors
  drm/radeon/kms: handle !force case in connector detect more gracefully
  drm/radeon/kms: set DMA mask properly on newer PCI asics
  drm/radeon/kms: simplify r6xx blit code
  drm/radeon/kms: make r600-NI blit suspend code common

Andi Kleen (7):
  drm/radeon: Drop inlines from evergreen_cs.c / r600_cs.c
  drm/radeon: drop inlines in r600_blit.c
  drm/radeon: Remove now unused functions in radeon driver
  drm/radeon: Remove more bogus inlines in the radeon driver.
  drm/radeon: Move more code out of line
  drm/radeon: Move r100_*_*reg out of line
  i915: Move i915_read/write out of line

Ben Skeggs (105):
  drm/nouveau/pm: store voltage in microvolts
  drm/nouveau/pm: initial attempt at parsing volt 0x40
  drm/nouveau/pm: add yet another vid gpio tag
  drm/nouveau/pm: add support for parsing perflvl voltage on fermi chips
  drm/nouveau/pm: show any info we can manage to glean on current perflvl
  drm/nvc0/pm: enable voltage_get
  drm/nouveau/pm: allow voltage-only perflvl set, enable nvc0
  drm/nouveau/pm: some fermi chipsets still use volt 0x30
  drm/nva3/pm: rewrite clock readback functions, far more correct now
  drm/nouveau/pm: add hooks to get/set *all* clocks at once
  drm/nva3/pm: rewrite clock_set, and switch to new interfaces
  drm/nva3/pm: parse/reclock vdec/41a0 clocks
  drm/nva3/pm: tidy and add some comments here and there
  drm/nv50/gr: insert set/clr of a ctxprog flag at start/end of ctxprog
  drm/nouveau: add function to wait until a callback returns true
  drm/nva3/pm: idle graphics engine before changing clocks
  drm/nvc0/pm: initial implementation of clocks_get()
  drm/nvc0/pm: more complete parsing of clock domains
  drm/nouveau: rename nv40_mpeg to nv31_mpeg
  drm/nv31/mpeg: support for a single class3174 user
  drm/nouveau: embed nouveau_mm
  drm/nouveau: allow a nouveau_mm to be created with holes
  drm/nvc0/gr: add support for nvcf chipset
  drm/nvc0/vram: support non-uniform memory size per controller
  drm/nvc0/gr: copy GPC mpart config from PFFB
  drm/nouveau: don't complain for disabled timingset entries
  drm/nvc0/gr: unblacklist nvcf acceleration
  drm/nouveau/tmr: calibrate for ns timestamps on init
  drm/nvd0: add a card_type for 0xdX chipsets
  drm/nouveau: make general drm modesetting init common
  drm/nouveau: fixup init/fini sequence to deal with no CRTCs
  drm/nouveau: allow modeset module option to select 'headless mode'
  drm/nouveau: initial chipset description for nvdX chipsets
  drm/nvd0/i2c: initial implementation
  drm/nvd0/gpio: initial implementation
  drm/nouveau/bios: fix INIT_GPIO for new chipsets
  drm/nvd0/pm: enable clock/voltage hooks
  drm/nouveau/bios: allow passing in crtc to the init table parser
  drm/nvd0/disp: very initial evo setup
  drm/nvd0/disp: whip up some basic dma handling for the evo channels
  drm/nvd0/disp: start on interrupt handling
  drm/nvd0/disp: setup a couple of dma objects we'll need
  drm/nvd0/disp: start on SOR encoder

[PATCH] drm/radeon/kms: allocate vram scratch page on 6xx+

2011-10-27 Thread alexdeuc...@gmail.com
From: Alex Deucher 

The vram scratch was originally only used on some 7xx asics
to work around a hw bug.  Allocate the scratch page on all 6xx+
radeons and set the MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR to point
to it.  We shouldn't ever hit it since we limit the system
aperture to vram or vram and AGP, but better safe than sorry.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/evergreen.c |5 +++
 drivers/gpu/drm/radeon/ni.c|5 +++
 drivers/gpu/drm/radeon/r600.c  |   54 +++-
 drivers/gpu/drm/radeon/radeon.h|   13 ++--
 drivers/gpu/drm/radeon/rv770.c |   60 ---
 5 files changed, 80 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index ed406e8..db9027d 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3031,6 +3031,10 @@ static int evergreen_startup(struct radeon_device *rdev)
}
}

+   r = r600_vram_scratch_init(rdev);
+   if (r)
+   return r;
+
evergreen_mc_program(rdev);
if (rdev->flags & RADEON_IS_AGP) {
evergreen_agp_enable(rdev);
@@ -3235,6 +3239,7 @@ void evergreen_fini(struct radeon_device *rdev)
radeon_ib_pool_fini(rdev);
radeon_irq_kms_fini(rdev);
evergreen_pcie_gart_fini(rdev);
+   r600_vram_scratch_fini(rdev);
radeon_gem_fini(rdev);
radeon_fence_driver_fini(rdev);
radeon_agp_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 556b7bc..56afaff 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1361,6 +1361,10 @@ static int cayman_startup(struct radeon_device *rdev)
return r;
}

+   r = r600_vram_scratch_init(rdev);
+   if (r)
+   return r;
+
evergreen_mc_program(rdev);
r = cayman_pcie_gart_enable(rdev);
if (r)
@@ -1556,6 +1560,7 @@ void cayman_fini(struct radeon_device *rdev)
radeon_ib_pool_fini(rdev);
radeon_irq_kms_fini(rdev);
cayman_pcie_gart_fini(rdev);
+   r600_vram_scratch_fini(rdev);
radeon_gem_fini(rdev);
radeon_fence_driver_fini(rdev);
radeon_bo_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 12470b0..3aa46d7 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1137,7 +1137,7 @@ static void r600_mc_program(struct radeon_device *rdev)
WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, rdev->mc.vram_start >> 
12);
WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, rdev->mc.vram_end >> 
12);
}
-   WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, 0);
+   WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, rdev->vram_scratch.gpu_addr 
>> 12);
tmp = ((rdev->mc.vram_end >> 24) & 0x) << 16;
tmp |= ((rdev->mc.vram_start >> 24) & 0x);
WREG32(MC_VM_FB_LOCATION, tmp);
@@ -1276,6 +1276,53 @@ int r600_mc_init(struct radeon_device *rdev)
return 0;
 }

+int r600_vram_scratch_init(struct radeon_device *rdev)
+{
+   int r;
+
+   if (rdev->vram_scratch.robj == NULL) {
+   r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE,
+PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
+&rdev->vram_scratch.robj);
+   if (r) {
+   return r;
+   }
+   }
+
+   r = radeon_bo_reserve(rdev->vram_scratch.robj, false);
+   if (unlikely(r != 0))
+   return r;
+   r = radeon_bo_pin(rdev->vram_scratch.robj,
+ RADEON_GEM_DOMAIN_VRAM, &rdev->vram_scratch.gpu_addr);
+   if (r) {
+   radeon_bo_unreserve(rdev->vram_scratch.robj);
+   return r;
+   }
+   r = radeon_bo_kmap(rdev->vram_scratch.robj,
+   (void **)&rdev->vram_scratch.ptr);
+   if (r)
+   radeon_bo_unpin(rdev->vram_scratch.robj);
+   radeon_bo_unreserve(rdev->vram_scratch.robj);
+
+   return r;
+}
+
+void r600_vram_scratch_fini(struct radeon_device *rdev)
+{
+   int r;
+
+   if (rdev->vram_scratch.robj == NULL) {
+   return;
+   }
+   r = radeon_bo_reserve(rdev->vram_scratch.robj, false);
+   if (likely(r == 0)) {
+   radeon_bo_kunmap(rdev->vram_scratch.robj);
+   radeon_bo_unpin(rdev->vram_scratch.robj);
+   radeon_bo_unreserve(rdev->vram_scratch.robj);
+   }
+   radeon_bo_unref(&rdev->vram_scratch.robj);
+}
+
 /* We doesn't check that the GPU really needs a reset we simply do the
  * reset, it's up to the caller to determine if the GPU needs one. We
  * might add an helper function to check that.
@@ -2420,6 +2467,10 @@ int r600_startup(struct radeon_device *rdev)
}
}

+   r = r

[PATCH 3/3] drm/radeon: fix a spelling mistake

2011-10-27 Thread Alex Deucher
2011/10/25 Christian K?nig :
> Better fix it before this obvious typo spreads even more.
>
> Signed-off-by: Christian K?nig 

Reviewed-by: Alex Deucher 

> ---
> ?drivers/gpu/drm/radeon/radeon.h ? ? ? | ? ?4 +-
> ?drivers/gpu/drm/radeon/radeon_fence.c | ? 34 
> ?drivers/gpu/drm/radeon/radeon_pm.c ? ?| ? ?4 +-
> ?drivers/gpu/drm/radeon/radeon_ring.c ?| ? ?2 +-
> ?4 files changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index c052406..f84e95c 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -198,7 +198,7 @@ struct radeon_fence_driver {
> ? ? ? ?wait_queue_head_t ? ? ? ? ? ? ? queue;
> ? ? ? ?rwlock_t ? ? ? ? ? ? ? ? ? ? ? ?lock;
> ? ? ? ?struct list_head ? ? ? ? ? ? ? ?created;
> - ? ? ? struct list_head ? ? ? ? ? ? ? ?emited;
> + ? ? ? struct list_head ? ? ? ? ? ? ? ?emitted;
> ? ? ? ?struct list_head ? ? ? ? ? ? ? ?signaled;
> ? ? ? ?bool ? ? ? ? ? ? ? ? ? ? ? ? ? ?initialized;
> ?};
> @@ -209,7 +209,7 @@ struct radeon_fence {
> ? ? ? ?struct list_head ? ? ? ? ? ? ? ?list;
> ? ? ? ?/* protected by radeon_fence.lock */
> ? ? ? ?uint32_t ? ? ? ? ? ? ? ? ? ? ? ?seq;
> - ? ? ? bool ? ? ? ? ? ? ? ? ? ? ? ? ? ?emited;
> + ? ? ? bool ? ? ? ? ? ? ? ? ? ? ? ? ? ?emitted;
> ? ? ? ?bool ? ? ? ? ? ? ? ? ? ? ? ? ? ?signaled;
> ?};
>
> diff --git a/drivers/gpu/drm/radeon/radeon_fence.c 
> b/drivers/gpu/drm/radeon/radeon_fence.c
> index 7fd4e3e..0bb7148 100644
> --- a/drivers/gpu/drm/radeon/radeon_fence.c
> +++ b/drivers/gpu/drm/radeon/radeon_fence.c
> @@ -74,7 +74,7 @@ int radeon_fence_emit(struct radeon_device *rdev, struct 
> radeon_fence *fence)
> ? ? ? ?unsigned long irq_flags;
>
> ? ? ? ?write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
> - ? ? ? if (fence->emited) {
> + ? ? ? if (fence->emitted) {
> ? ? ? ? ? ? ? ?write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
> ? ? ? ? ? ? ? ?return 0;
> ? ? ? ?}
> @@ -88,8 +88,8 @@ int radeon_fence_emit(struct radeon_device *rdev, struct 
> radeon_fence *fence)
> ? ? ? ? ? ? ? ?radeon_fence_ring_emit(rdev, fence);
>
> ? ? ? ?trace_radeon_fence_emit(rdev->ddev, fence->seq);
> - ? ? ? fence->emited = true;
> - ? ? ? list_move_tail(&fence->list, &rdev->fence_drv.emited);
> + ? ? ? fence->emitted = true;
> + ? ? ? list_move_tail(&fence->list, &rdev->fence_drv.emitted);
> ? ? ? ?write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
> ? ? ? ?return 0;
> ?}
> @@ -129,7 +129,7 @@ static bool radeon_fence_poll_locked(struct radeon_device 
> *rdev)
> ? ? ? ? ? ? ? ?return false;
> ? ? ? ?}
> ? ? ? ?n = NULL;
> - ? ? ? list_for_each(i, &rdev->fence_drv.emited) {
> + ? ? ? list_for_each(i, &rdev->fence_drv.emitted) {
> ? ? ? ? ? ? ? ?fence = list_entry(i, struct radeon_fence, list);
> ? ? ? ? ? ? ? ?if (fence->seq == seq) {
> ? ? ? ? ? ? ? ? ? ? ? ?n = i;
> @@ -145,7 +145,7 @@ static bool radeon_fence_poll_locked(struct radeon_device 
> *rdev)
> ? ? ? ? ? ? ? ? ? ? ? ?fence = list_entry(i, struct radeon_fence, list);
> ? ? ? ? ? ? ? ? ? ? ? ?fence->signaled = true;
> ? ? ? ? ? ? ? ? ? ? ? ?i = n;
> - ? ? ? ? ? ? ? } while (i != &rdev->fence_drv.emited);
> + ? ? ? ? ? ? ? } while (i != &rdev->fence_drv.emitted);
> ? ? ? ? ? ? ? ?wake = true;
> ? ? ? ?}
> ? ? ? ?return wake;
> @@ -159,7 +159,7 @@ static void radeon_fence_destroy(struct kref *kref)
> ? ? ? ?fence = container_of(kref, struct radeon_fence, kref);
> ? ? ? ?write_lock_irqsave(&fence->rdev->fence_drv.lock, irq_flags);
> ? ? ? ?list_del(&fence->list);
> - ? ? ? fence->emited = false;
> + ? ? ? fence->emitted = false;
> ? ? ? ?write_unlock_irqrestore(&fence->rdev->fence_drv.lock, irq_flags);
> ? ? ? ?kfree(fence);
> ?}
> @@ -174,7 +174,7 @@ int radeon_fence_create(struct radeon_device *rdev, 
> struct radeon_fence **fence)
> ? ? ? ?}
> ? ? ? ?kref_init(&((*fence)->kref));
> ? ? ? ?(*fence)->rdev = rdev;
> - ? ? ? (*fence)->emited = false;
> + ? ? ? (*fence)->emitted = false;
> ? ? ? ?(*fence)->signaled = false;
> ? ? ? ?(*fence)->seq = 0;
> ? ? ? ?INIT_LIST_HEAD(&(*fence)->list);
> @@ -203,8 +203,8 @@ bool radeon_fence_signaled(struct radeon_fence *fence)
> ? ? ? ?if (fence->rdev->shutdown) {
> ? ? ? ? ? ? ? ?signaled = true;
> ? ? ? ?}
> - ? ? ? if (!fence->emited) {
> - ? ? ? ? ? ? ? WARN(1, "Querying an unemited fence : %p !\n", fence);
> + ? ? ? if (!fence->emitted) {
> + ? ? ? ? ? ? ? WARN(1, "Querying an unemitted fence : %p !\n", fence);
> ? ? ? ? ? ? ? ?signaled = true;
> ? ? ? ?}
> ? ? ? ?if (!signaled) {
> @@ -295,11 +295,11 @@ int radeon_fence_wait_next(struct radeon_device *rdev)
> ? ? ? ? ? ? ? ?return 0;
> ? ? ? ?}
> ? ? ? ?write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
> - ? ? ? if (list_empty(&rdev->fence_drv.emited)) {
> + ? ? ? if (list_empty(&rdev->fence_drv.emitted)) {
> ? ? ? ? ? ? ? ?write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
> ? ? ? ? ? ? ? ?return 0;
> ? ? ? ?}
> - ? ? ? fence = list_entry(rdev->fence_drv.emited.nex

[PATCH 1/3] drm/radeon: fix debugfs handling

2011-10-27 Thread Alex Deucher
2011/10/25 Christian K?nig :
> Having registered debugfs files globally causes
> the files to not show up on the second, third
> etc.. card in the system.
>
> Signed-off-by: Christian K?nig 

Reviewed-by: Alex Deucher 

> ---
> ?drivers/gpu/drm/radeon/radeon.h ? ? ? ?| ? ?8 +++
> ?drivers/gpu/drm/radeon/radeon_device.c | ? 33 ++-
> ?2 files changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index c1e056b..c052406 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -881,6 +881,11 @@ void radeon_test_moves(struct radeon_device *rdev);
> ?/*
> ?* Debugfs
> ?*/
> +struct radeon_debugfs {
> + ? ? ? ?struct drm_info_list ? ?*files;
> + ? ? ? ?unsigned ? ? ? ? ? ? ? ?num_files;
> +};
> +
> ?int radeon_debugfs_add_files(struct radeon_device *rdev,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct drm_info_list *files,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned nfiles);
> @@ -1243,6 +1248,9 @@ struct radeon_device {
> ? ? ? ?struct drm_file *cmask_filp;
> ? ? ? ?/* i2c buses */
> ? ? ? ?struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS];
> + ? ? ? /* debugfs */
> + ? ? ? struct radeon_debugfs ? debugfs[RADEON_DEBUGFS_MAX_NUM_FILES];
> + ? ? ? unsigned ? ? ? ? ? ? ? ?debugfs_count;
> ?};
>
> ?int radeon_device_init(struct radeon_device *rdev,
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
> b/drivers/gpu/drm/radeon/radeon_device.c
> index b51e157..13ac46c 100644
> --- a/drivers/gpu/drm/radeon/radeon_device.c
> +++ b/drivers/gpu/drm/radeon/radeon_device.c
> @@ -977,33 +977,29 @@ int radeon_gpu_reset(struct radeon_device *rdev)
> ?/*
> ?* Debugfs
> ?*/
> -struct radeon_debugfs {
> - ? ? ? struct drm_info_list ? ?*files;
> - ? ? ? unsigned ? ? ? ? ? ? ? ?num_files;
> -};
> -static struct radeon_debugfs _radeon_debugfs[RADEON_DEBUGFS_MAX_NUM_FILES];
> -static unsigned _radeon_debugfs_count = 0;
> -
> ?int radeon_debugfs_add_files(struct radeon_device *rdev,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct drm_info_list *files,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned nfiles)
> ?{
> ? ? ? ?unsigned i;
>
> - ? ? ? for (i = 0; i < _radeon_debugfs_count; i++) {
> - ? ? ? ? ? ? ? if (_radeon_debugfs[i].files == files) {
> + ? ? ? for (i = 0; i < rdev->debugfs_count; i++) {
> + ? ? ? ? ? ? ? if (rdev->debugfs[i].files == files) {
> ? ? ? ? ? ? ? ? ? ? ? ?/* Already registered */
> ? ? ? ? ? ? ? ? ? ? ? ?return 0;
> ? ? ? ? ? ? ? ?}
> ? ? ? ?}
> - ? ? ? if ((_radeon_debugfs_count + nfiles) > RADEON_DEBUGFS_MAX_NUM_FILES) {
> - ? ? ? ? ? ? ? DRM_ERROR("Reached maximum number of debugfs files.\n");
> - ? ? ? ? ? ? ? DRM_ERROR("Report so we increase 
> RADEON_DEBUGFS_MAX_NUM_FILES.\n");
> +
> + ? ? ? i = rdev->debugfs_count + 1;
> + ? ? ? if (i > RADEON_DEBUGFS_MAX_NUM_FILES) {
> + ? ? ? ? ? ? ? DRM_ERROR("Reached maximum number of debugfs components.\n");
> + ? ? ? ? ? ? ? DRM_ERROR("Report so we increase "
> + ? ? ? ? ? ? ? ? ? ? ? ? "RADEON_DEBUGFS_MAX_COMPONENTS.\n");
> ? ? ? ? ? ? ? ?return -EINVAL;
> ? ? ? ?}
> - ? ? ? _radeon_debugfs[_radeon_debugfs_count].files = files;
> - ? ? ? _radeon_debugfs[_radeon_debugfs_count].num_files = nfiles;
> - ? ? ? _radeon_debugfs_count++;
> + ? ? ? rdev->debugfs[rdev->debugfs_count].files = files;
> + ? ? ? rdev->debugfs[rdev->debugfs_count].num_files = nfiles;
> + ? ? ? rdev->debugfs_count = i;
> ?#if defined(CONFIG_DEBUG_FS)
> ? ? ? ?drm_debugfs_create_files(files, nfiles,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? rdev->ddev->control->debugfs_root,
> @@ -1023,11 +1019,12 @@ int radeon_debugfs_init(struct drm_minor *minor)
>
> ?void radeon_debugfs_cleanup(struct drm_minor *minor)
> ?{
> + ? ? ? ?struct radeon_device *rdev = minor->dev->dev_private;
> ? ? ? ?unsigned i;
>
> - ? ? ? for (i = 0; i < _radeon_debugfs_count; i++) {
> - ? ? ? ? ? ? ? drm_debugfs_remove_files(_radeon_debugfs[i].files,
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?_radeon_debugfs[i].num_files, minor);
> + ? ? ? for (i = 0; i < rdev->debugfs_count; i++) {
> + ? ? ? ? ? ? ? drm_debugfs_remove_files(rdev->debugfs[i].files,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?rdev->debugfs[i].num_files, minor);
> ? ? ? ?}
> ?}
> ?#endif
> --
> 1.7.5.4
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>


[Bug 42090] [r300/compiler] [bisected] sauerbraten texture corruption

2011-10-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=42090

Tom Stellard  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #3 from Tom Stellard  2011-10-27 17:59:51 PDT 
---
Fix in git master commit 17a1c0cb0d9e04607c1726d04ef23485979dfc98

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/radeon/kms: allocate vram scratch page on 6xx+

2011-10-27 Thread alexdeucher
From: Alex Deucher 

The vram scratch was originally only used on some 7xx asics
to work around a hw bug.  Allocate the scratch page on all 6xx+
radeons and set the MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR to point
to it.  We shouldn't ever hit it since we limit the system
aperture to vram or vram and AGP, but better safe than sorry.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/evergreen.c |5 +++
 drivers/gpu/drm/radeon/ni.c|5 +++
 drivers/gpu/drm/radeon/r600.c  |   54 +++-
 drivers/gpu/drm/radeon/radeon.h|   13 ++--
 drivers/gpu/drm/radeon/rv770.c |   60 ---
 5 files changed, 80 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index ed406e8..db9027d 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3031,6 +3031,10 @@ static int evergreen_startup(struct radeon_device *rdev)
}
}
 
+   r = r600_vram_scratch_init(rdev);
+   if (r)
+   return r;
+
evergreen_mc_program(rdev);
if (rdev->flags & RADEON_IS_AGP) {
evergreen_agp_enable(rdev);
@@ -3235,6 +3239,7 @@ void evergreen_fini(struct radeon_device *rdev)
radeon_ib_pool_fini(rdev);
radeon_irq_kms_fini(rdev);
evergreen_pcie_gart_fini(rdev);
+   r600_vram_scratch_fini(rdev);
radeon_gem_fini(rdev);
radeon_fence_driver_fini(rdev);
radeon_agp_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 556b7bc..56afaff 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1361,6 +1361,10 @@ static int cayman_startup(struct radeon_device *rdev)
return r;
}
 
+   r = r600_vram_scratch_init(rdev);
+   if (r)
+   return r;
+
evergreen_mc_program(rdev);
r = cayman_pcie_gart_enable(rdev);
if (r)
@@ -1556,6 +1560,7 @@ void cayman_fini(struct radeon_device *rdev)
radeon_ib_pool_fini(rdev);
radeon_irq_kms_fini(rdev);
cayman_pcie_gart_fini(rdev);
+   r600_vram_scratch_fini(rdev);
radeon_gem_fini(rdev);
radeon_fence_driver_fini(rdev);
radeon_bo_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 12470b0..3aa46d7 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1137,7 +1137,7 @@ static void r600_mc_program(struct radeon_device *rdev)
WREG32(MC_VM_SYSTEM_APERTURE_LOW_ADDR, rdev->mc.vram_start >> 
12);
WREG32(MC_VM_SYSTEM_APERTURE_HIGH_ADDR, rdev->mc.vram_end >> 
12);
}
-   WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, 0);
+   WREG32(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, rdev->vram_scratch.gpu_addr 
>> 12);
tmp = ((rdev->mc.vram_end >> 24) & 0x) << 16;
tmp |= ((rdev->mc.vram_start >> 24) & 0x);
WREG32(MC_VM_FB_LOCATION, tmp);
@@ -1276,6 +1276,53 @@ int r600_mc_init(struct radeon_device *rdev)
return 0;
 }
 
+int r600_vram_scratch_init(struct radeon_device *rdev)
+{
+   int r;
+
+   if (rdev->vram_scratch.robj == NULL) {
+   r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE,
+PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
+&rdev->vram_scratch.robj);
+   if (r) {
+   return r;
+   }
+   }
+
+   r = radeon_bo_reserve(rdev->vram_scratch.robj, false);
+   if (unlikely(r != 0))
+   return r;
+   r = radeon_bo_pin(rdev->vram_scratch.robj,
+ RADEON_GEM_DOMAIN_VRAM, &rdev->vram_scratch.gpu_addr);
+   if (r) {
+   radeon_bo_unreserve(rdev->vram_scratch.robj);
+   return r;
+   }
+   r = radeon_bo_kmap(rdev->vram_scratch.robj,
+   (void **)&rdev->vram_scratch.ptr);
+   if (r)
+   radeon_bo_unpin(rdev->vram_scratch.robj);
+   radeon_bo_unreserve(rdev->vram_scratch.robj);
+
+   return r;
+}
+
+void r600_vram_scratch_fini(struct radeon_device *rdev)
+{
+   int r;
+
+   if (rdev->vram_scratch.robj == NULL) {
+   return;
+   }
+   r = radeon_bo_reserve(rdev->vram_scratch.robj, false);
+   if (likely(r == 0)) {
+   radeon_bo_kunmap(rdev->vram_scratch.robj);
+   radeon_bo_unpin(rdev->vram_scratch.robj);
+   radeon_bo_unreserve(rdev->vram_scratch.robj);
+   }
+   radeon_bo_unref(&rdev->vram_scratch.robj);
+}
+
 /* We doesn't check that the GPU really needs a reset we simply do the
  * reset, it's up to the caller to determine if the GPU needs one. We
  * might add an helper function to check that.
@@ -2420,6 +2467,10 @@ int r600_startup(struct radeon_device *rdev)
}
}
 
+   r

nouveau page_flip function implement not wait vblank, which cause screen garbage

2011-10-27 Thread chris
I think page_flip ioctl need to realize a synchronous mechanism to control 
fresh rate...!!!
At 2011-10-25 20:30:39,"Ben Skeggs"  wrote:
>On Tue, 2011-10-25 at 14:15 +0200, Francisco Jerez wrote:
>> Maarten Maathuis  writes:
>> 
>> > 2011/10/25 chris :
>> >> Can anyone give a suggestion, is wait-vblank fully implemented in
>> >> page_flip() for nouveau drm driver?
>> >>
>> 
>> It's intentionally not implemented.  The reason is that I wanted to
>> support non-vsync'ed vblank as well, and for vsync'ed blits we had to
>> think about a different mechanism for vblank synchronization anyway, so
>> I figured it didn't make that much sense to force vblank synchronization
>> directly from the pageflip ioctl.
>+1 I deliberately didn't flip 1 bit in the NV50/NVC0 page flipping code
>for this as well.  The interface IMO is flawed.  Though, that said, we
>really should look at doing something properly for this, a lot of people
>do want tear-free goodness.
>
>Ben.
>> 
>> >>
>> >> At 2011-10-24 14:30:55,chris  wrote:
>> >>
>> >> Dear,
>> >>
>> >> I use NVidia Geforce 7300GT graphics card in my PC, and Linux 3.1rc4 
>> >> kernel
>> >> code, git drm 2.4.36.
>> >>   When I run the vbltest program, it prints  "60HZ"  which indicated the
>> >> implementation of drmWaitVBlank() and drm_vblank_wait()  is correct.
>> >>   But when I run modetest with option " -v -s 12:1280x1024" , it prints 
>> >> high
>> >> fresh rate up to "150 HZ" .  I examing the code , and found that no 
>> >> waiting
>> >> vblank operation is processed in nouveau_crtc_ page_flip() function. The
>> >> screen  produced lots of garbage and blink very much.
>> 
>> That's fine if by "garbage" you just mean it's tearing like crazy.
>> 
>> >>[...]
>> >
>> > It seems to be, the actual page flipping is done by software method
>> > (see nv04_graph_mthd_page_flip). There is one thing i'm unsure about
>> > and that is that we wait for the rendering to be done to the current
>> > frontbuffer and not the current backbuffer (this is only done if the
>> > page flip channel is different than the rendering channel). Maybe
>> > someone else can comment on that.
>> 
>> There's no need to wait for the backbuffer rendering to end because the
>> pageflip is always pushed through the last channel that has queued
>> rendering to it, so, the "waiting" is actually done by the GPU. The
>> waiting to the current frontbuffer (which in most cases is going to be a
>> cross-channel barrier instead of actual CPU waiting) is necessary for
>> the (rare) case where you have several channels trying to render to the
>> same pageflipped drawable, to make sure that the flips are properly
>> synchronized with respect each other.
>> ___
>> dri-devel mailing list
>> dri-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
>___
>dri-devel mailing list
>dri-devel at lists.freedesktop.org
>http://lists.freedesktop.org/mailman/listinfo/dri-devel



Re: [PATCH 3/3] drm/radeon: fix a spelling mistake

2011-10-27 Thread Alex Deucher
2011/10/25 Christian König :
> Better fix it before this obvious typo spreads even more.
>
> Signed-off-by: Christian König 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/radeon/radeon.h       |    4 +-
>  drivers/gpu/drm/radeon/radeon_fence.c |   34 
>  drivers/gpu/drm/radeon/radeon_pm.c    |    4 +-
>  drivers/gpu/drm/radeon/radeon_ring.c  |    2 +-
>  4 files changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index c052406..f84e95c 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -198,7 +198,7 @@ struct radeon_fence_driver {
>        wait_queue_head_t               queue;
>        rwlock_t                        lock;
>        struct list_head                created;
> -       struct list_head                emited;
> +       struct list_head                emitted;
>        struct list_head                signaled;
>        bool                            initialized;
>  };
> @@ -209,7 +209,7 @@ struct radeon_fence {
>        struct list_head                list;
>        /* protected by radeon_fence.lock */
>        uint32_t                        seq;
> -       bool                            emited;
> +       bool                            emitted;
>        bool                            signaled;
>  };
>
> diff --git a/drivers/gpu/drm/radeon/radeon_fence.c 
> b/drivers/gpu/drm/radeon/radeon_fence.c
> index 7fd4e3e..0bb7148 100644
> --- a/drivers/gpu/drm/radeon/radeon_fence.c
> +++ b/drivers/gpu/drm/radeon/radeon_fence.c
> @@ -74,7 +74,7 @@ int radeon_fence_emit(struct radeon_device *rdev, struct 
> radeon_fence *fence)
>        unsigned long irq_flags;
>
>        write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
> -       if (fence->emited) {
> +       if (fence->emitted) {
>                write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
>                return 0;
>        }
> @@ -88,8 +88,8 @@ int radeon_fence_emit(struct radeon_device *rdev, struct 
> radeon_fence *fence)
>                radeon_fence_ring_emit(rdev, fence);
>
>        trace_radeon_fence_emit(rdev->ddev, fence->seq);
> -       fence->emited = true;
> -       list_move_tail(&fence->list, &rdev->fence_drv.emited);
> +       fence->emitted = true;
> +       list_move_tail(&fence->list, &rdev->fence_drv.emitted);
>        write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
>        return 0;
>  }
> @@ -129,7 +129,7 @@ static bool radeon_fence_poll_locked(struct radeon_device 
> *rdev)
>                return false;
>        }
>        n = NULL;
> -       list_for_each(i, &rdev->fence_drv.emited) {
> +       list_for_each(i, &rdev->fence_drv.emitted) {
>                fence = list_entry(i, struct radeon_fence, list);
>                if (fence->seq == seq) {
>                        n = i;
> @@ -145,7 +145,7 @@ static bool radeon_fence_poll_locked(struct radeon_device 
> *rdev)
>                        fence = list_entry(i, struct radeon_fence, list);
>                        fence->signaled = true;
>                        i = n;
> -               } while (i != &rdev->fence_drv.emited);
> +               } while (i != &rdev->fence_drv.emitted);
>                wake = true;
>        }
>        return wake;
> @@ -159,7 +159,7 @@ static void radeon_fence_destroy(struct kref *kref)
>        fence = container_of(kref, struct radeon_fence, kref);
>        write_lock_irqsave(&fence->rdev->fence_drv.lock, irq_flags);
>        list_del(&fence->list);
> -       fence->emited = false;
> +       fence->emitted = false;
>        write_unlock_irqrestore(&fence->rdev->fence_drv.lock, irq_flags);
>        kfree(fence);
>  }
> @@ -174,7 +174,7 @@ int radeon_fence_create(struct radeon_device *rdev, 
> struct radeon_fence **fence)
>        }
>        kref_init(&((*fence)->kref));
>        (*fence)->rdev = rdev;
> -       (*fence)->emited = false;
> +       (*fence)->emitted = false;
>        (*fence)->signaled = false;
>        (*fence)->seq = 0;
>        INIT_LIST_HEAD(&(*fence)->list);
> @@ -203,8 +203,8 @@ bool radeon_fence_signaled(struct radeon_fence *fence)
>        if (fence->rdev->shutdown) {
>                signaled = true;
>        }
> -       if (!fence->emited) {
> -               WARN(1, "Querying an unemited fence : %p !\n", fence);
> +       if (!fence->emitted) {
> +               WARN(1, "Querying an unemitted fence : %p !\n", fence);
>                signaled = true;
>        }
>        if (!signaled) {
> @@ -295,11 +295,11 @@ int radeon_fence_wait_next(struct radeon_device *rdev)
>                return 0;
>        }
>        write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
> -       if (list_empty(&rdev->fence_drv.emited)) {
> +       if (list_empty(&rdev->fence_drv.emitted)) {
>                write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
>                return 0;
>        }
> -       fence = list_entry(rdev->fence_drv.emited.nex

Re: [PATCH 1/3] drm/radeon: fix debugfs handling

2011-10-27 Thread Alex Deucher
2011/10/25 Christian König :
> Having registered debugfs files globally causes
> the files to not show up on the second, third
> etc.. card in the system.
>
> Signed-off-by: Christian König 

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/radeon/radeon.h        |    8 +++
>  drivers/gpu/drm/radeon/radeon_device.c |   33 ++-
>  2 files changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index c1e056b..c052406 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -881,6 +881,11 @@ void radeon_test_moves(struct radeon_device *rdev);
>  /*
>  * Debugfs
>  */
> +struct radeon_debugfs {
> +        struct drm_info_list    *files;
> +        unsigned                num_files;
> +};
> +
>  int radeon_debugfs_add_files(struct radeon_device *rdev,
>                             struct drm_info_list *files,
>                             unsigned nfiles);
> @@ -1243,6 +1248,9 @@ struct radeon_device {
>        struct drm_file *cmask_filp;
>        /* i2c buses */
>        struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS];
> +       /* debugfs */
> +       struct radeon_debugfs   debugfs[RADEON_DEBUGFS_MAX_NUM_FILES];
> +       unsigned                debugfs_count;
>  };
>
>  int radeon_device_init(struct radeon_device *rdev,
> diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
> b/drivers/gpu/drm/radeon/radeon_device.c
> index b51e157..13ac46c 100644
> --- a/drivers/gpu/drm/radeon/radeon_device.c
> +++ b/drivers/gpu/drm/radeon/radeon_device.c
> @@ -977,33 +977,29 @@ int radeon_gpu_reset(struct radeon_device *rdev)
>  /*
>  * Debugfs
>  */
> -struct radeon_debugfs {
> -       struct drm_info_list    *files;
> -       unsigned                num_files;
> -};
> -static struct radeon_debugfs _radeon_debugfs[RADEON_DEBUGFS_MAX_NUM_FILES];
> -static unsigned _radeon_debugfs_count = 0;
> -
>  int radeon_debugfs_add_files(struct radeon_device *rdev,
>                             struct drm_info_list *files,
>                             unsigned nfiles)
>  {
>        unsigned i;
>
> -       for (i = 0; i < _radeon_debugfs_count; i++) {
> -               if (_radeon_debugfs[i].files == files) {
> +       for (i = 0; i < rdev->debugfs_count; i++) {
> +               if (rdev->debugfs[i].files == files) {
>                        /* Already registered */
>                        return 0;
>                }
>        }
> -       if ((_radeon_debugfs_count + nfiles) > RADEON_DEBUGFS_MAX_NUM_FILES) {
> -               DRM_ERROR("Reached maximum number of debugfs files.\n");
> -               DRM_ERROR("Report so we increase 
> RADEON_DEBUGFS_MAX_NUM_FILES.\n");
> +
> +       i = rdev->debugfs_count + 1;
> +       if (i > RADEON_DEBUGFS_MAX_NUM_FILES) {
> +               DRM_ERROR("Reached maximum number of debugfs components.\n");
> +               DRM_ERROR("Report so we increase "
> +                         "RADEON_DEBUGFS_MAX_COMPONENTS.\n");
>                return -EINVAL;
>        }
> -       _radeon_debugfs[_radeon_debugfs_count].files = files;
> -       _radeon_debugfs[_radeon_debugfs_count].num_files = nfiles;
> -       _radeon_debugfs_count++;
> +       rdev->debugfs[rdev->debugfs_count].files = files;
> +       rdev->debugfs[rdev->debugfs_count].num_files = nfiles;
> +       rdev->debugfs_count = i;
>  #if defined(CONFIG_DEBUG_FS)
>        drm_debugfs_create_files(files, nfiles,
>                                 rdev->ddev->control->debugfs_root,
> @@ -1023,11 +1019,12 @@ int radeon_debugfs_init(struct drm_minor *minor)
>
>  void radeon_debugfs_cleanup(struct drm_minor *minor)
>  {
> +        struct radeon_device *rdev = minor->dev->dev_private;
>        unsigned i;
>
> -       for (i = 0; i < _radeon_debugfs_count; i++) {
> -               drm_debugfs_remove_files(_radeon_debugfs[i].files,
> -                                        _radeon_debugfs[i].num_files, minor);
> +       for (i = 0; i < rdev->debugfs_count; i++) {
> +               drm_debugfs_remove_files(rdev->debugfs[i].files,
> +                                        rdev->debugfs[i].num_files, minor);
>        }
>  }
>  #endif
> --
> 1.7.5.4
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #48 from Ilija Hadzic  2011-10-27 
15:33:33 PDT ---
> first) and apply the patch as 'patch -p1 name_of_the_patch.patch'

Typo, it should be


patch -p1 < name_of_the_patch.patch
^

but you probably already know that

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #47 from Ilija Hadzic  2011-10-27 
15:31:31 PDT ---
(In reply to comment #45)
> mmm... I wanted to try it but I still don't understand how to apply it (what
> version of files, where to get them and what command to run). I'm used with
> patchfiles and patch -pNum < patchfilename.

I have attached the patch for you to this bug report. Download it and save it
as
a .patch file.

If you are using a kernel that you checked out from git, you can use 
'git am name_of_the_patch.patch'

If you are using stock kernel that came with your distribution (Ubuntu ?) then
go to the top of your kernel source directory (you must have it installed
first) and apply the patch as 'patch -p1 name_of_the_patch.patch'

After that you have to recompile and reinstall your kernel (look at this page
for Ubuntu-specific instructions
https://help.ubuntu.com/community/Kerne/Compile).

The patch is meant for the latest kernel in Git repository, but I have just
tried it on 2.6.39 kernel (which I understand is what you are using) and it
applies fine.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #46 from Ilija Hadzic  2011-10-27 
15:27:15 PDT ---
Created attachment 52833
  --> https://bugs.freedesktop.org/attachment.cgi?id=52833
provisional patch to try as an experiment

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #45 from Siganderson  2011-10-27 15:05:52 PDT ---
mmm... I wanted to try it but I still don't understand how to apply it (what
version of files, where to get them and what command to run). I'm used with
patchfiles and patch -pNum < patchfilename.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 08/23] drm/via: use drm_mm instead of drm_sman

2011-10-27 Thread Daniel Vetter
On Thu, Oct 27, 2011 at 01:07:35PM +0200, Daniel Vetter wrote:
> Now that we are again in proper control of owner_list, we need to
> properly list_del it on free.
> 
> Signed-off-by: Daniel Vetter 

Chris Wilson rightly complained that this doesn't explain the list_del
magic going on. New commit msg reads:

To make the transition in a piece-wise and bisectable way possible,
I've hijacked the ->owner_list from drm_sman. While transitioning, the
list_add was done by the driver, while the list_del was still done by
the dying sman code.

Now that we are in full control of ->owner_list, do the list_del
ourselves.

He also noted the superflous additions of INIT_LIST_HEAD and the stale
comment about spinlock locking in the idr allocation (protected by
dev->struct_mutex) that I've copied over. All fixed up and pushed out for
the moment to my fdo repo:

http://cgit.freedesktop.org/~danvet/drm/log/?h=kill-with-fire

Cheers, Daniel
-- 
Daniel Vetter
Mail: dan...@ffwll.ch
Mobile: +41 (0)79 365 57 48
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/radeon: flush read cache for gtt with fence on r6xx and newer GPU V3

2011-10-27 Thread Jerome Glisse
On Thu, Oct 27, 2011 at 12:12:09PM -0400, Alex Deucher wrote:
> On Wed, Oct 26, 2011 at 11:41 AM,   wrote:
> > From: Jerome Glisse 
> >
> > Cayman seems to be particularly sensitive to read cache returning
> > old data after bind/unbind to GTT. Flush read cache for GTT range
> > with each fences for all new hw. Should fix several rendering glitches.
> > Like
> >
> > V2 flush whole address space
> > V3 also flush shader read cache
> >
> > https://bugs.freedesktop.org/show_bug.cgi?id=40221
> > https://bugs.freedesktop.org/show_bug.cgi?id=38022
> > https://bugzilla.redhat.com/show_bug.cgi?id=738790
> >
> > Signed-off-by: Jerome Glisse 
> > ---
> > ?drivers/gpu/drm/radeon/evergreen_blit_kms.c | ? ?4 ++--
> > ?drivers/gpu/drm/radeon/r600.c ? ? ? ? ? ? ? | ? 16 
> > ?drivers/gpu/drm/radeon/r600_blit_kms.c ? ? ?| ? ?4 ++--
> > ?3 files changed, 20 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c 
> > b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> > index dcf11bb..e9aeeed 100644
> > --- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> > +++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> > @@ -613,9 +613,9 @@ int evergreen_blit_init(struct radeon_device *rdev)
> > ? ? ? ?rdev->r600_blit.primitives.set_default_state = set_default_state;
> >
> > ? ? ? ?rdev->r600_blit.ring_size_common = 55; /* shaders + def state */
> > - ? ? ? rdev->r600_blit.ring_size_common += 10; /* fence emit for VB IB */
> > + ? ? ? rdev->r600_blit.ring_size_common += 16; /* fence emit for VB IB */
> > ? ? ? ?rdev->r600_blit.ring_size_common += 5; /* done copy */
> > - ? ? ? rdev->r600_blit.ring_size_common += 10; /* fence emit for done copy 
> > */
> > + ? ? ? rdev->r600_blit.ring_size_common += 16; /* fence emit for done copy 
> > */
> >
> > ? ? ? ?rdev->r600_blit.ring_size_per_loop = 74;
> >
> > diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
> > index 12470b0..1f007ad 100644
> > --- a/drivers/gpu/drm/radeon/r600.c
> > +++ b/drivers/gpu/drm/radeon/r600.c
> > @@ -2331,6 +2331,14 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
> > ? ? ? ?if (rdev->wb.use_event) {
> > ? ? ? ? ? ? ? ?u64 addr = rdev->wb.gpu_addr + R600_WB_EVENT_OFFSET +
> > ? ? ? ? ? ? ? ? ? ? ? ?(u64)(rdev->fence_drv.scratch_reg - 
> > rdev->scratch.reg_base);
> 
> We need to specify the vmid on cayman, so we should probably add the
> following here:
> 
> if (rdev->family >= CHIP_CAYMAN) {
> /* CP_COHER_CNTL2 has to be set manually when
> submitting a surface_sync
>  * to the RB directly. For IBs, the CP programs this
> as part of the
>  * surface_sync packet.
>  */
> radeon_ring_write(rdev, PACKET3(PACKET3_SET_CONFIG_REG, 1));
> radeon_ring_write(rdev, (0x85e8 -
> PACKET3_SET_CONFIG_REG_START) >> 2);
> radeon_ring_write(rdev, 0); /* CP_COHER_CNTL2 */
> }
> 

I think default cayman blit state already does specify vmid so we should
be fine.

Cheers,
Jerome


[Bug 42117] R200 driver performance, UMS, all mesa versions from 7.6

2011-10-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=42117

--- Comment #12 from Michal  2011-10-27 13:39:59 PDT ---
csm->gart_limit and csm->vram_limit are correct.

With GARTSize "64", openarena works great. ETRacer does not (but no fallbacks)
In ETRacer, when I disabled show fps in options, after few seconds on the map,
framerate back to normal.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 39202] FPS - KDE desktop effects with 3.0 rc6 kernel

2011-10-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=39202

--- Comment #44 from Siganderson  2011-10-27 13:36:58 PDT ---
I'll try the patch.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


nouveau page_flip function implement not wait vblank, which cause screen garbage

2011-10-27 Thread Thomas Hellstrom
On 10/27/2011 12:49 PM, Francisco Jerez wrote:
> Thomas Hellstrom  writes:
>
>
>> FWIW, there was a quite long discussion / argument when the page flip
>> ioctl was designed, and at that time
>> I pointed out that there are hardware capable of pageflipping using
>> the fifo/pipe with optional VSYNC barriers, and that it is actually
>> possible to queue up a number of pageflips in the fifo. Not just one.
>>
>>  
> That's the case of the nouveau driver, and it's the reason that we don't
> respect the API returning -EBUSY when there's an already scheduled flip
> request. IMHO that should be up to the driver, or even better, the IOCTL
> could be specified to block in case userspace is requesting more
> simultaneous page-flips than the kernel driver can handle, in order to
> make the resulting behavior consistent for userspace no matter which
> implementation is being used.
>
>
>> The interface description in drm_mode.h is somewhat different to what
>> was agreed upon, namely:
>>
>> 1) The command submission mechanism should block if a user tries to
>> render to a not yet flipped frontbuffer, and that would cause
>> rendering problems. For hardware that flips using a fifo / pipe,
>> that's not really a problem. Thus, any rendering errors due to
>> rendering to a not-yet-flipped frontbuffer is a kernel driver error.
>> The user-space app can avoid being blocked waiting using events.
>>
>>  
> Yeah, it would be good to relax this restriction -- the nouveau driver
> has never respected it because we'd end up lock-stepping the GPU (we
> wouldn't be sending the next batch of commands until the one sent before
> the flip had been completely processed), and it's just not necessary
> because we take additional measures to make sure that flips and commands
> sent to other hardware queues are properly ordered with respect to one
> another.
>
>

I don't think you need to care about this restriction, since the next 
batch doesn't arrive for execution until the flip has happened. Waiting 
to submit in this case was never intended when there is GPU support to 
order the flip and the next batch of commands, and the waiting is only 
to protect against rendering errors.


>> 2) The interface in itself doesn't require flips to be synced to
>> vblanks, as I understand it.
>>   However, it should be possible to add a new flag
>> DRM_MODE_PAGE_FLIP_SYNC that tries to sync if at all possible.
>>
>>  
> Yes, so the fact that the nouveau pageflip implementation doesn't sync
> to vblank before flipping isn't even a bug as it stands.
>

No it isn't. vmwgfx is doing (or going to do ) the same, since we can't 
sync to vblank currently. Also we are not holding rendering commands up, 
since the virtual GPU orders the flips and the next batch of commands.

/Thomas





[PATCH 23/23] drm: kill a few unused remnants from drm_memory.c

2011-10-27 Thread Daniel Vetter
Noticed while killing code in the area ...

Signed-Off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_memory.c |   19 ---
 include/drm/drmP.h   |5 -
 2 files changed, 0 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index c9b8050..21a554d 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -36,25 +36,6 @@
 #include 
 #include "drmP.h"

-/**
- * Called when "/proc/dri/%dev%/mem" is read.
- *
- * \param buf output buffer.
- * \param start start of output data.
- * \param offset requested start offset.
- * \param len requested number of bytes.
- * \param eof whether there is no more data to return.
- * \param data private data.
- * \return number of written bytes.
- *
- * No-op.
- */
-int drm_mem_info(char *buf, char **start, off_t offset,
-int len, int *eof, void *data)
-{
-   return 0;
-}
-
 #if __OS_HAS_AGP
 static void *agp_remap(unsigned long offset, unsigned long size,
   struct drm_device * dev)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d307dec..75e0e52 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1247,11 +1247,6 @@ extern unsigned int drm_poll(struct file *filp, struct 
poll_table_struct *wait);

/* Memory management support (drm_memory.h) */
 #include "drm_memory.h"
-extern void drm_mem_init(void);
-extern int drm_mem_info(char *buf, char **start, off_t offset,
-   int request, int *eof, void *data);
-extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
-
 extern void drm_free_agp(DRM_AGP_MEM * handle, int pages);
 extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
 extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
-- 
1.7.7.1



[PATCH 22/23] drm: kill procfs support

2011-10-27 Thread Daniel Vetter
We have debugfs and sysfs for these things now!

Digging through the dungeons of old code and wading through countless
result pages on google indeed turned up one user of this:

libdrm before 2001 checks via the presence of /proc/dri/0 whether
the kernel drm is present and has a module successfully loaded.

Frankly I think that demanding from users that they upgrade to a more
modern libdrm is in order.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/Makefile   |2 +-
 drivers/gpu/drm/drm_drv.c  |8 --
 drivers/gpu/drm/drm_proc.c |  220 
 drivers/gpu/drm/drm_stub.c |   25 ++
 include/drm/drmP.h |9 --
 5 files changed, 8 insertions(+), 256 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_proc.c

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index ea083cf..cea1435 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -7,7 +7,7 @@ ccflags-y := -Iinclude/drm
 drm-y   := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
drm_context.o drm_dma.o \
drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
-   drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
+   drm_lock.o drm_memory.o drm_stub.o drm_vm.o \
drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \
drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
drm_crtc.o drm_modes.o drm_edid.o \
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 1c853f4..1dece54 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -251,13 +251,6 @@ static int __init drm_core_init(void)
goto err_p2;
}

-   drm_proc_root = proc_mkdir("dri", NULL);
-   if (!drm_proc_root) {
-   DRM_ERROR("Cannot create /proc/dri\n");
-   ret = -1;
-   goto err_p3;
-   }
-
drm_debugfs_root = debugfs_create_dir("dri", NULL);
if (!drm_debugfs_root) {
DRM_ERROR("Cannot create /sys/kernel/debug/dri\n");
@@ -280,7 +273,6 @@ err_p1:

 static void __exit drm_core_exit(void)
 {
-   remove_proc_entry("dri", NULL);
debugfs_remove(drm_debugfs_root);
drm_sysfs_destroy();

diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c
deleted file mode 100644
index a60af79..000
--- a/drivers/gpu/drm/drm_proc.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/**
- * \file drm_proc.c
- * /proc support for DRM
- *
- * \author Rickard E. (Rik) Faith 
- * \author Gareth Hughes 
- *
- * \par Acknowledgements:
- *Matthew J Sottek  sent in a patch to fix
- *the problem with the proc files not outputting all their information.
- */
-
-/*
- * Created: Mon Jan 11 09:48:47 1999 by faith at valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include 
-#include 
-#include "drmP.h"
-
-/***
- * Initialization, etc.
- **/
-
-/**
- * Proc file list.
- */
-static struct drm_info_list drm_proc_list[] = {
-   {"name", drm_name_info, 0},
-   {"vm", drm_vm_info, 0},
-   {"clients", drm_clients_info, 0},
-   {"bufs", drm_bufs_info, 0},
-   {"gem_names", drm_gem_name_info, DRIVER_GEM},
-#if DRM_DEBUG_CODE
-   {"vma", drm_vma_info, 0},
-#endif
-};
-#define DRM_PROC_ENTRIES ARRAY_SIZE(drm_proc_list)
-
-static int drm_proc_open(struct inode *inode, struct file *file)
-{
-   struct drm_info_node* node = PDE(inode)->data;
-
-   return single_open(file, node->info_ent->show, node);
-}
-
-static const struct file_operations drm_proc_fops = {
-   .owner = THIS_MODULE,
-   .open = drm_proc_

[PATCH 21/23] drm: kill i915/i830 ids from drm_pciids.h

2011-10-27 Thread Daniel Vetter
Signed-off-by: Daniel Vetter 
---
 include/drm/drm_pciids.h |   42 --
 1 files changed, 0 insertions(+), 42 deletions(-)

diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index 3d53efd..ecd09a3 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -603,14 +603,6 @@
{0x8086, 0x1132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}

-#define i830_PCI_IDS \
-   {0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0x8086, 0x358e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0, 0, 0}
-
 #define gamma_PCI_IDS \
{0x3d3d, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
@@ -643,37 +635,3 @@

 #define ffb_PCI_IDS \
{0, 0, 0}
-
-#define i915_PCI_IDS \
-   {0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x258a, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x27ae, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2972, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2982, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2992, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x29a2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x29b2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x29c2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x29d2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2a02, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2a12, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2a42, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e02, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e12, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e22, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e32, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e42, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0xa001, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0xa011, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x35e8, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x0042, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x0046, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x0102, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0, 0, 0}
-- 
1.7.7.1



[PATCH 20/23] drm: unconditionally clean up dma buffers of closing clients

2011-10-27 Thread Daniel Vetter
With the last patch to ditch DMA_QUEUE support, we should be able
to call the dma cleanup uncoditionally, even when the master has
disappeared.

Do so because it just makes more sense.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 6d6dbe5..46f2cfd 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -366,9 +366,6 @@ static void drm_master_release(struct drm_device *dev, 
struct file *filp)
drm_lock_free(&file_priv->master->lock,
  
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
}
-
-   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
-   drm_core_reclaim_buffers(dev, file_priv);
 }

 static void drm_events_release(struct drm_file *file_priv)
@@ -433,6 +430,9 @@ int drm_release(struct inode *inode, struct file *filp)
if (file_priv->minor->master)
drm_master_release(dev, filp);

+   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
+   drm_core_reclaim_buffers(dev, file_priv);
+
drm_events_release(file_priv);

if (dev->driver->driver_features & DRIVER_GEM)
-- 
1.7.7.1



[PATCH 19/23] drm: kill dma queue support

2011-10-27 Thread Daniel Vetter
Absolutely unused. All the values are only ever initialized and
then used at most in some debug printout functions.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_bufs.c  |   16 ++--
 drivers/gpu/drm/drm_debugfs.c   |1 -
 drivers/gpu/drm/drm_dma.c   |5 -
 drivers/gpu/drm/drm_drv.c   |   11 ---
 drivers/gpu/drm/drm_fops.c  |4 
 drivers/gpu/drm/drm_info.c  |   36 
 drivers/gpu/drm/drm_proc.c  |1 -
 drivers/gpu/drm/i810/i810_drv.c |2 +-
 include/drm/drmP.h  |8 +---
 9 files changed, 4 insertions(+), 80 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 61e1ef9..bec0295 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -640,8 +640,6 @@ int drm_addbufs_agp(struct drm_device * dev, struct 
drm_buf_desc * request)

if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return -EINVAL;
-   if (dev->queue_count)
-   return -EBUSY;  /* Not while in use */

/* Make sure buffers are located in AGP memory that we own */
valid = 0;
@@ -703,7 +701,6 @@ int drm_addbufs_agp(struct drm_device * dev, struct 
drm_buf_desc * request)
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
-   init_waitqueue_head(&buf->dma_wait);
buf->file_priv = NULL;

buf->dev_priv_size = dev->driver->dev_priv_size;
@@ -795,13 +792,11 @@ int drm_addbufs_pci(struct drm_device * dev, struct 
drm_buf_desc * request)
order = drm_order(request->size);
size = 1 << order;

-   DRM_DEBUG("count=%d, size=%d (%d), order=%d, queue_count=%d\n",
- request->count, request->size, size, order, dev->queue_count);
+   DRM_DEBUG("count=%d, size=%d (%d), order=%d\n",
+ request->count, request->size, size, order);

if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return -EINVAL;
-   if (dev->queue_count)
-   return -EBUSY;  /* Not while in use */

alignment = (request->flags & _DRM_PAGE_ALIGN)
? PAGE_ALIGN(size) : size;
@@ -903,7 +898,6 @@ int drm_addbufs_pci(struct drm_device * dev, struct 
drm_buf_desc * request)
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
-   init_waitqueue_head(&buf->dma_wait);
buf->file_priv = NULL;

buf->dev_priv_size = dev->driver->dev_priv_size;
@@ -1018,8 +1012,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct 
drm_buf_desc * request

if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return -EINVAL;
-   if (dev->queue_count)
-   return -EBUSY;  /* Not while in use */

spin_lock(&dev->count_lock);
if (dev->buf_use) {
@@ -1070,7 +1062,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct 
drm_buf_desc * request
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
-   init_waitqueue_head(&buf->dma_wait);
buf->file_priv = NULL;

buf->dev_priv_size = dev->driver->dev_priv_size;
@@ -1176,8 +1167,6 @@ static int drm_addbufs_fb(struct drm_device * dev, struct 
drm_buf_desc * request

if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return -EINVAL;
-   if (dev->queue_count)
-   return -EBUSY;  /* Not while in use */

spin_lock(&dev->count_lock);
if (dev->buf_use) {
@@ -1227,7 +1216,6 @@ static int drm_addbufs_fb(struct drm_device * dev, struct 
drm_buf_desc * request
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
-   init_waitqueue_head(&buf->dma_wait);
buf->file_priv = NULL;

buf->dev_priv_size = dev->driver->dev_priv_size;
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 9d2668a..e72d46a 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -45,7 +45,6 @@ static struct drm_info_list drm_debugfs_list[] = {
{"name", drm_name_info, 0},
{"vm", drm_vm_info, 0},
{"clients", drm_clients_info, 0},
-   {"queues", drm_queues_info, 0},
{"bufs", drm_bufs_info, 0},
{"gem_names", drm_gem_name_info, DRIVER_GEM},
 #if DRM_DEBUG_CODE
diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
index 252cbd7..f91d54f 100644
--- a/drivers/gpu/drm/drm_dma.c
+++ b/drivers/gpu/drm/drm_dma.c
@@ -119,11 +119,6 @@ void drm_free_buffer(struct drm_device *dev, struct 
drm_buf * buf)
buf->pending = 0;
buf->file_priv = NULL;
buf->used = 0;
-
-   if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)
-   && wa

[PATCH 18/23] drm: ditch strange DRIVER_DMA_QUEUE only error bail-out

2011-10-27 Thread Daniel Vetter
Only one driver (i810) even sets that flag. Now the actual locking code
uncoditionally promotes lock->context to an unsigned int.

Closer inspection of the userspace reveals that the drm lock context
is defined as an unsigned int (at least on linux). I suspect
we just have a strange case of signedness confusion going on.

Tested on my i815, doesn't seem to break anything.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_lock.c |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index b107e1d..37822d1 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -69,10 +69,6 @@ int drm_lock(struct drm_device *dev, void *data, struct 
drm_file *file_priv)
  lock->context, task_pid_nr(current),
  master->lock.hw_lock->lock, lock->flags);

-   if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE))
-   if (lock->context < 0)
-   return -EINVAL;
-
add_wait_queue(&master->lock.lock_queue, &entry);
spin_lock_bh(&master->lock.spinlock);
master->lock.user_waiters++;
-- 
1.7.7.1



[PATCH 17/23] drm: kill reclaim_buffers callback

2011-10-27 Thread Daniel Vetter
All leftover users either haven't set DRIVER_HAVE_DMA, in which
case this will never be called, or use the drm_core implementation.

Call that directly in the only callsite.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c|5 ++---
 drivers/gpu/drm/i915/i915_drv.c   |1 -
 drivers/gpu/drm/mga/mga_drv.c |1 -
 drivers/gpu/drm/nouveau/nouveau_drv.c |1 -
 drivers/gpu/drm/r128/r128_drv.c   |1 -
 drivers/gpu/drm/radeon/radeon_drv.c   |2 --
 drivers/gpu/drm/tdfx/tdfx_drv.c   |1 -
 drivers/staging/gma500/psb_drv.c  |1 -
 include/drm/drmP.h|2 --
 9 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index a004525..c1298be 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -371,9 +371,8 @@ static void drm_master_release(struct drm_device *dev, 
struct file *filp)
  
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
}

-   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) {
-   dev->driver->reclaim_buffers(dev, file_priv);
-   }
+   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
+   drm_core_reclaim_buffers(dev, file_priv);
 }

 static void drm_events_release(struct drm_file *file_priv)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index f07e425..c2476d4 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -803,7 +803,6 @@ static struct drm_driver driver = {
.resume = i915_resume,

.device_is_agp = i915_driver_device_is_agp,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.master_create = i915_master_create,
.master_destroy = i915_master_destroy,
 #if defined(CONFIG_DEBUG_FS)
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 42d3187..421f4c9 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -59,7 +59,6 @@ static struct drm_driver driver = {
.irq_postinstall = mga_driver_irq_postinstall,
.irq_uninstall = mga_driver_irq_uninstall,
.irq_handler = mga_driver_irq_handler,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = mga_ioctls,
.dma_ioctl = mga_dma_buffers,
.fops = {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c 
b/drivers/gpu/drm/nouveau/nouveau_drv.c
index b30ddd8..c79d225 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -410,7 +410,6 @@ static struct drm_driver driver = {
.get_vblank_counter = drm_vblank_count,
.enable_vblank = nouveau_vblank_enable,
.disable_vblank = nouveau_vblank_disable,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = nouveau_ioctls,
.fops = {
.owner = THIS_MODULE,
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index b9e8efd..4afeaf0 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -55,7 +55,6 @@ static struct drm_driver driver = {
.irq_postinstall = r128_driver_irq_postinstall,
.irq_uninstall = r128_driver_irq_uninstall,
.irq_handler = r128_driver_irq_handler,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = r128_ioctls,
.dma_ioctl = r128_cce_buffers,
.fops = {
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index e71d2ed..3f220ea 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -223,7 +223,6 @@ static struct drm_driver driver_old = {
.irq_postinstall = radeon_driver_irq_postinstall,
.irq_uninstall = radeon_driver_irq_uninstall,
.irq_handler = radeon_driver_irq_handler,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = radeon_ioctls,
.dma_ioctl = radeon_cp_buffers,
.fops = {
@@ -325,7 +324,6 @@ static struct drm_driver kms_driver = {
.irq_postinstall = radeon_driver_irq_postinstall_kms,
.irq_uninstall = radeon_driver_irq_uninstall_kms,
.irq_handler = radeon_driver_irq_handler_kms,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = radeon_ioctls_kms,
.gem_init_object = radeon_gem_object_init,
.gem_free_object = radeon_gem_object_free,
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index 8bf9881..b3e64a7 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -41,7 +41,6 @@ static struct pci_device_id pciidlist[] = {

 static struct drm_driver driver = {
.driver_features = DRIVER_USE_MTRR,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.fops = {
 .owner = THIS_MODULE,
 .open = drm_open,
diff --git a/drivers/staging/gma500/psb_dr

[PATCH 16/23] drm/savage: clean up reclaim_buffers

2011-10-27 Thread Daniel Vetter
The reclaim_buffers function of the savage driver actually wants to run
with the hw_lock held - at least there are printks in the call-chain
to that effect. But the drm core only calls reclaim_buffers as used
by savage _after_ forcefully dropping the hwlock (in case it's still
hold by the closing fd).

So do the same idlelock dance as for the other dma drivers and hope
that papers over any issues.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/savage/savage_bci.c |7 +--
 drivers/gpu/drm/savage/savage_drv.c |2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/savage/savage_bci.c 
b/drivers/gpu/drm/savage/savage_bci.c
index cb1ee4e..1c00dbd 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -1050,6 +1050,7 @@ void savage_reclaim_buffers(struct drm_device *dev, 
struct drm_file *file_priv)
 {
struct drm_device_dma *dma = dev->dma;
drm_savage_private_t *dev_priv = dev->dev_private;
+   int release_idlelock = 0;
int i;

if (!dma)
@@ -1059,7 +1060,8 @@ void savage_reclaim_buffers(struct drm_device *dev, 
struct drm_file *file_priv)
if (!dma->buflist)
return;

-   /*i830_flush_queue(dev); */
+   if (file_priv->master && file_priv->master->lock.hw_lock)
+   drm_idlelock_take(&file_priv->master->lock);

for (i = 0; i < dma->buf_count; i++) {
struct drm_buf *buf = dma->buflist[i];
@@ -1075,7 +1077,8 @@ void savage_reclaim_buffers(struct drm_device *dev, 
struct drm_file *file_priv)
}
}

-   drm_core_reclaim_buffers(dev, file_priv);
+   if (release_idlelock)
+   drm_idlelock_release(&file_priv->master->lock);
 }

 struct drm_ioctl_desc savage_ioctls[] = {
diff --git a/drivers/gpu/drm/savage/savage_drv.c 
b/drivers/gpu/drm/savage/savage_drv.c
index 6464490..0ed88b1 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -39,9 +39,9 @@ static struct drm_driver driver = {
.dev_priv_size = sizeof(drm_savage_buf_priv_t),
.load = savage_driver_load,
.firstopen = savage_driver_firstopen,
+   .preclose = savage_reclaim_buffers,
.lastclose = savage_driver_lastclose,
.unload = savage_driver_unload,
-   .reclaim_buffers = savage_reclaim_buffers,
.ioctls = savage_ioctls,
.dma_ioctl = savage_bci_buffers,
.fops = {
-- 
1.7.7.1



[PATCH 15/23] drm: kill reclaim_buffers_locked

2011-10-27 Thread Daniel Vetter
i810 was the last user of this code, with that gone, kill it.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c  |   46 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c |1 -
 include/drm/drmP.h  |2 -
 3 files changed, 1 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index e18e329..a004525 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -360,53 +360,10 @@ int drm_fasync(int fd, struct file *filp, int on)
 }
 EXPORT_SYMBOL(drm_fasync);

-/*
- * Reclaim locked buffers; note that this may be a bad idea if the current
- * context doesn't have the hw lock...
- */
-static void drm_reclaim_locked_buffers(struct drm_device *dev, struct file *f)
-{
-   struct drm_file *file_priv = f->private_data;
-
-   if (drm_i_have_hw_lock(dev, file_priv)) {
-   dev->driver->reclaim_buffers_locked(dev, file_priv);
-   } else {
-   unsigned long _end = jiffies + 3 * DRM_HZ;
-   int locked = 0;
-
-   drm_idlelock_take(&file_priv->master->lock);
-
-   /*
-* Wait for a while.
-*/
-   do {
-   spin_lock_bh(&file_priv->master->lock.spinlock);
-   locked = file_priv->master->lock.idle_has_lock;
-   spin_unlock_bh(&file_priv->master->lock.spinlock);
-   if (locked)
-   break;
-   schedule();
-   } while (!time_after_eq(jiffies, _end));
-
-   if (!locked) {
-   DRM_ERROR("reclaim_buffers_locked() deadlock. Please 
rework this\n"
- "\tdriver to use reclaim_buffers_idlelocked() 
instead.\n"
- "\tI will go on reclaiming the buffers 
anyway.\n");
-   }
-
-   dev->driver->reclaim_buffers_locked(dev, file_priv);
-   drm_idlelock_release(&file_priv->master->lock);
-   }
-}
-
 static void drm_master_release(struct drm_device *dev, struct file *filp)
 {
struct drm_file *file_priv = filp->private_data;

-   if (dev->driver->reclaim_buffers_locked &&
-   file_priv->master->lock.hw_lock)
-   drm_reclaim_locked_buffers(dev, filp);
-
if (drm_i_have_hw_lock(dev, file_priv)) {
DRM_DEBUG("File %p released, freeing lock for context %d\n",
  filp, 
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
@@ -414,8 +371,7 @@ static void drm_master_release(struct drm_device *dev, 
struct file *filp)
  
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
}

-   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) &&
-   !dev->driver->reclaim_buffers_locked) {
+   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) {
dev->driver->reclaim_buffers(dev, file_priv);
}
 }
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 96949b9..dcf6c27 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -886,7 +886,6 @@ static struct drm_driver driver = {
.irq_uninstall = vmw_irq_uninstall,
.irq_handler = vmw_irq_handler,
.get_vblank_counter = vmw_get_vblank_counter,
-   .reclaim_buffers_locked = NULL,
.ioctls = vmw_ioctls,
.num_ioctls = DRM_ARRAY_SIZE(vmw_ioctls),
.dma_quiescent = NULL,  /*vmw_dma_quiescent, */
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 4690265..9823614 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -855,8 +855,6 @@ struct drm_driver {
void (*irq_uninstall) (struct drm_device *dev);
void (*reclaim_buffers) (struct drm_device *dev,
 struct drm_file * file_priv);
-   void (*reclaim_buffers_locked) (struct drm_device *dev,
-   struct drm_file *file_priv);
void (*set_version) (struct drm_device *dev,
 struct drm_set_version *sv);

-- 
1.7.7.1



[PATCH 14/23] drm/i810: cleanup reclaim_buffers

2011-10-27 Thread Daniel Vetter
My dear old i815 always hits the deadlocked on reclaim_buffers
warning. Switch over to the idlelock duct-tape on hope that
works better. I've fired up my i815 and now closing glxgears doesn't
take 5 seconds anymore. \o/

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/i810/i810_dma.c |   17 +++--
 drivers/gpu/drm/i810/i810_drv.c |1 -
 drivers/gpu/drm/i810/i810_drv.h |6 ++
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 8f371e8..6b73c3e 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -888,7 +888,7 @@ static int i810_flush_queue(struct drm_device *dev)
 }

 /* Must be called with the lock held */
-static void i810_reclaim_buffers(struct drm_device *dev,
+void i810_driver_reclaim_buffers(struct drm_device *dev,
 struct drm_file *file_priv)
 {
struct drm_device_dma *dma = dev->dma;
@@ -1225,12 +1225,17 @@ void i810_driver_preclose(struct drm_device *dev, 
struct drm_file *file_priv)
if (dev_priv->page_flipping)
i810_do_cleanup_pageflip(dev);
}
-}

-void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
-   struct drm_file *file_priv)
-{
-   i810_reclaim_buffers(dev, file_priv);
+   if (file_priv->master && file_priv->master->lock.hw_lock) {
+   drm_idlelock_take(&file_priv->master->lock);
+   i810_driver_reclaim_buffers(dev, file_priv);
+   drm_idlelock_release(&file_priv->master->lock);
+   } else {
+   /* master disappeared, clean up stuff anyway and hope nothing
+* goes wrong */
+   i810_driver_reclaim_buffers(dev, file_priv);
+   }
+
 }

 int i810_driver_dma_quiescent(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 6f98d05..b264e19 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -50,7 +50,6 @@ static struct drm_driver driver = {
.lastclose = i810_driver_lastclose,
.preclose = i810_driver_preclose,
.device_is_agp = i810_driver_device_is_agp,
-   .reclaim_buffers_locked = i810_driver_reclaim_buffers_locked,
.dma_quiescent = i810_driver_dma_quiescent,
.ioctls = i810_ioctls,
.fops = {
diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
index c9339f4..6e0acad 100644
--- a/drivers/gpu/drm/i810/i810_drv.h
+++ b/drivers/gpu/drm/i810/i810_drv.h
@@ -116,14 +116,12 @@ typedef struct drm_i810_private {

/* i810_dma.c */
 extern int i810_driver_dma_quiescent(struct drm_device *dev);
-extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
-  struct drm_file *file_priv);
+void i810_driver_reclaim_buffers(struct drm_device *dev,
+struct drm_file *file_priv);
 extern int i810_driver_load(struct drm_device *, unsigned long flags);
 extern void i810_driver_lastclose(struct drm_device *dev);
 extern void i810_driver_preclose(struct drm_device *dev,
 struct drm_file *file_priv);
-extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
-  struct drm_file *file_priv);
 extern int i810_driver_device_is_agp(struct drm_device *dev);

 extern long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
-- 
1.7.7.1



[PATCH 13/23] drm: kill reclaim_buffers_idlelocked functions

2011-10-27 Thread Daniel Vetter
The only two users are now folded into the drivers preclose functions,
so this is unused.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c |8 
 include/drm/drmP.h |2 --
 2 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 2ec7d48..e18e329 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -407,14 +407,6 @@ static void drm_master_release(struct drm_device *dev, 
struct file *filp)
file_priv->master->lock.hw_lock)
drm_reclaim_locked_buffers(dev, filp);

-   if (dev->driver->reclaim_buffers_idlelocked &&
-   file_priv->master->lock.hw_lock) {
-   drm_idlelock_take(&file_priv->master->lock);
-   dev->driver->reclaim_buffers_idlelocked(dev, file_priv);
-   drm_idlelock_release(&file_priv->master->lock);
-   }
-
-
if (drm_i_have_hw_lock(dev, file_priv)) {
DRM_DEBUG("File %p released, freeing lock for context %d\n",
  filp, 
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 9b7c2bb..4690265 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -857,8 +857,6 @@ struct drm_driver {
 struct drm_file * file_priv);
void (*reclaim_buffers_locked) (struct drm_device *dev,
struct drm_file *file_priv);
-   void (*reclaim_buffers_idlelocked) (struct drm_device *dev,
-   struct drm_file *file_priv);
void (*set_version) (struct drm_device *dev,
 struct drm_set_version *sv);

-- 
1.7.7.1



[PATCH 12/23] drm/sis: clean up reclaim_buffers

2011-10-27 Thread Daniel Vetter
Like for via.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/sis/sis_drv.c |3 +--
 drivers/gpu/drm/sis/sis_mm.c  |   12 ++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 278d1b0..1b299cc 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -91,10 +91,9 @@ static struct drm_driver driver = {
.load = sis_driver_load,
.unload = sis_driver_unload,
.open = sis_driver_open,
+   .preclose = sis_reclaim_buffers_locked,
.postclose = sis_driver_postclose,
.dma_quiescent = sis_idle,
-   .reclaim_buffers = NULL,
-   .reclaim_buffers_idlelocked = sis_reclaim_buffers_locked,
.lastclose = sis_lastclose,
.ioctls = sis_ioctls,
.fops = {
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index ff34680..f746618 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -324,14 +324,18 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
struct sis_file_private *file_priv = file->driver_priv;
struct sis_memblock *entry, *next;

+   int release_idlelock = 0;
+
+   if (file->master && file->master->lock.hw_lock)
+   drm_idlelock_take(&file->master->lock);
+
mutex_lock(&dev->struct_mutex);
if (list_empty(&file_priv->obj_list)) {
mutex_unlock(&dev->struct_mutex);
return;
}

-   if (dev->driver->dma_quiescent)
-   dev->driver->dma_quiescent(dev);
+   sis_idle(dev);


list_for_each_entry_safe(entry, next, &file_priv->obj_list,
@@ -346,6 +350,10 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
kfree(entry);
}
mutex_unlock(&dev->struct_mutex);
+
+   if (release_idlelock)
+   drm_idlelock_release(&file->master->lock);
+
return;
 }

-- 
1.7.7.1



[PATCH 11/23] drm/via: clean up reclaim_buffers

2011-10-27 Thread Daniel Vetter
A few things
- kill reclaim_buffers, it's never ever called because via does not set
  DRIVER_HAVE_DMA
- inline the idlelock dance into the buffer reclaim logic and make it
  a simple preclose cleanup function
- directly call the the dma_quiescent function and kill the needless
  if check.

Export the idlelock drm functions so that drivers can call them.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_lock.c|2 ++
 drivers/gpu/drm/via/via_drv.c |4 +---
 drivers/gpu/drm/via/via_mm.c  |   11 +--
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index 632ae24..b107e1d 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -345,6 +345,7 @@ void drm_idlelock_take(struct drm_lock_data *lock_data)
}
spin_unlock_bh(&lock_data->spinlock);
 }
+EXPORT_SYMBOL(drm_idlelock_take);

 void drm_idlelock_release(struct drm_lock_data *lock_data)
 {
@@ -364,6 +365,7 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
}
spin_unlock_bh(&lock_data->spinlock);
 }
+EXPORT_SYMBOL(drm_idlelock_release);

 int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv)
 {
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 472adcf..f50431c 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -62,6 +62,7 @@ static struct drm_driver driver = {
.load = via_driver_load,
.unload = via_driver_unload,
.open = via_driver_open,
+   .preclose = via_reclaim_buffers_locked,
.postclose = via_driver_postclose,
.context_dtor = via_final_context,
.get_vblank_counter = via_get_vblank_counter,
@@ -72,9 +73,6 @@ static struct drm_driver driver = {
.irq_uninstall = via_driver_irq_uninstall,
.irq_handler = via_driver_irq_handler,
.dma_quiescent = via_driver_dma_quiescent,
-   .reclaim_buffers = drm_core_reclaim_buffers,
-   .reclaim_buffers_locked = NULL,
-   .reclaim_buffers_idlelocked = via_reclaim_buffers_locked,
.lastclose = via_lastclose,
.ioctls = via_ioctls,
.fops = {
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index 80eab7d..8ce95c5 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -217,6 +217,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
 {
struct via_file_private *file_priv = file->driver_priv;
struct via_memblock *entry, *next;
+   int release_idlelock = 0;
+
+   if (file->master && file->master->lock.hw_lock)
+   drm_idlelock_take(&file->master->lock);

mutex_lock(&dev->struct_mutex);
if (list_empty(&file_priv->obj_list)) {
@@ -224,8 +228,7 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
return;
}

-   if (dev->driver->dma_quiescent)
-   dev->driver->dma_quiescent(dev);
+   via_driver_dma_quiescent(dev);

list_for_each_entry_safe(entry, next, &file_priv->obj_list,
 owner_list) {
@@ -234,5 +237,9 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
kfree(entry);
}
mutex_unlock(&dev->struct_mutex);
+
+   if (release_idlelock)
+   drm_idlelock_release(&file->master->lock);
+
return;
 }
-- 
1.7.7.1



[PATCH 10/23] drm: kill drm_sman

2011-10-27 Thread Daniel Vetter
No longer used.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/Makefile   |2 +-
 drivers/gpu/drm/drm_sman.c |  210 
 include/drm/drm_sman.h |  151 ---
 3 files changed, 1 insertions(+), 362 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_sman.c
 delete mode 100644 include/drm/drm_sman.h

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 89cf05a..ea083cf 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -9,7 +9,7 @@ drm-y   :=  drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \
-   drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \
+   drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
drm_crtc.o drm_modes.o drm_edid.o \
drm_info.o drm_debugfs.o drm_encoder_slave.o \
drm_trace_points.o drm_global.o drm_usb.o
diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
deleted file mode 100644
index 1a4fb9f..000
--- a/drivers/gpu/drm/drm_sman.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck., ND., USA.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **/
-/*
- * Simple memory manager interface that keeps track on allocate regions on a
- * per "owner" basis. All regions associated with an "owner" can be released
- * with a simple call. Typically if the "owner" exists. The owner is any
- * "unsigned long" identifier. Can typically be a pointer to a file private
- * struct or a context identifier.
- *
- * Authors:
- * Thomas Hellstr?m 
- */
-
-#include "drm_sman.h"
-
-struct drm_owner_item {
-   struct drm_hash_item owner_hash;
-   struct list_head sman_list;
-   struct list_head mem_blocks;
-};
-
-void drm_sman_takedown(struct drm_sman * sman)
-{
-   kfree(sman->mm);
-}
-
-EXPORT_SYMBOL(drm_sman_takedown);
-
-int
-drm_sman_init(struct drm_sman * sman, unsigned int num_managers,
- unsigned int user_order, unsigned int owner_order)
-{
-   int ret = 0;
-
-   sman->mm = kcalloc(num_managers, sizeof(*sman->mm), GFP_KERNEL);
-   if (!sman->mm) {
-   ret = -ENOMEM;
-   return ret;
-   }
-   sman->num_managers = num_managers;
-
-   return 0;
-}
-
-EXPORT_SYMBOL(drm_sman_init);
-
-static void *drm_sman_mm_allocate(void *private, unsigned long size,
- unsigned alignment)
-{
-   struct drm_mm *mm = (struct drm_mm *) private;
-   struct drm_mm_node *tmp;
-
-   tmp = drm_mm_search_free(mm, size, alignment, 1);
-   if (!tmp) {
-   return NULL;
-   }
-   tmp = drm_mm_get_block(tmp, size, alignment);
-   return tmp;
-}
-
-static void drm_sman_mm_free(void *private, void *ref)
-{
-   struct drm_mm_node *node = (struct drm_mm_node *) ref;
-
-   drm_mm_put_block(node);
-}
-
-static void drm_sman_mm_destroy(void *private)
-{
-   struct drm_mm *mm = (struct drm_mm *) private;
-   drm_mm_takedown(mm);
-   kfree(mm);
-}
-
-static unsigned long drm_sman_mm_offset(void *private, void *ref)
-{
-   struct drm_mm_node *node = (struct drm_mm_node *) ref;
-   return node->start;
-}
-
-int
-drm_sman_set_range(struct drm_sman * sman, unsigned int manager,
-  unsigned long start, unsigned long size)
-{
-   struct drm_sman_mm *sman_mm;
-   struct drm_mm *mm;
-   int ret;
-
-   BUG_ON(manager >= 

[PATCH 09/23] drm/sis: use drm_mm instead of drm_sman

2011-10-27 Thread Daniel Vetter
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/sis/sis_drv.c |4 -
 drivers/gpu/drm/sis/sis_drv.h |5 +-
 drivers/gpu/drm/sis/sis_mm.c  |  137 +++-
 3 files changed, 68 insertions(+), 78 deletions(-)

diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 9f5fbcf..278d1b0 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -47,9 +47,6 @@ static int sis_driver_load(struct drm_device *dev, unsigned 
long chipset)
dev->dev_private = (void *)dev_priv;
dev_priv->chipset = chipset;
idr_init(&dev->object_name_idr);
-   ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
-   if (ret)
-   kfree(dev_priv);

return ret;
 }
@@ -58,7 +55,6 @@ static int sis_driver_unload(struct drm_device *dev)
 {
drm_sis_private_t *dev_priv = dev->dev_private;

-   drm_sman_takedown(&dev_priv->sman);
idr_remove_all(&dev_priv->object_idr);
idr_destroy(&dev_priv->object_idr);

diff --git a/drivers/gpu/drm/sis/sis_drv.h b/drivers/gpu/drm/sis/sis_drv.h
index fcdd06a..573758b 100644
--- a/drivers/gpu/drm/sis/sis_drv.h
+++ b/drivers/gpu/drm/sis/sis_drv.h
@@ -44,7 +44,7 @@ enum sis_family {
SIS_CHIP_315 = 1,
 };

-#include "drm_sman.h"
+#include "drm_mm.h"


 #define SIS_BASE (dev_priv->mmio)
@@ -54,12 +54,13 @@ enum sis_family {
 typedef struct drm_sis_private {
drm_local_map_t *mmio;
unsigned int idle_fault;
-   struct drm_sman sman;
unsigned int chipset;
int vram_initialized;
int agp_initialized;
unsigned long vram_offset;
unsigned long agp_offset;
+   struct drm_mm vram_mm;
+   struct drm_mm agp_mm;
/** Mapping of userspace keys to mm objects */
struct idr object_idr;
 } drm_sis_private_t;
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index ef6045a..ff34680 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -41,40 +41,18 @@
 #define AGP_TYPE 1


+struct sis_memblock {
+   struct drm_mm_node mm_node;
+   struct sis_memreq req;
+   struct list_head owner_list;
+};
+
 #if defined(CONFIG_FB_SIS) || defined(CONFIG_FB_SIS_MODULE)
 /* fb management via fb device */

 #define SIS_MM_ALIGN_SHIFT 0
 #define SIS_MM_ALIGN_MASK 0

-static void *sis_sman_mm_allocate(void *private, unsigned long size,
- unsigned alignment)
-{
-   struct sis_memreq req;
-
-   req.size = size;
-   sis_malloc(&req);
-   if (req.size == 0)
-   return NULL;
-   else
-   return (void *)(unsigned long)~req.offset;
-}
-
-static void sis_sman_mm_free(void *private, void *ref)
-{
-   sis_free(~((unsigned long)ref));
-}
-
-static void sis_sman_mm_destroy(void *private)
-{
-   ;
-}
-
-static unsigned long sis_sman_mm_offset(void *private, void *ref)
-{
-   return ~((unsigned long)ref);
-}
-
 #else /* CONFIG_FB_SIS[_MODULE] */

 #define SIS_MM_ALIGN_SHIFT 4
@@ -86,30 +64,11 @@ static int sis_fb_init(struct drm_device *dev, void *data, 
struct drm_file *file
 {
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_fb_t *fb = data;
-   int ret;

mutex_lock(&dev->struct_mutex);
-#if defined(CONFIG_FB_SIS) || defined(CONFIG_FB_SIS_MODULE)
-   {
-   struct drm_sman_mm sman_mm;
-   sman_mm.private = (void *)0x;
-   sman_mm.allocate = sis_sman_mm_allocate;
-   sman_mm.free = sis_sman_mm_free;
-   sman_mm.destroy = sis_sman_mm_destroy;
-   sman_mm.offset = sis_sman_mm_offset;
-   ret =
-   drm_sman_set_manager(&dev_priv->sman, VIDEO_TYPE, &sman_mm);
-   }
-#else
-   ret = drm_sman_set_range(&dev_priv->sman, VIDEO_TYPE, 0,
-fb->size >> SIS_MM_ALIGN_SHIFT);
-#endif
-
-   if (ret) {
-   DRM_ERROR("VRAM memory manager initialisation error\n");
-   mutex_unlock(&dev->struct_mutex);
-   return ret;
-   }
+   /* Unconditionally init the drm_mm, even though we don't use it when the
+* fb sis driver is available - make cleanup easier. */
+   drm_mm_init(&dev_priv->vram_mm, 0, fb->size >> SIS_MM_ALIGN_SHIFT);

dev_priv->vram_initialized = 1;
dev_priv->vram_offset = fb->offset;
@@ -126,8 +85,9 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file,
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_mem_t *mem = data;
int retval = 0, user_key;
-   struct drm_memblock_item *item;
+   struct sis_memblock *item;
struct sis_file_private *file_priv = file->driver_priv;
+   unsigned long offset;

mutex_lock(&dev->struct_mutex);

@@ -139,13 +99,35 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file,
return -EINVAL;

[PATCH 08/23] drm/via: use drm_mm instead of drm_sman

2011-10-27 Thread Daniel Vetter
Now that we are again in proper control of owner_list, we need to
properly list_del it on free.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/via/via_drv.h |5 ++-
 drivers/gpu/drm/via/via_map.c |7 
 drivers/gpu/drm/via/via_mm.c  |   72 ++--
 3 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index 108ea71..88edacc 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -24,7 +24,7 @@
 #ifndef _VIA_DRV_H_
 #define _VIA_DRV_H_

-#include "drm_sman.h"
+#include "drm_mm.h"
 #define DRIVER_AUTHOR  "Various"

 #define DRIVER_NAME"via"
@@ -88,9 +88,10 @@ typedef struct drm_via_private {
uint32_t irq_pending_mask;
int *irq_map;
unsigned int idle_fault;
-   struct drm_sman sman;
int vram_initialized;
+   struct drm_mm vram_mm;
int agp_initialized;
+   struct drm_mm agp_mm;
/** Mapping of userspace keys to mm objects */
struct idr object_idr;
unsigned long vram_offset;
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index fa5afbc..a2ab343 100644
--- a/drivers/gpu/drm/via/via_map.c
+++ b/drivers/gpu/drm/via/via_map.c
@@ -105,15 +105,9 @@ int via_driver_load(struct drm_device *dev, unsigned long 
chipset)
dev_priv->chipset = chipset;

idr_init(&dev->object_name_idr);
-   ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
-   if (ret) {
-   kfree(dev_priv);
-   return ret;
-   }

ret = drm_vblank_init(dev, 1);
if (ret) {
-   drm_sman_takedown(&dev_priv->sman);
kfree(dev_priv);
return ret;
}
@@ -125,7 +119,6 @@ int via_driver_unload(struct drm_device *dev)
 {
drm_via_private_t *dev_priv = dev->dev_private;

-   drm_sman_takedown(&dev_priv->sman);
idr_remove_all(&dev_priv->object_idr);
idr_destroy(&dev_priv->object_idr);

diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index af9e771..80eab7d 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -28,26 +28,22 @@
 #include "drmP.h"
 #include "via_drm.h"
 #include "via_drv.h"
-#include "drm_sman.h"

 #define VIA_MM_ALIGN_SHIFT 4
 #define VIA_MM_ALIGN_MASK ((1 << VIA_MM_ALIGN_SHIFT) - 1)

+struct via_memblock {
+   struct drm_mm_node mm_node;
+   struct list_head owner_list;
+};
+
 int via_agp_init(struct drm_device *dev, void *data, struct drm_file 
*file_priv)
 {
drm_via_agp_t *agp = data;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
-   int ret;

mutex_lock(&dev->struct_mutex);
-   ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_AGP, 0,
-agp->size >> VIA_MM_ALIGN_SHIFT);
-
-   if (ret) {
-   DRM_ERROR("AGP memory manager initialisation error\n");
-   mutex_unlock(&dev->struct_mutex);
-   return ret;
-   }
+   drm_mm_init(&dev_priv->agp_mm, 0, agp->size >> VIA_MM_ALIGN_SHIFT);

dev_priv->agp_initialized = 1;
dev_priv->agp_offset = agp->offset;
@@ -61,17 +57,9 @@ int via_fb_init(struct drm_device *dev, void *data, struct 
drm_file *file_priv)
 {
drm_via_fb_t *fb = data;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
-   int ret;

mutex_lock(&dev->struct_mutex);
-   ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_VIDEO, 0,
-fb->size >> VIA_MM_ALIGN_SHIFT);
-
-   if (ret) {
-   DRM_ERROR("VRAM memory manager initialisation error\n");
-   mutex_unlock(&dev->struct_mutex);
-   return ret;
-   }
+   drm_mm_init(&dev_priv->vram_mm, 0, fb->size >> VIA_MM_ALIGN_SHIFT);

dev_priv->vram_initialized = 1;
dev_priv->vram_offset = fb->offset;
@@ -108,9 +96,14 @@ void via_lastclose(struct drm_device *dev)
return;

mutex_lock(&dev->struct_mutex);
-   drm_sman_cleanup(&dev_priv->sman);
-   dev_priv->vram_initialized = 0;
-   dev_priv->agp_initialized = 0;
+   if (dev_priv->vram_initialized) {
+   drm_mm_takedown(&dev_priv->vram_mm);
+   dev_priv->vram_initialized = 0;
+   }
+   if (dev_priv->agp_initialized) {
+   drm_mm_takedown(&dev_priv->agp_mm);
+   dev_priv->agp_initialized = 0;
+   }
mutex_unlock(&dev->struct_mutex);
 }

@@ -119,7 +112,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,
 {
drm_via_mem_t *mem = data;
int retval = 0, user_key;
-   struct drm_memblock_item *item;
+   struct via_memblock *item;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
struct via_file_private *file_priv = file->driver_priv;
unsigned long tmpSize;
@@ 

[PATCH 07/23] drm/sman: kill user_hash_tab

2011-10-27 Thread Daniel Vetter
No longer used.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_sman.c |   36 ++--
 include/drm/drm_sman.h |5 -
 2 files changed, 2 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
index 37a8844..1a4fb9f 100644
--- a/drivers/gpu/drm/drm_sman.c
+++ b/drivers/gpu/drm/drm_sman.c
@@ -46,7 +46,6 @@ struct drm_owner_item {

 void drm_sman_takedown(struct drm_sman * sman)
 {
-   drm_ht_remove(&sman->user_hash_tab);
kfree(sman->mm);
 }

@@ -61,16 +60,11 @@ drm_sman_init(struct drm_sman * sman, unsigned int 
num_managers,
sman->mm = kcalloc(num_managers, sizeof(*sman->mm), GFP_KERNEL);
if (!sman->mm) {
ret = -ENOMEM;
-   goto out;
+   return ret;
}
sman->num_managers = num_managers;
-   ret = drm_ht_create(&sman->user_hash_tab, user_order);
-   if (!ret)
-   goto out;

-   kfree(sman->mm);
-out:
-   return ret;
+   return 0;
 }

 EXPORT_SYMBOL(drm_sman_init);
@@ -179,15 +173,8 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman 
*sman, unsigned int man
memblock->mm = sman_mm;
memblock->sman = sman;

-   if (drm_ht_just_insert_please
-   (&sman->user_hash_tab, &memblock->user_hash,
-(unsigned long)memblock, 32, 0, 0))
-   goto out1;
-
return memblock;

-out1:
-   kfree(memblock);
 out:
sman_mm->free(sman_mm->private, tmp);

@@ -198,31 +185,12 @@ EXPORT_SYMBOL(drm_sman_alloc);

 void drm_sman_free(struct drm_memblock_item *item)
 {
-   struct drm_sman *sman = item->sman;
-
list_del(&item->owner_list);
-   drm_ht_remove_item(&sman->user_hash_tab, &item->user_hash);
item->mm->free(item->mm->private, item->mm_info);
kfree(item);
 }
 EXPORT_SYMBOL(drm_sman_free);

-int drm_sman_free_key(struct drm_sman *sman, unsigned int key)
-{
-   struct drm_hash_item *hash_item;
-   struct drm_memblock_item *memblock_item;
-
-   if (drm_ht_find_item(&sman->user_hash_tab, key, &hash_item))
-   return -EINVAL;
-
-   memblock_item = drm_hash_entry(hash_item, struct drm_memblock_item,
-  user_hash);
-   drm_sman_free(memblock_item);
-   return 0;
-}
-
-EXPORT_SYMBOL(drm_sman_free_key);
-
 void drm_sman_cleanup(struct drm_sman *sman)
 {
unsigned int i;
diff --git a/include/drm/drm_sman.h b/include/drm/drm_sman.h
index 34ae5ca..031e521 100644
--- a/include/drm/drm_sman.h
+++ b/include/drm/drm_sman.h
@@ -87,7 +87,6 @@ struct drm_memblock_item {
 struct drm_sman {
struct drm_sman_mm *mm;
int num_managers;
-   struct drm_open_hash user_hash_tab;
 };

 /*
@@ -139,11 +138,7 @@ extern struct drm_memblock_item *drm_sman_alloc(struct 
drm_sman * sman,
unsigned long size,
unsigned alignment,
unsigned long owner);
-/*
- * Free a memory block identified by its user hash key.
- */

-extern int drm_sman_free_key(struct drm_sman * sman, unsigned int key);
 extern void drm_sman_free(struct drm_memblock_item *item);

 /*
-- 
1.7.7.1



[PATCH 06/23] drm/sis: track user->memblock mapping with idr

2011-10-27 Thread Daniel Vetter
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/sis/sis_drv.c |4 +++
 drivers/gpu/drm/sis/sis_drv.h |2 +
 drivers/gpu/drm/sis/sis_mm.c  |   60 ++--
 drivers/gpu/drm/via/via_map.c |2 +
 4 files changed, 53 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index a5dcd0a..9f5fbcf 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -46,6 +46,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned 
long chipset)

dev->dev_private = (void *)dev_priv;
dev_priv->chipset = chipset;
+   idr_init(&dev->object_name_idr);
ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
if (ret)
kfree(dev_priv);
@@ -58,6 +59,9 @@ static int sis_driver_unload(struct drm_device *dev)
drm_sis_private_t *dev_priv = dev->dev_private;

drm_sman_takedown(&dev_priv->sman);
+   idr_remove_all(&dev_priv->object_idr);
+   idr_destroy(&dev_priv->object_idr);
+
kfree(dev_priv);

return 0;
diff --git a/drivers/gpu/drm/sis/sis_drv.h b/drivers/gpu/drm/sis/sis_drv.h
index 194303c..fcdd06a 100644
--- a/drivers/gpu/drm/sis/sis_drv.h
+++ b/drivers/gpu/drm/sis/sis_drv.h
@@ -60,6 +60,8 @@ typedef struct drm_sis_private {
int agp_initialized;
unsigned long vram_offset;
unsigned long agp_offset;
+   /** Mapping of userspace keys to mm objects */
+   struct idr object_idr;
 } drm_sis_private_t;

 extern int sis_idle(struct drm_device *dev);
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index dff70da..ef6045a 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -125,7 +125,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file,
 {
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_mem_t *mem = data;
-   int retval = 0;
+   int retval = 0, user_key;
struct drm_memblock_item *item;
struct sis_file_private *file_priv = file->driver_priv;

@@ -141,24 +141,46 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file,

mem->size = (mem->size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT;
item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0, 0);
+   if (!item) {
+   retval = -ENOMEM;
+   goto fail_alloc;
+   }

-   if (item) {
-   INIT_LIST_HEAD(&item->owner_list);
-   list_add(&item->owner_list, &file_priv->obj_list);
-   mem->offset = ((pool == 0) ?
- dev_priv->vram_offset : dev_priv->agp_offset) +
-   (item->mm->
-offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT);
-   mem->free = item->user_hash.key;
-   mem->size = mem->size << SIS_MM_ALIGN_SHIFT;
-   } else {
-   mem->offset = 0;
-   mem->size = 0;
-   mem->free = 0;
+again:
+   if (idr_pre_get(&dev_priv->object_idr, GFP_KERNEL) == 0) {
retval = -ENOMEM;
+   goto fail_idr;
}
+
+   /* do the allocation under our spinlock */
+   retval = idr_get_new_above(&dev_priv->object_idr, item, 1, &user_key);
+   if (retval == -EAGAIN)
+   goto again;
+   if (retval)
+   goto fail_idr;
+
+   INIT_LIST_HEAD(&item->owner_list);
+   list_add(&item->owner_list, &file_priv->obj_list);
+   mutex_unlock(&dev->struct_mutex);
+
+   mem->offset = ((pool == 0) ?
+ dev_priv->vram_offset : dev_priv->agp_offset) +
+   (item->mm->
+offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT);
+   mem->free = user_key;
+   mem->size = mem->size << SIS_MM_ALIGN_SHIFT;
+
+   return 0;
+
+fail_idr:
+   drm_sman_free(item);
+fail_alloc:
mutex_unlock(&dev->struct_mutex);

+   mem->offset = 0;
+   mem->size = 0;
+   mem->free = 0;
+
DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem->size,
  mem->offset);

@@ -169,10 +191,18 @@ static int sis_drm_free(struct drm_device *dev, void 
*data, struct drm_file *fil
 {
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_mem_t *mem = data;
+   struct drm_memblock_item *obj;
int ret;

mutex_lock(&dev->struct_mutex);
-   ret = drm_sman_free_key(&dev_priv->sman, mem->free);
+   obj = idr_find(&dev_priv->object_idr, mem->free);
+   if (obj == NULL) {
+   mutex_unlock(&dev->struct_mutex);
+   return -EINVAL;
+   }
+
+   idr_remove(&dev_priv->object_idr, mem->free);
+   drm_sman_free(obj);
mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("free = 0x%lx\n", mem->free);

diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index b09f659..fa5afbc 100644
--- a/drivers/gpu/drm/via/via_ma

[PATCH 05/23] drm/via: track user->memblock mapping with idr

2011-10-27 Thread Daniel Vetter
Massive indirection through a hashtable for a simple key->pointer
look-up actually just adds bloat.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/via/via_drv.h |2 +
 drivers/gpu/drm/via/via_map.c |1 +
 drivers/gpu/drm/via/via_mm.c  |   61 +++--
 3 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index 9cf87d9..108ea71 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -91,6 +91,8 @@ typedef struct drm_via_private {
struct drm_sman sman;
int vram_initialized;
int agp_initialized;
+   /** Mapping of userspace keys to mm objects */
+   struct idr object_idr;
unsigned long vram_offset;
unsigned long agp_offset;
drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES];
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index 6cca9a7..b09f659 100644
--- a/drivers/gpu/drm/via/via_map.c
+++ b/drivers/gpu/drm/via/via_map.c
@@ -104,6 +104,7 @@ int via_driver_load(struct drm_device *dev, unsigned long 
chipset)

dev_priv->chipset = chipset;

+   idr_init(&dev->object_name_idr);
ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
if (ret) {
kfree(dev_priv);
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index ea3d621..af9e771 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -118,7 +118,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,
  struct drm_file *file)
 {
drm_via_mem_t *mem = data;
-   int retval = 0;
+   int retval = 0, user_key;
struct drm_memblock_item *item;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
struct via_file_private *file_priv = file->driver_priv;
@@ -139,24 +139,46 @@ int via_mem_alloc(struct drm_device *dev, void *data,

tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0, 0);
+   if (!item) {
+   retval = -ENOMEM;
+   goto fail_alloc;
+   }

-   if (item) {
-   INIT_LIST_HEAD(&item->owner_list);
-   list_add(&item->owner_list, &file_priv->obj_list);
-   mem->offset = ((mem->type == VIA_MEM_VIDEO) ?
- dev_priv->vram_offset : dev_priv->agp_offset) +
-   (item->mm->
-offset(item->mm, item->mm_info) << VIA_MM_ALIGN_SHIFT);
-   mem->index = item->user_hash.key;
-   } else {
-   mem->offset = 0;
-   mem->size = 0;
-   mem->index = 0;
-   DRM_DEBUG("Video memory allocation failed\n");
+again:
+   if (idr_pre_get(&dev_priv->object_idr, GFP_KERNEL) == 0) {
retval = -ENOMEM;
+   goto fail_idr;
}
+
+   /* do the allocation under our spinlock */
+   retval = idr_get_new_above(&dev_priv->object_idr, item, 1, &user_key);
+   if (retval == -EAGAIN)
+   goto again;
+   if (retval)
+   goto fail_idr;
+
+   INIT_LIST_HEAD(&item->owner_list);
+   list_add(&item->owner_list, &file_priv->obj_list);
mutex_unlock(&dev->struct_mutex);

+   mem->offset = ((mem->type == VIA_MEM_VIDEO) ?
+ dev_priv->vram_offset : dev_priv->agp_offset) +
+   (item->mm->
+offset(item->mm, item->mm_info) << VIA_MM_ALIGN_SHIFT);
+   mem->index = user_key;
+
+   return 0;
+
+fail_idr:
+   drm_sman_free(item);
+fail_alloc:
+   mutex_unlock(&dev->struct_mutex);
+
+   mem->offset = 0;
+   mem->size = 0;
+   mem->index = 0;
+   DRM_DEBUG("Video memory allocation failed\n");
+
return retval;
 }

@@ -164,11 +186,20 @@ int via_mem_free(struct drm_device *dev, void *data, 
struct drm_file *file_priv)
 {
drm_via_private_t *dev_priv = dev->dev_private;
drm_via_mem_t *mem = data;
+   struct drm_memblock_item *obj;
int ret;

mutex_lock(&dev->struct_mutex);
-   ret = drm_sman_free_key(&dev_priv->sman, mem->index);
+   obj = idr_find(&dev_priv->object_idr, mem->index);
+   if (obj == NULL) {
+   mutex_unlock(&dev->struct_mutex);
+   return -EINVAL;
+   }
+
+   idr_remove(&dev_priv->object_idr, mem->index);
+   drm_sman_free(obj);
mutex_unlock(&dev->struct_mutex);
+
DRM_DEBUG("free = 0x%lx\n", mem->index);

return ret;
-- 
1.7.7.1



[PATCH 04/23] drm/sman: rip out owner tracking

2011-10-27 Thread Daniel Vetter
In contrast to kms drivers, sis/via _always_ associated a buffer with
a drm fd. So by the time we reach lastclose, all open drm fds are gone
and with them their associated objects.

So when sis/via call drm_sman_cleanup in their lastclose funcs, that
will free 0 objects.

The owner tracking now serves no purpose at all, hence rip it ou. We
can't kill the corresponding fields in struct drm_memblock_item yet
because we hijack these in the new driver private owner tracking. But
now that drm_sman.c doesn't touch ->owner_list anymore, we need to
kill the list_move hack and properly add the item to the file_priv
list.

Also leave the list_del(&obj->owner_list) in drm_sman_free for the
moment, it will move to the drivers when sman disappears completely.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_sman.c   |   71 --
 drivers/gpu/drm/sis/sis_mm.c |3 +-
 drivers/gpu/drm/via/via_mm.c |3 +-
 include/drm/drm_sman.h   |2 -
 4 files changed, 4 insertions(+), 75 deletions(-)

diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
index a672fea..37a8844 100644
--- a/drivers/gpu/drm/drm_sman.c
+++ b/drivers/gpu/drm/drm_sman.c
@@ -47,7 +47,6 @@ struct drm_owner_item {
 void drm_sman_takedown(struct drm_sman * sman)
 {
drm_ht_remove(&sman->user_hash_tab);
-   drm_ht_remove(&sman->owner_hash_tab);
kfree(sman->mm);
 }

@@ -65,16 +64,10 @@ drm_sman_init(struct drm_sman * sman, unsigned int 
num_managers,
goto out;
}
sman->num_managers = num_managers;
-   INIT_LIST_HEAD(&sman->owner_items);
-   ret = drm_ht_create(&sman->owner_hash_tab, owner_order);
-   if (ret)
-   goto out1;
ret = drm_ht_create(&sman->user_hash_tab, user_order);
if (!ret)
goto out;

-   drm_ht_remove(&sman->owner_hash_tab);
-out1:
kfree(sman->mm);
 out:
return ret;
@@ -160,44 +153,12 @@ drm_sman_set_manager(struct drm_sman * sman, unsigned int 
manager,
 }
 EXPORT_SYMBOL(drm_sman_set_manager);

-static struct drm_owner_item *drm_sman_get_owner_item(struct drm_sman * sman,
-unsigned long owner)
-{
-   int ret;
-   struct drm_hash_item *owner_hash_item;
-   struct drm_owner_item *owner_item;
-
-   ret = drm_ht_find_item(&sman->owner_hash_tab, owner, &owner_hash_item);
-   if (!ret) {
-   return drm_hash_entry(owner_hash_item, struct drm_owner_item,
- owner_hash);
-   }
-
-   owner_item = kzalloc(sizeof(*owner_item), GFP_KERNEL);
-   if (!owner_item)
-   goto out;
-
-   INIT_LIST_HEAD(&owner_item->mem_blocks);
-   owner_item->owner_hash.key = owner;
-   if (drm_ht_insert_item(&sman->owner_hash_tab, &owner_item->owner_hash))
-   goto out1;
-
-   list_add_tail(&owner_item->sman_list, &sman->owner_items);
-   return owner_item;
-
-out1:
-   kfree(owner_item);
-out:
-   return NULL;
-}
-
 struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int 
manager,
unsigned long size, unsigned alignment,
unsigned long owner)
 {
void *tmp;
struct drm_sman_mm *sman_mm;
-   struct drm_owner_item *owner_item;
struct drm_memblock_item *memblock;

BUG_ON(manager >= sman->num_managers);
@@ -223,16 +184,8 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman 
*sman, unsigned int man
 (unsigned long)memblock, 32, 0, 0))
goto out1;

-   owner_item = drm_sman_get_owner_item(sman, owner);
-   if (!owner_item)
-   goto out2;
-
-   list_add_tail(&memblock->owner_list, &owner_item->mem_blocks);
-
return memblock;

-out2:
-   drm_ht_remove_item(&sman->user_hash_tab, &memblock->user_hash);
 out1:
kfree(memblock);
 out:
@@ -270,35 +223,11 @@ int drm_sman_free_key(struct drm_sman *sman, unsigned int 
key)

 EXPORT_SYMBOL(drm_sman_free_key);

-static void drm_sman_remove_owner(struct drm_sman *sman,
- struct drm_owner_item *owner_item)
-{
-   list_del(&owner_item->sman_list);
-   drm_ht_remove_item(&sman->owner_hash_tab, &owner_item->owner_hash);
-   kfree(owner_item);
-}
-
-static void drm_sman_do_owner_cleanup(struct drm_sman *sman,
- struct drm_owner_item *owner_item)
-{
-   struct drm_memblock_item *entry, *next;
-
-   list_for_each_entry_safe(entry, next, &owner_item->mem_blocks,
-owner_list) {
-   drm_sman_free(entry);
-   }
-   drm_sman_remove_owner(sman, owner_item);
-}
-
 void drm_sman_cleanup(struct drm_sman *sman)
 {
-   struct drm_owner_item *entry, *next;
unsigned int i;
struct drm_sman_mm *sman_mm;

-   list_for_each_entry_safe(entry, nex

[PATCH 03/23] drm/sman: kill owner tracking interface functions

2011-10-27 Thread Daniel Vetter
These are now unused.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_sman.c |   38 --
 include/drm/drm_sman.h |   19 ---
 2 files changed, 0 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
index 37548b7..a672fea 100644
--- a/drivers/gpu/drm/drm_sman.c
+++ b/drivers/gpu/drm/drm_sman.c
@@ -278,27 +278,6 @@ static void drm_sman_remove_owner(struct drm_sman *sman,
kfree(owner_item);
 }

-int drm_sman_owner_clean(struct drm_sman *sman, unsigned long owner)
-{
-
-   struct drm_hash_item *hash_item;
-   struct drm_owner_item *owner_item;
-
-   if (drm_ht_find_item(&sman->owner_hash_tab, owner, &hash_item)) {
-   return -1;
-   }
-
-   owner_item = drm_hash_entry(hash_item, struct drm_owner_item, 
owner_hash);
-   if (owner_item->mem_blocks.next == &owner_item->mem_blocks) {
-   drm_sman_remove_owner(sman, owner_item);
-   return -1;
-   }
-
-   return 0;
-}
-
-EXPORT_SYMBOL(drm_sman_owner_clean);
-
 static void drm_sman_do_owner_cleanup(struct drm_sman *sman,
  struct drm_owner_item *owner_item)
 {
@@ -311,23 +290,6 @@ static void drm_sman_do_owner_cleanup(struct drm_sman 
*sman,
drm_sman_remove_owner(sman, owner_item);
 }

-void drm_sman_owner_cleanup(struct drm_sman *sman, unsigned long owner)
-{
-
-   struct drm_hash_item *hash_item;
-   struct drm_owner_item *owner_item;
-
-   if (drm_ht_find_item(&sman->owner_hash_tab, owner, &hash_item)) {
-
-   return;
-   }
-
-   owner_item = drm_hash_entry(hash_item, struct drm_owner_item, 
owner_hash);
-   drm_sman_do_owner_cleanup(sman, owner_item);
-}
-
-EXPORT_SYMBOL(drm_sman_owner_cleanup);
-
 void drm_sman_cleanup(struct drm_sman *sman)
 {
struct drm_owner_item *entry, *next;
diff --git a/include/drm/drm_sman.h b/include/drm/drm_sman.h
index 3b65ccf..d5ed903 100644
--- a/include/drm/drm_sman.h
+++ b/include/drm/drm_sman.h
@@ -149,25 +149,6 @@ extern int drm_sman_free_key(struct drm_sman * sman, 
unsigned int key);
 extern void drm_sman_free(struct drm_memblock_item *item);

 /*
- * returns 1 iff there are no stale memory blocks associated with this owner.
- * Typically called to determine if we need to idle the hardware and call
- * drm_sman_owner_cleanup. If there are no stale memory blocks, it removes all
- * resources associated with owner.
- */
-
-extern int drm_sman_owner_clean(struct drm_sman * sman, unsigned long owner);
-
-/*
- * Frees all stale memory blocks associated with this owner. Note that this
- * requires that the hardware is finished with all blocks, so the graphics 
engine
- * should be idled before this call is made. This function also frees
- * any resources associated with "owner" and should be called when owner
- * is not going to be referenced anymore.
- */
-
-extern void drm_sman_owner_cleanup(struct drm_sman * sman, unsigned long 
owner);
-
-/*
  * Frees all stale memory blocks associated with the memory manager.
  * See idling above.
  */
-- 
1.7.7.1



[PATCH 02/23] drm/via: track obj->drm_fd relations in the driver

2011-10-27 Thread Daniel Vetter
Exactly like the previous patch for sis.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/via/via_drv.c |   25 +
 drivers/gpu/drm/via/via_mm.c  |   22 ++
 include/drm/via_drm.h |4 
 3 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 920a552..472adcf 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -28,6 +28,29 @@

 #include "drm_pciids.h"

+static int via_driver_open(struct drm_device *dev, struct drm_file *file)
+{
+   struct via_file_private *file_priv;
+
+   DRM_DEBUG_DRIVER("\n");
+   file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
+   if (!file_priv)
+   return -ENOMEM;
+
+   file->driver_priv = file_priv;
+
+   INIT_LIST_HEAD(&file_priv->obj_list);
+
+   return 0;
+}
+
+void via_driver_postclose(struct drm_device *dev, struct drm_file *file)
+{
+   struct via_file_private *file_priv = file->driver_priv;
+
+   kfree(file_priv);
+}
+
 static struct pci_device_id pciidlist[] = {
viadrv_PCI_IDS
 };
@@ -38,6 +61,8 @@ static struct drm_driver driver = {
DRIVER_IRQ_SHARED,
.load = via_driver_load,
.unload = via_driver_unload,
+   .open = via_driver_open,
+   .postclose = via_driver_postclose,
.context_dtor = via_final_context,
.get_vblank_counter = via_get_vblank_counter,
.enable_vblank = via_enable_vblank,
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index 6cc2dad..19bb77c 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -115,12 +115,13 @@ void via_lastclose(struct drm_device *dev)
 }

 int via_mem_alloc(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+ struct drm_file *file)
 {
drm_via_mem_t *mem = data;
int retval = 0;
struct drm_memblock_item *item;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
+   struct via_file_private *file_priv = file->driver_priv;
unsigned long tmpSize;

if (mem->type > VIA_MEM_AGP) {
@@ -137,10 +138,10 @@ int via_mem_alloc(struct drm_device *dev, void *data,
}

tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
-   item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0,
- (unsigned long)file_priv);
-   mutex_unlock(&dev->struct_mutex);
+   item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0, 0);
+
if (item) {
+   list_move(&item->owner_list, &file_priv->obj_list);
mem->offset = ((mem->type == VIA_MEM_VIDEO) ?
  dev_priv->vram_offset : dev_priv->agp_offset) +
(item->mm->
@@ -153,6 +154,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,
DRM_DEBUG("Video memory allocation failed\n");
retval = -ENOMEM;
}
+   mutex_unlock(&dev->struct_mutex);

return retval;
 }
@@ -173,12 +175,13 @@ int via_mem_free(struct drm_device *dev, void *data, 
struct drm_file *file_priv)


 void via_reclaim_buffers_locked(struct drm_device *dev,
-   struct drm_file *file_priv)
+   struct drm_file *file)
 {
-   drm_via_private_t *dev_priv = dev->dev_private;
+   struct via_file_private *file_priv = file->driver_priv;
+   struct drm_memblock_item *entry, *next;

mutex_lock(&dev->struct_mutex);
-   if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)file_priv)) {
+   if (list_empty(&file_priv->obj_list)) {
mutex_unlock(&dev->struct_mutex);
return;
}
@@ -186,7 +189,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
if (dev->driver->dma_quiescent)
dev->driver->dma_quiescent(dev);

-   drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)file_priv);
+   list_for_each_entry_safe(entry, next, &file_priv->obj_list,
+owner_list) {
+   drm_sman_free(entry);
+   }
mutex_unlock(&dev->struct_mutex);
return;
 }
diff --git a/include/drm/via_drm.h b/include/drm/via_drm.h
index fd11a5b..79b3b6e 100644
--- a/include/drm/via_drm.h
+++ b/include/drm/via_drm.h
@@ -274,4 +274,8 @@ typedef struct drm_via_dmablit {
drm_via_blitsync_t sync;
 } drm_via_dmablit_t;

+struct via_file_private {
+   struct list_head obj_list;
+};
+
 #endif /* _VIA_DRM_H_ */
-- 
1.7.7.1



[PATCH 01/23] drm/sis: track obj->drm_fd relations in the driver

2011-10-27 Thread Daniel Vetter
By attach a driver private struct to each open drm fd.

Because we steal the owner_list from drm_sman until things settle,
use list_move instead of list_add.

This requires to export a drm_sman function temporarily before
drm_sman will die for real completely.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_sman.c|3 ++-
 drivers/gpu/drm/sis/sis_drv.c |   25 +
 drivers/gpu/drm/sis/sis_mm.c  |   22 ++
 include/drm/drm_sman.h|1 +
 include/drm/sis_drm.h |4 
 5 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
index 3466458..37548b7 100644
--- a/drivers/gpu/drm/drm_sman.c
+++ b/drivers/gpu/drm/drm_sman.c
@@ -243,7 +243,7 @@ out:

 EXPORT_SYMBOL(drm_sman_alloc);

-static void drm_sman_free(struct drm_memblock_item *item)
+void drm_sman_free(struct drm_memblock_item *item)
 {
struct drm_sman *sman = item->sman;

@@ -252,6 +252,7 @@ static void drm_sman_free(struct drm_memblock_item *item)
item->mm->free(item->mm->private, item->mm_info);
kfree(item);
 }
+EXPORT_SYMBOL(drm_sman_free);

 int drm_sman_free_key(struct drm_sman *sman, unsigned int key)
 {
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 46d5be6..a5dcd0a 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -63,10 +63,35 @@ static int sis_driver_unload(struct drm_device *dev)
return 0;
 }

+static int sis_driver_open(struct drm_device *dev, struct drm_file *file)
+{
+   struct sis_file_private *file_priv;
+
+   DRM_DEBUG_DRIVER("\n");
+   file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
+   if (!file_priv)
+   return -ENOMEM;
+
+   file->driver_priv = file_priv;
+
+   INIT_LIST_HEAD(&file_priv->obj_list);
+
+   return 0;
+}
+
+void sis_driver_postclose(struct drm_device *dev, struct drm_file *file)
+{
+   struct sis_file_private *file_priv = file->driver_priv;
+
+   kfree(file_priv);
+}
+
 static struct drm_driver driver = {
.driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR,
.load = sis_driver_load,
.unload = sis_driver_unload,
+   .open = sis_driver_open,
+   .postclose = sis_driver_postclose,
.dma_quiescent = sis_idle,
.reclaim_buffers = NULL,
.reclaim_buffers_idlelocked = sis_reclaim_buffers_locked,
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index 7fe2b63..a70b1bb 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -120,13 +120,14 @@ static int sis_fb_init(struct drm_device *dev, void 
*data, struct drm_file *file
return 0;
 }

-static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv,
+static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,
 void *data, int pool)
 {
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_mem_t *mem = data;
int retval = 0;
struct drm_memblock_item *item;
+   struct sis_file_private *file_priv = file->driver_priv;

mutex_lock(&dev->struct_mutex);

@@ -139,11 +140,10 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file_priv,
}

mem->size = (mem->size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT;
-   item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0,
- (unsigned long)file_priv);
+   item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0, 0);

-   mutex_unlock(&dev->struct_mutex);
if (item) {
+   list_move(&item->owner_list, &file_priv->obj_list);
mem->offset = ((pool == 0) ?
  dev_priv->vram_offset : dev_priv->agp_offset) +
(item->mm->
@@ -156,6 +156,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file_priv,
mem->free = 0;
retval = -ENOMEM;
}
+   mutex_unlock(&dev->struct_mutex);

DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem->size,
  mem->offset);
@@ -301,12 +302,13 @@ void sis_lastclose(struct drm_device *dev)
 }

 void sis_reclaim_buffers_locked(struct drm_device *dev,
-   struct drm_file *file_priv)
+   struct drm_file *file)
 {
-   drm_sis_private_t *dev_priv = dev->dev_private;
+   struct sis_file_private *file_priv = file->driver_priv;
+   struct drm_memblock_item *entry, *next;

mutex_lock(&dev->struct_mutex);
-   if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)file_priv)) {
+   if (list_empty(&file_priv->obj_list)) {
mutex_unlock(&dev->struct_mutex);
return;
}
@@ -314,7 +316,11 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
if (dev->driver->dma_quiescent)
de

[PATCH 00/23] kill drm cruft with fire

2011-10-27 Thread Daniel Vetter
Hi all,

It's that time of the year again when the weather gets crappy, people
depressed and danvet wades through drm cruft. Not that any of this is
related in any way.

Actually I only wanted to port users of drm_mm to the new interfaces,
completing a work I've started a while ago. It lead to a littel detour.

Patches 1-10 kill drm_sman (hereby reducing the number of users of the old
drm_mm interface by one). I don't have either sis or via hw but given
- how lightly the dri1 removal went down
- you can't really ebay this hw anymore (at least not here, I've tried)
- and that no one really changes much in them anymore (last time was me a
  year ago, killing cruft)

I think the risk is worth it. Worst case I expect to some oops-decoding
because this doesn't change neither userspace nor hw facing code, only pure
kernel book-keeping.

Patches 11-17 clean the reclaim_buffers support by the drm core by moving
everything into driver specific preclose functions. I've noticed this
horrid stuff while writing the buffer tracking code for via/sis.

Patches 18-20 rip out the dma queue code, which was totally unused. The two
risky steps of that surgery are split out.

Patches 21-23 finish this series by killing a few random smaller things
I've noticed.

Entire pile tested on my i810, that's the last fully working dri1 setup I
still have. The reclaim_buffers rework actually improves things there.

Two patches have a potential userspace abi impact, one is i810 specific
(didn't break anything in testing), the other breaks libdrm that is older
than 10 years (by killing proc).

The drm fd release path looks now much less scary with this series (mostly
due to the reclaim_buffers rework), but there's still the context support
seemingly only used by via left. I might look into that as soon as I can
get these images of horribly slaugthered kittens out of my brain ...

Review, flames highly welcome.

Cheers, Daniel

Daniel Vetter (23):
  drm/sis: track obj->drm_fd relations in the driver
  drm/via: track obj->drm_fd relations in the driver
  drm/sman: kill owner tracking interface functions
  drm/sman: rip out owner tracking
  drm/via: track user->memblock mapping with idr
  drm/sis: track user->memblock mapping with idr
  drm/sman: kill user_hash_tab
  drm/via: use drm_mm instead of drm_sman
  drm/sis: use drm_mm instead of drm_sman
  drm: kill drm_sman

  drm/via: clean up reclaim_buffers
  drm/sis: clean up reclaim_buffers
  drm: kill reclaim_buffers_idlelocked functions
  drm/i810: cleanup reclaim_buffers
  drm: kill reclaim_buffers_locked
  drm/savage: clean up reclaim_buffers
  drm: kill reclaim_buffers callback

  drm: ditch strange DRIVER_DMA_QUEUE only error bail-out
  drm: kill dma queue support
  drm: unconditionally clean up dma buffers of closing clients

  drm: kill i915/i830 ids from drm_pciids.h
  drm: kill procfs support
  drm: kill a few unused remnants from drm_memory.c

 drivers/gpu/drm/Makefile  |4 +-
 drivers/gpu/drm/drm_bufs.c|   16 +--
 drivers/gpu/drm/drm_debugfs.c |1 -
 drivers/gpu/drm/drm_dma.c |5 -
 drivers/gpu/drm/drm_drv.c |   19 --
 drivers/gpu/drm/drm_fops.c|   63 +--
 drivers/gpu/drm/drm_info.c|   36 
 drivers/gpu/drm/drm_lock.c|6 +-
 drivers/gpu/drm/drm_memory.c  |   19 --
 drivers/gpu/drm/drm_proc.c|  221 -
 drivers/gpu/drm/drm_sman.c|  350 -
 drivers/gpu/drm/drm_stub.c|   25 +--
 drivers/gpu/drm/i810/i810_dma.c   |   17 +-
 drivers/gpu/drm/i810/i810_drv.c   |3 +-
 drivers/gpu/drm/i810/i810_drv.h   |6 +-
 drivers/gpu/drm/i915/i915_drv.c   |1 -
 drivers/gpu/drm/mga/mga_drv.c |1 -
 drivers/gpu/drm/nouveau/nouveau_drv.c |1 -
 drivers/gpu/drm/r128/r128_drv.c   |1 -
 drivers/gpu/drm/radeon/radeon_drv.c   |2 -
 drivers/gpu/drm/savage/savage_bci.c   |7 +-
 drivers/gpu/drm/savage/savage_drv.c   |2 +-
 drivers/gpu/drm/sis/sis_drv.c |   36 +++-
 drivers/gpu/drm/sis/sis_drv.h |7 +-
 drivers/gpu/drm/sis/sis_mm.c  |  210 
 drivers/gpu/drm/tdfx/tdfx_drv.c   |1 -
 drivers/gpu/drm/via/via_drv.c |   29 +++-
 drivers/gpu/drm/via/via_drv.h |7 +-
 drivers/gpu/drm/via/via_map.c |   10 +-
 drivers/gpu/drm/via/via_mm.c  |  145 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |1 -
 drivers/staging/gma500/psb_drv.c  |1 -
 include/drm/drmP.h|   28 +---
 include/drm/drm_pciids.h  |   42 
 include/drm/drm_sman.h|  176 -
 include/drm/sis_drm.h |4 +
 include/drm/via_drm.h |4 +
 37 files changed, 337 insertions(+), 1170 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_proc.c
 delete mode 100644 drivers/gpu/drm/drm_sman.c
 delete mode 1006

nouveau page_flip function implement not wait vblank, which cause screen garbage

2011-10-27 Thread Francisco Jerez
ems to be, the actual page flipping is done by software method
>>>>> (see nv04_graph_mthd_page_flip). There is one thing i'm unsure about
>>>>> and that is that we wait for the rendering to be done to the current
>>>>> frontbuffer and not the current backbuffer (this is only done if the
>>>>> page flip channel is different than the rendering channel). Maybe
>>>>> someone else can comment on that.
>>>>>  
>>>> There's no need to wait for the backbuffer rendering to end because the
>>>> pageflip is always pushed through the last channel that has queued
>>>> rendering to it, so, the "waiting" is actually done by the GPU. The
>>>> waiting to the current frontbuffer (which in most cases is going to be a
>>>> cross-channel barrier instead of actual CPU waiting) is necessary for
>>>> the (rare) case where you have several channels trying to render to the
>>>> same pageflipped drawable, to make sure that the flips are properly
>>>> synchronized with respect each other.
>>>> ___
>>>> dri-devel mailing list
>>>> dri-devel at lists.freedesktop.org
>>>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>>>>
>>>
>>> ___
>>> dri-devel mailing list
>>> dri-devel at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>>>  
>> ___
>> dri-devel mailing list
>> dri-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>
>
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 229 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20111027/a627a592/attachment.pgp>


[PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Daniel Vetter
On Wed, Oct 26, 2011 at 05:33:24PM -0500, Ilija Hadzic wrote:
> Is DRM support for other OS-es officially dead ? I know it's not in
> best shape on BSD and friends, but I am not sure if I should make it
> worse (or inconsistent with the current code shape and form).

I think the idea of sharing kernel drm code is pretty much dead, yeah.

> main()
> {
> int fd;
> drmVBlank vbl;
> 
> fd = open("/dev/dri/card0", 0);
> printf("fd=%d\n", fd);
> 
> while(1) {
> vbl.request.type =  DRM_VBLANK_RELATIVE ;
> vbl.request.sequence = 60;
> printf("waiting on vblank\n");
> ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
> }
> }
> 
> Then start glxgears (on CRTC-0) and watch the hell break loose. The
> hostile code will cause any OpenGL application to hang for a full
> second before it can even enter the vblank_wait. Now because all
> vblank waits go through a common function in DDX, the whole
> windowing system will consequently go into a crawl. Run it with
> Compiz and things are even worse (the whole windowing system goes
> "stupid" as soon as the hostile application is started).

This is really just horrible.
> 
> 
> >>+   add_wait_queue(&(queue), &entry);   \
> >>+   mutex_unlock(&drm_global_mutex);\
> >
> >Hiding a lock-dropping in this fashion is horrible.
> 
> I explained above why am I have to release the lock inside the
> macro. That's equivalent to what you can find in the userland in
> POSIX threads, like I said. So that's not bad.

I disagree - this is just the blk magic reinvented. Also I don't like to
rush locking changes, because the hard part is reviewing all the drivers,
and I prefer to do that just once for the real solution.

Also explaining locking changes (especially in drm) starting with
"assuming the old code is correct, this is safe" isn't great. Because your
changes might simply enlarge the already existing race.

On a quick glance
- drm_vblank functions call by wait_vblank seem to do correct locking
  already using various spinlocks and atomic ops.
- linux waitqueues have their own locking
- dev->last_vblank_wait is only used for a procfs file. I don't think it
  makes much sense given that we can have more than one vblank waiter
- there's no selective wakeup going on, all waiters get woken for every
  vblank and call schedule again if it's not the right vblank

The only really hairy thing going on is racing modeset ioctls against
vblank waiters. But modeset is protected by the dev->mode_config.mutex
and hence already races against wait_vblank with the current code, so I'm
slightly inclined to ignore this for the moment. Would be great if you
coudl check that in-depth, too.

So I think the right thing to do is
- Kill dev->last_vblank_wait (in a prep patch).
- Imo we also have a few too many atomic ops going on, e.g.
  dev->vblank_refcount looks like it's atomic only because or the procfs
  file, so maybe kill that procfs file entirely.
- Audit the vblank locking, maybe resulting in a patch with updated
  comments, if there's anything misleading or tricky going on. And it's
  always good when the locking of structe members is explained in the
  header file ...
- Drop the mutex locking because it's not needed.

While locking at the code I also noticed that wait_vblank calls
drm_vblank_get, but not always drm_vblank_put. The code is correct, the
missing vblank_put is hidden in drm_queue_vblank_event. Can you also write
the patch to move that around to not trip up reviewers the next time
around?

Yours, Daniel
- 
-- 
Daniel Vetter
Mail: daniel at ffwll.ch
Mobile: +41 (0)79 365 57 48


[PATCH] drm/radeon: flush read cache for gtt with fence on r6xx and newer GPU V3

2011-10-27 Thread Alex Deucher
On Wed, Oct 26, 2011 at 11:41 AM,   wrote:
> From: Jerome Glisse 
>
> Cayman seems to be particularly sensitive to read cache returning
> old data after bind/unbind to GTT. Flush read cache for GTT range
> with each fences for all new hw. Should fix several rendering glitches.
> Like
>
> V2 flush whole address space
> V3 also flush shader read cache
>
> https://bugs.freedesktop.org/show_bug.cgi?id=40221
> https://bugs.freedesktop.org/show_bug.cgi?id=38022
> https://bugzilla.redhat.com/show_bug.cgi?id=738790
>
> Signed-off-by: Jerome Glisse 
> ---
> ?drivers/gpu/drm/radeon/evergreen_blit_kms.c | ? ?4 ++--
> ?drivers/gpu/drm/radeon/r600.c ? ? ? ? ? ? ? | ? 16 
> ?drivers/gpu/drm/radeon/r600_blit_kms.c ? ? ?| ? ?4 ++--
> ?3 files changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c 
> b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> index dcf11bb..e9aeeed 100644
> --- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> +++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> @@ -613,9 +613,9 @@ int evergreen_blit_init(struct radeon_device *rdev)
> ? ? ? ?rdev->r600_blit.primitives.set_default_state = set_default_state;
>
> ? ? ? ?rdev->r600_blit.ring_size_common = 55; /* shaders + def state */
> - ? ? ? rdev->r600_blit.ring_size_common += 10; /* fence emit for VB IB */
> + ? ? ? rdev->r600_blit.ring_size_common += 16; /* fence emit for VB IB */
> ? ? ? ?rdev->r600_blit.ring_size_common += 5; /* done copy */
> - ? ? ? rdev->r600_blit.ring_size_common += 10; /* fence emit for done copy */
> + ? ? ? rdev->r600_blit.ring_size_common += 16; /* fence emit for done copy */
>
> ? ? ? ?rdev->r600_blit.ring_size_per_loop = 74;
>
> diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
> index 12470b0..1f007ad 100644
> --- a/drivers/gpu/drm/radeon/r600.c
> +++ b/drivers/gpu/drm/radeon/r600.c
> @@ -2331,6 +2331,14 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
> ? ? ? ?if (rdev->wb.use_event) {
> ? ? ? ? ? ? ? ?u64 addr = rdev->wb.gpu_addr + R600_WB_EVENT_OFFSET +
> ? ? ? ? ? ? ? ? ? ? ? ?(u64)(rdev->fence_drv.scratch_reg - 
> rdev->scratch.reg_base);

We need to specify the vmid on cayman, so we should probably add the
following here:

if (rdev->family >= CHIP_CAYMAN) {
/* CP_COHER_CNTL2 has to be set manually when
submitting a surface_sync
 * to the RB directly. For IBs, the CP programs this
as part of the
 * surface_sync packet.
 */
radeon_ring_write(rdev, PACKET3(PACKET3_SET_CONFIG_REG, 1));
radeon_ring_write(rdev, (0x85e8 -
PACKET3_SET_CONFIG_REG_START) >> 2);
radeon_ring_write(rdev, 0); /* CP_COHER_CNTL2 */
}


> + ? ? ? ? ? ? ? /* flush read cache over gart */
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, PACKET3(PACKET3_SURFACE_SYNC, 3));
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, PACKET3_TC_ACTION_ENA |
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PACKET3_VC_ACTION_ENA |
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PACKET3_SH_ACTION_ENA);
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, 0x);
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, 0);
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, 10); /* poll interval */
> ? ? ? ? ? ? ? ?/* EVENT_WRITE_EOP - flush caches, send int */
> ? ? ? ? ? ? ? ?radeon_ring_write(rdev, PACKET3(PACKET3_EVENT_WRITE_EOP, 4));
> ? ? ? ? ? ? ? ?radeon_ring_write(rdev, 
> EVENT_TYPE(CACHE_FLUSH_AND_INV_EVENT_TS) | EVENT_INDEX(5));
> @@ -2339,6 +2347,14 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
> ? ? ? ? ? ? ? ?radeon_ring_write(rdev, fence->seq);
> ? ? ? ? ? ? ? ?radeon_ring_write(rdev, 0);
> ? ? ? ?} else {
> + ? ? ? ? ? ? ? /* flush read cache over gart */
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, PACKET3(PACKET3_SURFACE_SYNC, 3));
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, PACKET3_TC_ACTION_ENA |
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PACKET3_VC_ACTION_ENA |
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PACKET3_SH_ACTION_ENA);
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, 0x);
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, 0);
> + ? ? ? ? ? ? ? radeon_ring_write(rdev, 10); /* poll interval */
> ? ? ? ? ? ? ? ?radeon_ring_write(rdev, PACKET3(PACKET3_EVENT_WRITE, 0));
> ? ? ? ? ? ? ? ?radeon_ring_write(rdev, EVENT_TYPE(CACHE_FLUSH_AND_INV_EVENT) 
> | EVENT_INDEX(0));
> ? ? ? ? ? ? ? ?/* wait for 3D idle clean */
> diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c 
> b/drivers/gpu/drm/radeon/r600_blit_kms.c
> index c4cf130..36e62f2 100644
> --- a/drivers/gpu/drm/radeon/r600_blit_kms.c
> +++ b/drivers/gpu/drm/radeon/r600_blit_kms.c
> @@ -500,9 +500,9 @@ int r600_blit_init(struct radeon_device *rdev)
> ? ? ? ?rdev->r600_blit.primitives.set_default_state = set_default_state;
>
> ? ? ? ?rdev->r600_blit.ring_size_common = 40; /* shaders + def state */
> - ? ? ? rdev->r600_blit.ring_size_common += 10; /* fence emit for VB IB */
> + ? ? ? rdev->r600_blit.ring_size_common += 16; /* fence emit

[git pull] drm rc1 tree

2011-10-27 Thread Dave Airlie

Hi Linus,

this is the main pull request for the drm tree, I've got some more stuff 
coming but it all looks like -fixes stuff so no reason to hold this up 
which I had ready pre-ks except for some reverts off a radeon/ttm feature 
that wasn't what we wanted yet.

Highlights:
Samsung: exynos SoC modesetting driver (no accel support/interfaces).
vmwgfx: driver moves out of staging and has supportable ABI.
nouveau: displayport rewrite and 0xd9 gpu modesetting code
radeon: general fixes + blit speedups
intel: Apple Macbook Air fixes, RHEL stabilisation fixes.

Also a whole bunch of deinlining of insane stuff from Andi, 

This tree also contains some cross-over with dwmw2 on iommu fixes, as we
weren't sure what the merge plan was for them, but they shouldn't 
conflict, and had to be in this tree just to let me test them usefully.

/me goes back to looking for replacement cars :)

Dave.

The following changes since commit 899e3ee404961a90b828ad527573c39f0ab1:

  Linux 3.1-rc10 (2011-10-17 21:06:23 -0700)

are available in the git repository at:
  git://people.freedesktop.org/~airlied/linux.git drm-core-next

Adam Jackson (9):
  drm: Add KMS debug printk's for encoder and crtc fixup failure
  drm/i915: Remove "i2c_speed" nonsense from child device table
  drm/i915: Fix multifunction SDVO detection
  drm/i915: Rename intel_sdvo_hdmi_sink_detect
  drm/i915: Remove redundant bit shifting from intel_gmbus_set_speed
  drm/i915/dp: Fix the math in intel_dp_link_required
  drm/i915/dp: Remove eDP special cases from bandwidth checks
  drm/i915/dp: Introduce is_cpu_edp()
  drm/i915/dp: Fix eDP on PCH DP on CPT/PPT

Akshay Joshi (1):
  Drivers: i915: Fix all space related issues.

Alex Deucher (5):
  drm/radeon/kms: bail early in dvi_detect for digital only connectors
  drm/radeon/kms: handle !force case in connector detect more gracefully
  drm/radeon/kms: set DMA mask properly on newer PCI asics
  drm/radeon/kms: simplify r6xx blit code
  drm/radeon/kms: make r600-NI blit suspend code common

Andi Kleen (7):
  drm/radeon: Drop inlines from evergreen_cs.c / r600_cs.c
  drm/radeon: drop inlines in r600_blit.c
  drm/radeon: Remove now unused functions in radeon driver
  drm/radeon: Remove more bogus inlines in the radeon driver.
  drm/radeon: Move more code out of line
  drm/radeon: Move r100_*_*reg out of line
  i915: Move i915_read/write out of line

Ben Skeggs (105):
  drm/nouveau/pm: store voltage in microvolts
  drm/nouveau/pm: initial attempt at parsing volt 0x40
  drm/nouveau/pm: add yet another vid gpio tag
  drm/nouveau/pm: add support for parsing perflvl voltage on fermi chips
  drm/nouveau/pm: show any info we can manage to glean on current perflvl
  drm/nvc0/pm: enable voltage_get
  drm/nouveau/pm: allow voltage-only perflvl set, enable nvc0
  drm/nouveau/pm: some fermi chipsets still use volt 0x30
  drm/nva3/pm: rewrite clock readback functions, far more correct now
  drm/nouveau/pm: add hooks to get/set *all* clocks at once
  drm/nva3/pm: rewrite clock_set, and switch to new interfaces
  drm/nva3/pm: parse/reclock vdec/41a0 clocks
  drm/nva3/pm: tidy and add some comments here and there
  drm/nv50/gr: insert set/clr of a ctxprog flag at start/end of ctxprog
  drm/nouveau: add function to wait until a callback returns true
  drm/nva3/pm: idle graphics engine before changing clocks
  drm/nvc0/pm: initial implementation of clocks_get()
  drm/nvc0/pm: more complete parsing of clock domains
  drm/nouveau: rename nv40_mpeg to nv31_mpeg
  drm/nv31/mpeg: support for a single class3174 user
  drm/nouveau: embed nouveau_mm
  drm/nouveau: allow a nouveau_mm to be created with holes
  drm/nvc0/gr: add support for nvcf chipset
  drm/nvc0/vram: support non-uniform memory size per controller
  drm/nvc0/gr: copy GPC mpart config from PFFB
  drm/nouveau: don't complain for disabled timingset entries
  drm/nvc0/gr: unblacklist nvcf acceleration
  drm/nouveau/tmr: calibrate for ns timestamps on init
  drm/nvd0: add a card_type for 0xdX chipsets
  drm/nouveau: make general drm modesetting init common
  drm/nouveau: fixup init/fini sequence to deal with no CRTCs
  drm/nouveau: allow modeset module option to select 'headless mode'
  drm/nouveau: initial chipset description for nvdX chipsets
  drm/nvd0/i2c: initial implementation
  drm/nvd0/gpio: initial implementation
  drm/nouveau/bios: fix INIT_GPIO for new chipsets
  drm/nvd0/pm: enable clock/voltage hooks
  drm/nouveau/bios: allow passing in crtc to the init table parser
  drm/nvd0/disp: very initial evo setup
  drm/nvd0/disp: whip up some basic dma handling for the evo channels
  drm/nvd0/disp: start on interrupt handling
  drm/nvd0/disp: setup a couple of dma objects we'll need
  drm/nvd0/disp: start on SOR encoder

nouveau page_flip function implement not wait vblank, which cause screen garbage

2011-10-27 Thread Thomas Hellstrom
FWIW, there was a quite long discussion / argument when the page flip 
ioctl was designed, and at that time
I pointed out that there are hardware capable of pageflipping using the 
fifo/pipe with optional VSYNC barriers, and that it is actually possible 
to queue up a number of pageflips in the fifo. Not just one.

The interface description in drm_mode.h is somewhat different to what 
was agreed upon, namely:

1) The command submission mechanism should block if a user tries to 
render to a not yet flipped frontbuffer, and that would cause rendering 
problems. For hardware that flips using a fifo / pipe, that's not really 
a problem. Thus, any rendering errors due to rendering to a 
not-yet-flipped frontbuffer is a kernel driver error.
The user-space app can avoid being blocked waiting using events.

2) The interface in itself doesn't require flips to be synced to 
vblanks, as I understand it.
  However, it should be possible to add a new flag 
DRM_MODE_PAGE_FLIP_SYNC that tries to sync if at all possible.

/Thomas


On 10/27/2011 10:00 AM, chris wrote:
> I think page_flip ioctl need to realize a synchronous mechanism to control 
> fresh rate...!!!
> At 2011-10-25 20:30:39,"Ben Skeggs"  wrote:
>
>> On Tue, 2011-10-25 at 14:15 +0200, Francisco Jerez wrote:
>>  
>>> Maarten Maathuis  writes:
>>>
>>>
 2011/10/25 chris:
  
> Can anyone give a suggestion, is wait-vblank fully implemented in
> page_flip() for nouveau drm driver?
>
>
>>> It's intentionally not implemented.  The reason is that I wanted to
>>> support non-vsync'ed vblank as well, and for vsync'ed blits we had to
>>> think about a different mechanism for vblank synchronization anyway, so
>>> I figured it didn't make that much sense to force vblank synchronization
>>> directly from the pageflip ioctl.
>>>
>> +1 I deliberately didn't flip 1 bit in the NV50/NVC0 page flipping code
>> for this as well.  The interface IMO is flawed.  Though, that said, we
>> really should look at doing something properly for this, a lot of people
>> do want tear-free goodness.
>>
>> Ben.
>>  
>>>
> At 2011-10-24 14:30:55,chris  wrote:
>
> Dear,
>
> I use NVidia Geforce 7300GT graphics card in my PC, and Linux 3.1rc4 
> kernel
> code, git drm 2.4.36.
>When I run the vbltest program, it prints  "60HZ"  which indicated the
> implementation of drmWaitVBlank() and drm_vblank_wait()  is correct.
>But when I run modetest with option " -v -s 12:1280x1024" , it prints 
> high
> fresh rate up to "150 HZ" .  I examing the code , and found that no 
> waiting
> vblank operation is processed in nouveau_crtc_ page_flip() function. The
> screen  produced lots of garbage and blink very much.
>
>>> That's fine if by "garbage" you just mean it's tearing like crazy.
>>>
>>>
> [...]
>
 It seems to be, the actual page flipping is done by software method
 (see nv04_graph_mthd_page_flip). There is one thing i'm unsure about
 and that is that we wait for the rendering to be done to the current
 frontbuffer and not the current backbuffer (this is only done if the
 page flip channel is different than the rendering channel). Maybe
 someone else can comment on that.
  
>>> There's no need to wait for the backbuffer rendering to end because the
>>> pageflip is always pushed through the last channel that has queued
>>> rendering to it, so, the "waiting" is actually done by the GPU. The
>>> waiting to the current frontbuffer (which in most cases is going to be a
>>> cross-channel barrier instead of actual CPU waiting) is necessary for
>>> the (rare) case where you have several channels trying to render to the
>>> same pageflipped drawable, to make sure that the flips are properly
>>> synchronized with respect each other.
>>> ___
>>> dri-devel mailing list
>>> dri-devel at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>>>
>>
>> ___
>> dri-devel mailing list
>> dri-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>>  
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>





Re: [PATCH] drm/radeon: flush read cache for gtt with fence on r6xx and newer GPU V3

2011-10-27 Thread Jerome Glisse
On Thu, Oct 27, 2011 at 12:12:09PM -0400, Alex Deucher wrote:
> On Wed, Oct 26, 2011 at 11:41 AM,   wrote:
> > From: Jerome Glisse 
> >
> > Cayman seems to be particularly sensitive to read cache returning
> > old data after bind/unbind to GTT. Flush read cache for GTT range
> > with each fences for all new hw. Should fix several rendering glitches.
> > Like
> >
> > V2 flush whole address space
> > V3 also flush shader read cache
> >
> > https://bugs.freedesktop.org/show_bug.cgi?id=40221
> > https://bugs.freedesktop.org/show_bug.cgi?id=38022
> > https://bugzilla.redhat.com/show_bug.cgi?id=738790
> >
> > Signed-off-by: Jerome Glisse 
> > ---
> >  drivers/gpu/drm/radeon/evergreen_blit_kms.c |    4 ++--
> >  drivers/gpu/drm/radeon/r600.c               |   16 
> >  drivers/gpu/drm/radeon/r600_blit_kms.c      |    4 ++--
> >  3 files changed, 20 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c 
> > b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> > index dcf11bb..e9aeeed 100644
> > --- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> > +++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> > @@ -613,9 +613,9 @@ int evergreen_blit_init(struct radeon_device *rdev)
> >        rdev->r600_blit.primitives.set_default_state = set_default_state;
> >
> >        rdev->r600_blit.ring_size_common = 55; /* shaders + def state */
> > -       rdev->r600_blit.ring_size_common += 10; /* fence emit for VB IB */
> > +       rdev->r600_blit.ring_size_common += 16; /* fence emit for VB IB */
> >        rdev->r600_blit.ring_size_common += 5; /* done copy */
> > -       rdev->r600_blit.ring_size_common += 10; /* fence emit for done copy 
> > */
> > +       rdev->r600_blit.ring_size_common += 16; /* fence emit for done copy 
> > */
> >
> >        rdev->r600_blit.ring_size_per_loop = 74;
> >
> > diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
> > index 12470b0..1f007ad 100644
> > --- a/drivers/gpu/drm/radeon/r600.c
> > +++ b/drivers/gpu/drm/radeon/r600.c
> > @@ -2331,6 +2331,14 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
> >        if (rdev->wb.use_event) {
> >                u64 addr = rdev->wb.gpu_addr + R600_WB_EVENT_OFFSET +
> >                        (u64)(rdev->fence_drv.scratch_reg - 
> > rdev->scratch.reg_base);
> 
> We need to specify the vmid on cayman, so we should probably add the
> following here:
> 
> if (rdev->family >= CHIP_CAYMAN) {
> /* CP_COHER_CNTL2 has to be set manually when
> submitting a surface_sync
>  * to the RB directly. For IBs, the CP programs this
> as part of the
>  * surface_sync packet.
>  */
> radeon_ring_write(rdev, PACKET3(PACKET3_SET_CONFIG_REG, 1));
> radeon_ring_write(rdev, (0x85e8 -
> PACKET3_SET_CONFIG_REG_START) >> 2);
> radeon_ring_write(rdev, 0); /* CP_COHER_CNTL2 */
> }
> 

I think default cayman blit state already does specify vmid so we should
be fine.

Cheers,
Jerome
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Ilija Hadzic


On Thu, 27 Oct 2011, Alan Coopersmith wrote:

>> 
>> I think the idea of sharing kernel drm code is pretty much dead, yeah.
>
> We are still trying to keep it alive, despite what some may think.
>

In the context of this patch (in progress), it's probably a moot topic 
because per comments that Daniel sent, most of the locks in 
drm_vblank_wait will become unecessary after I rework the patch
and I won't need to introduce (new) DRM_WAIT_ON_LOCKED any more.

I will, however, *not* convert existing DRM_WAIT_ON to a Linux-centric 
function, so I will not be the one to kill (or contribute to the killing 
of) the portability of that file. That I leave to someone else ;-).

P.S. If the "fight" starts I will side with the "keep the portability 
alive" camp. I have "emotional" ties with other (less widely used) 
operating systems. ;-)

-- Ilija


Re: [PATCH] drm/radeon: flush read cache for gtt with fence on r6xx and newer GPU V3

2011-10-27 Thread Alex Deucher
On Wed, Oct 26, 2011 at 11:41 AM,   wrote:
> From: Jerome Glisse 
>
> Cayman seems to be particularly sensitive to read cache returning
> old data after bind/unbind to GTT. Flush read cache for GTT range
> with each fences for all new hw. Should fix several rendering glitches.
> Like
>
> V2 flush whole address space
> V3 also flush shader read cache
>
> https://bugs.freedesktop.org/show_bug.cgi?id=40221
> https://bugs.freedesktop.org/show_bug.cgi?id=38022
> https://bugzilla.redhat.com/show_bug.cgi?id=738790
>
> Signed-off-by: Jerome Glisse 
> ---
>  drivers/gpu/drm/radeon/evergreen_blit_kms.c |    4 ++--
>  drivers/gpu/drm/radeon/r600.c               |   16 
>  drivers/gpu/drm/radeon/r600_blit_kms.c      |    4 ++--
>  3 files changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c 
> b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> index dcf11bb..e9aeeed 100644
> --- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> +++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
> @@ -613,9 +613,9 @@ int evergreen_blit_init(struct radeon_device *rdev)
>        rdev->r600_blit.primitives.set_default_state = set_default_state;
>
>        rdev->r600_blit.ring_size_common = 55; /* shaders + def state */
> -       rdev->r600_blit.ring_size_common += 10; /* fence emit for VB IB */
> +       rdev->r600_blit.ring_size_common += 16; /* fence emit for VB IB */
>        rdev->r600_blit.ring_size_common += 5; /* done copy */
> -       rdev->r600_blit.ring_size_common += 10; /* fence emit for done copy */
> +       rdev->r600_blit.ring_size_common += 16; /* fence emit for done copy */
>
>        rdev->r600_blit.ring_size_per_loop = 74;
>
> diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
> index 12470b0..1f007ad 100644
> --- a/drivers/gpu/drm/radeon/r600.c
> +++ b/drivers/gpu/drm/radeon/r600.c
> @@ -2331,6 +2331,14 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
>        if (rdev->wb.use_event) {
>                u64 addr = rdev->wb.gpu_addr + R600_WB_EVENT_OFFSET +
>                        (u64)(rdev->fence_drv.scratch_reg - 
> rdev->scratch.reg_base);

We need to specify the vmid on cayman, so we should probably add the
following here:

if (rdev->family >= CHIP_CAYMAN) {
/* CP_COHER_CNTL2 has to be set manually when
submitting a surface_sync
 * to the RB directly. For IBs, the CP programs this
as part of the
 * surface_sync packet.
 */
radeon_ring_write(rdev, PACKET3(PACKET3_SET_CONFIG_REG, 1));
radeon_ring_write(rdev, (0x85e8 -
PACKET3_SET_CONFIG_REG_START) >> 2);
radeon_ring_write(rdev, 0); /* CP_COHER_CNTL2 */
}


> +               /* flush read cache over gart */
> +               radeon_ring_write(rdev, PACKET3(PACKET3_SURFACE_SYNC, 3));
> +               radeon_ring_write(rdev, PACKET3_TC_ACTION_ENA |
> +                                       PACKET3_VC_ACTION_ENA |
> +                                       PACKET3_SH_ACTION_ENA);
> +               radeon_ring_write(rdev, 0x);
> +               radeon_ring_write(rdev, 0);
> +               radeon_ring_write(rdev, 10); /* poll interval */
>                /* EVENT_WRITE_EOP - flush caches, send int */
>                radeon_ring_write(rdev, PACKET3(PACKET3_EVENT_WRITE_EOP, 4));
>                radeon_ring_write(rdev, 
> EVENT_TYPE(CACHE_FLUSH_AND_INV_EVENT_TS) | EVENT_INDEX(5));
> @@ -2339,6 +2347,14 @@ void r600_fence_ring_emit(struct radeon_device *rdev,
>                radeon_ring_write(rdev, fence->seq);
>                radeon_ring_write(rdev, 0);
>        } else {
> +               /* flush read cache over gart */
> +               radeon_ring_write(rdev, PACKET3(PACKET3_SURFACE_SYNC, 3));
> +               radeon_ring_write(rdev, PACKET3_TC_ACTION_ENA |
> +                                       PACKET3_VC_ACTION_ENA |
> +                                       PACKET3_SH_ACTION_ENA);
> +               radeon_ring_write(rdev, 0x);
> +               radeon_ring_write(rdev, 0);
> +               radeon_ring_write(rdev, 10); /* poll interval */
>                radeon_ring_write(rdev, PACKET3(PACKET3_EVENT_WRITE, 0));
>                radeon_ring_write(rdev, EVENT_TYPE(CACHE_FLUSH_AND_INV_EVENT) 
> | EVENT_INDEX(0));
>                /* wait for 3D idle clean */
> diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c 
> b/drivers/gpu/drm/radeon/r600_blit_kms.c
> index c4cf130..36e62f2 100644
> --- a/drivers/gpu/drm/radeon/r600_blit_kms.c
> +++ b/drivers/gpu/drm/radeon/r600_blit_kms.c
> @@ -500,9 +500,9 @@ int r600_blit_init(struct radeon_device *rdev)
>        rdev->r600_blit.primitives.set_default_state = set_default_state;
>
>        rdev->r600_blit.ring_size_common = 40; /* shaders + def state */
> -       rdev->r600_blit.ring_size_common += 10; /* fence emit for VB IB */
> +       rdev->r600_blit.ring_size_common += 16; /* fence emit

Re: [PATCH 01/11] drm: add plane support

2011-10-27 Thread Jesse Barnes
On Wed, 26 Oct 2011 14:40:07 +0900
Joonyoung Shim  wrote:

> 10/25/2011 06:46 PM, Jesse Barnes 쓴 글:
> 
> [snip]
> > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> > index 8020798..d7f03aa 100644
> > --- a/include/drm/drm_crtc.h
> > +++ b/include/drm/drm_crtc.h
> > @@ -44,6 +44,7 @@ struct drm_framebuffer;
> >   #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
> >   #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
> >   #define DRM_MODE_OBJECT_BLOB 0x
> > +#define DRM_MODE_OBJECT_PLANE 0x
> >
> >   struct drm_mode_object {
> > uint32_t id;
> > @@ -278,6 +279,7 @@ struct drm_crtc;
> >   struct drm_connector;
> >   struct drm_encoder;
> >   struct drm_pending_vblank_event;
> > +struct drm_plane;
> >
> >   /**
> >* drm_crtc_funcs - control CRTCs for a given device
> > @@ -536,6 +538,58 @@ struct drm_connector {
> >   };
> >
> >   /**
> > + * drm_plane_funcs - driver plane control functions
> > + * @update_plane: update the plane configuration
> > + */
> > +struct drm_plane_funcs {
> > +   int (*update_plane)(struct drm_plane *plane,
> > +   struct drm_crtc *crtc, struct drm_framebuffer *fb,
> > +   int crtc_x, int crtc_y,
> > +   unsigned int crtc_w, unsigned int crtc_h,
> > +   uint32_t src_x, uint32_t src_y,
> > +   uint32_t src_w, uint32_t src_h);
> > +   int (*disable_plane)(struct drm_plane *plane);
> > +};
> 
> How about add destroy() function and call it in
> drm_mode_config_cleanup()?

Oh good idea; destroy will be needed for hot plug.

-- 
Jesse Barnes, Intel Open Source Technology Center


signature.asc
Description: PGP signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 01/11] drm: add plane support

2011-10-27 Thread Jesse Barnes
On Wed, 26 Oct 2011 14:40:07 +0900
Joonyoung Shim  wrote:

> 10/25/2011 06:46 PM, Jesse Barnes ? ?:
> 
> [snip]
> > diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> > index 8020798..d7f03aa 100644
> > --- a/include/drm/drm_crtc.h
> > +++ b/include/drm/drm_crtc.h
> > @@ -44,6 +44,7 @@ struct drm_framebuffer;
> >   #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
> >   #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
> >   #define DRM_MODE_OBJECT_BLOB 0x
> > +#define DRM_MODE_OBJECT_PLANE 0x
> >
> >   struct drm_mode_object {
> > uint32_t id;
> > @@ -278,6 +279,7 @@ struct drm_crtc;
> >   struct drm_connector;
> >   struct drm_encoder;
> >   struct drm_pending_vblank_event;
> > +struct drm_plane;
> >
> >   /**
> >* drm_crtc_funcs - control CRTCs for a given device
> > @@ -536,6 +538,58 @@ struct drm_connector {
> >   };
> >
> >   /**
> > + * drm_plane_funcs - driver plane control functions
> > + * @update_plane: update the plane configuration
> > + */
> > +struct drm_plane_funcs {
> > +   int (*update_plane)(struct drm_plane *plane,
> > +   struct drm_crtc *crtc, struct drm_framebuffer *fb,
> > +   int crtc_x, int crtc_y,
> > +   unsigned int crtc_w, unsigned int crtc_h,
> > +   uint32_t src_x, uint32_t src_y,
> > +   uint32_t src_w, uint32_t src_h);
> > +   int (*disable_plane)(struct drm_plane *plane);
> > +};
> 
> How about add destroy() function and call it in
> drm_mode_config_cleanup()?

Oh good idea; destroy will be needed for hot plug.

-- 
Jesse Barnes, Intel Open Source Technology Center
------ next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20111027/347bd6d2/attachment.pgp>


Re: [PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Ilija Hadzic



On Thu, 27 Oct 2011, Alan Coopersmith wrote:



I think the idea of sharing kernel drm code is pretty much dead, yeah.


We are still trying to keep it alive, despite what some may think.



In the context of this patch (in progress), it's probably a moot topic 
because per comments that Daniel sent, most of the locks in 
drm_vblank_wait will become unecessary after I rework the patch

and I won't need to introduce (new) DRM_WAIT_ON_LOCKED any more.

I will, however, *not* convert existing DRM_WAIT_ON to a Linux-centric 
function, so I will not be the one to kill (or contribute to the killing 
of) the portability of that file. That I leave to someone else ;-).


P.S. If the "fight" starts I will side with the "keep the portability 
alive" camp. I have "emotional" ties with other (less widely used) 
operating systems. ;-)


-- Ilija
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Alan Coopersmith

On 10/27/11 03:43, Daniel Vetter wrote:

On Wed, Oct 26, 2011 at 05:33:24PM -0500, Ilija Hadzic wrote:

Is DRM support for other OS-es officially dead ? I know it's not in
best shape on BSD and friends, but I am not sure if I should make it
worse (or inconsistent with the current code shape and form).


I think the idea of sharing kernel drm code is pretty much dead, yeah.


We are still trying to keep it alive, despite what some may think.

--
-Alan Coopersmith-alan.coopersm...@oracle.com
 Oracle Solaris Platform Engineering: X Window System

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Alan Coopersmith
On 10/27/11 03:43, Daniel Vetter wrote:
> On Wed, Oct 26, 2011 at 05:33:24PM -0500, Ilija Hadzic wrote:
>> Is DRM support for other OS-es officially dead ? I know it's not in
>> best shape on BSD and friends, but I am not sure if I should make it
>> worse (or inconsistent with the current code shape and form).
>
> I think the idea of sharing kernel drm code is pretty much dead, yeah.

We are still trying to keep it alive, despite what some may think.

-- 
-Alan Coopersmith-alan.coopersmith at oracle.com
 Oracle Solaris Platform Engineering: X Window System



Re: nouveau page_flip function implement not wait vblank, which cause screen garbage

2011-10-27 Thread Thomas Hellstrom

On 10/27/2011 12:49 PM, Francisco Jerez wrote:

Thomas Hellstrom  writes:

   

FWIW, there was a quite long discussion / argument when the page flip
ioctl was designed, and at that time
I pointed out that there are hardware capable of pageflipping using
the fifo/pipe with optional VSYNC barriers, and that it is actually
possible to queue up a number of pageflips in the fifo. Not just one.

 

That's the case of the nouveau driver, and it's the reason that we don't
respect the API returning -EBUSY when there's an already scheduled flip
request. IMHO that should be up to the driver, or even better, the IOCTL
could be specified to block in case userspace is requesting more
simultaneous page-flips than the kernel driver can handle, in order to
make the resulting behavior consistent for userspace no matter which
implementation is being used.

   

The interface description in drm_mode.h is somewhat different to what
was agreed upon, namely:

1) The command submission mechanism should block if a user tries to
render to a not yet flipped frontbuffer, and that would cause
rendering problems. For hardware that flips using a fifo / pipe,
that's not really a problem. Thus, any rendering errors due to
rendering to a not-yet-flipped frontbuffer is a kernel driver error.
The user-space app can avoid being blocked waiting using events.

 

Yeah, it would be good to relax this restriction -- the nouveau driver
has never respected it because we'd end up lock-stepping the GPU (we
wouldn't be sending the next batch of commands until the one sent before
the flip had been completely processed), and it's just not necessary
because we take additional measures to make sure that flips and commands
sent to other hardware queues are properly ordered with respect to one
another.

   


I don't think you need to care about this restriction, since the next 
batch doesn't arrive for execution until the flip has happened. Waiting 
to submit in this case was never intended when there is GPU support to 
order the flip and the next batch of commands, and the waiting is only 
to protect against rendering errors.




2) The interface in itself doesn't require flips to be synced to
vblanks, as I understand it.
  However, it should be possible to add a new flag
DRM_MODE_PAGE_FLIP_SYNC that tries to sync if at all possible.

 

Yes, so the fact that the nouveau pageflip implementation doesn't sync
to vblank before flipping isn't even a bug as it stands.
   


No it isn't. vmwgfx is doing (or going to do ) the same, since we can't 
sync to vblank currently. Also we are not holding rendering commands up, 
since the virtual GPU orders the flips and the next batch of commands.


/Thomas



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 23/23] drm: kill a few unused remnants from drm_memory.c

2011-10-27 Thread Daniel Vetter
Noticed while killing code in the area ...

Signed-Off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_memory.c |   19 ---
 include/drm/drmP.h   |5 -
 2 files changed, 0 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index c9b8050..21a554d 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -36,25 +36,6 @@
 #include 
 #include "drmP.h"
 
-/**
- * Called when "/proc/dri/%dev%/mem" is read.
- *
- * \param buf output buffer.
- * \param start start of output data.
- * \param offset requested start offset.
- * \param len requested number of bytes.
- * \param eof whether there is no more data to return.
- * \param data private data.
- * \return number of written bytes.
- *
- * No-op.
- */
-int drm_mem_info(char *buf, char **start, off_t offset,
-int len, int *eof, void *data)
-{
-   return 0;
-}
-
 #if __OS_HAS_AGP
 static void *agp_remap(unsigned long offset, unsigned long size,
   struct drm_device * dev)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index d307dec..75e0e52 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1247,11 +1247,6 @@ extern unsigned int drm_poll(struct file *filp, struct 
poll_table_struct *wait);
 
/* Memory management support (drm_memory.h) */
 #include "drm_memory.h"
-extern void drm_mem_init(void);
-extern int drm_mem_info(char *buf, char **start, off_t offset,
-   int request, int *eof, void *data);
-extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area);
-
 extern void drm_free_agp(DRM_AGP_MEM * handle, int pages);
 extern int drm_bind_agp(DRM_AGP_MEM * handle, unsigned int start);
 extern DRM_AGP_MEM *drm_agp_bind_pages(struct drm_device *dev,
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 22/23] drm: kill procfs support

2011-10-27 Thread Daniel Vetter
We have debugfs and sysfs for these things now!

Digging through the dungeons of old code and wading through countless
result pages on google indeed turned up one user of this:

libdrm before 2001 checks via the presence of /proc/dri/0 whether
the kernel drm is present and has a module successfully loaded.

Frankly I think that demanding from users that they upgrade to a more
modern libdrm is in order.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/Makefile   |2 +-
 drivers/gpu/drm/drm_drv.c  |8 --
 drivers/gpu/drm/drm_proc.c |  220 
 drivers/gpu/drm/drm_stub.c |   25 ++
 include/drm/drmP.h |9 --
 5 files changed, 8 insertions(+), 256 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_proc.c

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index ea083cf..cea1435 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -7,7 +7,7 @@ ccflags-y := -Iinclude/drm
 drm-y   := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
drm_context.o drm_dma.o \
drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
-   drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
+   drm_lock.o drm_memory.o drm_stub.o drm_vm.o \
drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \
drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
drm_crtc.o drm_modes.o drm_edid.o \
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 1c853f4..1dece54 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -251,13 +251,6 @@ static int __init drm_core_init(void)
goto err_p2;
}
 
-   drm_proc_root = proc_mkdir("dri", NULL);
-   if (!drm_proc_root) {
-   DRM_ERROR("Cannot create /proc/dri\n");
-   ret = -1;
-   goto err_p3;
-   }
-
drm_debugfs_root = debugfs_create_dir("dri", NULL);
if (!drm_debugfs_root) {
DRM_ERROR("Cannot create /sys/kernel/debug/dri\n");
@@ -280,7 +273,6 @@ err_p1:
 
 static void __exit drm_core_exit(void)
 {
-   remove_proc_entry("dri", NULL);
debugfs_remove(drm_debugfs_root);
drm_sysfs_destroy();
 
diff --git a/drivers/gpu/drm/drm_proc.c b/drivers/gpu/drm/drm_proc.c
deleted file mode 100644
index a60af79..000
--- a/drivers/gpu/drm/drm_proc.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/**
- * \file drm_proc.c
- * /proc support for DRM
- *
- * \author Rickard E. (Rik) Faith 
- * \author Gareth Hughes 
- *
- * \par Acknowledgements:
- *Matthew J Sottek  sent in a patch to fix
- *the problem with the proc files not outputting all their information.
- */
-
-/*
- * Created: Mon Jan 11 09:48:47 1999 by fa...@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include 
-#include 
-#include "drmP.h"
-
-/***
- * Initialization, etc.
- **/
-
-/**
- * Proc file list.
- */
-static struct drm_info_list drm_proc_list[] = {
-   {"name", drm_name_info, 0},
-   {"vm", drm_vm_info, 0},
-   {"clients", drm_clients_info, 0},
-   {"bufs", drm_bufs_info, 0},
-   {"gem_names", drm_gem_name_info, DRIVER_GEM},
-#if DRM_DEBUG_CODE
-   {"vma", drm_vma_info, 0},
-#endif
-};
-#define DRM_PROC_ENTRIES ARRAY_SIZE(drm_proc_list)
-
-static int drm_proc_open(struct inode *inode, struct file *file)
-{
-   struct drm_info_node* node = PDE(inode)->data;
-
-   return single_open(file, node->info_ent->show, node);
-}
-
-static const struct file_operations drm_proc_fops = {
-   .owner = THIS_MODULE,
-   .open = drm_proc_

[PATCH 21/23] drm: kill i915/i830 ids from drm_pciids.h

2011-10-27 Thread Daniel Vetter
Signed-off-by: Daniel Vetter 
---
 include/drm/drm_pciids.h |   42 --
 1 files changed, 0 insertions(+), 42 deletions(-)

diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index 3d53efd..ecd09a3 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -603,14 +603,6 @@
{0x8086, 0x1132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
 
-#define i830_PCI_IDS \
-   {0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0x8086, 0x358e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
-   {0, 0, 0}
-
 #define gamma_PCI_IDS \
{0x3d3d, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \
{0, 0, 0}
@@ -643,37 +635,3 @@
 
 #define ffb_PCI_IDS \
{0, 0, 0}
-
-#define i915_PCI_IDS \
-   {0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x258a, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x27ae, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2972, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2982, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2992, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x29a2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x29b2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x29c2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x29d2, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2a02, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2a12, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2a42, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e02, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e12, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e22, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e32, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x2e42, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0xa001, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0xa011, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x35e8, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x0042, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x0046, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0x8086, 0x0102, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, 
0x00, 0}, \
-   {0, 0, 0}
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 20/23] drm: unconditionally clean up dma buffers of closing clients

2011-10-27 Thread Daniel Vetter
With the last patch to ditch DMA_QUEUE support, we should be able
to call the dma cleanup uncoditionally, even when the master has
disappeared.

Do so because it just makes more sense.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 6d6dbe5..46f2cfd 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -366,9 +366,6 @@ static void drm_master_release(struct drm_device *dev, 
struct file *filp)
drm_lock_free(&file_priv->master->lock,
  
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
}
-
-   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
-   drm_core_reclaim_buffers(dev, file_priv);
 }
 
 static void drm_events_release(struct drm_file *file_priv)
@@ -433,6 +430,9 @@ int drm_release(struct inode *inode, struct file *filp)
if (file_priv->minor->master)
drm_master_release(dev, filp);
 
+   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
+   drm_core_reclaim_buffers(dev, file_priv);
+
drm_events_release(file_priv);
 
if (dev->driver->driver_features & DRIVER_GEM)
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 19/23] drm: kill dma queue support

2011-10-27 Thread Daniel Vetter
Absolutely unused. All the values are only ever initialized and
then used at most in some debug printout functions.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_bufs.c  |   16 ++--
 drivers/gpu/drm/drm_debugfs.c   |1 -
 drivers/gpu/drm/drm_dma.c   |5 -
 drivers/gpu/drm/drm_drv.c   |   11 ---
 drivers/gpu/drm/drm_fops.c  |4 
 drivers/gpu/drm/drm_info.c  |   36 
 drivers/gpu/drm/drm_proc.c  |1 -
 drivers/gpu/drm/i810/i810_drv.c |2 +-
 include/drm/drmP.h  |8 +---
 9 files changed, 4 insertions(+), 80 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 61e1ef9..bec0295 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -640,8 +640,6 @@ int drm_addbufs_agp(struct drm_device * dev, struct 
drm_buf_desc * request)
 
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return -EINVAL;
-   if (dev->queue_count)
-   return -EBUSY;  /* Not while in use */
 
/* Make sure buffers are located in AGP memory that we own */
valid = 0;
@@ -703,7 +701,6 @@ int drm_addbufs_agp(struct drm_device * dev, struct 
drm_buf_desc * request)
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
-   init_waitqueue_head(&buf->dma_wait);
buf->file_priv = NULL;
 
buf->dev_priv_size = dev->driver->dev_priv_size;
@@ -795,13 +792,11 @@ int drm_addbufs_pci(struct drm_device * dev, struct 
drm_buf_desc * request)
order = drm_order(request->size);
size = 1 << order;
 
-   DRM_DEBUG("count=%d, size=%d (%d), order=%d, queue_count=%d\n",
- request->count, request->size, size, order, dev->queue_count);
+   DRM_DEBUG("count=%d, size=%d (%d), order=%d\n",
+ request->count, request->size, size, order);
 
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return -EINVAL;
-   if (dev->queue_count)
-   return -EBUSY;  /* Not while in use */
 
alignment = (request->flags & _DRM_PAGE_ALIGN)
? PAGE_ALIGN(size) : size;
@@ -903,7 +898,6 @@ int drm_addbufs_pci(struct drm_device * dev, struct 
drm_buf_desc * request)
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
-   init_waitqueue_head(&buf->dma_wait);
buf->file_priv = NULL;
 
buf->dev_priv_size = dev->driver->dev_priv_size;
@@ -1018,8 +1012,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct 
drm_buf_desc * request
 
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return -EINVAL;
-   if (dev->queue_count)
-   return -EBUSY;  /* Not while in use */
 
spin_lock(&dev->count_lock);
if (dev->buf_use) {
@@ -1070,7 +1062,6 @@ static int drm_addbufs_sg(struct drm_device * dev, struct 
drm_buf_desc * request
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
-   init_waitqueue_head(&buf->dma_wait);
buf->file_priv = NULL;
 
buf->dev_priv_size = dev->driver->dev_priv_size;
@@ -1176,8 +1167,6 @@ static int drm_addbufs_fb(struct drm_device * dev, struct 
drm_buf_desc * request
 
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return -EINVAL;
-   if (dev->queue_count)
-   return -EBUSY;  /* Not while in use */
 
spin_lock(&dev->count_lock);
if (dev->buf_use) {
@@ -1227,7 +1216,6 @@ static int drm_addbufs_fb(struct drm_device * dev, struct 
drm_buf_desc * request
buf->next = NULL;
buf->waiting = 0;
buf->pending = 0;
-   init_waitqueue_head(&buf->dma_wait);
buf->file_priv = NULL;
 
buf->dev_priv_size = dev->driver->dev_priv_size;
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 9d2668a..e72d46a 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -45,7 +45,6 @@ static struct drm_info_list drm_debugfs_list[] = {
{"name", drm_name_info, 0},
{"vm", drm_vm_info, 0},
{"clients", drm_clients_info, 0},
-   {"queues", drm_queues_info, 0},
{"bufs", drm_bufs_info, 0},
{"gem_names", drm_gem_name_info, DRIVER_GEM},
 #if DRM_DEBUG_CODE
diff --git a/drivers/gpu/drm/drm_dma.c b/drivers/gpu/drm/drm_dma.c
index 252cbd7..f91d54f 100644
--- a/drivers/gpu/drm/drm_dma.c
+++ b/drivers/gpu/drm/drm_dma.c
@@ -119,11 +119,6 @@ void drm_free_buffer(struct drm_device *dev, struct 
drm_buf * buf)
buf->pending = 0;
buf->file_priv = NULL;
buf->used = 0;
-
-   if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)
-   

[PATCH 18/23] drm: ditch strange DRIVER_DMA_QUEUE only error bail-out

2011-10-27 Thread Daniel Vetter
Only one driver (i810) even sets that flag. Now the actual locking code
uncoditionally promotes lock->context to an unsigned int.

Closer inspection of the userspace reveals that the drm lock context
is defined as an unsigned int (at least on linux). I suspect
we just have a strange case of signedness confusion going on.

Tested on my i815, doesn't seem to break anything.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_lock.c |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index b107e1d..37822d1 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -69,10 +69,6 @@ int drm_lock(struct drm_device *dev, void *data, struct 
drm_file *file_priv)
  lock->context, task_pid_nr(current),
  master->lock.hw_lock->lock, lock->flags);
 
-   if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE))
-   if (lock->context < 0)
-   return -EINVAL;
-
add_wait_queue(&master->lock.lock_queue, &entry);
spin_lock_bh(&master->lock.spinlock);
master->lock.user_waiters++;
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 17/23] drm: kill reclaim_buffers callback

2011-10-27 Thread Daniel Vetter
All leftover users either haven't set DRIVER_HAVE_DMA, in which
case this will never be called, or use the drm_core implementation.

Call that directly in the only callsite.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c|5 ++---
 drivers/gpu/drm/i915/i915_drv.c   |1 -
 drivers/gpu/drm/mga/mga_drv.c |1 -
 drivers/gpu/drm/nouveau/nouveau_drv.c |1 -
 drivers/gpu/drm/r128/r128_drv.c   |1 -
 drivers/gpu/drm/radeon/radeon_drv.c   |2 --
 drivers/gpu/drm/tdfx/tdfx_drv.c   |1 -
 drivers/staging/gma500/psb_drv.c  |1 -
 include/drm/drmP.h|2 --
 9 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index a004525..c1298be 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -371,9 +371,8 @@ static void drm_master_release(struct drm_device *dev, 
struct file *filp)
  
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
}
 
-   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) {
-   dev->driver->reclaim_buffers(dev, file_priv);
-   }
+   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
+   drm_core_reclaim_buffers(dev, file_priv);
 }
 
 static void drm_events_release(struct drm_file *file_priv)
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index f07e425..c2476d4 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -803,7 +803,6 @@ static struct drm_driver driver = {
.resume = i915_resume,
 
.device_is_agp = i915_driver_device_is_agp,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.master_create = i915_master_create,
.master_destroy = i915_master_destroy,
 #if defined(CONFIG_DEBUG_FS)
diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 42d3187..421f4c9 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -59,7 +59,6 @@ static struct drm_driver driver = {
.irq_postinstall = mga_driver_irq_postinstall,
.irq_uninstall = mga_driver_irq_uninstall,
.irq_handler = mga_driver_irq_handler,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = mga_ioctls,
.dma_ioctl = mga_dma_buffers,
.fops = {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c 
b/drivers/gpu/drm/nouveau/nouveau_drv.c
index b30ddd8..c79d225 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -410,7 +410,6 @@ static struct drm_driver driver = {
.get_vblank_counter = drm_vblank_count,
.enable_vblank = nouveau_vblank_enable,
.disable_vblank = nouveau_vblank_disable,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = nouveau_ioctls,
.fops = {
.owner = THIS_MODULE,
diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index b9e8efd..4afeaf0 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -55,7 +55,6 @@ static struct drm_driver driver = {
.irq_postinstall = r128_driver_irq_postinstall,
.irq_uninstall = r128_driver_irq_uninstall,
.irq_handler = r128_driver_irq_handler,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = r128_ioctls,
.dma_ioctl = r128_cce_buffers,
.fops = {
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index e71d2ed..3f220ea 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -223,7 +223,6 @@ static struct drm_driver driver_old = {
.irq_postinstall = radeon_driver_irq_postinstall,
.irq_uninstall = radeon_driver_irq_uninstall,
.irq_handler = radeon_driver_irq_handler,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = radeon_ioctls,
.dma_ioctl = radeon_cp_buffers,
.fops = {
@@ -325,7 +324,6 @@ static struct drm_driver kms_driver = {
.irq_postinstall = radeon_driver_irq_postinstall_kms,
.irq_uninstall = radeon_driver_irq_uninstall_kms,
.irq_handler = radeon_driver_irq_handler_kms,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.ioctls = radeon_ioctls_kms,
.gem_init_object = radeon_gem_object_init,
.gem_free_object = radeon_gem_object_free,
diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index 8bf9881..b3e64a7 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -41,7 +41,6 @@ static struct pci_device_id pciidlist[] = {
 
 static struct drm_driver driver = {
.driver_features = DRIVER_USE_MTRR,
-   .reclaim_buffers = drm_core_reclaim_buffers,
.fops = {
 .owner = THIS_MODULE,
 .open = drm_open,
diff --git a/drivers/staging/gma500/ps

[PATCH 16/23] drm/savage: clean up reclaim_buffers

2011-10-27 Thread Daniel Vetter
The reclaim_buffers function of the savage driver actually wants to run
with the hw_lock held - at least there are printks in the call-chain
to that effect. But the drm core only calls reclaim_buffers as used
by savage _after_ forcefully dropping the hwlock (in case it's still
hold by the closing fd).

So do the same idlelock dance as for the other dma drivers and hope
that papers over any issues.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/savage/savage_bci.c |7 +--
 drivers/gpu/drm/savage/savage_drv.c |2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/savage/savage_bci.c 
b/drivers/gpu/drm/savage/savage_bci.c
index cb1ee4e..1c00dbd 100644
--- a/drivers/gpu/drm/savage/savage_bci.c
+++ b/drivers/gpu/drm/savage/savage_bci.c
@@ -1050,6 +1050,7 @@ void savage_reclaim_buffers(struct drm_device *dev, 
struct drm_file *file_priv)
 {
struct drm_device_dma *dma = dev->dma;
drm_savage_private_t *dev_priv = dev->dev_private;
+   int release_idlelock = 0;
int i;
 
if (!dma)
@@ -1059,7 +1060,8 @@ void savage_reclaim_buffers(struct drm_device *dev, 
struct drm_file *file_priv)
if (!dma->buflist)
return;
 
-   /*i830_flush_queue(dev); */
+   if (file_priv->master && file_priv->master->lock.hw_lock)
+   drm_idlelock_take(&file_priv->master->lock);
 
for (i = 0; i < dma->buf_count; i++) {
struct drm_buf *buf = dma->buflist[i];
@@ -1075,7 +1077,8 @@ void savage_reclaim_buffers(struct drm_device *dev, 
struct drm_file *file_priv)
}
}
 
-   drm_core_reclaim_buffers(dev, file_priv);
+   if (release_idlelock)
+   drm_idlelock_release(&file_priv->master->lock);
 }
 
 struct drm_ioctl_desc savage_ioctls[] = {
diff --git a/drivers/gpu/drm/savage/savage_drv.c 
b/drivers/gpu/drm/savage/savage_drv.c
index 6464490..0ed88b1 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -39,9 +39,9 @@ static struct drm_driver driver = {
.dev_priv_size = sizeof(drm_savage_buf_priv_t),
.load = savage_driver_load,
.firstopen = savage_driver_firstopen,
+   .preclose = savage_reclaim_buffers,
.lastclose = savage_driver_lastclose,
.unload = savage_driver_unload,
-   .reclaim_buffers = savage_reclaim_buffers,
.ioctls = savage_ioctls,
.dma_ioctl = savage_bci_buffers,
.fops = {
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 15/23] drm: kill reclaim_buffers_locked

2011-10-27 Thread Daniel Vetter
i810 was the last user of this code, with that gone, kill it.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c  |   46 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c |1 -
 include/drm/drmP.h  |2 -
 3 files changed, 1 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index e18e329..a004525 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -360,53 +360,10 @@ int drm_fasync(int fd, struct file *filp, int on)
 }
 EXPORT_SYMBOL(drm_fasync);
 
-/*
- * Reclaim locked buffers; note that this may be a bad idea if the current
- * context doesn't have the hw lock...
- */
-static void drm_reclaim_locked_buffers(struct drm_device *dev, struct file *f)
-{
-   struct drm_file *file_priv = f->private_data;
-
-   if (drm_i_have_hw_lock(dev, file_priv)) {
-   dev->driver->reclaim_buffers_locked(dev, file_priv);
-   } else {
-   unsigned long _end = jiffies + 3 * DRM_HZ;
-   int locked = 0;
-
-   drm_idlelock_take(&file_priv->master->lock);
-
-   /*
-* Wait for a while.
-*/
-   do {
-   spin_lock_bh(&file_priv->master->lock.spinlock);
-   locked = file_priv->master->lock.idle_has_lock;
-   spin_unlock_bh(&file_priv->master->lock.spinlock);
-   if (locked)
-   break;
-   schedule();
-   } while (!time_after_eq(jiffies, _end));
-
-   if (!locked) {
-   DRM_ERROR("reclaim_buffers_locked() deadlock. Please 
rework this\n"
- "\tdriver to use reclaim_buffers_idlelocked() 
instead.\n"
- "\tI will go on reclaiming the buffers 
anyway.\n");
-   }
-
-   dev->driver->reclaim_buffers_locked(dev, file_priv);
-   drm_idlelock_release(&file_priv->master->lock);
-   }
-}
-
 static void drm_master_release(struct drm_device *dev, struct file *filp)
 {
struct drm_file *file_priv = filp->private_data;
 
-   if (dev->driver->reclaim_buffers_locked &&
-   file_priv->master->lock.hw_lock)
-   drm_reclaim_locked_buffers(dev, filp);
-
if (drm_i_have_hw_lock(dev, file_priv)) {
DRM_DEBUG("File %p released, freeing lock for context %d\n",
  filp, 
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
@@ -414,8 +371,7 @@ static void drm_master_release(struct drm_device *dev, 
struct file *filp)
  
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
}
 
-   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) &&
-   !dev->driver->reclaim_buffers_locked) {
+   if (drm_core_check_feature(dev, DRIVER_HAVE_DMA)) {
dev->driver->reclaim_buffers(dev, file_priv);
}
 }
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 96949b9..dcf6c27 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -886,7 +886,6 @@ static struct drm_driver driver = {
.irq_uninstall = vmw_irq_uninstall,
.irq_handler = vmw_irq_handler,
.get_vblank_counter = vmw_get_vblank_counter,
-   .reclaim_buffers_locked = NULL,
.ioctls = vmw_ioctls,
.num_ioctls = DRM_ARRAY_SIZE(vmw_ioctls),
.dma_quiescent = NULL,  /*vmw_dma_quiescent, */
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 4690265..9823614 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -855,8 +855,6 @@ struct drm_driver {
void (*irq_uninstall) (struct drm_device *dev);
void (*reclaim_buffers) (struct drm_device *dev,
 struct drm_file * file_priv);
-   void (*reclaim_buffers_locked) (struct drm_device *dev,
-   struct drm_file *file_priv);
void (*set_version) (struct drm_device *dev,
 struct drm_set_version *sv);
 
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 14/23] drm/i810: cleanup reclaim_buffers

2011-10-27 Thread Daniel Vetter
My dear old i815 always hits the deadlocked on reclaim_buffers
warning. Switch over to the idlelock duct-tape on hope that
works better. I've fired up my i815 and now closing glxgears doesn't
take 5 seconds anymore. \o/

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/i810/i810_dma.c |   17 +++--
 drivers/gpu/drm/i810/i810_drv.c |1 -
 drivers/gpu/drm/i810/i810_drv.h |6 ++
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 8f371e8..6b73c3e 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -888,7 +888,7 @@ static int i810_flush_queue(struct drm_device *dev)
 }
 
 /* Must be called with the lock held */
-static void i810_reclaim_buffers(struct drm_device *dev,
+void i810_driver_reclaim_buffers(struct drm_device *dev,
 struct drm_file *file_priv)
 {
struct drm_device_dma *dma = dev->dma;
@@ -1225,12 +1225,17 @@ void i810_driver_preclose(struct drm_device *dev, 
struct drm_file *file_priv)
if (dev_priv->page_flipping)
i810_do_cleanup_pageflip(dev);
}
-}
 
-void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
-   struct drm_file *file_priv)
-{
-   i810_reclaim_buffers(dev, file_priv);
+   if (file_priv->master && file_priv->master->lock.hw_lock) {
+   drm_idlelock_take(&file_priv->master->lock);
+   i810_driver_reclaim_buffers(dev, file_priv);
+   drm_idlelock_release(&file_priv->master->lock);
+   } else {
+   /* master disappeared, clean up stuff anyway and hope nothing
+* goes wrong */
+   i810_driver_reclaim_buffers(dev, file_priv);
+   }
+
 }
 
 int i810_driver_dma_quiescent(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 6f98d05..b264e19 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -50,7 +50,6 @@ static struct drm_driver driver = {
.lastclose = i810_driver_lastclose,
.preclose = i810_driver_preclose,
.device_is_agp = i810_driver_device_is_agp,
-   .reclaim_buffers_locked = i810_driver_reclaim_buffers_locked,
.dma_quiescent = i810_driver_dma_quiescent,
.ioctls = i810_ioctls,
.fops = {
diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
index c9339f4..6e0acad 100644
--- a/drivers/gpu/drm/i810/i810_drv.h
+++ b/drivers/gpu/drm/i810/i810_drv.h
@@ -116,14 +116,12 @@ typedef struct drm_i810_private {
 
/* i810_dma.c */
 extern int i810_driver_dma_quiescent(struct drm_device *dev);
-extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
-  struct drm_file *file_priv);
+void i810_driver_reclaim_buffers(struct drm_device *dev,
+struct drm_file *file_priv);
 extern int i810_driver_load(struct drm_device *, unsigned long flags);
 extern void i810_driver_lastclose(struct drm_device *dev);
 extern void i810_driver_preclose(struct drm_device *dev,
 struct drm_file *file_priv);
-extern void i810_driver_reclaim_buffers_locked(struct drm_device *dev,
-  struct drm_file *file_priv);
 extern int i810_driver_device_is_agp(struct drm_device *dev);
 
 extern long i810_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 13/23] drm: kill reclaim_buffers_idlelocked functions

2011-10-27 Thread Daniel Vetter
The only two users are now folded into the drivers preclose functions,
so this is unused.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_fops.c |8 
 include/drm/drmP.h |2 --
 2 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 2ec7d48..e18e329 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -407,14 +407,6 @@ static void drm_master_release(struct drm_device *dev, 
struct file *filp)
file_priv->master->lock.hw_lock)
drm_reclaim_locked_buffers(dev, filp);
 
-   if (dev->driver->reclaim_buffers_idlelocked &&
-   file_priv->master->lock.hw_lock) {
-   drm_idlelock_take(&file_priv->master->lock);
-   dev->driver->reclaim_buffers_idlelocked(dev, file_priv);
-   drm_idlelock_release(&file_priv->master->lock);
-   }
-
-
if (drm_i_have_hw_lock(dev, file_priv)) {
DRM_DEBUG("File %p released, freeing lock for context %d\n",
  filp, 
_DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock));
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 9b7c2bb..4690265 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -857,8 +857,6 @@ struct drm_driver {
 struct drm_file * file_priv);
void (*reclaim_buffers_locked) (struct drm_device *dev,
struct drm_file *file_priv);
-   void (*reclaim_buffers_idlelocked) (struct drm_device *dev,
-   struct drm_file *file_priv);
void (*set_version) (struct drm_device *dev,
 struct drm_set_version *sv);
 
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 12/23] drm/sis: clean up reclaim_buffers

2011-10-27 Thread Daniel Vetter
Like for via.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/sis/sis_drv.c |3 +--
 drivers/gpu/drm/sis/sis_mm.c  |   12 ++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 278d1b0..1b299cc 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -91,10 +91,9 @@ static struct drm_driver driver = {
.load = sis_driver_load,
.unload = sis_driver_unload,
.open = sis_driver_open,
+   .preclose = sis_reclaim_buffers_locked,
.postclose = sis_driver_postclose,
.dma_quiescent = sis_idle,
-   .reclaim_buffers = NULL,
-   .reclaim_buffers_idlelocked = sis_reclaim_buffers_locked,
.lastclose = sis_lastclose,
.ioctls = sis_ioctls,
.fops = {
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index ff34680..f746618 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -324,14 +324,18 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
struct sis_file_private *file_priv = file->driver_priv;
struct sis_memblock *entry, *next;
 
+   int release_idlelock = 0;
+
+   if (file->master && file->master->lock.hw_lock)
+   drm_idlelock_take(&file->master->lock);
+
mutex_lock(&dev->struct_mutex);
if (list_empty(&file_priv->obj_list)) {
mutex_unlock(&dev->struct_mutex);
return;
}
 
-   if (dev->driver->dma_quiescent)
-   dev->driver->dma_quiescent(dev);
+   sis_idle(dev);
 
 
list_for_each_entry_safe(entry, next, &file_priv->obj_list,
@@ -346,6 +350,10 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
kfree(entry);
}
mutex_unlock(&dev->struct_mutex);
+
+   if (release_idlelock)
+   drm_idlelock_release(&file->master->lock);
+
return;
 }
 
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 11/23] drm/via: clean up reclaim_buffers

2011-10-27 Thread Daniel Vetter
A few things
- kill reclaim_buffers, it's never ever called because via does not set
  DRIVER_HAVE_DMA
- inline the idlelock dance into the buffer reclaim logic and make it
  a simple preclose cleanup function
- directly call the the dma_quiescent function and kill the needless
  if check.

Export the idlelock drm functions so that drivers can call them.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_lock.c|2 ++
 drivers/gpu/drm/via/via_drv.c |4 +---
 drivers/gpu/drm/via/via_mm.c  |   11 +--
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index 632ae24..b107e1d 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -345,6 +345,7 @@ void drm_idlelock_take(struct drm_lock_data *lock_data)
}
spin_unlock_bh(&lock_data->spinlock);
 }
+EXPORT_SYMBOL(drm_idlelock_take);
 
 void drm_idlelock_release(struct drm_lock_data *lock_data)
 {
@@ -364,6 +365,7 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
}
spin_unlock_bh(&lock_data->spinlock);
 }
+EXPORT_SYMBOL(drm_idlelock_release);
 
 int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv)
 {
diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 472adcf..f50431c 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -62,6 +62,7 @@ static struct drm_driver driver = {
.load = via_driver_load,
.unload = via_driver_unload,
.open = via_driver_open,
+   .preclose = via_reclaim_buffers_locked,
.postclose = via_driver_postclose,
.context_dtor = via_final_context,
.get_vblank_counter = via_get_vblank_counter,
@@ -72,9 +73,6 @@ static struct drm_driver driver = {
.irq_uninstall = via_driver_irq_uninstall,
.irq_handler = via_driver_irq_handler,
.dma_quiescent = via_driver_dma_quiescent,
-   .reclaim_buffers = drm_core_reclaim_buffers,
-   .reclaim_buffers_locked = NULL,
-   .reclaim_buffers_idlelocked = via_reclaim_buffers_locked,
.lastclose = via_lastclose,
.ioctls = via_ioctls,
.fops = {
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index 80eab7d..8ce95c5 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -217,6 +217,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
 {
struct via_file_private *file_priv = file->driver_priv;
struct via_memblock *entry, *next;
+   int release_idlelock = 0;
+
+   if (file->master && file->master->lock.hw_lock)
+   drm_idlelock_take(&file->master->lock);
 
mutex_lock(&dev->struct_mutex);
if (list_empty(&file_priv->obj_list)) {
@@ -224,8 +228,7 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
return;
}
 
-   if (dev->driver->dma_quiescent)
-   dev->driver->dma_quiescent(dev);
+   via_driver_dma_quiescent(dev);
 
list_for_each_entry_safe(entry, next, &file_priv->obj_list,
 owner_list) {
@@ -234,5 +237,9 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
kfree(entry);
}
mutex_unlock(&dev->struct_mutex);
+
+   if (release_idlelock)
+   drm_idlelock_release(&file->master->lock);
+
return;
 }
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 10/23] drm: kill drm_sman

2011-10-27 Thread Daniel Vetter
No longer used.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/Makefile   |2 +-
 drivers/gpu/drm/drm_sman.c |  210 
 include/drm/drm_sman.h |  151 ---
 3 files changed, 1 insertions(+), 362 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_sman.c
 delete mode 100644 include/drm/drm_sman.h

diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 89cf05a..ea083cf 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -9,7 +9,7 @@ drm-y   :=  drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \
drm_drv.o drm_fops.o drm_gem.o drm_ioctl.o drm_irq.o \
drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \
-   drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \
+   drm_platform.o drm_sysfs.o drm_hashtab.o drm_mm.o \
drm_crtc.o drm_modes.o drm_edid.o \
drm_info.o drm_debugfs.o drm_encoder_slave.o \
drm_trace_points.o drm_global.o drm_usb.o
diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
deleted file mode 100644
index 1a4fb9f..000
--- a/drivers/gpu/drm/drm_sman.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck., ND., USA.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **/
-/*
- * Simple memory manager interface that keeps track on allocate regions on a
- * per "owner" basis. All regions associated with an "owner" can be released
- * with a simple call. Typically if the "owner" exists. The owner is any
- * "unsigned long" identifier. Can typically be a pointer to a file private
- * struct or a context identifier.
- *
- * Authors:
- * Thomas Hellström 
- */
-
-#include "drm_sman.h"
-
-struct drm_owner_item {
-   struct drm_hash_item owner_hash;
-   struct list_head sman_list;
-   struct list_head mem_blocks;
-};
-
-void drm_sman_takedown(struct drm_sman * sman)
-{
-   kfree(sman->mm);
-}
-
-EXPORT_SYMBOL(drm_sman_takedown);
-
-int
-drm_sman_init(struct drm_sman * sman, unsigned int num_managers,
- unsigned int user_order, unsigned int owner_order)
-{
-   int ret = 0;
-
-   sman->mm = kcalloc(num_managers, sizeof(*sman->mm), GFP_KERNEL);
-   if (!sman->mm) {
-   ret = -ENOMEM;
-   return ret;
-   }
-   sman->num_managers = num_managers;
-
-   return 0;
-}
-
-EXPORT_SYMBOL(drm_sman_init);
-
-static void *drm_sman_mm_allocate(void *private, unsigned long size,
- unsigned alignment)
-{
-   struct drm_mm *mm = (struct drm_mm *) private;
-   struct drm_mm_node *tmp;
-
-   tmp = drm_mm_search_free(mm, size, alignment, 1);
-   if (!tmp) {
-   return NULL;
-   }
-   tmp = drm_mm_get_block(tmp, size, alignment);
-   return tmp;
-}
-
-static void drm_sman_mm_free(void *private, void *ref)
-{
-   struct drm_mm_node *node = (struct drm_mm_node *) ref;
-
-   drm_mm_put_block(node);
-}
-
-static void drm_sman_mm_destroy(void *private)
-{
-   struct drm_mm *mm = (struct drm_mm *) private;
-   drm_mm_takedown(mm);
-   kfree(mm);
-}
-
-static unsigned long drm_sman_mm_offset(void *private, void *ref)
-{
-   struct drm_mm_node *node = (struct drm_mm_node *) ref;
-   return node->start;
-}
-
-int
-drm_sman_set_range(struct drm_sman * sman, unsigned int manager,
-  unsigned long start, unsigned long size)
-{
-   struct drm_sman_mm *sman_mm;
-   struct drm_mm *mm;
-   int ret;
-
-   BUG_ON(manager >= 

[PATCH 09/23] drm/sis: use drm_mm instead of drm_sman

2011-10-27 Thread Daniel Vetter
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/sis/sis_drv.c |4 -
 drivers/gpu/drm/sis/sis_drv.h |5 +-
 drivers/gpu/drm/sis/sis_mm.c  |  137 +++-
 3 files changed, 68 insertions(+), 78 deletions(-)

diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 9f5fbcf..278d1b0 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -47,9 +47,6 @@ static int sis_driver_load(struct drm_device *dev, unsigned 
long chipset)
dev->dev_private = (void *)dev_priv;
dev_priv->chipset = chipset;
idr_init(&dev->object_name_idr);
-   ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
-   if (ret)
-   kfree(dev_priv);
 
return ret;
 }
@@ -58,7 +55,6 @@ static int sis_driver_unload(struct drm_device *dev)
 {
drm_sis_private_t *dev_priv = dev->dev_private;
 
-   drm_sman_takedown(&dev_priv->sman);
idr_remove_all(&dev_priv->object_idr);
idr_destroy(&dev_priv->object_idr);
 
diff --git a/drivers/gpu/drm/sis/sis_drv.h b/drivers/gpu/drm/sis/sis_drv.h
index fcdd06a..573758b 100644
--- a/drivers/gpu/drm/sis/sis_drv.h
+++ b/drivers/gpu/drm/sis/sis_drv.h
@@ -44,7 +44,7 @@ enum sis_family {
SIS_CHIP_315 = 1,
 };
 
-#include "drm_sman.h"
+#include "drm_mm.h"
 
 
 #define SIS_BASE (dev_priv->mmio)
@@ -54,12 +54,13 @@ enum sis_family {
 typedef struct drm_sis_private {
drm_local_map_t *mmio;
unsigned int idle_fault;
-   struct drm_sman sman;
unsigned int chipset;
int vram_initialized;
int agp_initialized;
unsigned long vram_offset;
unsigned long agp_offset;
+   struct drm_mm vram_mm;
+   struct drm_mm agp_mm;
/** Mapping of userspace keys to mm objects */
struct idr object_idr;
 } drm_sis_private_t;
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index ef6045a..ff34680 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -41,40 +41,18 @@
 #define AGP_TYPE 1
 
 
+struct sis_memblock {
+   struct drm_mm_node mm_node;
+   struct sis_memreq req;
+   struct list_head owner_list;
+};
+
 #if defined(CONFIG_FB_SIS) || defined(CONFIG_FB_SIS_MODULE)
 /* fb management via fb device */
 
 #define SIS_MM_ALIGN_SHIFT 0
 #define SIS_MM_ALIGN_MASK 0
 
-static void *sis_sman_mm_allocate(void *private, unsigned long size,
- unsigned alignment)
-{
-   struct sis_memreq req;
-
-   req.size = size;
-   sis_malloc(&req);
-   if (req.size == 0)
-   return NULL;
-   else
-   return (void *)(unsigned long)~req.offset;
-}
-
-static void sis_sman_mm_free(void *private, void *ref)
-{
-   sis_free(~((unsigned long)ref));
-}
-
-static void sis_sman_mm_destroy(void *private)
-{
-   ;
-}
-
-static unsigned long sis_sman_mm_offset(void *private, void *ref)
-{
-   return ~((unsigned long)ref);
-}
-
 #else /* CONFIG_FB_SIS[_MODULE] */
 
 #define SIS_MM_ALIGN_SHIFT 4
@@ -86,30 +64,11 @@ static int sis_fb_init(struct drm_device *dev, void *data, 
struct drm_file *file
 {
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_fb_t *fb = data;
-   int ret;
 
mutex_lock(&dev->struct_mutex);
-#if defined(CONFIG_FB_SIS) || defined(CONFIG_FB_SIS_MODULE)
-   {
-   struct drm_sman_mm sman_mm;
-   sman_mm.private = (void *)0x;
-   sman_mm.allocate = sis_sman_mm_allocate;
-   sman_mm.free = sis_sman_mm_free;
-   sman_mm.destroy = sis_sman_mm_destroy;
-   sman_mm.offset = sis_sman_mm_offset;
-   ret =
-   drm_sman_set_manager(&dev_priv->sman, VIDEO_TYPE, &sman_mm);
-   }
-#else
-   ret = drm_sman_set_range(&dev_priv->sman, VIDEO_TYPE, 0,
-fb->size >> SIS_MM_ALIGN_SHIFT);
-#endif
-
-   if (ret) {
-   DRM_ERROR("VRAM memory manager initialisation error\n");
-   mutex_unlock(&dev->struct_mutex);
-   return ret;
-   }
+   /* Unconditionally init the drm_mm, even though we don't use it when the
+* fb sis driver is available - make cleanup easier. */
+   drm_mm_init(&dev_priv->vram_mm, 0, fb->size >> SIS_MM_ALIGN_SHIFT);
 
dev_priv->vram_initialized = 1;
dev_priv->vram_offset = fb->offset;
@@ -126,8 +85,9 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file,
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_mem_t *mem = data;
int retval = 0, user_key;
-   struct drm_memblock_item *item;
+   struct sis_memblock *item;
struct sis_file_private *file_priv = file->driver_priv;
+   unsigned long offset;
 
mutex_lock(&dev->struct_mutex);
 
@@ -139,13 +99,35 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file,
return -E

[PATCH 08/23] drm/via: use drm_mm instead of drm_sman

2011-10-27 Thread Daniel Vetter
Now that we are again in proper control of owner_list, we need to
properly list_del it on free.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/via/via_drv.h |5 ++-
 drivers/gpu/drm/via/via_map.c |7 
 drivers/gpu/drm/via/via_mm.c  |   72 ++--
 3 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index 108ea71..88edacc 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -24,7 +24,7 @@
 #ifndef _VIA_DRV_H_
 #define _VIA_DRV_H_
 
-#include "drm_sman.h"
+#include "drm_mm.h"
 #define DRIVER_AUTHOR  "Various"
 
 #define DRIVER_NAME"via"
@@ -88,9 +88,10 @@ typedef struct drm_via_private {
uint32_t irq_pending_mask;
int *irq_map;
unsigned int idle_fault;
-   struct drm_sman sman;
int vram_initialized;
+   struct drm_mm vram_mm;
int agp_initialized;
+   struct drm_mm agp_mm;
/** Mapping of userspace keys to mm objects */
struct idr object_idr;
unsigned long vram_offset;
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index fa5afbc..a2ab343 100644
--- a/drivers/gpu/drm/via/via_map.c
+++ b/drivers/gpu/drm/via/via_map.c
@@ -105,15 +105,9 @@ int via_driver_load(struct drm_device *dev, unsigned long 
chipset)
dev_priv->chipset = chipset;
 
idr_init(&dev->object_name_idr);
-   ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
-   if (ret) {
-   kfree(dev_priv);
-   return ret;
-   }
 
ret = drm_vblank_init(dev, 1);
if (ret) {
-   drm_sman_takedown(&dev_priv->sman);
kfree(dev_priv);
return ret;
}
@@ -125,7 +119,6 @@ int via_driver_unload(struct drm_device *dev)
 {
drm_via_private_t *dev_priv = dev->dev_private;
 
-   drm_sman_takedown(&dev_priv->sman);
idr_remove_all(&dev_priv->object_idr);
idr_destroy(&dev_priv->object_idr);
 
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index af9e771..80eab7d 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -28,26 +28,22 @@
 #include "drmP.h"
 #include "via_drm.h"
 #include "via_drv.h"
-#include "drm_sman.h"
 
 #define VIA_MM_ALIGN_SHIFT 4
 #define VIA_MM_ALIGN_MASK ((1 << VIA_MM_ALIGN_SHIFT) - 1)
 
+struct via_memblock {
+   struct drm_mm_node mm_node;
+   struct list_head owner_list;
+};
+
 int via_agp_init(struct drm_device *dev, void *data, struct drm_file 
*file_priv)
 {
drm_via_agp_t *agp = data;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
-   int ret;
 
mutex_lock(&dev->struct_mutex);
-   ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_AGP, 0,
-agp->size >> VIA_MM_ALIGN_SHIFT);
-
-   if (ret) {
-   DRM_ERROR("AGP memory manager initialisation error\n");
-   mutex_unlock(&dev->struct_mutex);
-   return ret;
-   }
+   drm_mm_init(&dev_priv->agp_mm, 0, agp->size >> VIA_MM_ALIGN_SHIFT);
 
dev_priv->agp_initialized = 1;
dev_priv->agp_offset = agp->offset;
@@ -61,17 +57,9 @@ int via_fb_init(struct drm_device *dev, void *data, struct 
drm_file *file_priv)
 {
drm_via_fb_t *fb = data;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
-   int ret;
 
mutex_lock(&dev->struct_mutex);
-   ret = drm_sman_set_range(&dev_priv->sman, VIA_MEM_VIDEO, 0,
-fb->size >> VIA_MM_ALIGN_SHIFT);
-
-   if (ret) {
-   DRM_ERROR("VRAM memory manager initialisation error\n");
-   mutex_unlock(&dev->struct_mutex);
-   return ret;
-   }
+   drm_mm_init(&dev_priv->vram_mm, 0, fb->size >> VIA_MM_ALIGN_SHIFT);
 
dev_priv->vram_initialized = 1;
dev_priv->vram_offset = fb->offset;
@@ -108,9 +96,14 @@ void via_lastclose(struct drm_device *dev)
return;
 
mutex_lock(&dev->struct_mutex);
-   drm_sman_cleanup(&dev_priv->sman);
-   dev_priv->vram_initialized = 0;
-   dev_priv->agp_initialized = 0;
+   if (dev_priv->vram_initialized) {
+   drm_mm_takedown(&dev_priv->vram_mm);
+   dev_priv->vram_initialized = 0;
+   }
+   if (dev_priv->agp_initialized) {
+   drm_mm_takedown(&dev_priv->agp_mm);
+   dev_priv->agp_initialized = 0;
+   }
mutex_unlock(&dev->struct_mutex);
 }
 
@@ -119,7 +112,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,
 {
drm_via_mem_t *mem = data;
int retval = 0, user_key;
-   struct drm_memblock_item *item;
+   struct via_memblock *item;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
struct via_file_private *file_priv = file->driver_priv;
unsigned lon

[PATCH 07/23] drm/sman: kill user_hash_tab

2011-10-27 Thread Daniel Vetter
No longer used.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_sman.c |   36 ++--
 include/drm/drm_sman.h |5 -
 2 files changed, 2 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
index 37a8844..1a4fb9f 100644
--- a/drivers/gpu/drm/drm_sman.c
+++ b/drivers/gpu/drm/drm_sman.c
@@ -46,7 +46,6 @@ struct drm_owner_item {
 
 void drm_sman_takedown(struct drm_sman * sman)
 {
-   drm_ht_remove(&sman->user_hash_tab);
kfree(sman->mm);
 }
 
@@ -61,16 +60,11 @@ drm_sman_init(struct drm_sman * sman, unsigned int 
num_managers,
sman->mm = kcalloc(num_managers, sizeof(*sman->mm), GFP_KERNEL);
if (!sman->mm) {
ret = -ENOMEM;
-   goto out;
+   return ret;
}
sman->num_managers = num_managers;
-   ret = drm_ht_create(&sman->user_hash_tab, user_order);
-   if (!ret)
-   goto out;
 
-   kfree(sman->mm);
-out:
-   return ret;
+   return 0;
 }
 
 EXPORT_SYMBOL(drm_sman_init);
@@ -179,15 +173,8 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman 
*sman, unsigned int man
memblock->mm = sman_mm;
memblock->sman = sman;
 
-   if (drm_ht_just_insert_please
-   (&sman->user_hash_tab, &memblock->user_hash,
-(unsigned long)memblock, 32, 0, 0))
-   goto out1;
-
return memblock;
 
-out1:
-   kfree(memblock);
 out:
sman_mm->free(sman_mm->private, tmp);
 
@@ -198,31 +185,12 @@ EXPORT_SYMBOL(drm_sman_alloc);
 
 void drm_sman_free(struct drm_memblock_item *item)
 {
-   struct drm_sman *sman = item->sman;
-
list_del(&item->owner_list);
-   drm_ht_remove_item(&sman->user_hash_tab, &item->user_hash);
item->mm->free(item->mm->private, item->mm_info);
kfree(item);
 }
 EXPORT_SYMBOL(drm_sman_free);
 
-int drm_sman_free_key(struct drm_sman *sman, unsigned int key)
-{
-   struct drm_hash_item *hash_item;
-   struct drm_memblock_item *memblock_item;
-
-   if (drm_ht_find_item(&sman->user_hash_tab, key, &hash_item))
-   return -EINVAL;
-
-   memblock_item = drm_hash_entry(hash_item, struct drm_memblock_item,
-  user_hash);
-   drm_sman_free(memblock_item);
-   return 0;
-}
-
-EXPORT_SYMBOL(drm_sman_free_key);
-
 void drm_sman_cleanup(struct drm_sman *sman)
 {
unsigned int i;
diff --git a/include/drm/drm_sman.h b/include/drm/drm_sman.h
index 34ae5ca..031e521 100644
--- a/include/drm/drm_sman.h
+++ b/include/drm/drm_sman.h
@@ -87,7 +87,6 @@ struct drm_memblock_item {
 struct drm_sman {
struct drm_sman_mm *mm;
int num_managers;
-   struct drm_open_hash user_hash_tab;
 };
 
 /*
@@ -139,11 +138,7 @@ extern struct drm_memblock_item *drm_sman_alloc(struct 
drm_sman * sman,
unsigned long size,
unsigned alignment,
unsigned long owner);
-/*
- * Free a memory block identified by its user hash key.
- */
 
-extern int drm_sman_free_key(struct drm_sman * sman, unsigned int key);
 extern void drm_sman_free(struct drm_memblock_item *item);
 
 /*
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 06/23] drm/sis: track user->memblock mapping with idr

2011-10-27 Thread Daniel Vetter
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/sis/sis_drv.c |4 +++
 drivers/gpu/drm/sis/sis_drv.h |2 +
 drivers/gpu/drm/sis/sis_mm.c  |   60 ++--
 drivers/gpu/drm/via/via_map.c |2 +
 4 files changed, 53 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index a5dcd0a..9f5fbcf 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -46,6 +46,7 @@ static int sis_driver_load(struct drm_device *dev, unsigned 
long chipset)
 
dev->dev_private = (void *)dev_priv;
dev_priv->chipset = chipset;
+   idr_init(&dev->object_name_idr);
ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
if (ret)
kfree(dev_priv);
@@ -58,6 +59,9 @@ static int sis_driver_unload(struct drm_device *dev)
drm_sis_private_t *dev_priv = dev->dev_private;
 
drm_sman_takedown(&dev_priv->sman);
+   idr_remove_all(&dev_priv->object_idr);
+   idr_destroy(&dev_priv->object_idr);
+
kfree(dev_priv);
 
return 0;
diff --git a/drivers/gpu/drm/sis/sis_drv.h b/drivers/gpu/drm/sis/sis_drv.h
index 194303c..fcdd06a 100644
--- a/drivers/gpu/drm/sis/sis_drv.h
+++ b/drivers/gpu/drm/sis/sis_drv.h
@@ -60,6 +60,8 @@ typedef struct drm_sis_private {
int agp_initialized;
unsigned long vram_offset;
unsigned long agp_offset;
+   /** Mapping of userspace keys to mm objects */
+   struct idr object_idr;
 } drm_sis_private_t;
 
 extern int sis_idle(struct drm_device *dev);
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index dff70da..ef6045a 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -125,7 +125,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file,
 {
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_mem_t *mem = data;
-   int retval = 0;
+   int retval = 0, user_key;
struct drm_memblock_item *item;
struct sis_file_private *file_priv = file->driver_priv;
 
@@ -141,24 +141,46 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file,
 
mem->size = (mem->size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT;
item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0, 0);
+   if (!item) {
+   retval = -ENOMEM;
+   goto fail_alloc;
+   }
 
-   if (item) {
-   INIT_LIST_HEAD(&item->owner_list);
-   list_add(&item->owner_list, &file_priv->obj_list);
-   mem->offset = ((pool == 0) ?
- dev_priv->vram_offset : dev_priv->agp_offset) +
-   (item->mm->
-offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT);
-   mem->free = item->user_hash.key;
-   mem->size = mem->size << SIS_MM_ALIGN_SHIFT;
-   } else {
-   mem->offset = 0;
-   mem->size = 0;
-   mem->free = 0;
+again:
+   if (idr_pre_get(&dev_priv->object_idr, GFP_KERNEL) == 0) {
retval = -ENOMEM;
+   goto fail_idr;
}
+
+   /* do the allocation under our spinlock */
+   retval = idr_get_new_above(&dev_priv->object_idr, item, 1, &user_key);
+   if (retval == -EAGAIN)
+   goto again;
+   if (retval)
+   goto fail_idr;
+
+   INIT_LIST_HEAD(&item->owner_list);
+   list_add(&item->owner_list, &file_priv->obj_list);
+   mutex_unlock(&dev->struct_mutex);
+
+   mem->offset = ((pool == 0) ?
+ dev_priv->vram_offset : dev_priv->agp_offset) +
+   (item->mm->
+offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT);
+   mem->free = user_key;
+   mem->size = mem->size << SIS_MM_ALIGN_SHIFT;
+
+   return 0;
+
+fail_idr:
+   drm_sman_free(item);
+fail_alloc:
mutex_unlock(&dev->struct_mutex);
 
+   mem->offset = 0;
+   mem->size = 0;
+   mem->free = 0;
+
DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem->size,
  mem->offset);
 
@@ -169,10 +191,18 @@ static int sis_drm_free(struct drm_device *dev, void 
*data, struct drm_file *fil
 {
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_mem_t *mem = data;
+   struct drm_memblock_item *obj;
int ret;
 
mutex_lock(&dev->struct_mutex);
-   ret = drm_sman_free_key(&dev_priv->sman, mem->free);
+   obj = idr_find(&dev_priv->object_idr, mem->free);
+   if (obj == NULL) {
+   mutex_unlock(&dev->struct_mutex);
+   return -EINVAL;
+   }
+
+   idr_remove(&dev_priv->object_idr, mem->free);
+   drm_sman_free(obj);
mutex_unlock(&dev->struct_mutex);
DRM_DEBUG("free = 0x%lx\n", mem->free);
 
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index b09f659..fa5afbc 100644
--- a/drivers/gpu/drm

[PATCH 05/23] drm/via: track user->memblock mapping with idr

2011-10-27 Thread Daniel Vetter
Massive indirection through a hashtable for a simple key->pointer
look-up actually just adds bloat.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/via/via_drv.h |2 +
 drivers/gpu/drm/via/via_map.c |1 +
 drivers/gpu/drm/via/via_mm.c  |   61 +++--
 3 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
index 9cf87d9..108ea71 100644
--- a/drivers/gpu/drm/via/via_drv.h
+++ b/drivers/gpu/drm/via/via_drv.h
@@ -91,6 +91,8 @@ typedef struct drm_via_private {
struct drm_sman sman;
int vram_initialized;
int agp_initialized;
+   /** Mapping of userspace keys to mm objects */
+   struct idr object_idr;
unsigned long vram_offset;
unsigned long agp_offset;
drm_via_blitq_t blit_queues[VIA_NUM_BLIT_ENGINES];
diff --git a/drivers/gpu/drm/via/via_map.c b/drivers/gpu/drm/via/via_map.c
index 6cca9a7..b09f659 100644
--- a/drivers/gpu/drm/via/via_map.c
+++ b/drivers/gpu/drm/via/via_map.c
@@ -104,6 +104,7 @@ int via_driver_load(struct drm_device *dev, unsigned long 
chipset)
 
dev_priv->chipset = chipset;
 
+   idr_init(&dev->object_name_idr);
ret = drm_sman_init(&dev_priv->sman, 2, 12, 8);
if (ret) {
kfree(dev_priv);
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index ea3d621..af9e771 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -118,7 +118,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,
  struct drm_file *file)
 {
drm_via_mem_t *mem = data;
-   int retval = 0;
+   int retval = 0, user_key;
struct drm_memblock_item *item;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
struct via_file_private *file_priv = file->driver_priv;
@@ -139,24 +139,46 @@ int via_mem_alloc(struct drm_device *dev, void *data,
 
tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0, 0);
+   if (!item) {
+   retval = -ENOMEM;
+   goto fail_alloc;
+   }
 
-   if (item) {
-   INIT_LIST_HEAD(&item->owner_list);
-   list_add(&item->owner_list, &file_priv->obj_list);
-   mem->offset = ((mem->type == VIA_MEM_VIDEO) ?
- dev_priv->vram_offset : dev_priv->agp_offset) +
-   (item->mm->
-offset(item->mm, item->mm_info) << VIA_MM_ALIGN_SHIFT);
-   mem->index = item->user_hash.key;
-   } else {
-   mem->offset = 0;
-   mem->size = 0;
-   mem->index = 0;
-   DRM_DEBUG("Video memory allocation failed\n");
+again:
+   if (idr_pre_get(&dev_priv->object_idr, GFP_KERNEL) == 0) {
retval = -ENOMEM;
+   goto fail_idr;
}
+
+   /* do the allocation under our spinlock */
+   retval = idr_get_new_above(&dev_priv->object_idr, item, 1, &user_key);
+   if (retval == -EAGAIN)
+   goto again;
+   if (retval)
+   goto fail_idr;
+
+   INIT_LIST_HEAD(&item->owner_list);
+   list_add(&item->owner_list, &file_priv->obj_list);
mutex_unlock(&dev->struct_mutex);
 
+   mem->offset = ((mem->type == VIA_MEM_VIDEO) ?
+ dev_priv->vram_offset : dev_priv->agp_offset) +
+   (item->mm->
+offset(item->mm, item->mm_info) << VIA_MM_ALIGN_SHIFT);
+   mem->index = user_key;
+
+   return 0;
+
+fail_idr:
+   drm_sman_free(item);
+fail_alloc:
+   mutex_unlock(&dev->struct_mutex);
+
+   mem->offset = 0;
+   mem->size = 0;
+   mem->index = 0;
+   DRM_DEBUG("Video memory allocation failed\n");
+
return retval;
 }
 
@@ -164,11 +186,20 @@ int via_mem_free(struct drm_device *dev, void *data, 
struct drm_file *file_priv)
 {
drm_via_private_t *dev_priv = dev->dev_private;
drm_via_mem_t *mem = data;
+   struct drm_memblock_item *obj;
int ret;
 
mutex_lock(&dev->struct_mutex);
-   ret = drm_sman_free_key(&dev_priv->sman, mem->index);
+   obj = idr_find(&dev_priv->object_idr, mem->index);
+   if (obj == NULL) {
+   mutex_unlock(&dev->struct_mutex);
+   return -EINVAL;
+   }
+
+   idr_remove(&dev_priv->object_idr, mem->index);
+   drm_sman_free(obj);
mutex_unlock(&dev->struct_mutex);
+
DRM_DEBUG("free = 0x%lx\n", mem->index);
 
return ret;
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 04/23] drm/sman: rip out owner tracking

2011-10-27 Thread Daniel Vetter
In contrast to kms drivers, sis/via _always_ associated a buffer with
a drm fd. So by the time we reach lastclose, all open drm fds are gone
and with them their associated objects.

So when sis/via call drm_sman_cleanup in their lastclose funcs, that
will free 0 objects.

The owner tracking now serves no purpose at all, hence rip it ou. We
can't kill the corresponding fields in struct drm_memblock_item yet
because we hijack these in the new driver private owner tracking. But
now that drm_sman.c doesn't touch ->owner_list anymore, we need to
kill the list_move hack and properly add the item to the file_priv
list.

Also leave the list_del(&obj->owner_list) in drm_sman_free for the
moment, it will move to the drivers when sman disappears completely.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_sman.c   |   71 --
 drivers/gpu/drm/sis/sis_mm.c |3 +-
 drivers/gpu/drm/via/via_mm.c |3 +-
 include/drm/drm_sman.h   |2 -
 4 files changed, 4 insertions(+), 75 deletions(-)

diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
index a672fea..37a8844 100644
--- a/drivers/gpu/drm/drm_sman.c
+++ b/drivers/gpu/drm/drm_sman.c
@@ -47,7 +47,6 @@ struct drm_owner_item {
 void drm_sman_takedown(struct drm_sman * sman)
 {
drm_ht_remove(&sman->user_hash_tab);
-   drm_ht_remove(&sman->owner_hash_tab);
kfree(sman->mm);
 }
 
@@ -65,16 +64,10 @@ drm_sman_init(struct drm_sman * sman, unsigned int 
num_managers,
goto out;
}
sman->num_managers = num_managers;
-   INIT_LIST_HEAD(&sman->owner_items);
-   ret = drm_ht_create(&sman->owner_hash_tab, owner_order);
-   if (ret)
-   goto out1;
ret = drm_ht_create(&sman->user_hash_tab, user_order);
if (!ret)
goto out;
 
-   drm_ht_remove(&sman->owner_hash_tab);
-out1:
kfree(sman->mm);
 out:
return ret;
@@ -160,44 +153,12 @@ drm_sman_set_manager(struct drm_sman * sman, unsigned int 
manager,
 }
 EXPORT_SYMBOL(drm_sman_set_manager);
 
-static struct drm_owner_item *drm_sman_get_owner_item(struct drm_sman * sman,
-unsigned long owner)
-{
-   int ret;
-   struct drm_hash_item *owner_hash_item;
-   struct drm_owner_item *owner_item;
-
-   ret = drm_ht_find_item(&sman->owner_hash_tab, owner, &owner_hash_item);
-   if (!ret) {
-   return drm_hash_entry(owner_hash_item, struct drm_owner_item,
- owner_hash);
-   }
-
-   owner_item = kzalloc(sizeof(*owner_item), GFP_KERNEL);
-   if (!owner_item)
-   goto out;
-
-   INIT_LIST_HEAD(&owner_item->mem_blocks);
-   owner_item->owner_hash.key = owner;
-   if (drm_ht_insert_item(&sman->owner_hash_tab, &owner_item->owner_hash))
-   goto out1;
-
-   list_add_tail(&owner_item->sman_list, &sman->owner_items);
-   return owner_item;
-
-out1:
-   kfree(owner_item);
-out:
-   return NULL;
-}
-
 struct drm_memblock_item *drm_sman_alloc(struct drm_sman *sman, unsigned int 
manager,
unsigned long size, unsigned alignment,
unsigned long owner)
 {
void *tmp;
struct drm_sman_mm *sman_mm;
-   struct drm_owner_item *owner_item;
struct drm_memblock_item *memblock;
 
BUG_ON(manager >= sman->num_managers);
@@ -223,16 +184,8 @@ struct drm_memblock_item *drm_sman_alloc(struct drm_sman 
*sman, unsigned int man
 (unsigned long)memblock, 32, 0, 0))
goto out1;
 
-   owner_item = drm_sman_get_owner_item(sman, owner);
-   if (!owner_item)
-   goto out2;
-
-   list_add_tail(&memblock->owner_list, &owner_item->mem_blocks);
-
return memblock;
 
-out2:
-   drm_ht_remove_item(&sman->user_hash_tab, &memblock->user_hash);
 out1:
kfree(memblock);
 out:
@@ -270,35 +223,11 @@ int drm_sman_free_key(struct drm_sman *sman, unsigned int 
key)
 
 EXPORT_SYMBOL(drm_sman_free_key);
 
-static void drm_sman_remove_owner(struct drm_sman *sman,
- struct drm_owner_item *owner_item)
-{
-   list_del(&owner_item->sman_list);
-   drm_ht_remove_item(&sman->owner_hash_tab, &owner_item->owner_hash);
-   kfree(owner_item);
-}
-
-static void drm_sman_do_owner_cleanup(struct drm_sman *sman,
- struct drm_owner_item *owner_item)
-{
-   struct drm_memblock_item *entry, *next;
-
-   list_for_each_entry_safe(entry, next, &owner_item->mem_blocks,
-owner_list) {
-   drm_sman_free(entry);
-   }
-   drm_sman_remove_owner(sman, owner_item);
-}
-
 void drm_sman_cleanup(struct drm_sman *sman)
 {
-   struct drm_owner_item *entry, *next;
unsigned int i;
struct drm_sman_mm *sman_mm;
 
-   list_for_each_entry_safe(e

[PATCH 03/23] drm/sman: kill owner tracking interface functions

2011-10-27 Thread Daniel Vetter
These are now unused.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_sman.c |   38 --
 include/drm/drm_sman.h |   19 ---
 2 files changed, 0 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
index 37548b7..a672fea 100644
--- a/drivers/gpu/drm/drm_sman.c
+++ b/drivers/gpu/drm/drm_sman.c
@@ -278,27 +278,6 @@ static void drm_sman_remove_owner(struct drm_sman *sman,
kfree(owner_item);
 }
 
-int drm_sman_owner_clean(struct drm_sman *sman, unsigned long owner)
-{
-
-   struct drm_hash_item *hash_item;
-   struct drm_owner_item *owner_item;
-
-   if (drm_ht_find_item(&sman->owner_hash_tab, owner, &hash_item)) {
-   return -1;
-   }
-
-   owner_item = drm_hash_entry(hash_item, struct drm_owner_item, 
owner_hash);
-   if (owner_item->mem_blocks.next == &owner_item->mem_blocks) {
-   drm_sman_remove_owner(sman, owner_item);
-   return -1;
-   }
-
-   return 0;
-}
-
-EXPORT_SYMBOL(drm_sman_owner_clean);
-
 static void drm_sman_do_owner_cleanup(struct drm_sman *sman,
  struct drm_owner_item *owner_item)
 {
@@ -311,23 +290,6 @@ static void drm_sman_do_owner_cleanup(struct drm_sman 
*sman,
drm_sman_remove_owner(sman, owner_item);
 }
 
-void drm_sman_owner_cleanup(struct drm_sman *sman, unsigned long owner)
-{
-
-   struct drm_hash_item *hash_item;
-   struct drm_owner_item *owner_item;
-
-   if (drm_ht_find_item(&sman->owner_hash_tab, owner, &hash_item)) {
-
-   return;
-   }
-
-   owner_item = drm_hash_entry(hash_item, struct drm_owner_item, 
owner_hash);
-   drm_sman_do_owner_cleanup(sman, owner_item);
-}
-
-EXPORT_SYMBOL(drm_sman_owner_cleanup);
-
 void drm_sman_cleanup(struct drm_sman *sman)
 {
struct drm_owner_item *entry, *next;
diff --git a/include/drm/drm_sman.h b/include/drm/drm_sman.h
index 3b65ccf..d5ed903 100644
--- a/include/drm/drm_sman.h
+++ b/include/drm/drm_sman.h
@@ -149,25 +149,6 @@ extern int drm_sman_free_key(struct drm_sman * sman, 
unsigned int key);
 extern void drm_sman_free(struct drm_memblock_item *item);
 
 /*
- * returns 1 iff there are no stale memory blocks associated with this owner.
- * Typically called to determine if we need to idle the hardware and call
- * drm_sman_owner_cleanup. If there are no stale memory blocks, it removes all
- * resources associated with owner.
- */
-
-extern int drm_sman_owner_clean(struct drm_sman * sman, unsigned long owner);
-
-/*
- * Frees all stale memory blocks associated with this owner. Note that this
- * requires that the hardware is finished with all blocks, so the graphics 
engine
- * should be idled before this call is made. This function also frees
- * any resources associated with "owner" and should be called when owner
- * is not going to be referenced anymore.
- */
-
-extern void drm_sman_owner_cleanup(struct drm_sman * sman, unsigned long 
owner);
-
-/*
  * Frees all stale memory blocks associated with the memory manager.
  * See idling above.
  */
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 02/23] drm/via: track obj->drm_fd relations in the driver

2011-10-27 Thread Daniel Vetter
Exactly like the previous patch for sis.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/via/via_drv.c |   25 +
 drivers/gpu/drm/via/via_mm.c  |   22 ++
 include/drm/via_drm.h |4 
 3 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 920a552..472adcf 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -28,6 +28,29 @@
 
 #include "drm_pciids.h"
 
+static int via_driver_open(struct drm_device *dev, struct drm_file *file)
+{
+   struct via_file_private *file_priv;
+
+   DRM_DEBUG_DRIVER("\n");
+   file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
+   if (!file_priv)
+   return -ENOMEM;
+
+   file->driver_priv = file_priv;
+
+   INIT_LIST_HEAD(&file_priv->obj_list);
+
+   return 0;
+}
+
+void via_driver_postclose(struct drm_device *dev, struct drm_file *file)
+{
+   struct via_file_private *file_priv = file->driver_priv;
+
+   kfree(file_priv);
+}
+
 static struct pci_device_id pciidlist[] = {
viadrv_PCI_IDS
 };
@@ -38,6 +61,8 @@ static struct drm_driver driver = {
DRIVER_IRQ_SHARED,
.load = via_driver_load,
.unload = via_driver_unload,
+   .open = via_driver_open,
+   .postclose = via_driver_postclose,
.context_dtor = via_final_context,
.get_vblank_counter = via_get_vblank_counter,
.enable_vblank = via_enable_vblank,
diff --git a/drivers/gpu/drm/via/via_mm.c b/drivers/gpu/drm/via/via_mm.c
index 6cc2dad..19bb77c 100644
--- a/drivers/gpu/drm/via/via_mm.c
+++ b/drivers/gpu/drm/via/via_mm.c
@@ -115,12 +115,13 @@ void via_lastclose(struct drm_device *dev)
 }
 
 int via_mem_alloc(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
+ struct drm_file *file)
 {
drm_via_mem_t *mem = data;
int retval = 0;
struct drm_memblock_item *item;
drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
+   struct via_file_private *file_priv = file->driver_priv;
unsigned long tmpSize;
 
if (mem->type > VIA_MEM_AGP) {
@@ -137,10 +138,10 @@ int via_mem_alloc(struct drm_device *dev, void *data,
}
 
tmpSize = (mem->size + VIA_MM_ALIGN_MASK) >> VIA_MM_ALIGN_SHIFT;
-   item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0,
- (unsigned long)file_priv);
-   mutex_unlock(&dev->struct_mutex);
+   item = drm_sman_alloc(&dev_priv->sman, mem->type, tmpSize, 0, 0);
+
if (item) {
+   list_move(&item->owner_list, &file_priv->obj_list);
mem->offset = ((mem->type == VIA_MEM_VIDEO) ?
  dev_priv->vram_offset : dev_priv->agp_offset) +
(item->mm->
@@ -153,6 +154,7 @@ int via_mem_alloc(struct drm_device *dev, void *data,
DRM_DEBUG("Video memory allocation failed\n");
retval = -ENOMEM;
}
+   mutex_unlock(&dev->struct_mutex);
 
return retval;
 }
@@ -173,12 +175,13 @@ int via_mem_free(struct drm_device *dev, void *data, 
struct drm_file *file_priv)
 
 
 void via_reclaim_buffers_locked(struct drm_device *dev,
-   struct drm_file *file_priv)
+   struct drm_file *file)
 {
-   drm_via_private_t *dev_priv = dev->dev_private;
+   struct via_file_private *file_priv = file->driver_priv;
+   struct drm_memblock_item *entry, *next;
 
mutex_lock(&dev->struct_mutex);
-   if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)file_priv)) {
+   if (list_empty(&file_priv->obj_list)) {
mutex_unlock(&dev->struct_mutex);
return;
}
@@ -186,7 +189,10 @@ void via_reclaim_buffers_locked(struct drm_device *dev,
if (dev->driver->dma_quiescent)
dev->driver->dma_quiescent(dev);
 
-   drm_sman_owner_cleanup(&dev_priv->sman, (unsigned long)file_priv);
+   list_for_each_entry_safe(entry, next, &file_priv->obj_list,
+owner_list) {
+   drm_sman_free(entry);
+   }
mutex_unlock(&dev->struct_mutex);
return;
 }
diff --git a/include/drm/via_drm.h b/include/drm/via_drm.h
index fd11a5b..79b3b6e 100644
--- a/include/drm/via_drm.h
+++ b/include/drm/via_drm.h
@@ -274,4 +274,8 @@ typedef struct drm_via_dmablit {
drm_via_blitsync_t sync;
 } drm_via_dmablit_t;
 
+struct via_file_private {
+   struct list_head obj_list;
+};
+
 #endif /* _VIA_DRM_H_ */
-- 
1.7.7.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 01/23] drm/sis: track obj->drm_fd relations in the driver

2011-10-27 Thread Daniel Vetter
By attach a driver private struct to each open drm fd.

Because we steal the owner_list from drm_sman until things settle,
use list_move instead of list_add.

This requires to export a drm_sman function temporarily before
drm_sman will die for real completely.

Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/drm_sman.c|3 ++-
 drivers/gpu/drm/sis/sis_drv.c |   25 +
 drivers/gpu/drm/sis/sis_mm.c  |   22 ++
 include/drm/drm_sman.h|1 +
 include/drm/sis_drm.h |4 
 5 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/drm_sman.c b/drivers/gpu/drm/drm_sman.c
index 3466458..37548b7 100644
--- a/drivers/gpu/drm/drm_sman.c
+++ b/drivers/gpu/drm/drm_sman.c
@@ -243,7 +243,7 @@ out:
 
 EXPORT_SYMBOL(drm_sman_alloc);
 
-static void drm_sman_free(struct drm_memblock_item *item)
+void drm_sman_free(struct drm_memblock_item *item)
 {
struct drm_sman *sman = item->sman;
 
@@ -252,6 +252,7 @@ static void drm_sman_free(struct drm_memblock_item *item)
item->mm->free(item->mm->private, item->mm_info);
kfree(item);
 }
+EXPORT_SYMBOL(drm_sman_free);
 
 int drm_sman_free_key(struct drm_sman *sman, unsigned int key)
 {
diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index 46d5be6..a5dcd0a 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -63,10 +63,35 @@ static int sis_driver_unload(struct drm_device *dev)
return 0;
 }
 
+static int sis_driver_open(struct drm_device *dev, struct drm_file *file)
+{
+   struct sis_file_private *file_priv;
+
+   DRM_DEBUG_DRIVER("\n");
+   file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
+   if (!file_priv)
+   return -ENOMEM;
+
+   file->driver_priv = file_priv;
+
+   INIT_LIST_HEAD(&file_priv->obj_list);
+
+   return 0;
+}
+
+void sis_driver_postclose(struct drm_device *dev, struct drm_file *file)
+{
+   struct sis_file_private *file_priv = file->driver_priv;
+
+   kfree(file_priv);
+}
+
 static struct drm_driver driver = {
.driver_features = DRIVER_USE_AGP | DRIVER_USE_MTRR,
.load = sis_driver_load,
.unload = sis_driver_unload,
+   .open = sis_driver_open,
+   .postclose = sis_driver_postclose,
.dma_quiescent = sis_idle,
.reclaim_buffers = NULL,
.reclaim_buffers_idlelocked = sis_reclaim_buffers_locked,
diff --git a/drivers/gpu/drm/sis/sis_mm.c b/drivers/gpu/drm/sis/sis_mm.c
index 7fe2b63..a70b1bb 100644
--- a/drivers/gpu/drm/sis/sis_mm.c
+++ b/drivers/gpu/drm/sis/sis_mm.c
@@ -120,13 +120,14 @@ static int sis_fb_init(struct drm_device *dev, void 
*data, struct drm_file *file
return 0;
 }
 
-static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv,
+static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file,
 void *data, int pool)
 {
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_mem_t *mem = data;
int retval = 0;
struct drm_memblock_item *item;
+   struct sis_file_private *file_priv = file->driver_priv;
 
mutex_lock(&dev->struct_mutex);
 
@@ -139,11 +140,10 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file_priv,
}
 
mem->size = (mem->size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT;
-   item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0,
- (unsigned long)file_priv);
+   item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0, 0);
 
-   mutex_unlock(&dev->struct_mutex);
if (item) {
+   list_move(&item->owner_list, &file_priv->obj_list);
mem->offset = ((pool == 0) ?
  dev_priv->vram_offset : dev_priv->agp_offset) +
(item->mm->
@@ -156,6 +156,7 @@ static int sis_drm_alloc(struct drm_device *dev, struct 
drm_file *file_priv,
mem->free = 0;
retval = -ENOMEM;
}
+   mutex_unlock(&dev->struct_mutex);
 
DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem->size,
  mem->offset);
@@ -301,12 +302,13 @@ void sis_lastclose(struct drm_device *dev)
 }
 
 void sis_reclaim_buffers_locked(struct drm_device *dev,
-   struct drm_file *file_priv)
+   struct drm_file *file)
 {
-   drm_sis_private_t *dev_priv = dev->dev_private;
+   struct sis_file_private *file_priv = file->driver_priv;
+   struct drm_memblock_item *entry, *next;
 
mutex_lock(&dev->struct_mutex);
-   if (drm_sman_owner_clean(&dev_priv->sman, (unsigned long)file_priv)) {
+   if (list_empty(&file_priv->obj_list)) {
mutex_unlock(&dev->struct_mutex);
return;
}
@@ -314,7 +316,11 @@ void sis_reclaim_buffers_locked(struct drm_device *dev,
if (dev->driver->dma_quiescent)
 

[PATCH 00/23] kill drm cruft with fire

2011-10-27 Thread Daniel Vetter
Hi all,

It's that time of the year again when the weather gets crappy, people
depressed and danvet wades through drm cruft. Not that any of this is
related in any way.

Actually I only wanted to port users of drm_mm to the new interfaces,
completing a work I've started a while ago. It lead to a littel detour.

Patches 1-10 kill drm_sman (hereby reducing the number of users of the old
drm_mm interface by one). I don't have either sis or via hw but given
- how lightly the dri1 removal went down
- you can't really ebay this hw anymore (at least not here, I've tried)
- and that no one really changes much in them anymore (last time was me a
  year ago, killing cruft)

I think the risk is worth it. Worst case I expect to some oops-decoding
because this doesn't change neither userspace nor hw facing code, only pure
kernel book-keeping.

Patches 11-17 clean the reclaim_buffers support by the drm core by moving
everything into driver specific preclose functions. I've noticed this
horrid stuff while writing the buffer tracking code for via/sis.

Patches 18-20 rip out the dma queue code, which was totally unused. The two
risky steps of that surgery are split out.

Patches 21-23 finish this series by killing a few random smaller things
I've noticed.

Entire pile tested on my i810, that's the last fully working dri1 setup I
still have. The reclaim_buffers rework actually improves things there.

Two patches have a potential userspace abi impact, one is i810 specific
(didn't break anything in testing), the other breaks libdrm that is older
than 10 years (by killing proc).

The drm fd release path looks now much less scary with this series (mostly
due to the reclaim_buffers rework), but there's still the context support
seemingly only used by via left. I might look into that as soon as I can
get these images of horribly slaugthered kittens out of my brain ...

Review, flames highly welcome.

Cheers, Daniel

Daniel Vetter (23):
  drm/sis: track obj->drm_fd relations in the driver
  drm/via: track obj->drm_fd relations in the driver
  drm/sman: kill owner tracking interface functions
  drm/sman: rip out owner tracking
  drm/via: track user->memblock mapping with idr
  drm/sis: track user->memblock mapping with idr
  drm/sman: kill user_hash_tab
  drm/via: use drm_mm instead of drm_sman
  drm/sis: use drm_mm instead of drm_sman
  drm: kill drm_sman

  drm/via: clean up reclaim_buffers
  drm/sis: clean up reclaim_buffers
  drm: kill reclaim_buffers_idlelocked functions
  drm/i810: cleanup reclaim_buffers
  drm: kill reclaim_buffers_locked
  drm/savage: clean up reclaim_buffers
  drm: kill reclaim_buffers callback

  drm: ditch strange DRIVER_DMA_QUEUE only error bail-out
  drm: kill dma queue support
  drm: unconditionally clean up dma buffers of closing clients

  drm: kill i915/i830 ids from drm_pciids.h
  drm: kill procfs support
  drm: kill a few unused remnants from drm_memory.c

 drivers/gpu/drm/Makefile  |4 +-
 drivers/gpu/drm/drm_bufs.c|   16 +--
 drivers/gpu/drm/drm_debugfs.c |1 -
 drivers/gpu/drm/drm_dma.c |5 -
 drivers/gpu/drm/drm_drv.c |   19 --
 drivers/gpu/drm/drm_fops.c|   63 +--
 drivers/gpu/drm/drm_info.c|   36 
 drivers/gpu/drm/drm_lock.c|6 +-
 drivers/gpu/drm/drm_memory.c  |   19 --
 drivers/gpu/drm/drm_proc.c|  221 -
 drivers/gpu/drm/drm_sman.c|  350 -
 drivers/gpu/drm/drm_stub.c|   25 +--
 drivers/gpu/drm/i810/i810_dma.c   |   17 +-
 drivers/gpu/drm/i810/i810_drv.c   |3 +-
 drivers/gpu/drm/i810/i810_drv.h   |6 +-
 drivers/gpu/drm/i915/i915_drv.c   |1 -
 drivers/gpu/drm/mga/mga_drv.c |1 -
 drivers/gpu/drm/nouveau/nouveau_drv.c |1 -
 drivers/gpu/drm/r128/r128_drv.c   |1 -
 drivers/gpu/drm/radeon/radeon_drv.c   |2 -
 drivers/gpu/drm/savage/savage_bci.c   |7 +-
 drivers/gpu/drm/savage/savage_drv.c   |2 +-
 drivers/gpu/drm/sis/sis_drv.c |   36 +++-
 drivers/gpu/drm/sis/sis_drv.h |7 +-
 drivers/gpu/drm/sis/sis_mm.c  |  210 
 drivers/gpu/drm/tdfx/tdfx_drv.c   |1 -
 drivers/gpu/drm/via/via_drv.c |   29 +++-
 drivers/gpu/drm/via/via_drv.h |7 +-
 drivers/gpu/drm/via/via_map.c |   10 +-
 drivers/gpu/drm/via/via_mm.c  |  145 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |1 -
 drivers/staging/gma500/psb_drv.c  |1 -
 include/drm/drmP.h|   28 +---
 include/drm/drm_pciids.h  |   42 
 include/drm/drm_sman.h|  176 -
 include/drm/sis_drm.h |4 +
 include/drm/via_drm.h |4 +
 37 files changed, 337 insertions(+), 1170 deletions(-)
 delete mode 100644 drivers/gpu/drm/drm_proc.c
 delete mode 100644 drivers/gpu/drm/drm_sman.c
 delete mode 1006

Re: nouveau page_flip function implement not wait vblank, which cause screen garbage

2011-10-27 Thread Francisco Jerez
Thomas Hellstrom  writes:

> FWIW, there was a quite long discussion / argument when the page flip
> ioctl was designed, and at that time
> I pointed out that there are hardware capable of pageflipping using
> the fifo/pipe with optional VSYNC barriers, and that it is actually
> possible to queue up a number of pageflips in the fifo. Not just one.
>
That's the case of the nouveau driver, and it's the reason that we don't
respect the API returning -EBUSY when there's an already scheduled flip
request. IMHO that should be up to the driver, or even better, the IOCTL
could be specified to block in case userspace is requesting more
simultaneous page-flips than the kernel driver can handle, in order to
make the resulting behavior consistent for userspace no matter which
implementation is being used.

> The interface description in drm_mode.h is somewhat different to what
> was agreed upon, namely:
>
> 1) The command submission mechanism should block if a user tries to
> render to a not yet flipped frontbuffer, and that would cause
> rendering problems. For hardware that flips using a fifo / pipe,
> that's not really a problem. Thus, any rendering errors due to
> rendering to a not-yet-flipped frontbuffer is a kernel driver error.
> The user-space app can avoid being blocked waiting using events.
>
Yeah, it would be good to relax this restriction -- the nouveau driver
has never respected it because we'd end up lock-stepping the GPU (we
wouldn't be sending the next batch of commands until the one sent before
the flip had been completely processed), and it's just not necessary
because we take additional measures to make sure that flips and commands
sent to other hardware queues are properly ordered with respect to one
another.

> 2) The interface in itself doesn't require flips to be synced to
> vblanks, as I understand it.
>  However, it should be possible to add a new flag
> DRM_MODE_PAGE_FLIP_SYNC that tries to sync if at all possible.
>
Yes, so the fact that the nouveau pageflip implementation doesn't sync
to vblank before flipping isn't even a bug as it stands.

> /Thomas
>
>
> On 10/27/2011 10:00 AM, chris wrote:
>> I think page_flip ioctl need to realize a synchronous mechanism to control 
>> fresh rate...!!!
>> At 2011-10-25 20:30:39,"Ben Skeggs"  wrote:
>>
>>> On Tue, 2011-10-25 at 14:15 +0200, Francisco Jerez wrote:
>>>  
 Maarten Maathuis  writes:


> 2011/10/25 chris:
>  
>> Can anyone give a suggestion, is wait-vblank fully implemented in
>> page_flip() for nouveau drm driver?
>>
>>
 It's intentionally not implemented.  The reason is that I wanted to
 support non-vsync'ed vblank as well, and for vsync'ed blits we had to
 think about a different mechanism for vblank synchronization anyway, so
 I figured it didn't make that much sense to force vblank synchronization
 directly from the pageflip ioctl.

>>> +1 I deliberately didn't flip 1 bit in the NV50/NVC0 page flipping code
>>> for this as well.  The interface IMO is flawed.  Though, that said, we
>>> really should look at doing something properly for this, a lot of people
>>> do want tear-free goodness.
>>>
>>> Ben.
>>>  

>> At 2011-10-24 14:30:55,chris  wrote:
>>
>> Dear,
>>
>> I use NVidia Geforce 7300GT graphics card in my PC, and Linux 3.1rc4 
>> kernel
>> code, git drm 2.4.36.
>>When I run the vbltest program, it prints  "60HZ"  which indicated the
>> implementation of drmWaitVBlank() and drm_vblank_wait()  is correct.
>>But when I run modetest with option " -v -s 12:1280x1024" , it prints 
>> high
>> fresh rate up to "150 HZ" .  I examing the code , and found that no 
>> waiting
>> vblank operation is processed in nouveau_crtc_ page_flip() function. The
>> screen  produced lots of garbage and blink very much.
>>
 That's fine if by "garbage" you just mean it's tearing like crazy.


>> [...]
>>
> It seems to be, the actual page flipping is done by software method
> (see nv04_graph_mthd_page_flip). There is one thing i'm unsure about
> and that is that we wait for the rendering to be done to the current
> frontbuffer and not the current backbuffer (this is only done if the
> page flip channel is different than the rendering channel). Maybe
> someone else can comment on that.
>  
 There's no need to wait for the backbuffer rendering to end because the
 pageflip is always pushed through the last channel that has queued
 rendering to it, so, the "waiting" is actually done by the GPU. The
 waiting to the current frontbuffer (which in most cases is going to be a
 cross-channel barrier instead of actual CPU waiting) is necessary for
 the (rare) case where you have several channels trying to render to the
 same pageflipped drawable, to make sure that t

Re: [PATCH 3/3] drm: do not sleep on vblank while holding a mutex

2011-10-27 Thread Daniel Vetter
On Wed, Oct 26, 2011 at 05:33:24PM -0500, Ilija Hadzic wrote:
> Is DRM support for other OS-es officially dead ? I know it's not in
> best shape on BSD and friends, but I am not sure if I should make it
> worse (or inconsistent with the current code shape and form).

I think the idea of sharing kernel drm code is pretty much dead, yeah.

> main()
> {
> int fd;
> drmVBlank vbl;
> 
> fd = open("/dev/dri/card0", 0);
> printf("fd=%d\n", fd);
> 
> while(1) {
> vbl.request.type =  DRM_VBLANK_RELATIVE ;
> vbl.request.sequence = 60;
> printf("waiting on vblank\n");
> ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
> }
> }
> 
> Then start glxgears (on CRTC-0) and watch the hell break loose. The
> hostile code will cause any OpenGL application to hang for a full
> second before it can even enter the vblank_wait. Now because all
> vblank waits go through a common function in DDX, the whole
> windowing system will consequently go into a crawl. Run it with
> Compiz and things are even worse (the whole windowing system goes
> "stupid" as soon as the hostile application is started).

This is really just horrible.
> 
> 
> >>+   add_wait_queue(&(queue), &entry);   \
> >>+   mutex_unlock(&drm_global_mutex);\
> >
> >Hiding a lock-dropping in this fashion is horrible.
> 
> I explained above why am I have to release the lock inside the
> macro. That's equivalent to what you can find in the userland in
> POSIX threads, like I said. So that's not bad.

I disagree - this is just the blk magic reinvented. Also I don't like to
rush locking changes, because the hard part is reviewing all the drivers,
and I prefer to do that just once for the real solution.

Also explaining locking changes (especially in drm) starting with
"assuming the old code is correct, this is safe" isn't great. Because your
changes might simply enlarge the already existing race.

On a quick glance
- drm_vblank functions call by wait_vblank seem to do correct locking
  already using various spinlocks and atomic ops.
- linux waitqueues have their own locking
- dev->last_vblank_wait is only used for a procfs file. I don't think it
  makes much sense given that we can have more than one vblank waiter
- there's no selective wakeup going on, all waiters get woken for every
  vblank and call schedule again if it's not the right vblank

The only really hairy thing going on is racing modeset ioctls against
vblank waiters. But modeset is protected by the dev->mode_config.mutex
and hence already races against wait_vblank with the current code, so I'm
slightly inclined to ignore this for the moment. Would be great if you
coudl check that in-depth, too.

So I think the right thing to do is
- Kill dev->last_vblank_wait (in a prep patch).
- Imo we also have a few too many atomic ops going on, e.g.
  dev->vblank_refcount looks like it's atomic only because or the procfs
  file, so maybe kill that procfs file entirely.
- Audit the vblank locking, maybe resulting in a patch with updated
  comments, if there's anything misleading or tricky going on. And it's
  always good when the locking of structe members is explained in the
  header file ...
- Drop the mutex locking because it's not needed.

While locking at the code I also noticed that wait_vblank calls
drm_vblank_get, but not always drm_vblank_put. The code is correct, the
missing vblank_put is hidden in drm_queue_vblank_event. Can you also write
the patch to move that around to not trip up reviewers the next time
around?

Yours, Daniel
- 
-- 
Daniel Vetter
Mail: dan...@ffwll.ch
Mobile: +41 (0)79 365 57 48
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: nouveau page_flip function implement not wait vblank, which cause screen garbage

2011-10-27 Thread Thomas Hellstrom
FWIW, there was a quite long discussion / argument when the page flip 
ioctl was designed, and at that time
I pointed out that there are hardware capable of pageflipping using the 
fifo/pipe with optional VSYNC barriers, and that it is actually possible 
to queue up a number of pageflips in the fifo. Not just one.


The interface description in drm_mode.h is somewhat different to what 
was agreed upon, namely:


1) The command submission mechanism should block if a user tries to 
render to a not yet flipped frontbuffer, and that would cause rendering 
problems. For hardware that flips using a fifo / pipe, that's not really 
a problem. Thus, any rendering errors due to rendering to a 
not-yet-flipped frontbuffer is a kernel driver error.

The user-space app can avoid being blocked waiting using events.

2) The interface in itself doesn't require flips to be synced to 
vblanks, as I understand it.
 However, it should be possible to add a new flag 
DRM_MODE_PAGE_FLIP_SYNC that tries to sync if at all possible.


/Thomas


On 10/27/2011 10:00 AM, chris wrote:

I think page_flip ioctl need to realize a synchronous mechanism to control 
fresh rate...!!!
At 2011-10-25 20:30:39,"Ben Skeggs"  wrote:
   

On Tue, 2011-10-25 at 14:15 +0200, Francisco Jerez wrote:
 

Maarten Maathuis  writes:

   

2011/10/25 chris:
 

Can anyone give a suggestion, is wait-vblank fully implemented in
page_flip() for nouveau drm driver?

   

It's intentionally not implemented.  The reason is that I wanted to
support non-vsync'ed vblank as well, and for vsync'ed blits we had to
think about a different mechanism for vblank synchronization anyway, so
I figured it didn't make that much sense to force vblank synchronization
directly from the pageflip ioctl.
   

+1 I deliberately didn't flip 1 bit in the NV50/NVC0 page flipping code
for this as well.  The interface IMO is flawed.  Though, that said, we
really should look at doing something properly for this, a lot of people
do want tear-free goodness.

Ben.
 
   

At 2011-10-24 14:30:55,chris  wrote:

Dear,

I use NVidia Geforce 7300GT graphics card in my PC, and Linux 3.1rc4 kernel
code, git drm 2.4.36.
   When I run the vbltest program, it prints  "60HZ"  which indicated the
implementation of drmWaitVBlank() and drm_vblank_wait()  is correct.
   But when I run modetest with option " -v -s 12:1280x1024" , it prints high
fresh rate up to "150 HZ" .  I examing the code , and found that no waiting
vblank operation is processed in nouveau_crtc_ page_flip() function. The
screen  produced lots of garbage and blink very much.
   

That's fine if by "garbage" you just mean it's tearing like crazy.

   

[...]
   

It seems to be, the actual page flipping is done by software method
(see nv04_graph_mthd_page_flip). There is one thing i'm unsure about
and that is that we wait for the rendering to be done to the current
frontbuffer and not the current backbuffer (this is only done if the
page flip channel is different than the rendering channel). Maybe
someone else can comment on that.
 

There's no need to wait for the backbuffer rendering to end because the
pageflip is always pushed through the last channel that has queued
rendering to it, so, the "waiting" is actually done by the GPU. The
waiting to the current frontbuffer (which in most cases is going to be a
cross-channel barrier instead of actual CPU waiting) is necessary for
the (rare) case where you have several channels trying to render to the
same pageflipped drawable, to make sure that the flips are properly
synchronized with respect each other.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
   


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
 

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
   




___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re:Re: nouveau page_flip function implement not wait vblank, which cause screen garbage

2011-10-27 Thread chris
I think page_flip ioctl need to realize a synchronous mechanism to control 
fresh rate...!!!
At 2011-10-25 20:30:39,"Ben Skeggs"  wrote:
>On Tue, 2011-10-25 at 14:15 +0200, Francisco Jerez wrote:
>> Maarten Maathuis  writes:
>> 
>> > 2011/10/25 chris :
>> >> Can anyone give a suggestion, is wait-vblank fully implemented in
>> >> page_flip() for nouveau drm driver?
>> >>
>> 
>> It's intentionally not implemented.  The reason is that I wanted to
>> support non-vsync'ed vblank as well, and for vsync'ed blits we had to
>> think about a different mechanism for vblank synchronization anyway, so
>> I figured it didn't make that much sense to force vblank synchronization
>> directly from the pageflip ioctl.
>+1 I deliberately didn't flip 1 bit in the NV50/NVC0 page flipping code
>for this as well.  The interface IMO is flawed.  Though, that said, we
>really should look at doing something properly for this, a lot of people
>do want tear-free goodness.
>
>Ben.
>> 
>> >>
>> >> At 2011-10-24 14:30:55,chris  wrote:
>> >>
>> >> Dear,
>> >>
>> >> I use NVidia Geforce 7300GT graphics card in my PC, and Linux 3.1rc4 
>> >> kernel
>> >> code, git drm 2.4.36.
>> >>   When I run the vbltest program, it prints  "60HZ"  which indicated the
>> >> implementation of drmWaitVBlank() and drm_vblank_wait()  is correct.
>> >>   But when I run modetest with option " -v -s 12:1280x1024" , it prints 
>> >> high
>> >> fresh rate up to "150 HZ" .  I examing the code , and found that no 
>> >> waiting
>> >> vblank operation is processed in nouveau_crtc_ page_flip() function. The
>> >> screen  produced lots of garbage and blink very much.
>> 
>> That's fine if by "garbage" you just mean it's tearing like crazy.
>> 
>> >>[...]
>> >
>> > It seems to be, the actual page flipping is done by software method
>> > (see nv04_graph_mthd_page_flip). There is one thing i'm unsure about
>> > and that is that we wait for the rendering to be done to the current
>> > frontbuffer and not the current backbuffer (this is only done if the
>> > page flip channel is different than the rendering channel). Maybe
>> > someone else can comment on that.
>> 
>> There's no need to wait for the backbuffer rendering to end because the
>> pageflip is always pushed through the last channel that has queued
>> rendering to it, so, the "waiting" is actually done by the GPU. The
>> waiting to the current frontbuffer (which in most cases is going to be a
>> cross-channel barrier instead of actual CPU waiting) is necessary for
>> the (rare) case where you have several channels trying to render to the
>> same pageflipped drawable, to make sure that the flips are properly
>> synchronized with respect each other.
>> ___
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
>___
>dri-devel mailing list
>dri-devel@lists.freedesktop.org
>http://lists.freedesktop.org/mailman/listinfo/dri-devel

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 42297] New: [r600g] Segfaults and failed assertions with piglit test fbo-generatemipmap-formats

2011-10-27 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=42297

 Bug #: 42297
   Summary: [r600g] Segfaults and failed assertions with piglit
test fbo-generatemipmap-formats
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: x86-64 (AMD64)
OS/Version: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Gallium/r600
AssignedTo: dri-devel at lists.freedesktop.org
ReportedBy: tdroste at gmx.de


Below are backtraces from segfaults and failed assertions while running the
piglit test fbo-generatemipmap-formats. I tried it with and without
R600_TILING=on.

piglit: from git and updated+rebuilt today.
Mesa: 2.1 Mesa 7.12-devel (git-4fc9a98)
Driver: r600g
Kernel: 3.0
Hardware: Evergreen (Juniper)



$ R600_TILING=on gdb ./bin/fbo-generatemipmap-formats

Using test set: GL_EXT_texture_compression_rgtc
Testing GL_COMPRESSED_RED
Program received signal SIGSEGV, Segmentation fault.
#0  0x00694990 in ?? ()
#1  0x73dfe0b4 in pb_destroy (csc=0x77fe7da0) at
../../../../../src/gallium/auxiliary/pipebuffer/pb_buffer.h:232
#2  pb_reference (csc=0x77fe7da0) at
../../../../../src/gallium/auxiliary/pipebuffer/pb_buffer.h:242
#3  radeon_bo_reference (csc=0x77fe7da0) at radeon_drm_bo.h:82
#4  radeon_cs_context_cleanup (csc=0x77fe7da0) at radeon_drm_cs.c:114
#5  radeon_drm_cs_emit_ioctl_oneshot (csc=0x77fe7da0) at
radeon_drm_cs.c:380
#6  0x73dff4d7 in radeon_drm_cs_flush (rcs=0x77fd7010, flags=) at radeon_drm_cs.c:435
#7  0x73deb08e in r600_context_flush (ctx=0x6a6480, flags=0) at
r600_hw_context.c:1508
#8  0x73dd455b in r600_texture_get_transfer (ctx=0x6a6150,
texture=, level=0, usage=,
box=0x7ffed590)
at r600_texture.c:719
#9  0x740138eb in pipe_get_transfer (ctx=0x7b0150, x=258, y=171,
width=1, height=128, format=6407, type=5126, pack=0x7bf8c8,
dest=) at
../../src/gallium/auxiliary/util/u_inlines.h:380
#10 st_readpixels (ctx=0x7b0150, x=258, y=171, width=1, height=128,
format=6407, type=5126, pack=0x7bf8c8, dest=)
at state_tracker/st_cb_readpixels.c:472
#11 0x73e9b8af in _mesa_ReadnPixelsARB (x=258, y=1, width=1,
height=128, format=6407, type=5126, pixels=0xa27fa0) at main/readpix.c:269
#12 _mesa_ReadPixels (x=258, y=1, width=1, height=128, format=6407, type=5126,
pixels=0xa27fa0) at main/readpix.c:277
#13 0x00455035 in piglit_probe_rect_rgb ()
#14 0x0042d828 in test_mipmap_drawing ()
#15 0x0042e052 in test_format ()
#16 0x0042e269 in piglit_display ()
#17 0x0042e8f5 in display ()
#18 0x776d1860 in ?? () from /usr/lib64/libglut.so.3
#19 0x776d4f69 in fgEnumWindows () from /usr/lib64/libglut.so.3
#20 0x776d1bba in glutMainLoopEvent () from /usr/lib64/libglut.so.3
#21 0x776d2545 in glutMainLoop () from /usr/lib64/libglut.so.3
#22 0x0042efd2 in main ()


Using test set: GL_EXT_texture_compression_rgtc
Testing GL_COMPRESSED_RED
*** glibc detected *** ./bin/fbo-generatemipmap-formats: malloc(): smallbin
double linked list corrupted: 0x009e6850 ***
#17 0x76df2ede in calloc () from /lib64/libc.so.6
#18 0x73dfceff in radeon_bomgr_create_bo (_mgr=0x694b00, size=32768,
desc=0x7fffd140) at radeon_drm_bo.c:360
#19 0x73dfcd30 in radeon_winsys_bo_create (rws=,
size=, alignment=,
bind=, usage=) at
radeon_drm_bo.c:560
#20 0x73de7d03 in r600_init_resource (rscreen=0x694be0, res=0x9d9760,
size=, alignment=,
bind=, usage=) at
r600_buffer.c:154
#21 0x73dd53dc in r600_texture_create_object (screen=0x694be0,
base=0x7fffd250, array_mode=2, pitch_in_bytes_override=,
buf=0x0, alloc_bo=1 '\001', max_buffer_size=0) at r600_texture.c:463
#22 0x73f1a676 in st_texture_create (st=,
target=PIPE_TEXTURE_2D, format=PIPE_FORMAT_RGTC1_UNORM, last_level=0,
width0=256,
height0=256, depth0=1, layers=1, bind=8) at state_tracker/st_texture.c:94
#23 0x73f0d6dc in guess_and_alloc_texture (st=0x814420, stObj=0xa269b0,
stImage=) at state_tracker/st_cb_texture.c:446
#24 0x73f0fe3b in st_TexImage (ctx=0x7b0150, dims=2, target=3553,
level=0, internalFormat=33317, width=256, height=256, depth=1, border=0,
format=6408, type=5126, pixels=0xa40460, unpack=0x7bf8f0, texObj=0xa269b0,
texImage=0xa26ec0, imageSize=0, compressed_src=0 '\000')
at state_tracker/st_cb_texture.c:628
#25 0x73f100b3 in st_TexImage2D (ctx=,
target=, level=,
internalFormat=, width=,
height=, border=0, format=6408, type=5126,
pixels=0xa40460,
unpack=0x7bf8f0, texObj=0xa269b0, texImage=0xa26ec0) at
state_tracker/st_cb_texture.c:812
#26 0x73ec2fa2 in teximage (ctx=0x7b0150, dims=2, target=3553, level=0,
internalFormat=33317, width=256, height=256, depth=1, border=0,
format=6408, type=5126, pixels=0xa40460