Hello All:
    This is patch 4 of the 5 patches. It's based on 
2.6.32-rc3+patch1+patch2+patch3. It fixes the bug of via_verify.c function.

3 files has been modified for this patch.

Sign-off by Bruce C. Chang <[email protected]>
diff -Nur linux-2.6.32-rc3-old/drivers/gpu/drm/via/via_3d_reg.h 
linux-2.6.32-rc3-new/drivers/gpu/drm/via/via_3d_reg.h
--- linux-2.6.32-rc3-old/drivers/gpu/drm/via/via_3d_reg.h       2009-10-05 
08:12:30.000000000 +0800
+++ linux-2.6.32-rc3-new/drivers/gpu/drm/via/via_3d_reg.h       2009-10-08 
10:19:12.000000000 +0800
@@ -1647,4 +1647,7 @@
 #define VIA_VIDEO_HEADER6       0xFE050000
 #define VIA_VIDEO_HEADER7       0xFE060000
 #define VIA_VIDEOMASK           0xFFFF0000
+#define HALCYON_HEADER3         0xF4000000
+#define HALCYON_HEADER4         0xF6000000
+#define HALCYON_HEADER_MASK     0xFE000000
 #endif
diff -Nur linux-2.6.32-rc3-old/drivers/gpu/drm/via/via_verifier.c 
linux-2.6.32-rc3-new/drivers/gpu/drm/via/via_verifier.c
--- linux-2.6.32-rc3-old/drivers/gpu/drm/via/via_verifier.c     2009-10-05 
08:12:30.000000000 +0800
+++ linux-2.6.32-rc3-new/drivers/gpu/drm/via/via_verifier.c     2009-10-08 
10:19:12.000000000 +0800
@@ -41,6 +41,8 @@
        state_header1,
        state_vheader5,
        state_vheader6,
+       state_header3,
+       state_header4,
        state_error
 } verifier_state_t;
 
@@ -227,7 +229,10 @@
        {0xf2, check_for_header2_err},
        {0xf0, check_for_header1_err},
        {0xcc, check_for_dummy},
-       {0x00, check_number_texunits}
+       {0x00, check_number_texunits},
+       {0x01, no_check},
+       {0x02, no_check},
+       {0x03, no_check}
 };
 
 static hazard_t table1[256];
@@ -768,11 +773,12 @@
                DRM_ERROR("Invalid VIDEO DMA command. "
                          "Attempt to access 3D- or command burst area.\n");
                return 1;
-       } else if ((address > 0xCFF) && (address < 0x1300)) {
+       } else if ((address > 0xDFF) && (address < 0x1200)) {
                DRM_ERROR("Invalid VIDEO DMA command. "
                          "Attempt to access PCI DMA area.\n");
                return 1;
-       } else if (address > 0x13FF) {
+       } else if (((address > 0x13FF) && (address < 0x2200)) ||
+               (address > 0x33ff)) {
                DRM_ERROR("Invalid VIDEO DMA command. "
                          "Attempt to access VGA registers.\n");
                return 1;
@@ -791,10 +797,11 @@
                return 1;
        }
        while (dwords--) {
-               if (*buf++) {
+               if (*buf && !is_dummy_cmd(*buf)) {
                        DRM_ERROR("Illegal video command tail.\n");
                        return 1;
                }
+               buf++;
        }
        *buffer = buf;
        return 0;
@@ -1001,6 +1008,14 @@
                case state_vheader6:
                        state = via_check_vheader6(&buf, buf_end);
                        break;
+               case state_header3:
+               case state_header4:
+                       buf++;
+                       while (buf < buf_end && !is_agp_header(*buf))
+                               buf++;
+                       state = state_command;
+                       break;
+
                case state_command:
                        if ((HALCYON_HEADER2 == (cmd = *buf)) &&
                            supported_3d)
@@ -1016,7 +1031,12 @@
                        else if ((cmd == HALCYON_HEADER2) && !supported_3d) {
                                DRM_ERROR("Accelerated 3D is not supported on 
this chipset yet.\n");
                                state = state_error;
-                       } else {
+                       } else if ((cmd & HALCYON_HEADER_MASK) ==
+                                       HALCYON_HEADER3)
+                               state = state_header3;
+                       else if ((cmd & HALCYON_HEADER_MASK) == HALCYON_HEADER4)
+                               state = state_header4;
+                       else {
                                DRM_ERROR
                                    ("Invalid / Unimplemented DMA HEADER 
command. 0x%x\n",
                                     cmd);
diff -Nur linux-2.6.32-rc3-old/drivers/gpu/drm/via/via_verifier.h 
linux-2.6.32-rc3-new/drivers/gpu/drm/via/via_verifier.h
--- linux-2.6.32-rc3-old/drivers/gpu/drm/via/via_verifier.h     2009-10-05 
08:12:30.000000000 +0800
+++ linux-2.6.32-rc3-new/drivers/gpu/drm/via/via_verifier.h     2009-10-08 
10:19:12.000000000 +0800
@@ -25,7 +25,8 @@
 
 #ifndef _VIA_VERIFIER_H_
 #define _VIA_VERIFIER_H_
-
+#include "via_3d_reg.h"
+#define INV_DUMMY_MASK 0xFF000000
 typedef enum {
        no_sequence = 0,
        z_address,
@@ -59,4 +60,38 @@
 extern int via_parse_command_stream(struct drm_device *dev, const uint32_t 
*buf,
                                    unsigned int size);
 
+static inline int is_agp_header(unsigned int data)
+{
+       if (data == HALCYON_HEADER2)
+               return 1;
+       else if ((data & VIA_VIDEOMASK) == VIA_VIDEO_HEADER5)
+               ;
+       else if ((data & VIA_VIDEOMASK) == VIA_VIDEO_HEADER6)
+               ;
+       else if (data & HALCYON_HEADER_MASK) {
+               switch (data & HALCYON_HEADER_MASK) {
+               case HALCYON_HEADER3:
+               case HALCYON_HEADER4:
+               case HALCYON_HEADER1:
+                       return 1;
+               default:
+                       return 0;
+               }
+       } else
+               return 0;
+
+       return 1;
+}
+
+static inline int is_dummy_cmd(uint32_t cmd)
+{
+               if ((cmd & INV_DUMMY_MASK) == 0xCC000000 ||
+                       (cmd & INV_DUMMY_MASK) == 0xCD000000 ||
+                       (cmd & INV_DUMMY_MASK) == 0xCE000000 ||
+                       (cmd & INV_DUMMY_MASK) == 0xCF000000 ||
+                       (cmd & INV_DUMMY_MASK) == 0xDD000000)
+                       return 1;
+               return 0;
+}
+
 #endif

Thanks and Best regards  
=================================================
Bruce C. Chang(張祖明)
VIA Technologies, Inc. 
Address: 1F, 531, Chung-Cheng Road, Hsin-Tien, 231 Taipei
Tel: +886-2-22185452 Ext 7323
Mobile: +886-968343824
Fax: +886-2-22186282
Skype: Bruce.C.Chang
Email: [email protected]
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to