LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* libfdt: Abolish _typed() variants, add _cell() variants
From: David Gibson @ 2007-11-20  2:35 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev

In a number of places through libfdt and its tests, we have *_typed()
macro variants on functions which use gcc's typeof and statement
expression extensions to allow passing literals where the underlying
function takes a buffer and size.

These seemed like a good idea at the time, but in fact they have some
problems.  They use typeof and statement expressions, extensions I'd
prefer to avoid for portability.  Plus, they have potential gotchas -
although they'll deal with the size of the thing passed, they won't
deal with other representation issues (like endianness) and results
could be very strange if the type of the expression passed isn't what
you think it is.

In fact, the only users of these _typed() macros were when the value
passed is a single cell (32-bit integer).  Therefore, this patch
removes all these _typed() macros and replaces them with explicit
_cell() variants which handle a single 32-bit integer, and which also
perform endian convesions as appropriate.

With this in place, it now becomes easy to use standardized big-endian
representation for integer valued properties in the testcases,
regardless of the platform we're running on.  We therefore do that,
which has the additional advantage that all the example trees created
during a test run are now byte-for-byte identical regardless of
platform.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Index: dtc/libfdt/libfdt.h
===================================================================
--- dtc.orig/libfdt/libfdt.h	2007-11-20 13:04:09.000000000 +1100
+++ dtc/libfdt/libfdt.h	2007-11-20 13:05:24.000000000 +1100
@@ -657,12 +657,12 @@ int fdt_node_offset_by_compatible(const 
 
 int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
 			const void *val, int len);
-
-#define fdt_setprop_inplace_typed(fdt, nodeoffset, name, val) \
-	({ \
-		typeof(val) x = val; \
-		fdt_setprop_inplace(fdt, nodeoffset, name, &x, sizeof(x)); \
-	})
+static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
+					   const char *name, uint32_t val)
+{
+	val = cpu_to_fdt32(val);
+	return fdt_setprop_inplace(fdt, nodeoffset, name, &val, sizeof(val));
+}
 
 int fdt_nop_property(void *fdt, int nodeoffset, const char *name);
 int fdt_nop_node(void *fdt, int nodeoffset);
@@ -676,11 +676,11 @@ int fdt_add_reservemap_entry(void *fdt, 
 int fdt_finish_reservemap(void *fdt);
 int fdt_begin_node(void *fdt, const char *name);
 int fdt_property(void *fdt, const char *name, const void *val, int len);
-#define fdt_property_typed(fdt, name, val) \
-	({ \
-		typeof(val) x = (val); \
-		fdt_property((fdt), (name), &x, sizeof(x)); \
-	})
+static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
+{
+	val = cpu_to_fdt32(val);
+	return fdt_property(fdt, name, &val, sizeof(val));
+}
 #define fdt_property_string(fdt, name, str) \
 	fdt_property(fdt, name, str, strlen(str)+1)
 int fdt_end_node(void *fdt);
@@ -698,11 +698,12 @@ int fdt_del_mem_rsv(void *fdt, int n);
 
 int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 		const void *val, int len);
-#define fdt_setprop_typed(fdt, nodeoffset, name, val) \
-	({ \
-		typeof(val) x = (val); \
-		fdt_setprop((fdt), (nodeoffset), (name), &x, sizeof(x)); \
-	})
+static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
+				   uint32_t val)
+{
+	val = cpu_to_fdt32(val);
+	return fdt_setprop(fdt, nodeoffset, name, &val, sizeof(val));
+}
 #define fdt_setprop_string(fdt, nodeoffset, name, str) \
 	fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
 int fdt_delprop(void *fdt, int nodeoffset, const char *name);
Index: dtc/tests/setprop_inplace.c
===================================================================
--- dtc.orig/tests/setprop_inplace.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/setprop_inplace.c	2007-11-20 13:05:55.000000000 +1100
@@ -42,14 +42,14 @@ int main(int argc, char *argv[])
 	test_init(argc, argv);
 	fdt = load_blob_arg(argc, argv);
 
-	intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+	intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
 
 	verbose_printf("Old int value was 0x%08x\n", *intp);
-	err = fdt_setprop_inplace_typed(fdt, 0, "prop-int", ~TEST_VALUE_1);
+	err = fdt_setprop_inplace_cell(fdt, 0, "prop-int", ~TEST_VALUE_1);
 	if (err)
 		FAIL("Failed to set \"prop-int\" to 0x08%x: %s",
 		     ~TEST_VALUE_1, fdt_strerror(err));
-	intp = check_getprop_typed(fdt, 0, "prop-int", ~TEST_VALUE_1);
+	intp = check_getprop_cell(fdt, 0, "prop-int", ~TEST_VALUE_1);
 	verbose_printf("New int value is 0x%08x\n", *intp);
 
 	strp = check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1,
Index: dtc/tests/del_node.c
===================================================================
--- dtc.orig/tests/del_node.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/del_node.c	2007-11-20 13:04:09.000000000 +1100
@@ -48,19 +48,19 @@ int main(int argc, char *argv[])
 	if (subnode1_offset < 0)
 		FAIL("Couldn't find \"/subnode@1\": %s",
 		     fdt_strerror(subnode1_offset));
-	check_getprop_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
+	check_getprop_cell(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
 
 	subnode2_offset = fdt_path_offset(fdt, "/subnode@2");
 	if (subnode2_offset < 0)
 		FAIL("Couldn't find \"/subnode@2\": %s",
 		     fdt_strerror(subnode2_offset));
-	check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+	check_getprop_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
 
 	subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode");
 	if (subsubnode2_offset < 0)
 		FAIL("Couldn't find \"/subnode@2/subsubnode\": %s",
 		     fdt_strerror(subsubnode2_offset));
-	check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+	check_getprop_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
 
 	err = fdt_del_node(fdt, subnode1_offset);
 	if (err)
@@ -76,13 +76,13 @@ int main(int argc, char *argv[])
 	if (subnode2_offset < 0)
 		FAIL("Couldn't find \"/subnode2\": %s",
 		     fdt_strerror(subnode2_offset));
-	check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+	check_getprop_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
 
 	subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode");
 	if (subsubnode2_offset < 0)
 		FAIL("Couldn't find \"/subnode@2/subsubnode\": %s",
 		     fdt_strerror(subsubnode2_offset));
-	check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+	check_getprop_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
 
 	err = fdt_del_node(fdt, subnode2_offset);
 	if (err)
Index: dtc/tests/del_property.c
===================================================================
--- dtc.orig/tests/del_property.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/del_property.c	2007-11-20 13:04:09.000000000 +1100
@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
 
 	oldsize = fdt_totalsize(fdt);
 
-	intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+	intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
 	verbose_printf("int value was 0x%08x\n", *intp);
 
 	err = fdt_delprop(fdt, 0, "prop-int");
Index: dtc/tests/find_property.c
===================================================================
--- dtc.orig/tests/find_property.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/find_property.c	2007-11-20 13:04:09.000000000 +1100
@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
 	test_init(argc, argv);
 	fdt = load_blob_arg(argc, argv);
 
-	check_property_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+	check_property_cell(fdt, 0, "prop-int", TEST_VALUE_1);
 	check_property(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, TEST_STRING_1);
 
 	PASS();
Index: dtc/tests/getprop.c
===================================================================
--- dtc.orig/tests/getprop.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/getprop.c	2007-11-20 13:04:09.000000000 +1100
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
 	test_init(argc, argv);
 	fdt = load_blob_arg(argc, argv);
 
-	check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+	check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
 	check_getprop(fdt, 0, "prop-str", strlen(TEST_STRING_1)+1, TEST_STRING_1);
 
 	PASS();
Index: dtc/tests/node_offset_by_prop_value.c
===================================================================
--- dtc.orig/tests/node_offset_by_prop_value.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/node_offset_by_prop_value.c	2007-11-20 13:04:09.000000000 +1100
@@ -67,9 +67,9 @@ void check_search_str(void *fdt, const c
 	va_end(ap);
 }
 
-#define check_search_val(fdt, propname, propval, ...) \
+#define check_search_cell(fdt, propname, propval, ...) \
 	{ \
-		typeof(propval) val = (propval); \
+		uint32_t val = cpu_to_fdt32(propval); \
 		check_search((fdt), (propname), &val, sizeof(val), \
 			     ##__VA_ARGS__); \
 	}
@@ -92,17 +92,17 @@ int main(int argc, char *argv[])
 	    || (subsubnode1_offset < 0) || (subsubnode2_offset < 0))
 		FAIL("Can't find required nodes");
 
-	check_search_val(fdt, "prop-int", TEST_VALUE_1, 0, subnode1_offset,
-			 subsubnode1_offset, -FDT_ERR_NOTFOUND);
+	check_search_cell(fdt, "prop-int", TEST_VALUE_1, 0, subnode1_offset,
+			  subsubnode1_offset, -FDT_ERR_NOTFOUND);
 
-	check_search_val(fdt, "prop-int", TEST_VALUE_2, subnode2_offset,
-			 subsubnode2_offset, -FDT_ERR_NOTFOUND);
+	check_search_cell(fdt, "prop-int", TEST_VALUE_2, subnode2_offset,
+			  subsubnode2_offset, -FDT_ERR_NOTFOUND);
 
 	check_search_str(fdt, "prop-str", TEST_STRING_1, 0, -FDT_ERR_NOTFOUND);
 
 	check_search_str(fdt, "prop-str", "no such string", -FDT_ERR_NOTFOUND);
 
-	check_search_val(fdt, "prop-int", TEST_VALUE_1+1, -FDT_ERR_NOTFOUND);
+	check_search_cell(fdt, "prop-int", TEST_VALUE_1+1, -FDT_ERR_NOTFOUND);
 
 	check_search(fdt, "no-such-prop", NULL, 0, -FDT_ERR_NOTFOUND);
 
Index: dtc/tests/nop_node.c
===================================================================
--- dtc.orig/tests/nop_node.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/nop_node.c	2007-11-20 13:04:09.000000000 +1100
@@ -43,19 +43,19 @@ int main(int argc, char *argv[])
 	if (subnode1_offset < 0)
 		FAIL("Couldn't find \"/subnode1\": %s",
 		     fdt_strerror(subnode1_offset));
-	check_getprop_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
+	check_getprop_cell(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
 
 	subnode2_offset = fdt_path_offset(fdt, "/subnode@2");
 	if (subnode2_offset < 0)
 		FAIL("Couldn't find \"/subnode2\": %s",
 		     fdt_strerror(subnode2_offset));
-	check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+	check_getprop_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
 
 	subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode");
 	if (subsubnode2_offset < 0)
 		FAIL("Couldn't find \"/subnode@2/subsubnode\": %s",
 		     fdt_strerror(subsubnode2_offset));
-	check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+	check_getprop_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
 
 	err = fdt_nop_node(fdt, subnode1_offset);
 	if (err)
@@ -71,13 +71,13 @@ int main(int argc, char *argv[])
 	if (subnode2_offset < 0)
 		FAIL("Couldn't find \"/subnode2\": %s",
 		     fdt_strerror(subnode2_offset));
-	check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+	check_getprop_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
 
 	subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode");
 	if (subsubnode2_offset < 0)
 		FAIL("Couldn't find \"/subnode@2/subsubnode\": %s",
 		     fdt_strerror(subsubnode2_offset));
-	check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+	check_getprop_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
 
 	err = fdt_nop_node(fdt, subnode2_offset);
 	if (err)
Index: dtc/tests/nop_property.c
===================================================================
--- dtc.orig/tests/nop_property.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/nop_property.c	2007-11-20 13:04:09.000000000 +1100
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
 	test_init(argc, argv);
 	fdt = load_blob_arg(argc, argv);
 
-	intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+	intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
 	verbose_printf("int value was 0x%08x\n", *intp);
 
 	err = fdt_nop_property(fdt, 0, "prop-int");
Index: dtc/tests/rw_tree1.c
===================================================================
--- dtc.orig/tests/rw_tree1.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/rw_tree1.c	2007-11-20 13:04:09.000000000 +1100
@@ -73,27 +73,25 @@ int main(int argc, char *argv[])
 	CHECK(fdt_add_mem_rsv(fdt, TEST_ADDR_2, TEST_SIZE_2));
 
 	CHECK(fdt_setprop_string(fdt, 0, "compatible", "test_tree1"));
-	CHECK(fdt_setprop_typed(fdt, 0, "prop-int", TEST_VALUE_1));
+	CHECK(fdt_setprop_cell(fdt, 0, "prop-int", TEST_VALUE_1));
 	CHECK(fdt_setprop_string(fdt, 0, "prop-str", TEST_STRING_1));
 
 	OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@1"));
 	CHECK(fdt_setprop_string(fdt, offset, "compatible", "subnode1"));
-	CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1));
+	CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_1));
 	OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode"));
 	CHECK(fdt_setprop(fdt, offset, "compatible",
 			  "subsubnode1\0subsubnode", 23));
-	CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1));
+	CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_1));
 
 	OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@2"));
-	CHECK(fdt_setprop_typed(fdt, offset, "linux,phandle",
-				cpu_to_fdt32(PHANDLE_1)));
-	CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2));
+	CHECK(fdt_setprop_cell(fdt, offset, "linux,phandle", PHANDLE_1));
+	CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_2));
 	OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode@0"));
-	CHECK(fdt_setprop_typed(fdt, offset, "linux,phandle",
-				cpu_to_fdt32(PHANDLE_2)));
+	CHECK(fdt_setprop_cell(fdt, offset, "linux,phandle", PHANDLE_2));
 	CHECK(fdt_setprop(fdt, offset, "compatible",
 			  "subsubnode2\0subsubnode", 23));
-	CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2));
+	CHECK(fdt_setprop_cell(fdt, offset, "prop-int", TEST_VALUE_2));
 
 	CHECK(fdt_pack(fdt));
 
Index: dtc/tests/setprop.c
===================================================================
--- dtc.orig/tests/setprop.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/setprop.c	2007-11-20 13:04:09.000000000 +1100
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
 
 	fdt = buf;
 
-	intp = check_getprop_typed(fdt, 0, "prop-int", TEST_VALUE_1);
+	intp = check_getprop_cell(fdt, 0, "prop-int", TEST_VALUE_1);
 
 	verbose_printf("Old int value was 0x%08x\n", *intp);
 	err = fdt_setprop_string(fdt, 0, "prop-int", NEW_STRING);
Index: dtc/tests/subnode_offset.c
===================================================================
--- dtc.orig/tests/subnode_offset.c	2007-11-20 13:04:09.000000000 +1100
+++ dtc/tests/subnode_offset.c	2007-11-20 13:04:09.000000000 +1100
@@ -70,16 +70,16 @@ int main(int argc, char *argv[])
 	if (subnode1_offset == subnode2_offset)
 		FAIL("Different subnodes have same offset");
 
-	check_property_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
-	check_property_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
+	check_property_cell(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
+	check_property_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);
 
 	subsubnode1_offset = check_subnode(fdt, subnode1_offset, "subsubnode");
 	subsubnode2_offset = check_subnode(fdt, subnode2_offset, "subsubnode@0");
 	subsubnode2_offset2 = check_subnode(fdt, subnode2_offset, "subsubnode");
 
-	check_property_typed(fdt, subsubnode1_offset, "prop-int", TEST_VALUE_1);
-	check_property_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
-	check_property_typed(fdt, subsubnode2_offset2, "prop-int", TEST_VALUE_2);
+	check_property_cell(fdt, subsubnode1_offset, "prop-int", TEST_VALUE_1);
+	check_property_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
+	check_property_cell(fdt, subsubnode2_offset2, "prop-int", TEST_VALUE_2);
 
 	if (subsubnode2_offset != subsubnode2_offset2)
 		FAIL("Different offsets with and without unit address");
Index: dtc/tests/sw_tree1.c
===================================================================
--- dtc.orig/tests/sw_tree1.c	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/sw_tree1.c	2007-11-20 13:04:09.000000000 +1100
@@ -55,27 +55,27 @@ int main(int argc, char *argv[])
 
 	CHECK(fdt_begin_node(fdt, ""));
 	CHECK(fdt_property_string(fdt, "compatible", "test_tree1"));
-	CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1));
+	CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
 	CHECK(fdt_property_string(fdt, "prop-str", TEST_STRING_1));
 
 	CHECK(fdt_begin_node(fdt, "subnode@1"));
 	CHECK(fdt_property_string(fdt, "compatible", "subnode1"));
-	CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1));
+	CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
 	CHECK(fdt_begin_node(fdt, "subsubnode"));
 	CHECK(fdt_property(fdt, "compatible", "subsubnode1\0subsubnode",
 			   23));
-	CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1));
+	CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_1));
 	CHECK(fdt_end_node(fdt));
 	CHECK(fdt_end_node(fdt));
 
 	CHECK(fdt_begin_node(fdt, "subnode@2"));
-	CHECK(fdt_property_typed(fdt, "linux,phandle", cpu_to_fdt32(PHANDLE_1)));
-	CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_2));
+	CHECK(fdt_property_cell(fdt, "linux,phandle", PHANDLE_1));
+	CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_2));
 	CHECK(fdt_begin_node(fdt, "subsubnode@0"));
-	CHECK(fdt_property_typed(fdt, "linux,phandle", cpu_to_fdt32(PHANDLE_2)));
+	CHECK(fdt_property_cell(fdt, "linux,phandle", PHANDLE_2));
 	CHECK(fdt_property(fdt, "compatible", "subsubnode2\0subsubnode",
 			   23));
-	CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_2));
+	CHECK(fdt_property_cell(fdt, "prop-int", TEST_VALUE_2));
 	CHECK(fdt_end_node(fdt));
 	CHECK(fdt_end_node(fdt));
 
Index: dtc/tests/testdata.h
===================================================================
--- dtc.orig/tests/testdata.h	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/testdata.h	2007-11-20 13:04:09.000000000 +1100
@@ -20,8 +20,8 @@
 #define TEST_ADDR_2	ASM_CONST_LL(123456789)
 #define TEST_SIZE_2	ASM_CONST_LL(010000)
 
-#define TEST_VALUE_1	cell_to_fdt(0xdeadbeef)
-#define TEST_VALUE_2	cell_to_fdt(123456789)
+#define TEST_VALUE_1	0xdeadbeef
+#define TEST_VALUE_2	123456789
 
 #define PHANDLE_1	0x2000
 #define PHANDLE_2	0x2001
Index: dtc/tests/tests.h
===================================================================
--- dtc.orig/tests/tests.h	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/tests.h	2007-11-20 13:04:09.000000000 +1100
@@ -112,18 +112,18 @@ void check_mem_rsv(void *fdt, int n, uin
 
 void check_property(void *fdt, int nodeoffset, const char *name,
 		    int len, const void *val);
-#define check_property_typed(fdt, nodeoffset, name, val) \
+#define check_property_cell(fdt, nodeoffset, name, val) \
 	({ \
-		typeof(val) x = val; \
+		uint32_t x = cpu_to_fdt32(val);			      \
 		check_property(fdt, nodeoffset, name, sizeof(x), &x); \
 	})
 
 
 const void *check_getprop(void *fdt, int nodeoffset, const char *name,
 			  int len, const void *val);
-#define check_getprop_typed(fdt, nodeoffset, name, val) \
+#define check_getprop_cell(fdt, nodeoffset, name, val) \
 	({ \
-		typeof(val) x = val; \
+		uint32_t x = cpu_to_fdt32(val);			     \
 		check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
 	})
 #define check_getprop_string(fdt, nodeoffset, name, s) \
Index: dtc/tests/trees.S
===================================================================
--- dtc.orig/tests/trees.S	2007-11-20 10:15:51.000000000 +1100
+++ dtc/tests/trees.S	2007-11-20 13:04:09.000000000 +1100
@@ -50,8 +50,7 @@ tree##_rsvmap_end:		;
 
 #define PROP_INT(tree, name, val) \
 	PROPHDR(tree, name, 4) \
-	/* For ease of testing the property values go in native-endian */ \
-	.long	val		;
+	FDTLONG(val)		;
 
 #define PROP_STR(tree, name, str) \
 	PROPHDR(tree, name, 55f - 54f) \
@@ -100,11 +99,11 @@ test_tree1_struct:
 	END_NODE
 
 	BEGIN_NODE("subnode@2")
-	PROP_INT(test_tree1, phandle, cell_to_fdt(PHANDLE_1))
+	PROP_INT(test_tree1, phandle, PHANDLE_1)
 	PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
 
 	BEGIN_NODE("subsubnode@0")
-	PROP_INT(test_tree1, phandle, cell_to_fdt(PHANDLE_2))
+	PROP_INT(test_tree1, phandle, PHANDLE_2)
 	PROP_STR(test_tree1, compatible, "subsubnode2\0subsubnode")
 	PROP_INT(test_tree1, prop_int, TEST_VALUE_2)
 	END_NODE

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply

* [PATCH] fix scaled time accounting possible divide by zero
From: Michael Neuling @ 2007-11-20  3:25 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev, Balbir Singh

This fixes a problem noticed by Balbir Singh

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
Paulus: can we send this up for 2.6.24?

 arch/powerpc/kernel/time.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: linux-2.6-ozlabs/arch/powerpc/kernel/time.c
===================================================================
--- linux-2.6-ozlabs.orig/arch/powerpc/kernel/time.c
+++ linux-2.6-ozlabs/arch/powerpc/kernel/time.c
@@ -244,8 +244,9 @@ void account_system_vtime(struct task_st
 		/* deltascaled includes both user and system time.
 		 * Hence scale it based on the purr ratio to estimate
 		 * the system time */
-		deltascaled = deltascaled * get_paca()->system_time /
-		(get_paca()->system_time + get_paca()->user_time);
+		if (get_paca()->user_time)
+			deltascaled = deltascaled * get_paca()->system_time /
+			(get_paca()->system_time + get_paca()->user_time);
 		delta += get_paca()->system_time;
 		get_paca()->system_time = 0;
 	}

^ permalink raw reply

* Re: [PATCH v2] PMU: replace information ioctls and schedule for removal
From: Paul Mackerras @ 2007-11-20  3:33 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev list
In-Reply-To: <1194981108.6695.11.camel@johannes.berg>

Johannes Berg writes:

> This patch adds sysfs attributes to the PMU to allow getting
> the information on the PMU type and whether adb is present from
> there instead of via the ioctl. The ioctl is made optional and
> scheduled for removal.

I don't see any reason to ever remove the ioctls.  We're talking about
just 4 lines of code here.  Sure we can add the sysfs attributes -
even though that adds an order of magnitude more lines of code 
(thanks sysfs :) but I don't see any good reason to remove the
existing interface.

Paul.

^ permalink raw reply

* [PATCH] [POWERPC] Emulate isel (Integer Select) instruction
From: Kumar Gala @ 2007-11-20  3:36 UTC (permalink / raw)
  To: linuxppc-dev

isel (Integer Select) is a new user space instruction in the
PowerISA 2.04 spec.  Not all processors implement it so lets emulate
to ensure code built with isel will run everywhere.

---
 arch/powerpc/kernel/traps.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

In my git tree for 2.6.25.

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 59c464e..cad6484 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -622,6 +622,9 @@ static void parse_fpe(struct pt_regs *regs)
 #define INST_POPCNTB		0x7c0000f4
 #define INST_POPCNTB_MASK	0xfc0007fe

+#define INST_ISEL		0x7c00001e
+#define INST_ISEL_MASK		0xfc00003e
+
 static int emulate_string_inst(struct pt_regs *regs, u32 instword)
 {
 	u8 rT = (instword >> 21) & 0x1f;
@@ -707,6 +710,23 @@ static int emulate_popcntb_inst(struct pt_regs *regs, u32 instword)
 	return 0;
 }

+static int emulate_isel(struct pt_regs *regs, u32 instword)
+{
+	u8 rT = (instword >> 21) & 0x1f;
+	u8 rA = (instword >> 16) & 0x1f;
+	u8 rB = (instword >> 11) & 0x1f;
+	u8 BC = (instword >> 6) & 0x1f;
+	u8 bit;
+	unsigned long tmp;
+
+	tmp = (rA == 0) ? 0 : regs->gpr[rA];
+	bit = (regs->ccr >> (31 - BC)) & 0x1;
+
+	regs->gpr[rT] = bit ? tmp : regs->gpr[rB];
+
+	return 0;
+}
+
 static int emulate_instruction(struct pt_regs *regs)
 {
 	u32 instword;
@@ -749,6 +769,11 @@ static int emulate_instruction(struct pt_regs *regs)
 		return emulate_popcntb_inst(regs, instword);
 	}

+	/* Emulate isel (Integer Select) instruction */
+	if ((instword & INST_ISEL_MASK) == INST_ISEL) {
+		return emulate_isel(regs, instword);
+	}
+
 	return -EINVAL;
 }

-- 
1.5.3.4

^ permalink raw reply related

* [PATCH] ibm_newemac: Fix possible lockup on close
From: Benjamin Herrenschmidt @ 2007-11-20  3:50 UTC (permalink / raw)
  To: jgarzik; +Cc: linuxppc-dev, netdev

It's a bad idea to call flush_scheduled_work from within a
netdev->stop because the linkwatch will occasionally take the
rtnl lock from a workqueue context, and thus that can deadlock.

This reworks things a bit in that area to avoid the problem.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

 drivers/net/ibm_newemac/core.c |   31 ++++++++++++++++++++-----------
 drivers/net/ibm_newemac/core.h |    1 +
 2 files changed, 21 insertions(+), 11 deletions(-)

Index: linux-work/drivers/net/ibm_newemac/core.c
===================================================================
--- linux-work.orig/drivers/net/ibm_newemac/core.c	2007-11-20 14:42:50.000000000 +1100
+++ linux-work/drivers/net/ibm_newemac/core.c	2007-11-20 14:46:51.000000000 +1100
@@ -642,9 +642,11 @@ static void emac_reset_work(struct work_
 	DBG(dev, "reset_work" NL);
 
 	mutex_lock(&dev->link_lock);
-	emac_netif_stop(dev);
-	emac_full_tx_reset(dev);
-	emac_netif_start(dev);
+	if (dev->opened) {
+		emac_netif_stop(dev);
+		emac_full_tx_reset(dev);
+		emac_netif_start(dev);
+	}
 	mutex_unlock(&dev->link_lock);
 }
 
@@ -1063,10 +1065,9 @@ static int emac_open(struct net_device *
 	dev->rx_sg_skb = NULL;
 
 	mutex_lock(&dev->link_lock);
+	dev->opened = 1;
 
-	/* XXX Start PHY polling now. Shouldn't wr do like sungem instead and
-	 * always poll the PHY even when the iface is down ? That would allow
-	 * things like laptop-net to work. --BenH
+	/* Start PHY polling now.
 	 */
 	if (dev->phy.address >= 0) {
 		int link_poll_interval;
@@ -1145,9 +1146,11 @@ static void emac_link_timer(struct work_
 	int link_poll_interval;
 
 	mutex_lock(&dev->link_lock);
-
 	DBG2(dev, "link timer" NL);
 
+	if (!dev->opened)
+		goto bail;
+
 	if (dev->phy.def->ops->poll_link(&dev->phy)) {
 		if (!netif_carrier_ok(dev->ndev)) {
 			/* Get new link parameters */
@@ -1170,13 +1173,14 @@ static void emac_link_timer(struct work_
 		link_poll_interval = PHY_POLL_LINK_OFF;
 	}
 	schedule_delayed_work(&dev->link_work, link_poll_interval);
-
+ bail:
 	mutex_unlock(&dev->link_lock);
 }
 
 static void emac_force_link_update(struct emac_instance *dev)
 {
 	netif_carrier_off(dev->ndev);
+	smp_rmb();
 	if (dev->link_polling) {
 		cancel_rearming_delayed_work(&dev->link_work);
 		if (dev->link_polling)
@@ -1191,11 +1195,14 @@ static int emac_close(struct net_device 
 
 	DBG(dev, "close" NL);
 
-	if (dev->phy.address >= 0)
+	if (dev->phy.address >= 0) {
+		dev->link_polling = 0;
 		cancel_rearming_delayed_work(&dev->link_work);
-
+	}
+	mutex_lock(&dev->link_lock);
 	emac_netif_stop(dev);
-	flush_scheduled_work();
+	dev->opened = 0;
+	mutex_unlock(&dev->link_lock);
 
 	emac_rx_disable(dev);
 	emac_tx_disable(dev);
@@ -2756,6 +2763,8 @@ static int __devexit emac_remove(struct 
 
 	unregister_netdev(dev->ndev);
 
+	flush_scheduled_work();
+
 	if (emac_has_feature(dev, EMAC_FTR_HAS_TAH))
 		tah_detach(dev->tah_dev, dev->tah_port);
 	if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII))
Index: linux-work/drivers/net/ibm_newemac/core.h
===================================================================
--- linux-work.orig/drivers/net/ibm_newemac/core.h	2007-11-20 14:42:50.000000000 +1100
+++ linux-work/drivers/net/ibm_newemac/core.h	2007-11-20 14:46:51.000000000 +1100
@@ -258,6 +258,7 @@ struct emac_instance {
 	int				stop_timeout;	/* in us */
 	int				no_mcast;
 	int				mcast_pending;
+	int				opened;
 	struct work_struct		reset_work;
 	spinlock_t			lock;
 };

^ permalink raw reply

* Re: [PATCH] fix scaled time accounting possible divide by zero
From: Balbir Singh @ 2007-11-20  4:16 UTC (permalink / raw)
  To: Michael Neuling; +Cc: linuxppc-dev, paulus
In-Reply-To: <9965.1195529141@neuling.org>

Michael Neuling wrote:
> This fixes a problem noticed by Balbir Singh
> 
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> ---
> Paulus: can we send this up for 2.6.24?
> 
>  arch/powerpc/kernel/time.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6-ozlabs/arch/powerpc/kernel/time.c
> ===================================================================
> --- linux-2.6-ozlabs.orig/arch/powerpc/kernel/time.c
> +++ linux-2.6-ozlabs/arch/powerpc/kernel/time.c
> @@ -244,8 +244,9 @@ void account_system_vtime(struct task_st
>  		/* deltascaled includes both user and system time.
>  		 * Hence scale it based on the purr ratio to estimate
>  		 * the system time */
> -		deltascaled = deltascaled * get_paca()->system_time /
> -		(get_paca()->system_time + get_paca()->user_time);
> +		if (get_paca()->user_time)
> +			deltascaled = deltascaled * get_paca()->system_time /
> +			(get_paca()->system_time + get_paca()->user_time);

Hi, Michael,

I'd be doubly careful with scaled multiplication approach, we tried this
for CFS (please see task_utime() and task_stime() and the fixes that
went around it). We ran into problems were due to multiplication
rounding errors, we would see stime and utime go back after a period
of time.

Please see http://kerneltrap.org/mailarchive/linux-kernel/2007/10/16/344377

Our problems were made severe by the fact that sum_exec_runtime and
stime/utime accounting occured differently. stime/utime were sampled
at jiffy boundaries and hence could we incorrect. I think we need
to use rounding to ensure that ac_scaled*time never goes back
due to rounding errors.

>  		delta += get_paca()->system_time;
>  		get_paca()->system_time = 0;
>  	}


-- 
	Warm Regards,
	Balbir Singh
	Linux Technology Center
	IBM, ISTL

^ permalink raw reply

* [PATCH] fix scaled time accounting possible divide by zero
From: Michael Neuling @ 2007-11-20  4:18 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev, Balbir Singh
In-Reply-To: <9965.1195529141@neuling.org>

If we get no user time allocated since the last account_system_vtime,
the system to user time ratio estimate can end up dividing by zero.

This was causing a problem noticed by Balbir Singh.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
Resent as the first version had whitespace corruption.  

Paulus: can we send this up for 2.6.24?

 arch/powerpc/kernel/time.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: linux-2.6-ozlabs/arch/powerpc/kernel/time.c
===================================================================
--- linux-2.6-ozlabs.orig/arch/powerpc/kernel/time.c
+++ linux-2.6-ozlabs/arch/powerpc/kernel/time.c
@@ -241,8 +241,9 @@ void account_system_vtime(struct task_st
 		/* deltascaled includes both user and system time.
 		 * Hence scale it based on the purr ratio to estimate
 		 * the system time */
-		deltascaled = deltascaled * get_paca()->system_time /
-			(get_paca()->system_time + get_paca()->user_time);
+		if (get_paca()->user_time)
+			deltascaled = deltascaled * get_paca()->system_time /
+			     (get_paca()->system_time + get_paca()->user_time);
 		delta += get_paca()->system_time;
 		get_paca()->system_time = 0;
 	}

^ permalink raw reply

* Re: [PATCH] fix scaled time accounting possible divide by zero
From: Michael Neuling @ 2007-11-20  4:36 UTC (permalink / raw)
  To: balbir; +Cc: linuxppc-dev, paulus
In-Reply-To: <47425F8F.3060208@linux.vnet.ibm.com>

In message <47425F8F.3060208@linux.vnet.ibm.com> you wrote:
> Michael Neuling wrote:
> > This fixes a problem noticed by Balbir Singh
> > 
> > Signed-off-by: Michael Neuling <mikey@neuling.org>
> > ---
> > Paulus: can we send this up for 2.6.24?
> > 
> >  arch/powerpc/kernel/time.c |    5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > Index: linux-2.6-ozlabs/arch/powerpc/kernel/time.c
> > ===================================================================
> > --- linux-2.6-ozlabs.orig/arch/powerpc/kernel/time.c
> > +++ linux-2.6-ozlabs/arch/powerpc/kernel/time.c
> > @@ -244,8 +244,9 @@ void account_system_vtime(struct task_st
> >  		/* deltascaled includes both user and system time.
> >  		 * Hence scale it based on the purr ratio to estimate
> >  		 * the system time */
> > -		deltascaled = deltascaled * get_paca()->system_time /
> > -		(get_paca()->system_time + get_paca()->user_time);
> > +		if (get_paca()->user_time)
> > +			deltascaled = deltascaled * get_paca()->system_time /
> > +			(get_paca()->system_time + get_paca()->user_time);
> 
> Hi, Michael,
> 
> I'd be doubly careful with scaled multiplication approach, we tried this
> for CFS (please see task_utime() and task_stime() and the fixes that
> went around it). We ran into problems were due to multiplication
> rounding errors, we would see stime and utime go back after a period
> of time.
> 
> Please see http://kerneltrap.org/mailarchive/linux-kernel/2007/10/16/344377
> 
> Our problems were made severe by the fact that sum_exec_runtime and
> stime/utime accounting occured differently. stime/utime were sampled
> at jiffy boundaries and hence could we incorrect. I think we need
> to use rounding to ensure that ac_scaled*time never goes back
> due to rounding errors.

I've not changed the math here much, just the case of user_time being
zero.

Is this related to this patch specifically, or something that's been
wrong with these patches for a while?

Mikey

^ permalink raw reply

* RE: How can I make the DDR momory storage bigger than 256M?
From: Liu Dave @ 2007-11-20  4:38 UTC (permalink / raw)
  To: 郭劲, linuxppc-embedded
In-Reply-To: <395483341.30896@tsinghua.org.cn>

Hello Guo,

Please post your question to u-boot maillist:

u-boot-users@lists.sourceforge.net=20

Please check if you have the correct BATs for 1GB memory.
1GB memory should need 4 BATs.

Regards,
Dave

> -----Original Message-----
> From:=20
> linuxppc-embedded-bounces+daveliu=3Dfreescale.com@ozlabs.org=20
> [mailto:linuxppc-embedded-bounces+daveliu=3Dfreescale.com@ozlabs
> .org] On Behalf Of =B9=F9=BE=A2
> Sent: 2007=C4=EA11=D4=C219=C8=D5 10:42 PM
> To: linuxppc-embedded@ozlabs.org
> Subject: How can I make the DDR momory storage bigger than 256M?
>=20
> Hi,friends,
>=20
> I used the U-Boot 1.2.0 on MPC8360E board. My board work=20
> nomally with 256M DDR-1
> Memory.  If I change the DDR-1 up to 1GB, the U-Boot can=20
> visit the DDR address
> range from 0x00000000 to 0x10000000, but it can not visit the=20
> address bigger than
> 0x10000000,I wat wondering why? Thanks.
>=20
> Using the 1GB DDR-1, I can write the u-boot to my flash by=20
> CodeWarrior.
>=20
> Follow is the information that when I test the DDR on u-boot,=20
> the start address is
> 0x1ff00000, the end address is 0x20000000;it was dead when=20
> visit the DDR.
>=20
>=20
>=20
>=20
>=20
>=20
> U-Boot 1.2.0 (Nov 19 2007 - 20:55:34) MPC83XX                =20
>                =20
>                                                              =20
>                =20
> CPU:   e300c1, MPC8360E, Rev: 20 at 528 MHz, CSB:  264 MHz   =20
>                =20
> Board: Freescale MPC8360EMDS                                 =20
>                =20
> I2C:   ready                                                 =20
>                =20
> DRAM:                                                        =20
>                =20
> DIMM type:                                                   =20
>                =20
> SPD size:        128                                         =20
>                =20
> EEPROM size:     256                                         =20
>                =20
> Memory type:     7                                           =20
>                =20
> Row addr:        13                                          =20
>                =20
> Column addr:     11                                          =20
>                =20
> # of rows:       2                                           =20
>                =20
> Row density:     128                                         =20
>                =20
> # of banks:      4                                           =20
>                =20
> Data width:      64                                          =20
>                =20
> Chip width:      8                                           =20
>                =20
> Refresh rate:    82                                          =20
>                =20
> CAS latencies:   18                                          =20
>                =20
> Write latencies: 02                                          =20
>                =20
> tRP:             60                                          =20
>                =20
> tRCD:            60                                          =20
>                =20
>                                                              =20
>                =20
>                                                              =20
>                =20
> cs0_bnds =3D 0x0000001f                                        =20
>                =20
> cs0_config =3D 0x80000103                                      =20
>                =20
> cs1_bnds =3D 0x0020003f                                        =20
>                =20
> cs1_config =3D 0x80000103                                      =20
>                =20
> DDR:bar=3D0x00000000                                           =20
>                =20
> DDR:ar=3D0x8000001d                                            =20
>                =20
> DDR: caslat SPD bit is 4                                     =20
>                =20
> DDR:Module maximum data rate is: 400Mhz                      =20
>                =20
> DDR:Effective data rate is: 266Mhz                           =20
>                =20
> DDR:The MSB 1 of CAS Latency is: 4                           =20
>                =20
> DDR: effective data rate is 266 MHz                          =20
>                =20
> DDR: caslat SPD bit is 4, controller field is 0x5            =20
>                =20
> DDR:timing_cfg_1=3D0x26252727                                  =20
>                =20
> DDR:timing_cfg_2=3D0x00004841                                  =20
>                =20
>                                                              =20
>                =20
>    DDR DIMM: data bus width is 64 bit without ECC            =20
>                =20
> DDR:sdram_mode=3D0x00000032                                    =20
>                =20
> DDR: sdram_mode2 =3D 0x00000000                                =20
>                =20
> DDR:sdram_interval=3D0x04060100                                =20
>                =20
> DDR:sdram_clk_cntl=3D0x02000000                                =20
>                =20
>    DDRC ECC mode: OFF                                        =20
>                =20
> DDR:sdram_cfg=3D0xc2008000                                     =20
>                =20
>                                                              =20
>                =20
>    SDRAM on Local Bus: 64 MB                                 =20
>                =20
>    DDR RAM: 1024 MB                                          =20
>                =20
> DDR test phase 1:             =20
>=20
>=20
> (dead)
>=20
>=20
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>=20

^ permalink raw reply

* [patch] xmon bitlock fix
From: Nick Piggin @ 2007-11-20  5:08 UTC (permalink / raw)
  To: Paul Mackerras, Benjamin Herrenschmidt, linuxppc-dev

(sorry, untested for lack of hardware)
--
xmon uses a bit lock spinlock but doesn't close the critical section
when releasing it. It doesn't seem like a big deal because it will
eventually break out of the lock anyway, but presumably that's only
in exceptional cases where some error is tolerated, while the lack of a memory
barrier could allow incorrect results during normal functioning operation
as well.

Convert it to use a regular spinlock instead.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
Index: linux-2.6/arch/ppc/xmon/start.c
===================================================================
--- linux-2.6.orig/arch/ppc/xmon/start.c
+++ linux-2.6/arch/ppc/xmon/start.c
@@ -92,16 +92,14 @@ xmon_write(void *handle, void *ptr, int 
 {
 	char *p = ptr;
 	int i, c, ct;
-
-#ifdef CONFIG_SMP
-	static unsigned long xmon_write_lock;
+	static DEFINE_SPINLOCK(xmon_write_lock);
 	int lock_wait = 1000000;
 	int locked;
 
-	while ((locked = test_and_set_bit(0, &xmon_write_lock)) != 0)
+	while (!(locked = spin_trylock(&xmon_write_lock))) {
 		if (--lock_wait == 0)
 			break;
-#endif
+	}
 
 	if (!scc_initialized)
 		xmon_init_scc();
@@ -122,10 +120,9 @@ xmon_write(void *handle, void *ptr, int 
 		eieio();
 	}
 
-#ifdef CONFIG_SMP
-	if (!locked)
-		clear_bit(0, &xmon_write_lock);
-#endif
+	if (locked)
+		spin_unlock(&xmon_write_lock);
+
 	return nb;
 }
 

^ permalink raw reply

* [patch] powerpc: hash lock use lock bitops
From: Nick Piggin @ 2007-11-20  5:09 UTC (permalink / raw)
  To: Paul Mackerras, Benjamin Herrenschmidt, linuxppc-dev; +Cc: Anton Blanchard
In-Reply-To: <20071120050826.GA18332@wotan.suse.de>

This isn't a bugfix, but may help performance slightly...

--
powerpc 64-bit hash pte lock bit is an actual lock, so it can take advantage
of lock bitops for slightly more optimal memory barriers (can avoid an lwsync
in the trylock).

Signed-off-by: Nick Piggin <npiggin@suse.de>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
Index: linux-2.6/arch/powerpc/mm/hash_native_64.c
===================================================================
--- linux-2.6.orig/arch/powerpc/mm/hash_native_64.c
+++ linux-2.6/arch/powerpc/mm/hash_native_64.c
@@ -113,7 +113,7 @@ static inline void native_lock_hpte(stru
 	unsigned long *word = &hptep->v;
 
 	while (1) {
-		if (!test_and_set_bit(HPTE_LOCK_BIT, word))
+		if (!test_and_set_bit_lock(HPTE_LOCK_BIT, word))
 			break;
 		while(test_bit(HPTE_LOCK_BIT, word))
 			cpu_relax();
@@ -124,8 +124,7 @@ static inline void native_unlock_hpte(st
 {
 	unsigned long *word = &hptep->v;
 
-	asm volatile("lwsync":::"memory");
-	clear_bit(HPTE_LOCK_BIT, word);
+	clear_bit_unlock(HPTE_LOCK_BIT, word);
 }
 
 static long native_hpte_insert(unsigned long hpte_group, unsigned long va,

^ permalink raw reply

* dtc: Add testcases for tree checks
From: David Gibson @ 2007-11-20  5:24 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev

This patch adds a group of testcases to check that dtc correctly
rejects trees with various structural errors.

To make things easier to test, we change dtc so that failing checks
(as opposed to other errors) result in exit code 2.

This patch also fixes an embarrasing bug uncovered by these new tests:
check_phandles() worked out if the tree's phandles were valid, then
throws that information away and returns success always.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

NOTE! jdl, you'll need to chmod +x tests/dtc-checkfails.sh before you
git commit this - it's a new shell script and patch can't encode the
permissions info.

Index: dtc/tests/dup-nodename.dts
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dtc/tests/dup-nodename.dts	2007-11-20 16:02:22.000000000 +1100
@@ -0,0 +1,8 @@
+/dts-v1/;
+
+/ {
+	node {
+	};
+	node {
+	};
+};
Index: dtc/dtc.c
===================================================================
--- dtc.orig/dtc.c	2007-11-20 16:01:54.000000000 +1100
+++ dtc/dtc.c	2007-11-20 16:02:22.000000000 +1100
@@ -197,7 +197,7 @@ int main(int argc, char *argv[])
 	if (!structure_ok) {
 		if (!force) {
 			fprintf(stderr, "ERROR: Input tree has structural errors, aborting (use -f to force output)\n");
-			exit(1);
+			exit(2);
 		} else if (quiet < 3) {
 			fprintf(stderr, "Warning: Input tree has structural errors, output forced\n");
 		}
Index: dtc/tests/dtc.sh
===================================================================
--- dtc.orig/tests/dtc.sh	2007-11-20 16:01:54.000000000 +1100
+++ dtc/tests/dtc.sh	2007-11-20 16:02:22.000000000 +1100
@@ -1,24 +1,6 @@
 #! /bin/sh
 
-PASS () {
-    echo "PASS"
-    exit 0
-}
-
-FAIL () {
-    echo "FAIL" "$@"
-    exit 2
-}
-
-DTC=../dtc
-
-verbose_run () {
-    if [ -z "$QUIET_TEST" ]; then
-	"$@"
-    else
-	"$@" > /dev/null 2> /dev/null
-    fi
-}
+. tests.sh
 
 if verbose_run "$DTC" "$@"; then
     PASS
Index: dtc/tests/tests.sh
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dtc/tests/tests.sh	2007-11-20 16:02:22.000000000 +1100
@@ -0,0 +1,21 @@
+# Common functions for shell testcases
+
+PASS () {
+    echo "PASS"
+    exit 0
+}
+
+FAIL () {
+    echo "FAIL" "$@"
+    exit 2
+}
+
+DTC=../dtc
+
+verbose_run () {
+    if [ -z "$QUIET_TEST" ]; then
+	"$@"
+    else
+	"$@" > /dev/null 2> /dev/null
+    fi
+}
Index: dtc/tests/dtc-checkfails.sh
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dtc/tests/dtc-checkfails.sh	2007-11-20 16:02:50.000000000 +1100
@@ -0,0 +1,22 @@
+#! /bin/sh
+
+. tests.sh
+
+TMPFILE="tmp.out.$$"
+
+rm -f $TMPFILE
+
+verbose_run "$DTC" -o $TMPFILE "$@"
+ret="$?"
+
+if [ -f $TMPFILE ]; then
+    FAIL "output file was created despite bad input"
+fi
+
+if [ "$ret" = "2" ]; then
+    PASS
+else
+    FAIL "dtc returned error code $ret instead of 2 (check failed)"
+fi
+
+rm -f $TMPFILE
Index: dtc/tests/run_tests.sh
===================================================================
--- dtc.orig/tests/run_tests.sh	2007-11-20 16:02:21.000000000 +1100
+++ dtc/tests/run_tests.sh	2007-11-20 16:02:22.000000000 +1100
@@ -143,6 +143,12 @@ dtc_tests () {
 	run_test dtbs_equal_ordered $tree odts_$tree.test.dtb
     done
 
+    # Check some checks
+    run_test dtc-checkfails.sh -I dts -O dtb dup-nodename.dts
+    run_test dtc-checkfails.sh -I dts -O dtb dup-propname.dts
+    run_test dtc-checkfails.sh -I dts -O dtb dup-phandle.dts
+    run_test dtc-checkfails.sh -I dts -O dtb zero-phandle.dts
+    run_test dtc-checkfails.sh -I dts -O dtb minusone-phandle.dts
 }
 
 while getopts "vdt:" ARG ; do
Index: dtc/tests/dup-propname.dts
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dtc/tests/dup-propname.dts	2007-11-20 16:02:22.000000000 +1100
@@ -0,0 +1,6 @@
+/dts-v1/;
+
+/ {
+	prop;
+	prop;
+};
Index: dtc/tests/dup-phandle.dts
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dtc/tests/dup-phandle.dts	2007-11-20 16:02:22.000000000 +1100
@@ -0,0 +1,10 @@
+/dts-v1/;
+
+/ {
+	node1 {
+		linux,phandle = <1>;
+	};
+	node2 {
+		linux,phandle = <1>;
+	};
+};
Index: dtc/tests/minusone-phandle.dts
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dtc/tests/minusone-phandle.dts	2007-11-20 16:02:22.000000000 +1100
@@ -0,0 +1,7 @@
+/dts-v1/;
+
+/ {
+	node {
+		linux,phandle = <0xffffffff>;
+	};
+};
Index: dtc/tests/zero-phandle.dts
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ dtc/tests/zero-phandle.dts	2007-11-20 16:02:22.000000000 +1100
@@ -0,0 +1,7 @@
+/dts-v1/;
+
+/ {
+	node {
+		linux,phandle = <0>;
+	};
+};
Index: dtc/checks.c
===================================================================
--- dtc.orig/checks.c	2007-11-20 16:01:54.000000000 +1100
+++ dtc/checks.c	2007-11-20 16:02:23.000000000 +1100
@@ -101,7 +101,7 @@ static int check_phandles(struct node *r
 	for_each_child(node, child)
 		ok = ok && check_phandles(root, child);
 
-	return 1;
+	return ok;
 }
 
 int check_structure(struct node *dt)

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply

* Re: [patch] xmon bitlock fix
From: Paul Mackerras @ 2007-11-20  5:28 UTC (permalink / raw)
  To: Nick Piggin; +Cc: linuxppc-dev
In-Reply-To: <20071120050826.GA18332@wotan.suse.de>

Nick Piggin writes:

> xmon uses a bit lock spinlock but doesn't close the critical section
> when releasing it. It doesn't seem like a big deal because it will
> eventually break out of the lock anyway, but presumably that's only
> in exceptional cases where some error is tolerated, while the lack of a memory
> barrier could allow incorrect results during normal functioning operation
> as well.
> 
> Convert it to use a regular spinlock instead.

I'd rather not.  The idea is that xmon is as independent as possible
of the rest of the kernel, so that it will work even when lots of
kernel data structures are corrupted.  If spinlocks were simple spin
loops then maybe, but they're not these days.

As for the memory barrier comment, I don't think it is a reason, since
test_and_set_bit acts as a barrier, and in any case the worst thing
that could happen is that the characters from different cpu's outputs
get interleaved (that's one reason why the loop has a timeout, the
other is for robustness).

In any case this is in arch/ppc which is dying code.  I don't think
there are any SMP platforms supported in arch/ppc any more except for
some (fairly rare) PReP platforms, and I hope to get PReP moved over
soon.

Finally, why do you say that it doesn't close the critical section?
Possibly the "locked" variable is badly named (it's zero when we get
the lock) but AFAICS the code is actually correct.

Paul.

^ permalink raw reply

* Re: [BUG] 2.6.24-rc2-mm1 - kernel bug on nfs v4
From: Andrew Morton @ 2007-11-20  5:35 UTC (permalink / raw)
  To: Trond Myklebust
  Cc: Peter Zijlstra, steved, LKML, Torsten Kaiser, Kamalesh Babulal,
	linuxppc-dev, nfs, Ingo Molnar, Jan Blunck, Balbir Singh
In-Reply-To: <1195413486.7893.16.camel@heimdal.trondhjem.org>

On Sun, 18 Nov 2007 14:18:06 -0500 Trond Myklebust <trond.myklebust@fys.uio.no> wrote:

> > 
> > Torsten
> 
> I had already fixed that one in my own stack. Attached are the 3 patches
> that I've got. 1 from SteveD, 2 fixes.
> 
> Andrew, could you please unapply the sillyrename patches you've got, and
> apply these 3 instead?

I'd expect to see things like this appear in git-nfs.patch.  Did something change?

^ permalink raw reply

* [PATCH] [POWERPC] Fix device tree interrupt map for Freescale ULI1575 boards
From: Kumar Gala @ 2007-11-20  5:50 UTC (permalink / raw)
  To: linuxppc-dev

The interrupt map for the PCI PHB that had the ULI1575 was not correct
on the boards that have it.

* 8544 DS:
   - Fix interrupt mask
   - Be explicit about use of INTA for on chip peripherals

* 8572 DS/8641 HPCN:
   - Fix interrupt mask
   - Expand interrupt map for PCI slots to cover all functions
   - Be explicit about use of INTA for on chip peripherals

---

intended for 2.6.24 as a bug fix.  Its ugly but I don't think we have a
choice, silly HW.

 arch/powerpc/boot/dts/mpc8544ds.dts    |   20 +++---
 arch/powerpc/boot/dts/mpc8572ds.dts    |  108 ++++++++++++++++++++++++---
 arch/powerpc/boot/dts/mpc8641_hpcn.dts |  126 ++++++++++++++++++++++++++-----
 3 files changed, 211 insertions(+), 43 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8544ds.dts b/arch/powerpc/boot/dts/mpc8544ds.dts
index 3f9d15c..6c608de 100644
--- a/arch/powerpc/boot/dts/mpc8544ds.dts
+++ b/arch/powerpc/boot/dts/mpc8544ds.dts
@@ -272,24 +272,24 @@
 		clock-frequency = <1fca055>;
 		interrupt-parent = <&mpic>;
 		interrupts = <1b 2>;
-		interrupt-map-mask = <fb00 0 0 0>;
+		interrupt-map-mask = <ff00 0 0 1>;
 		interrupt-map = <
 			// IDSEL 0x1c  USB
-			e000 0 0 0 &i8259 c 2
-			e100 0 0 0 &i8259 9 2
-			e200 0 0 0 &i8259 a 2
-			e300 0 0 0 &i8259 b 2
+			e000 0 0 1 &i8259 c 2
+			e100 0 0 1 &i8259 9 2
+			e200 0 0 1 &i8259 a 2
+			e300 0 0 1 &i8259 b 2

 			// IDSEL 0x1d  Audio
-			e800 0 0 0 &i8259 6 2
+			e800 0 0 1 &i8259 6 2

 			// IDSEL 0x1e Legacy
-			f000 0 0 0 &i8259 7 2
-			f100 0 0 0 &i8259 7 2
+			f000 0 0 1 &i8259 7 2
+			f100 0 0 1 &i8259 7 2

 			// IDSEL 0x1f IDE/SATA
-			f800 0 0 0 &i8259 e 2
-			f900 0 0 0 &i8259 5 2
+			f800 0 0 1 &i8259 e 2
+			f900 0 0 1 &i8259 5 2
 		>;

 		pcie@0 {
diff --git a/arch/powerpc/boot/dts/mpc8572ds.dts b/arch/powerpc/boot/dts/mpc8572ds.dts
index d638dee..0eb44fb 100644
--- a/arch/powerpc/boot/dts/mpc8572ds.dts
+++ b/arch/powerpc/boot/dts/mpc8572ds.dts
@@ -219,36 +219,120 @@
 		clock-frequency = <1fca055>;
 		interrupt-parent = <&mpic>;
 		interrupts = <18 2>;
-		interrupt-map-mask = <fb00 0 0 0>;
+		interrupt-map-mask = <ff00 0 0 7>;
 		interrupt-map = <
-			/* IDSEL 0x11 - PCI slot 1 */
+			/* IDSEL 0x11 func 0 - PCI slot 1 */
 			8800 0 0 1 &mpic 2 1
 			8800 0 0 2 &mpic 3 1
 			8800 0 0 3 &mpic 4 1
 			8800 0 0 4 &mpic 1 1

-			/* IDSEL 0x12 - PCI slot 2 */
+			/* IDSEL 0x11 func 1 - PCI slot 1 */
+			8900 0 0 1 &mpic 2 1
+			8900 0 0 2 &mpic 3 1
+			8900 0 0 3 &mpic 4 1
+			8900 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 2 - PCI slot 1 */
+			8a00 0 0 1 &mpic 2 1
+			8a00 0 0 2 &mpic 3 1
+			8a00 0 0 3 &mpic 4 1
+			8a00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 3 - PCI slot 1 */
+			8b00 0 0 1 &mpic 2 1
+			8b00 0 0 2 &mpic 3 1
+			8b00 0 0 3 &mpic 4 1
+			8b00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 4 - PCI slot 1 */
+			8c00 0 0 1 &mpic 2 1
+			8c00 0 0 2 &mpic 3 1
+			8c00 0 0 3 &mpic 4 1
+			8c00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 5 - PCI slot 1 */
+			8d00 0 0 1 &mpic 2 1
+			8d00 0 0 2 &mpic 3 1
+			8d00 0 0 3 &mpic 4 1
+			8d00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 6 - PCI slot 1 */
+			8e00 0 0 1 &mpic 2 1
+			8e00 0 0 2 &mpic 3 1
+			8e00 0 0 3 &mpic 4 1
+			8e00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 7 - PCI slot 1 */
+			8f00 0 0 1 &mpic 2 1
+			8f00 0 0 2 &mpic 3 1
+			8f00 0 0 3 &mpic 4 1
+			8f00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x12 func 0 - PCI slot 2 */
 			9000 0 0 1 &mpic 3 1
 			9000 0 0 2 &mpic 4 1
 			9000 0 0 3 &mpic 1 1
 			9000 0 0 4 &mpic 2 1

+			/* IDSEL 0x12 func 1 - PCI slot 2 */
+			9100 0 0 1 &mpic 3 1
+			9100 0 0 2 &mpic 4 1
+			9100 0 0 3 &mpic 1 1
+			9100 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 2 - PCI slot 2 */
+			9200 0 0 1 &mpic 3 1
+			9200 0 0 2 &mpic 4 1
+			9200 0 0 3 &mpic 1 1
+			9200 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 3 - PCI slot 2 */
+			9300 0 0 1 &mpic 3 1
+			9300 0 0 2 &mpic 4 1
+			9300 0 0 3 &mpic 1 1
+			9300 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 4 - PCI slot 2 */
+			9400 0 0 1 &mpic 3 1
+			9400 0 0 2 &mpic 4 1
+			9400 0 0 3 &mpic 1 1
+			9400 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 5 - PCI slot 2 */
+			9500 0 0 1 &mpic 3 1
+			9500 0 0 2 &mpic 4 1
+			9500 0 0 3 &mpic 1 1
+			9500 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 6 - PCI slot 2 */
+			9600 0 0 1 &mpic 3 1
+			9600 0 0 2 &mpic 4 1
+			9600 0 0 3 &mpic 1 1
+			9600 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 7 - PCI slot 2 */
+			9700 0 0 1 &mpic 3 1
+			9700 0 0 2 &mpic 4 1
+			9700 0 0 3 &mpic 1 1
+			9700 0 0 4 &mpic 2 1
+
 			// IDSEL 0x1c  USB
-			e000 0 0 0 &i8259 c 2
-			e100 0 0 0 &i8259 9 2
-			e200 0 0 0 &i8259 a 2
-			e300 0 0 0 &i8259 b 2
+			e000 0 0 1 &i8259 c 2
+			e100 0 0 1 &i8259 9 2
+			e200 0 0 1 &i8259 a 2
+			e300 0 0 1 &i8259 b 2

 			// IDSEL 0x1d  Audio
-			e800 0 0 0 &i8259 6 2
+			e800 0 0 1 &i8259 6 2

 			// IDSEL 0x1e Legacy
-			f000 0 0 0 &i8259 7 2
-			f100 0 0 0 &i8259 7 2
+			f000 0 0 1 &i8259 7 2
+			f100 0 0 1 &i8259 7 2

 			// IDSEL 0x1f IDE/SATA
-			f800 0 0 0 &i8259 e 2
-			f900 0 0 0 &i8259 5 2
+			f800 0 0 1 &i8259 e 2
+			f900 0 0 1 &i8259 5 2

 			>;

diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn.dts b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
index 3677659..abb26dc 100644
--- a/arch/powerpc/boot/dts/mpc8641_hpcn.dts
+++ b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
@@ -235,36 +235,120 @@
 		clock-frequency = <1fca055>;
 		interrupt-parent = <&mpic>;
 		interrupts = <18 2>;
-		interrupt-map-mask = <fb00 0 0 0>;
+		interrupt-map-mask = <ff00 0 0 7>;
 		interrupt-map = <
-			/* IDSEL 0x11 */
-			8800 0 0 1 &i8259 9 2
-			8800 0 0 2 &i8259 a 2
-			8800 0 0 3 &i8259 b 2
-			8800 0 0 4 &i8259 c 2
-
-			/* IDSEL 0x12 */
-			9000 0 0 1 &i8259 a 2
-			9000 0 0 2 &i8259 b 2
-			9000 0 0 3 &i8259 c 2
-			9000 0 0 4 &i8259 9 2
+			/* IDSEL 0x11 func 0 - PCI slot 1 */
+			8800 0 0 1 &mpic 2 1
+			8800 0 0 2 &mpic 3 1
+			8800 0 0 3 &mpic 4 1
+			8800 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 1 - PCI slot 1 */
+			8900 0 0 1 &mpic 2 1
+			8900 0 0 2 &mpic 3 1
+			8900 0 0 3 &mpic 4 1
+			8900 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 2 - PCI slot 1 */
+			8a00 0 0 1 &mpic 2 1
+			8a00 0 0 2 &mpic 3 1
+			8a00 0 0 3 &mpic 4 1
+			8a00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 3 - PCI slot 1 */
+			8b00 0 0 1 &mpic 2 1
+			8b00 0 0 2 &mpic 3 1
+			8b00 0 0 3 &mpic 4 1
+			8b00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 4 - PCI slot 1 */
+			8c00 0 0 1 &mpic 2 1
+			8c00 0 0 2 &mpic 3 1
+			8c00 0 0 3 &mpic 4 1
+			8c00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 5 - PCI slot 1 */
+			8d00 0 0 1 &mpic 2 1
+			8d00 0 0 2 &mpic 3 1
+			8d00 0 0 3 &mpic 4 1
+			8d00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 6 - PCI slot 1 */
+			8e00 0 0 1 &mpic 2 1
+			8e00 0 0 2 &mpic 3 1
+			8e00 0 0 3 &mpic 4 1
+			8e00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x11 func 7 - PCI slot 1 */
+			8f00 0 0 1 &mpic 2 1
+			8f00 0 0 2 &mpic 3 1
+			8f00 0 0 3 &mpic 4 1
+			8f00 0 0 4 &mpic 1 1
+
+			/* IDSEL 0x12 func 0 - PCI slot 2 */
+			9000 0 0 1 &mpic 3 1
+			9000 0 0 2 &mpic 4 1
+			9000 0 0 3 &mpic 1 1
+			9000 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 1 - PCI slot 2 */
+			9100 0 0 1 &mpic 3 1
+			9100 0 0 2 &mpic 4 1
+			9100 0 0 3 &mpic 1 1
+			9100 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 2 - PCI slot 2 */
+			9200 0 0 1 &mpic 3 1
+			9200 0 0 2 &mpic 4 1
+			9200 0 0 3 &mpic 1 1
+			9200 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 3 - PCI slot 2 */
+			9300 0 0 1 &mpic 3 1
+			9300 0 0 2 &mpic 4 1
+			9300 0 0 3 &mpic 1 1
+			9300 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 4 - PCI slot 2 */
+			9400 0 0 1 &mpic 3 1
+			9400 0 0 2 &mpic 4 1
+			9400 0 0 3 &mpic 1 1
+			9400 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 5 - PCI slot 2 */
+			9500 0 0 1 &mpic 3 1
+			9500 0 0 2 &mpic 4 1
+			9500 0 0 3 &mpic 1 1
+			9500 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 6 - PCI slot 2 */
+			9600 0 0 1 &mpic 3 1
+			9600 0 0 2 &mpic 4 1
+			9600 0 0 3 &mpic 1 1
+			9600 0 0 4 &mpic 2 1
+
+			/* IDSEL 0x12 func 7 - PCI slot 2 */
+			9700 0 0 1 &mpic 3 1
+			9700 0 0 2 &mpic 4 1
+			9700 0 0 3 &mpic 1 1
+			9700 0 0 4 &mpic 2 1

 			// IDSEL 0x1c  USB
-			e000 0 0 0 &i8259 c 2
-			e100 0 0 0 &i8259 9 2
-			e200 0 0 0 &i8259 a 2
-			e300 0 0 0 &i8259 b 2
+			e000 0 0 1 &i8259 c 2
+			e100 0 0 1 &i8259 9 2
+			e200 0 0 1 &i8259 a 2
+			e300 0 0 1 &i8259 b 2

 			// IDSEL 0x1d  Audio
-			e800 0 0 0 &i8259 6 2
+			e800 0 0 1 &i8259 6 2

 			// IDSEL 0x1e Legacy
-			f000 0 0 0 &i8259 7 2
-			f100 0 0 0 &i8259 7 2
+			f000 0 0 1 &i8259 7 2
+			f100 0 0 1 &i8259 7 2

 			// IDSEL 0x1f IDE/SATA
-			f800 0 0 0 &i8259 e 2
-			f900 0 0 0 &i8259 5 2
+			f800 0 0 1 &i8259 e 2
+			f900 0 0 1 &i8259 5 2
 			>;

 		pcie@0 {
-- 
1.5.3.4

^ permalink raw reply related

* Re: [PATCH] PPC: Fix potential NULL dereference
From: Kumar Gala @ 2007-11-20  5:51 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: linuxppc-dev, Paul Mackerras, LKML
In-Reply-To: <20071115184705.GA7273@cvg>

On Thu, 15 Nov 2007, Cyrill Gorcunov wrote:

> This patch does fix potential NULL pointer dereference
> that could take place inside of strcmp() if
> of_get_property() call failed.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>
>  arch/powerpc/platforms/83xx/usb.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
>

CC the linuxppc-dev@ozlabs.org list in the future.

applied.

- k

^ permalink raw reply

* Re: [PATCH] powerpc: mpc832x mds: Fix board PHY reset code
From: Kumar Gala @ 2007-11-20  5:52 UTC (permalink / raw)
  To: Kim Phillips; +Cc: linuxppc-dev, Li Yang, peter.vanackeren
In-Reply-To: <20071119190443.7c04ae6b.kim.phillips@freescale.com>

On Mon, 19 Nov 2007, Kim Phillips wrote:

> currently the board-level PHY reset code for the mpc832x MDS messes with
> reset configuration words source settings which is plain wrong (it
> looks like this board code was cut-n-pasted from the mpc8360 mds code,
> which has the PHY reset bits in a different BCSR); this patch points
> the PHY reset code to the proper mpc832x mds PHY reset bits in the BCSR.
>
> Signed-off-by: Peter Van Ackeren <peter.vanackeren@freescale.com>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
>  arch/powerpc/platforms/83xx/mpc832x_mds.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
>

applied.

- k

^ permalink raw reply

* Re: [PATCH] powerpc: fix 2nd UCC entry in mpc832x_mds.dts
From: Kumar Gala @ 2007-11-20  5:52 UTC (permalink / raw)
  To: Kim Phillips; +Cc: linuxppc-dev
In-Reply-To: <20071113172631.7b42e1e1.kim.phillips@freescale.com>

On Tue, 13 Nov 2007, Kim Phillips wrote:

> correct the reg property, remove duplicate io port entry, whitespace fixes.
>
> Thanks to Peter Van Ackeren for pointing this out.
>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
>  arch/powerpc/boot/dts/mpc832x_mds.dts |    9 ++++-----
>  1 files changed, 4 insertions(+), 5 deletions(-)
>

applied

- k

^ permalink raw reply

* Re: [PATCH 5/5] powerpc: handle mpc8360 rev. 2.1 RGMII timing erratum
From: Kumar Gala @ 2007-11-20  5:53 UTC (permalink / raw)
  To: Kim Phillips; +Cc: netdev, Li Yang, jgarzik, paulus, linuxppc-dev
In-Reply-To: <20071105121551.a28b5446.kim.phillips@freescale.com>

On Mon, 5 Nov 2007, Kim Phillips wrote:

> if on a rev. 2.1, adjust UCC clock and data timing characteristics
> as specified in the rev.2.1 erratum #2.
>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
>  arch/powerpc/platforms/83xx/mpc836x_mds.c |   31 ++++++++++++++++++++++++++--
>  1 files changed, 28 insertions(+), 3 deletions(-)
>

applied.

- k

^ permalink raw reply

* Re: [PATCH 1/5] powerpc: document rgmii-rxid and rgmii-txid phy-connection-types
From: Kumar Gala @ 2007-11-20  5:53 UTC (permalink / raw)
  To: Kim Phillips; +Cc: netdev, Li Yang, jgarzik, paulus, linuxppc-dev
In-Reply-To: <20071105121535.c423d095.kim.phillips@freescale.com>

On Mon, 5 Nov 2007, Kim Phillips wrote:

> A h/w bug requires we program the PHY in RGMII mode for internal delay
> on the receive or transmit side only; document the new property values.
>
> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
> ---
>  Documentation/powerpc/booting-without-of.txt |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>

applied.

- k

^ permalink raw reply

* Please pull from 'for-2.6.24' branch
From: Kumar Gala @ 2007-11-20  5:56 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

Please pull from 'for-2.6.24' branch of

	master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc.git for-2.6.24

to receive the following updates:

 Documentation/powerpc/booting-without-of.txt |    5 -
 arch/powerpc/boot/dts/mpc832x_mds.dts        |    9 -
 arch/powerpc/boot/dts/mpc8544ds.dts          |   20 ++--
 arch/powerpc/boot/dts/mpc8572ds.dts          |  108 ++++++++++++++++++++---
 arch/powerpc/boot/dts/mpc8641_hpcn.dts       |  126 ++++++++++++++++++++++-----
 arch/powerpc/platforms/83xx/mpc832x_mds.c    |    7 -
 arch/powerpc/platforms/83xx/mpc836x_mds.c    |   31 ++++++
 arch/powerpc/platforms/83xx/usb.c            |    8 -
 8 files changed, 254 insertions(+), 60 deletions(-)

Cyrill Gorcunov (1):
      [POWERPC] Fix potential NULL dereference

Kim Phillips (4):
      [POWERPC] 83xx: mpc832x mds: Fix board PHY reset code
      [POWERPC] 83xx: Fix 2nd UCC entry in mpc832x_mds.dts
      [POWERPC] Document rgmii-rxid and rgmii-txid phy-connection-types
      [POWERPC] 83xx: Handle mpc8360 rev. 2.1 RGMII timing erratum

Kumar Gala (1):
      [POWERPC] Fix device tree interrupt map for Freescale ULI1575 boards

^ permalink raw reply

* Re: [patch] xmon bitlock fix
From: Nick Piggin @ 2007-11-20  6:03 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev
In-Reply-To: <18242.28770.6643.679177@cargo.ozlabs.ibm.com>

On Tue, Nov 20, 2007 at 04:28:02PM +1100, Paul Mackerras wrote:
> Nick Piggin writes:
> 
> > xmon uses a bit lock spinlock but doesn't close the critical section
> > when releasing it. It doesn't seem like a big deal because it will
> > eventually break out of the lock anyway, but presumably that's only
> > in exceptional cases where some error is tolerated, while the lack of a memory
> > barrier could allow incorrect results during normal functioning operation
> > as well.
> > 
> > Convert it to use a regular spinlock instead.
> 
> I'd rather not.  The idea is that xmon is as independent as possible
> of the rest of the kernel, so that it will work even when lots of
> kernel data structures are corrupted.  If spinlocks were simple spin
> loops then maybe, but they're not these days.

Fair enough, I guess you still want lockdep kernels to work.

 
> As for the memory barrier comment, I don't think it is a reason, since
> test_and_set_bit acts as a barrier, and in any case the worst thing

test_and_set_bit is a barrier (although heavier than required to acquire
a lock). But clear_bit isn't strong enough... you do have eieio() in
there, making it probably less problem, but that won't get executed if
nb is 0, and it is still doing the xmon_init_scc() outside the loop. I
just prefer to make it a simple lock that doesn't rely on barriers or
the specific structure of the critical section.


> that could happen is that the characters from different cpu's outputs
> get interleaved (that's one reason why the loop has a timeout, the
> other is for robustness).
> 
> In any case this is in arch/ppc which is dying code.  I don't think
> there are any SMP platforms supported in arch/ppc any more except for
> some (fairly rare) PReP platforms, and I hope to get PReP moved over
> soon.
 
I was just grepping the tree, and trying to reduce code which might
be fragile, broken, or a poor example.


> Finally, why do you say that it doesn't close the critical section?
> Possibly the "locked" variable is badly named (it's zero when we get
> the lock) but AFAICS the code is actually correct.

Well the unlock itself doesn't close it properly because clear_bit
doesn't order previous loads or stores.

How about this?
---

xmon uses a bit lock spinlock but doesn't close the critical section
when releasing it. It doesn't seem like a big deal because it will
eventually break out of the lock anyway, but presumably that's only
in exceptional cases where some error is tolerated, while the lack of a memory
barrier could allow incorrect results during normal functioning operation
as well.

Signed-off-by: Nick Piggin <npiggin@suse.de>
---
Index: linux-2.6/arch/ppc/xmon/start.c
===================================================================
--- linux-2.6.orig/arch/ppc/xmon/start.c
+++ linux-2.6/arch/ppc/xmon/start.c
@@ -98,7 +98,7 @@ xmon_write(void *handle, void *ptr, int 
 	int lock_wait = 1000000;
 	int locked;
 
-	while ((locked = test_and_set_bit(0, &xmon_write_lock)) != 0)
+	while ((locked = test_and_set_bit_lock(0, &xmon_write_lock)) != 0)
 		if (--lock_wait == 0)
 			break;
 #endif
@@ -124,7 +124,7 @@ xmon_write(void *handle, void *ptr, int 
 
 #ifdef CONFIG_SMP
 	if (!locked)
-		clear_bit(0, &xmon_write_lock);
+		clear_bit_unlock(0, &xmon_write_lock);
 #endif
 	return nb;
 }

^ permalink raw reply

* Re: [patch] powerpc: hash lock use lock bitops
From: Benjamin Herrenschmidt @ 2007-11-20  6:08 UTC (permalink / raw)
  To: Nick Piggin; +Cc: linuxppc-dev, Paul Mackerras, Anton Blanchard
In-Reply-To: <20071120050950.GB18332@wotan.suse.de>


On Tue, 2007-11-20 at 06:09 +0100, Nick Piggin wrote:
> This isn't a bugfix, but may help performance slightly...
> 
> --
> powerpc 64-bit hash pte lock bit is an actual lock, so it can take advantage
> of lock bitops for slightly more optimal memory barriers (can avoid an lwsync
> in the trylock).
> 
> Signed-off-by: Nick Piggin <npiggin@suse.de>
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---

Looks nice, I'll try it out on a G5 and let you know.

Cheers,
Ben.

^ permalink raw reply

* [PATCH] [PPC] Remove xmon from ml300 and ml403 defconfig
From: Grant Likely @ 2007-11-20  6:08 UTC (permalink / raw)
  To: "jwboyer, linuxppc-dev

From: Grant Likely <grant.likely@secretlab.ca>

xmon is broken under arch/ppc so remove it from the defconfig.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

Josh; I'm not going to even bother doing a full defconfig update for these
boards right now; it's probably not worth it.  This change just eliminates
the xmon build issue.  Plus doing it this way is trivial to review.  :-)

In fact; looking at the code, I don't think xmon builds for *any* arch/ppc
platforms at the moment.  :-/  Probably not even worth worrying about.

As we discussed, this should go in for .24

Cheers,
g.

 arch/ppc/configs/ml300_defconfig |    2 +-
 arch/ppc/configs/ml403_defconfig |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/ppc/configs/ml300_defconfig b/arch/ppc/configs/ml300_defconfig
index 69bad91..d66cacd 100644
--- a/arch/ppc/configs/ml300_defconfig
+++ b/arch/ppc/configs/ml300_defconfig
@@ -719,7 +719,7 @@ CONFIG_DEBUG_INFO=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_KGDB is not set
-CONFIG_XMON=y
+# CONFIG_XMON is not set
 # CONFIG_BDI_SWITCH is not set
 # CONFIG_SERIAL_TEXT_DEBUG is not set
 
diff --git a/arch/ppc/configs/ml403_defconfig b/arch/ppc/configs/ml403_defconfig
index a78896e..71bcfa7 100644
--- a/arch/ppc/configs/ml403_defconfig
+++ b/arch/ppc/configs/ml403_defconfig
@@ -720,7 +720,7 @@ CONFIG_DEBUG_INFO=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_KGDB is not set
-CONFIG_XMON=y
+# CONFIG_XMON is not set
 # CONFIG_BDI_SWITCH is not set
 # CONFIG_SERIAL_TEXT_DEBUG is not set
 

^ permalink raw reply related

* Re: [patch] powerpc: hash lock use lock bitops
From: Nick Piggin @ 2007-11-20  6:26 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Paul Mackerras, Anton Blanchard
In-Reply-To: <1195538904.6970.37.camel@pasglop>

On Tue, Nov 20, 2007 at 05:08:24PM +1100, Benjamin Herrenschmidt wrote:
> 
> On Tue, 2007-11-20 at 06:09 +0100, Nick Piggin wrote:
> > This isn't a bugfix, but may help performance slightly...
> > 
> > --
> > powerpc 64-bit hash pte lock bit is an actual lock, so it can take advantage
> > of lock bitops for slightly more optimal memory barriers (can avoid an lwsync
> > in the trylock).
> > 
> > Signed-off-by: Nick Piggin <npiggin@suse.de>
> > Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > ---
> 
> Looks nice, I'll try it out on a G5 and let you know.

Cool, thanks (I don't have mine handy ATM...).

BTW, here is another thing which you might want to think about. Again
untested for temporary lack of hardware.

--

The radix-tree is now RCU safe, so powerpc can avoid the games it was playing
in order to have a lockless readside. Saves an irq disable/enable, a couple of
__get_cpu_var()s, a cacheline, and a memory barrier, in the fastpath. Should
save a cycle or two...

---
Index: linux-2.6/arch/powerpc/kernel/irq.c
===================================================================
--- linux-2.6.orig/arch/powerpc/kernel/irq.c
+++ linux-2.6/arch/powerpc/kernel/irq.c
@@ -406,8 +406,6 @@ void do_softirq(void)
 
 static LIST_HEAD(irq_hosts);
 static DEFINE_SPINLOCK(irq_big_lock);
-static DEFINE_PER_CPU(unsigned int, irq_radix_reader);
-static unsigned int irq_radix_writer;
 struct irq_map_entry irq_map[NR_IRQS];
 static unsigned int irq_virq_count = NR_IRQS;
 static struct irq_host *irq_default_host;
@@ -550,57 +548,6 @@ void irq_set_virq_count(unsigned int cou
 		irq_virq_count = count;
 }
 
-/* radix tree not lockless safe ! we use a brlock-type mecanism
- * for now, until we can use a lockless radix tree
- */
-static void irq_radix_wrlock(unsigned long *flags)
-{
-	unsigned int cpu, ok;
-
-	spin_lock_irqsave(&irq_big_lock, *flags);
-	irq_radix_writer = 1;
-	smp_mb();
-	do {
-		barrier();
-		ok = 1;
-		for_each_possible_cpu(cpu) {
-			if (per_cpu(irq_radix_reader, cpu)) {
-				ok = 0;
-				break;
-			}
-		}
-		if (!ok)
-			cpu_relax();
-	} while(!ok);
-}
-
-static void irq_radix_wrunlock(unsigned long flags)
-{
-	smp_wmb();
-	irq_radix_writer = 0;
-	spin_unlock_irqrestore(&irq_big_lock, flags);
-}
-
-static void irq_radix_rdlock(unsigned long *flags)
-{
-	local_irq_save(*flags);
-	__get_cpu_var(irq_radix_reader) = 1;
-	smp_mb();
-	if (likely(irq_radix_writer == 0))
-		return;
-	__get_cpu_var(irq_radix_reader) = 0;
-	smp_wmb();
-	spin_lock(&irq_big_lock);
-	__get_cpu_var(irq_radix_reader) = 1;
-	spin_unlock(&irq_big_lock);
-}
-
-static void irq_radix_rdunlock(unsigned long flags)
-{
-	__get_cpu_var(irq_radix_reader) = 0;
-	local_irq_restore(flags);
-}
-
 static int irq_setup_virq(struct irq_host *host, unsigned int virq,
 			    irq_hw_number_t hwirq)
 {
@@ -791,9 +738,9 @@ void irq_dispose_mapping(unsigned int vi
 		/* Check if radix tree allocated yet */
 		if (host->revmap_data.tree.gfp_mask == 0)
 			break;
-		irq_radix_wrlock(&flags);
+		spin_lock_irqsave(&irq_big_lock, flags);
 		radix_tree_delete(&host->revmap_data.tree, hwirq);
-		irq_radix_wrunlock(flags);
+		spin_unlock_irqrestore(&irq_big_lock, flags);
 		break;
 	}
 
@@ -861,9 +808,9 @@ unsigned int irq_radix_revmap(struct irq
 		return irq_find_mapping(host, hwirq);
 
 	/* Now try to resolve */
-	irq_radix_rdlock(&flags);
+	rcu_read_lock();
 	ptr = radix_tree_lookup(tree, hwirq);
-	irq_radix_rdunlock(flags);
+	rcu_read_unlock();
 
 	/* Found it, return */
 	if (ptr) {
@@ -874,9 +821,9 @@ unsigned int irq_radix_revmap(struct irq
 	/* If not there, try to insert it */
 	virq = irq_find_mapping(host, hwirq);
 	if (virq != NO_IRQ) {
-		irq_radix_wrlock(&flags);
+		spin_lock_irqsave(&irq_big_lock, flags);
 		radix_tree_insert(tree, hwirq, &irq_map[virq]);
-		irq_radix_wrunlock(flags);
+		spin_unlock_irqrestore(&irq_big_lock, flags);
 	}
 	return virq;
 }
@@ -989,12 +936,12 @@ static int irq_late_init(void)
 	struct irq_host *h;
 	unsigned long flags;
 
-	irq_radix_wrlock(&flags);
+	spin_lock_irqsave(&irq_big_lock, flags);
 	list_for_each_entry(h, &irq_hosts, link) {
 		if (h->revmap_type == IRQ_HOST_MAP_TREE)
 			INIT_RADIX_TREE(&h->revmap_data.tree, GFP_ATOMIC);
 	}
-	irq_radix_wrunlock(flags);
+	spin_unlock_irqrestore(&irq_big_lock, flags);
 
 	return 0;
 }

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox