SKL: use the hw defautl value mocs index before linux 4.3.

Submitted by Yang, Rong R on Dec. 28, 2015, 2:40 a.m.

Details

Message ID 1451270414-6130-1-git-send-email-rong.r.yang@intel.com
State New
Headers show
Series "SKL: use the hw defautl value mocs index before linux 4.3." ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Yang, Rong R Dec. 28, 2015, 2:40 a.m.
From linux 4.3, kernel redefined the mocs table's value,
But before 4.3, still used the hw defautl value.

Signed-off-by: Yang Rong <rong.r.yang@intel.com>
---
 src/intel/intel_gpgpu.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/intel/intel_gpgpu.c b/src/intel/intel_gpgpu.c
index 7e379a2..ac92ed3 100644
--- a/src/intel/intel_gpgpu.c
+++ b/src/intel/intel_gpgpu.c
@@ -26,6 +26,7 @@ 
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/utsname.h>
 #include <fcntl.h>
 #include <stddef.h>
 #include <errno.h>
@@ -287,7 +288,20 @@  intel_gpgpu_get_cache_ctrl_gen9()
 {
   //Kernel-defined cache control registers 2:
   //L3CC: WB; LeCC: WB; TC: LLC/eLLC;
-  return (0x2 << 1);
+  int major = 0, minor = 0;
+  int mocs_index = 0x2;
+
+  struct utsname buf;
+  uname(&buf);
+  sscanf(buf.release, "%d.%d", &major, &minor);
+  //From linux 4.3, kernel redefined the mocs table's value,
+  //But before 4.3, still used the hw defautl value.
+  if(strcmp(buf.sysname, "Linux") == 0 &&
+     major == 4 && minor < 3) { /* linux kernel support skl from  4.x, so check from 4 */
+    mocs_index = 0x9;
+  }
+
+  return (mocs_index << 1);
 }
 
 static void

Comments

Yes, looks acceptable. And seems no other better choice.

Thanks!
Ruiling

> -----Original Message-----

> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf Of

> Yang Rong

> Sent: Monday, December 28, 2015 10:40 AM

> To: beignet@lists.freedesktop.org

> Cc: Yang, Rong R <rong.r.yang@intel.com>

> Subject: [Beignet] [PATCH] SKL: use the hw defautl value mocs index before linux

> 4.3.

> 

> From linux 4.3, kernel redefined the mocs table's value,

> But before 4.3, still used the hw defautl value.

> 

> Signed-off-by: Yang Rong <rong.r.yang@intel.com>

> ---

>  src/intel/intel_gpgpu.c | 16 +++++++++++++++-

>  1 file changed, 15 insertions(+), 1 deletion(-)

> 

> diff --git a/src/intel/intel_gpgpu.c b/src/intel/intel_gpgpu.c

> index 7e379a2..ac92ed3 100644

> --- a/src/intel/intel_gpgpu.c

> +++ b/src/intel/intel_gpgpu.c

> @@ -26,6 +26,7 @@

>  #include <unistd.h>

>  #include <sys/types.h>

>  #include <sys/stat.h>

> +#include <sys/utsname.h>

>  #include <fcntl.h>

>  #include <stddef.h>

>  #include <errno.h>

> @@ -287,7 +288,20 @@ intel_gpgpu_get_cache_ctrl_gen9()

>  {

>    //Kernel-defined cache control registers 2:

>    //L3CC: WB; LeCC: WB; TC: LLC/eLLC;

> -  return (0x2 << 1);

> +  int major = 0, minor = 0;

> +  int mocs_index = 0x2;

> +

> +  struct utsname buf;

> +  uname(&buf);

> +  sscanf(buf.release, "%d.%d", &major, &minor);

> +  //From linux 4.3, kernel redefined the mocs table's value,

> +  //But before 4.3, still used the hw defautl value.

> +  if(strcmp(buf.sysname, "Linux") == 0 &&

> +     major == 4 && minor < 3) { /* linux kernel support skl from  4.x, so check

> from 4 */

> +    mocs_index = 0x9;

> +  }

> +

> +  return (mocs_index << 1);

>  }

> 

>  static void

> --

> 2.1.4

> 

> _______________________________________________

> Beignet mailing list

> Beignet@lists.freedesktop.org

> http://lists.freedesktop.org/mailman/listinfo/beignet