[PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.

2009-12-18 Thread Corbin Simpson
From 7c1de3201bd4e965da7c1d542c46d8b2725bf42d Mon Sep 17 00:00:00 2001
From: Corbin Simpson mostawesomed...@gmail.com
Date: Fri, 18 Dec 2009 01:00:57 -0800
Subject: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.

Long story short, this fixes sporadic hardlocks with my rv410 during
times of intense 2D acceleration (Flash on Fx3).

Signed-off-by: Corbin Simpson mostawesomed...@gmail.com
---
 drivers/gpu/drm/radeon/r420.c   |   35 +++
 drivers/gpu/drm/radeon/radeon.h |1 +
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index 5c7fe52..6f096a6 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -30,6 +30,7 @@
 #include radeon_reg.h
 #include radeon.h
 #include atom.h
+#include r100d.h
 #include r420d.h

 int r420_mc_init(struct radeon_device *rdev)
@@ -165,6 +166,36 @@ static void r420_clock_resume(struct radeon_device *rdev)
WREG32_PLL(R_0D_SCLK_CNTL, sclk_cntl);
 }

+static void r420_cp_errata_init(struct radeon_device *rdev)
+{
+/* RV410 and R420 can lock up if CP DMA to host memory happens while the
+ * 2D engine is busy.
+ *
+ * The proper workaround is to queue a RESYNC at the beginning of the CP
+ * init, apparently.
+ */
+radeon_scratch_get(rdev, rdev-resync_scratch);
+
+radeon_ring_lock(rdev, 8);
+radeon_ring_write(rdev, PACKET0(R300_CP_RESYNC_ADDR, 1));
+radeon_ring_write(rdev, rdev-resync_scratch);
+radeon_ring_write(rdev, 0xDEADBEEF);
+radeon_ring_unlock_commit(rdev);
+}
+
+static void r420_cp_errata_fini(struct radeon_device *rdev)
+{
+/* Catch the RESYNC we dispatched all the way back, at the very beginning
+ * of the CP init.
+ */
+radeon_ring_lock(rdev, 8);
+radeon_ring_write(rdev, PACKET0(R300_RB3D_DSTCACHE_CTLSTAT, 0));
+radeon_ring_write(rdev, R300_RB3D_DC_FINISH);
+radeon_ring_unlock_commit(rdev);
+
+radeon_scratch_free(rdev, rdev-resync_scratch);
+}
+
 static int r420_startup(struct radeon_device *rdev)
 {
int r;
@@ -194,6 +225,9 @@ static int r420_startup(struct radeon_device *rdev)
dev_err(rdev-dev, failled initializing CP (%d).\n, r);
return r;
}
+/* Handle CP errata. */
+r420_cp_errata_init(rdev);
+
r = r100_wb_init(rdev);
if (r) {
dev_err(rdev-dev, failled initializing WB (%d).\n, r);
@@ -247,6 +281,7 @@ int r420_suspend(struct radeon_device *rdev)

 void r420_fini(struct radeon_device *rdev)
 {
+r420_cp_errata_fini(rdev);
r100_cp_fini(rdev);
r100_wb_fini(rdev);
r100_ib_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 5ab35b8..0da50a2 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -771,6 +771,7 @@ struct radeon_device {
struct radeon_gem   gem;
struct radeon_pmpm;
uint32_tbios_scratch[RADEON_BIOS_NUM_SCRATCH];
+uint32_t resync_scratch;
struct mutexcs_mutex;
struct radeon_wbwb;
struct radeon_dummy_pagedummy_page;
-- 
1.6.5.2

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.

2009-12-18 Thread Jerome Glisse
On Fri, Dec 18, 2009 at 01:11:45AM -0800, Corbin Simpson wrote:
 From 7c1de3201bd4e965da7c1d542c46d8b2725bf42d Mon Sep 17 00:00:00 2001
 From: Corbin Simpson mostawesomed...@gmail.com
 Date: Fri, 18 Dec 2009 01:00:57 -0800
 Subject: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.
 
 Long story short, this fixes sporadic hardlocks with my rv410 during
 times of intense 2D acceleration (Flash on Fx3).
 
 Signed-off-by: Corbin Simpson mostawesomed...@gmail.com

It seems you are using space and not tab.

Cheers,
Jerome

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.

2009-12-18 Thread Rafał Miłecki
2009/12/18 Corbin Simpson mostawesomed...@gmail.com:
 From 7c1de3201bd4e965da7c1d542c46d8b2725bf42d Mon Sep 17 00:00:00 2001
 From: Corbin Simpson mostawesomed...@gmail.com
 Date: Fri, 18 Dec 2009 01:00:57 -0800
 Subject: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.

 Long story short, this fixes sporadic hardlocks with my rv410 during
 times of intense 2D acceleration (Flash on Fx3).

Can this be issue on newer chipsets as well? I get hard lockup on
RV620 from time to time, very easy reproducible with just starting
JDownloader (java application). It seems to do some heavy 2D and locks
up my machine in something between 1 second and few minutes.

This does not happen when I use UMS (non-KMS) or when I start
JDownloader on KDE's virtual desktop #2 and switch to desktop #1.

-- 
Rafał

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.

2009-12-18 Thread Michel Dänzer
On Fri, 2009-12-18 at 11:54 +0100, Rafał Miłecki wrote: 
 2009/12/18 Corbin Simpson mostawesomed...@gmail.com:
  From 7c1de3201bd4e965da7c1d542c46d8b2725bf42d Mon Sep 17 00:00:00 2001
  From: Corbin Simpson mostawesomed...@gmail.com
  Date: Fri, 18 Dec 2009 01:00:57 -0800
  Subject: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.
 
  Long story short, this fixes sporadic hardlocks with my rv410 during
  times of intense 2D acceleration (Flash on Fx3).
 
 Can this be issue on newer chipsets as well? I get hard lockup on
 RV620 from time to time, very easy reproducible with just starting
 JDownloader (java application). It seems to do some heavy 2D and locks
 up my machine in something between 1 second and few minutes.
 
 This does not happen when I use UMS (non-KMS) or when I start
 JDownloader on KDE's virtual desktop #2 and switch to desktop #1.

It can't be the same problem: it's specific to the 2D engine, which
doesn't exist anymore as of R6xx, and it would also happen with UMS.


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

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.

2009-12-18 Thread Xavier Bestel
On Fri, 2009-12-18 at 01:11 -0800, Corbin Simpson wrote:
[...]
 @@ -194,6 +225,9 @@ static int r420_startup(struct radeon_device *rdev)
   dev_err(rdev-dev, failled initializing CP (%d).\n, r);
   return r;
   }
 +/* Handle CP errata. */
 +r420_cp_errata_init(rdev);
 +
   r = r100_wb_init(rdev);
   if (r) {

On a purely cosmetic POV, it looks like you indent with spaces in a file
previously indented with tabs.

Xav




--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


Re: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.

2009-12-18 Thread Jerome Glisse
On Fri, Dec 18, 2009 at 01:11:45AM -0800, Corbin Simpson wrote:
 From 7c1de3201bd4e965da7c1d542c46d8b2725bf42d Mon Sep 17 00:00:00 2001
 From: Corbin Simpson mostawesomed...@gmail.com
 Date: Fri, 18 Dec 2009 01:00:57 -0800
 Subject: [PATCH] drivers/radeon/kms: Workaround RV410/R420 CP errata.
 
 Long story short, this fixes sporadic hardlocks with my rv410 during
 times of intense 2D acceleration (Flash on Fx3).
 
 Signed-off-by: Corbin Simpson mostawesomed...@gmail.com
 ---

Beside the tab issue you should also avoid to reallocate scratch register
if it was already allocated. Maybe init the scratch to -1 and test for
that. Otherwise after few suspend/resume you won't have scratch reg left.

Cheers,
Jerome

--
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
--
___
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel