The location code fix which is included in OFED-1.3-rc1 openibd script fails on 
rhel-4.5, because the /proc/ppc64/ofdt
does not provide "update_property" functionallity. So we have to workaround 
this missing function call.If two devices 
have the same location code and we are running on rhel-4.5, we will first save 
all properties of this node, then delete the node
and add the node again with an updated location code. This patch adds this 
workaround in openibd script.
On all other kernels and distributions the original functionallity is unchanged.

Signed-off-by: Stefan Roscher <stefan.roscher at de.ibm.com>
---

 openibd |   35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)


--- ofa_kernel-1.3_old/ofed_scripts/openibd     2007-12-12 06:45:57.000000000 
-0500
+++ ofa_kernel-1.3_new/ofed_scripts/openibd     2007-12-20 10:34:09.000000000 
-0500
@@ -556,7 +556,7 @@ need_location_code_fix()
        2.6.9-*.EL*)
                sub=$(echo $KVERSION | cut -d"-" -f2 | cut -d"." -f1)
                if [ $sub -lt 62 ]; then
-                       return 0;
+                       return 2;
                fi
        ;;
        2.6.16.*-*-*)
@@ -587,12 +587,14 @@ fix_location_codes()
        # ppc64 only:
        # Fix duplicate location codes on kernels where ibmebus can't handle 
them
 
-       if ! need_location_code_fix; then return 0; fi
+       need_location_code_fix
+       ret=$?
+       if  [ $ret = 1 ]; then return 0; fi
        if ! [ -d /proc/device-tree -a -f /proc/ppc64/ofdt ]; then return 0; fi
 
        local i=1 phandle lcode len
        # output all duplicate location codes and their devices
-       for attr in $(find /proc/device-tree -wholename "[EMAIL 
PROTECTED]/ibm,loc-code"); do
+       for attr in $(find /proc/device-tree -name "ibm,loc-code" | grep 
"lh.a"); do
                echo -e $(dirname $attr)"\t"$(cat $attr)
        done | sort -k2 | uniq -f1 --all-repeated=separate | cut -f1 | while 
read dev; do
                if [ -n "$dev" ]; then
@@ -600,9 +602,32 @@ fix_location_codes()
                        phandle=$(hexdump -e '8 "%u"' $dev/ibm,phandle)
                        lcode=$(cat $dev/ibm,loc-code)-I$i
                        len=$(echo -n "$lcode" | wc -c)
-                       # echo "$dev -> $lcode"
-                       echo -n "update_property $phandle ibm,loc-code $len 
$lcode" > /proc/ppc64/ofdt
+                       node=${dev#/proc/device-tree}
+
+                       # kernel-2.6.9 don't provide "update_property"
+                       if [ ! -z "$(echo -n "$node" | grep "lhca")" ]; then
+                               if [ $ret = 2 ]; then
+                                       echo -n "add_node $node" > /tmp/addnode
+                                       cd $dev
+                                       for a in *; do
+                                               SIZE=$(stat -c%s $a)
+                                               if [ "$a" = "ibm,loc-code" ] ; 
then
+                                                       echo -n " $a $len 
$lcode" >> /tmp/addnode
+                                               elif [ "$a" = "interrupts" ] ; 
then
+                                                       echo -n " $a 0 " >> 
/tmp/addnode
+                                               else
+                                                       echo -n " $a $SIZE " >> 
/tmp/addnode
+                                                       cat $a >> /tmp/addnode
+                                               fi
+                                       done
+                                       echo -n "remove_node $node" > 
/proc/ppc64/ofdt
+                                       cat /tmp/addnode > /proc/ppc64/ofdt
+                                       rm -rf /tmp/addnode
+                               else
+                                       echo -n "update_property $phandle 
ibm,loc-code $len $lcode" > /proc/ppc64/ofdt
+                               fi
                        i=$(($i + 1))
+                       fi
                else
                        # empty line means new group -- reset i
                        i=1
_______________________________________________
ewg mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ewg

Reply via email to