Skip to content

Commit a6c0c37

Browse files
ozbenhtorvalds
authored andcommitted
radeonfb: misc cleanup of engine and dst cache handling
Fix a couple of incomplete tests of the chip families in the engine init/reset code and proper initialization of the destination cache mode. The result should better match what the latest X radeon driver does. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: David S. Miller <davem@davemloft.net> Cc: Krzysztof Halasa <khc@pm.waw.pl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7c08c9a commit a6c0c37

4 files changed

Lines changed: 42 additions & 31 deletions

File tree

‎drivers/video/aty/radeon_accel.c‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ void radeonfb_engine_reset(struct radeonfb_info *rinfo)
211211
host_path_cntl = INREG(HOST_PATH_CNTL);
212212
rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
213213

214-
if (rinfo->family == CHIP_FAMILY_R300 ||
215-
rinfo->family == CHIP_FAMILY_R350 ||
216-
rinfo->family == CHIP_FAMILY_RV350) {
214+
if (IS_R300_VARIANT(rinfo)) {
217215
u32 tmp;
218216

219217
OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset |
@@ -249,9 +247,7 @@ void radeonfb_engine_reset(struct radeonfb_info *rinfo)
249247
INREG(HOST_PATH_CNTL);
250248
OUTREG(HOST_PATH_CNTL, host_path_cntl);
251249

252-
if (rinfo->family != CHIP_FAMILY_R300 &&
253-
rinfo->family != CHIP_FAMILY_R350 &&
254-
rinfo->family != CHIP_FAMILY_RV350)
250+
if (!IS_R300_VARIANT(rinfo))
255251
OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
256252

257253
OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
@@ -268,10 +264,18 @@ void radeonfb_engine_init (struct radeonfb_info *rinfo)
268264
radeonfb_engine_reset(rinfo);
269265

270266
radeon_fifo_wait (1);
271-
if ((rinfo->family != CHIP_FAMILY_R300) &&
272-
(rinfo->family != CHIP_FAMILY_R350) &&
273-
(rinfo->family != CHIP_FAMILY_RV350))
267+
if (IS_R300_VARIANT(rinfo)) {
268+
OUTREG(RB2D_DSTCACHE_MODE, INREG(RB2D_DSTCACHE_MODE) |
269+
RB2D_DC_AUTOFLUSH_ENABLE |
270+
RB2D_DC_DC_DISABLE_IGNORE_PE);
271+
} else {
272+
/* This needs to be double checked with ATI. Latest X driver
273+
* completely "forgets" to set this register on < r3xx, and
274+
* we used to just write 0 there... I'll keep the 0 and update
275+
* that when we have sorted things out on X side.
276+
*/
274277
OUTREG(RB2D_DSTCACHE_MODE, 0);
278+
}
275279

276280
radeon_fifo_wait (3);
277281
/* We re-read MC_FB_LOCATION from card as it can have been

‎drivers/video/aty/radeon_base.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,11 +1286,10 @@ static void radeon_write_pll_regs(struct radeonfb_info *rinfo, struct radeon_reg
12861286
radeon_pll_errata_after_data(rinfo);
12871287

12881288
/* Set PPLL ref. div */
1289-
if (rinfo->family == CHIP_FAMILY_R300 ||
1289+
if (IS_R300_VARIANT(rinfo) ||
12901290
rinfo->family == CHIP_FAMILY_RS300 ||
1291-
rinfo->family == CHIP_FAMILY_R350 ||
1292-
rinfo->family == CHIP_FAMILY_RV350 ||
1293-
rinfo->family == CHIP_FAMILY_RV380 ) {
1291+
rinfo->family == CHIP_FAMILY_RS400 ||
1292+
rinfo->family == CHIP_FAMILY_RS480) {
12941293
if (mode->ppll_ref_div & R300_PPLL_REF_DIV_ACC_MASK) {
12951294
/* When restoring console mode, use saved PPLL_REF_DIV
12961295
* setting.
@@ -1461,10 +1460,7 @@ static void radeon_calc_pll_regs(struct radeonfb_info *rinfo, struct radeon_regs
14611460
/* Not all chip revs have the same format for this register,
14621461
* extract the source selection
14631462
*/
1464-
if (rinfo->family == CHIP_FAMILY_R200 ||
1465-
rinfo->family == CHIP_FAMILY_R300 ||
1466-
rinfo->family == CHIP_FAMILY_R350 ||
1467-
rinfo->family == CHIP_FAMILY_RV350) {
1463+
if (rinfo->family == CHIP_FAMILY_R200 || IS_R300_VARIANT(rinfo)) {
14681464
source = (fp2_gen_cntl >> 10) & 0x3;
14691465
/* sourced from transform unit, check for transform unit
14701466
* own source
@@ -2005,6 +2001,7 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo)
20052001
(rinfo->family == CHIP_FAMILY_RS200) ||
20062002
(rinfo->family == CHIP_FAMILY_RS300) ||
20072003
(rinfo->family == CHIP_FAMILY_RC410) ||
2004+
(rinfo->family == CHIP_FAMILY_RS400) ||
20082005
(rinfo->family == CHIP_FAMILY_RS480) ) {
20092006
u32 tom = INREG(NB_TOM);
20102007
tmp = ((((tom >> 16) - (tom & 0xffff) + 1) << 6) * 1024);

‎drivers/video/aty/radeonfb.h‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ enum radeon_family {
5353
CHIP_FAMILY_RV380, /* RV370/RV380/M22/M24 */
5454
CHIP_FAMILY_R420, /* R420/R423/M18 */
5555
CHIP_FAMILY_RC410,
56+
CHIP_FAMILY_RS400,
5657
CHIP_FAMILY_RS480,
5758
CHIP_FAMILY_LAST,
5859
};
@@ -533,33 +534,39 @@ static inline u32 radeon_get_dstbpp(u16 depth)
533534
/*
534535
* 2D Engine helper routines
535536
*/
536-
static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
537+
538+
static inline void _radeon_fifo_wait(struct radeonfb_info *rinfo, int entries)
537539
{
538540
int i;
539541

540-
/* initiate flush */
541-
OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
542-
~RB2D_DC_FLUSH_ALL);
543-
544-
for (i=0; i < 2000000; i++) {
545-
if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
542+
for (i=0; i<2000000; i++) {
543+
if ((INREG(RBBM_STATUS) & 0x7f) >= entries)
546544
return;
547545
udelay(1);
548546
}
549-
printk(KERN_ERR "radeonfb: Flush Timeout !\n");
547+
printk(KERN_ERR "radeonfb: FIFO Timeout !\n");
550548
}
551549

552-
553-
static inline void _radeon_fifo_wait(struct radeonfb_info *rinfo, int entries)
550+
static inline void radeon_engine_flush (struct radeonfb_info *rinfo)
554551
{
555552
int i;
556553

557-
for (i=0; i<2000000; i++) {
558-
if ((INREG(RBBM_STATUS) & 0x7f) >= entries)
554+
/* Initiate flush */
555+
OUTREGP(DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
556+
~RB2D_DC_FLUSH_ALL);
557+
558+
/* Ensure FIFO is empty, ie, make sure the flush commands
559+
* has reached the cache
560+
*/
561+
_radeon_fifo_wait (rinfo, 64);
562+
563+
/* Wait for the flush to complete */
564+
for (i=0; i < 2000000; i++) {
565+
if (!(INREG(DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
559566
return;
560567
udelay(1);
561568
}
562-
printk(KERN_ERR "radeonfb: FIFO Timeout !\n");
569+
printk(KERN_ERR "radeonfb: Flush Timeout !\n");
563570
}
564571

565572

‎include/video/radeon.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@
386386
#define SC_BOTTOM_RIGHT 0x16F0
387387
#define SRC_SC_BOTTOM_RIGHT 0x16F4
388388
#define RB2D_DSTCACHE_MODE 0x3428
389-
#define RB2D_DSTCACHE_CTLSTAT 0x342C
389+
#define RB2D_DSTCACHE_CTLSTAT_broken 0x342C /* do not use */
390390
#define LVDS_GEN_CNTL 0x02d0
391391
#define LVDS_PLL_CNTL 0x02d4
392392
#define FP2_GEN_CNTL 0x0288
@@ -532,6 +532,9 @@
532532
#define RB2D_DC_FLUSH_ALL (RB2D_DC_FLUSH_2D | RB2D_DC_FREE_2D)
533533
#define RB2D_DC_BUSY (1 << 31)
534534

535+
/* DSTCACHE_MODE bits constants */
536+
#define RB2D_DC_AUTOFLUSH_ENABLE (1 << 8)
537+
#define RB2D_DC_DC_DISABLE_IGNORE_PE (1 << 17)
535538

536539
/* CRTC_GEN_CNTL bit constants */
537540
#define CRTC_DBL_SCAN_EN 0x00000001

0 commit comments

Comments
 (0)