Using a correct DATAPORT and SFID for some send message of haswell.
authorJunyan He <junyan.he@linux.intel.com>
Wed, 7 May 2014 10:02:56 +0000 (18:02 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Mon, 12 May 2014 06:42:56 +0000 (14:42 +0800)
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Signed-off-by: Junyan He <junyan.he@linux.intel.com>
backend/src/backend/gen75_context.cpp
backend/src/backend/gen75_encoder.cpp
backend/src/backend/gen75_encoder.hpp
backend/src/backend/gen_defs.hpp
backend/src/backend/gen_encoder.cpp
backend/src/backend/gen_encoder.hpp

index 909b301..ede9d55 100644 (file)
 
 namespace gbe
 {
+  void Gen75Encoder::setDPUntypedRW(GenNativeInstruction *insn,
+                                    uint32_t bti,
+                                    uint32_t rgba,
+                                    uint32_t msg_type,
+                                    uint32_t msg_length,
+                                    uint32_t response_length)
+  {
+    const GenMessageTarget sfid = GEN_SFID_DATAPORT1_DATA_CACHE;
+    setMessageDescriptor(insn, sfid, msg_length, response_length);
+    insn->bits3.gen7_untyped_rw.msg_type = msg_type;
+    insn->bits3.gen7_untyped_rw.bti = bti;
+    insn->bits3.gen7_untyped_rw.rgba = rgba;
+    if (curr.execWidth == 8)
+      insn->bits3.gen7_untyped_rw.simd_mode = GEN_UNTYPED_SIMD8;
+    else if (curr.execWidth == 16)
+      insn->bits3.gen7_untyped_rw.simd_mode = GEN_UNTYPED_SIMD16;
+    else
+      NOT_SUPPORTED;
+  }
 
+  void Gen75Encoder::setTypedWriteMessage(GenNativeInstruction *insn, unsigned char bti,
+                                          unsigned char msg_type, uint32_t msg_length, bool header_present)
+  {
+    const GenMessageTarget sfid = GEN_SFID_DATAPORT1_DATA_CACHE;
+    setMessageDescriptor(insn, sfid, msg_length, 0, header_present);
+    insn->bits3.gen7_typed_rw.bti = bti;
+    insn->bits3.gen7_typed_rw.msg_type = msg_type;
+
+    /* Always using the low 8 slots here. */
+    insn->bits3.gen7_typed_rw.slot = 1;
+  }
 } /* End of the name space. */
index 9541c26..53db3a7 100644 (file)
@@ -33,6 +33,12 @@ namespace gbe
   public:
     Gen75Encoder(uint32_t simdWidth, uint32_t gen, uint32_t deviceID)
          : GenEncoder(simdWidth, gen, deviceID, 8) { };
+
+    virtual void setDPUntypedRW(GenNativeInstruction *insn, uint32_t bti, uint32_t rgba,
+                   uint32_t msg_type, uint32_t msg_length, uint32_t response_length);
+    virtual void setTypedWriteMessage(GenNativeInstruction *insn, unsigned char bti,
+                                      unsigned char msg_type, uint32_t msg_length,
+                                      bool header_present);
   };
 }
 #endif /* __GBE_GEN75_ENCODER_HPP__ */
index 28e3203..1b43864 100644 (file)
@@ -209,7 +209,8 @@ enum GenMessageTarget {
   GEN6_SFID_DATAPORT_SAMPLER_CACHE  = 4,
   GEN6_SFID_DATAPORT_RENDER_CACHE   = 5,
   GEN6_SFID_DATAPORT_CONSTANT_CACHE = 9,
-  GEN_SFID_DATAPORT_DATA_CACHE     = 10,
+  GEN_SFID_DATAPORT_DATA_CACHE      = 10,
+  GEN_SFID_DATAPORT1_DATA_CACHE     = 12,
 };
 
 #define GEN_PREDICATE_NONE                    0
@@ -307,20 +308,46 @@ enum GenMessageTarget {
 #define GEN_BYTE_SCATTER_SIMD8    0
 #define GEN_BYTE_SCATTER_SIMD16   1
 
-/* Data port message type*/
-#define GEN_OBLOCK_READ           0 //0000: OWord Block Read
-#define GEN_UNALIGNED_OBLOCK_READ 1 //0001: Unaligned OWord Block Read
-#define GEN_ODBLOCK_READ          2 //0010: OWord Dual Block Read
-#define GEN_DWORD_GATHER          3 //0011: DWord Scattered Read
-#define GEN_BYTE_GATHER           4 //0100: Byte Scattered Read
-#define GEN_UNTYPED_READ          5 //0101: Untyped Surface Read
-#define GEN_UNTYPED_ATOMIC_READ   6 //0110: Untyped Atomic Operation
-#define GEN_MEMORY_FENCE          7 //0111: Memory Fence
-#define GEN_OBLOCK_WRITE          8 //1000: OWord Block Write
-#define GEN_ODBLOCK_WRITE         10//1010: OWord Dual Block Write
-#define GEN_DWORD_SCATTER         11//1011: DWord Scattered Write
-#define GEN_BYTE_SCATTER          12//1100: Byte Scattered Write
-#define GEN_UNTYPED_WRITE         13//1101: Untyped Surface Write
+/* Data port message type for gen7*/
+#define GEN7_OBLOCK_READ           0 //0000: OWord Block Read
+#define GEN7_UNALIGNED_OBLOCK_READ 1 //0001: Unaligned OWord Block Read
+#define GEN7_ODBLOCK_READ          2 //0010: OWord Dual Block Read
+#define GEN7_DWORD_GATHER          3 //0011: DWord Scattered Read
+#define GEN7_BYTE_GATHER           4 //0100: Byte Scattered Read
+#define GEN7_UNTYPED_READ          5 //0101: Untyped Surface Read
+#define GEN7_UNTYPED_ATOMIC_READ   6 //0110: Untyped Atomic Operation
+#define GEN7_MEMORY_FENCE          7 //0111: Memory Fence
+#define GEN7_OBLOCK_WRITE          8 //1000: OWord Block Write
+#define GEN7_ODBLOCK_WRITE         10//1010: OWord Dual Block Write
+#define GEN7_DWORD_SCATTER         11//1011: DWord Scattered Write
+#define GEN7_BYTE_SCATTER          12//1100: Byte Scattered Write
+#define GEN7_UNTYPED_WRITE         13//1101: Untyped Surface Write
+
+/* Data port0 message type for Gen75*/
+#define GEN75_P0_OBLOCK_READ            0 //0000: OWord Block Read
+#define GEN75_P0_UNALIGNED_OBLOCK_READ  1 //0001: Unaligned OWord Block Read
+#define GEN75_P0_ODBLOCK_READ           2 //0010: OWord Dual Block Read
+#define GEN75_P0_DWORD_GATHER           3 //0011: DWord Scattered Read
+#define GEN75_P0_BYTE_GATHER            4 //0100: Byte Scattered Read
+#define GEN75_P0_MEMORY_FENCE           7 //0111: Memory Fence
+#define GEN75_P0_OBLOCK_WRITE           8 //1000: OWord Block Write
+#define GEN75_P0_ODBLOCK_WRITE         10 //1010: OWord Dual Block Write
+#define GEN75_P0_DWORD_SCATTER         11 //1011: DWord Scattered Write
+#define GEN75_P0_BYTE_SCATTER          12 //1100: Byte Scattered Write
+
+/* Data port1 message type for Gen75*/
+#define GEN75_P1_UNTYPED_READ           1 //0001: Untyped Surface Read
+#define GEN75_P1_UNTYPED_ATOMIC_OP      2 //0010: Untyped Atomic Operation
+#define GEN75_P1_UNTYPED_ATOMIC_OP_4X2  3 //0011: Untyped Atomic Operation SIMD4x2
+#define GEN75_P1_MEDIA_BREAD            4 //0100: Media Block Read
+#define GEN75_P1_TYPED_SURFACE_READ     5 //0101: Typed Surface Read
+#define GEN75_P1_TYPED_ATOMIC_OP        6 //0110: Typed Atomic Operation
+#define GEN75_P1_TYPED_ATOMIC_OP_4X2    7 //0111: Typed Atomic Operation SIMD4x2
+#define GEN75_P1_UNTYPED_SURFACE_WRITE  9 //1001: Untyped Surface Write
+#define GEN75_P1_MEDIA_TYPED_BWRITE    10 //1010: Media Block Write
+#define GEN75_P1_ATOMIC_COUNTER        11 //1011: Atomic Counter Operation
+#define GEN75_P1_ATOMIC_COUNTER_4X2    12 //1100: Atomic Counter Operation 4X2
+#define GEN75_P1_TYPED_SURFACE_WRITE   13 //1101: Typed Surface Write
 
 /* Data port data cache scratch messages*/
 #define GEN_SCRATCH_READ                  0
@@ -867,8 +894,7 @@ union GenNativeInstruction
       struct {
         uint32_t bti:8;
         uint32_t chan_mask:4;
-        uint32_t pad:1;
-        uint32_t slot:1;
+        uint32_t slot:2;
         uint32_t msg_type:4;
         uint32_t pad2:1;
         uint32_t header_present:1;
index 1f8ecc6..059ea94 100644 (file)
@@ -93,15 +93,12 @@ namespace gbe
     return false;
   }
 
-  static void setMessageDescriptor(GenEncoder *p,
-                                   GenNativeInstruction *inst,
-                                   enum GenMessageTarget sfid,
-                                   unsigned msg_length,
-                                   unsigned response_length,
-                                   bool header_present = false,
-                                   bool end_of_thread = false)
+
+  void GenEncoder::setMessageDescriptor(GenNativeInstruction *inst, enum GenMessageTarget sfid,
+                                        unsigned msg_length, unsigned response_length,
+                                        bool header_present, bool end_of_thread)
   {
-     p->setSrc1(inst, GenRegister::immd(0));
+     setSrc1(inst, GenRegister::immd(0));
      inst->bits3.generic_gen5.header_present = header_present;
      inst->bits3.generic_gen5.response_length = response_length;
      inst->bits3.generic_gen5.msg_length = msg_length;
@@ -109,22 +106,28 @@ namespace gbe
      inst->header.destreg_or_condmod = sfid;
   }
 
-  static void setDPUntypedRW(GenEncoder *p,
-                             GenNativeInstruction *insn,
-                             uint32_t bti,
-                             uint32_t rgba,
-                             uint32_t msg_type,
-                             uint32_t msg_length,
-                             uint32_t response_length)
+  void GenEncoder::setTypedWriteMessage(GenNativeInstruction *insn, unsigned char bti,
+                                        unsigned char msg_type, uint32_t msg_length,
+                                        bool header_present)
+  {
+    const GenMessageTarget sfid = GEN6_SFID_DATAPORT_RENDER_CACHE;
+    setMessageDescriptor(insn, sfid, msg_length, 0, header_present);
+    insn->bits3.gen7_typed_rw.bti = bti;
+    insn->bits3.gen7_typed_rw.msg_type = msg_type;
+  }
+
+  void GenEncoder::setDPUntypedRW(GenNativeInstruction *insn, uint32_t bti,
+                                  uint32_t rgba, uint32_t msg_type,
+                                  uint32_t msg_length, uint32_t response_length)
   {
     const GenMessageTarget sfid = GEN_SFID_DATAPORT_DATA_CACHE;
-    setMessageDescriptor(p, insn, sfid, msg_length, response_length);
+    setMessageDescriptor(insn, sfid, msg_length, response_length);
     insn->bits3.gen7_untyped_rw.msg_type = msg_type;
     insn->bits3.gen7_untyped_rw.bti = bti;
     insn->bits3.gen7_untyped_rw.rgba = rgba;
-    if (p->curr.execWidth == 8)
+    if (curr.execWidth == 8)
       insn->bits3.gen7_untyped_rw.simd_mode = GEN_UNTYPED_SIMD8;
-    else if (p->curr.execWidth == 16)
+    else if (curr.execWidth == 16)
       insn->bits3.gen7_untyped_rw.simd_mode = GEN_UNTYPED_SIMD16;
     else
       NOT_SUPPORTED;
@@ -139,7 +142,7 @@ namespace gbe
                                      uint32_t response_length)
   {
     const GenMessageTarget sfid = GEN_SFID_DATAPORT_DATA_CACHE;
-    setMessageDescriptor(p, insn, sfid, msg_length, response_length);
+    p->setMessageDescriptor(insn, sfid, msg_length, response_length);
     insn->bits3.gen7_byte_rw.msg_type = msg_type;
     insn->bits3.gen7_byte_rw.bti = bti;
     insn->bits3.gen7_byte_rw.data_size = elem_size;
@@ -160,7 +163,7 @@ namespace gbe
                           uint32_t response_length)
   {
     const GenMessageTarget sfid = GEN_SFID_DATAPORT_DATA_CACHE;
-    setMessageDescriptor(p, insn, sfid, msg_length, response_length);
+    p->setMessageDescriptor(insn, sfid, msg_length, response_length);
     assert(size == 2 || size == 4);
     insn->bits3.gen7_oblock_rw.msg_type = msg_type;
     insn->bits3.gen7_oblock_rw.bti = bti;
@@ -181,26 +184,13 @@ namespace gbe
                                 uint32_t return_format)
   {
      const GenMessageTarget sfid = GEN_SFID_SAMPLER;
-     setMessageDescriptor(p, insn, sfid, msg_length, response_length);
+     p->setMessageDescriptor(insn, sfid, msg_length, response_length);
      insn->bits3.sampler_gen7.bti = bti;
      insn->bits3.sampler_gen7.sampler = sampler;
      insn->bits3.sampler_gen7.msg_type = msg_type;
      insn->bits3.sampler_gen7.simd_mode = simd_mode;
   }
 
-
-  static void setTypedWriteMessage(GenEncoder *p,
-                                   GenNativeInstruction *insn,
-                                   unsigned char bti,
-                                   unsigned char msg_type,
-                                   uint32_t msg_length,
-                                   bool header_present)
-  {
-     const GenMessageTarget sfid = GEN6_SFID_DATAPORT_RENDER_CACHE;
-     setMessageDescriptor(p, insn, sfid, msg_length, 0, header_present);
-     insn->bits3.gen7_typed_rw.bti = bti;
-     insn->bits3.gen7_typed_rw.msg_type = msg_type;
-  }
   static void setDWordScatterMessgae(GenEncoder *p,
                                      GenNativeInstruction *insn,
                                      uint32_t bti,
@@ -214,7 +204,7 @@ namespace gbe
     // We workaround it to use DATA CACHE instead.
     const GenMessageTarget sfid = (p->deviceID == PCI_CHIP_BAYTRAIL_T) ?
                                  GEN_SFID_DATAPORT_DATA_CACHE : GEN6_SFID_DATAPORT_CONSTANT_CACHE;
-    setMessageDescriptor(p, insn, sfid, msg_length, response_length);
+    p->setMessageDescriptor(insn, sfid, msg_length, response_length);
     insn->bits3.gen7_dword_rw.msg_type = msg_type;
     insn->bits3.gen7_dword_rw.bti = bti;
     insn->bits3.gen7_dword_rw.block_size = block_size;
@@ -466,11 +456,10 @@ namespace gbe
     this->setDst(insn,  GenRegister::uw16grf(dst.nr, 0));
     this->setSrc0(insn, GenRegister::ud8grf(src.nr, 0));
     this->setSrc1(insn, GenRegister::immud(0));
-    setDPUntypedRW(this,
-                   insn,
+    setDPUntypedRW(insn,
                    bti,
                    untypedRWMask[elemNum],
-                   GEN_UNTYPED_READ,
+                   GEN7_UNTYPED_READ,
                    msg_length,
                    response_length);
   }
@@ -492,11 +481,10 @@ namespace gbe
       NOT_IMPLEMENTED;
     this->setSrc0(insn, GenRegister::ud8grf(msg.nr, 0));
     this->setSrc1(insn, GenRegister::immud(0));
-    setDPUntypedRW(this,
-                   insn,
+    setDPUntypedRW(insn,
                    bti,
                    untypedRWMask[elemNum],
-                   GEN_UNTYPED_WRITE,
+                   GEN7_UNTYPED_WRITE,
                    msg_length,
                    response_length);
   }
@@ -522,7 +510,7 @@ namespace gbe
                            insn,
                            bti,
                            elemSize,
-                           GEN_BYTE_GATHER,
+                           GEN7_BYTE_GATHER,
                            msg_length,
                            response_length);
   }
@@ -546,7 +534,7 @@ namespace gbe
                            insn,
                            bti,
                            elemSize,
-                           GEN_BYTE_SCATTER,
+                           GEN7_BYTE_SCATTER,
                            msg_length,
                            response_length);
   }
@@ -575,7 +563,7 @@ namespace gbe
                            insn,
                            bti,
                            block_size,
-                           GEN_DWORD_GATHER,
+                           GEN7_DWORD_GATHER,
                            msg_length,
                            response_length);
 
@@ -601,8 +589,8 @@ namespace gbe
     this->setSrc1(insn, GenRegister::immud(0));
 
     const GenMessageTarget sfid = GEN_SFID_DATAPORT_DATA_CACHE;
-    setMessageDescriptor(this, insn, sfid, msg_length, response_length);
-    insn->bits3.gen7_atomic_op.msg_type = GEN_UNTYPED_ATOMIC_READ;
+    setMessageDescriptor(insn, sfid, msg_length, response_length);
+    insn->bits3.gen7_atomic_op.msg_type = GEN7_UNTYPED_ATOMIC_READ;
     insn->bits3.gen7_atomic_op.bti = bti;
     insn->bits3.gen7_atomic_op.return_data = 1;
     insn->bits3.gen7_atomic_op.aop_type = function;
@@ -1078,7 +1066,7 @@ namespace gbe
      this->setHeader(insn);
      this->setDst(insn, GenRegister::null());
      this->setSrc0(insn, src);
-     setMessageDescriptor(this, insn, GEN_SFID_MESSAGE_GATEWAY, 1, 0);
+     setMessageDescriptor(insn, GEN_SFID_MESSAGE_GATEWAY, 1, 0);
      insn->bits3.msg_gateway.sub_function_id = GEN_BARRIER_MSG;
      insn->bits3.msg_gateway.notify = 0x1;
   }
@@ -1087,7 +1075,7 @@ namespace gbe
     this->setHeader(insn);
     this->setDst(insn, dst);
     this->setSrc0(insn, dst);
-    setMessageDescriptor(this, insn, GEN_SFID_DATAPORT_DATA_CACHE, 1, 1, 1);
+    setMessageDescriptor(insn, GEN_SFID_DATAPORT_DATA_CACHE, 1, 1, 1);
     insn->bits3.gen7_memory_fence.msg_type = GEN_MEM_FENCE;
     insn->bits3.gen7_memory_fence.commit_enable = 0x1;
   }
@@ -1316,7 +1304,7 @@ namespace gbe
      this->setHeader(insn);
      this->setDst(insn, GenRegister::retype(GenRegister::null(), GEN_TYPE_UD));
      this->setSrc0(insn, msg);
-     setTypedWriteMessage(this, insn, bti, msg_type, msg_length, header_present);
+     setTypedWriteMessage(insn, bti, msg_type, msg_length, header_present);
   }
   static void setScratchMessage(GenEncoder *p,
                                    GenNativeInstruction *insn,
@@ -1328,7 +1316,7 @@ namespace gbe
                                    uint32_t response_length)
   {
      const GenMessageTarget sfid = GEN_SFID_DATAPORT_DATA_CACHE;
-     setMessageDescriptor(p, insn, sfid, msg_length, response_length, true);
+     p->setMessageDescriptor(insn, sfid, msg_length, response_length, true);
      insn->bits3.gen7_scratch_rw.block_size = block_size;
      insn->bits3.gen7_scratch_rw.msg_type = msg_type;
      insn->bits3.gen7_scratch_rw.channel_mode = channel_mode;
index 024d9c6..31d7f4e 100644 (file)
@@ -207,6 +207,15 @@ namespace gbe
     ////////////////////////////////////////////////////////////////////////
     // Helper functions to encode
     ////////////////////////////////////////////////////////////////////////
+    virtual void setDPUntypedRW(GenNativeInstruction *insn, uint32_t bti, uint32_t rgba,
+                                uint32_t msg_type, uint32_t msg_length,
+                                uint32_t response_length);
+    virtual void setTypedWriteMessage(GenNativeInstruction *insn, unsigned char bti,
+                                      unsigned char msg_type, uint32_t msg_length,
+                                      bool header_present);
+    void setMessageDescriptor(GenNativeInstruction *inst, enum GenMessageTarget sfid,
+                              unsigned msg_length, unsigned response_length,
+                              bool header_present = false, bool end_of_thread = false);
     void setHeader(GenNativeInstruction *insn);
     void setDst(GenNativeInstruction *insn, GenRegister dest);
     void setSrc0(GenNativeInstruction *insn, GenRegister reg);