Skip to contentSkip to conversation

x86/UV: Fix conditional in gru_exit

PATCH In review Dimitri Sivanich 3 participants 6 messages Mar 20, 2014 – Apr 1, 2014 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/UV: Fix conditional in gru_exit

Fix conditional in gru_exit to match gru_init.

---
 drivers/misc/sgi-gru/grufile.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/sgi-gru/grufile.c +1 -1
Index: linux/drivers/misc/sgi-gru/grufile.c
===================================================================
@@ -573,7 +573,7 @@ exit0:
 
 static void __exit gru_exit(void)
 {
-	if (!is_uv_system())
+	if (!is_uv_system() || (is_uvx_hub() && !is_uv2_hub()))
 		return;
 
 	gru_teardown_tlb_irqs();
#1 lore raw
Quoted 12 lines · Dimitri Sivanich

Fix conditional in gru_exit to match gru_init.

---
 drivers/misc/sgi-gru/grufile.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux/drivers/misc/sgi-gru/grufile.c
===================================================================

drivers/misc/sgi-gru/grufile.c exit0: · line 577

Quoted 6 lines
drivers/misc/sgi-gru/grufile.c +1 -1
@@ -573,7 +573,7 @@ exit0:
 
 static void __exit gru_exit(void)
 {
-	if (!is_uv_system())
+	if (!is_uv_system() || (is_uvx_hub() && !is_uv2_hub()))
 		return;

Such an amalgation of three system specific conditionals is disgusting, please at minimum factor out a helper routine so that such mismatches cannot happen.

Thanks,

Ingo

#2 lore raw
Quoted 8 lines · Ingo Molnar

Review

Quoted 3 lines
(quoted diff) +1 -1
-	if (!is_uv_system())
+	if (!is_uv_system() || (is_uvx_hub() && !is_uv2_hub()))
 		return;

Such an amalgation of three system specific conditionals is disgusting, please at minimum factor out a helper routine so that such mismatches cannot happen.

Agreed. Here's a new patch.

Fix supported system conditional in gru_exit.

---
 drivers/misc/sgi-gru/grufile.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/misc/sgi-gru/grufile.c +6 -2
Index: linux/drivers/misc/sgi-gru/grufile.c
===================================================================
@@ -58,6 +58,10 @@ static int max_user_cbrs, max_user_dsr_b
 
 static struct miscdevice gru_miscdev;
 
+static int gru_unsupported(void)
+{
+	return !is_uv_system() || (is_uvx_hub() && !is_uv2_hub());
+}
 
 /*
  * gru_vma_close
@@ -518,7 +522,7 @@ static int __init gru_init(void)
 {
 	int ret;
 
-	if (!is_uv_system() || (is_uvx_hub() && !is_uv2_hub()))
+	if (gru_unsupported())
 		return 0;
 
 #if defined CONFIG_IA64
@@ -573,7 +577,7 @@ exit0:
 
 static void __exit gru_exit(void)
 {
-	if (!is_uv_system())
+	if (gru_unsupported())
 		return;
 
 	gru_teardown_tlb_irqs();
#3 lore raw
Quoted 24 lines · Dimitri Sivanich
Quoted 8 lines · Ingo Molnar

drivers/misc/sgi-gru/grufile.c exit0: · line 581

Quoted 3 lines
drivers/misc/sgi-gru/grufile.c +1 -1
-	if (!is_uv_system())
+	if (!is_uv_system() || (is_uvx_hub() && !is_uv2_hub()))
 		return;

Such an amalgation of three system specific conditionals is disgusting, please at minimum factor out a helper routine so that such mismatches cannot happen.

Agreed. Here's a new patch.

Fix supported system conditional in gru_exit.

---
 drivers/misc/sgi-gru/grufile.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Index: linux/drivers/misc/sgi-gru/grufile.c
===================================================================

drivers/misc/sgi-gru/grufile.c static int max_user_cbrs, max_user_dsr_b · line 64

Quoted 7 lines
drivers/misc/sgi-gru/grufile.c +4 -0
@@ -58,6 +58,10 @@ static int max_user_cbrs, max_user_dsr_b
 
 static struct miscdevice gru_miscdev;
 
+static int gru_unsupported(void)
+{
+	return !is_uv_system() || (is_uvx_hub() && !is_uv2_hub());
+}

So the usual pattern is to introduce simple patterns, without logic operations in their name. I.e. "gru_supported()" would be more natural than "gru_not_supported()" or gru_unsupported()".

Thanks,

Ingo

#4 lore raw
Quoted 11 lines · Ingo Molnar

Review

Quoted 4 lines · Dimitri Sivanich
(quoted diff) +4 -0
+static int gru_unsupported(void)
+{
+	return !is_uv_system() || (is_uvx_hub() && !is_uv2_hub());
+}

So the usual pattern is to introduce simple patterns, without logic operations in their name. I.e. "gru_supported()" would be more natural than "gru_not_supported()" or gru_unsupported()".

OK. Here's a revised version.

Fix supported system conditional in gru_exit.

---
 drivers/misc/sgi-gru/grufile.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/misc/sgi-gru/grufile.c +8 -3
Index: linux/drivers/misc/sgi-gru/grufile.c
===================================================================
@@ -6,7 +6,7 @@
  * This file supports the user system call for file open, close, mmap, etc.
  * This also incudes the driver initialization code.
  *
- *  Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
+ *  Copyright (c) 2008-2014 Silicon Graphics, Inc.  All Rights Reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -58,6 +58,11 @@ static int max_user_cbrs, max_user_dsr_b
 
 static struct miscdevice gru_miscdev;
 
+static int gru_supported(void)
+{
+	return is_uv_system() &&
+		(uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE);
+}
 
 /*
  * gru_vma_close
@@ -518,7 +523,7 @@ static int __init gru_init(void)
 {
 	int ret;
 
-	if (!is_uv_system() || (is_uvx_hub() && !is_uv2_hub()))
+	if (!gru_supported())
 		return 0;
 
 #if defined CONFIG_IA64
@@ -573,7 +578,7 @@ exit0:
 
 static void __exit gru_exit(void)
 {
-	if (!is_uv_system())
+	if (!gru_supported())
 		return;
 
 	gru_teardown_tlb_irqs();
#5 lore raw

[tip:x86/uv] x86/UV: Fix conditional in gru_exit()

x86/UV: Fix conditional in gru_exit()
Commit-ID:  fe455b17de6c881eecf4f9784c3b0483a5e3d19e
Gitweb:     http://git.kernel.org/tip/fe455b17de6c881eecf4f9784c3b0483a5e3d19e
Author:     Dimitri Sivanich <[email protected]>
AuthorDate: Mon, 31 Mar 2014 10:23:20 -0500
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 1 Apr 2014 12:10:45 +0200

x86/UV: Fix conditional in gru_exit()

Fix supported system conditional in gru_exit(), in preparation for UV3.

---
 drivers/misc/sgi-gru/grufile.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/misc/sgi-gru/grufile.c +8 -3
index 0535d1e..104a05f 100644
@@ -6,7 +6,7 @@
  * This file supports the user system call for file open, close, mmap, etc.
  * This also incudes the driver initialization code.
  *
- *  Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
+ *  Copyright (c) 2008-2014 Silicon Graphics, Inc.  All Rights Reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -58,6 +58,11 @@ static int max_user_cbrs, max_user_dsr_bytes;
 
 static struct miscdevice gru_miscdev;
 
+static int gru_supported(void)
+{
+	return is_uv_system() &&
+		(uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE);
+}
 
 /*
  * gru_vma_close
@@ -518,7 +523,7 @@ static int __init gru_init(void)
 {
 	int ret;
 
-	if (!is_uv_system() || (is_uvx_hub() && !is_uv2_hub()))
+	if (!gru_supported())
 		return 0;
 
 #if defined CONFIG_IA64
@@ -573,7 +578,7 @@ exit0:
 
 static void __exit gru_exit(void)
 {
-	if (!is_uv_system())
+	if (!gru_supported())
 		return;
 
 	gru_teardown_tlb_irqs();