Skip to contentSkip to conversation

igt/list-workarounds: Extend the script to Mesa

PATCH In review Sameer Kibey 3 participants 4 messages Feb 5, 2016 – Feb 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 igt/list-workarounds: Extend the script to Mesa

Updated the list-workarounds script so that it can parse Mesa directory if provided. Moved the common code to a separate function to allow reuse for both kernel and mesa.

The new command line is:
Usage: list-workarounds [options] path-to-kernel
-k path-to-kernel -m path-to-mesa

The legacy usage is retained to avoid breaking backwards compatibility. New parameters -k and -m are added for the new behavior.

Either kernel or mesa or both paths can be specified. If path-to-mesa is invalid, error is reported.

---
 scripts/list-workarounds | 74 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 53 insertions(+), 21 deletions(-)
scripts/list-workarounds +53 -21
index d11b6a9..8b41ae5 100755
@@ -18,7 +18,7 @@ def find_nth(haystack, needle, n):
 	return start
 
 valid_platforms = ('ctg', 'elk', 'ilk', 'snb', 'ivb', 'vlv', 'hsw', 'bdw',
-		   'chv', 'skl', 'bxt')
+		   'chv', 'skl', 'bxt', 'kbl')
 def parse_platforms(line, p):
 	l =  p.split(',')
 	for p in l:
@@ -65,9 +65,15 @@ def execute(cmd):
 	return out, err
 
 def parse_options(args):
-	usage = "Usage: list-workarounds [options] path-to-kernel"
+	usage = "Usage: list-workarounds [options] path-to-kernel -k path-to-kernel -m path-to-mesa"
 	parser = optparse.OptionParser(usage, version=1.0)
 
+	parser.add_option("-k", "--kernel-path", dest="kernel_path", default=None,
+			  help="path to kernel")
+
+	parser.add_option("-m", "--mesa-path", dest="mesa_path", default=None,
+			  help="path to mesa")
+
 	parser.add_option("-v", "--verbose", action="store_true",
 			  dest="verbose", default=False,
 			  help="be more verbose")
@@ -76,38 +82,64 @@ def parse_options(args):
 			  help="List workarounds for the specified platform")
 
 	(options, args) = parser.parse_args()
-
 	return (options, args)
 
-if __name__ == '__main__':
-	(options, args) = parse_options(sys.argv[1:])
-	verbose = options.verbose
-
-	if not len(args):
-		sys.stderr.write("error: A path to a kernel tree is required\n")
-		sys.exit(1)
-
-	kernel_path = args[0]
-	kconfig = os.path.join(kernel_path, 'Kconfig')
-	if not os.path.isfile(kconfig):
-		sys.stderr.write("error: %s does not point to a kernel tree \n"
-				 % kernel_path)
-		sys.exit(1)
-
-	i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
+def print_workarounds(project_root, driver_dir, project):
 	olddir = os.getcwd()
-	os.chdir(kernel_path)
+	os.chdir(project_root)
 	work_arounds, err = execute(['git', 'grep', '-n',
 				     '-e', 'W[aA][A-Z0-9][a-zA-Z0-9_]\+',
-				     i915_dir])
+				     driver_dir])
 	os.chdir(olddir)
 	if err:
 		print(err)
 		sys.exit(1)
 
 	parse(work_arounds)
+	print "\nList of workarounds found in %s:" % project
 	for wa in sorted(workarounds.keys()):
 		if not options.platform:
 			print("%s: %s" % (wa, ', '.join(workarounds[wa])))
 		elif options.platform in workarounds[wa]:
 			print(wa)
+
+
+if __name__ == '__main__':
+	(options, args) = parse_options(sys.argv)
+	verbose = options.verbose
+	kernel_path = None
+
+	if not len(args) and options.kernel_path == None and options.mesa_path == None:
+		sys.stderr.write("error: A path to either a kernel tree or Mesa is required\n")
+		sys.exit(1)
+
+	if len(args):
+		kernel_path = args[0]
+	elif options.kernel_path != None:
+		kernel_path = options.kernel_path
+
+	if kernel_path != None:
+	# --- list Kernel workarounds if path is provided ---
+		kconfig = os.path.join(kernel_path, 'Kconfig')
+		if not os.path.isfile(kconfig):
+			sys.stderr.write("error: %s does not point to a kernel tree \n"
+							% kernel_path)
+			sys.exit(1)
+
+		i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
+		print_workarounds(kernel_path, i915_dir, "kernel")
+
+	# --- list mesa workarounds if path is provided ---
+	if options.mesa_path != None:
+		# reset workarounds array
+		workarounds = {}
+
+		mesa_path = options.mesa_path
+		i965_dir = os.path.join('src', 'mesa', 'drivers', 'dri', 'i965')
+		mesa_dir = os.path.join(mesa_path, i965_dir)
+		if not os.path.exists(mesa_dir):
+			sys.stderr.write("error: %s does not point to a valid mesa path \n"
+							% mesa_path)
+			sys.exit(1)
+
+		print_workarounds(mesa_path, i965_dir, "Mesa")
Signature · 6 lines
1.9.1

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev
#1 lore raw
Quoted 9 lines · Sameer Kibey

Updated the list-workarounds script so that it can parse Mesa directory if provided. Moved the common code to a separate function to allow reuse for both kernel and mesa.

The new command line is:
Usage: list-workarounds [options] path-to-kernel
-k path-to-kernel -m path-to-mesa

Quoted 8 lines

The legacy usage is retained to avoid breaking backwards compatibility. New parameters -k and -m are added for the new behavior.

Either kernel or mesa or both paths can be specified. If path-to-mesa is invalid, error is reported.

Pushed thanks for the patch.

Signature · 1 line
Damien
Quoted 121 lines
---
 scripts/list-workarounds | 74 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 53 insertions(+), 21 deletions(-)
scripts/list-workarounds +53 -21
index d11b6a9..8b41ae5 100755
@@ -18,7 +18,7 @@ def find_nth(haystack, needle, n):
 	return start
 
 valid_platforms = ('ctg', 'elk', 'ilk', 'snb', 'ivb', 'vlv', 'hsw', 'bdw',
-		   'chv', 'skl', 'bxt')
+		   'chv', 'skl', 'bxt', 'kbl')
 def parse_platforms(line, p):
 	l =  p.split(',')
 	for p in l:
@@ -65,9 +65,15 @@ def execute(cmd):
 	return out, err
 
 def parse_options(args):
-	usage = "Usage: list-workarounds [options] path-to-kernel"
+	usage = "Usage: list-workarounds [options] path-to-kernel -k path-to-kernel -m path-to-mesa"
 	parser = optparse.OptionParser(usage, version=1.0)
 
+	parser.add_option("-k", "--kernel-path", dest="kernel_path", default=None,
+			  help="path to kernel")
+
+	parser.add_option("-m", "--mesa-path", dest="mesa_path", default=None,
+			  help="path to mesa")
+
 	parser.add_option("-v", "--verbose", action="store_true",
 			  dest="verbose", default=False,
 			  help="be more verbose")
@@ -76,38 +82,64 @@ def parse_options(args):
 			  help="List workarounds for the specified platform")
 
 	(options, args) = parser.parse_args()
-
 	return (options, args)
 
-if __name__ == '__main__':
-	(options, args) = parse_options(sys.argv[1:])
-	verbose = options.verbose
-
-	if not len(args):
-		sys.stderr.write("error: A path to a kernel tree is required\n")
-		sys.exit(1)
-
-	kernel_path = args[0]
-	kconfig = os.path.join(kernel_path, 'Kconfig')
-	if not os.path.isfile(kconfig):
-		sys.stderr.write("error: %s does not point to a kernel tree \n"
-				 % kernel_path)
-		sys.exit(1)
-
-	i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
+def print_workarounds(project_root, driver_dir, project):
 	olddir = os.getcwd()
-	os.chdir(kernel_path)
+	os.chdir(project_root)
 	work_arounds, err = execute(['git', 'grep', '-n',
 				     '-e', 'W[aA][A-Z0-9][a-zA-Z0-9_]\+',
-				     i915_dir])
+				     driver_dir])
 	os.chdir(olddir)
 	if err:
 		print(err)
 		sys.exit(1)
 
 	parse(work_arounds)
+	print "\nList of workarounds found in %s:" % project
 	for wa in sorted(workarounds.keys()):
 		if not options.platform:
 			print("%s: %s" % (wa, ', '.join(workarounds[wa])))
 		elif options.platform in workarounds[wa]:
 			print(wa)
+
+
+if __name__ == '__main__':
+	(options, args) = parse_options(sys.argv)
+	verbose = options.verbose
+	kernel_path = None
+
+	if not len(args) and options.kernel_path == None and options.mesa_path == None:
+		sys.stderr.write("error: A path to either a kernel tree or Mesa is required\n")
+		sys.exit(1)
+
+	if len(args):
+		kernel_path = args[0]
+	elif options.kernel_path != None:
+		kernel_path = options.kernel_path
+
+	if kernel_path != None:
+	# --- list Kernel workarounds if path is provided ---
+		kconfig = os.path.join(kernel_path, 'Kconfig')
+		if not os.path.isfile(kconfig):
+			sys.stderr.write("error: %s does not point to a kernel tree \n"
+							% kernel_path)
+			sys.exit(1)
+
+		i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
+		print_workarounds(kernel_path, i915_dir, "kernel")
+
+	# --- list mesa workarounds if path is provided ---
+	if options.mesa_path != None:
+		# reset workarounds array
+		workarounds = {}
+
+		mesa_path = options.mesa_path
+		i965_dir = os.path.join('src', 'mesa', 'drivers', 'dri', 'i965')
+		mesa_dir = os.path.join(mesa_path, i965_dir)
+		if not os.path.exists(mesa_dir):
+			sys.stderr.write("error: %s does not point to a valid mesa path \n"
+							% mesa_path)
+			sys.exit(1)
+
+		print_workarounds(mesa_path, i965_dir, "Mesa")
Signature · 1 line
1.9.1

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

#2 lore raw

Quoting Damien Lespiau (2016-02-05 15:46:51)

Quoted 14 lines · Sameer Kibey
Quoted 13 lines

Updated the list-workarounds script so that it can parse Mesa directory if provided. Moved the common code to a separate function to allow reuse for both kernel and mesa.

The new command line is:
Usage: list-workarounds [options] path-to-kernel
-k path-to-kernel -m path-to-mesa

The legacy usage is retained to avoid breaking backwards compatibility. New parameters -k and -m are added for the new behavior.

Quoted 82 lines
Quoted 4 lines

Either kernel or mesa or both paths can be specified. If path-to-mesa is invalid, error is reported.

Pushed thanks for the patch.

Signature · 1 line
Damien
Quoted 62 lines
---
 scripts/list-workarounds | 74 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 53 insertions(+), 21 deletions(-)
scripts/list-workarounds +10 -20
index d11b6a9..8b41ae5 100755
@@ -18,7 +18,7 @@ def find_nth(haystack, needle, n):
      return start
 
 valid_platforms = ('ctg', 'elk', 'ilk', 'snb', 'ivb', 'vlv', 'hsw', 'bdw',
-                'chv', 'skl', 'bxt')
+                'chv', 'skl', 'bxt', 'kbl')
 def parse_platforms(line, p):
      l =  p.split(',')
      for p in l:
@@ -65,9 +65,15 @@ def execute(cmd):
      return out, err
 
 def parse_options(args):
-     usage = "Usage: list-workarounds [options] path-to-kernel"
+     usage = "Usage: list-workarounds [options] path-to-kernel -k path-to-kernel -m path-to-mesa"
      parser = optparse.OptionParser(usage, version=1.0)
 
+     parser.add_option("-k", "--kernel-path", dest="kernel_path", default=None,
+                       help="path to kernel")
+
+     parser.add_option("-m", "--mesa-path", dest="mesa_path", default=None,
+                       help="path to mesa")
+
      parser.add_option("-v", "--verbose", action="store_true",
                        dest="verbose", default=False,
                        help="be more verbose")
@@ -76,38 +82,64 @@ def parse_options(args):
                        help="List workarounds for the specified platform")
 
      (options, args) = parser.parse_args()
-
      return (options, args)
 
-if __name__ == '__main__':
-     (options, args) = parse_options(sys.argv[1:])
-     verbose = options.verbose
-
-     if not len(args):
-             sys.stderr.write("error: A path to a kernel tree is required\n")
-             sys.exit(1)
-
-     kernel_path = args[0]
-     kconfig = os.path.join(kernel_path, 'Kconfig')
-     if not os.path.isfile(kconfig):
-             sys.stderr.write("error: %s does not point to a kernel tree \n"
-                              % kernel_path)
-             sys.exit(1)
-
-     i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
+def print_workarounds(project_root, driver_dir, project):
      olddir = os.getcwd()
-     os.chdir(kernel_path)
+     os.chdir(project_root)
      work_arounds, err = execute(['git', 'grep', '-n',

scripts/list-workarounds def parse_options(args): · line 99

Quoted 10 lines
scripts/list-workarounds +2 -1
                                   '-e', 'W[aA][A-Z0-9][a-zA-Z0-9_]\+',
-                                  i915_dir])
+                                  driver_dir])
      os.chdir(olddir)
      if err:
              print(err)
              sys.exit(1)
 
      parse(work_arounds)
+     print "\nList of workarounds found in %s:" % project

Hey Damien, the script says it's python 3, and this ^^^ is broken syntax in python 3 (but not in 2).

Quoted 45 lines
Quoted 45 lines
scripts/list-workarounds +40 -0
      for wa in sorted(workarounds.keys()):
              if not options.platform:
                      print("%s: %s" % (wa, ', '.join(workarounds[wa])))
              elif options.platform in workarounds[wa]:
                      print(wa)
+
+
+if __name__ == '__main__':
+     (options, args) = parse_options(sys.argv)
+     verbose = options.verbose
+     kernel_path = None
+
+     if not len(args) and options.kernel_path == None and options.mesa_path == None:
+             sys.stderr.write("error: A path to either a kernel tree or Mesa is required\n")
+             sys.exit(1)
+
+     if len(args):
+             kernel_path = args[0]
+     elif options.kernel_path != None:
+             kernel_path = options.kernel_path
+
+     if kernel_path != None:
+     # --- list Kernel workarounds if path is provided ---
+             kconfig = os.path.join(kernel_path, 'Kconfig')
+             if not os.path.isfile(kconfig):
+                     sys.stderr.write("error: %s does not point to a kernel tree \n"
+                                                     % kernel_path)
+                     sys.exit(1)
+
+             i915_dir = os.path.join('drivers', 'gpu', 'drm', 'i915')
+             print_workarounds(kernel_path, i915_dir, "kernel")
+
+     # --- list mesa workarounds if path is provided ---
+     if options.mesa_path != None:
+             # reset workarounds array
+             workarounds = {}
+
+             mesa_path = options.mesa_path
+             i965_dir = os.path.join('src', 'mesa', 'drivers', 'dri', 'i965')
+             mesa_dir = os.path.join(mesa_path, i965_dir)
+             if not os.path.exists(mesa_dir):
+                     sys.stderr.write("error: %s does not point to a valid mesa path \n"
+                                                     % mesa_path)
+                     sys.exit(1)
+
Quoted 8 lines
Quoted 4 lines
scripts/list-workarounds +1 -0
+             print_workarounds(mesa_path, i965_dir, "Mesa")
Signature · 1 line
1.9.1

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

#3 lore raw
Quoted 5 lines · Dylan Baker
Quoted 2 lines
Quoted 2 lines

parse(work_arounds)
+ print "\nList of workarounds found in %s:" % project

Hey Damien, the script says it's python 3, and this ^^^ is broken syntax in python 3 (but not in 2).

:(

I did notice the python2 construct, but then, of course, the diff is missing the full context so didn't realize it was a python3 script.

Sent and pushed the obvious fix.

I really want to trust that developers run the code at least once before submitting, even if it's a rework of the original patch. Even better would be a simple unit test, and hook make distcheck to patchwork. I'll look into that at some point.

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx