[PATCH 1/1] drm/i915: fix operator precedence when enabling RC6p

2012-02-23 Thread Eugeni Dodonov
As noticed by Torsten Kaiser, the operator precedence can play tricks with
us here.

CC: Dave Airlie 
CC: Jesse Barnes 
Signed-off-by: Eugeni Dodonov 
---
 drivers/gpu/drm/i915/intel_display.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index e654f32..4871ba0 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8194,7 +8194,7 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv)

if (intel_enable_rc6(dev_priv->dev))
rc6_mask = GEN6_RC_CTL_RC6_ENABLE |
-   (IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 0;
+   ((IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 
0);

I915_WRITE(GEN6_RC_CONTROL,
   rc6_mask |
-- 
1.7.8.4



3.3-rc4+: Reported regressions from 3.2

2012-02-23 Thread Rafael J. Wysocki
Hi all,

We definitely aren't 100% in business yet with the tracking of regressions,
but since the Bugzilla is operational again, we can collect reports at least.

I'd like to use this opportunity to thank Maciej Rutecki and Florian Mickler
for their hard work on the regression tracking and to clarify some things that
seem to have caused some confusion to happen recently.  Namely, we use the
kernel Bugzilla (https://bugzilla.kernel.org) for the tracking of regressions
for the simple reason that our scripts generate the lists that are posted
(like the one below) out of Bugzilla entries created by us (and sometimes
by other people).  Those entries are used by us as a storage of information,
so we're going to add them even though some kernel developers don't seem to
like that.  We don't require developers to actually use those entries for
handling bug reports, we only need people to let us know when they should be
closed, because the bug has been fixed in the Linus' tree, or when there's
a patch available for the bug (in which case we mark it as "resolved", but
we don't close it just yet).  There is no reason for you to be openly hostile
to Maciej, who's been creating those entries recently, because he's just been
doing his job.  However, you may not want us to track kernel regressions at
all, in which case please let us know about that and we will find some other,
presumably equally interesting things to do. :-)

Yes, we might have been more verbose about what _exactly_ we've been using the
Bugzilla for and what our workflow is, but at the same time people might have
been a bit less harsh to someone who's been doing a service to the community,
completely voluntarily.

Thanks,
Rafael

---

This message contains a list of some regressions from 3.2,
for which there are no fixes in the mainline known to the tracking team.
If any of them have been fixed already, please let us know.

If you know of any other unresolved regressions from 3.2, please let us
know either and we'll add them to the list.  Also, please let us know
if any of the entries below are invalid.

Each entry from the list will be sent additionally in an automatic reply
to this message with CCs to the people involved in reporting and handling
the issue.


Listed regressions statistics:

  Date  Total  Pending  Unresolved
  
  2012-02-23   15   13  13


Unresolved regressions
--

Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42798
Subject : i915 regression with 3.3-rc3+git
Submitter   : Riccardo Magliocchetti 
Date: 2012-02-17 20:48 (7 days old)
Message-ID  : <4F3EBD0D.7000906 at gmail.com>
References  : http://marc.info/?l=linux-kernel&m=132951173002619&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42776
Subject : OF-related boot crash in 3.3.0-rc3-00188-g3ec1e88
Submitter   : Meelis Roos 
Date: 2012-02-13 7:45 (11 days old)
Message-ID  : 
References  : http://marc.info/?l=linux-kernel&m=132911916331615&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42761
Subject : Possible circular locking dependency (3.3-rc2)
Submitter   : Felipe Balbi 
Date: 2012-02-08 12:41 (16 days old)
Message-ID  : <20120208124147.GF16334 at legolas.emea.dhcp.ti.com>
References  : http://marc.info/?l=linux-kernel&m=132870492311858&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42746
Subject : 3.3-rc2 snd_pcm lockdep backtrace
Submitter   : Josh Boyer 
Date: 2012-02-06 14:56 (18 days old)
Message-ID  : <20120206145621.GA4771 at zod.bos.redhat.com>
References  : http://marc.info/?l=linux-kernel&m=132854040916172&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42735
Subject : kobject (88003ffbb4b8): tried to init an initialized 
object, something is seriously wrong.
Submitter   : Konrad Rzeszutek Wilk 
Date: 2012-02-03 20:59 (21 days old)
Message-ID  : <20120203205953.GA2897 at phenom.dumpdata.com>
References  : http://marc.info/?l=linux-kernel&m=132830315526901&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42734
Subject : dosemu graphics broken in v3.3-rc1
Submitter   : Hans de Bruin 
Date: 2012-02-02 22:25 (22 days old)
First-Bad-Commit: 
http://git.kernel.org/linus/308e5bcbdb10452e8aba31aa21432fb67ee46d72
Message-ID  : <4F2B0D4D.3000304 at xmsnet.nl>
References  : http://marc.info/?l=linux-kernel&m=132825899111982&w=2
Handled-By  : Jesse Barnes 


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42733
Subject : Regression 3.2 -> 3.3-rc1 10 sec hang at boot and resume, 
COMRESET failed
Submitter   : Norbert Preining 
Date: 2012-02-02 5:12 (22 days old)
Message-ID  : <20120202051258.GA15550 at gamma.logic.tuwien.ac.at>
References  : http://m

[Linaro-mm-sig] [PATCH 6/7] drm/vgem: import support

2012-02-23 Thread Chris Wilson
On Wed, 22 Feb 2012 20:29:19 +0100, Ben Widawsky  wrote:
> + mutex_lock(&dev->prime_mutex);
> + /* First check that we don't dup on this file */
> + ret = drm_prime_lookup_fd_handle_mapping(&file_priv->prime, dma_buf,
> +  handle);

The other example of importing bo we have already in GEM is through the
use of flink and global names. There we create a new handle every time a
process opens a name, and de-duplication is indeed handled in userspace
if it so desires.

Multiple handles pointing to the same object simplifies the code without
risking kernel integrity, so why bother with kernel de-dupe? And allow
userspace the extra bit of freedom to shoot itself in the foot!
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[Bug 42678] [3.3-rc1] radeon stuck in kernel after lockup

2012-02-23 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=42678





--- Comment #6 from Rafael J. Wysocki   2012-02-23 22:32:02 ---
Handled-By : J?r?me Glisse 

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.


[git pull] drm fixes

2012-02-23 Thread Torsten Kaiser
On Wed, Feb 22, 2012 at 8:56 PM, Dave Airlie  wrote:
> Eugeni Dodonov (4):
> ? ? ?drm/i915: gen7: implement rczunit workaround
> ? ? ?drm/i915: gen7: Implement an L3 caching workaround.
> ? ? ?drm/i915: gen7: work around a system hang on IVB
> ? ? ?drm/i915: do not enable RC6p on Sandy Bridge

That last patch about RC6p looks wrong.

It does:
 GEN6_RC_CTL_RC6_ENABLE |
(IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 0;
But I think this was meant:
 GEN6_RC_CTL_RC6_ENABLE |
((IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 
0);

Or did I get the operator precedence wrong?

HTH

Torsten


[PATCH] drm: Reduce the number of retries whilst reading EDIDs

2012-02-23 Thread Chris Wilson
i2c retries if sees an EGAIN, drm_do_probe_ddc_edid retries until it
gets a result and *then* drm_do_get_edid retries until it gets a result
it is happy with. All in all, that is a lot of processor intensive
looping in cases where we do not expect and cannot get valid data - for
example on Intel with disconnected hardware we will busy-spin until we
hit the i2c timeout. This is then repeated for every connector when
querying the current status of outputs.

So to improve the situation, we can trim the number of retries for
reading the base block and to check for a reschedule before proceeding
so that we do not hog the machine whilst probing outputs. (Though since
we will be likely blocking the graphics device, the user is still going
to notice the latency.)

Reported-by: Linus Torvalds 
Reported-by: Stephan B?rwolf 
Signed-off-by: Chris Wilson 
Cc: Eugeni Dodonov 
Cc: Dave Airlie 
Cc: Alex Deucher 
---
 drivers/gpu/drm/drm_edid.c |   30 +++---
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index ece03fc..4409cd4 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -35,6 +35,9 @@
 #include "drm_edid.h"
 #include "drm_edid_modes.h"

+#define EDID_PROBE_RETRIES 1
+#define EDID_READ_RETRIES 5
+
 #define version_greater(edid, maj, min) \
(((edid)->version > (maj)) || \
 ((edid)->version == (maj) && (edid)->revision > (min)))
@@ -239,11 +242,12 @@ EXPORT_SYMBOL(drm_edid_is_valid);
  * Try to fetch EDID information by calling i2c driver function.
  */
 static int
-drm_do_probe_ddc_edid(struct i2c_adapter *adapter, unsigned char *buf,
- int block, int len)
+drm_get_edid_block(struct i2c_adapter *adapter,
+  unsigned char *buf, int block, int len,
+  int retries)
 {
unsigned char start = block * EDID_LENGTH;
-   int ret, retries = 5;
+   int ret;

/* The core i2c driver will automatically retry the transfer if the
 * adapter reports EAGAIN. However, we find that bit-banging transfers
@@ -293,7 +297,19 @@ drm_do_get_edid(struct drm_connector *connector, struct 
i2c_adapter *adapter)

/* base block fetch */
for (i = 0; i < 4; i++) {
-   if (drm_do_probe_ddc_edid(adapter, block, 0, EDID_LENGTH))
+   /* EDID transfer may be quite processor intensive and last
+* a long time. For example, when waiting for a timeout on
+* a non-existent connector whilst using bit-banging. As a
+* result we can end up hogging the machine, so give someone
+* else the chance to run first. But when we have started a
+* transfer don't interrupt until finished.
+*/
+   if (need_resched())
+   schedule();
+
+   if (drm_get_edid_block(adapter,
+  block, 0, EDID_LENGTH,
+  EDID_PROBE_RETRIES))
goto out;
if (drm_edid_block_valid(block))
break;
@@ -316,9 +332,9 @@ drm_do_get_edid(struct drm_connector *connector, struct 
i2c_adapter *adapter)

for (j = 1; j <= block[0x7e]; j++) {
for (i = 0; i < 4; i++) {
-   if (drm_do_probe_ddc_edid(adapter,
+   if (drm_get_edid_block(adapter,
  block + (valid_extensions + 1) * EDID_LENGTH,
- j, EDID_LENGTH))
+ j, EDID_LENGTH, EDID_READ_RETRIES))
goto out;
if (drm_edid_block_valid(block + (valid_extensions + 1) 
* EDID_LENGTH)) {
valid_extensions++;
@@ -362,7 +378,7 @@ drm_probe_ddc(struct i2c_adapter *adapter)
 {
unsigned char out;

-   return (drm_do_probe_ddc_edid(adapter, &out, 0, 1) == 0);
+   return drm_get_edid_block(adapter, &out, 0, 1, EDID_PROBE_RETRIES) == 0;
 }

 /**
-- 
1.7.9.1



[PATCH] drm: Reduce the number of retries whilst reading EDIDs

2012-02-23 Thread Eugeni Dodonov
On 02/23/2012 06:15 PM, Linus Torvalds wrote:
> On Thu, Feb 23, 2012 at 11:52 AM, Chris Wilson  
> wrote:
>>
>> i2c retries if sees an EGAIN, drm_do_probe_ddc_edid retries until it
>> gets a result and *then* drm_do_get_edid retries until it gets a result
>> it is happy with. All in all, that is a lot of processor intensive
>> looping in cases where we do not expect and cannot get valid data - for
>> example on Intel with disconnected hardware we will busy-spin until we
>> hit the i2c timeout. This is then repeated for every connector when
>> querying the current status of outputs.
>
> Sadly, this doesn't seem to make any difference to my case. My xrandr
> stays at 0.555s even with this patch.

Perhaps a stupid question, but does you tree has 
http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=9292f37e1f5c79400254dca46f83313488093825
 
from Dave's drm-next?

If it has, it would be the 1st time that I see xrandr take longer than 
.5s with that patch on an Intel GPU. We even added a check for this into 
intel-gpu-tools to warn us if any machine takes that long, and none had 
hit it so far. So if this is the case here, there is something Mac 
Mini-specific indeed to investigate.

-Eugeni


[PATCH 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Christian König
On 23.02.2012 18:32, Jerome Glisse wrote:
> 2012/2/23 Mathias Fr?hlich  <mailto:Mathias.Froehlich at gmx.net>>
>
>
> Christian,
>
> On Thursday, February 23, 2012 15:18:42 Christian K?nig wrote:
> > The function radeon_bo_list_validate can cause a
> > bo to move, resulting in a different sync_obj
> > and a dependency to wait for this move to finish.
> >
> > Signed-off-by: Christian K?nig  <mailto:deathsimple at vodafone.de>>
> > Reviewed-by: Alex Deucher  <mailto:alexander.deucher at amd.com>>
>
> I am not sure, but to me this looks like this could fix these kind
> of gpu
> lockups that I experience since some time every now and then.
> The usual symptom is that I get the
>
> radeon :01:00.0: GPU lockup CP stall for more than 1msec
> GPU lockup (waiting for 0x00682AC3 last fence id 0x00682AC2)
> [...]
>
> kernel message. Each time with the fence being off by one like in
> the example
> above.
>
> If this change has the potential to fix this issue I think this
> particular
> patch should be considered for the current upstream kernel release.
>
> Mathias
>
>
> No this patch doesn't. This patch is all about getting proper sync btw 
> different rings.
That's unfortunately true, since we wasn't able to release any code that 
makes direct use of the different rings (yet) it shouldn't really matter 
in practice. I Just wanted to have that fix upstream since it is an 
obvious bug.

Christian.
>
> Sorry for the deception.
>
> Cheers,
> Jerome

-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20120223/26b6042a/attachment.htm>


[PATCH 2/4] drm/radeon/kms: no need to align IB like this

2012-02-23 Thread Christian König
On 23.02.2012 18:00, Jerome Glisse wrote:
>
> 2012/2/23 Christian K?nig  <mailto:deathsimple at vodafone.de>>
>
> So don't confuse devs by doing so.
>
> Signed-off-by: Christian K?nig  <mailto:deathsimple at vodafone..de>>
> ---
>  drivers/gpu/drm/radeon/r600.c |   15 +--
>  1 files changed, 1 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r600.c
> b/drivers/gpu/drm/radeon/r600.c
> index 4f08e5e..4a4ac8f 100644
> --- a/drivers/gpu/drm/radeon/r600.c
> +++ b/drivers/gpu/drm/radeon/r600.c
> @@ -2719,20 +2719,7 @@ int r600_ib_test(struct radeon_device
> *rdev, int ring)
>ib->ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1);
>ib->ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
>ib->ptr[2] = 0xDEADBEEF;
> -   ib->ptr[3] = PACKET2(0);
> -   ib->ptr[4] = PACKET2(0);
> -   ib->ptr[5] = PACKET2(0);
> -   ib->ptr[6] = PACKET2(0);
> -   ib->ptr[7] = PACKET2(0);
> -   ib->ptr[8] = PACKET2(0);
> -   ib->ptr[9] = PACKET2(0);
> -   ib->ptr[10] = PACKET2(0);
> -   ib->ptr[11] = PACKET2(0);
> -   ib->ptr[12] = PACKET2(0);
> -   ib->ptr[13] = PACKET2(0);
> -   ib->ptr[14] = PACKET2(0);
> -   ib->ptr[15] = PACKET2(0);
> -   ib->length_dw = 16;
> +   ib->length_dw = 3;
>r = radeon_ib_schedule(rdev, ib);
>if (r) {
>radeon_scratch_free(rdev, scratch);
> --
> 1.7.5.4
>
>
> You sure about that ? I remember this helped with GPU lockup and i 
> also seen fglrx aligning IB.
Yeah, pretty much. Well I searched for halve an hour for the 
corresponding IB alignment in mesa/the CS ioctl until I finally figured 
out that there isn't any.

So IBs submitted by usermode aren't aligned in any way So it really 
seems to work fine and I couldn't find any reason why we should align an 
IB for the GFX ring in our docs also.

Christian.
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20120223/7698749b/attachment.html>


[PATCH] Fix deferred page-flip detection logic on Avivo-based ASICs

2012-02-23 Thread Felix Kuehling
This fixes page-flip-related flickering observed on Iconia Tab W500.

The update_pending status returned by radeon_page_flip is very accurate on
Avivo-based ASICs when vpos is negative.

Experiments were conducted on several ASIC generations ranging from RS690
to Cayman where the page flip was artificially timed to occur at a specific
vpos. With negative vpos, overriding update_pending always lead to
flickering.

The same experiment on RV380 and RV410 showed that update_pending is not
accurate with negative vpos. In most cases update_pending == 1 is returned
although the flip would complete before the start of the next frame.
Therefore I left the behaviour unchanged for pre-AVIVO ASICs for
performance reasons, although this may result in flickering in rare cases.

This change also makes the logic a little easier to understand.

Signed-off-by: Felix Kuehling 
---
 drivers/gpu/drm/radeon/radeon_display.c |   13 +++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index 7cb062d..1f98e5f 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -303,8 +303,17 @@ void radeon_crtc_handle_flip(struct radeon_device *rdev, 
int crtc_id)
if (update_pending &&
(DRM_SCANOUTPOS_VALID & radeon_get_crtc_scanoutpos(rdev->ddev, 
crtc_id,
   &vpos, &hpos)) &&
-   (vpos >=0) &&
-   (vpos < (99 * 
rdev->mode_info.crtcs[crtc_id]->base.hwmode.crtc_vdisplay)/100)) {
+   ((vpos >= (99 * 
rdev->mode_info.crtcs[crtc_id]->base.hwmode.crtc_vdisplay)/100) ||
+(vpos < 0 && !ASIC_IS_AVIVO(rdev {
+   /* crtc didn't flip in this target vblank interval,
+* but flip is pending in crtc. Based on the current
+* scanout position we know that the current frame is
+* (nearly) complete and the flip will (likely)
+* complete before the start of the next frame.
+*/
+   update_pending = 0;
+   }
+   if (update_pending) {
/* crtc didn't flip in this target vblank interval,
 * but flip is pending in crtc. It will complete it
 * in next vblank interval, so complete the flip at
-- 
1.7.5.4


--030107010002010209080004--


[Linaro-mm-sig] [PATCH 6/7] drm/vgem: import support

2012-02-23 Thread Chris Wilson
On Wed, 22 Feb 2012 20:29:19 +0100, Ben Widawsky  wrote:
> dma-buf import support. The function definitely needs some cleanup.
> 
> When reading through this code, there are 3 cases to consider:
> 1. vgem exporter, vgem importer, same fd
> 2. vgem exporter, vgem importer, different fd
> 3. X expoter, vgem importer - not yet tested
> 
> See the comments in the code for detailed explanation.
> 
> Cc: Daniel Vetter 
> Cc: Dave Airlie 
> Signed-off-by: Ben Widawsky 
> ---
>  drivers/gpu/drm/vgem/vgem_dma_buf.c |  120 
> +++
>  1 files changed, 120 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vgem/vgem_dma_buf.c 
> b/drivers/gpu/drm/vgem/vgem_dma_buf.c
> index eca9445..92c1823 100644
> --- a/drivers/gpu/drm/vgem/vgem_dma_buf.c
> +++ b/drivers/gpu/drm/vgem/vgem_dma_buf.c
> @@ -120,9 +120,129 @@ out_fd:
>   return 0;
>  }
>  
> +/*
> + * Convert a dma-buf fd to a drm object handle, creating new object/handle as
> + * needed.
> + *
> + * There are 2 "interesting" cases we have to consider. The other, less 
> interesting
> + * case is when importer == exporter, and drm_files are the same.
> + * vgem exporter
> + *   The original exporter may or may not still hold a reference to the
> + *   object by the time we reach here. Once we get a dma_buf reference though
> + *   we know the original object cannot go away. Next we grab the prime mutex
> + *   to prevent our lists from being screwed up from under us. We should next
> + *   find the object in our global dma_buf hash. To make everything cool
> + *   though we need to
> + * create a handle for the importer
> + * add the handle to the per file list
> + * drop the dma_buf reference
> + *   the object can't go away due to us owning a file handle for it.
> + *   In the end there should be 2 handle references, and 1 dma-buf reference.
> + *
> + * other exporter
> + *   This case is very similar to the previous one. The primary difference 
> is we
> + *   do not want to drop the dma_buf reference since we know nothing about 
> the
> + *   reference counting from the exporter. So instead, we hold the dma_buf
> + *   reference, but can drop the object reference. In the end of this case 
> there
> + *   should be 1 handle reference, and 1 dma-buf reference.
> + */
>  int vgem_prime_to_handle(struct drm_device *dev,
>struct drm_file *file, int prime_fd,
>uint32_t *handle)
>  {
> + struct drm_vgem_file_private *file_priv = file->driver_priv;
> + struct drm_vgem_gem_object *vobj = NULL;
> + struct drm_gem_object *obj = NULL;
> + struct dma_buf *dma_buf;
> + struct dma_buf_attachment *attach = NULL;
> + struct sg_table *sg = NULL;
> + bool drop_dma_buf_ref = false;
> + int ret;
> +
> + dma_buf = dma_buf_get(prime_fd);
> + if (IS_ERR(dma_buf))
> + return PTR_ERR(dma_buf);
> +
> + mutex_lock(&dev->prime_mutex);
> + /* First check that we don't dup on this file */
> + ret = drm_prime_lookup_fd_handle_mapping(&file_priv->prime, dma_buf,
> +  handle);
> + if (ret == 0) {
> + DRM_DEBUG_PRIME("file_priv has an object for this dma_buf\n");
> + dma_buf_put(dma_buf);
> + mutex_unlock(&dev->prime_mutex);
> + return 0;
> + }
> +
> + /* Now check if we've already created/imported this object */
> + ret = drm_prime_lookup_obj(dev, dma_buf, &obj);
> + if (ret == 0 && obj != NULL) {
> + DRM_DEBUG_PRIME("driver has an object for this dma_buf\n");
> + drop_dma_buf_ref = true;
> + vobj = to_vgem_bo(obj);
> + goto handle_create;
> + }
> +
> + DRM_DEBUG_PRIME("Creating a new object for dma_buf\n");
> +
> + attach = dma_buf_attach(dma_buf, dev->dev);
> + if (IS_ERR(attach)) {
> + ret = PTR_ERR(attach);
> + goto fail_put;
> + }
> +
> + sg = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
> + if (IS_ERR(sg)) {
> + ret = PTR_ERR(sg);
> + goto fail_detach;
> + }
> +
> + vobj = kzalloc(sizeof(*vobj), GFP_KERNEL);
> + if (vobj == NULL) {
> + ret = -ENOMEM;
> + goto fail_unmap;
> + }
> +
> + /* As a result of this mmap will not work -yet- */
> + ret = drm_gem_private_object_init(dev, &vobj->base, dma_buf->size);
> + if (ret) {
> + kfree(vobj);
> + ret = -ENOMEM;
> + goto fail_unmap;
> + }
> +
> + obj = &vobj->base;
Don't we need to store the backing attachment and prime_fd on the newly
created vgem obj?

> +
> +handle_create:
> + ret = drm_gem_handle_create(file, obj, handle);
> + if (ret)
> + return ret;
> +
> + ret = drm_prime_insert_fd_handle_mapping(&file_priv->prime,
> +  dma_buf, *handle);
> + if (ret)
> + g

[Linaro-mm-sig] [PATCH 5/7] drm/vgem: prime export support

2012-02-23 Thread Chris Wilson
On Wed, 22 Feb 2012 20:29:18 +0100, Ben Widawsky  wrote:
> dma-buf export implementation. Heavily influenced by Dave Airlie's proof
> of concept work.
> 
> Cc: Daniel Vetter 
> Cc: Dave Airlie 
> Signed-off-by: Ben Widawsky 
> ---
>  drivers/gpu/drm/vgem/Makefile   |2 +-
>  drivers/gpu/drm/vgem/vgem_dma_buf.c |  128 
> +++
>  drivers/gpu/drm/vgem/vgem_drv.c |6 ++
>  drivers/gpu/drm/vgem/vgem_drv.h |7 ++
>  4 files changed, 142 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/gpu/drm/vgem/vgem_dma_buf.c
> 
> diff --git a/drivers/gpu/drm/vgem/Makefile b/drivers/gpu/drm/vgem/Makefile
> index 3f4c7b8..1055cb7 100644
> --- a/drivers/gpu/drm/vgem/Makefile
> +++ b/drivers/gpu/drm/vgem/Makefile
> @@ -1,4 +1,4 @@
>  ccflags-y := -Iinclude/drm
> -vgem-y := vgem_drv.o
> +vgem-y := vgem_drv.o vgem_dma_buf.o
>  
>  obj-$(CONFIG_DRM_VGEM)   += vgem.o
> diff --git a/drivers/gpu/drm/vgem/vgem_dma_buf.c 
> b/drivers/gpu/drm/vgem/vgem_dma_buf.c
> new file mode 100644
> index 000..eca9445
> --- /dev/null
> +++ b/drivers/gpu/drm/vgem/vgem_dma_buf.c
> @@ -0,0 +1,128 @@
> +/*
> + * Copyright ?? 2012 Intel Corporation
> + *
> + * 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
> + * THE AUTHORS OR COPYRIGHT HOLDERS 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.
> + *
> + * Authors:
> + *Ben Widawsky 
> + *
> + */
> +
> +#include 
> +#include "vgem_drv.h"
> +
> +#define VGEM_FD_PERMS 0600
> +
> +struct sg_table *vgem_gem_map_dma_buf(struct dma_buf_attachment *attachment,
> +  enum dma_data_direction dir)
I guess I'm just not quite happy with the dma-buf interface, but I'd
have liked to have avoided the whole sg_table allocation and have made
the dma_buf embeddable. Daniel is slacking!

> +int vgem_prime_to_fd(struct drm_device *dev, struct drm_file *file,
> +  uint32_t handle, int *prime_fd)
> +{
> + struct drm_vgem_file_private *file_priv = file->driver_priv;
> + struct drm_vgem_gem_object *obj;
> + int ret;
> +
> + DRM_DEBUG_PRIME("Request fd for handle %d\n", handle);
> +
> + obj = to_vgem_bo(drm_gem_object_lookup(dev, file, handle));
> + if (!obj)
> + return -EBADF;
-ENOENT; EBADF is for reporting that ioctl was itself called on an invalid fd.

locking fail.

> + /* This means a user has already called get_fd on this */
> + if (obj->base.prime_fd != -1) {
> + DRM_DEBUG_PRIME("User requested a previously exported buffer "
> + "%d %d\n", handle, obj->base.prime_fd);
> + drm_gem_object_unreference(&obj->base);
> + goto out_fd;
> + }
> +
> + /* Make a dma buf out of our vgem object */
> + obj->base.export_dma_buf = dma_buf_export(obj, &vgem_dmabuf_ops,
> +   obj->base.size,
> +   VGEM_FD_PERMS);
locking fail.

> + if (IS_ERR(obj->base.export_dma_buf)) {
> + DRM_DEBUG_PRIME("export fail\n");
> + return PTR_ERR(obj->base.export_dma_buf);
> + } else
> + obj->base.prime_fd = dma_buf_fd(obj->base.export_dma_buf);
locking fail... ;-)

> +
> + mutex_lock(&dev->prime_mutex);
Per-device mutex for a per-file hash-table?

> + ret = drm_prime_insert_fd_handle_mapping(&file_priv->prime,
> +  obj->base.export_dma_buf,
> +  handle);
> + WARN_ON(ret);
> + ret = drm_prime_add_dma_buf(dev, &obj->base);
> + mutex_unlock(&dev->prime_mutex);
> + if (ret)
> + return ret;
> +
> +out_fd:
> + *prime_fd = obj->base.prime_fd;
> +
> + return 0;
> +}
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[Bug 42678] [3.3-rc1] radeon stuck in kernel after lockup

2012-02-23 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=42678





--- Comment #7 from Jérôme Glisse   2012-02-24 02:53:43 
---
You no longer have those lockup ? The fix in the ddx might explain why the
kernel was no longer able to recover from lockup. Sadly userspace change can
affect kernel successfulness at things like lockup recovering.

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


3.3-rc4+: Reported regressions from 3.2

2012-02-23 Thread David Miller
From: "Rafael J. Wysocki" 
Date: Thu, 23 Feb 2012 23:51:20 +0100 (CET)

> Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=42776
> Subject   : OF-related boot crash in 3.3.0-rc3-00188-g3ec1e88
> Submitter : Meelis Roos 
> Date  : 2012-02-13 7:45 (11 days old)
> Message-ID: 
> References: http://marc.info/?l=linux-kernel&m=132911916331615&w=2

Potential workaround/fix at:

http://marc.info/?l=linux-kernel&m=132993294018762&w=2


[drm-next 14/14] drm/radeon/kms: clean up radeon_asic struct (v2)

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

v2: fix typo.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   38 ++---
 drivers/gpu/drm/radeon/radeon_asic.c |  102 +-
 2 files changed, 69 insertions(+), 71 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 5077478..be3683f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1131,12 +1131,23 @@ struct radeon_asic {
void (*vga_set_state)(struct radeon_device *rdev, bool state);
bool (*gpu_is_lockup)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*asic_reset)(struct radeon_device *rdev);
-
+   /* ioctl hw specific callback. Some hw might want to perform special
+* operation on specific ioctl. For instance on wait idle some hw
+* might want to perform and HDP flush through MMIO as it seems that
+* some R6XX/R7XX hw doesn't take HDP flush into account if programmed
+* through ring.
+*/
+   void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
+   /* check if 3D engine is idle */
+   bool (*gui_idle)(struct radeon_device *rdev);
+   /* wait for mc_idle */
+   int (*mc_wait_for_idle)(struct radeon_device *rdev);
+   /* gart */
struct {
void (*tlb_flush)(struct radeon_device *rdev);
int (*set_page)(struct radeon_device *rdev, int i, uint64_t 
addr);
} gart;
-
+   /* ring specific callbacks */
struct {
void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib 
*ib);
int (*ib_parse)(struct radeon_device *rdev, struct radeon_ib 
*ib);
@@ -1148,12 +1159,12 @@ struct radeon_asic {
int (*ring_test)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*ib_test)(struct radeon_device *rdev, struct radeon_ring 
*cp);
} ring[RADEON_NUM_RINGS];
-
+   /* irqs */
struct {
int (*set)(struct radeon_device *rdev);
int (*process)(struct radeon_device *rdev);
} irq;
-
+   /* displays */
struct {
/* display watermarks */
void (*bandwidth_update)(struct radeon_device *rdev);
@@ -1162,7 +1173,7 @@ struct radeon_asic {
/* wait for vblank */
void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
} display;
-
+   /* copy functions for bo handling */
struct {
int (*blit)(struct radeon_device *rdev,
uint64_t src_offset,
@@ -1185,30 +1196,20 @@ struct radeon_asic {
/* ring used for bo copies */
u32 copy_ring_index;
} copy;
-
+   /* surfaces */
struct {
int (*set_reg)(struct radeon_device *rdev, int reg,
   uint32_t tiling_flags, uint32_t pitch,
   uint32_t offset, uint32_t obj_size);
void (*clear_reg)(struct radeon_device *rdev, int reg);
} surface;
-
+   /* hotplug detect */
struct {
void (*init)(struct radeon_device *rdev);
void (*fini)(struct radeon_device *rdev);
bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id 
hpd);
void (*set_polarity)(struct radeon_device *rdev, enum 
radeon_hpd_id hpd);
} hpd;
-
-   /* ioctl hw specific callback. Some hw might want to perform special
-* operation on specific ioctl. For instance on wait idle some hw
-* might want to perform and HDP flush through MMIO as it seems that
-* some R6XX/R7XX hw doesn't take HDP flush into account if programmed
-* through ring.
-*/
-   void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
-   /* check if 3D engine is idle */
-   bool (*gui_idle)(struct radeon_device *rdev);
/* power management */
struct {
void (*misc)(struct radeon_device *rdev);
@@ -1230,9 +1231,6 @@ struct radeon_asic {
u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 
crtc_base);
void (*post_page_flip)(struct radeon_device *rdev, int crtc);
} pflip;
-
-   /* wait for mc_idle */
-   int (*mc_wait_for_idle)(struct radeon_device *rdev);
 };

 /*
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 0a59f48..479c89e 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -136,6 +136,9 @@ static struct radeon_asic r100_asic = {
.vga_set_state = &r100_vga_set_state,
.gpu_is_lockup = &r100_gpu_is_lockup,
.asic_reset = &r100_asic_reset,
+   .ioctl_wait_idle = NULL,
+   .gui_idle = &r100_gui_idle,
+   .mc_wait_for_idle = &r100_mc_wait_for_idle,
 

[PATCH 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Mathias Fröhlich

Christian,

On Thursday, February 23, 2012 15:18:42 Christian K?nig wrote:
> The function radeon_bo_list_validate can cause a
> bo to move, resulting in a different sync_obj
> and a dependency to wait for this move to finish.
> 
> Signed-off-by: Christian K?nig 
> Reviewed-by: Alex Deucher 

I am not sure, but to me this looks like this could fix these kind of gpu 
lockups that I experience since some time every now and then.
The usual symptom is that I get the 

radeon :01:00.0: GPU lockup CP stall for more than 1msec
GPU lockup (waiting for 0x00682AC3 last fence id 0x00682AC2)
[...]

kernel message. Each time with the fence being off by one like in the example 
above.

If this change has the potential to fix this issue I think this particular 
patch should be considered for the current upstream kernel release.

Mathias


[PATCH 1/1] drm/i915: fix operator precedence when enabling RC6p

2012-02-23 Thread Eugeni Dodonov
As noticed by Torsten Kaiser, the operator precedence can play tricks with
us here.

CC: Dave Airlie 
CC: Jesse Barnes 
Signed-off-by: Eugeni Dodonov 
---
 drivers/gpu/drm/i915/intel_display.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c 
b/drivers/gpu/drm/i915/intel_display.c
index e654f32..4871ba0 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8194,7 +8194,7 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv)
 
if (intel_enable_rc6(dev_priv->dev))
rc6_mask = GEN6_RC_CTL_RC6_ENABLE |
-   (IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 0;
+   ((IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 
0);
 
I915_WRITE(GEN6_RC_CONTROL,
   rc6_mask |
-- 
1.7.8.4

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


[drm-next 14/14] drm/radeon/kms: clean up radeon_asic struct

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   38 ++---
 drivers/gpu/drm/radeon/radeon_asic.c |  100 +-
 2 files changed, 68 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 5077478..be3683f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1131,12 +1131,23 @@ struct radeon_asic {
void (*vga_set_state)(struct radeon_device *rdev, bool state);
bool (*gpu_is_lockup)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*asic_reset)(struct radeon_device *rdev);
-
+   /* ioctl hw specific callback. Some hw might want to perform special
+* operation on specific ioctl. For instance on wait idle some hw
+* might want to perform and HDP flush through MMIO as it seems that
+* some R6XX/R7XX hw doesn't take HDP flush into account if programmed
+* through ring.
+*/
+   void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
+   /* check if 3D engine is idle */
+   bool (*gui_idle)(struct radeon_device *rdev);
+   /* wait for mc_idle */
+   int (*mc_wait_for_idle)(struct radeon_device *rdev);
+   /* gart */
struct {
void (*tlb_flush)(struct radeon_device *rdev);
int (*set_page)(struct radeon_device *rdev, int i, uint64_t 
addr);
} gart;
-
+   /* ring specific callbacks */
struct {
void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib 
*ib);
int (*ib_parse)(struct radeon_device *rdev, struct radeon_ib 
*ib);
@@ -1148,12 +1159,12 @@ struct radeon_asic {
int (*ring_test)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*ib_test)(struct radeon_device *rdev, struct radeon_ring 
*cp);
} ring[RADEON_NUM_RINGS];
-
+   /* irqs */
struct {
int (*set)(struct radeon_device *rdev);
int (*process)(struct radeon_device *rdev);
} irq;
-
+   /* displays */
struct {
/* display watermarks */
void (*bandwidth_update)(struct radeon_device *rdev);
@@ -1162,7 +1173,7 @@ struct radeon_asic {
/* wait for vblank */
void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
} display;
-
+   /* copy functions for bo handling */
struct {
int (*blit)(struct radeon_device *rdev,
uint64_t src_offset,
@@ -1185,30 +1196,20 @@ struct radeon_asic {
/* ring used for bo copies */
u32 copy_ring_index;
} copy;
-
+   /* surfaces */
struct {
int (*set_reg)(struct radeon_device *rdev, int reg,
   uint32_t tiling_flags, uint32_t pitch,
   uint32_t offset, uint32_t obj_size);
void (*clear_reg)(struct radeon_device *rdev, int reg);
} surface;
-
+   /* hotplug detect */
struct {
void (*init)(struct radeon_device *rdev);
void (*fini)(struct radeon_device *rdev);
bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id 
hpd);
void (*set_polarity)(struct radeon_device *rdev, enum 
radeon_hpd_id hpd);
} hpd;
-
-   /* ioctl hw specific callback. Some hw might want to perform special
-* operation on specific ioctl. For instance on wait idle some hw
-* might want to perform and HDP flush through MMIO as it seems that
-* some R6XX/R7XX hw doesn't take HDP flush into account if programmed
-* through ring.
-*/
-   void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
-   /* check if 3D engine is idle */
-   bool (*gui_idle)(struct radeon_device *rdev);
/* power management */
struct {
void (*misc)(struct radeon_device *rdev);
@@ -1230,9 +1231,6 @@ struct radeon_asic {
u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 
crtc_base);
void (*post_page_flip)(struct radeon_device *rdev, int crtc);
} pflip;
-
-   /* wait for mc_idle */
-   int (*mc_wait_for_idle)(struct radeon_device *rdev);
 };

 /*
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 0a59f48..a592ca5 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -136,6 +136,9 @@ static struct radeon_asic r100_asic = {
.vga_set_state = &r100_vga_set_state,
.gpu_is_lockup = &r100_gpu_is_lockup,
.asic_reset = &r100_asic_reset,
+   .ioctl_wait_idle = NULL,
+   .gui_idle = &r100_gui_idle,
+   .mc_wait_for_idle = &r100_mc_wait_for_idle,
.gart = 

[drm-next 13/14] drm/radeon/kms: reorganize surface callbacks

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   14 +++--
 drivers/gpu/drm/radeon/radeon_asic.c |  103 ++
 2 files changed, 76 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 88dacc5..5077478 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1186,10 +1186,12 @@ struct radeon_asic {
u32 copy_ring_index;
} copy;

-   int (*set_surface_reg)(struct radeon_device *rdev, int reg,
-  uint32_t tiling_flags, uint32_t pitch,
-  uint32_t offset, uint32_t obj_size);
-   void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
+   struct {
+   int (*set_reg)(struct radeon_device *rdev, int reg,
+  uint32_t tiling_flags, uint32_t pitch,
+  uint32_t offset, uint32_t obj_size);
+   void (*clear_reg)(struct radeon_device *rdev, int reg);
+   } surface;

struct {
void (*init)(struct radeon_device *rdev);
@@ -1705,8 +1707,8 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_get_pcie_lanes(rdev) (rdev)->asic->pm.get_pcie_lanes((rdev))
 #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), 
(l))
 #define radeon_set_clock_gating(rdev, e) 
(rdev)->asic->pm.set_clock_gating((rdev), (e))
-#define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
-#define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->clear_surface_reg((rdev), (r)))
+#define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
+#define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->surface.clear_reg((rdev), (r)))
 #define radeon_bandwidth_update(rdev) 
(rdev)->asic->display.bandwidth_update((rdev))
 #define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
 #define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 4eaa5f1..0a59f48 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -168,8 +168,10 @@ static struct radeon_asic r100_asic = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -240,8 +242,10 @@ static struct radeon_asic r200_asic = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -312,8 +316,10 @@ static struct radeon_asic r300_asic = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -384,8 +390,10 @@ static struct radeon_asic r300_asic_pcie = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -456,9 +464,10 @@ static struct radeon_asic r420_asic = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
-
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -529,8 +538,10 @@ static struc

[drm-next 12/14] drm/radeon/kms: move clock/pcie setting callbacks into pm struct

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

tidy up radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/r100.c  |2 +-
 drivers/gpu/drm/radeon/radeon.h|   28 ++--
 drivers/gpu/drm/radeon/radeon_asic.c   |  248 
 drivers/gpu/drm/radeon/radeon_clocks.c |2 +-
 drivers/gpu/drm/radeon/radeon_pm.c |6 +-
 drivers/gpu/drm/radeon/rs600.c |2 +-
 6 files changed, 145 insertions(+), 143 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 8eb1421..42ae955 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -446,7 +446,7 @@ void r100_pm_misc(struct radeon_device *rdev)
/* set pcie lanes */
if ((rdev->flags & RADEON_IS_PCIE) &&
!(rdev->flags & RADEON_IS_IGP) &&
-   rdev->asic->set_pcie_lanes &&
+   rdev->asic->pm.set_pcie_lanes &&
(ps->pcie_lanes !=
 
rdev->pm.power_state[rdev->pm.current_power_state_index].pcie_lanes)) {
radeon_set_pcie_lanes(rdev,
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 0e75a05..88dacc5 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1186,13 +1186,6 @@ struct radeon_asic {
u32 copy_ring_index;
} copy;

-   uint32_t (*get_engine_clock)(struct radeon_device *rdev);
-   void (*set_engine_clock)(struct radeon_device *rdev, uint32_t 
eng_clock);
-   uint32_t (*get_memory_clock)(struct radeon_device *rdev);
-   void (*set_memory_clock)(struct radeon_device *rdev, uint32_t 
mem_clock);
-   int (*get_pcie_lanes)(struct radeon_device *rdev);
-   void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
-   void (*set_clock_gating)(struct radeon_device *rdev, int enable);
int (*set_surface_reg)(struct radeon_device *rdev, int reg,
   uint32_t tiling_flags, uint32_t pitch,
   uint32_t offset, uint32_t obj_size);
@@ -1221,6 +1214,13 @@ struct radeon_asic {
void (*finish)(struct radeon_device *rdev);
void (*init_profile)(struct radeon_device *rdev);
void (*get_dynpm_state)(struct radeon_device *rdev);
+   uint32_t (*get_engine_clock)(struct radeon_device *rdev);
+   void (*set_engine_clock)(struct radeon_device *rdev, uint32_t 
eng_clock);
+   uint32_t (*get_memory_clock)(struct radeon_device *rdev);
+   void (*set_memory_clock)(struct radeon_device *rdev, uint32_t 
mem_clock);
+   int (*get_pcie_lanes)(struct radeon_device *rdev);
+   void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
+   void (*set_clock_gating)(struct radeon_device *rdev, int 
enable);
} pm;
/* pageflipping */
struct {
@@ -1698,13 +1698,13 @@ void radeon_ring_write(struct radeon_ring *ring, 
uint32_t v);
 #define radeon_copy_blit_ring_index(rdev) (rdev)->asic->copy.blit_ring_index
 #define radeon_copy_dma_ring_index(rdev) (rdev)->asic->copy.dma_ring_index
 #define radeon_copy_ring_index(rdev) (rdev)->asic->copy.copy_ring_index
-#define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev))
-#define radeon_set_engine_clock(rdev, e) 
(rdev)->asic->set_engine_clock((rdev), (e))
-#define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev))
-#define radeon_set_memory_clock(rdev, e) 
(rdev)->asic->set_memory_clock((rdev), (e))
-#define radeon_get_pcie_lanes(rdev) (rdev)->asic->get_pcie_lanes((rdev))
-#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), 
(l))
-#define radeon_set_clock_gating(rdev, e) 
(rdev)->asic->set_clock_gating((rdev), (e))
+#define radeon_get_engine_clock(rdev) (rdev)->asic->pm.get_engine_clock((rdev))
+#define radeon_set_engine_clock(rdev, e) 
(rdev)->asic->pm.set_engine_clock((rdev), (e))
+#define radeon_get_memory_clock(rdev) (rdev)->asic->pm.get_memory_clock((rdev))
+#define radeon_set_memory_clock(rdev, e) 
(rdev)->asic->pm.set_memory_clock((rdev), (e))
+#define radeon_get_pcie_lanes(rdev) (rdev)->asic->pm.get_pcie_lanes((rdev))
+#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), 
(l))
+#define radeon_set_clock_gating(rdev, e) 
(rdev)->asic->pm.set_clock_gating((rdev), (e))
 #define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
 #define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->clear_surface_reg((rdev), (r)))
 #define radeon_bandwidth_update(rdev) 
(rdev)->asic->display.bandwidth_update((rdev))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 01ea642..4eaa5f1 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -168,13 +168,6 @@ static struct radeon_asic r100_asic = {
.copy =

[drm-next 11/14] drm/radeon/kms: reorganize display callbacks

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   19 +++--
 drivers/gpu/drm/radeon/radeon_asic.c |  137 +-
 2 files changed, 98 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 732582f..0e75a05 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1154,7 +1154,14 @@ struct radeon_asic {
int (*process)(struct radeon_device *rdev);
} irq;

-   u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
+   struct {
+   /* display watermarks */
+   void (*bandwidth_update)(struct radeon_device *rdev);
+   /* get frame count */
+   u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
+   /* wait for vblank */
+   void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
+   } display;

struct {
int (*blit)(struct radeon_device *rdev,
@@ -1190,7 +1197,6 @@ struct radeon_asic {
   uint32_t tiling_flags, uint32_t pitch,
   uint32_t offset, uint32_t obj_size);
void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
-   void (*bandwidth_update)(struct radeon_device *rdev);

struct {
void (*init)(struct radeon_device *rdev);
@@ -1222,8 +1228,7 @@ struct radeon_asic {
u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 
crtc_base);
void (*post_page_flip)(struct radeon_device *rdev, int crtc);
} pflip;
-   /* wait for vblank */
-   void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
+
/* wait for mc_idle */
int (*mc_wait_for_idle)(struct radeon_device *rdev);
 };
@@ -1684,7 +1689,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_ring_ib_parse(rdev, r, ib) 
(rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
 #define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
 #define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
-#define radeon_get_vblank_counter(rdev, crtc) 
(rdev)->asic->get_vblank_counter((rdev), (crtc))
+#define radeon_get_vblank_counter(rdev, crtc) 
(rdev)->asic->display.get_vblank_counter((rdev), (crtc))
 #define radeon_fence_ring_emit(rdev, r, fence) 
(rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
 #define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) 
(rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
 #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy.blit((rdev), 
(s), (d), (np), (f))
@@ -1702,7 +1707,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_set_clock_gating(rdev, e) 
(rdev)->asic->set_clock_gating((rdev), (e))
 #define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
 #define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->clear_surface_reg((rdev), (r)))
-#define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
+#define radeon_bandwidth_update(rdev) 
(rdev)->asic->display.bandwidth_update((rdev))
 #define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
 #define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
 #define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
@@ -1716,7 +1721,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_pre_page_flip(rdev, crtc) 
rdev->asic->pflip.pre_page_flip((rdev), (crtc))
 #define radeon_page_flip(rdev, crtc, base) rdev->asic->pflip.page_flip((rdev), 
(crtc), (base))
 #define radeon_post_page_flip(rdev, crtc) 
rdev->asic->pflip.post_page_flip((rdev), (crtc))
-#define radeon_wait_for_vblank(rdev, crtc) rdev->asic->wait_for_vblank((rdev), 
(crtc))
+#define radeon_wait_for_vblank(rdev, crtc) 
rdev->asic->display.wait_for_vblank((rdev), (crtc))
 #define radeon_mc_wait_for_idle(rdev) rdev->asic->mc_wait_for_idle((rdev))

 /* Common functions */
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 1fd6e56..01ea642 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -155,7 +155,11 @@ static struct radeon_asic r100_asic = {
.set = &r100_irq_set,
.process = &r100_irq_process,
},
-   .get_vblank_counter = &r100_get_vblank_counter,
+   .display = {
+   .bandwidth_update = &r100_bandwidth_update,
+   .get_vblank_counter = &r100_get_vblank_counter,
+   .wait_for_vblank = &r100_wait_for_vblank,
+   },
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
@@ -173,7 +177,6 @@ static struct radeon_asic r100_asic = {
.s

[drm-next 10/14] drm/radeon/kms: reorganize gart callbacks

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/r100.c|4 +-
 drivers/gpu/drm/radeon/r300.c|4 +-
 drivers/gpu/drm/radeon/radeon.h  |   12 +++-
 drivers/gpu/drm/radeon/radeon_asic.c |  110 ++
 4 files changed, 84 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index e36b730..8eb1421 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -626,8 +626,8 @@ int r100_pci_gart_init(struct radeon_device *rdev)
if (r)
return r;
rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
-   rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
-   rdev->asic->gart_set_page = &r100_pci_gart_set_page;
+   rdev->asic->gart.tlb_flush = &r100_pci_gart_tlb_flush;
+   rdev->asic->gart.set_page = &r100_pci_gart_set_page;
return radeon_gart_table_ram_alloc(rdev);
 }

diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 0a17b1d..fa14383 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -105,8 +105,8 @@ int rv370_pcie_gart_init(struct radeon_device *rdev)
if (r)
DRM_ERROR("Failed to register debugfs file for PCIE gart !\n");
rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
-   rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
-   rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
+   rdev->asic->gart.tlb_flush = &rv370_pcie_gart_tlb_flush;
+   rdev->asic->gart.set_page = &rv370_pcie_gart_set_page;
return radeon_gart_table_vram_alloc(rdev);
 }

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 4559338..732582f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1131,8 +1131,12 @@ struct radeon_asic {
void (*vga_set_state)(struct radeon_device *rdev, bool state);
bool (*gpu_is_lockup)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*asic_reset)(struct radeon_device *rdev);
-   void (*gart_tlb_flush)(struct radeon_device *rdev);
-   int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr);
+
+   struct {
+   void (*tlb_flush)(struct radeon_device *rdev);
+   int (*set_page)(struct radeon_device *rdev, int i, uint64_t 
addr);
+   } gart;
+
struct {
void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib 
*ib);
int (*ib_parse)(struct radeon_device *rdev, struct radeon_ib 
*ib);
@@ -1671,8 +1675,8 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), 
(state))
 #define radeon_gpu_is_lockup(rdev, cp) (rdev)->asic->gpu_is_lockup((rdev), 
(cp))
 #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
-#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev))
-#define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart_set_page((rdev), 
(i), (p))
+#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev))
+#define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart.set_page((rdev), 
(i), (p))
 #define radeon_ring_start(rdev, r, cp) 
(rdev)->asic->ring[(r)].ring_start((rdev), (cp))
 #define radeon_ring_test(rdev, r, cp) 
(rdev)->asic->ring[(r)].ring_test((rdev), (cp))
 #define radeon_ib_test(rdev, r, cp) (rdev)->asic->ring[(r)].ib_test((rdev), 
(cp))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 85e1350..1fd6e56 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -114,13 +114,13 @@ void radeon_agp_disable(struct radeon_device *rdev)
rdev->family == CHIP_R423) {
DRM_INFO("Forcing AGP to PCIE mode\n");
rdev->flags |= RADEON_IS_PCIE;
-   rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
-   rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
+   rdev->asic->gart.tlb_flush = &rv370_pcie_gart_tlb_flush;
+   rdev->asic->gart.set_page = &rv370_pcie_gart_set_page;
} else {
DRM_INFO("Forcing AGP to PCI mode\n");
rdev->flags |= RADEON_IS_PCI;
-   rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
-   rdev->asic->gart_set_page = &r100_pci_gart_set_page;
+   rdev->asic->gart.tlb_flush = &r100_pci_gart_tlb_flush;
+   rdev->asic->gart.set_page = &r100_pci_gart_set_page;
}
rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
 }
@@ -136,8 +136,10 @@ static struct radeon_asic r100_asic = {
.vga_set_state = &r100_vga_set_state,
.gpu_is_lockup = &r100_gpu_is_lockup,
.asic_reset = &r100_asic_reset,
-   .gar

[drm-next 09/14] drm/radeon/kms: make ring_start, ring_test, and ib_test per ring

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

Each ring type may need a different variant.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/evergreen.c   |4 +-
 drivers/gpu/drm/radeon/ni.c  |4 +-
 drivers/gpu/drm/radeon/r100.c|   11 ++---
 drivers/gpu/drm/radeon/r300.c|5 +-
 drivers/gpu/drm/radeon/r420.c|2 +-
 drivers/gpu/drm/radeon/r520.c|2 +-
 drivers/gpu/drm/radeon/r600.c|9 ++--
 drivers/gpu/drm/radeon/radeon.h  |   13 +++---
 drivers/gpu/drm/radeon/radeon_asic.c |   75 +
 drivers/gpu/drm/radeon/radeon_asic.h |   10 ++--
 drivers/gpu/drm/radeon/rs400.c   |2 +-
 drivers/gpu/drm/radeon/rs600.c   |2 +-
 drivers/gpu/drm/radeon/rs690.c   |2 +-
 drivers/gpu/drm/radeon/rv515.c   |5 +-
 drivers/gpu/drm/radeon/rv770.c   |2 +-
 15 files changed, 83 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index ab334e9..758f04b 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1508,7 +1508,7 @@ int evergreen_cp_resume(struct radeon_device *rdev)

evergreen_cp_start(rdev);
ring->ready = true;
-   r = radeon_ring_test(rdev, ring);
+   r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, ring);
if (r) {
ring->ready = false;
return r;
@@ -3206,7 +3206,7 @@ static int evergreen_startup(struct radeon_device *rdev)
if (r)
return r;

-   r = r600_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX);
+   r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
if (r) {
DRM_ERROR("radeon: failed testing IB (%d).\n", r);
rdev->accel_working = false;
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 2d9ee5d..160799c 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1318,7 +1318,7 @@ int cayman_cp_resume(struct radeon_device *rdev)
rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX].ready = false;
rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = false;
/* this only test cp0 */
-   r = radeon_ring_test(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
+   r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
if (r) {
rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false;
rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX].ready = false;
@@ -1518,7 +1518,7 @@ static int cayman_startup(struct radeon_device *rdev)
if (r)
return r;

-   r = r600_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX);
+   r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
if (r) {
DRM_ERROR("radeon: failed testing IB (%d).\n", r);
rdev->accel_working = false;
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index bff612a..e36b730 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -964,9 +964,8 @@ static int r100_cp_wait_for_idle(struct radeon_device *rdev)
return -1;
 }

-void r100_ring_start(struct radeon_device *rdev)
+void r100_ring_start(struct radeon_device *rdev, struct radeon_ring *ring)
 {
-   struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
int r;

r = radeon_ring_lock(rdev, ring, 2);
@@ -1177,8 +1176,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned 
ring_size)
WREG32(RADEON_CP_RB_WPTR_DELAY, 0);
WREG32(RADEON_CP_CSQ_MODE, 0x4D4D);
WREG32(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM);
-   radeon_ring_start(rdev);
-   r = radeon_ring_test(rdev, ring);
+   radeon_ring_start(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
+   r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, ring);
if (r) {
DRM_ERROR("radeon: cp isn't working (%d).\n", r);
return r;
@@ -3725,7 +3724,7 @@ void r100_ring_ib_execute(struct radeon_device *rdev, 
struct radeon_ib *ib)
radeon_ring_write(ring, ib->length_dw);
 }

-int r100_ib_test(struct radeon_device *rdev)
+int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
 {
struct radeon_ib *ib;
uint32_t scratch;
@@ -3950,7 +3949,7 @@ static int r100_startup(struct radeon_device *rdev)
if (r)
return r;

-   r = r100_ib_test(rdev);
+   r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
if (r) {
dev_err(rdev->dev, "failed testing IB (%d).\n", r);
rdev->accel_working = false;
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 6829638..0a17b1d 100644
--- a/drivers/gpu/drm/radeon/r300.c

[drm-next 08/14] drm/radeon/kms: remove unused cp callbacks from radeon_asic

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 9fbeca4..d2aa41f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1134,9 +1134,6 @@ struct radeon_asic {
int (*asic_reset)(struct radeon_device *rdev);
void (*gart_tlb_flush)(struct radeon_device *rdev);
int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr);
-   int (*cp_init)(struct radeon_device *rdev, unsigned ring_size);
-   void (*cp_fini)(struct radeon_device *rdev);
-   void (*cp_disable)(struct radeon_device *rdev);
void (*ring_start)(struct radeon_device *rdev);

struct {
-- 
1.7.7.5



[drm-next 07/14] drm/radeon/kms: reorganize irq callbacks

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   13 +++-
 drivers/gpu/drm/radeon/radeon_asic.c |  102 ++---
 2 files changed, 77 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index d49d461..9fbeca4 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1149,8 +1149,12 @@ struct radeon_asic {
} ring[RADEON_NUM_RINGS];

int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
-   int (*irq_set)(struct radeon_device *rdev);
-   int (*irq_process)(struct radeon_device *rdev);
+
+   struct {
+   int (*set)(struct radeon_device *rdev);
+   int (*process)(struct radeon_device *rdev);
+   } irq;
+
u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);

struct {
@@ -1203,6 +1207,7 @@ struct radeon_asic {
 * through ring.
 */
void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
+   /* check if 3D engine is idle */
bool (*gui_idle)(struct radeon_device *rdev);
/* power management */
struct {
@@ -1677,8 +1682,8 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_ring_test(rdev, cp) (rdev)->asic->ring_test((rdev), (cp))
 #define radeon_ring_ib_execute(rdev, r, ib) 
(rdev)->asic->ring[(r)].ib_execute((rdev), (ib))
 #define radeon_ring_ib_parse(rdev, r, ib) 
(rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
-#define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev))
-#define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev))
+#define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
+#define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
 #define radeon_get_vblank_counter(rdev, crtc) 
(rdev)->asic->get_vblank_counter((rdev), (crtc))
 #define radeon_fence_ring_emit(rdev, r, fence) 
(rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
 #define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) 
(rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 6bd1525..a7b6c37 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -148,8 +148,10 @@ static struct radeon_asic r100_asic = {
.cs_parse = &r100_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -213,8 +215,10 @@ static struct radeon_asic r200_asic = {
.cs_parse = &r100_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -277,8 +281,10 @@ static struct radeon_asic r300_asic = {
.cs_parse = &r300_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -342,8 +348,10 @@ static struct radeon_asic r300_asic_pcie = {
.cs_parse = &r300_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -406,8 +414,10 @@ static struct radeon_asic r420_asic = {
.cs_parse = &r300_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -471,8 +481,10 @@ static struct radeon_asic rs400_asic = {
.cs_parse = &r300_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_

[drm-next 06/14] drm/radeon/kms: reorganize copy callbacks

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

tidy up the radeon_asic struct, handle multiple
rings better.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/evergreen.c|2 +-
 drivers/gpu/drm/radeon/ni.c   |2 +-
 drivers/gpu/drm/radeon/r600.c |2 +-
 drivers/gpu/drm/radeon/radeon.h   |   50 +---
 drivers/gpu/drm/radeon/radeon_asic.c  |  190 +
 drivers/gpu/drm/radeon/radeon_benchmark.c |   12 +-
 drivers/gpu/drm/radeon/radeon_ttm.c   |   15 ++-
 drivers/gpu/drm/radeon/rv770.c|2 +-
 8 files changed, 185 insertions(+), 90 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index 158ff59..ab334e9 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3166,7 +3166,7 @@ static int evergreen_startup(struct radeon_device *rdev)
r = evergreen_blit_init(rdev);
if (r) {
r600_blit_fini(rdev);
-   rdev->asic->copy = NULL;
+   rdev->asic->copy.copy = NULL;
dev_warn(rdev->dev, "failed blitter (%d) falling back to 
memcpy\n", r);
}

diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 2509c50..2d9ee5d 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1466,7 +1466,7 @@ static int cayman_startup(struct radeon_device *rdev)
r = evergreen_blit_init(rdev);
if (r) {
r600_blit_fini(rdev);
-   rdev->asic->copy = NULL;
+   rdev->asic->copy.copy = NULL;
dev_warn(rdev->dev, "failed blitter (%d) falling back to 
memcpy\n", r);
}

diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index fbcd848..e15a267 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2449,7 +2449,7 @@ int r600_startup(struct radeon_device *rdev)
r = r600_blit_init(rdev);
if (r) {
r600_blit_fini(rdev);
-   rdev->asic->copy = NULL;
+   rdev->asic->copy.copy = NULL;
dev_warn(rdev->dev, "failed blitter (%d) falling back to 
memcpy\n", r);
}

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 3ad14208..d49d461 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1152,21 +1152,30 @@ struct radeon_asic {
int (*irq_set)(struct radeon_device *rdev);
int (*irq_process)(struct radeon_device *rdev);
u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
-   int (*copy_blit)(struct radeon_device *rdev,
-uint64_t src_offset,
-uint64_t dst_offset,
-unsigned num_gpu_pages,
-struct radeon_fence *fence);
-   int (*copy_dma)(struct radeon_device *rdev,
-   uint64_t src_offset,
-   uint64_t dst_offset,
-   unsigned num_gpu_pages,
-   struct radeon_fence *fence);
-   int (*copy)(struct radeon_device *rdev,
-   uint64_t src_offset,
-   uint64_t dst_offset,
-   unsigned num_gpu_pages,
-   struct radeon_fence *fence);
+
+   struct {
+   int (*blit)(struct radeon_device *rdev,
+   uint64_t src_offset,
+   uint64_t dst_offset,
+   unsigned num_gpu_pages,
+   struct radeon_fence *fence);
+   u32 blit_ring_index;
+   int (*dma)(struct radeon_device *rdev,
+  uint64_t src_offset,
+  uint64_t dst_offset,
+  unsigned num_gpu_pages,
+  struct radeon_fence *fence);
+   u32 dma_ring_index;
+   /* method used for bo copy */
+   int (*copy)(struct radeon_device *rdev,
+   uint64_t src_offset,
+   uint64_t dst_offset,
+   unsigned num_gpu_pages,
+   struct radeon_fence *fence);
+   /* ring used for bo copies */
+   u32 copy_ring_index;
+   } copy;
+
uint32_t (*get_engine_clock)(struct radeon_device *rdev);
void (*set_engine_clock)(struct radeon_device *rdev, uint32_t 
eng_clock);
uint32_t (*get_memory_clock)(struct radeon_device *rdev);
@@ -1503,8 +1512,6 @@ struct radeon_device {
unsigneddebugfs_count;
/* virtual memory */
struct radeon_vm_managervm_manager;
-   /* ring used for bo copies */
-   u32 copy_ring;
 };

 int radeon_device_init(struct radeon_device *rdev,
@@ -1675,9 +1682,12 @@ void radeon_ring_write(struct radeon_ring *ring, 
uint32_t v

[drm-next 05/14] drm/radeon/kms: reorganize pm callbacks

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   22 ++--
 drivers/gpu/drm/radeon/radeon_asic.c |  204 --
 2 files changed, 131 insertions(+), 95 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 20d4aad..3ad14208 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1196,11 +1196,13 @@ struct radeon_asic {
void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
bool (*gui_idle)(struct radeon_device *rdev);
/* power management */
-   void (*pm_misc)(struct radeon_device *rdev);
-   void (*pm_prepare)(struct radeon_device *rdev);
-   void (*pm_finish)(struct radeon_device *rdev);
-   void (*pm_init_profile)(struct radeon_device *rdev);
-   void (*pm_get_dynpm_state)(struct radeon_device *rdev);
+   struct {
+   void (*misc)(struct radeon_device *rdev);
+   void (*prepare)(struct radeon_device *rdev);
+   void (*finish)(struct radeon_device *rdev);
+   void (*init_profile)(struct radeon_device *rdev);
+   void (*get_dynpm_state)(struct radeon_device *rdev);
+   } pm;
/* pageflipping */
struct {
void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
@@ -1691,11 +1693,11 @@ void radeon_ring_write(struct radeon_ring *ring, 
uint32_t v);
 #define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
 #define radeon_hpd_set_polarity(rdev, h) 
(rdev)->asic->hpd.set_polarity((rdev), (h))
 #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
-#define radeon_pm_misc(rdev) (rdev)->asic->pm_misc((rdev))
-#define radeon_pm_prepare(rdev) (rdev)->asic->pm_prepare((rdev))
-#define radeon_pm_finish(rdev) (rdev)->asic->pm_finish((rdev))
-#define radeon_pm_init_profile(rdev) (rdev)->asic->pm_init_profile((rdev))
-#define radeon_pm_get_dynpm_state(rdev) 
(rdev)->asic->pm_get_dynpm_state((rdev))
+#define radeon_pm_misc(rdev) (rdev)->asic->pm.misc((rdev))
+#define radeon_pm_prepare(rdev) (rdev)->asic->pm.prepare((rdev))
+#define radeon_pm_finish(rdev) (rdev)->asic->pm.finish((rdev))
+#define radeon_pm_init_profile(rdev) (rdev)->asic->pm.init_profile((rdev))
+#define radeon_pm_get_dynpm_state(rdev) 
(rdev)->asic->pm.get_dynpm_state((rdev))
 #define radeon_pre_page_flip(rdev, crtc) 
rdev->asic->pflip.pre_page_flip((rdev), (crtc))
 #define radeon_page_flip(rdev, crtc, base) rdev->asic->pflip.page_flip((rdev), 
(crtc), (base))
 #define radeon_post_page_flip(rdev, crtc) 
rdev->asic->pflip.post_page_flip((rdev), (crtc))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 6ebdeeb..38a29bc 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -172,11 +172,13 @@ static struct radeon_asic r100_asic = {
},
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
-   .pm_misc = &r100_pm_misc,
-   .pm_prepare = &r100_pm_prepare,
-   .pm_finish = &r100_pm_finish,
-   .pm_init_profile = &r100_pm_init_profile,
-   .pm_get_dynpm_state = &r100_pm_get_dynpm_state,
+   .pm = {
+   .misc = &r100_pm_misc,
+   .prepare = &r100_pm_prepare,
+   .finish = &r100_pm_finish,
+   .init_profile = &r100_pm_init_profile,
+   .get_dynpm_state = &r100_pm_get_dynpm_state,
+   },
.pflip = {
.pre_page_flip = &r100_pre_page_flip,
.page_flip = &r100_page_flip,
@@ -229,11 +231,13 @@ static struct radeon_asic r200_asic = {
},
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
-   .pm_misc = &r100_pm_misc,
-   .pm_prepare = &r100_pm_prepare,
-   .pm_finish = &r100_pm_finish,
-   .pm_init_profile = &r100_pm_init_profile,
-   .pm_get_dynpm_state = &r100_pm_get_dynpm_state,
+   .pm = {
+   .misc = &r100_pm_misc,
+   .prepare = &r100_pm_prepare,
+   .finish = &r100_pm_finish,
+   .init_profile = &r100_pm_init_profile,
+   .get_dynpm_state = &r100_pm_get_dynpm_state,
+   },
.pflip = {
.pre_page_flip = &r100_pre_page_flip,
.page_flip = &r100_page_flip,
@@ -287,11 +291,13 @@ static struct radeon_asic r300_asic = {
},
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
-   .pm_misc = &r100_pm_misc,
-   .pm_prepare = &r100_pm_prepare,
-   .pm_finish = &r100_pm_finish,
-   .pm_init_profile = &r100_pm_init_profile,
-   .pm_get_dynpm_state = &r100_pm_get_dynpm_state,
+   .pm = {
+   .misc = &r100_pm_misc,
+   .prepare = &r100_pm_prepare,
+   .finish = &r100_pm_finish,
+   .init_profile = &r100_pm_init_profile,
+   .get_dyn

[drm-next 04/14] drm/radeon/kms: reorganize page flip callbacks

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   14 ++--
 drivers/gpu/drm/radeon/radeon_asic.c |  136 +-
 2 files changed, 93 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 31e3d33..20d4aad 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1202,9 +1202,11 @@ struct radeon_asic {
void (*pm_init_profile)(struct radeon_device *rdev);
void (*pm_get_dynpm_state)(struct radeon_device *rdev);
/* pageflipping */
-   void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
-   u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
-   void (*post_page_flip)(struct radeon_device *rdev, int crtc);
+   struct {
+   void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
+   u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 
crtc_base);
+   void (*post_page_flip)(struct radeon_device *rdev, int crtc);
+   } pflip;
/* wait for vblank */
void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
/* wait for mc_idle */
@@ -1694,9 +1696,9 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_pm_finish(rdev) (rdev)->asic->pm_finish((rdev))
 #define radeon_pm_init_profile(rdev) (rdev)->asic->pm_init_profile((rdev))
 #define radeon_pm_get_dynpm_state(rdev) 
(rdev)->asic->pm_get_dynpm_state((rdev))
-#define radeon_pre_page_flip(rdev, crtc) rdev->asic->pre_page_flip((rdev), 
(crtc))
-#define radeon_page_flip(rdev, crtc, base) rdev->asic->page_flip((rdev), 
(crtc), (base))
-#define radeon_post_page_flip(rdev, crtc) rdev->asic->post_page_flip((rdev), 
(crtc))
+#define radeon_pre_page_flip(rdev, crtc) 
rdev->asic->pflip.pre_page_flip((rdev), (crtc))
+#define radeon_page_flip(rdev, crtc, base) rdev->asic->pflip.page_flip((rdev), 
(crtc), (base))
+#define radeon_post_page_flip(rdev, crtc) 
rdev->asic->pflip.post_page_flip((rdev), (crtc))
 #define radeon_wait_for_vblank(rdev, crtc) rdev->asic->wait_for_vblank((rdev), 
(crtc))
 #define radeon_mc_wait_for_idle(rdev) rdev->asic->mc_wait_for_idle((rdev))

diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 4a23255..6ebdeeb 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -177,9 +177,11 @@ static struct radeon_asic r100_asic = {
.pm_finish = &r100_pm_finish,
.pm_init_profile = &r100_pm_init_profile,
.pm_get_dynpm_state = &r100_pm_get_dynpm_state,
-   .pre_page_flip = &r100_pre_page_flip,
-   .page_flip = &r100_page_flip,
-   .post_page_flip = &r100_post_page_flip,
+   .pflip = {
+   .pre_page_flip = &r100_pre_page_flip,
+   .page_flip = &r100_page_flip,
+   .post_page_flip = &r100_post_page_flip,
+   },
.wait_for_vblank = &r100_wait_for_vblank,
.mc_wait_for_idle = &r100_mc_wait_for_idle,
 };
@@ -232,9 +234,11 @@ static struct radeon_asic r200_asic = {
.pm_finish = &r100_pm_finish,
.pm_init_profile = &r100_pm_init_profile,
.pm_get_dynpm_state = &r100_pm_get_dynpm_state,
-   .pre_page_flip = &r100_pre_page_flip,
-   .page_flip = &r100_page_flip,
-   .post_page_flip = &r100_post_page_flip,
+   .pflip = {
+   .pre_page_flip = &r100_pre_page_flip,
+   .page_flip = &r100_page_flip,
+   .post_page_flip = &r100_post_page_flip,
+   },
.wait_for_vblank = &r100_wait_for_vblank,
.mc_wait_for_idle = &r100_mc_wait_for_idle,
 };
@@ -288,9 +292,11 @@ static struct radeon_asic r300_asic = {
.pm_finish = &r100_pm_finish,
.pm_init_profile = &r100_pm_init_profile,
.pm_get_dynpm_state = &r100_pm_get_dynpm_state,
-   .pre_page_flip = &r100_pre_page_flip,
-   .page_flip = &r100_page_flip,
-   .post_page_flip = &r100_post_page_flip,
+   .pflip = {
+   .pre_page_flip = &r100_pre_page_flip,
+   .page_flip = &r100_page_flip,
+   .post_page_flip = &r100_post_page_flip,
+   },
.wait_for_vblank = &r100_wait_for_vblank,
.mc_wait_for_idle = &r300_mc_wait_for_idle,
 };
@@ -343,9 +349,11 @@ static struct radeon_asic r300_asic_pcie = {
.pm_finish = &r100_pm_finish,
.pm_init_profile = &r100_pm_init_profile,
.pm_get_dynpm_state = &r100_pm_get_dynpm_state,
-   .pre_page_flip = &r100_pre_page_flip,
-   .page_flip = &r100_page_flip,
-   .post_page_flip = &r100_post_page_flip,
+   .pflip = {
+   .pre_page_flip = &r100_pre_page_flip,
+   .page_flip = &r100_page_flip,
+   .post_page_flip = &r100_post_page_flip,
+   },
.wait_for_vblank = &r100_wait_for_vblank,
.mc_wait_for_idle = &r30

[drm-next 03/14] drm/radeon/kms: reorganize hpd callbacks

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   20 +++--
 drivers/gpu/drm/radeon/radeon_asic.c |  170 --
 2 files changed, 114 insertions(+), 76 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 3906927..31e3d33 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1179,10 +1179,14 @@ struct radeon_asic {
   uint32_t offset, uint32_t obj_size);
void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
void (*bandwidth_update)(struct radeon_device *rdev);
-   void (*hpd_init)(struct radeon_device *rdev);
-   void (*hpd_fini)(struct radeon_device *rdev);
-   bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
-   void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id 
hpd);
+
+   struct {
+   void (*init)(struct radeon_device *rdev);
+   void (*fini)(struct radeon_device *rdev);
+   bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id 
hpd);
+   void (*set_polarity)(struct radeon_device *rdev, enum 
radeon_hpd_id hpd);
+   } hpd;
+
/* ioctl hw specific callback. Some hw might want to perform special
 * operation on specific ioctl. For instance on wait idle some hw
 * might want to perform and HDP flush through MMIO as it seems that
@@ -1680,10 +1684,10 @@ void radeon_ring_write(struct radeon_ring *ring, 
uint32_t v);
 #define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
 #define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->clear_surface_reg((rdev), (r)))
 #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
-#define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev))
-#define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev))
-#define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd))
-#define radeon_hpd_set_polarity(rdev, hpd) 
(rdev)->asic->hpd_set_polarity((rdev), (hpd))
+#define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
+#define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
+#define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
+#define radeon_hpd_set_polarity(rdev, h) 
(rdev)->asic->hpd.set_polarity((rdev), (h))
 #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
 #define radeon_pm_misc(rdev) (rdev)->asic->pm_misc((rdev))
 #define radeon_pm_prepare(rdev) (rdev)->asic->pm_prepare((rdev))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 9f20546..4a23255 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -164,10 +164,12 @@ static struct radeon_asic r100_asic = {
.set_surface_reg = r100_set_surface_reg,
.clear_surface_reg = r100_clear_surface_reg,
.bandwidth_update = &r100_bandwidth_update,
-   .hpd_init = &r100_hpd_init,
-   .hpd_fini = &r100_hpd_fini,
-   .hpd_sense = &r100_hpd_sense,
-   .hpd_set_polarity = &r100_hpd_set_polarity,
+   .hpd = {
+   .init = &r100_hpd_init,
+   .fini = &r100_hpd_fini,
+   .sense = &r100_hpd_sense,
+   .set_polarity = &r100_hpd_set_polarity,
+   },
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
.pm_misc = &r100_pm_misc,
@@ -217,10 +219,12 @@ static struct radeon_asic r200_asic = {
.set_surface_reg = r100_set_surface_reg,
.clear_surface_reg = r100_clear_surface_reg,
.bandwidth_update = &r100_bandwidth_update,
-   .hpd_init = &r100_hpd_init,
-   .hpd_fini = &r100_hpd_fini,
-   .hpd_sense = &r100_hpd_sense,
-   .hpd_set_polarity = &r100_hpd_set_polarity,
+   .hpd = {
+   .init = &r100_hpd_init,
+   .fini = &r100_hpd_fini,
+   .sense = &r100_hpd_sense,
+   .set_polarity = &r100_hpd_set_polarity,
+   },
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
.pm_misc = &r100_pm_misc,
@@ -271,10 +275,12 @@ static struct radeon_asic r300_asic = {
.set_surface_reg = r100_set_surface_reg,
.clear_surface_reg = r100_clear_surface_reg,
.bandwidth_update = &r100_bandwidth_update,
-   .hpd_init = &r100_hpd_init,
-   .hpd_fini = &r100_hpd_fini,
-   .hpd_sense = &r100_hpd_sense,
-   .hpd_set_polarity = &r100_hpd_set_polarity,
+   .hpd = {
+   .init = &r100_hpd_init,
+   .fini = &r100_hpd_fini,
+   .sense = &r100_hpd_sense,
+   .set_polarity = &r100_hpd_set_polarity,
+   },
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
.pm_misc = &r100_pm_misc,
@@ -324,10 +330,12 @@ static struct radeon_asic r300_asic_pcie

[drm-next 02/14] drm/radeon/kms: add a radeon asic callback for mc idle

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

Required for future functionality.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/r520.c|2 +-
 drivers/gpu/drm/radeon/radeon.h  |3 +++
 drivers/gpu/drm/radeon/radeon_asic.c |   17 +
 drivers/gpu/drm/radeon/radeon_asic.h |   10 +-
 drivers/gpu/drm/radeon/rs690.c   |2 +-
 5 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index 25084e8..8a9dab0 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -33,7 +33,7 @@

 /* This files gather functions specifics to: r520,rv530,rv560,rv570,r580 */

-static int r520_mc_wait_for_idle(struct radeon_device *rdev)
+int r520_mc_wait_for_idle(struct radeon_device *rdev)
 {
unsigned i;
uint32_t tmp;
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 76d08d8..3906927 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1203,6 +1203,8 @@ struct radeon_asic {
void (*post_page_flip)(struct radeon_device *rdev, int crtc);
/* wait for vblank */
void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
+   /* wait for mc_idle */
+   int (*mc_wait_for_idle)(struct radeon_device *rdev);
 };

 /*
@@ -1692,6 +1694,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_page_flip(rdev, crtc, base) rdev->asic->page_flip((rdev), 
(crtc), (base))
 #define radeon_post_page_flip(rdev, crtc) rdev->asic->post_page_flip((rdev), 
(crtc))
 #define radeon_wait_for_vblank(rdev, crtc) rdev->asic->wait_for_vblank((rdev), 
(crtc))
+#define radeon_mc_wait_for_idle(rdev) rdev->asic->mc_wait_for_idle((rdev))

 /* Common functions */
 /* AGP */
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 67f809e..9f20546 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -179,6 +179,7 @@ static struct radeon_asic r100_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r100_mc_wait_for_idle,
 };

 static struct radeon_asic r200_asic = {
@@ -231,6 +232,7 @@ static struct radeon_asic r200_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r100_mc_wait_for_idle,
 };

 static struct radeon_asic r300_asic = {
@@ -284,6 +286,7 @@ static struct radeon_asic r300_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r300_mc_wait_for_idle,
 };

 static struct radeon_asic r300_asic_pcie = {
@@ -336,6 +339,7 @@ static struct radeon_asic r300_asic_pcie = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r300_mc_wait_for_idle,
 };

 static struct radeon_asic r420_asic = {
@@ -389,6 +393,7 @@ static struct radeon_asic r420_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r300_mc_wait_for_idle,
 };

 static struct radeon_asic rs400_asic = {
@@ -442,6 +447,7 @@ static struct radeon_asic rs400_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &rs400_mc_wait_for_idle,
 };

 static struct radeon_asic rs600_asic = {
@@ -495,6 +501,7 @@ static struct radeon_asic rs600_asic = {
.page_flip = &rs600_page_flip,
.post_page_flip = &rs600_post_page_flip,
.wait_for_vblank = &avivo_wait_for_vblank,
+   .mc_wait_for_idle = &rs600_mc_wait_for_idle,
 };

 static struct radeon_asic rs690_asic = {
@@ -548,6 +555,7 @@ static struct radeon_asic rs690_asic = {
.page_flip = &rs600_page_flip,
.post_page_flip = &rs600_post_page_flip,
.wait_for_vblank = &avivo_wait_for_vblank,
+   .mc_wait_for_idle = &rs690_mc_wait_for_idle,
 };

 static struct radeon_asic rv515_asic = {
@@ -601,6 +609,7 @@ static struct radeon_asic rv515_asic = {
.page_flip = &rs600_page_flip,
.post_page_flip = &rs600_post_page_flip,
.wait_for_vblank = &avivo_wait_for_vblank,
+   .mc_wait_for_idle = &rv515_mc_wait_for_idle,
 };

 static struct radeon_asic r520_asic = {
@@ -654,6 +663,7 @@ static struct radeon_asic r520_asic = {
.page_flip = &rs600_page_flip,
.post_page_flip = &rs600_post_page_flip,
.wait_for_vblank = &avivo_wait_for_vblank,
+   .mc_wait_for_idle = &r520_mc_wait_for_idle,
 };

 static struct radeon_asic r600_asic = {
@@ -706,6 +71

[drm-next 01/14] drm/radeon/kms: add wait_for_vblank asic callback

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

Required for future functionality.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/evergreen.c |   19 +
 drivers/gpu/drm/radeon/evergreen_reg.h |1 +
 drivers/gpu/drm/radeon/r100.c  |   34 
 drivers/gpu/drm/radeon/r500_reg.h  |2 +
 drivers/gpu/drm/radeon/radeon.h|3 ++
 drivers/gpu/drm/radeon/radeon_asic.c   |   17 
 drivers/gpu/drm/radeon/radeon_asic.h   |4 ++-
 drivers/gpu/drm/radeon/radeon_reg.h|2 +
 drivers/gpu/drm/radeon/rs600.c |   19 +
 9 files changed, 100 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index f58254a..158ff59 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -68,6 +68,25 @@ void evergreen_fix_pci_max_read_req_size(struct 
radeon_device *rdev)
}
 }

+void dce4_wait_for_vblank(struct radeon_device *rdev, int crtc)
+{
+   struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc];
+   int i;
+
+   if (RREG32(EVERGREEN_CRTC_CONTROL + radeon_crtc->crtc_offset) & 
EVERGREEN_CRTC_MASTER_EN) {
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (!(RREG32(EVERGREEN_CRTC_STATUS + 
radeon_crtc->crtc_offset) & EVERGREEN_CRTC_V_BLANK))
+   break;
+   udelay(1);
+   }
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (RREG32(EVERGREEN_CRTC_STATUS + 
radeon_crtc->crtc_offset) & EVERGREEN_CRTC_V_BLANK)
+   break;
+   udelay(1);
+   }
+   }
+}
+
 void evergreen_pre_page_flip(struct radeon_device *rdev, int crtc)
 {
/* enable the pflip int */
diff --git a/drivers/gpu/drm/radeon/evergreen_reg.h 
b/drivers/gpu/drm/radeon/evergreen_reg.h
index 4215de9..96c10b3 100644
--- a/drivers/gpu/drm/radeon/evergreen_reg.h
+++ b/drivers/gpu/drm/radeon/evergreen_reg.h
@@ -219,6 +219,7 @@
 #   define EVERGREEN_CRTC_MASTER_EN (1 << 0)
 #   define EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE (1 << 24)
 #define EVERGREEN_CRTC_STATUS   0x6e8c
+#   define EVERGREEN_CRTC_V_BLANK   (1 << 0)
 #define EVERGREEN_CRTC_STATUS_POSITION  0x6e90
 #define EVERGREEN_MASTER_UPDATE_MODE0x6ef8
 #define EVERGREEN_CRTC_UPDATE_LOCK  0x6ed4
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 333cde9..bff612a 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -65,6 +65,40 @@ MODULE_FIRMWARE(FIRMWARE_R520);

 #include "r100_track.h"

+void r100_wait_for_vblank(struct radeon_device *rdev, int crtc)
+{
+   struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc];
+   int i;
+
+   if (radeon_crtc->crtc_id == 0) {
+   if (RREG32(RADEON_CRTC_GEN_CNTL) & RADEON_CRTC_EN) {
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (!(RREG32(RADEON_CRTC_STATUS) & 
RADEON_CRTC_VBLANK_CUR))
+   break;
+   udelay(1);
+   }
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (RREG32(RADEON_CRTC_STATUS) & 
RADEON_CRTC_VBLANK_CUR)
+   break;
+   udelay(1);
+   }
+   }
+   } else {
+   if (RREG32(RADEON_CRTC2_GEN_CNTL) & RADEON_CRTC2_EN) {
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (!(RREG32(RADEON_CRTC2_STATUS) & 
RADEON_CRTC2_VBLANK_CUR))
+   break;
+   udelay(1);
+   }
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (RREG32(RADEON_CRTC2_STATUS) & 
RADEON_CRTC2_VBLANK_CUR)
+   break;
+   udelay(1);
+   }
+   }
+   }
+}
+
 /* This files gather functions specifics to:
  * r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280
  */
diff --git a/drivers/gpu/drm/radeon/r500_reg.h 
b/drivers/gpu/drm/radeon/r500_reg.h
index 3bd8f1b..ec576aa 100644
--- a/drivers/gpu/drm/radeon/r500_reg.h
+++ b/drivers/gpu/drm/radeon/r500_reg.h
@@ -351,6 +351,8 @@
 #define AVIVO_D1CRTC_BLANK_CONTROL  0x6084
 #define AVIVO_D1CRTC_INTERLACE_CONTROL  0x6088
 #define AVIVO_D1CRTC_INTERLACE_STATUS   0x608c
+#define AVIVO_D1CRTC_STATUS 0x609c
+#   define AVIVO_D1CRTC_V_BLANK (

[drm-next 00/14] radeon_asic cleanups for drm-next

2012-02-23 Thread alexdeuc...@gmail.com
From: Alex Deucher 

This patch set cleans up radeon_asic and organizes the asic
specific callbacks based on their function.  Not change in
functionality.  It requires Christian's patch:
"drm/radeon: also make the cs_parse function per ring"

Alex Deucher (14):
  drm/radeon/kms: add wait_for_vblank asic callback
  drm/radeon/kms: add a radeon asic callback for mc idle
  drm/radeon/kms: reorganize hpd callbacks
  drm/radeon/kms: reorganize page flip callbacks
  drm/radeon/kms: reorganize pm callbacks
  drm/radeon/kms: reorganize copy callbacks
  drm/radeon/kms: reorganize irq callbacks
  drm/radeon/kms: remove unused cp callbacks from radeon_asic
  drm/radeon/kms: make ring_start, ring_test, and ib_test per ring
  drm/radeon/kms: reorganize gart callbacks
  drm/radeon/kms: reorganize display callbacks
  drm/radeon/kms: move clock/pcie setting callbacks into pm struct
  drm/radeon/kms: reorganize surface callbacks
  drm/radeon/kms: clean up radeon_asic struct

 drivers/gpu/drm/radeon/evergreen.c|   25 +-
 drivers/gpu/drm/radeon/evergreen_reg.h|1 +
 drivers/gpu/drm/radeon/ni.c   |6 +-
 drivers/gpu/drm/radeon/r100.c |   51 +-
 drivers/gpu/drm/radeon/r300.c |9 +-
 drivers/gpu/drm/radeon/r420.c |2 +-
 drivers/gpu/drm/radeon/r500_reg.h |2 +
 drivers/gpu/drm/radeon/r520.c |4 +-
 drivers/gpu/drm/radeon/r600.c |   11 +-
 drivers/gpu/drm/radeon/radeon.h   |  222 +++--
 drivers/gpu/drm/radeon/radeon_asic.c  | 1541 ++---
 drivers/gpu/drm/radeon/radeon_asic.h  |   24 +-
 drivers/gpu/drm/radeon/radeon_benchmark.c |   12 +-
 drivers/gpu/drm/radeon/radeon_clocks.c|2 +-
 drivers/gpu/drm/radeon/radeon_pm.c|6 +-
 drivers/gpu/drm/radeon/radeon_reg.h   |2 +
 drivers/gpu/drm/radeon/radeon_ttm.c   |   15 +-
 drivers/gpu/drm/radeon/rs400.c|2 +-
 drivers/gpu/drm/radeon/rs600.c|   23 +-
 drivers/gpu/drm/radeon/rs690.c|4 +-
 drivers/gpu/drm/radeon/rv515.c|5 +-
 drivers/gpu/drm/radeon/rv770.c|4 +-
 22 files changed, 1236 insertions(+), 737 deletions(-)

-- 
1.7.7.5



[Bug 21582] Build failure if NOUVEAU && !HWMON

2012-02-23 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=21582


Guenter Roeck  changed:

   What|Removed |Added

 AssignedTo|drivers_video-dri at kernel-bu |linux at roeck-us.net
   |gs.osdl.org |




-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.


Re: 3.3-rc4+: Reported regressions from 3.2

2012-02-23 Thread Rafael J. Wysocki
On Friday, February 24, 2012, David Miller wrote:
> From: "Rafael J. Wysocki" 
> Date: Thu, 23 Feb 2012 23:51:20 +0100 (CET)
> 
> > Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42776
> > Subject : OF-related boot crash in 3.3.0-rc3-00188-g3ec1e88
> > Submitter   : Meelis Roos 
> > Date: 2012-02-13 7:45 (11 days old)
> > Message-ID  : 
> > References  : http://marc.info/?l=linux-kernel&m=132911916331615&w=2
> 
> Potential workaround/fix at:
> 
> http://marc.info/?l=linux-kernel&m=132993294018762&w=2

Thanks, updated.

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


3.3-rc4+: Reported regressions from 3.2

2012-02-23 Thread Rafael J. Wysocki
Hi all,

We definitely aren't 100% in business yet with the tracking of regressions,
but since the Bugzilla is operational again, we can collect reports at least.

I'd like to use this opportunity to thank Maciej Rutecki and Florian Mickler
for their hard work on the regression tracking and to clarify some things that
seem to have caused some confusion to happen recently.  Namely, we use the
kernel Bugzilla (https://bugzilla.kernel.org) for the tracking of regressions
for the simple reason that our scripts generate the lists that are posted
(like the one below) out of Bugzilla entries created by us (and sometimes
by other people).  Those entries are used by us as a storage of information,
so we're going to add them even though some kernel developers don't seem to
like that.  We don't require developers to actually use those entries for
handling bug reports, we only need people to let us know when they should be
closed, because the bug has been fixed in the Linus' tree, or when there's
a patch available for the bug (in which case we mark it as "resolved", but
we don't close it just yet).  There is no reason for you to be openly hostile
to Maciej, who's been creating those entries recently, because he's just been
doing his job.  However, you may not want us to track kernel regressions at
all, in which case please let us know about that and we will find some other,
presumably equally interesting things to do. :-)

Yes, we might have been more verbose about what _exactly_ we've been using the
Bugzilla for and what our workflow is, but at the same time people might have
been a bit less harsh to someone who's been doing a service to the community,
completely voluntarily.

Thanks,
Rafael

---

This message contains a list of some regressions from 3.2,
for which there are no fixes in the mainline known to the tracking team.
If any of them have been fixed already, please let us know.

If you know of any other unresolved regressions from 3.2, please let us
know either and we'll add them to the list.  Also, please let us know
if any of the entries below are invalid.

Each entry from the list will be sent additionally in an automatic reply
to this message with CCs to the people involved in reporting and handling
the issue.


Listed regressions statistics:

  Date  Total  Pending  Unresolved
  
  2012-02-23   15   13  13


Unresolved regressions
--

Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42798
Subject : i915 regression with 3.3-rc3+git
Submitter   : Riccardo Magliocchetti 
Date: 2012-02-17 20:48 (7 days old)
Message-ID  : <4f3ebd0d.7000...@gmail.com>
References  : http://marc.info/?l=linux-kernel&m=132951173002619&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42776
Subject : OF-related boot crash in 3.3.0-rc3-00188-g3ec1e88
Submitter   : Meelis Roos 
Date: 2012-02-13 7:45 (11 days old)
Message-ID  : 
References  : http://marc.info/?l=linux-kernel&m=132911916331615&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42761
Subject : Possible circular locking dependency (3.3-rc2)
Submitter   : Felipe Balbi 
Date: 2012-02-08 12:41 (16 days old)
Message-ID  : <20120208124147.gf16...@legolas.emea.dhcp.ti.com>
References  : http://marc.info/?l=linux-kernel&m=132870492311858&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42746
Subject : 3.3-rc2 snd_pcm lockdep backtrace
Submitter   : Josh Boyer 
Date: 2012-02-06 14:56 (18 days old)
Message-ID  : <20120206145621.ga4...@zod.bos.redhat.com>
References  : http://marc.info/?l=linux-kernel&m=132854040916172&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42735
Subject : kobject (88003ffbb4b8): tried to init an initialized 
object, something is seriously wrong.
Submitter   : Konrad Rzeszutek Wilk 
Date: 2012-02-03 20:59 (21 days old)
Message-ID  : <20120203205953.ga2...@phenom.dumpdata.com>
References  : http://marc.info/?l=linux-kernel&m=132830315526901&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42734
Subject : dosemu graphics broken in v3.3-rc1
Submitter   : Hans de Bruin 
Date: 2012-02-02 22:25 (22 days old)
First-Bad-Commit: 
http://git.kernel.org/linus/308e5bcbdb10452e8aba31aa21432fb67ee46d72
Message-ID  : <4f2b0d4d.3000...@xmsnet.nl>
References  : http://marc.info/?l=linux-kernel&m=132825899111982&w=2
Handled-By  : Jesse Barnes 


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42733
Subject : Regression 3.2 -> 3.3-rc1 10 sec hang at boot and resume, 
COMRESET failed
Submitter   : Norbert Preining 
Date: 2012-02-02 5:12 (22 days old)
Message-ID  : <20120202051258.ga15...@gamma.logic.tuwien.ac.at>
References  : http://marc.info/?l=linux-

3.3-rc4+: Reported regressions 3.1 -> 3.2

2012-02-23 Thread Rafael J. Wysocki
This message contains a list of some post-3.1 regressions introduced before
3.2, for which there are no fixes in the mainline known to the tracking team.
If any of them have been fixed already, please let us know.

If you know of any other unresolved post-3.1 regressions, please let us know
either and we'll add them to the list.  Also, please let us know if any
of the entries below are invalid.

Each entry from the list will be sent additionally in an automatic reply to
this message with CCs to the people involved in reporting and handling the
issue.


Listed regressions statistics:

  Date  Total  Pending  Unresolved
  
  2012-02-2498   7


Unresolved regressions
--

Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42714
Subject : 3.2.x Regression for SAS Controller on Dell C6100
Submitter   : Herbert Poetzl 
Date: 2012-01-31 18:09 (24 days old)
Message-ID  : <20120131180949.gt29...@mail.13thfloor.at>
References  : http://marc.info/?l=linux-kernel&m=132803360019481&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42685
Subject : multi-media key "mute" no longer recognized
Submitter   : Toralf Förster 
Date: 2012-01-23 10:52 (32 days old)
Message-ID  : <201201231152.25344.toralf.foers...@gmx.de>
References  : http://marc.info/?l=linux-kernel&m=132731613606121&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42684
Subject : FYIO: usb/video 3.2 breaks logitech 9000pro webcam focus 
control
Submitter   : M G Berberich 
Date: 2012-01-23 21:49 (32 days old)
Message-ID  : <20120123214934.GA4240@invalid>
References  : http://marc.info/?l=linux-kernel&m=132735609521443&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42631
Subject : Sound broken in 3.2.0 and 3.2.1
Submitter   : Joseph Parmelee 
Date: 2012-01-13 19:44 (42 days old)
Message-ID  : 
References  : http://marc.info/?l=linux-kernel&m=132648462806235&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42629
Subject : recvmsg sleeping from invalid context
Submitter   : Dave Jones 
Date: 2012-01-13 18:24 (42 days old)
Message-ID  : <20120113182401.ga25...@redhat.com>
References  : http://marc.info/?l=linux-kernel&m=132647921304184&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42611
Subject : kernel 3.2 crashes too early on HP dc7700 and HP t5000 series
Submitter   : Dmitry D. Khlebnikov 
Date: 2012-01-10 11:49 (45 days old)
Message-ID  : <20120110114905.gc13...@openwall.com>
References  : http://marc.info/?l=linux-kernel&m=132619793012702&w=2


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42610
Subject : 3.2.0 reboot powers off machine
Submitter   : Tom Weber 
Date: 2012-01-11 11:03 (44 days old)
Message-ID  : <1326279818.24835.12.camel@utumno>
References  : http://marc.info/?l=linux-kernel&m=132628059308023&w=2


Regressions with patches


Bug-Entry   : http://bugzilla.kernel.org/show_bug.cgi?id=42571
Subject : BUG in ofcs2_change_file_space
Submitter   : Bret Towe 
Date: 2012-01-05 22:23 (50 days old)
Message-ID  : 

References  : http://marc.info/?l=linux-kernel&m=132580236211209&w=2
Patch   : 
http://oss.oracle.com/pipermail/ocfs2-devel/2012-January/008464.html


For details, please visit the bug entries and follow the links given in
references.

As you can see, there is a Bugzilla entry for each of the listed regressions.
There also is a Bugzilla entry used for tracking the regressions introduced
between 3.1 and 3.2, unresolved as well as resolved, at:

http://bugzilla.kernel.org/show_bug.cgi?id=42566

Please let the tracking team know if there are any Bugzilla entries that
should be added to the list in there.

Thanks!

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


[PATCH 4/4] drm/radeon: fix IB debugfs files for multiple cards

2012-02-23 Thread Christian König
Storing pointers to the IBs in a static var just
leads to giving the same content back for all
cards in the system.

Signed-off-by: Christian K?nig 
---
 drivers/gpu/drm/radeon/radeon_ring.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ring.c 
b/drivers/gpu/drm/radeon/radeon_ring.c
index 30a4c50..32c83d8 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -478,7 +478,9 @@ static struct drm_info_list radeon_debugfs_ring_info_list[] 
= {
 static int radeon_debugfs_ib_info(struct seq_file *m, void *data)
 {
struct drm_info_node *node = (struct drm_info_node *) m->private;
-   struct radeon_ib *ib = node->info_ent->data;
+   struct drm_device *dev = node->minor->dev;
+   struct radeon_device *rdev = dev->dev_private;
+   struct radeon_ib *ib = 
&rdev->ib_pool.ibs[*((unsigned*)node->info_ent->data)];
unsigned i;

if (ib == NULL) {
@@ -495,6 +497,7 @@ static int radeon_debugfs_ib_info(struct seq_file *m, void 
*data)

 static struct drm_info_list radeon_debugfs_ib_list[RADEON_IB_POOL_SIZE];
 static char radeon_debugfs_ib_names[RADEON_IB_POOL_SIZE][32];
+static unsigned radeon_debugfs_ib_idx[RADEON_IB_POOL_SIZE];
 #endif

 int radeon_debugfs_ring_init(struct radeon_device *rdev)
@@ -514,10 +517,11 @@ int radeon_debugfs_ib_init(struct radeon_device *rdev)

for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
sprintf(radeon_debugfs_ib_names[i], "radeon_ib_%04u", i);
+   radeon_debugfs_ib_idx[i] = i;
radeon_debugfs_ib_list[i].name = radeon_debugfs_ib_names[i];
radeon_debugfs_ib_list[i].show = &radeon_debugfs_ib_info;
radeon_debugfs_ib_list[i].driver_features = 0;
-   radeon_debugfs_ib_list[i].data = &rdev->ib_pool.ibs[i];
+   radeon_debugfs_ib_list[i].data = &radeon_debugfs_ib_idx[i];
}
return radeon_debugfs_add_files(rdev, radeon_debugfs_ib_list,
RADEON_IB_POOL_SIZE);
-- 
1.7.5.4



[PATCH 3/4] drm/radeon: also make the cs_parse function per ring

2012-02-23 Thread Christian König
Not all rings use PM4, so the cs_parser also needs to be per ring.

Signed-off-by: Christian K?nig 
---
 drivers/gpu/drm/radeon/radeon.h  |4 +-
 drivers/gpu/drm/radeon/radeon_asic.c |   38 +
 drivers/gpu/drm/radeon/radeon_cs.c   |2 +-
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 4c1b981..ca98772 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1147,13 +1147,13 @@ struct radeon_asic {
void (*emit_fence)(struct radeon_device *rdev, struct 
radeon_fence *fence);
void (*emit_semaphore)(struct radeon_device *rdev, struct 
radeon_ring *cp,
   struct radeon_semaphore *semaphore, bool 
emit_wait);
+   int (*cs_parse)(struct radeon_cs_parser *p);
} ring[RADEON_NUM_RINGS];

int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
int (*irq_set)(struct radeon_device *rdev);
int (*irq_process)(struct radeon_device *rdev);
u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
-   int (*cs_parse)(struct radeon_cs_parser *p);
int (*copy_blit)(struct radeon_device *rdev,
 uint64_t src_offset,
 uint64_t dst_offset,
@@ -1650,7 +1650,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
 #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
 #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
-#define radeon_cs_parse(p) rdev->asic->cs_parse((p))
+#define radeon_cs_parse(rdev, r, p) (rdev)->asic->ring[(r)].cs_parse((p))
 #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), 
(state))
 #define radeon_gpu_is_lockup(rdev, cp) (rdev)->asic->gpu_is_lockup((rdev), 
(cp))
 #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 36a6192..636c68f 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -145,12 +145,12 @@ static struct radeon_asic r100_asic = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r100_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r100_cs_parse,
}
},
.irq_set = &r100_irq_set,
.irq_process = &r100_irq_process,
.get_vblank_counter = &r100_get_vblank_counter,
-   .cs_parse = &r100_cs_parse,
.copy_blit = &r100_copy_blit,
.copy_dma = NULL,
.copy = &r100_copy_blit,
@@ -197,12 +197,12 @@ static struct radeon_asic r200_asic = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r100_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r100_cs_parse,
}
},
.irq_set = &r100_irq_set,
.irq_process = &r100_irq_process,
.get_vblank_counter = &r100_get_vblank_counter,
-   .cs_parse = &r100_cs_parse,
.copy_blit = &r100_copy_blit,
.copy_dma = &r200_copy_dma,
.copy = &r100_copy_blit,
@@ -248,12 +248,12 @@ static struct radeon_asic r300_asic = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r300_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r300_cs_parse,
}
},
.irq_set = &r100_irq_set,
.irq_process = &r100_irq_process,
.get_vblank_counter = &r100_get_vblank_counter,
-   .cs_parse = &r300_cs_parse,
.copy_blit = &r100_copy_blit,
.copy_dma = &r200_copy_dma,
.copy = &r100_copy_blit,
@@ -300,12 +300,12 @@ static struct radeon_asic r300_asic_pcie = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r300_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r300_cs_parse,
}
},
.irq_set = &r100_irq_set,
.irq_process = &r100_irq_process,
.get_vblank_counter = &r100_get_vblank_counter,
-   .cs_parse = &r300_cs_parse,
.copy_blit = &r100_copy_blit,
.copy_dma = &r200_copy_dma,
.copy = &r100_copy_blit,
@@ -351,12 +351,12 @@ static struct radeon_asic r420_asic = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r300_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r300_cs_parse,
}
},
.ir

[PATCH 2/4] drm/radeon/kms: no need to align IB like this

2012-02-23 Thread Christian König
So don't confuse devs by doing so.

Signed-off-by: Christian K?nig 
---
 drivers/gpu/drm/radeon/r600.c |   15 +--
 1 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 4f08e5e..4a4ac8f 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2719,20 +2719,7 @@ int r600_ib_test(struct radeon_device *rdev, int ring)
ib->ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1);
ib->ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
ib->ptr[2] = 0xDEADBEEF;
-   ib->ptr[3] = PACKET2(0);
-   ib->ptr[4] = PACKET2(0);
-   ib->ptr[5] = PACKET2(0);
-   ib->ptr[6] = PACKET2(0);
-   ib->ptr[7] = PACKET2(0);
-   ib->ptr[8] = PACKET2(0);
-   ib->ptr[9] = PACKET2(0);
-   ib->ptr[10] = PACKET2(0);
-   ib->ptr[11] = PACKET2(0);
-   ib->ptr[12] = PACKET2(0);
-   ib->ptr[13] = PACKET2(0);
-   ib->ptr[14] = PACKET2(0);
-   ib->ptr[15] = PACKET2(0);
-   ib->length_dw = 16;
+   ib->length_dw = 3;
r = radeon_ib_schedule(rdev, ib);
if (r) {
radeon_scratch_free(rdev, scratch);
-- 
1.7.5.4



[PATCH 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Christian König
The function radeon_bo_list_validate can cause a
bo to move, resulting in a different sync_obj
and a dependency to wait for this move to finish.

Signed-off-by: Christian K?nig 
Reviewed-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h|1 -
 drivers/gpu/drm/radeon/radeon_cs.c |   21 ++---
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 884e0d4..4c1b981 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -836,7 +836,6 @@ struct radeon_cs_parser {
struct radeon_cs_reloc  *relocs;
struct radeon_cs_reloc  **relocs_ptr;
struct list_headvalidated;
-   boolsync_to_ring[RADEON_NUM_RINGS];
/* indices of various chunks */
int chunk_ib_idx;
int chunk_relocs_idx;
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c 
b/drivers/gpu/drm/radeon/radeon_cs.c
index 435a3d9..7fd0987 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -85,12 +85,6 @@ int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
radeon_bo_list_add_object(&p->relocs[i].lobj,
  &p->validated);

-   if (p->relocs[i].robj->tbo.sync_obj && !(r->flags & 
RADEON_RELOC_DONT_SYNC)) {
-   struct radeon_fence *fence = 
p->relocs[i].robj->tbo.sync_obj;
-   if (!radeon_fence_signaled(fence)) {
-   p->sync_to_ring[fence->ring] = true;
-   }
-   }
} else
p->relocs[i].handle = 0;
}
@@ -118,11 +112,24 @@ static int radeon_cs_get_ring(struct radeon_cs_parser *p, 
u32 ring, s32 priority

 static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
 {
+   bool sync_to_ring[RADEON_NUM_RINGS] = { };
int i, r;

+   for (i = 0; i < p->nrelocs; i++) {
+   if (!p->relocs[i].robj || !p->relocs[i].robj->tbo.sync_obj)
+   continue;
+
+   if (!(p->relocs[i].flags & RADEON_RELOC_DONT_SYNC)) {
+   struct radeon_fence *fence = 
p->relocs[i].robj->tbo.sync_obj;
+   if (!radeon_fence_signaled(fence)) {
+   sync_to_ring[fence->ring] = true;
+   }
+   }
+   }
+
for (i = 0; i < RADEON_NUM_RINGS; ++i) {
/* no need to sync to our own or unused rings */
-   if (i == p->ring || !p->sync_to_ring[i] || 
!p->rdev->ring[i].ready)
+   if (i == p->ring || !sync_to_ring[i] || !p->rdev->ring[i].ready)
continue;

if (!p->ib->fence->semaphore) {
-- 
1.7.5.4



[drm-next 14/14] drm/radeon/kms: clean up radeon_asic struct (v2)

2012-02-23 Thread alexdeucher
From: Alex Deucher 

v2: fix typo.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   38 ++---
 drivers/gpu/drm/radeon/radeon_asic.c |  102 +-
 2 files changed, 69 insertions(+), 71 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 5077478..be3683f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1131,12 +1131,23 @@ struct radeon_asic {
void (*vga_set_state)(struct radeon_device *rdev, bool state);
bool (*gpu_is_lockup)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*asic_reset)(struct radeon_device *rdev);
-
+   /* ioctl hw specific callback. Some hw might want to perform special
+* operation on specific ioctl. For instance on wait idle some hw
+* might want to perform and HDP flush through MMIO as it seems that
+* some R6XX/R7XX hw doesn't take HDP flush into account if programmed
+* through ring.
+*/
+   void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
+   /* check if 3D engine is idle */
+   bool (*gui_idle)(struct radeon_device *rdev);
+   /* wait for mc_idle */
+   int (*mc_wait_for_idle)(struct radeon_device *rdev);
+   /* gart */
struct {
void (*tlb_flush)(struct radeon_device *rdev);
int (*set_page)(struct radeon_device *rdev, int i, uint64_t 
addr);
} gart;
-
+   /* ring specific callbacks */
struct {
void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib 
*ib);
int (*ib_parse)(struct radeon_device *rdev, struct radeon_ib 
*ib);
@@ -1148,12 +1159,12 @@ struct radeon_asic {
int (*ring_test)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*ib_test)(struct radeon_device *rdev, struct radeon_ring 
*cp);
} ring[RADEON_NUM_RINGS];
-
+   /* irqs */
struct {
int (*set)(struct radeon_device *rdev);
int (*process)(struct radeon_device *rdev);
} irq;
-
+   /* displays */
struct {
/* display watermarks */
void (*bandwidth_update)(struct radeon_device *rdev);
@@ -1162,7 +1173,7 @@ struct radeon_asic {
/* wait for vblank */
void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
} display;
-
+   /* copy functions for bo handling */
struct {
int (*blit)(struct radeon_device *rdev,
uint64_t src_offset,
@@ -1185,30 +1196,20 @@ struct radeon_asic {
/* ring used for bo copies */
u32 copy_ring_index;
} copy;
-
+   /* surfaces */
struct {
int (*set_reg)(struct radeon_device *rdev, int reg,
   uint32_t tiling_flags, uint32_t pitch,
   uint32_t offset, uint32_t obj_size);
void (*clear_reg)(struct radeon_device *rdev, int reg);
} surface;
-
+   /* hotplug detect */
struct {
void (*init)(struct radeon_device *rdev);
void (*fini)(struct radeon_device *rdev);
bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id 
hpd);
void (*set_polarity)(struct radeon_device *rdev, enum 
radeon_hpd_id hpd);
} hpd;
-
-   /* ioctl hw specific callback. Some hw might want to perform special
-* operation on specific ioctl. For instance on wait idle some hw
-* might want to perform and HDP flush through MMIO as it seems that
-* some R6XX/R7XX hw doesn't take HDP flush into account if programmed
-* through ring.
-*/
-   void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
-   /* check if 3D engine is idle */
-   bool (*gui_idle)(struct radeon_device *rdev);
/* power management */
struct {
void (*misc)(struct radeon_device *rdev);
@@ -1230,9 +1231,6 @@ struct radeon_asic {
u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 
crtc_base);
void (*post_page_flip)(struct radeon_device *rdev, int crtc);
} pflip;
-
-   /* wait for mc_idle */
-   int (*mc_wait_for_idle)(struct radeon_device *rdev);
 };
 
 /*
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 0a59f48..479c89e 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -136,6 +136,9 @@ static struct radeon_asic r100_asic = {
.vga_set_state = &r100_vga_set_state,
.gpu_is_lockup = &r100_gpu_is_lockup,
.asic_reset = &r100_asic_reset,
+   .ioctl_wait_idle = NULL,
+   .gui_idle = &r100_gui_idle,
+   .mc_wait_for_idle = &r100_mc_wait_for_idle,

Re: [Linaro-mm-sig] [PATCH 6/7] drm/vgem: import support

2012-02-23 Thread Chris Wilson
On Wed, 22 Feb 2012 20:29:19 +0100, Ben Widawsky  wrote:
> + mutex_lock(&dev->prime_mutex);
> + /* First check that we don't dup on this file */
> + ret = drm_prime_lookup_fd_handle_mapping(&file_priv->prime, dma_buf,
> +  handle);

The other example of importing bo we have already in GEM is through the
use of flink and global names. There we create a new handle every time a
process opens a name, and de-duplication is indeed handled in userspace
if it so desires.

Multiple handles pointing to the same object simplifies the code without
risking kernel integrity, so why bother with kernel de-dupe? And allow
userspace the extra bit of freedom to shoot itself in the foot!
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[drm-next 14/14] drm/radeon/kms: clean up radeon_asic struct

2012-02-23 Thread alexdeucher
From: Alex Deucher 

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   38 ++---
 drivers/gpu/drm/radeon/radeon_asic.c |  100 +-
 2 files changed, 68 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 5077478..be3683f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1131,12 +1131,23 @@ struct radeon_asic {
void (*vga_set_state)(struct radeon_device *rdev, bool state);
bool (*gpu_is_lockup)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*asic_reset)(struct radeon_device *rdev);
-
+   /* ioctl hw specific callback. Some hw might want to perform special
+* operation on specific ioctl. For instance on wait idle some hw
+* might want to perform and HDP flush through MMIO as it seems that
+* some R6XX/R7XX hw doesn't take HDP flush into account if programmed
+* through ring.
+*/
+   void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
+   /* check if 3D engine is idle */
+   bool (*gui_idle)(struct radeon_device *rdev);
+   /* wait for mc_idle */
+   int (*mc_wait_for_idle)(struct radeon_device *rdev);
+   /* gart */
struct {
void (*tlb_flush)(struct radeon_device *rdev);
int (*set_page)(struct radeon_device *rdev, int i, uint64_t 
addr);
} gart;
-
+   /* ring specific callbacks */
struct {
void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib 
*ib);
int (*ib_parse)(struct radeon_device *rdev, struct radeon_ib 
*ib);
@@ -1148,12 +1159,12 @@ struct radeon_asic {
int (*ring_test)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*ib_test)(struct radeon_device *rdev, struct radeon_ring 
*cp);
} ring[RADEON_NUM_RINGS];
-
+   /* irqs */
struct {
int (*set)(struct radeon_device *rdev);
int (*process)(struct radeon_device *rdev);
} irq;
-
+   /* displays */
struct {
/* display watermarks */
void (*bandwidth_update)(struct radeon_device *rdev);
@@ -1162,7 +1173,7 @@ struct radeon_asic {
/* wait for vblank */
void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
} display;
-
+   /* copy functions for bo handling */
struct {
int (*blit)(struct radeon_device *rdev,
uint64_t src_offset,
@@ -1185,30 +1196,20 @@ struct radeon_asic {
/* ring used for bo copies */
u32 copy_ring_index;
} copy;
-
+   /* surfaces */
struct {
int (*set_reg)(struct radeon_device *rdev, int reg,
   uint32_t tiling_flags, uint32_t pitch,
   uint32_t offset, uint32_t obj_size);
void (*clear_reg)(struct radeon_device *rdev, int reg);
} surface;
-
+   /* hotplug detect */
struct {
void (*init)(struct radeon_device *rdev);
void (*fini)(struct radeon_device *rdev);
bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id 
hpd);
void (*set_polarity)(struct radeon_device *rdev, enum 
radeon_hpd_id hpd);
} hpd;
-
-   /* ioctl hw specific callback. Some hw might want to perform special
-* operation on specific ioctl. For instance on wait idle some hw
-* might want to perform and HDP flush through MMIO as it seems that
-* some R6XX/R7XX hw doesn't take HDP flush into account if programmed
-* through ring.
-*/
-   void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
-   /* check if 3D engine is idle */
-   bool (*gui_idle)(struct radeon_device *rdev);
/* power management */
struct {
void (*misc)(struct radeon_device *rdev);
@@ -1230,9 +1231,6 @@ struct radeon_asic {
u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 
crtc_base);
void (*post_page_flip)(struct radeon_device *rdev, int crtc);
} pflip;
-
-   /* wait for mc_idle */
-   int (*mc_wait_for_idle)(struct radeon_device *rdev);
 };
 
 /*
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 0a59f48..a592ca5 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -136,6 +136,9 @@ static struct radeon_asic r100_asic = {
.vga_set_state = &r100_vga_set_state,
.gpu_is_lockup = &r100_gpu_is_lockup,
.asic_reset = &r100_asic_reset,
+   .ioctl_wait_idle = NULL,
+   .gui_idle = &r100_gui_idle,
+   .mc_wait_for_idle = &r100_mc_wait_for_idle,
.gart =

[drm-next 13/14] drm/radeon/kms: reorganize surface callbacks

2012-02-23 Thread alexdeucher
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   14 +++--
 drivers/gpu/drm/radeon/radeon_asic.c |  103 ++
 2 files changed, 76 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 88dacc5..5077478 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1186,10 +1186,12 @@ struct radeon_asic {
u32 copy_ring_index;
} copy;
 
-   int (*set_surface_reg)(struct radeon_device *rdev, int reg,
-  uint32_t tiling_flags, uint32_t pitch,
-  uint32_t offset, uint32_t obj_size);
-   void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
+   struct {
+   int (*set_reg)(struct radeon_device *rdev, int reg,
+  uint32_t tiling_flags, uint32_t pitch,
+  uint32_t offset, uint32_t obj_size);
+   void (*clear_reg)(struct radeon_device *rdev, int reg);
+   } surface;
 
struct {
void (*init)(struct radeon_device *rdev);
@@ -1705,8 +1707,8 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_get_pcie_lanes(rdev) (rdev)->asic->pm.get_pcie_lanes((rdev))
 #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), 
(l))
 #define radeon_set_clock_gating(rdev, e) 
(rdev)->asic->pm.set_clock_gating((rdev), (e))
-#define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
-#define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->clear_surface_reg((rdev), (r)))
+#define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
+#define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->surface.clear_reg((rdev), (r)))
 #define radeon_bandwidth_update(rdev) 
(rdev)->asic->display.bandwidth_update((rdev))
 #define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
 #define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 4eaa5f1..0a59f48 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -168,8 +168,10 @@ static struct radeon_asic r100_asic = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -240,8 +242,10 @@ static struct radeon_asic r200_asic = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -312,8 +316,10 @@ static struct radeon_asic r300_asic = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -384,8 +390,10 @@ static struct radeon_asic r300_asic_pcie = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -456,9 +464,10 @@ static struct radeon_asic r420_asic = {
.copy = &r100_copy_blit,
.copy_ring_index = RADEON_RING_TYPE_GFX_INDEX,
},
-   .set_surface_reg = r100_set_surface_reg,
-   .clear_surface_reg = r100_clear_surface_reg,
-
+   .surface = {
+   .set_reg = r100_set_surface_reg,
+   .clear_reg = r100_clear_surface_reg,
+   },
.hpd = {
.init = &r100_hpd_init,
.fini = &r100_hpd_fini,
@@ -529,8 +538,10 @@ static str

[drm-next 12/14] drm/radeon/kms: move clock/pcie setting callbacks into pm struct

2012-02-23 Thread alexdeucher
From: Alex Deucher 

tidy up radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/r100.c  |2 +-
 drivers/gpu/drm/radeon/radeon.h|   28 ++--
 drivers/gpu/drm/radeon/radeon_asic.c   |  248 
 drivers/gpu/drm/radeon/radeon_clocks.c |2 +-
 drivers/gpu/drm/radeon/radeon_pm.c |6 +-
 drivers/gpu/drm/radeon/rs600.c |2 +-
 6 files changed, 145 insertions(+), 143 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 8eb1421..42ae955 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -446,7 +446,7 @@ void r100_pm_misc(struct radeon_device *rdev)
/* set pcie lanes */
if ((rdev->flags & RADEON_IS_PCIE) &&
!(rdev->flags & RADEON_IS_IGP) &&
-   rdev->asic->set_pcie_lanes &&
+   rdev->asic->pm.set_pcie_lanes &&
(ps->pcie_lanes !=
 
rdev->pm.power_state[rdev->pm.current_power_state_index].pcie_lanes)) {
radeon_set_pcie_lanes(rdev,
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 0e75a05..88dacc5 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1186,13 +1186,6 @@ struct radeon_asic {
u32 copy_ring_index;
} copy;
 
-   uint32_t (*get_engine_clock)(struct radeon_device *rdev);
-   void (*set_engine_clock)(struct radeon_device *rdev, uint32_t 
eng_clock);
-   uint32_t (*get_memory_clock)(struct radeon_device *rdev);
-   void (*set_memory_clock)(struct radeon_device *rdev, uint32_t 
mem_clock);
-   int (*get_pcie_lanes)(struct radeon_device *rdev);
-   void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
-   void (*set_clock_gating)(struct radeon_device *rdev, int enable);
int (*set_surface_reg)(struct radeon_device *rdev, int reg,
   uint32_t tiling_flags, uint32_t pitch,
   uint32_t offset, uint32_t obj_size);
@@ -1221,6 +1214,13 @@ struct radeon_asic {
void (*finish)(struct radeon_device *rdev);
void (*init_profile)(struct radeon_device *rdev);
void (*get_dynpm_state)(struct radeon_device *rdev);
+   uint32_t (*get_engine_clock)(struct radeon_device *rdev);
+   void (*set_engine_clock)(struct radeon_device *rdev, uint32_t 
eng_clock);
+   uint32_t (*get_memory_clock)(struct radeon_device *rdev);
+   void (*set_memory_clock)(struct radeon_device *rdev, uint32_t 
mem_clock);
+   int (*get_pcie_lanes)(struct radeon_device *rdev);
+   void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
+   void (*set_clock_gating)(struct radeon_device *rdev, int 
enable);
} pm;
/* pageflipping */
struct {
@@ -1698,13 +1698,13 @@ void radeon_ring_write(struct radeon_ring *ring, 
uint32_t v);
 #define radeon_copy_blit_ring_index(rdev) (rdev)->asic->copy.blit_ring_index
 #define radeon_copy_dma_ring_index(rdev) (rdev)->asic->copy.dma_ring_index
 #define radeon_copy_ring_index(rdev) (rdev)->asic->copy.copy_ring_index
-#define radeon_get_engine_clock(rdev) (rdev)->asic->get_engine_clock((rdev))
-#define radeon_set_engine_clock(rdev, e) 
(rdev)->asic->set_engine_clock((rdev), (e))
-#define radeon_get_memory_clock(rdev) (rdev)->asic->get_memory_clock((rdev))
-#define radeon_set_memory_clock(rdev, e) 
(rdev)->asic->set_memory_clock((rdev), (e))
-#define radeon_get_pcie_lanes(rdev) (rdev)->asic->get_pcie_lanes((rdev))
-#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->set_pcie_lanes((rdev), 
(l))
-#define radeon_set_clock_gating(rdev, e) 
(rdev)->asic->set_clock_gating((rdev), (e))
+#define radeon_get_engine_clock(rdev) (rdev)->asic->pm.get_engine_clock((rdev))
+#define radeon_set_engine_clock(rdev, e) 
(rdev)->asic->pm.set_engine_clock((rdev), (e))
+#define radeon_get_memory_clock(rdev) (rdev)->asic->pm.get_memory_clock((rdev))
+#define radeon_set_memory_clock(rdev, e) 
(rdev)->asic->pm.set_memory_clock((rdev), (e))
+#define radeon_get_pcie_lanes(rdev) (rdev)->asic->pm.get_pcie_lanes((rdev))
+#define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), 
(l))
+#define radeon_set_clock_gating(rdev, e) 
(rdev)->asic->pm.set_clock_gating((rdev), (e))
 #define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
 #define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->clear_surface_reg((rdev), (r)))
 #define radeon_bandwidth_update(rdev) 
(rdev)->asic->display.bandwidth_update((rdev))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 01ea642..4eaa5f1 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -168,13 +168,6 @@ static struct radeon_asic r100_asic = {
.copy 

[drm-next 11/14] drm/radeon/kms: reorganize display callbacks

2012-02-23 Thread alexdeucher
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   19 +++--
 drivers/gpu/drm/radeon/radeon_asic.c |  137 +-
 2 files changed, 98 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 732582f..0e75a05 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1154,7 +1154,14 @@ struct radeon_asic {
int (*process)(struct radeon_device *rdev);
} irq;
 
-   u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
+   struct {
+   /* display watermarks */
+   void (*bandwidth_update)(struct radeon_device *rdev);
+   /* get frame count */
+   u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
+   /* wait for vblank */
+   void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
+   } display;
 
struct {
int (*blit)(struct radeon_device *rdev,
@@ -1190,7 +1197,6 @@ struct radeon_asic {
   uint32_t tiling_flags, uint32_t pitch,
   uint32_t offset, uint32_t obj_size);
void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
-   void (*bandwidth_update)(struct radeon_device *rdev);
 
struct {
void (*init)(struct radeon_device *rdev);
@@ -1222,8 +1228,7 @@ struct radeon_asic {
u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 
crtc_base);
void (*post_page_flip)(struct radeon_device *rdev, int crtc);
} pflip;
-   /* wait for vblank */
-   void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
+
/* wait for mc_idle */
int (*mc_wait_for_idle)(struct radeon_device *rdev);
 };
@@ -1684,7 +1689,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_ring_ib_parse(rdev, r, ib) 
(rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
 #define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
 #define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
-#define radeon_get_vblank_counter(rdev, crtc) 
(rdev)->asic->get_vblank_counter((rdev), (crtc))
+#define radeon_get_vblank_counter(rdev, crtc) 
(rdev)->asic->display.get_vblank_counter((rdev), (crtc))
 #define radeon_fence_ring_emit(rdev, r, fence) 
(rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
 #define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) 
(rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
 #define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy.blit((rdev), 
(s), (d), (np), (f))
@@ -1702,7 +1707,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_set_clock_gating(rdev, e) 
(rdev)->asic->set_clock_gating((rdev), (e))
 #define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
 #define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->clear_surface_reg((rdev), (r)))
-#define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
+#define radeon_bandwidth_update(rdev) 
(rdev)->asic->display.bandwidth_update((rdev))
 #define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
 #define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
 #define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
@@ -1716,7 +1721,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_pre_page_flip(rdev, crtc) 
rdev->asic->pflip.pre_page_flip((rdev), (crtc))
 #define radeon_page_flip(rdev, crtc, base) rdev->asic->pflip.page_flip((rdev), 
(crtc), (base))
 #define radeon_post_page_flip(rdev, crtc) 
rdev->asic->pflip.post_page_flip((rdev), (crtc))
-#define radeon_wait_for_vblank(rdev, crtc) rdev->asic->wait_for_vblank((rdev), 
(crtc))
+#define radeon_wait_for_vblank(rdev, crtc) 
rdev->asic->display.wait_for_vblank((rdev), (crtc))
 #define radeon_mc_wait_for_idle(rdev) rdev->asic->mc_wait_for_idle((rdev))
 
 /* Common functions */
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 1fd6e56..01ea642 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -155,7 +155,11 @@ static struct radeon_asic r100_asic = {
.set = &r100_irq_set,
.process = &r100_irq_process,
},
-   .get_vblank_counter = &r100_get_vblank_counter,
+   .display = {
+   .bandwidth_update = &r100_bandwidth_update,
+   .get_vblank_counter = &r100_get_vblank_counter,
+   .wait_for_vblank = &r100_wait_for_vblank,
+   },
.copy = {
.blit = &r100_copy_blit,
.blit_ring_index = RADEON_RING_TYPE_GFX_INDEX,
@@ -173,7 +177,6 @@ static struct radeon_asic r100_asic = {
  

[drm-next 10/14] drm/radeon/kms: reorganize gart callbacks

2012-02-23 Thread alexdeucher
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/r100.c|4 +-
 drivers/gpu/drm/radeon/r300.c|4 +-
 drivers/gpu/drm/radeon/radeon.h  |   12 +++-
 drivers/gpu/drm/radeon/radeon_asic.c |  110 ++
 4 files changed, 84 insertions(+), 46 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index e36b730..8eb1421 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -626,8 +626,8 @@ int r100_pci_gart_init(struct radeon_device *rdev)
if (r)
return r;
rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
-   rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
-   rdev->asic->gart_set_page = &r100_pci_gart_set_page;
+   rdev->asic->gart.tlb_flush = &r100_pci_gart_tlb_flush;
+   rdev->asic->gart.set_page = &r100_pci_gart_set_page;
return radeon_gart_table_ram_alloc(rdev);
 }
 
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 0a17b1d..fa14383 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -105,8 +105,8 @@ int rv370_pcie_gart_init(struct radeon_device *rdev)
if (r)
DRM_ERROR("Failed to register debugfs file for PCIE gart !\n");
rdev->gart.table_size = rdev->gart.num_gpu_pages * 4;
-   rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
-   rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
+   rdev->asic->gart.tlb_flush = &rv370_pcie_gart_tlb_flush;
+   rdev->asic->gart.set_page = &rv370_pcie_gart_set_page;
return radeon_gart_table_vram_alloc(rdev);
 }
 
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 4559338..732582f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1131,8 +1131,12 @@ struct radeon_asic {
void (*vga_set_state)(struct radeon_device *rdev, bool state);
bool (*gpu_is_lockup)(struct radeon_device *rdev, struct radeon_ring 
*cp);
int (*asic_reset)(struct radeon_device *rdev);
-   void (*gart_tlb_flush)(struct radeon_device *rdev);
-   int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr);
+
+   struct {
+   void (*tlb_flush)(struct radeon_device *rdev);
+   int (*set_page)(struct radeon_device *rdev, int i, uint64_t 
addr);
+   } gart;
+
struct {
void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib 
*ib);
int (*ib_parse)(struct radeon_device *rdev, struct radeon_ib 
*ib);
@@ -1671,8 +1675,8 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), 
(state))
 #define radeon_gpu_is_lockup(rdev, cp) (rdev)->asic->gpu_is_lockup((rdev), 
(cp))
 #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
-#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart_tlb_flush((rdev))
-#define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart_set_page((rdev), 
(i), (p))
+#define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev))
+#define radeon_gart_set_page(rdev, i, p) (rdev)->asic->gart.set_page((rdev), 
(i), (p))
 #define radeon_ring_start(rdev, r, cp) 
(rdev)->asic->ring[(r)].ring_start((rdev), (cp))
 #define radeon_ring_test(rdev, r, cp) 
(rdev)->asic->ring[(r)].ring_test((rdev), (cp))
 #define radeon_ib_test(rdev, r, cp) (rdev)->asic->ring[(r)].ib_test((rdev), 
(cp))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 85e1350..1fd6e56 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -114,13 +114,13 @@ void radeon_agp_disable(struct radeon_device *rdev)
rdev->family == CHIP_R423) {
DRM_INFO("Forcing AGP to PCIE mode\n");
rdev->flags |= RADEON_IS_PCIE;
-   rdev->asic->gart_tlb_flush = &rv370_pcie_gart_tlb_flush;
-   rdev->asic->gart_set_page = &rv370_pcie_gart_set_page;
+   rdev->asic->gart.tlb_flush = &rv370_pcie_gart_tlb_flush;
+   rdev->asic->gart.set_page = &rv370_pcie_gart_set_page;
} else {
DRM_INFO("Forcing AGP to PCI mode\n");
rdev->flags |= RADEON_IS_PCI;
-   rdev->asic->gart_tlb_flush = &r100_pci_gart_tlb_flush;
-   rdev->asic->gart_set_page = &r100_pci_gart_set_page;
+   rdev->asic->gart.tlb_flush = &r100_pci_gart_tlb_flush;
+   rdev->asic->gart.set_page = &r100_pci_gart_set_page;
}
rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
 }
@@ -136,8 +136,10 @@ static struct radeon_asic r100_asic = {
.vga_set_state = &r100_vga_set_state,
.gpu_is_lockup = &r100_gpu_is_lockup,
.asic_reset = &r100_asic_reset,
-   .g

[drm-next 09/14] drm/radeon/kms: make ring_start, ring_test, and ib_test per ring

2012-02-23 Thread alexdeucher
From: Alex Deucher 

Each ring type may need a different variant.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/evergreen.c   |4 +-
 drivers/gpu/drm/radeon/ni.c  |4 +-
 drivers/gpu/drm/radeon/r100.c|   11 ++---
 drivers/gpu/drm/radeon/r300.c|5 +-
 drivers/gpu/drm/radeon/r420.c|2 +-
 drivers/gpu/drm/radeon/r520.c|2 +-
 drivers/gpu/drm/radeon/r600.c|9 ++--
 drivers/gpu/drm/radeon/radeon.h  |   13 +++---
 drivers/gpu/drm/radeon/radeon_asic.c |   75 +
 drivers/gpu/drm/radeon/radeon_asic.h |   10 ++--
 drivers/gpu/drm/radeon/rs400.c   |2 +-
 drivers/gpu/drm/radeon/rs600.c   |2 +-
 drivers/gpu/drm/radeon/rs690.c   |2 +-
 drivers/gpu/drm/radeon/rv515.c   |5 +-
 drivers/gpu/drm/radeon/rv770.c   |2 +-
 15 files changed, 83 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index ab334e9..758f04b 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1508,7 +1508,7 @@ int evergreen_cp_resume(struct radeon_device *rdev)
 
evergreen_cp_start(rdev);
ring->ready = true;
-   r = radeon_ring_test(rdev, ring);
+   r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, ring);
if (r) {
ring->ready = false;
return r;
@@ -3206,7 +3206,7 @@ static int evergreen_startup(struct radeon_device *rdev)
if (r)
return r;
 
-   r = r600_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX);
+   r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
if (r) {
DRM_ERROR("radeon: failed testing IB (%d).\n", r);
rdev->accel_working = false;
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 2d9ee5d..160799c 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1318,7 +1318,7 @@ int cayman_cp_resume(struct radeon_device *rdev)
rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX].ready = false;
rdev->ring[CAYMAN_RING_TYPE_CP2_INDEX].ready = false;
/* this only test cp0 */
-   r = radeon_ring_test(rdev, &rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
+   r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
if (r) {
rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready = false;
rdev->ring[CAYMAN_RING_TYPE_CP1_INDEX].ready = false;
@@ -1518,7 +1518,7 @@ static int cayman_startup(struct radeon_device *rdev)
if (r)
return r;
 
-   r = r600_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX);
+   r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
if (r) {
DRM_ERROR("radeon: failed testing IB (%d).\n", r);
rdev->accel_working = false;
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index bff612a..e36b730 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -964,9 +964,8 @@ static int r100_cp_wait_for_idle(struct radeon_device *rdev)
return -1;
 }
 
-void r100_ring_start(struct radeon_device *rdev)
+void r100_ring_start(struct radeon_device *rdev, struct radeon_ring *ring)
 {
-   struct radeon_ring *ring = &rdev->ring[RADEON_RING_TYPE_GFX_INDEX];
int r;
 
r = radeon_ring_lock(rdev, ring, 2);
@@ -1177,8 +1176,8 @@ int r100_cp_init(struct radeon_device *rdev, unsigned 
ring_size)
WREG32(RADEON_CP_RB_WPTR_DELAY, 0);
WREG32(RADEON_CP_CSQ_MODE, 0x4D4D);
WREG32(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM);
-   radeon_ring_start(rdev);
-   r = radeon_ring_test(rdev, ring);
+   radeon_ring_start(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
+   r = radeon_ring_test(rdev, RADEON_RING_TYPE_GFX_INDEX, ring);
if (r) {
DRM_ERROR("radeon: cp isn't working (%d).\n", r);
return r;
@@ -3725,7 +3724,7 @@ void r100_ring_ib_execute(struct radeon_device *rdev, 
struct radeon_ib *ib)
radeon_ring_write(ring, ib->length_dw);
 }
 
-int r100_ib_test(struct radeon_device *rdev)
+int r100_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
 {
struct radeon_ib *ib;
uint32_t scratch;
@@ -3950,7 +3949,7 @@ static int r100_startup(struct radeon_device *rdev)
if (r)
return r;
 
-   r = r100_ib_test(rdev);
+   r = radeon_ib_test(rdev, RADEON_RING_TYPE_GFX_INDEX, 
&rdev->ring[RADEON_RING_TYPE_GFX_INDEX]);
if (r) {
dev_err(rdev->dev, "failed testing IB (%d).\n", r);
rdev->accel_working = false;
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 6829638..0a17b1d 100644
--- a/drivers/gpu/drm/radeon

[drm-next 08/14] drm/radeon/kms: remove unused cp callbacks from radeon_asic

2012-02-23 Thread alexdeucher
From: Alex Deucher 

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 9fbeca4..d2aa41f 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1134,9 +1134,6 @@ struct radeon_asic {
int (*asic_reset)(struct radeon_device *rdev);
void (*gart_tlb_flush)(struct radeon_device *rdev);
int (*gart_set_page)(struct radeon_device *rdev, int i, uint64_t addr);
-   int (*cp_init)(struct radeon_device *rdev, unsigned ring_size);
-   void (*cp_fini)(struct radeon_device *rdev);
-   void (*cp_disable)(struct radeon_device *rdev);
void (*ring_start)(struct radeon_device *rdev);
 
struct {
-- 
1.7.7.5

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


[drm-next 07/14] drm/radeon/kms: reorganize irq callbacks

2012-02-23 Thread alexdeucher
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   13 +++-
 drivers/gpu/drm/radeon/radeon_asic.c |  102 ++---
 2 files changed, 77 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index d49d461..9fbeca4 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1149,8 +1149,12 @@ struct radeon_asic {
} ring[RADEON_NUM_RINGS];
 
int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
-   int (*irq_set)(struct radeon_device *rdev);
-   int (*irq_process)(struct radeon_device *rdev);
+
+   struct {
+   int (*set)(struct radeon_device *rdev);
+   int (*process)(struct radeon_device *rdev);
+   } irq;
+
u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
 
struct {
@@ -1203,6 +1207,7 @@ struct radeon_asic {
 * through ring.
 */
void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
+   /* check if 3D engine is idle */
bool (*gui_idle)(struct radeon_device *rdev);
/* power management */
struct {
@@ -1677,8 +1682,8 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_ring_test(rdev, cp) (rdev)->asic->ring_test((rdev), (cp))
 #define radeon_ring_ib_execute(rdev, r, ib) 
(rdev)->asic->ring[(r)].ib_execute((rdev), (ib))
 #define radeon_ring_ib_parse(rdev, r, ib) 
(rdev)->asic->ring[(r)].ib_parse((rdev), (ib))
-#define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev))
-#define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev))
+#define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
+#define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
 #define radeon_get_vblank_counter(rdev, crtc) 
(rdev)->asic->get_vblank_counter((rdev), (crtc))
 #define radeon_fence_ring_emit(rdev, r, fence) 
(rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
 #define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) 
(rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 6bd1525..a7b6c37 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -148,8 +148,10 @@ static struct radeon_asic r100_asic = {
.cs_parse = &r100_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -213,8 +215,10 @@ static struct radeon_asic r200_asic = {
.cs_parse = &r100_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -277,8 +281,10 @@ static struct radeon_asic r300_asic = {
.cs_parse = &r300_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -342,8 +348,10 @@ static struct radeon_asic r300_asic_pcie = {
.cs_parse = &r300_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -406,8 +414,10 @@ static struct radeon_asic r420_asic = {
.cs_parse = &r300_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.get_vblank_counter = &r100_get_vblank_counter,
.copy = {
.blit = &r100_copy_blit,
@@ -471,8 +481,10 @@ static struct radeon_asic rs400_asic = {
.cs_parse = &r300_cs_parse,
}
},
-   .irq_set = &r100_irq_set,
-   .irq_process = &r100_irq_process,
+   .irq = {
+   .set = &r100_irq_set,
+   .process = &r100_irq_process,
+   },
.ge

[drm-next 06/14] drm/radeon/kms: reorganize copy callbacks

2012-02-23 Thread alexdeucher
From: Alex Deucher 

tidy up the radeon_asic struct, handle multiple
rings better.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/evergreen.c|2 +-
 drivers/gpu/drm/radeon/ni.c   |2 +-
 drivers/gpu/drm/radeon/r600.c |2 +-
 drivers/gpu/drm/radeon/radeon.h   |   50 +---
 drivers/gpu/drm/radeon/radeon_asic.c  |  190 +
 drivers/gpu/drm/radeon/radeon_benchmark.c |   12 +-
 drivers/gpu/drm/radeon/radeon_ttm.c   |   15 ++-
 drivers/gpu/drm/radeon/rv770.c|2 +-
 8 files changed, 185 insertions(+), 90 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index 158ff59..ab334e9 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3166,7 +3166,7 @@ static int evergreen_startup(struct radeon_device *rdev)
r = evergreen_blit_init(rdev);
if (r) {
r600_blit_fini(rdev);
-   rdev->asic->copy = NULL;
+   rdev->asic->copy.copy = NULL;
dev_warn(rdev->dev, "failed blitter (%d) falling back to 
memcpy\n", r);
}
 
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 2509c50..2d9ee5d 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1466,7 +1466,7 @@ static int cayman_startup(struct radeon_device *rdev)
r = evergreen_blit_init(rdev);
if (r) {
r600_blit_fini(rdev);
-   rdev->asic->copy = NULL;
+   rdev->asic->copy.copy = NULL;
dev_warn(rdev->dev, "failed blitter (%d) falling back to 
memcpy\n", r);
}
 
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index fbcd848..e15a267 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2449,7 +2449,7 @@ int r600_startup(struct radeon_device *rdev)
r = r600_blit_init(rdev);
if (r) {
r600_blit_fini(rdev);
-   rdev->asic->copy = NULL;
+   rdev->asic->copy.copy = NULL;
dev_warn(rdev->dev, "failed blitter (%d) falling back to 
memcpy\n", r);
}
 
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 3ad14208..d49d461 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1152,21 +1152,30 @@ struct radeon_asic {
int (*irq_set)(struct radeon_device *rdev);
int (*irq_process)(struct radeon_device *rdev);
u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
-   int (*copy_blit)(struct radeon_device *rdev,
-uint64_t src_offset,
-uint64_t dst_offset,
-unsigned num_gpu_pages,
-struct radeon_fence *fence);
-   int (*copy_dma)(struct radeon_device *rdev,
-   uint64_t src_offset,
-   uint64_t dst_offset,
-   unsigned num_gpu_pages,
-   struct radeon_fence *fence);
-   int (*copy)(struct radeon_device *rdev,
-   uint64_t src_offset,
-   uint64_t dst_offset,
-   unsigned num_gpu_pages,
-   struct radeon_fence *fence);
+
+   struct {
+   int (*blit)(struct radeon_device *rdev,
+   uint64_t src_offset,
+   uint64_t dst_offset,
+   unsigned num_gpu_pages,
+   struct radeon_fence *fence);
+   u32 blit_ring_index;
+   int (*dma)(struct radeon_device *rdev,
+  uint64_t src_offset,
+  uint64_t dst_offset,
+  unsigned num_gpu_pages,
+  struct radeon_fence *fence);
+   u32 dma_ring_index;
+   /* method used for bo copy */
+   int (*copy)(struct radeon_device *rdev,
+   uint64_t src_offset,
+   uint64_t dst_offset,
+   unsigned num_gpu_pages,
+   struct radeon_fence *fence);
+   /* ring used for bo copies */
+   u32 copy_ring_index;
+   } copy;
+
uint32_t (*get_engine_clock)(struct radeon_device *rdev);
void (*set_engine_clock)(struct radeon_device *rdev, uint32_t 
eng_clock);
uint32_t (*get_memory_clock)(struct radeon_device *rdev);
@@ -1503,8 +1512,6 @@ struct radeon_device {
unsigneddebugfs_count;
/* virtual memory */
struct radeon_vm_managervm_manager;
-   /* ring used for bo copies */
-   u32 copy_ring;
 };
 
 int radeon_device_init(struct radeon_device *rdev,
@@ -1675,9 +1682,12 @@ void radeon_ring_write(struct radeon_ring *ring, 
uint32

[drm-next 05/14] drm/radeon/kms: reorganize pm callbacks

2012-02-23 Thread alexdeucher
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   22 ++--
 drivers/gpu/drm/radeon/radeon_asic.c |  204 --
 2 files changed, 131 insertions(+), 95 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 20d4aad..3ad14208 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1196,11 +1196,13 @@ struct radeon_asic {
void (*ioctl_wait_idle)(struct radeon_device *rdev, struct radeon_bo 
*bo);
bool (*gui_idle)(struct radeon_device *rdev);
/* power management */
-   void (*pm_misc)(struct radeon_device *rdev);
-   void (*pm_prepare)(struct radeon_device *rdev);
-   void (*pm_finish)(struct radeon_device *rdev);
-   void (*pm_init_profile)(struct radeon_device *rdev);
-   void (*pm_get_dynpm_state)(struct radeon_device *rdev);
+   struct {
+   void (*misc)(struct radeon_device *rdev);
+   void (*prepare)(struct radeon_device *rdev);
+   void (*finish)(struct radeon_device *rdev);
+   void (*init_profile)(struct radeon_device *rdev);
+   void (*get_dynpm_state)(struct radeon_device *rdev);
+   } pm;
/* pageflipping */
struct {
void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
@@ -1691,11 +1693,11 @@ void radeon_ring_write(struct radeon_ring *ring, 
uint32_t v);
 #define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
 #define radeon_hpd_set_polarity(rdev, h) 
(rdev)->asic->hpd.set_polarity((rdev), (h))
 #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
-#define radeon_pm_misc(rdev) (rdev)->asic->pm_misc((rdev))
-#define radeon_pm_prepare(rdev) (rdev)->asic->pm_prepare((rdev))
-#define radeon_pm_finish(rdev) (rdev)->asic->pm_finish((rdev))
-#define radeon_pm_init_profile(rdev) (rdev)->asic->pm_init_profile((rdev))
-#define radeon_pm_get_dynpm_state(rdev) 
(rdev)->asic->pm_get_dynpm_state((rdev))
+#define radeon_pm_misc(rdev) (rdev)->asic->pm.misc((rdev))
+#define radeon_pm_prepare(rdev) (rdev)->asic->pm.prepare((rdev))
+#define radeon_pm_finish(rdev) (rdev)->asic->pm.finish((rdev))
+#define radeon_pm_init_profile(rdev) (rdev)->asic->pm.init_profile((rdev))
+#define radeon_pm_get_dynpm_state(rdev) 
(rdev)->asic->pm.get_dynpm_state((rdev))
 #define radeon_pre_page_flip(rdev, crtc) 
rdev->asic->pflip.pre_page_flip((rdev), (crtc))
 #define radeon_page_flip(rdev, crtc, base) rdev->asic->pflip.page_flip((rdev), 
(crtc), (base))
 #define radeon_post_page_flip(rdev, crtc) 
rdev->asic->pflip.post_page_flip((rdev), (crtc))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 6ebdeeb..38a29bc 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -172,11 +172,13 @@ static struct radeon_asic r100_asic = {
},
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
-   .pm_misc = &r100_pm_misc,
-   .pm_prepare = &r100_pm_prepare,
-   .pm_finish = &r100_pm_finish,
-   .pm_init_profile = &r100_pm_init_profile,
-   .pm_get_dynpm_state = &r100_pm_get_dynpm_state,
+   .pm = {
+   .misc = &r100_pm_misc,
+   .prepare = &r100_pm_prepare,
+   .finish = &r100_pm_finish,
+   .init_profile = &r100_pm_init_profile,
+   .get_dynpm_state = &r100_pm_get_dynpm_state,
+   },
.pflip = {
.pre_page_flip = &r100_pre_page_flip,
.page_flip = &r100_page_flip,
@@ -229,11 +231,13 @@ static struct radeon_asic r200_asic = {
},
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
-   .pm_misc = &r100_pm_misc,
-   .pm_prepare = &r100_pm_prepare,
-   .pm_finish = &r100_pm_finish,
-   .pm_init_profile = &r100_pm_init_profile,
-   .pm_get_dynpm_state = &r100_pm_get_dynpm_state,
+   .pm = {
+   .misc = &r100_pm_misc,
+   .prepare = &r100_pm_prepare,
+   .finish = &r100_pm_finish,
+   .init_profile = &r100_pm_init_profile,
+   .get_dynpm_state = &r100_pm_get_dynpm_state,
+   },
.pflip = {
.pre_page_flip = &r100_pre_page_flip,
.page_flip = &r100_page_flip,
@@ -287,11 +291,13 @@ static struct radeon_asic r300_asic = {
},
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
-   .pm_misc = &r100_pm_misc,
-   .pm_prepare = &r100_pm_prepare,
-   .pm_finish = &r100_pm_finish,
-   .pm_init_profile = &r100_pm_init_profile,
-   .pm_get_dynpm_state = &r100_pm_get_dynpm_state,
+   .pm = {
+   .misc = &r100_pm_misc,
+   .prepare = &r100_pm_prepare,
+   .finish = &r100_pm_finish,
+   .init_profile = &r100_pm_init_profile,
+   .get_dyn

[drm-next 04/14] drm/radeon/kms: reorganize page flip callbacks

2012-02-23 Thread alexdeucher
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   14 ++--
 drivers/gpu/drm/radeon/radeon_asic.c |  136 +-
 2 files changed, 93 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 31e3d33..20d4aad 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1202,9 +1202,11 @@ struct radeon_asic {
void (*pm_init_profile)(struct radeon_device *rdev);
void (*pm_get_dynpm_state)(struct radeon_device *rdev);
/* pageflipping */
-   void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
-   u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
-   void (*post_page_flip)(struct radeon_device *rdev, int crtc);
+   struct {
+   void (*pre_page_flip)(struct radeon_device *rdev, int crtc);
+   u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 
crtc_base);
+   void (*post_page_flip)(struct radeon_device *rdev, int crtc);
+   } pflip;
/* wait for vblank */
void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
/* wait for mc_idle */
@@ -1694,9 +1696,9 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_pm_finish(rdev) (rdev)->asic->pm_finish((rdev))
 #define radeon_pm_init_profile(rdev) (rdev)->asic->pm_init_profile((rdev))
 #define radeon_pm_get_dynpm_state(rdev) 
(rdev)->asic->pm_get_dynpm_state((rdev))
-#define radeon_pre_page_flip(rdev, crtc) rdev->asic->pre_page_flip((rdev), 
(crtc))
-#define radeon_page_flip(rdev, crtc, base) rdev->asic->page_flip((rdev), 
(crtc), (base))
-#define radeon_post_page_flip(rdev, crtc) rdev->asic->post_page_flip((rdev), 
(crtc))
+#define radeon_pre_page_flip(rdev, crtc) 
rdev->asic->pflip.pre_page_flip((rdev), (crtc))
+#define radeon_page_flip(rdev, crtc, base) rdev->asic->pflip.page_flip((rdev), 
(crtc), (base))
+#define radeon_post_page_flip(rdev, crtc) 
rdev->asic->pflip.post_page_flip((rdev), (crtc))
 #define radeon_wait_for_vblank(rdev, crtc) rdev->asic->wait_for_vblank((rdev), 
(crtc))
 #define radeon_mc_wait_for_idle(rdev) rdev->asic->mc_wait_for_idle((rdev))
 
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 4a23255..6ebdeeb 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -177,9 +177,11 @@ static struct radeon_asic r100_asic = {
.pm_finish = &r100_pm_finish,
.pm_init_profile = &r100_pm_init_profile,
.pm_get_dynpm_state = &r100_pm_get_dynpm_state,
-   .pre_page_flip = &r100_pre_page_flip,
-   .page_flip = &r100_page_flip,
-   .post_page_flip = &r100_post_page_flip,
+   .pflip = {
+   .pre_page_flip = &r100_pre_page_flip,
+   .page_flip = &r100_page_flip,
+   .post_page_flip = &r100_post_page_flip,
+   },
.wait_for_vblank = &r100_wait_for_vblank,
.mc_wait_for_idle = &r100_mc_wait_for_idle,
 };
@@ -232,9 +234,11 @@ static struct radeon_asic r200_asic = {
.pm_finish = &r100_pm_finish,
.pm_init_profile = &r100_pm_init_profile,
.pm_get_dynpm_state = &r100_pm_get_dynpm_state,
-   .pre_page_flip = &r100_pre_page_flip,
-   .page_flip = &r100_page_flip,
-   .post_page_flip = &r100_post_page_flip,
+   .pflip = {
+   .pre_page_flip = &r100_pre_page_flip,
+   .page_flip = &r100_page_flip,
+   .post_page_flip = &r100_post_page_flip,
+   },
.wait_for_vblank = &r100_wait_for_vblank,
.mc_wait_for_idle = &r100_mc_wait_for_idle,
 };
@@ -288,9 +292,11 @@ static struct radeon_asic r300_asic = {
.pm_finish = &r100_pm_finish,
.pm_init_profile = &r100_pm_init_profile,
.pm_get_dynpm_state = &r100_pm_get_dynpm_state,
-   .pre_page_flip = &r100_pre_page_flip,
-   .page_flip = &r100_page_flip,
-   .post_page_flip = &r100_post_page_flip,
+   .pflip = {
+   .pre_page_flip = &r100_pre_page_flip,
+   .page_flip = &r100_page_flip,
+   .post_page_flip = &r100_post_page_flip,
+   },
.wait_for_vblank = &r100_wait_for_vblank,
.mc_wait_for_idle = &r300_mc_wait_for_idle,
 };
@@ -343,9 +349,11 @@ static struct radeon_asic r300_asic_pcie = {
.pm_finish = &r100_pm_finish,
.pm_init_profile = &r100_pm_init_profile,
.pm_get_dynpm_state = &r100_pm_get_dynpm_state,
-   .pre_page_flip = &r100_pre_page_flip,
-   .page_flip = &r100_page_flip,
-   .post_page_flip = &r100_post_page_flip,
+   .pflip = {
+   .pre_page_flip = &r100_pre_page_flip,
+   .page_flip = &r100_page_flip,
+   .post_page_flip = &r100_post_page_flip,
+   },
.wait_for_vblank = &r100_wait_for_vblank,
.mc_wait_for_idle = &r3

[drm-next 03/14] drm/radeon/kms: reorganize hpd callbacks

2012-02-23 Thread alexdeucher
From: Alex Deucher 

tidy up the radeon_asic struct.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h  |   20 +++--
 drivers/gpu/drm/radeon/radeon_asic.c |  170 --
 2 files changed, 114 insertions(+), 76 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 3906927..31e3d33 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1179,10 +1179,14 @@ struct radeon_asic {
   uint32_t offset, uint32_t obj_size);
void (*clear_surface_reg)(struct radeon_device *rdev, int reg);
void (*bandwidth_update)(struct radeon_device *rdev);
-   void (*hpd_init)(struct radeon_device *rdev);
-   void (*hpd_fini)(struct radeon_device *rdev);
-   bool (*hpd_sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
-   void (*hpd_set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id 
hpd);
+
+   struct {
+   void (*init)(struct radeon_device *rdev);
+   void (*fini)(struct radeon_device *rdev);
+   bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id 
hpd);
+   void (*set_polarity)(struct radeon_device *rdev, enum 
radeon_hpd_id hpd);
+   } hpd;
+
/* ioctl hw specific callback. Some hw might want to perform special
 * operation on specific ioctl. For instance on wait idle some hw
 * might want to perform and HDP flush through MMIO as it seems that
@@ -1680,10 +1684,10 @@ void radeon_ring_write(struct radeon_ring *ring, 
uint32_t v);
 #define radeon_set_surface_reg(rdev, r, f, p, o, s) 
((rdev)->asic->set_surface_reg((rdev), (r), (f), (p), (o), (s)))
 #define radeon_clear_surface_reg(rdev, r) 
((rdev)->asic->clear_surface_reg((rdev), (r)))
 #define radeon_bandwidth_update(rdev) (rdev)->asic->bandwidth_update((rdev))
-#define radeon_hpd_init(rdev) (rdev)->asic->hpd_init((rdev))
-#define radeon_hpd_fini(rdev) (rdev)->asic->hpd_fini((rdev))
-#define radeon_hpd_sense(rdev, hpd) (rdev)->asic->hpd_sense((rdev), (hpd))
-#define radeon_hpd_set_polarity(rdev, hpd) 
(rdev)->asic->hpd_set_polarity((rdev), (hpd))
+#define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
+#define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
+#define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
+#define radeon_hpd_set_polarity(rdev, h) 
(rdev)->asic->hpd.set_polarity((rdev), (h))
 #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
 #define radeon_pm_misc(rdev) (rdev)->asic->pm_misc((rdev))
 #define radeon_pm_prepare(rdev) (rdev)->asic->pm_prepare((rdev))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 9f20546..4a23255 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -164,10 +164,12 @@ static struct radeon_asic r100_asic = {
.set_surface_reg = r100_set_surface_reg,
.clear_surface_reg = r100_clear_surface_reg,
.bandwidth_update = &r100_bandwidth_update,
-   .hpd_init = &r100_hpd_init,
-   .hpd_fini = &r100_hpd_fini,
-   .hpd_sense = &r100_hpd_sense,
-   .hpd_set_polarity = &r100_hpd_set_polarity,
+   .hpd = {
+   .init = &r100_hpd_init,
+   .fini = &r100_hpd_fini,
+   .sense = &r100_hpd_sense,
+   .set_polarity = &r100_hpd_set_polarity,
+   },
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
.pm_misc = &r100_pm_misc,
@@ -217,10 +219,12 @@ static struct radeon_asic r200_asic = {
.set_surface_reg = r100_set_surface_reg,
.clear_surface_reg = r100_clear_surface_reg,
.bandwidth_update = &r100_bandwidth_update,
-   .hpd_init = &r100_hpd_init,
-   .hpd_fini = &r100_hpd_fini,
-   .hpd_sense = &r100_hpd_sense,
-   .hpd_set_polarity = &r100_hpd_set_polarity,
+   .hpd = {
+   .init = &r100_hpd_init,
+   .fini = &r100_hpd_fini,
+   .sense = &r100_hpd_sense,
+   .set_polarity = &r100_hpd_set_polarity,
+   },
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
.pm_misc = &r100_pm_misc,
@@ -271,10 +275,12 @@ static struct radeon_asic r300_asic = {
.set_surface_reg = r100_set_surface_reg,
.clear_surface_reg = r100_clear_surface_reg,
.bandwidth_update = &r100_bandwidth_update,
-   .hpd_init = &r100_hpd_init,
-   .hpd_fini = &r100_hpd_fini,
-   .hpd_sense = &r100_hpd_sense,
-   .hpd_set_polarity = &r100_hpd_set_polarity,
+   .hpd = {
+   .init = &r100_hpd_init,
+   .fini = &r100_hpd_fini,
+   .sense = &r100_hpd_sense,
+   .set_polarity = &r100_hpd_set_polarity,
+   },
.ioctl_wait_idle = NULL,
.gui_idle = &r100_gui_idle,
.pm_misc = &r100_pm_misc,
@@ -324,10 +330,12 @@ static struct radeon_asic r300_asic_pcie

[drm-next 02/14] drm/radeon/kms: add a radeon asic callback for mc idle

2012-02-23 Thread alexdeucher
From: Alex Deucher 

Required for future functionality.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/r520.c|2 +-
 drivers/gpu/drm/radeon/radeon.h  |3 +++
 drivers/gpu/drm/radeon/radeon_asic.c |   17 +
 drivers/gpu/drm/radeon/radeon_asic.h |   10 +-
 drivers/gpu/drm/radeon/rs690.c   |2 +-
 5 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index 25084e8..8a9dab0 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -33,7 +33,7 @@
 
 /* This files gather functions specifics to: r520,rv530,rv560,rv570,r580 */
 
-static int r520_mc_wait_for_idle(struct radeon_device *rdev)
+int r520_mc_wait_for_idle(struct radeon_device *rdev)
 {
unsigned i;
uint32_t tmp;
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 76d08d8..3906927 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1203,6 +1203,8 @@ struct radeon_asic {
void (*post_page_flip)(struct radeon_device *rdev, int crtc);
/* wait for vblank */
void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
+   /* wait for mc_idle */
+   int (*mc_wait_for_idle)(struct radeon_device *rdev);
 };
 
 /*
@@ -1692,6 +1694,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_page_flip(rdev, crtc, base) rdev->asic->page_flip((rdev), 
(crtc), (base))
 #define radeon_post_page_flip(rdev, crtc) rdev->asic->post_page_flip((rdev), 
(crtc))
 #define radeon_wait_for_vblank(rdev, crtc) rdev->asic->wait_for_vblank((rdev), 
(crtc))
+#define radeon_mc_wait_for_idle(rdev) rdev->asic->mc_wait_for_idle((rdev))
 
 /* Common functions */
 /* AGP */
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 67f809e..9f20546 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -179,6 +179,7 @@ static struct radeon_asic r100_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r100_mc_wait_for_idle,
 };
 
 static struct radeon_asic r200_asic = {
@@ -231,6 +232,7 @@ static struct radeon_asic r200_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r100_mc_wait_for_idle,
 };
 
 static struct radeon_asic r300_asic = {
@@ -284,6 +286,7 @@ static struct radeon_asic r300_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r300_mc_wait_for_idle,
 };
 
 static struct radeon_asic r300_asic_pcie = {
@@ -336,6 +339,7 @@ static struct radeon_asic r300_asic_pcie = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r300_mc_wait_for_idle,
 };
 
 static struct radeon_asic r420_asic = {
@@ -389,6 +393,7 @@ static struct radeon_asic r420_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &r300_mc_wait_for_idle,
 };
 
 static struct radeon_asic rs400_asic = {
@@ -442,6 +447,7 @@ static struct radeon_asic rs400_asic = {
.page_flip = &r100_page_flip,
.post_page_flip = &r100_post_page_flip,
.wait_for_vblank = &r100_wait_for_vblank,
+   .mc_wait_for_idle = &rs400_mc_wait_for_idle,
 };
 
 static struct radeon_asic rs600_asic = {
@@ -495,6 +501,7 @@ static struct radeon_asic rs600_asic = {
.page_flip = &rs600_page_flip,
.post_page_flip = &rs600_post_page_flip,
.wait_for_vblank = &avivo_wait_for_vblank,
+   .mc_wait_for_idle = &rs600_mc_wait_for_idle,
 };
 
 static struct radeon_asic rs690_asic = {
@@ -548,6 +555,7 @@ static struct radeon_asic rs690_asic = {
.page_flip = &rs600_page_flip,
.post_page_flip = &rs600_post_page_flip,
.wait_for_vblank = &avivo_wait_for_vblank,
+   .mc_wait_for_idle = &rs690_mc_wait_for_idle,
 };
 
 static struct radeon_asic rv515_asic = {
@@ -601,6 +609,7 @@ static struct radeon_asic rv515_asic = {
.page_flip = &rs600_page_flip,
.post_page_flip = &rs600_post_page_flip,
.wait_for_vblank = &avivo_wait_for_vblank,
+   .mc_wait_for_idle = &rv515_mc_wait_for_idle,
 };
 
 static struct radeon_asic r520_asic = {
@@ -654,6 +663,7 @@ static struct radeon_asic r520_asic = {
.page_flip = &rs600_page_flip,
.post_page_flip = &rs600_post_page_flip,
.wait_for_vblank = &avivo_wait_for_vblank,
+   .mc_wait_for_idle = &r520_mc_wait_for_idle,
 };
 
 static struct radeon_asic r600_asic = {

[drm-next 01/14] drm/radeon/kms: add wait_for_vblank asic callback

2012-02-23 Thread alexdeucher
From: Alex Deucher 

Required for future functionality.

Signed-off-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/evergreen.c |   19 +
 drivers/gpu/drm/radeon/evergreen_reg.h |1 +
 drivers/gpu/drm/radeon/r100.c  |   34 
 drivers/gpu/drm/radeon/r500_reg.h  |2 +
 drivers/gpu/drm/radeon/radeon.h|3 ++
 drivers/gpu/drm/radeon/radeon_asic.c   |   17 
 drivers/gpu/drm/radeon/radeon_asic.h   |4 ++-
 drivers/gpu/drm/radeon/radeon_reg.h|2 +
 drivers/gpu/drm/radeon/rs600.c |   19 +
 9 files changed, 100 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index f58254a..158ff59 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -68,6 +68,25 @@ void evergreen_fix_pci_max_read_req_size(struct 
radeon_device *rdev)
}
 }
 
+void dce4_wait_for_vblank(struct radeon_device *rdev, int crtc)
+{
+   struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc];
+   int i;
+
+   if (RREG32(EVERGREEN_CRTC_CONTROL + radeon_crtc->crtc_offset) & 
EVERGREEN_CRTC_MASTER_EN) {
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (!(RREG32(EVERGREEN_CRTC_STATUS + 
radeon_crtc->crtc_offset) & EVERGREEN_CRTC_V_BLANK))
+   break;
+   udelay(1);
+   }
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (RREG32(EVERGREEN_CRTC_STATUS + 
radeon_crtc->crtc_offset) & EVERGREEN_CRTC_V_BLANK)
+   break;
+   udelay(1);
+   }
+   }
+}
+
 void evergreen_pre_page_flip(struct radeon_device *rdev, int crtc)
 {
/* enable the pflip int */
diff --git a/drivers/gpu/drm/radeon/evergreen_reg.h 
b/drivers/gpu/drm/radeon/evergreen_reg.h
index 4215de9..96c10b3 100644
--- a/drivers/gpu/drm/radeon/evergreen_reg.h
+++ b/drivers/gpu/drm/radeon/evergreen_reg.h
@@ -219,6 +219,7 @@
 #   define EVERGREEN_CRTC_MASTER_EN (1 << 0)
 #   define EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE (1 << 24)
 #define EVERGREEN_CRTC_STATUS   0x6e8c
+#   define EVERGREEN_CRTC_V_BLANK   (1 << 0)
 #define EVERGREEN_CRTC_STATUS_POSITION  0x6e90
 #define EVERGREEN_MASTER_UPDATE_MODE0x6ef8
 #define EVERGREEN_CRTC_UPDATE_LOCK  0x6ed4
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 333cde9..bff612a 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -65,6 +65,40 @@ MODULE_FIRMWARE(FIRMWARE_R520);
 
 #include "r100_track.h"
 
+void r100_wait_for_vblank(struct radeon_device *rdev, int crtc)
+{
+   struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc];
+   int i;
+
+   if (radeon_crtc->crtc_id == 0) {
+   if (RREG32(RADEON_CRTC_GEN_CNTL) & RADEON_CRTC_EN) {
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (!(RREG32(RADEON_CRTC_STATUS) & 
RADEON_CRTC_VBLANK_CUR))
+   break;
+   udelay(1);
+   }
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (RREG32(RADEON_CRTC_STATUS) & 
RADEON_CRTC_VBLANK_CUR)
+   break;
+   udelay(1);
+   }
+   }
+   } else {
+   if (RREG32(RADEON_CRTC2_GEN_CNTL) & RADEON_CRTC2_EN) {
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (!(RREG32(RADEON_CRTC2_STATUS) & 
RADEON_CRTC2_VBLANK_CUR))
+   break;
+   udelay(1);
+   }
+   for (i = 0; i < rdev->usec_timeout; i++) {
+   if (RREG32(RADEON_CRTC2_STATUS) & 
RADEON_CRTC2_VBLANK_CUR)
+   break;
+   udelay(1);
+   }
+   }
+   }
+}
+
 /* This files gather functions specifics to:
  * r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280
  */
diff --git a/drivers/gpu/drm/radeon/r500_reg.h 
b/drivers/gpu/drm/radeon/r500_reg.h
index 3bd8f1b..ec576aa 100644
--- a/drivers/gpu/drm/radeon/r500_reg.h
+++ b/drivers/gpu/drm/radeon/r500_reg.h
@@ -351,6 +351,8 @@
 #define AVIVO_D1CRTC_BLANK_CONTROL  0x6084
 #define AVIVO_D1CRTC_INTERLACE_CONTROL  0x6088
 #define AVIVO_D1CRTC_INTERLACE_STATUS   0x608c
+#define AVIVO_D1CRTC_STATUS 0x609c
+#   define AVIVO_D1CRTC_V_BLANK   

[drm-next 00/14] radeon_asic cleanups for drm-next

2012-02-23 Thread alexdeucher
From: Alex Deucher 

This patch set cleans up radeon_asic and organizes the asic
specific callbacks based on their function.  Not change in
functionality.  It requires Christian's patch:
"drm/radeon: also make the cs_parse function per ring"

Alex Deucher (14):
  drm/radeon/kms: add wait_for_vblank asic callback
  drm/radeon/kms: add a radeon asic callback for mc idle
  drm/radeon/kms: reorganize hpd callbacks
  drm/radeon/kms: reorganize page flip callbacks
  drm/radeon/kms: reorganize pm callbacks
  drm/radeon/kms: reorganize copy callbacks
  drm/radeon/kms: reorganize irq callbacks
  drm/radeon/kms: remove unused cp callbacks from radeon_asic
  drm/radeon/kms: make ring_start, ring_test, and ib_test per ring
  drm/radeon/kms: reorganize gart callbacks
  drm/radeon/kms: reorganize display callbacks
  drm/radeon/kms: move clock/pcie setting callbacks into pm struct
  drm/radeon/kms: reorganize surface callbacks
  drm/radeon/kms: clean up radeon_asic struct

 drivers/gpu/drm/radeon/evergreen.c|   25 +-
 drivers/gpu/drm/radeon/evergreen_reg.h|1 +
 drivers/gpu/drm/radeon/ni.c   |6 +-
 drivers/gpu/drm/radeon/r100.c |   51 +-
 drivers/gpu/drm/radeon/r300.c |9 +-
 drivers/gpu/drm/radeon/r420.c |2 +-
 drivers/gpu/drm/radeon/r500_reg.h |2 +
 drivers/gpu/drm/radeon/r520.c |4 +-
 drivers/gpu/drm/radeon/r600.c |   11 +-
 drivers/gpu/drm/radeon/radeon.h   |  222 +++--
 drivers/gpu/drm/radeon/radeon_asic.c  | 1541 ++---
 drivers/gpu/drm/radeon/radeon_asic.h  |   24 +-
 drivers/gpu/drm/radeon/radeon_benchmark.c |   12 +-
 drivers/gpu/drm/radeon/radeon_clocks.c|2 +-
 drivers/gpu/drm/radeon/radeon_pm.c|6 +-
 drivers/gpu/drm/radeon/radeon_reg.h   |2 +
 drivers/gpu/drm/radeon/radeon_ttm.c   |   15 +-
 drivers/gpu/drm/radeon/rs400.c|2 +-
 drivers/gpu/drm/radeon/rs600.c|   23 +-
 drivers/gpu/drm/radeon/rs690.c|4 +-
 drivers/gpu/drm/radeon/rv515.c|5 +-
 drivers/gpu/drm/radeon/rv770.c|4 +-
 22 files changed, 1236 insertions(+), 737 deletions(-)

-- 
1.7.7.5

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


Re: [PATCH] mm: extend prefault helpers to fault in more than PAGE_SIZE

2012-02-23 Thread Andrew Morton
On Thu, 16 Feb 2012 13:01:36 +0100
Daniel Vetter  wrote:

> drm/i915 wants to read/write more than one page in its fastpath
> and hence needs to prefault more than PAGE_SIZE bytes.
> 
> I've checked the callsites and they all already clamp size when
> calling fault_in_pages_* to the same as for the subsequent
> __copy_to|from_user and hence don't rely on the implicit clamping
> to PAGE_SIZE.
> 
> Also kill a copy&pasted spurious space in both functions while at it.
>
> ...
>
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -408,6 +408,7 @@ extern void add_page_wait_queue(struct page *page, 
> wait_queue_t *waiter);
>  static inline int fault_in_pages_writeable(char __user *uaddr, int size)
>  {
>   int ret;
> + char __user *end = uaddr + size - 1;
>  
>   if (unlikely(size == 0))
>   return 0;
> @@ -416,17 +417,20 @@ static inline int fault_in_pages_writeable(char __user 
> *uaddr, int size)
>* Writing zeroes into userspace here is OK, because we know that if
>* the zero gets there, we'll be overwriting it.
>*/
> - ret = __put_user(0, uaddr);
> + while (uaddr <= end) {
> + ret = __put_user(0, uaddr);
> + if (ret != 0)
> + return ret;
> + uaddr += PAGE_SIZE;
> + }

The callsites in filemap.c are pretty hot paths, which is why this
thing remains explicitly inlined.  I think it would be worth adding a
bit of code here to avoid adding a pointless test-n-branch and larger
cache footprint to read() and write().

A way of doing that is to add another argument to these functions, say
"bool multipage".  Change the code to do

if (multipage) {
while (uaddr <= end) {
...
}
}

and change the callsites to pass in constant "true" or "false".  Then
compile it up and manually check that the compiler completely removed
the offending code from the filemap.c callsites.

Wanna have a think about that?  If it all looks OK then please be sure
to add code comments explaining why we did this.

>   if (ret == 0) {
> - char __user *end = uaddr + size - 1;
> -
>   /*
>* If the page was already mapped, this will get a cache miss
>* for sure, so try to avoid doing it.
>*/
> - if (((unsigned long)uaddr & PAGE_MASK) !=
> + if (((unsigned long)uaddr & PAGE_MASK) ==
>   ((unsigned long)end & PAGE_MASK))

Maybe I'm having a dim day, but I don't immediately see why != got
turned into ==.


Once we have this settled I'd suggest that the patch be carried in
whatever-git-tree-needs-it.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 42069] Texture artifacts

2012-02-23 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=42069

--- Comment #2 from Lauri Kasanen  2012-02-23 06:38:04 
PST ---
I can't test mesa 8.0 on the laptop in question, since there's now a hard dep
on xcb.

The apitrace is still downloadable though?

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


[PATCH] mm: extend prefault helpers to fault in more than PAGE_SIZE

2012-02-23 Thread Andrew Morton
On Thu, 16 Feb 2012 13:01:36 +0100
Daniel Vetter  wrote:

> drm/i915 wants to read/write more than one page in its fastpath
> and hence needs to prefault more than PAGE_SIZE bytes.
> 
> I've checked the callsites and they all already clamp size when
> calling fault_in_pages_* to the same as for the subsequent
> __copy_to|from_user and hence don't rely on the implicit clamping
> to PAGE_SIZE.
> 
> Also kill a copy&pasted spurious space in both functions while at it.
>
> ...
>
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -408,6 +408,7 @@ extern void add_page_wait_queue(struct page *page, 
> wait_queue_t *waiter);
>  static inline int fault_in_pages_writeable(char __user *uaddr, int size)
>  {
>   int ret;
> + char __user *end = uaddr + size - 1;
>  
>   if (unlikely(size == 0))
>   return 0;
> @@ -416,17 +417,20 @@ static inline int fault_in_pages_writeable(char __user 
> *uaddr, int size)
>* Writing zeroes into userspace here is OK, because we know that if
>* the zero gets there, we'll be overwriting it.
>*/
> - ret = __put_user(0, uaddr);
> + while (uaddr <= end) {
> + ret = __put_user(0, uaddr);
> + if (ret != 0)
> + return ret;
> + uaddr += PAGE_SIZE;
> + }

The callsites in filemap.c are pretty hot paths, which is why this
thing remains explicitly inlined.  I think it would be worth adding a
bit of code here to avoid adding a pointless test-n-branch and larger
cache footprint to read() and write().

A way of doing that is to add another argument to these functions, say
"bool multipage".  Change the code to do

if (multipage) {
while (uaddr <= end) {
...
}
}

and change the callsites to pass in constant "true" or "false".  Then
compile it up and manually check that the compiler completely removed
the offending code from the filemap.c callsites.

Wanna have a think about that?  If it all looks OK then please be sure
to add code comments explaining why we did this.

>   if (ret == 0) {
> - char __user *end = uaddr + size - 1;
> -
>   /*
>* If the page was already mapped, this will get a cache miss
>* for sure, so try to avoid doing it.
>*/
> - if (((unsigned long)uaddr & PAGE_MASK) !=
> + if (((unsigned long)uaddr & PAGE_MASK) ==
>   ((unsigned long)end & PAGE_MASK))

Maybe I'm having a dim day, but I don't immediately see why != got
turned into ==.


Once we have this settled I'd suggest that the patch be carried in
whatever-git-tree-needs-it.


[Bug 42678] [3.3-rc1] radeon stuck in kernel after lockup

2012-02-23 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=42678





--- Comment #6 from Rafael J. Wysocki   2012-02-23 22:32:02 ---
Handled-By : Jérôme Glisse 

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


Re: [PATCH] drm: Reduce the number of retries whilst reading EDIDs

2012-02-23 Thread Linus Torvalds
On Thu, Feb 23, 2012 at 1:36 PM, Eugeni Dodonov
 wrote:
>
> Perhaps a stupid question, but does you tree has
> http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=9292f37e1f5c79400254dca46f83313488093825
> from Dave's drm-next?
>
> If it has, it would be the 1st time that I see xrandr take longer than .5s
> with that patch on an Intel GPU. We even added a check for this into
> intel-gpu-tools to warn us if any machine takes that long, and none had hit
> it so far. So if this is the case here, there is something Mac Mini-specific
> indeed to investigate.

Yup, the tree I tested was current -git with the two commits mentioned
in this thread:

   drm: Reduce the number of retries whilst reading EDIDs
   drm: give up on edid retries when i2c bus is not responding

applied separately on top of it.

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


[PATCH] drm: Reduce the number of retries whilst reading EDIDs

2012-02-23 Thread Linus Torvalds
On Thu, Feb 23, 2012 at 1:36 PM, Eugeni Dodonov
 wrote:
>
> Perhaps a stupid question, but does you tree has
> http://cgit.freedesktop.org/~airlied/linux/commit/?h=drm-next&id=9292f37e1f5c79400254dca46f83313488093825
> from Dave's drm-next?
>
> If it has, it would be the 1st time that I see xrandr take longer than .5s
> with that patch on an Intel GPU. We even added a check for this into
> intel-gpu-tools to warn us if any machine takes that long, and none had hit
> it so far. So if this is the case here, there is something Mac Mini-specific
> indeed to investigate.

Yup, the tree I tested was current -git with the two commits mentioned
in this thread:

   drm: Reduce the number of retries whilst reading EDIDs
   drm: give up on edid retries when i2c bus is not responding

applied separately on top of it.

Linus


Re: [PATCH] drm: Reduce the number of retries whilst reading EDIDs

2012-02-23 Thread Linus Torvalds
On Thu, Feb 23, 2012 at 12:15 PM, Linus Torvalds
 wrote:
>
> Sadly, this doesn't seem to make any difference to my case. My xrandr
> stays at 0.555s even with this patch.

Btw, profiling with call chains seems to say that it all comes from
intel_sdvo_get_analog_edid() (about half from  intel_sdvo_get_modes()
and half from intel_sdvo_tmds_sink_detect()).

All called through drm_ioctl() -> drm_mode_getconnector() ->
drm_helper_probe_single_connector_modes().

Which I guess isn't anything interesting, but that
intel_sdvo_get_analog_edid() thing seems to be very much a Mac mini
hack. There's a comment about that in the sources too:

/*
 * Mac mini hack.  On this device, the DVI-I connector shares one DDC
 * link between analog and digital outputs. So, if the regular SDVO
 * DDC fails, check to see if the analog output is disconnected, in
 * which case we'll look there for the digital DDC data.
 */

and maybe that mac mini hack ends up interacting badly with something
else? I'll happily test patches if people have any ideas.

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


[PATCH] drm: Reduce the number of retries whilst reading EDIDs

2012-02-23 Thread Linus Torvalds
On Thu, Feb 23, 2012 at 12:15 PM, Linus Torvalds
 wrote:
>
> Sadly, this doesn't seem to make any difference to my case. My xrandr
> stays at 0.555s even with this patch.

Btw, profiling with call chains seems to say that it all comes from
intel_sdvo_get_analog_edid() (about half from  intel_sdvo_get_modes()
and half from intel_sdvo_tmds_sink_detect()).

All called through drm_ioctl() -> drm_mode_getconnector() ->
drm_helper_probe_single_connector_modes().

Which I guess isn't anything interesting, but that
intel_sdvo_get_analog_edid() thing seems to be very much a Mac mini
hack. There's a comment about that in the sources too:

/*
 * Mac mini hack.  On this device, the DVI-I connector shares one DDC
 * link between analog and digital outputs. So, if the regular SDVO
 * DDC fails, check to see if the analog output is disconnected, in
 * which case we'll look there for the digital DDC data.
 */

and maybe that mac mini hack ends up interacting badly with something
else? I'll happily test patches if people have any ideas.

  Linus


[PATCH 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Jerome Glisse
2012/2/23 Mathias Fr?hlich 

>
> Christian,
>
> On Thursday, February 23, 2012 15:18:42 Christian K?nig wrote:
> > The function radeon_bo_list_validate can cause a
> > bo to move, resulting in a different sync_obj
> > and a dependency to wait for this move to finish.
> >
> > Signed-off-by: Christian K?nig 
> > Reviewed-by: Alex Deucher 
>
> I am not sure, but to me this looks like this could fix these kind of gpu
> lockups that I experience since some time every now and then.
> The usual symptom is that I get the
>
> radeon :01:00.0: GPU lockup CP stall for more than 1msec
> GPU lockup (waiting for 0x00682AC3 last fence id 0x00682AC2)
> [...]
>
> kernel message. Each time with the fence being off by one like in the
> example
> above.
>
> If this change has the potential to fix this issue I think this particular
> patch should be considered for the current upstream kernel release.
>
> Mathias
>

No this patch doesn't. This patch is all about getting proper sync btw
different rings.

Sorry for the deception.

Cheers,
Jerome
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20120223/500a22cf/attachment.htm>


Re: [git pull] drm fixes

2012-02-23 Thread Torsten Kaiser
On Wed, Feb 22, 2012 at 8:56 PM, Dave Airlie  wrote:
> Eugeni Dodonov (4):
>      drm/i915: gen7: implement rczunit workaround
>      drm/i915: gen7: Implement an L3 caching workaround.
>      drm/i915: gen7: work around a system hang on IVB
>      drm/i915: do not enable RC6p on Sandy Bridge

That last patch about RC6p looks wrong.

It does:
 GEN6_RC_CTL_RC6_ENABLE |
(IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 0;
But I think this was meant:
 GEN6_RC_CTL_RC6_ENABLE |
((IS_GEN7(dev_priv->dev)) ? GEN6_RC_CTL_RC6p_ENABLE : 
0);

Or did I get the operator precedence wrong?

HTH

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


Re: [PATCH] drm: Reduce the number of retries whilst reading EDIDs

2012-02-23 Thread Linus Torvalds
On Thu, Feb 23, 2012 at 11:52 AM, Chris Wilson  wrote:
>
> i2c retries if sees an EGAIN, drm_do_probe_ddc_edid retries until it
> gets a result and *then* drm_do_get_edid retries until it gets a result
> it is happy with. All in all, that is a lot of processor intensive
> looping in cases where we do not expect and cannot get valid data - for
> example on Intel with disconnected hardware we will busy-spin until we
> hit the i2c timeout. This is then repeated for every connector when
> querying the current status of outputs.

Sadly, this doesn't seem to make any difference to my case. My xrandr
stays at 0.555s even with this patch.

So apparently the Apple Mac Mini issue is not about retries. But maybe
this fixes the problem Stephan Bärwolf reported?  The Apple Mac Mini
is known for doing things oddly, so ..

You didn't include Stephan on the cc for that patch, though.

Btw, clearly X does *not* cache the EDID results, at least not for
this case. So the explicit xrandr example is probably pretty close to
what wine does. Maybe the proper fix is to just make X.org force
caching when clients do this (because it's definitely X that does the
drm_mode_getconnector() thing - xrandr itself spends zero time on
this, it just does an X request and waits for the result).

The fact that EDID takes half a second to get is not a problem per se.
It's a problem only when X does it over and over again because some
client does something unexpected.

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


[PATCH] drm: Reduce the number of retries whilst reading EDIDs

2012-02-23 Thread Linus Torvalds
On Thu, Feb 23, 2012 at 11:52 AM, Chris Wilson  
wrote:
>
> i2c retries if sees an EGAIN, drm_do_probe_ddc_edid retries until it
> gets a result and *then* drm_do_get_edid retries until it gets a result
> it is happy with. All in all, that is a lot of processor intensive
> looping in cases where we do not expect and cannot get valid data - for
> example on Intel with disconnected hardware we will busy-spin until we
> hit the i2c timeout. This is then repeated for every connector when
> querying the current status of outputs.

Sadly, this doesn't seem to make any difference to my case. My xrandr
stays at 0.555s even with this patch.

So apparently the Apple Mac Mini issue is not about retries. But maybe
this fixes the problem Stephan B?rwolf reported?  The Apple Mac Mini
is known for doing things oddly, so ..

You didn't include Stephan on the cc for that patch, though.

Btw, clearly X does *not* cache the EDID results, at least not for
this case. So the explicit xrandr example is probably pretty close to
what wine does. Maybe the proper fix is to just make X.org force
caching when clients do this (because it's definitely X that does the
drm_mode_getconnector() thing - xrandr itself spends zero time on
this, it just does an X request and waits for the result).

The fact that EDID takes half a second to get is not a problem per se.
It's a problem only when X does it over and over again because some
client does something unexpected.

  Linus


[PATCH] drm: drop setting vm_file to filp

2012-02-23 Thread Dave Airlie
On Thu, Feb 23, 2012 at 11:42 AM, Dave Airlie  wrote:
> From: Dave Airlie 
>
> Talking to Al Viro on irc, we can see no possible reason for doing
> this, the upper mmap code does it. The code has been there since
> first import into drm tree I can find.
>
> Of course it probably means this will crash and burn.

Al tracked down the core vm changed in 2.3.51pre1 so this should be safe now :-)

Dave.


[PATCH 2/4] drm/radeon/kms: no need to align IB like this

2012-02-23 Thread Jerome Glisse
2012/2/23 Christian K?nig 

> So don't confuse devs by doing so.
>
> Signed-off-by: Christian K?nig 
> ---
>  drivers/gpu/drm/radeon/r600.c |   15 +--
>  1 files changed, 1 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
> index 4f08e5e..4a4ac8f 100644
> --- a/drivers/gpu/drm/radeon/r600.c
> +++ b/drivers/gpu/drm/radeon/r600.c
> @@ -2719,20 +2719,7 @@ int r600_ib_test(struct radeon_device *rdev, int
> ring)
>ib->ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1);
>ib->ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
>ib->ptr[2] = 0xDEADBEEF;
> -   ib->ptr[3] = PACKET2(0);
> -   ib->ptr[4] = PACKET2(0);
> -   ib->ptr[5] = PACKET2(0);
> -   ib->ptr[6] = PACKET2(0);
> -   ib->ptr[7] = PACKET2(0);
> -   ib->ptr[8] = PACKET2(0);
> -   ib->ptr[9] = PACKET2(0);
> -   ib->ptr[10] = PACKET2(0);
> -   ib->ptr[11] = PACKET2(0);
> -   ib->ptr[12] = PACKET2(0);
> -   ib->ptr[13] = PACKET2(0);
> -   ib->ptr[14] = PACKET2(0);
> -   ib->ptr[15] = PACKET2(0);
> -   ib->length_dw = 16;
> +   ib->length_dw = 3;
>r = radeon_ib_schedule(rdev, ib);
>if (r) {
>radeon_scratch_free(rdev, scratch);
> --
> 1.7.5.4
>

You sure about that ? I remember this helped with GPU lockup and i also
seen fglrx aligning IB.

Cheers,
Jerome
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20120223/f5977310/attachment.htm>


[PULL] drm-intel-next

2012-02-23 Thread Daniel Vetter
Hi Dave,

New pull request for drm-intel-next, this time with a backmerge from
-fixes to sort out a few things.

Highlights:
- interlaced support for i915. Again thanks a lot to all the ppl who help
  out with testing, patches and doc-crawling.
- aliasing ppgtt support for snb/ivb. Because ppgtt ptes are
  gpu-cacheable, this can also speed things up a bit.
- swizzling support for snb/ivb, again a slight perf improvements on some
  things.
- more error_state work - we're slowly reaching a level of paranoia
  suitable for dealing with gpus.
- outstanding_lazy_request fix and the autoreport patches from Chris: I'm
  pretty hopefully that these two squash a lot of the semaphores=1 issues
  we've seen on snb, please retest if you've had issues.
- the usual pile of minor patches, one noteworthy one is to use the lvds
  presence pin on pch_split chips. I expect a few new quirks due to this
  ...

Our QA reported a funky missed IRQ issue on snb, but strangely they claim
that it has not been introduced by enabling the forcewake voodoo on snb
(and disabling the old hwstam workaround). Investigation is still ongoing,
but the usual set of workarounds (reinstating hwstam or the cs register
readback) are all confirmed to still work. So I don't think we should
stall just because of this.

Otherwise now new issues for this reported. QA report as usual below the
pull request. Note that I've had to manually frob the shortlog to not
include any patches already merged into -next, -fixes or Linus' upstream.

The following changes since commit 28a4d5675857f6386930a324317281cb8ed1e5d0:

  Merge branch 'drm-intel-fixes' of 
git://git.kernel.org/pub/scm/linux/kernel/git/keithp/linux into drm-fixes 
(2012-02-10 08:35:19 +)

are available in the git repository at:


  git://people.freedesktop.org/~danvet/drm-intel tags/drm-intel-next-2012-02-16

for you to fetch changes up to de67cba65944f26c0f147035bd62e30c5f456b96:

  Revert "drivers/gpu/drm/i915/intel_overlay.c needs seq_file.h" (2012-02-16 
10:31:23 +0100)

Ben Widawsky (3):
  drm/i915: use gtfifodbg
  drm/i915: catch gtfifo errors on forcewake_put
  drm/i915: check gtfifodbg after possibly failed writes

Chris Wilson (4):
  drm/i915: Record the tail at each request and use it to estimate the head
  drm/i915: Record the in-flight requests at the time of a hang
  drm/i915: Record the position of the request upon error
  drm/i915/lvds: Always use the presence pin for LVDS on PCH

Daniel Vetter (24):
  drm/i915: swizzling support for snb/ivb
  drm/i915: consolidate swizzling control bit frobbing
  drm/i915: add gen6+ registers to i915_swizzle_info
  drm/i915: s/DRM_ERROR/DRM_DEBUG in i915_gem_execbuffer.c
  drm/i915: dump even more into the error_state
  agp/intel-gtt: export the scratch page dma address
  agp/intel-gtt: export the gtt pagetable iomapping
  drm/i915: initialization/teardown for the aliasing ppgtt
  drm/i915: ppgtt binding/unbinding support
  drm/i915: ppgtt register definitions
  drm/i915: ppgtt debugfs info
  drm/i915: enable ppgtt
  Merge remote-tracking branch 'airlied/drm-fixes' into 
drm-intel-next-queued
  drm/i915: clean up interlaced pipeconf bit definitions
  drm/i915: fixup interlaced vertical timings confusion, part 1
  drm/i915: fixup interlaced vertical timings confusion, part 2
  drm/i915: fixup interlaced support on ilk+
  drm/i915: don't allow interlaced pipeconf on gen2
  drm/i915: correctly program the VSYNCSHIFT register
  drm/i915: fixup overlay checks for interlaced modes
  drm/i915: outstanding_lazy_request is a u32
  drm/i915: fixup seqno allocation logic for lazy_request
  drm/i915: enable forcewake voodoo also for gen6
  drm/i915: fix up locking inconsistency around gem_do_init

Danny Kukawka (1):
  Revert "drivers/gpu/drm/i915/intel_overlay.c needs seq_file.h"

Paulo Zanoni (2):
  drm/i915: set interlaced bits for TRANSCONF
  drm/i915: add missing SDVO bits for interlaced modes on ILK

Peter Ross (2):
  drm/i915: allow interlaced mode output on the SDVO connector
  drm/i915: allow interlaced mode output on the HDMI connector

Sean Paul (1):
  drm/i915: Don't lock panel registers when downclocking

Wu Fengguang (1):
  drm/i915: add a "force-dvi" HDMI audio mode

Yufeng Shen (1):
  drm/i915: Fix race condition in accessing GMBUS

On Tue, Feb 21, 2012 at 07:45:57AM +, Sun, Yi wrote:
> A new round of Kernel testing is finished. We covered the platforms 
> IvyBridge, SandyBridge, IronLake, G33 and PineView.
> We use the latest version on drm-intel-testing branch:
> Kernel: (drm-intel-testing)de67cba65944f26c0f147035bd62e30c5f456b96
> Some additional commit info:
> Author: Danny Kukawka 
> Date:   Wed Feb 15 18:53:55 2012 +0100
> 
> Revert "drivers/gpu/drm/i915/intel_overlay.c needs seq_file.h"
> 
> In this round of testing, no new bugs are found. 
> And one bug is fixed by the p

[PATCH] drm: Reduce the number of retries whilst reading EDIDs

2012-02-23 Thread Chris Wilson
i2c retries if sees an EGAIN, drm_do_probe_ddc_edid retries until it
gets a result and *then* drm_do_get_edid retries until it gets a result
it is happy with. All in all, that is a lot of processor intensive
looping in cases where we do not expect and cannot get valid data - for
example on Intel with disconnected hardware we will busy-spin until we
hit the i2c timeout. This is then repeated for every connector when
querying the current status of outputs.

So to improve the situation, we can trim the number of retries for
reading the base block and to check for a reschedule before proceeding
so that we do not hog the machine whilst probing outputs. (Though since
we will be likely blocking the graphics device, the user is still going
to notice the latency.)

Reported-by: Linus Torvalds 
Reported-by: Stephan Bärwolf 
Signed-off-by: Chris Wilson 
Cc: Eugeni Dodonov 
Cc: Dave Airlie 
Cc: Alex Deucher 
---
 drivers/gpu/drm/drm_edid.c |   30 +++---
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index ece03fc..4409cd4 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -35,6 +35,9 @@
 #include "drm_edid.h"
 #include "drm_edid_modes.h"
 
+#define EDID_PROBE_RETRIES 1
+#define EDID_READ_RETRIES 5
+
 #define version_greater(edid, maj, min) \
(((edid)->version > (maj)) || \
 ((edid)->version == (maj) && (edid)->revision > (min)))
@@ -239,11 +242,12 @@ EXPORT_SYMBOL(drm_edid_is_valid);
  * Try to fetch EDID information by calling i2c driver function.
  */
 static int
-drm_do_probe_ddc_edid(struct i2c_adapter *adapter, unsigned char *buf,
- int block, int len)
+drm_get_edid_block(struct i2c_adapter *adapter,
+  unsigned char *buf, int block, int len,
+  int retries)
 {
unsigned char start = block * EDID_LENGTH;
-   int ret, retries = 5;
+   int ret;
 
/* The core i2c driver will automatically retry the transfer if the
 * adapter reports EAGAIN. However, we find that bit-banging transfers
@@ -293,7 +297,19 @@ drm_do_get_edid(struct drm_connector *connector, struct 
i2c_adapter *adapter)
 
/* base block fetch */
for (i = 0; i < 4; i++) {
-   if (drm_do_probe_ddc_edid(adapter, block, 0, EDID_LENGTH))
+   /* EDID transfer may be quite processor intensive and last
+* a long time. For example, when waiting for a timeout on
+* a non-existent connector whilst using bit-banging. As a
+* result we can end up hogging the machine, so give someone
+* else the chance to run first. But when we have started a
+* transfer don't interrupt until finished.
+*/
+   if (need_resched())
+   schedule();
+
+   if (drm_get_edid_block(adapter,
+  block, 0, EDID_LENGTH,
+  EDID_PROBE_RETRIES))
goto out;
if (drm_edid_block_valid(block))
break;
@@ -316,9 +332,9 @@ drm_do_get_edid(struct drm_connector *connector, struct 
i2c_adapter *adapter)
 
for (j = 1; j <= block[0x7e]; j++) {
for (i = 0; i < 4; i++) {
-   if (drm_do_probe_ddc_edid(adapter,
+   if (drm_get_edid_block(adapter,
  block + (valid_extensions + 1) * EDID_LENGTH,
- j, EDID_LENGTH))
+ j, EDID_LENGTH, EDID_READ_RETRIES))
goto out;
if (drm_edid_block_valid(block + (valid_extensions + 1) 
* EDID_LENGTH)) {
valid_extensions++;
@@ -362,7 +378,7 @@ drm_probe_ddc(struct i2c_adapter *adapter)
 {
unsigned char out;
 
-   return (drm_do_probe_ddc_edid(adapter, &out, 0, 1) == 0);
+   return drm_get_edid_block(adapter, &out, 0, 1, EDID_PROBE_RETRIES) == 0;
 }
 
 /**
-- 
1.7.9.1

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


[PATCH] drm: drop setting vm_file to filp

2012-02-23 Thread Dave Airlie
From: Dave Airlie 

Talking to Al Viro on irc, we can see no possible reason for doing
this, the upper mmap code does it. The code has been there since
first import into drm tree I can find.

Of course it probably means this will crash and burn.

Cc: Al Viro 
Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/drm_gem.c   |1 -
 drivers/gpu/drm/drm_vm.c|2 --
 drivers/gpu/drm/exynos/exynos_drm_gem.c |1 -
 drivers/gpu/drm/i810/i810_dma.c |1 -
 4 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index f8625e2..3ebe3c8 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -700,7 +700,6 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct 
*vma)
 */
drm_gem_object_reference(obj);

-   vma->vm_file = filp;/* Needed for drm_vm_open() */
drm_vm_open_locked(vma);

 out_unlock:
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 8c03eaf..55cd615 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -519,7 +519,6 @@ static int drm_mmap_dma(struct file *filp, struct 
vm_area_struct *vma)
vma->vm_flags |= VM_RESERVED;   /* Don't swap */
vma->vm_flags |= VM_DONTEXPAND;

-   vma->vm_file = filp;/* Needed for drm_vm_open() */
drm_vm_open_locked(vma);
return 0;
 }
@@ -671,7 +670,6 @@ int drm_mmap_locked(struct file *filp, struct 
vm_area_struct *vma)
vma->vm_flags |= VM_RESERVED;   /* Don't swap */
vma->vm_flags |= VM_DONTEXPAND;

-   vma->vm_file = filp;/* Needed for drm_vm_open() */
drm_vm_open_locked(vma);
return 0;
 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c 
b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 025abb3..6545251 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -208,7 +208,6 @@ static int exynos_drm_gem_mmap_buffer(struct file *filp,

/* in case of direct mapping, always having non-cachable attribute */
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-   vma->vm_file = filp;

vm_size = vma->vm_end - vma->vm_start;
/*
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 7f4b4e1..b4c1eca 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -99,7 +99,6 @@ static int i810_mmap_buffers(struct file *filp, struct 
vm_area_struct *vma)
buf_priv = buf->dev_private;

vma->vm_flags |= (VM_IO | VM_DONTCOPY);
-   vma->vm_file = filp;

buf_priv->currently_mapped = I810_BUF_MAPPED;

-- 
1.7.7.6



Re: [Linaro-mm-sig] [PATCH 6/7] drm/vgem: import support

2012-02-23 Thread Chris Wilson
On Wed, 22 Feb 2012 20:29:19 +0100, Ben Widawsky  wrote:
> dma-buf import support. The function definitely needs some cleanup.
> 
> When reading through this code, there are 3 cases to consider:
> 1. vgem exporter, vgem importer, same fd
> 2. vgem exporter, vgem importer, different fd
> 3. X expoter, vgem importer - not yet tested
> 
> See the comments in the code for detailed explanation.
> 
> Cc: Daniel Vetter 
> Cc: Dave Airlie 
> Signed-off-by: Ben Widawsky 
> ---
>  drivers/gpu/drm/vgem/vgem_dma_buf.c |  120 
> +++
>  1 files changed, 120 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vgem/vgem_dma_buf.c 
> b/drivers/gpu/drm/vgem/vgem_dma_buf.c
> index eca9445..92c1823 100644
> --- a/drivers/gpu/drm/vgem/vgem_dma_buf.c
> +++ b/drivers/gpu/drm/vgem/vgem_dma_buf.c
> @@ -120,9 +120,129 @@ out_fd:
>   return 0;
>  }
>  
> +/*
> + * Convert a dma-buf fd to a drm object handle, creating new object/handle as
> + * needed.
> + *
> + * There are 2 "interesting" cases we have to consider. The other, less 
> interesting
> + * case is when importer == exporter, and drm_files are the same.
> + * vgem exporter
> + *   The original exporter may or may not still hold a reference to the
> + *   object by the time we reach here. Once we get a dma_buf reference though
> + *   we know the original object cannot go away. Next we grab the prime mutex
> + *   to prevent our lists from being screwed up from under us. We should next
> + *   find the object in our global dma_buf hash. To make everything cool
> + *   though we need to
> + * create a handle for the importer
> + * add the handle to the per file list
> + * drop the dma_buf reference
> + *   the object can't go away due to us owning a file handle for it.
> + *   In the end there should be 2 handle references, and 1 dma-buf reference.
> + *
> + * other exporter
> + *   This case is very similar to the previous one. The primary difference 
> is we
> + *   do not want to drop the dma_buf reference since we know nothing about 
> the
> + *   reference counting from the exporter. So instead, we hold the dma_buf
> + *   reference, but can drop the object reference. In the end of this case 
> there
> + *   should be 1 handle reference, and 1 dma-buf reference.
> + */
>  int vgem_prime_to_handle(struct drm_device *dev,
>struct drm_file *file, int prime_fd,
>uint32_t *handle)
>  {
> + struct drm_vgem_file_private *file_priv = file->driver_priv;
> + struct drm_vgem_gem_object *vobj = NULL;
> + struct drm_gem_object *obj = NULL;
> + struct dma_buf *dma_buf;
> + struct dma_buf_attachment *attach = NULL;
> + struct sg_table *sg = NULL;
> + bool drop_dma_buf_ref = false;
> + int ret;
> +
> + dma_buf = dma_buf_get(prime_fd);
> + if (IS_ERR(dma_buf))
> + return PTR_ERR(dma_buf);
> +
> + mutex_lock(&dev->prime_mutex);
> + /* First check that we don't dup on this file */
> + ret = drm_prime_lookup_fd_handle_mapping(&file_priv->prime, dma_buf,
> +  handle);
> + if (ret == 0) {
> + DRM_DEBUG_PRIME("file_priv has an object for this dma_buf\n");
> + dma_buf_put(dma_buf);
> + mutex_unlock(&dev->prime_mutex);
> + return 0;
> + }
> +
> + /* Now check if we've already created/imported this object */
> + ret = drm_prime_lookup_obj(dev, dma_buf, &obj);
> + if (ret == 0 && obj != NULL) {
> + DRM_DEBUG_PRIME("driver has an object for this dma_buf\n");
> + drop_dma_buf_ref = true;
> + vobj = to_vgem_bo(obj);
> + goto handle_create;
> + }
> +
> + DRM_DEBUG_PRIME("Creating a new object for dma_buf\n");
> +
> + attach = dma_buf_attach(dma_buf, dev->dev);
> + if (IS_ERR(attach)) {
> + ret = PTR_ERR(attach);
> + goto fail_put;
> + }
> +
> + sg = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
> + if (IS_ERR(sg)) {
> + ret = PTR_ERR(sg);
> + goto fail_detach;
> + }
> +
> + vobj = kzalloc(sizeof(*vobj), GFP_KERNEL);
> + if (vobj == NULL) {
> + ret = -ENOMEM;
> + goto fail_unmap;
> + }
> +
> + /* As a result of this mmap will not work -yet- */
> + ret = drm_gem_private_object_init(dev, &vobj->base, dma_buf->size);
> + if (ret) {
> + kfree(vobj);
> + ret = -ENOMEM;
> + goto fail_unmap;
> + }
> +
> + obj = &vobj->base;
Don't we need to store the backing attachment and prime_fd on the newly
created vgem obj?

> +
> +handle_create:
> + ret = drm_gem_handle_create(file, obj, handle);
> + if (ret)
> + return ret;
> +
> + ret = drm_prime_insert_fd_handle_mapping(&file_priv->prime,
> +  dma_buf, *handle);
> + if (ret)
> + g

Re: [Linaro-mm-sig] [PATCH 5/7] drm/vgem: prime export support

2012-02-23 Thread Chris Wilson
On Wed, 22 Feb 2012 20:29:18 +0100, Ben Widawsky  wrote:
> dma-buf export implementation. Heavily influenced by Dave Airlie's proof
> of concept work.
> 
> Cc: Daniel Vetter 
> Cc: Dave Airlie 
> Signed-off-by: Ben Widawsky 
> ---
>  drivers/gpu/drm/vgem/Makefile   |2 +-
>  drivers/gpu/drm/vgem/vgem_dma_buf.c |  128 
> +++
>  drivers/gpu/drm/vgem/vgem_drv.c |6 ++
>  drivers/gpu/drm/vgem/vgem_drv.h |7 ++
>  4 files changed, 142 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/gpu/drm/vgem/vgem_dma_buf.c
> 
> diff --git a/drivers/gpu/drm/vgem/Makefile b/drivers/gpu/drm/vgem/Makefile
> index 3f4c7b8..1055cb7 100644
> --- a/drivers/gpu/drm/vgem/Makefile
> +++ b/drivers/gpu/drm/vgem/Makefile
> @@ -1,4 +1,4 @@
>  ccflags-y := -Iinclude/drm
> -vgem-y := vgem_drv.o
> +vgem-y := vgem_drv.o vgem_dma_buf.o
>  
>  obj-$(CONFIG_DRM_VGEM)   += vgem.o
> diff --git a/drivers/gpu/drm/vgem/vgem_dma_buf.c 
> b/drivers/gpu/drm/vgem/vgem_dma_buf.c
> new file mode 100644
> index 000..eca9445
> --- /dev/null
> +++ b/drivers/gpu/drm/vgem/vgem_dma_buf.c
> @@ -0,0 +1,128 @@
> +/*
> + * Copyright © 2012 Intel Corporation
> + *
> + * 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
> + * THE AUTHORS OR COPYRIGHT HOLDERS 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.
> + *
> + * Authors:
> + *Ben Widawsky 
> + *
> + */
> +
> +#include 
> +#include "vgem_drv.h"
> +
> +#define VGEM_FD_PERMS 0600
> +
> +struct sg_table *vgem_gem_map_dma_buf(struct dma_buf_attachment *attachment,
> +  enum dma_data_direction dir)
I guess I'm just not quite happy with the dma-buf interface, but I'd
have liked to have avoided the whole sg_table allocation and have made
the dma_buf embeddable. Daniel is slacking!

> +int vgem_prime_to_fd(struct drm_device *dev, struct drm_file *file,
> +  uint32_t handle, int *prime_fd)
> +{
> + struct drm_vgem_file_private *file_priv = file->driver_priv;
> + struct drm_vgem_gem_object *obj;
> + int ret;
> +
> + DRM_DEBUG_PRIME("Request fd for handle %d\n", handle);
> +
> + obj = to_vgem_bo(drm_gem_object_lookup(dev, file, handle));
> + if (!obj)
> + return -EBADF;
-ENOENT; EBADF is for reporting that ioctl was itself called on an invalid fd.

locking fail.

> + /* This means a user has already called get_fd on this */
> + if (obj->base.prime_fd != -1) {
> + DRM_DEBUG_PRIME("User requested a previously exported buffer "
> + "%d %d\n", handle, obj->base.prime_fd);
> + drm_gem_object_unreference(&obj->base);
> + goto out_fd;
> + }
> +
> + /* Make a dma buf out of our vgem object */
> + obj->base.export_dma_buf = dma_buf_export(obj, &vgem_dmabuf_ops,
> +   obj->base.size,
> +   VGEM_FD_PERMS);
locking fail.

> + if (IS_ERR(obj->base.export_dma_buf)) {
> + DRM_DEBUG_PRIME("export fail\n");
> + return PTR_ERR(obj->base.export_dma_buf);
> + } else
> + obj->base.prime_fd = dma_buf_fd(obj->base.export_dma_buf);
locking fail... ;-)

> +
> + mutex_lock(&dev->prime_mutex);
Per-device mutex for a per-file hash-table?

> + ret = drm_prime_insert_fd_handle_mapping(&file_priv->prime,
> +  obj->base.export_dma_buf,
> +  handle);
> + WARN_ON(ret);
> + ret = drm_prime_add_dma_buf(dev, &obj->base);
> + mutex_unlock(&dev->prime_mutex);
> + if (ret)
> + return ret;
> +
> +out_fd:
> + *prime_fd = obj->base.prime_fd;
> +
> + return 0;
> +}
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/

Re: [PATCH 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Christian König

On 23.02.2012 18:32, Jerome Glisse wrote:
2012/2/23 Mathias Fröhlich >



Christian,

On Thursday, February 23, 2012 15:18:42 Christian König wrote:
> The function radeon_bo_list_validate can cause a
> bo to move, resulting in a different sync_obj
> and a dependency to wait for this move to finish.
>
> Signed-off-by: Christian König mailto:deathsim...@vodafone.de>>
> Reviewed-by: Alex Deucher mailto:alexander.deuc...@amd.com>>

I am not sure, but to me this looks like this could fix these kind
of gpu
lockups that I experience since some time every now and then.
The usual symptom is that I get the

radeon :01:00.0: GPU lockup CP stall for more than 1msec
GPU lockup (waiting for 0x00682AC3 last fence id 0x00682AC2)
[...]

kernel message. Each time with the fence being off by one like in
the example
above.

If this change has the potential to fix this issue I think this
particular
patch should be considered for the current upstream kernel release.

Mathias


No this patch doesn't. This patch is all about getting proper sync btw 
different rings.
That's unfortunately true, since we wasn't able to release any code that 
makes direct use of the different rings (yet) it shouldn't really matter 
in practice. I Just wanted to have that fix upstream since it is an 
obvious bug.


Christian.


Sorry for the deception.

Cheers,
Jerome


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


Re: [PATCH 2/4] drm/radeon/kms: no need to align IB like this

2012-02-23 Thread Christian König

On 23.02.2012 18:00, Jerome Glisse wrote:


2012/2/23 Christian König >


So don't confuse devs by doing so.

Signed-off-by: Christian König mailto:deathsim...@vodafone..de>>
---
 drivers/gpu/drm/radeon/r600.c |   15 +--
 1 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r600.c
b/drivers/gpu/drm/radeon/r600.c
index 4f08e5e..4a4ac8f 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2719,20 +2719,7 @@ int r600_ib_test(struct radeon_device
*rdev, int ring)
   ib->ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1);
   ib->ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
   ib->ptr[2] = 0xDEADBEEF;
-   ib->ptr[3] = PACKET2(0);
-   ib->ptr[4] = PACKET2(0);
-   ib->ptr[5] = PACKET2(0);
-   ib->ptr[6] = PACKET2(0);
-   ib->ptr[7] = PACKET2(0);
-   ib->ptr[8] = PACKET2(0);
-   ib->ptr[9] = PACKET2(0);
-   ib->ptr[10] = PACKET2(0);
-   ib->ptr[11] = PACKET2(0);
-   ib->ptr[12] = PACKET2(0);
-   ib->ptr[13] = PACKET2(0);
-   ib->ptr[14] = PACKET2(0);
-   ib->ptr[15] = PACKET2(0);
-   ib->length_dw = 16;
+   ib->length_dw = 3;
   r = radeon_ib_schedule(rdev, ib);
   if (r) {
   radeon_scratch_free(rdev, scratch);
--
1.7.5.4


You sure about that ? I remember this helped with GPU lockup and i 
also seen fglrx aligning IB.
Yeah, pretty much. Well I searched for halve an hour for the 
corresponding IB alignment in mesa/the CS ioctl until I finally figured 
out that there isn't any.


So IBs submitted by usermode aren't aligned in any way So it really 
seems to work fine and I couldn't find any reason why we should align an 
IB for the GFX ring in our docs also.


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


[PATCH 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Alex Deucher
2012/2/23 Christian K?nig :
> The function radeon_bo_list_validate can cause a
> bo to move, resulting in a different sync_obj
> and a dependency to wait for this move to finish.
>
> Signed-off-by: Christian K?nig 
> Reviewed-by: Alex Deucher 

For the series:

Reviewed-by: Alex Deucher 

> ---
> ?drivers/gpu/drm/radeon/radeon.h ? ?| ? ?1 -
> ?drivers/gpu/drm/radeon/radeon_cs.c | ? 21 ++---
> ?2 files changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index 884e0d4..4c1b981 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -836,7 +836,6 @@ struct radeon_cs_parser {
> ? ? ? ?struct radeon_cs_reloc ?*relocs;
> ? ? ? ?struct radeon_cs_reloc ?**relocs_ptr;
> ? ? ? ?struct list_head ? ? ? ?validated;
> - ? ? ? bool ? ? ? ? ? ? ? ? ? ?sync_to_ring[RADEON_NUM_RINGS];
> ? ? ? ?/* indices of various chunks */
> ? ? ? ?int ? ? ? ? ? ? ? ? ? ? chunk_ib_idx;
> ? ? ? ?int ? ? ? ? ? ? ? ? ? ? chunk_relocs_idx;
> diff --git a/drivers/gpu/drm/radeon/radeon_cs.c 
> b/drivers/gpu/drm/radeon/radeon_cs.c
> index 435a3d9..7fd0987 100644
> --- a/drivers/gpu/drm/radeon/radeon_cs.c
> +++ b/drivers/gpu/drm/radeon/radeon_cs.c
> @@ -85,12 +85,6 @@ int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
> ? ? ? ? ? ? ? ? ? ? ? ?radeon_bo_list_add_object(&p->relocs[i].lobj,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?&p->validated);
>
> - ? ? ? ? ? ? ? ? ? ? ? if (p->relocs[i].robj->tbo.sync_obj && !(r->flags & 
> RADEON_RELOC_DONT_SYNC)) {
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? struct radeon_fence *fence = 
> p->relocs[i].robj->tbo.sync_obj;
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if (!radeon_fence_signaled(fence)) {
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? p->sync_to_ring[fence->ring] = true;
> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
> - ? ? ? ? ? ? ? ? ? ? ? }
> ? ? ? ? ? ? ? ?} else
> ? ? ? ? ? ? ? ? ? ? ? ?p->relocs[i].handle = 0;
> ? ? ? ?}
> @@ -118,11 +112,24 @@ static int radeon_cs_get_ring(struct radeon_cs_parser 
> *p, u32 ring, s32 priority
>
> ?static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
> ?{
> + ? ? ? bool sync_to_ring[RADEON_NUM_RINGS] = { };
> ? ? ? ?int i, r;
>
> + ? ? ? for (i = 0; i < p->nrelocs; i++) {
> + ? ? ? ? ? ? ? if (!p->relocs[i].robj || !p->relocs[i].robj->tbo.sync_obj)
> + ? ? ? ? ? ? ? ? ? ? ? continue;
> +
> + ? ? ? ? ? ? ? if (!(p->relocs[i].flags & RADEON_RELOC_DONT_SYNC)) {
> + ? ? ? ? ? ? ? ? ? ? ? struct radeon_fence *fence = 
> p->relocs[i].robj->tbo.sync_obj;
> + ? ? ? ? ? ? ? ? ? ? ? if (!radeon_fence_signaled(fence)) {
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? sync_to_ring[fence->ring] = true;
> + ? ? ? ? ? ? ? ? ? ? ? }
> + ? ? ? ? ? ? ? }
> + ? ? ? }
> +
> ? ? ? ?for (i = 0; i < RADEON_NUM_RINGS; ++i) {
> ? ? ? ? ? ? ? ?/* no need to sync to our own or unused rings */
> - ? ? ? ? ? ? ? if (i == p->ring || !p->sync_to_ring[i] || 
> !p->rdev->ring[i].ready)
> + ? ? ? ? ? ? ? if (i == p->ring || !sync_to_ring[i] || 
> !p->rdev->ring[i].ready)
> ? ? ? ? ? ? ? ? ? ? ? ?continue;
>
> ? ? ? ? ? ? ? ?if (!p->ib->fence->semaphore) {
> --
> 1.7.5.4
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/radeon/kms: add htile support to the cs checker v2

2012-02-23 Thread Alex Deucher
On Wed, Feb 22, 2012 at 5:28 PM,   wrote:
> From: Jerome Glisse 
>
> For 6xx+. ?Required for mesa to use htile support for HiZ/HiS.
> Userspace will check radeon version 2.14 with is bumped either
> by tiling patch or stream out patch. This patch only add support
> for htile relocation which should be enough for any userspace
> to implement the hyperz (using htile buffer) feature.
>
> v2: Jerome: Fix size checking for htile buffer.
>
> Signed-off-by: Pierre-Eric Pelloux-Prayer 
> Signed-off-by: Alex Deucher 
> Signed-off-by: Jerome Glisse 


Reviewed-by: Alex Deucher 

> ---
> ?drivers/gpu/drm/radeon/evergreen_cs.c ? ? | ? 78 ++-
> ?drivers/gpu/drm/radeon/evergreend.h ? ? ? | ? ?8 +
> ?drivers/gpu/drm/radeon/r600_cs.c ? ? ? ? ?| ?379 
> -
> ?drivers/gpu/drm/radeon/r600d.h ? ? ? ? ? ?| ? ?8 +
> ?drivers/gpu/drm/radeon/reg_srcs/cayman ? ?| ? ?1 -
> ?drivers/gpu/drm/radeon/reg_srcs/evergreen | ? ?1 -
> ?drivers/gpu/drm/radeon/reg_srcs/r600 ? ? ?| ? ?1 -
> ?7 files changed, 360 insertions(+), 116 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c 
> b/drivers/gpu/drm/radeon/evergreen_cs.c
> index 2ed17f7..54a320a 100644
> --- a/drivers/gpu/drm/radeon/evergreen_cs.c
> +++ b/drivers/gpu/drm/radeon/evergreen_cs.c
> @@ -85,6 +85,9 @@ struct evergreen_cs_track {
> ? ? ? ?u32 ? ? ? ? ? ? ? ? ? ? db_s_write_offset;
> ? ? ? ?struct radeon_bo ? ? ? ?*db_s_read_bo;
> ? ? ? ?struct radeon_bo ? ? ? ?*db_s_write_bo;
> + ? ? ? u32 ? ? ? ? ? ? ? ? ? ? htile_offset;
> + ? ? ? u32 ? ? ? ? ? ? ? ? ? ? htile_surface;
> + ? ? ? struct radeon_bo ? ? ? ?*htile_bo;
> ?};
>
> ?static u32 evergreen_cs_get_aray_mode(u32 tiling_flags)
> @@ -155,6 +158,9 @@ static void evergreen_cs_track_init(struct 
> evergreen_cs_track *track)
> ? ? ? ?track->db_s_write_offset = 0x;
> ? ? ? ?track->db_s_read_bo = NULL;
> ? ? ? ?track->db_s_write_bo = NULL;
> + ? ? ? track->htile_bo = NULL;
> + ? ? ? track->htile_offset = 0x;
> + ? ? ? track->htile_surface = 0;
>
> ? ? ? ?for (i = 0; i < 4; i++) {
> ? ? ? ? ? ? ? ?track->vgt_strmout_size[i] = 0;
> @@ -627,6 +633,62 @@ static int evergreen_cs_track_validate_depth(struct 
> radeon_cs_parser *p)
> ? ? ? ? ? ? ? ?return -EINVAL;
> ? ? ? ?}
>
> + ? ? ? /* hyperz */
> + ? ? ? if (G_028040_TILE_SURFACE_ENABLE(track->db_z_info)) {
> + ? ? ? ? ? ? ? unsigned long size;
> + ? ? ? ? ? ? ? unsigned nbx, nby;
> +
> + ? ? ? ? ? ? ? if (track->htile_bo == NULL) {
> + ? ? ? ? ? ? ? ? ? ? ? dev_warn(p->dev, "%s:%d htile enabled without htile 
> surface 0x%08x\n",
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?__func__, __LINE__, track->db_z_info);
> + ? ? ? ? ? ? ? ? ? ? ? return -EINVAL;
> + ? ? ? ? ? ? ? }
> +
> + ? ? ? ? ? ? ? nbx = surf.nbx;
> + ? ? ? ? ? ? ? nby = surf.nby;
> + ? ? ? ? ? ? ? if (G_028ABC_LINEAR(track->htile_surface)) {
> + ? ? ? ? ? ? ? ? ? ? ? /* pitch must be 16 htiles aligned == 16 * 8 pixel 
> aligned */
> + ? ? ? ? ? ? ? ? ? ? ? nbx = round_up(nbx, 16 * 8);
> + ? ? ? ? ? ? ? ? ? ? ? /* height is npipes htiles aligned == npipes * 8 
> pixel aligned */
> + ? ? ? ? ? ? ? ? ? ? ? nby = round_up(nby, track->npipes * 8);
> + ? ? ? ? ? ? ? } else {
> + ? ? ? ? ? ? ? ? ? ? ? switch (track->npipes) {
> + ? ? ? ? ? ? ? ? ? ? ? case 8:
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? nbx = round_up(nbx, 64 * 8);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? nby = round_up(nby, 64 * 8);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
> + ? ? ? ? ? ? ? ? ? ? ? case 4:
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? nbx = round_up(nbx, 64 * 8);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? nby = round_up(nby, 32 * 8);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
> + ? ? ? ? ? ? ? ? ? ? ? case 2:
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? nbx = round_up(nbx, 32 * 8);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? nby = round_up(nby, 32 * 8);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
> + ? ? ? ? ? ? ? ? ? ? ? case 1:
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? nbx = round_up(nbx, 32 * 8);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? nby = round_up(nby, 16 * 8);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;
> + ? ? ? ? ? ? ? ? ? ? ? default:
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? dev_warn(p->dev, "%s:%d invalid num pipes 
> %d\n",
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?__func__, __LINE__, track->npipes);
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return -EINVAL;
> + ? ? ? ? ? ? ? ? ? ? ? }
> + ? ? ? ? ? ? ? }
> + ? ? ? ? ? ? ? /* compute number of htile */
> + ? ? ? ? ? ? ? nbx = nbx / 8;
> + ? ? ? ? ? ? ? nby = nby / 8;
> + ? ? ? ? ? ? ? size = nbx * nby * 4;
> + ? ? ? ? ? ? ? size += track->htile_offset;
> +
> + ? ? ? ? ? ? ? if (size > radeon_bo_size(track->htile_bo)) {
> + ? ? ? ? ? ? ? ? ? ? ? dev_warn(p->dev, "%s:%d htile surface too small %ld 
> for %ld (%d %d)\n",
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?__func__, __LINE__, 
> radeon_bo_size(track->htile_bo),
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?size, nbx, nby);
> + ? ? ? ? ? ? ? ? ? ? ? return -EINVAL;
> + ? ? ? ? ? ? ? }
> + ? ? ? }
> +
> ? ? ? ?return 0;
> ?}
>
> @@ -1611,6 +1673,21 @@ static int evergreen_cs_check_reg(struct

[PATCH] Ignore LVDS on hp t5745 and hp st5747 thin client

2012-02-23 Thread Keith Packard
<#part sign=pgpmime>
On Wed, 22 Feb 2012 17:29:59 +0100, Daniel Vetter  wrote:

> Queued for -next (with Adam's Acked-by from irc added), thanks for the
> patch.

Should these be pulled into -fixes?

-- 
keith.packard at intel.com


Re: [PATCH 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Jerome Glisse
2012/2/23 Mathias Fröhlich 

>
> Christian,
>
> On Thursday, February 23, 2012 15:18:42 Christian König wrote:
> > The function radeon_bo_list_validate can cause a
> > bo to move, resulting in a different sync_obj
> > and a dependency to wait for this move to finish.
> >
> > Signed-off-by: Christian König 
> > Reviewed-by: Alex Deucher 
>
> I am not sure, but to me this looks like this could fix these kind of gpu
> lockups that I experience since some time every now and then.
> The usual symptom is that I get the
>
> radeon :01:00.0: GPU lockup CP stall for more than 1msec
> GPU lockup (waiting for 0x00682AC3 last fence id 0x00682AC2)
> [...]
>
> kernel message. Each time with the fence being off by one like in the
> example
> above.
>
> If this change has the potential to fix this issue I think this particular
> patch should be considered for the current upstream kernel release.
>
> Mathias
>

No this patch doesn't. This patch is all about getting proper sync btw
different rings.

Sorry for the deception.

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


[Bug 21582] Build failure if NOUVEAU && !HWMON

2012-02-23 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=21582


Guenter Roeck  changed:

   What|Removed |Added

 AssignedTo|drivers_video-dri@kernel-bu |li...@roeck-us.net
   |gs.osdl.org |




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


Re: [PATCH 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Mathias Fröhlich

Christian,

On Thursday, February 23, 2012 15:18:42 Christian König wrote:
> The function radeon_bo_list_validate can cause a
> bo to move, resulting in a different sync_obj
> and a dependency to wait for this move to finish.
> 
> Signed-off-by: Christian König 
> Reviewed-by: Alex Deucher 

I am not sure, but to me this looks like this could fix these kind of gpu 
lockups that I experience since some time every now and then.
The usual symptom is that I get the 

radeon :01:00.0: GPU lockup CP stall for more than 1msec
GPU lockup (waiting for 0x00682AC3 last fence id 0x00682AC2)
[...]

kernel message. Each time with the fence being off by one like in the example 
above.

If this change has the potential to fix this issue I think this particular 
patch should be considered for the current upstream kernel release.

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


Re: [PATCH 2/4] drm/radeon/kms: no need to align IB like this

2012-02-23 Thread Jerome Glisse
2012/2/23 Christian König 

> So don't confuse devs by doing so.
>
> Signed-off-by: Christian König 
> ---
>  drivers/gpu/drm/radeon/r600.c |   15 +--
>  1 files changed, 1 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
> index 4f08e5e..4a4ac8f 100644
> --- a/drivers/gpu/drm/radeon/r600.c
> +++ b/drivers/gpu/drm/radeon/r600.c
> @@ -2719,20 +2719,7 @@ int r600_ib_test(struct radeon_device *rdev, int
> ring)
>ib->ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1);
>ib->ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
>ib->ptr[2] = 0xDEADBEEF;
> -   ib->ptr[3] = PACKET2(0);
> -   ib->ptr[4] = PACKET2(0);
> -   ib->ptr[5] = PACKET2(0);
> -   ib->ptr[6] = PACKET2(0);
> -   ib->ptr[7] = PACKET2(0);
> -   ib->ptr[8] = PACKET2(0);
> -   ib->ptr[9] = PACKET2(0);
> -   ib->ptr[10] = PACKET2(0);
> -   ib->ptr[11] = PACKET2(0);
> -   ib->ptr[12] = PACKET2(0);
> -   ib->ptr[13] = PACKET2(0);
> -   ib->ptr[14] = PACKET2(0);
> -   ib->ptr[15] = PACKET2(0);
> -   ib->length_dw = 16;
> +   ib->length_dw = 3;
>r = radeon_ib_schedule(rdev, ib);
>if (r) {
>radeon_scratch_free(rdev, scratch);
> --
> 1.7.5.4
>

You sure about that ? I remember this helped with GPU lockup and i also
seen fglrx aligning IB.

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


[Bug 29842] Radeon runs very hot

2012-02-23 Thread Pasi Kärkkäinen
On Wed, Feb 22, 2012 at 04:56:26PM +, bugzilla-daemon at 
bugzilla.kernel.org wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=29842
> 
> 
> 
> 
> 
> --- Comment #14 from Igor Rudchenko   2012-02-22 
> 16:56:23 ---
> Commit "PCI: Rework ASPM disable code" added in 3.0.20 and 3.2.25 has worsened
> the situation. I can't enable ASPM on ThinkPad T60 now even with
> "pcie_aspm=force" kernel parameter. So radeon is always hot now.
> 

Are you sure it's about ASPM ? My radeon (On a HP laptop) is very hot because
of the unimplemented (and/or buggy) power management in the radeon driver!

I can make the temperature lower if I switch to power_profile "low" instead of 
the "default".

-- Pasi

> 
> 3.2.4 kernel:
> 
> # dmesg | grep ASPM
> [0.00] PCIe ASPM is forcibly enabled
> [0.161612] ACPI FADT declares the system doesn't support PCIe ASPM, so
> disable it
> [3.612673] e1000e :02:00.0: Disabling ASPM L0s L1
> 
> # lspci -vv -s 01:00.0 | grep ASPM
> LnkCap:Port #0, Speed 2.5GT/s, Width x16, ASPM L0s L1, Latency L0 <64ns, 
> L1
> <1us
> LnkCtl:ASPM L0s L1 Enabled; RCB 64 bytes Disabled- Retrain- CommClk+
> 
> # cat /proc/acpi/ibm/thermal
> temperatures:49 41 37 68 36 -128 33 -128 42 54 55 -128 -128 -128 -128 -128
> 
> 
> 3.2.5 kernel:
> 
> # dmesg | grep ASPM
> [0.00] PCIe ASPM is forcibly enabled
> [0.161614] ACPI FADT declares the system doesn't support PCIe ASPM, so
> disable it
> [3.523647] e1000e :02:00.0: Disabling ASPM L0s L1
> 
> # lspci -vv -s 01:00.0 | grep ASPM
> LnkCap:Port #0, Speed 2.5GT/s, Width x16, ASPM L0s L1, Latency L0 <64ns, 
> L1
> <1us
> LnkCtl:ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
> 
> # cat /proc/acpi/ibm/thermal
> temperatures:51 41 37 72 36 -128 33 -128 43 55 59 -128 -128 -128 -128 -128
> 
> 
> Already tested kernels 3.2.7 and 3.3-rc4 - same problem.
> 
> -- 
> Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
> --- You are receiving this mail because: ---
> You are watching the assignee of the bug.
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel


Kernel Display and Video API Consolidation mini-summit at ELC 2012 - Notes

2012-02-23 Thread Michel Dänzer
On Mit, 2012-02-22 at 10:28 -0600, Rob Clark wrote: 
> On Wed, Feb 22, 2012 at 10:24 AM, Daniel Vetter  wrote:
> > On Wed, Feb 22, 2012 at 04:03:21PM +, James Simmons wrote:
> >>
> >> > > Imo we should ditch this - fb accel doesn't belong into the kernel. 
> >> > > Even
> >> > > on hw that still has a blitter for easy 2d accel without a complete 3d
> >> > > state setup necessary, it's not worth it. Chris Wilson from our team 
> >> > > once
> >> > > played around with implementing fb accel in the kernel (i915 hw still 
> >> > > has
> >> > > a blitter engine in the latest generations). He quickly noticed that to
> >> > > have decent speed, competitive with s/w rendering by the cpu he needs 
> >> > > the
> >> > > entire batch and buffer management stuff from userspace. And to really
> >> > > beat the cpu, you need even more magic.
> >> > >
> >> > > If you want fast 2d accel, use something like cairo.
> >> >
> >> > Our conclusion on this is that we should not expose an explicit 2D
> >> > acceleration API at the kernel level. If really needed, hardware 2D
> >> > acceleration could be implemented as a DRM device to handle memory 
> >> > management,
> >> > commands ring setup, synchronization, ... but I'm not even sure if that's
> >> > worth it. I might not have conveyed it well in my notes.
> >>
> >> Fbcon scrolling at be painful at HD or better modes. Fbcon needs 3
> >> possible accels; copyarea, imageblit, and fillrect. The first two could be
> >> hooked from the TTM layer. Its something I plan to experiment to see if
> >> its worth it.
> >
> > Let's bite into this ;-) I know that fbcon scrolling totally sucks on big
> > screens, but I also think it's a total waste of time to fix this. Imo
> > fbcon has 2 use-cases:
> > - display an OOSP.
> > - allow me to run fsck (or any other desaster-recovery stuff).
> >
> > It can do that quite fine already.
> 
> and for just fbcon scrolling, if you really wanted to you could
> implement it by just shuffling pages around in a GART..

Keep in mind there are still discrete GPUs :), where scanning out from
anything but VRAM may not be feasible, and direct CPU access to
(especially reads from) VRAM tends to be very slow.

However, for fbcon that can be addressed in each driver (as is done e.g.
in nouveau), and has nothing to do with any userspace interface.


-- 
Earthling Michel D?nzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer


[Bug 46004] [r300g, bisected] piglit glsl-fs-discard-02 fails

2012-02-23 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=46004

vincent  changed:

   What|Removed |Added

 Status|NEW |NEEDINFO
 AssignedTo|dri-devel at lists.freedesktop |vljn at ovi.com
   |.org|

--- Comment #7 from vincent  2012-02-23 00:26:52 PST ---
Created attachment 57507
  --> https://bugs.freedesktop.org/attachment.cgi?id=57507
Output remove less aggressive patch

Can you try this 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 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Alex Deucher
2012/2/23 Christian König :
> The function radeon_bo_list_validate can cause a
> bo to move, resulting in a different sync_obj
> and a dependency to wait for this move to finish.
>
> Signed-off-by: Christian König 
> Reviewed-by: Alex Deucher 

For the series:

Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/radeon/radeon.h    |    1 -
>  drivers/gpu/drm/radeon/radeon_cs.c |   21 ++---
>  2 files changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
> index 884e0d4..4c1b981 100644
> --- a/drivers/gpu/drm/radeon/radeon.h
> +++ b/drivers/gpu/drm/radeon/radeon.h
> @@ -836,7 +836,6 @@ struct radeon_cs_parser {
>        struct radeon_cs_reloc  *relocs;
>        struct radeon_cs_reloc  **relocs_ptr;
>        struct list_head        validated;
> -       bool                    sync_to_ring[RADEON_NUM_RINGS];
>        /* indices of various chunks */
>        int                     chunk_ib_idx;
>        int                     chunk_relocs_idx;
> diff --git a/drivers/gpu/drm/radeon/radeon_cs.c 
> b/drivers/gpu/drm/radeon/radeon_cs.c
> index 435a3d9..7fd0987 100644
> --- a/drivers/gpu/drm/radeon/radeon_cs.c
> +++ b/drivers/gpu/drm/radeon/radeon_cs.c
> @@ -85,12 +85,6 @@ int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
>                        radeon_bo_list_add_object(&p->relocs[i].lobj,
>                                                  &p->validated);
>
> -                       if (p->relocs[i].robj->tbo.sync_obj && !(r->flags & 
> RADEON_RELOC_DONT_SYNC)) {
> -                               struct radeon_fence *fence = 
> p->relocs[i].robj->tbo.sync_obj;
> -                               if (!radeon_fence_signaled(fence)) {
> -                                       p->sync_to_ring[fence->ring] = true;
> -                               }
> -                       }
>                } else
>                        p->relocs[i].handle = 0;
>        }
> @@ -118,11 +112,24 @@ static int radeon_cs_get_ring(struct radeon_cs_parser 
> *p, u32 ring, s32 priority
>
>  static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
>  {
> +       bool sync_to_ring[RADEON_NUM_RINGS] = { };
>        int i, r;
>
> +       for (i = 0; i < p->nrelocs; i++) {
> +               if (!p->relocs[i].robj || !p->relocs[i].robj->tbo.sync_obj)
> +                       continue;
> +
> +               if (!(p->relocs[i].flags & RADEON_RELOC_DONT_SYNC)) {
> +                       struct radeon_fence *fence = 
> p->relocs[i].robj->tbo.sync_obj;
> +                       if (!radeon_fence_signaled(fence)) {
> +                               sync_to_ring[fence->ring] = true;
> +                       }
> +               }
> +       }
> +
>        for (i = 0; i < RADEON_NUM_RINGS; ++i) {
>                /* no need to sync to our own or unused rings */
> -               if (i == p->ring || !p->sync_to_ring[i] || 
> !p->rdev->ring[i].ready)
> +               if (i == p->ring || !sync_to_ring[i] || 
> !p->rdev->ring[i].ready)
>                        continue;
>
>                if (!p->ib->fence->semaphore) {
> --
> 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


Re: [PATCH] drm/radeon/kms: add htile support to the cs checker v2

2012-02-23 Thread Alex Deucher
On Wed, Feb 22, 2012 at 5:28 PM,   wrote:
> From: Jerome Glisse 
>
> For 6xx+.  Required for mesa to use htile support for HiZ/HiS.
> Userspace will check radeon version 2.14 with is bumped either
> by tiling patch or stream out patch. This patch only add support
> for htile relocation which should be enough for any userspace
> to implement the hyperz (using htile buffer) feature.
>
> v2: Jerome: Fix size checking for htile buffer.
>
> Signed-off-by: Pierre-Eric Pelloux-Prayer 
> Signed-off-by: Alex Deucher 
> Signed-off-by: Jerome Glisse 


Reviewed-by: Alex Deucher 

> ---
>  drivers/gpu/drm/radeon/evergreen_cs.c     |   78 ++-
>  drivers/gpu/drm/radeon/evergreend.h       |    8 +
>  drivers/gpu/drm/radeon/r600_cs.c          |  379 
> -
>  drivers/gpu/drm/radeon/r600d.h            |    8 +
>  drivers/gpu/drm/radeon/reg_srcs/cayman    |    1 -
>  drivers/gpu/drm/radeon/reg_srcs/evergreen |    1 -
>  drivers/gpu/drm/radeon/reg_srcs/r600      |    1 -
>  7 files changed, 360 insertions(+), 116 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c 
> b/drivers/gpu/drm/radeon/evergreen_cs.c
> index 2ed17f7..54a320a 100644
> --- a/drivers/gpu/drm/radeon/evergreen_cs.c
> +++ b/drivers/gpu/drm/radeon/evergreen_cs.c
> @@ -85,6 +85,9 @@ struct evergreen_cs_track {
>        u32                     db_s_write_offset;
>        struct radeon_bo        *db_s_read_bo;
>        struct radeon_bo        *db_s_write_bo;
> +       u32                     htile_offset;
> +       u32                     htile_surface;
> +       struct radeon_bo        *htile_bo;
>  };
>
>  static u32 evergreen_cs_get_aray_mode(u32 tiling_flags)
> @@ -155,6 +158,9 @@ static void evergreen_cs_track_init(struct 
> evergreen_cs_track *track)
>        track->db_s_write_offset = 0x;
>        track->db_s_read_bo = NULL;
>        track->db_s_write_bo = NULL;
> +       track->htile_bo = NULL;
> +       track->htile_offset = 0x;
> +       track->htile_surface = 0;
>
>        for (i = 0; i < 4; i++) {
>                track->vgt_strmout_size[i] = 0;
> @@ -627,6 +633,62 @@ static int evergreen_cs_track_validate_depth(struct 
> radeon_cs_parser *p)
>                return -EINVAL;
>        }
>
> +       /* hyperz */
> +       if (G_028040_TILE_SURFACE_ENABLE(track->db_z_info)) {
> +               unsigned long size;
> +               unsigned nbx, nby;
> +
> +               if (track->htile_bo == NULL) {
> +                       dev_warn(p->dev, "%s:%d htile enabled without htile 
> surface 0x%08x\n",
> +                                __func__, __LINE__, track->db_z_info);
> +                       return -EINVAL;
> +               }
> +
> +               nbx = surf.nbx;
> +               nby = surf.nby;
> +               if (G_028ABC_LINEAR(track->htile_surface)) {
> +                       /* pitch must be 16 htiles aligned == 16 * 8 pixel 
> aligned */
> +                       nbx = round_up(nbx, 16 * 8);
> +                       /* height is npipes htiles aligned == npipes * 8 
> pixel aligned */
> +                       nby = round_up(nby, track->npipes * 8);
> +               } else {
> +                       switch (track->npipes) {
> +                       case 8:
> +                               nbx = round_up(nbx, 64 * 8);
> +                               nby = round_up(nby, 64 * 8);
> +                               break;
> +                       case 4:
> +                               nbx = round_up(nbx, 64 * 8);
> +                               nby = round_up(nby, 32 * 8);
> +                               break;
> +                       case 2:
> +                               nbx = round_up(nbx, 32 * 8);
> +                               nby = round_up(nby, 32 * 8);
> +                               break;
> +                       case 1:
> +                               nbx = round_up(nbx, 32 * 8);
> +                               nby = round_up(nby, 16 * 8);
> +                               break;
> +                       default:
> +                               dev_warn(p->dev, "%s:%d invalid num pipes 
> %d\n",
> +                                        __func__, __LINE__, track->npipes);
> +                               return -EINVAL;
> +                       }
> +               }
> +               /* compute number of htile */
> +               nbx = nbx / 8;
> +               nby = nby / 8;
> +               size = nbx * nby * 4;
> +               size += track->htile_offset;
> +
> +               if (size > radeon_bo_size(track->htile_bo)) {
> +                       dev_warn(p->dev, "%s:%d htile surface too small %ld 
> for %ld (%d %d)\n",
> +                                __func__, __LINE__, 
> radeon_bo_size(track->htile_bo),
> +                                size, nbx, nby);
> +                       return -EINVAL;
> +               }
> +       }
> +
>        return 0;
>  }
>
> @@ -1611,6 +1673,21 @@ static int evergreen_cs_check_reg(struct

[Bug 42069] Texture artifacts

2012-02-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=42069

--- Comment #2 from Lauri Kasanen  2012-02-23 06:38:04 
PST ---
I can't test mesa 8.0 on the laptop in question, since there's now a hard dep
on xcb.

The apitrace is still downloadable though?

-- 
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 4/4] drm/radeon: fix IB debugfs files for multiple cards

2012-02-23 Thread Christian König
Storing pointers to the IBs in a static var just
leads to giving the same content back for all
cards in the system.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/radeon/radeon_ring.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ring.c 
b/drivers/gpu/drm/radeon/radeon_ring.c
index 30a4c50..32c83d8 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -478,7 +478,9 @@ static struct drm_info_list radeon_debugfs_ring_info_list[] 
= {
 static int radeon_debugfs_ib_info(struct seq_file *m, void *data)
 {
struct drm_info_node *node = (struct drm_info_node *) m->private;
-   struct radeon_ib *ib = node->info_ent->data;
+   struct drm_device *dev = node->minor->dev;
+   struct radeon_device *rdev = dev->dev_private;
+   struct radeon_ib *ib = 
&rdev->ib_pool.ibs[*((unsigned*)node->info_ent->data)];
unsigned i;
 
if (ib == NULL) {
@@ -495,6 +497,7 @@ static int radeon_debugfs_ib_info(struct seq_file *m, void 
*data)
 
 static struct drm_info_list radeon_debugfs_ib_list[RADEON_IB_POOL_SIZE];
 static char radeon_debugfs_ib_names[RADEON_IB_POOL_SIZE][32];
+static unsigned radeon_debugfs_ib_idx[RADEON_IB_POOL_SIZE];
 #endif
 
 int radeon_debugfs_ring_init(struct radeon_device *rdev)
@@ -514,10 +517,11 @@ int radeon_debugfs_ib_init(struct radeon_device *rdev)
 
for (i = 0; i < RADEON_IB_POOL_SIZE; i++) {
sprintf(radeon_debugfs_ib_names[i], "radeon_ib_%04u", i);
+   radeon_debugfs_ib_idx[i] = i;
radeon_debugfs_ib_list[i].name = radeon_debugfs_ib_names[i];
radeon_debugfs_ib_list[i].show = &radeon_debugfs_ib_info;
radeon_debugfs_ib_list[i].driver_features = 0;
-   radeon_debugfs_ib_list[i].data = &rdev->ib_pool.ibs[i];
+   radeon_debugfs_ib_list[i].data = &radeon_debugfs_ib_idx[i];
}
return radeon_debugfs_add_files(rdev, radeon_debugfs_ib_list,
RADEON_IB_POOL_SIZE);
-- 
1.7.5.4

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


[PATCH 3/4] drm/radeon: also make the cs_parse function per ring

2012-02-23 Thread Christian König
Not all rings use PM4, so the cs_parser also needs to be per ring.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/radeon/radeon.h  |4 +-
 drivers/gpu/drm/radeon/radeon_asic.c |   38 +
 drivers/gpu/drm/radeon/radeon_cs.c   |2 +-
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 4c1b981..ca98772 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1147,13 +1147,13 @@ struct radeon_asic {
void (*emit_fence)(struct radeon_device *rdev, struct 
radeon_fence *fence);
void (*emit_semaphore)(struct radeon_device *rdev, struct 
radeon_ring *cp,
   struct radeon_semaphore *semaphore, bool 
emit_wait);
+   int (*cs_parse)(struct radeon_cs_parser *p);
} ring[RADEON_NUM_RINGS];
 
int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
int (*irq_set)(struct radeon_device *rdev);
int (*irq_process)(struct radeon_device *rdev);
u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
-   int (*cs_parse)(struct radeon_cs_parser *p);
int (*copy_blit)(struct radeon_device *rdev,
 uint64_t src_offset,
 uint64_t dst_offset,
@@ -1650,7 +1650,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t 
v);
 #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
 #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
 #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
-#define radeon_cs_parse(p) rdev->asic->cs_parse((p))
+#define radeon_cs_parse(rdev, r, p) (rdev)->asic->ring[(r)].cs_parse((p))
 #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), 
(state))
 #define radeon_gpu_is_lockup(rdev, cp) (rdev)->asic->gpu_is_lockup((rdev), 
(cp))
 #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c 
b/drivers/gpu/drm/radeon/radeon_asic.c
index 36a6192..636c68f 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.c
+++ b/drivers/gpu/drm/radeon/radeon_asic.c
@@ -145,12 +145,12 @@ static struct radeon_asic r100_asic = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r100_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r100_cs_parse,
}
},
.irq_set = &r100_irq_set,
.irq_process = &r100_irq_process,
.get_vblank_counter = &r100_get_vblank_counter,
-   .cs_parse = &r100_cs_parse,
.copy_blit = &r100_copy_blit,
.copy_dma = NULL,
.copy = &r100_copy_blit,
@@ -197,12 +197,12 @@ static struct radeon_asic r200_asic = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r100_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r100_cs_parse,
}
},
.irq_set = &r100_irq_set,
.irq_process = &r100_irq_process,
.get_vblank_counter = &r100_get_vblank_counter,
-   .cs_parse = &r100_cs_parse,
.copy_blit = &r100_copy_blit,
.copy_dma = &r200_copy_dma,
.copy = &r100_copy_blit,
@@ -248,12 +248,12 @@ static struct radeon_asic r300_asic = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r300_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r300_cs_parse,
}
},
.irq_set = &r100_irq_set,
.irq_process = &r100_irq_process,
.get_vblank_counter = &r100_get_vblank_counter,
-   .cs_parse = &r300_cs_parse,
.copy_blit = &r100_copy_blit,
.copy_dma = &r200_copy_dma,
.copy = &r100_copy_blit,
@@ -300,12 +300,12 @@ static struct radeon_asic r300_asic_pcie = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r300_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r300_cs_parse,
}
},
.irq_set = &r100_irq_set,
.irq_process = &r100_irq_process,
.get_vblank_counter = &r100_get_vblank_counter,
-   .cs_parse = &r300_cs_parse,
.copy_blit = &r100_copy_blit,
.copy_dma = &r200_copy_dma,
.copy = &r100_copy_blit,
@@ -351,12 +351,12 @@ static struct radeon_asic r420_asic = {
.ib_execute = &r100_ring_ib_execute,
.emit_fence = &r300_fence_ring_emit,
.emit_semaphore = &r100_semaphore_ring_emit,
+   .cs_parse = &r300_cs_parse,
}
},
.i

[PATCH 2/4] drm/radeon/kms: no need to align IB like this

2012-02-23 Thread Christian König
So don't confuse devs by doing so.

Signed-off-by: Christian König 
---
 drivers/gpu/drm/radeon/r600.c |   15 +--
 1 files changed, 1 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 4f08e5e..4a4ac8f 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2719,20 +2719,7 @@ int r600_ib_test(struct radeon_device *rdev, int ring)
ib->ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1);
ib->ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_OFFSET) >> 2);
ib->ptr[2] = 0xDEADBEEF;
-   ib->ptr[3] = PACKET2(0);
-   ib->ptr[4] = PACKET2(0);
-   ib->ptr[5] = PACKET2(0);
-   ib->ptr[6] = PACKET2(0);
-   ib->ptr[7] = PACKET2(0);
-   ib->ptr[8] = PACKET2(0);
-   ib->ptr[9] = PACKET2(0);
-   ib->ptr[10] = PACKET2(0);
-   ib->ptr[11] = PACKET2(0);
-   ib->ptr[12] = PACKET2(0);
-   ib->ptr[13] = PACKET2(0);
-   ib->ptr[14] = PACKET2(0);
-   ib->ptr[15] = PACKET2(0);
-   ib->length_dw = 16;
+   ib->length_dw = 3;
r = radeon_ib_schedule(rdev, ib);
if (r) {
radeon_scratch_free(rdev, scratch);
-- 
1.7.5.4

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


[PATCH 1/4] drm/radeon: move ring syncing after bo validation

2012-02-23 Thread Christian König
The function radeon_bo_list_validate can cause a
bo to move, resulting in a different sync_obj
and a dependency to wait for this move to finish.

Signed-off-by: Christian König 
Reviewed-by: Alex Deucher 
---
 drivers/gpu/drm/radeon/radeon.h|1 -
 drivers/gpu/drm/radeon/radeon_cs.c |   21 ++---
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 884e0d4..4c1b981 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -836,7 +836,6 @@ struct radeon_cs_parser {
struct radeon_cs_reloc  *relocs;
struct radeon_cs_reloc  **relocs_ptr;
struct list_headvalidated;
-   boolsync_to_ring[RADEON_NUM_RINGS];
/* indices of various chunks */
int chunk_ib_idx;
int chunk_relocs_idx;
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c 
b/drivers/gpu/drm/radeon/radeon_cs.c
index 435a3d9..7fd0987 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -85,12 +85,6 @@ int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
radeon_bo_list_add_object(&p->relocs[i].lobj,
  &p->validated);
 
-   if (p->relocs[i].robj->tbo.sync_obj && !(r->flags & 
RADEON_RELOC_DONT_SYNC)) {
-   struct radeon_fence *fence = 
p->relocs[i].robj->tbo.sync_obj;
-   if (!radeon_fence_signaled(fence)) {
-   p->sync_to_ring[fence->ring] = true;
-   }
-   }
} else
p->relocs[i].handle = 0;
}
@@ -118,11 +112,24 @@ static int radeon_cs_get_ring(struct radeon_cs_parser *p, 
u32 ring, s32 priority
 
 static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
 {
+   bool sync_to_ring[RADEON_NUM_RINGS] = { };
int i, r;
 
+   for (i = 0; i < p->nrelocs; i++) {
+   if (!p->relocs[i].robj || !p->relocs[i].robj->tbo.sync_obj)
+   continue;
+
+   if (!(p->relocs[i].flags & RADEON_RELOC_DONT_SYNC)) {
+   struct radeon_fence *fence = 
p->relocs[i].robj->tbo.sync_obj;
+   if (!radeon_fence_signaled(fence)) {
+   sync_to_ring[fence->ring] = true;
+   }
+   }
+   }
+
for (i = 0; i < RADEON_NUM_RINGS; ++i) {
/* no need to sync to our own or unused rings */
-   if (i == p->ring || !p->sync_to_ring[i] || 
!p->rdev->ring[i].ready)
+   if (i == p->ring || !sync_to_ring[i] || !p->rdev->ring[i].ready)
continue;
 
if (!p->ib->fence->semaphore) {
-- 
1.7.5.4

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


Re: [PATCH] drm: drop setting vm_file to filp

2012-02-23 Thread Dave Airlie
On Thu, Feb 23, 2012 at 11:42 AM, Dave Airlie  wrote:
> From: Dave Airlie 
>
> Talking to Al Viro on irc, we can see no possible reason for doing
> this, the upper mmap code does it. The code has been there since
> first import into drm tree I can find.
>
> Of course it probably means this will crash and burn.

Al tracked down the core vm changed in 2.3.51pre1 so this should be safe now :-)

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


[PATCH] drm: drop setting vm_file to filp

2012-02-23 Thread Dave Airlie
From: Dave Airlie 

Talking to Al Viro on irc, we can see no possible reason for doing
this, the upper mmap code does it. The code has been there since
first import into drm tree I can find.

Of course it probably means this will crash and burn.

Cc: Al Viro 
Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/drm_gem.c   |1 -
 drivers/gpu/drm/drm_vm.c|2 --
 drivers/gpu/drm/exynos/exynos_drm_gem.c |1 -
 drivers/gpu/drm/i810/i810_dma.c |1 -
 4 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index f8625e2..3ebe3c8 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -700,7 +700,6 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct 
*vma)
 */
drm_gem_object_reference(obj);
 
-   vma->vm_file = filp;/* Needed for drm_vm_open() */
drm_vm_open_locked(vma);
 
 out_unlock:
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 8c03eaf..55cd615 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -519,7 +519,6 @@ static int drm_mmap_dma(struct file *filp, struct 
vm_area_struct *vma)
vma->vm_flags |= VM_RESERVED;   /* Don't swap */
vma->vm_flags |= VM_DONTEXPAND;
 
-   vma->vm_file = filp;/* Needed for drm_vm_open() */
drm_vm_open_locked(vma);
return 0;
 }
@@ -671,7 +670,6 @@ int drm_mmap_locked(struct file *filp, struct 
vm_area_struct *vma)
vma->vm_flags |= VM_RESERVED;   /* Don't swap */
vma->vm_flags |= VM_DONTEXPAND;
 
-   vma->vm_file = filp;/* Needed for drm_vm_open() */
drm_vm_open_locked(vma);
return 0;
 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c 
b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index 025abb3..6545251 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -208,7 +208,6 @@ static int exynos_drm_gem_mmap_buffer(struct file *filp,
 
/* in case of direct mapping, always having non-cachable attribute */
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-   vma->vm_file = filp;
 
vm_size = vma->vm_end - vma->vm_start;
/*
diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
index 7f4b4e1..b4c1eca 100644
--- a/drivers/gpu/drm/i810/i810_dma.c
+++ b/drivers/gpu/drm/i810/i810_dma.c
@@ -99,7 +99,6 @@ static int i810_mmap_buffers(struct file *filp, struct 
vm_area_struct *vma)
buf_priv = buf->dev_private;
 
vma->vm_flags |= (VM_IO | VM_DONTCOPY);
-   vma->vm_file = filp;
 
buf_priv->currently_mapped = I810_BUF_MAPPED;
 
-- 
1.7.7.6

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


[PULL] drm-intel-next

2012-02-23 Thread Daniel Vetter
Hi Dave,

New pull request for drm-intel-next, this time with a backmerge from
-fixes to sort out a few things.

Highlights:
- interlaced support for i915. Again thanks a lot to all the ppl who help
  out with testing, patches and doc-crawling.
- aliasing ppgtt support for snb/ivb. Because ppgtt ptes are
  gpu-cacheable, this can also speed things up a bit.
- swizzling support for snb/ivb, again a slight perf improvements on some
  things.
- more error_state work - we're slowly reaching a level of paranoia
  suitable for dealing with gpus.
- outstanding_lazy_request fix and the autoreport patches from Chris: I'm
  pretty hopefully that these two squash a lot of the semaphores=1 issues
  we've seen on snb, please retest if you've had issues.
- the usual pile of minor patches, one noteworthy one is to use the lvds
  presence pin on pch_split chips. I expect a few new quirks due to this
  ...

Our QA reported a funky missed IRQ issue on snb, but strangely they claim
that it has not been introduced by enabling the forcewake voodoo on snb
(and disabling the old hwstam workaround). Investigation is still ongoing,
but the usual set of workarounds (reinstating hwstam or the cs register
readback) are all confirmed to still work. So I don't think we should
stall just because of this.

Otherwise now new issues for this reported. QA report as usual below the
pull request. Note that I've had to manually frob the shortlog to not
include any patches already merged into -next, -fixes or Linus' upstream.

The following changes since commit 28a4d5675857f6386930a324317281cb8ed1e5d0:

  Merge branch 'drm-intel-fixes' of 
git://git.kernel.org/pub/scm/linux/kernel/git/keithp/linux into drm-fixes 
(2012-02-10 08:35:19 +)

are available in the git repository at:


  git://people.freedesktop.org/~danvet/drm-intel tags/drm-intel-next-2012-02-16

for you to fetch changes up to de67cba65944f26c0f147035bd62e30c5f456b96:

  Revert "drivers/gpu/drm/i915/intel_overlay.c needs seq_file.h" (2012-02-16 
10:31:23 +0100)

Ben Widawsky (3):
  drm/i915: use gtfifodbg
  drm/i915: catch gtfifo errors on forcewake_put
  drm/i915: check gtfifodbg after possibly failed writes

Chris Wilson (4):
  drm/i915: Record the tail at each request and use it to estimate the head
  drm/i915: Record the in-flight requests at the time of a hang
  drm/i915: Record the position of the request upon error
  drm/i915/lvds: Always use the presence pin for LVDS on PCH

Daniel Vetter (24):
  drm/i915: swizzling support for snb/ivb
  drm/i915: consolidate swizzling control bit frobbing
  drm/i915: add gen6+ registers to i915_swizzle_info
  drm/i915: s/DRM_ERROR/DRM_DEBUG in i915_gem_execbuffer.c
  drm/i915: dump even more into the error_state
  agp/intel-gtt: export the scratch page dma address
  agp/intel-gtt: export the gtt pagetable iomapping
  drm/i915: initialization/teardown for the aliasing ppgtt
  drm/i915: ppgtt binding/unbinding support
  drm/i915: ppgtt register definitions
  drm/i915: ppgtt debugfs info
  drm/i915: enable ppgtt
  Merge remote-tracking branch 'airlied/drm-fixes' into 
drm-intel-next-queued
  drm/i915: clean up interlaced pipeconf bit definitions
  drm/i915: fixup interlaced vertical timings confusion, part 1
  drm/i915: fixup interlaced vertical timings confusion, part 2
  drm/i915: fixup interlaced support on ilk+
  drm/i915: don't allow interlaced pipeconf on gen2
  drm/i915: correctly program the VSYNCSHIFT register
  drm/i915: fixup overlay checks for interlaced modes
  drm/i915: outstanding_lazy_request is a u32
  drm/i915: fixup seqno allocation logic for lazy_request
  drm/i915: enable forcewake voodoo also for gen6
  drm/i915: fix up locking inconsistency around gem_do_init

Danny Kukawka (1):
  Revert "drivers/gpu/drm/i915/intel_overlay.c needs seq_file.h"

Paulo Zanoni (2):
  drm/i915: set interlaced bits for TRANSCONF
  drm/i915: add missing SDVO bits for interlaced modes on ILK

Peter Ross (2):
  drm/i915: allow interlaced mode output on the SDVO connector
  drm/i915: allow interlaced mode output on the HDMI connector

Sean Paul (1):
  drm/i915: Don't lock panel registers when downclocking

Wu Fengguang (1):
  drm/i915: add a "force-dvi" HDMI audio mode

Yufeng Shen (1):
  drm/i915: Fix race condition in accessing GMBUS

On Tue, Feb 21, 2012 at 07:45:57AM +, Sun, Yi wrote:
> A new round of Kernel testing is finished. We covered the platforms 
> IvyBridge, SandyBridge, IronLake, G33 and PineView.
> We use the latest version on drm-intel-testing branch:
> Kernel: (drm-intel-testing)de67cba65944f26c0f147035bd62e30c5f456b96
> Some additional commit info:
> Author: Danny Kukawka 
> Date:   Wed Feb 15 18:53:55 2012 +0100
> 
> Revert "drivers/gpu/drm/i915/intel_overlay.c needs seq_file.h"
> 
> In this round of testing, no new bugs are found. 
> And one bug is fixed by the p

[Bug 46004] [r300g, bisected] piglit glsl-fs-discard-02 fails

2012-02-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=46004

vincent  changed:

   What|Removed |Added

 Status|NEW |NEEDINFO
 AssignedTo|dri-devel@lists.freedesktop |v...@ovi.com
   |.org|

--- Comment #7 from vincent  2012-02-23 00:26:52 PST ---
Created attachment 57507
  --> https://bugs.freedesktop.org/attachment.cgi?id=57507
Output remove less aggressive patch

Can you try this 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


Kernel Display and Video API Consolidation mini-summit at ELC 2012 - Notes

2012-02-23 Thread Alan Cox
> and when doing 2d accel on a 3d core..  it basically amounts to
> putting a shader compiler in the kernel.   Wh!

What I did for the GMA500 is to use the GTT to do scrolling by rewriting
the framebuffer GTT tables so they work as a circular buffer and doing a
bit of alignment of buffers.

The end result is faster than most accelerated 2D scrolls unsurprisingly.

Even faster would be to map enough of the start of the object on the end
of the range in repeat and just roll the frame buffer base. That would
get it down to a couple of 32bit I/O writes..

Alan


  1   2   >