Hi Emil,

The first attachment is the patch for 10.2. The other two patches fix
build with latest LLVM for 10.2.

Marek

On Tue, Aug 26, 2014 at 10:09 PM, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> On 06/08/14 17:16, Alex Deucher wrote:
>> On Mon, Aug 4, 2014 at 6:48 AM, Andreas Boll <andreas.boll....@gmail.com> 
>> wrote:
>>> The initial firmware for hawaii does not support type3 nop packet.
>>> Detect the new hawaii firmware with query RADEON_INFO_ACCEL_WORKING2.
>>> If the returned value is 3, then the new firmware is used.
>>>
>>> This patch uses type2 for the old firmware and type3 for the new firmware.
>>>
>>> It fixes the cases when the old firmware is used and the user wants to
>>> manually enable acceleration.
>>> The two possible scenarios are:
>>>  - the kernel has no support for the new firmware.
>>>  - the kernel has support for the new firmware but only the old firmware
>>>    is available.
>>>
>>> Additionaly this patch disables GPU acceleration on hawaii if the kernel
>>> returns a value < 2. In this case the kernel hasn't the required fixes
>>> for proper acceleration.
>>>
>>> v2:
>>>  - Fix indentation
>>>  - Use private struct radeon_drm_winsys instead of public struct radeon_info
>>>  - Rename r600_accel_working2 to accel_working2
>>>
>>> v3:
>>>  - Use type2 nop packet for returned value < 3
>>>
>>> v4:
>>>  - Fail to initialize winsys for returned value < 2
>>>
>>> Cc: mesa-sta...@lists.freedesktop.org
>>> Cc: Alex Deucher <alexander.deuc...@amd.com>
>>> Cc: Jérôme Glisse <jgli...@redhat.com>
>>> Cc: Marek Olšák <marek.ol...@amd.com>
>>> Cc: Michel Dänzer <michel.daen...@amd.com>
>>> Signed-off-by: Andreas Boll <andreas.boll....@gmail.com>
>>
>> Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>
>>
> Gents this patch does not apply cleanly on the 10.2 branch. Would be nice if
> someone can backport rather than me butchering it.
>
> Thanks
> Emil
>
>>> ---
>>>
>>> Unfortunately I can't test this patch myself since I don't own a hawaii 
>>> card.
>>> So I'd need someone to test this patch on kernel >= 3.16-rc7 + these patches
>>> [1-2].
>>>
>>> This patch would bring us one step further for hawaii acceleration on kernel
>>> 3.16.
>>>
>>> Finally we can enable hawaii acceleration if the query returns > 2 [3].
>>>
>>> Andreas.
>>>
>>> [1] http://lists.freedesktop.org/archives/dri-devel/2014-August/065305.html
>>> [2] http://lists.freedesktop.org/archives/dri-devel/2014-August/065306.html
>>> [3] http://lists.x.org/archives/xorg-driver-ati/2014-August/026534.html
>>>
>>>  src/gallium/winsys/radeon/drm/radeon_drm_cs.c     |  6 +++++-
>>>  src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 10 ++++++++++
>>>  src/gallium/winsys/radeon/drm/radeon_drm_winsys.h |  1 +
>>>  3 files changed, 16 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c 
>>> b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
>>> index a06ecb2..dd109af 100644
>>> --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
>>> +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
>>> @@ -446,8 +446,12 @@ static void radeon_drm_cs_flush(struct 
>>> radeon_winsys_cs *rcs,
>>>      case RING_GFX:
>>>          /* pad DMA ring to 8 DWs to meet CP fetch alignment requirements
>>>           * r6xx, requires at least 4 dw alignment to avoid a hw bug.
>>> +         * hawaii with old firmware needs type2 nop packet.
>>> +         * accel_working2 with value 2 indicates the new firmware.
>>>           */
>>> -        if (cs->ws->info.chip_class <= SI) {
>>> +        if (cs->ws->info.chip_class <= SI ||
>>> +            (cs->ws->info.family == CHIP_HAWAII &&
>>> +             cs->ws->accel_working2 < 3)) {
>>>              while (rcs->cdw & 7)
>>>                  OUT_CS(&cs->base, 0x80000000); /* type2 nop packet */
>>>          } else {
>>> diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
>>> b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
>>> index 910d06b..ecff0e7 100644
>>> --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
>>> +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
>>> @@ -395,6 +395,16 @@ static boolean do_winsys_init(struct radeon_drm_winsys 
>>> *ws)
>>>      radeon_get_drm_value(ws->fd, RADEON_INFO_MAX_SH_PER_SE, NULL,
>>>                           &ws->info.max_sh_per_se);
>>>
>>> +    radeon_get_drm_value(ws->fd, RADEON_INFO_ACCEL_WORKING2, NULL,
>>> +                         &ws->accel_working2);
>>> +    if (ws->info.family == CHIP_HAWAII && ws->accel_working2 < 2) {
>>> +        fprintf(stderr, "radeon: GPU acceleration for Hawaii disabled, "
>>> +                "returned accel_working2 value %u is smaller than 2. "
>>> +                "Please install a newer kernel.\n",
>>> +                ws->accel_working2);
>>> +        return FALSE;
>>> +    }
>>> +
>>>      if (radeon_get_drm_value(ws->fd, RADEON_INFO_SI_TILE_MODE_ARRAY, NULL,
>>>                               ws->info.si_tile_mode_array)) {
>>>          ws->info.si_tile_mode_array_valid = TRUE;
>>> diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h 
>>> b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
>>> index ea6f7f0..aebc391 100644
>>> --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
>>> +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
>>> @@ -55,6 +55,7 @@ struct radeon_drm_winsys {
>>>      enum radeon_generation gen;
>>>      struct radeon_info info;
>>>      uint32_t va_start;
>>> +    uint32_t accel_working2;
>>>
>>>      struct pb_manager *kman;
>>>      struct pb_manager *cman_vram;
>>> --
>>> 2.0.1
>>>
>>> _______________________________________________
>>> mesa-dev mailing list
>>> mesa-dev@lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> _______________________________________________
>> mesa-stable mailing list
>> mesa-sta...@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-stable
>>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
From 6284517cbad6b284e2b818a17809894f91afaa09 Mon Sep 17 00:00:00 2001
From: Andreas Boll <andreas.boll....@gmail.com>
Date: Thu, 24 Jul 2014 17:30:31 -0400
Subject: [PATCH] winsys/radeon: fix nop packet padding for hawaii
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

// Marek - merged cce58147eb1450a26c03756af37da52d180580c4 into this one

The initial firmware for hawaii does not support type3 nop packet.
Detect the new hawaii firmware with query RADEON_INFO_ACCEL_WORKING2.
If the returned value is 3, then the new firmware is used.

This patch uses type2 for the old firmware and type3 for the new firmware.

It fixes the cases when the old firmware is used and the user wants to
manually enable acceleration.
The two possible scenarios are:
 - the kernel has no support for the new firmware.
 - the kernel has support for the new firmware but only the old firmware
   is available.

Additionaly this patch disables GPU acceleration on hawaii if the kernel
returns a value < 2. In this case the kernel hasn't the required fixes
for proper acceleration.

v2:
 - Fix indentation
 - Use private struct radeon_drm_winsys instead of public struct radeon_info
 - Rename r600_accel_working2 to accel_working2

v3:
 - Use type2 nop packet for returned value < 3

v4:
 - Fail to initialize winsys for returned value < 2

Cc: mesa-sta...@lists.freedesktop.org
Cc: Alex Deucher <alexander.deuc...@amd.com>
Cc: Jérôme Glisse <jgli...@redhat.com>
Cc: Marek Olšák <marek.ol...@amd.com>
Cc: Michel Dänzer <michel.daen...@amd.com>
Signed-off-by: Andreas Boll <andreas.boll....@gmail.com>
Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>

Conflicts:
	src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
---
 src/gallium/winsys/radeon/drm/radeon_drm_cs.c     | 62 ++++++++++++-----------
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 10 ++++
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.h |  1 +
 3 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index 67375dc..7e94ce4 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -155,7 +155,7 @@ static struct radeon_winsys_cs *
 radeon_drm_cs_create(struct radeon_winsys *rws,
                      enum ring_type ring_type,
                      void (*flush)(void *ctx, unsigned flags,
-				   struct pipe_fence_handle **fence),
+                                   struct pipe_fence_handle **fence),
                      void *flush_ctx,
                      struct radeon_winsys_cs_handle *trace_buf)
 {
@@ -196,10 +196,10 @@ radeon_drm_cs_create(struct radeon_winsys *rws,
 #define OUT_CS(cs, value) (cs)->buf[(cs)->cdw++] = (value)
 
 static INLINE void update_reloc(struct drm_radeon_cs_reloc *reloc,
-				enum radeon_bo_domain rd,
-				enum radeon_bo_domain wd,
-				unsigned priority,
-				enum radeon_bo_domain *added_domains)
+                                enum radeon_bo_domain rd,
+                                enum radeon_bo_domain wd,
+                                unsigned priority,
+                                enum radeon_bo_domain *added_domains)
 {
     *added_domains = (rd | wd) & ~(reloc->read_domains | reloc->write_domain);
 
@@ -434,33 +434,37 @@ static void radeon_drm_cs_flush(struct radeon_winsys_cs *rcs,
 
     switch (cs->base.ring_type) {
     case RING_DMA:
-	    /* pad DMA ring to 8 DWs */
-	    if (cs->ws->info.chip_class <= SI) {
-		    while (rcs->cdw & 7)
-			    OUT_CS(&cs->base, 0xf0000000); /* NOP packet */
-	    } else {
-		    while (rcs->cdw & 7)
-			    OUT_CS(&cs->base, 0x00000000); /* NOP packet */
-	    }
-	    break;
+        /* pad DMA ring to 8 DWs */
+        if (cs->ws->info.chip_class <= SI) {
+            while (rcs->cdw & 7)
+                OUT_CS(&cs->base, 0xf0000000); /* NOP packet */
+        } else {
+            while (rcs->cdw & 7)
+                OUT_CS(&cs->base, 0x00000000); /* NOP packet */
+        }
+        break;
     case RING_GFX:
-	    /* pad DMA ring to 8 DWs to meet CP fetch alignment requirements
-	     * r6xx, requires at least 4 dw alignment to avoid a hw bug.
-	     */
-	    if (cs->ws->info.chip_class <= SI) {
-		    while (rcs->cdw & 7)
-			    OUT_CS(&cs->base, 0x80000000); /* type2 nop packet */
-	    } else {
-		    while (rcs->cdw & 7)
-			    OUT_CS(&cs->base, 0xffff1000); /* type3 nop packet */
-	    }
-	    break;
+        /* pad DMA ring to 8 DWs to meet CP fetch alignment requirements
+         * r6xx, requires at least 4 dw alignment to avoid a hw bug.
+         * hawaii with old firmware needs type2 nop packet.
+         * accel_working2 with value 2 indicates the new firmware.
+         */
+        if (cs->ws->info.chip_class <= SI ||
+            (cs->ws->info.family == CHIP_HAWAII &&
+             cs->ws->accel_working2 < 3)) {
+            while (rcs->cdw & 7)
+                OUT_CS(&cs->base, 0x80000000); /* type2 nop packet */
+        } else {
+            while (rcs->cdw & 7)
+                OUT_CS(&cs->base, 0xffff1000); /* type3 nop packet */
+        }
+        break;
     case RING_UVD:
-            while (rcs->cdw & 15)
-		OUT_CS(&cs->base, 0x80000000); /* type2 nop packet */
-	    break;
+        while (rcs->cdw & 15)
+            OUT_CS(&cs->base, 0x80000000); /* type2 nop packet */
+        break;
     default:
-	    break;
+        break;
     }
 
     if (rcs->cdw > RADEON_MAX_CMDBUF_DWORDS) {
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index e54e79e..7033758 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -382,6 +382,16 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
     radeon_get_drm_value(ws->fd, RADEON_INFO_MAX_PIPES, NULL,
                          &ws->info.r600_max_pipes);
 
+    radeon_get_drm_value(ws->fd, RADEON_INFO_ACCEL_WORKING2, NULL,
+                         &ws->accel_working2);
+    if (ws->info.family == CHIP_HAWAII && ws->accel_working2 < 2) {
+        fprintf(stderr, "radeon: GPU acceleration for Hawaii disabled, "
+                "returned accel_working2 value %u is smaller than 2. "
+                "Please install a newer kernel.\n",
+                ws->accel_working2);
+        return FALSE;
+    }
+
     if (radeon_get_drm_value(ws->fd, RADEON_INFO_SI_TILE_MODE_ARRAY, NULL,
                              ws->info.si_tile_mode_array)) {
         ws->info.si_tile_mode_array_valid = TRUE;
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
index 18fe0ae..1e0c632 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
@@ -55,6 +55,7 @@ struct radeon_drm_winsys {
     enum radeon_generation gen;
     struct radeon_info info;
     uint32_t va_start;
+    uint32_t accel_working2;
 
     struct pb_manager *kman;
     struct pb_manager *cman;
-- 
1.9.1

From 98535ca302c9f72584754916606ef4ac05369aee Mon Sep 17 00:00:00 2001
From: Jan Vesely <jan.ves...@rutgers.edu>
Date: Mon, 4 Aug 2014 18:50:02 -0400
Subject: [PATCH 2/3] gallivm: Fix build with latest LLVM
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu>
Reviewed-and-Tested-by: Michel Dänzer <michel.daen...@amd.com>

Conflicts:
	src/gallium/auxiliary/gallivm/lp_bld_debug.cpp

cherry-picked from e28136343b6aa7dfff8ec85f6463574d6625b5a6
---
 src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
index 7e43b51..2629aaa 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
@@ -34,6 +34,10 @@
 #include <llvm/Support/Format.h>
 #include <llvm/Support/MemoryObject.h>
 
+#if HAVE_LLVM >= 0x0306
+#include <llvm/Target/TargetSubtargetInfo.h>
+#endif
+
 #if HAVE_LLVM >= 0x0300
 #include <llvm/Support/TargetRegistry.h>
 #include <llvm/MC/MCSubtargetInfo.h>
@@ -302,7 +306,11 @@ disassemble(const void* func, llvm::raw_ostream & Out)
    OwningPtr<TargetMachine> TM(T->createTargetMachine(Triple, ""));
 #endif
 
+#if HAVE_LLVM >= 0x0306
+   const TargetInstrInfo *TII = TM->getSubtargetImpl()->getInstrInfo();
+#else
    const TargetInstrInfo *TII = TM->getInstrInfo();
+#endif
 
    /*
     * Wrap the data in a MemoryObject
-- 
1.9.1

From 6586813273c74e1a1e1465a872283bf525c6b53f Mon Sep 17 00:00:00 2001
From: Vinson Lee <v...@freedesktop.org>
Date: Tue, 19 Aug 2014 23:17:40 -0700
Subject: [PATCH 3/3] gallivm: Fix build with LLVM >= 3.6 r215967.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This LLVM 3.6 commit changed EngineBuilder constructor.

commit 3f4ed32b4398eaf4fe0080d8001ba01e6c2f43c8
Author: Rafael Espindola <rafael.espind...@gmail.com>
Date:   Tue Aug 19 04:04:25 2014 +0000

    Make it explicit that ExecutionEngine takes ownership of the modules.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215967 91177308-0d34-0410-b5e6-96231b3b80d8

Signed-off-by: Vinson Lee <v...@freedesktop.org>
Reviewed-and-Tested-by: Michel Dänzer <michel.daen...@amd.com>
(cherry-picked from c04a6d5c298f102469df45a7dbe81f40c6faed5f)
---
 src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index 65c02d8..d85adfb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -266,7 +266,11 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
    using namespace llvm;
 
    std::string Error;
+#if HAVE_LLVM >= 0x0306
+   EngineBuilder builder(std::unique_ptr<Module>(unwrap(M)));
+#else
    EngineBuilder builder(unwrap(M));
+#endif
 
    /**
     * LLVM 3.1+ haven't more "extern unsigned llvm::StackAlignmentOverride" and
-- 
1.9.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to